Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
user.h
00001 /******************************************************************************* 00002 user.h -> fichier de fonctions 00003 00004 Gestion des 2 DELs de la carte CPU 00005 Mesure tension batterie 00006 Mesure courant panneaux solaires 00007 Mesure température 00008 *******************************************************************************/ 00009 // Initialistion du µC, Tests divers 00010 /** 00011 * @param null 00012 */ 00013 void Init_System(void) { 00014 // Hello World 00015 pc.printf("\r\nIniSat V2 : TP5\r\n\n"); 00016 00017 // Test de l'horloge Systeme 00018 // pc.printf("Horloge CPU a %d Hz\r\n", SystemCoreClock); 00019 00020 xbee.baud(38400); 00021 } 00022 /******************************************************************************/ 00023 // Gestion des 2 Dels de la carte CPU 00024 Ticker Compteur_Led; 00025 uint16_t cmpt_led; 00026 uint8_t etat_led; 00027 enum {Off, Ro, Ve, Ro_Ve} couleur; 00028 00029 void Tache_Cmpt_Led(void) { 00030 cmpt_led++; 00031 if(cmpt_led >= 100) { // Période : 1 sec 00032 cmpt_led = 0; 00033 DEL_R = etat_led & 1; 00034 } 00035 else if(cmpt_led == 5) { 00036 DEL_R = 0; 00037 } 00038 else if(cmpt_led == 50) { 00039 DEL_V = etat_led & 2; 00040 } 00041 else if(cmpt_led == 60) { 00042 DEL_V = 0; 00043 } 00044 } 00045 00046 void Init_Led(void) { 00047 cmpt_led = 0; 00048 etat_led = 0; 00049 Compteur_Led.attach(&Tache_Cmpt_Led,0.01); // 10ms 00050 } 00051 00052 void Start_Led(void) { 00053 Compteur_Led.attach(&Tache_Cmpt_Led,0.01); // 10ms 00054 } 00055 00056 void Stop_Led(void) { 00057 Compteur_Led.detach(); 00058 } 00059 00060 void Set_Led(uint8_t couleur) { 00061 etat_led = couleur; 00062 } 00063 /******************************************************************************/ 00064 // Mesure de la tension de la batterie 00065 float mes_bat; 00066 00067 float Mes_Bat(void) { 00068 00069 mes_bat = batin.read()*4.59f + 0.31f; // 3.3 x 13.9/10 + 310mV(D2 carte EPS) 00070 return mes_bat; 00071 } 00072 00073 void Envoi_Mes_Bat(void) { 00074 00075 pc.printf("BAT: %.2f V\n",mes_bat); // Format pour Terminal (Putty) 00076 } 00077 00078 void XBee_Envoi_Mes_Bat(void) { 00079 00080 xbee.printf("#B%d\n",(uint16_t)(mes_bat*100)); // Format pour Supervision sans fil par XBee 00081 } 00082 /******************************************************************************/ 00083 // Mesure des courants des 2 panneaux solaires 00084 float mes_sp1, mes_sp2; 00085 00086 void Mes_SP(void) { 00087 00088 mes_sp1 = sp_1in.read()*165.0f; // 3.3 x 50 00089 mes_sp2 = sp_2in.read()*165.0f; // 3.3 x 50 00090 } 00091 00092 void Envoi_Mes_SP(void) { 00093 00094 pc.printf("SP1: %.1f mA\tSP2: %.1f mA\n",mes_sp1,mes_sp2); 00095 } 00096 /******************************************************************************/ 00097 // Fonction pour initialiser les fonctions précédentes 00098 00099 void Init_User_Fonctions(void) { 00100 00101 ctrl_reg = 1; // Pour mettre sous tension le moniteur de courant des Solar Panels 00102 Init_Led(); 00103 } 00104 // Fonction pour stopper les fonctions précédentes 00105 00106 void Stop_User_Fonctions(void) { 00107 00108 ctrl_reg = 0; 00109 Stop_Led(); 00110 } 00111 /******************************************************************************/ 00112 // Mesure de la température 00113 float mes_temp; 00114 00115 void Mes_Temp(void) { 00116 00117 mes_temp = (tempin.read()*3.3f-0.5f)/0.01f; // 3.3 x -500mV 00118 } 00119 00120 void Envoi_Mes_Temp(void) { 00121 00122 pc.printf("Temp: %.1f degC\r\n",mes_temp); // Mesure directe 00123 } 00124 00125 void XBee_Envoi_Mes_Temp(void) { 00126 00127 xbee.printf("#T%d\n",(uint16_t)(mes_temp*10)); // Supervision -> par XBee 00128 } 00129 /******************************************************************************/ 00130 00131
Generated on Mon Aug 15 2022 23:44:49 by
1.7.2