avec dfu
Fork of Utils by
Utils.h@8:23fd400c4edd, 2018-02-23 (annotated)
- Committer:
- POTLESS_2
- Date:
- Fri Feb 23 13:11:14 2018 +0000
- Revision:
- 8:23fd400c4edd
- Parent:
- 7:1bd8b236feb1
- Child:
- 9:fa2818db80cf
nouvelles fonctions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
POTLESS_2 | 0:794c15bd30b0 | 1 | #ifndef CHANGEME_H_ |
POTLESS_2 | 0:794c15bd30b0 | 2 | #define CHANGEME_H_ |
POTLESS_2 | 0:794c15bd30b0 | 3 | |
POTLESS_2 | 0:794c15bd30b0 | 4 | #include "mbed.h" |
POTLESS_2 | 0:794c15bd30b0 | 5 | #include <string> |
POTLESS_2 | 0:794c15bd30b0 | 6 | |
POTLESS_2 | 0:794c15bd30b0 | 7 | #include "FATFileSystem.h" |
POTLESS_2 | 0:794c15bd30b0 | 8 | #include "SDBlockDevice.h" |
POTLESS_2 | 6:8bae97034114 | 9 | //#include "SPIFBlockDevice.h" |
POTLESS_2 | 8:23fd400c4edd | 10 | |
POTLESS_2 | 0:794c15bd30b0 | 11 | #include <stdio.h> |
POTLESS_2 | 0:794c15bd30b0 | 12 | #include <errno.h> |
POTLESS_2 | 0:794c15bd30b0 | 13 | |
POTLESS_2 | 6:8bae97034114 | 14 | //PIN OUT Flash |
POTLESS_2 | 6:8bae97034114 | 15 | #define Flash_MOSI PA_7 |
POTLESS_2 | 6:8bae97034114 | 16 | #define Flash_MISO PA_6 |
POTLESS_2 | 6:8bae97034114 | 17 | #define Flash_SCK PA_5 |
POTLESS_2 | 6:8bae97034114 | 18 | #define Flash_CS PB_6 |
POTLESS_2 | 6:8bae97034114 | 19 | |
POTLESS_2 | 6:8bae97034114 | 20 | #define DEBUG_UTILS 0 |
POTLESS_2 | 6:8bae97034114 | 21 | |
POTLESS_2 | 6:8bae97034114 | 22 | #if DEBUG_UTILS |
POTLESS_2 | 6:8bae97034114 | 23 | #define DEBUG_U(...) { printf(__VA_ARGS__); fflush(stdout);} |
POTLESS_2 | 6:8bae97034114 | 24 | #else |
POTLESS_2 | 6:8bae97034114 | 25 | #define DEBUG_U(...) |
POTLESS_2 | 6:8bae97034114 | 26 | #endif |
POTLESS_2 | 0:794c15bd30b0 | 27 | |
POTLESS_2 | 0:794c15bd30b0 | 28 | /** Utils class. |
POTLESS_2 | 0:794c15bd30b0 | 29 | * Rassemblant des fonctions annexes pour le fonctionnement de l'ARNSRS. |
POTLESS_2 | 0:794c15bd30b0 | 30 | * |
POTLESS_2 | 0:794c15bd30b0 | 31 | * A besoin des libs suivantes : |
POTLESS_2 | 0:794c15bd30b0 | 32 | * |
POTLESS_2 | 0:794c15bd30b0 | 33 | * - FATFileSystem |
POTLESS_2 | 0:794c15bd30b0 | 34 | * |
POTLESS_2 | 6:8bae97034114 | 35 | * - SPIFBlockDevice |
POTLESS_2 | 0:794c15bd30b0 | 36 | * |
POTLESS_2 | 0:794c15bd30b0 | 37 | * |
POTLESS_2 | 0:794c15bd30b0 | 38 | * Constantes de l'application : |
POTLESS_2 | 0:794c15bd30b0 | 39 | * |
POTLESS_2 | 6:8bae97034114 | 40 | * Pin out Flash : |
POTLESS_2 | 6:8bae97034114 | 41 | * |
POTLESS_2 | 6:8bae97034114 | 42 | * - Flash_MOSI PA_7 |
POTLESS_2 | 6:8bae97034114 | 43 | * |
POTLESS_2 | 6:8bae97034114 | 44 | * - Flash_MISO PA_6 |
POTLESS_2 | 6:8bae97034114 | 45 | * |
POTLESS_2 | 6:8bae97034114 | 46 | * - Flash_SCK PA_5 |
POTLESS_2 | 6:8bae97034114 | 47 | * |
POTLESS_2 | 6:8bae97034114 | 48 | * - Flash_CS PB_6 |
POTLESS_2 | 6:8bae97034114 | 49 | * |
POTLESS_2 | 6:8bae97034114 | 50 | * Liste des erreurs possibles sur les fonctions Flash : |
POTLESS_2 | 0:794c15bd30b0 | 51 | * |
POTLESS_2 | 6:8bae97034114 | 52 | * |
POTLESS_2 | 6:8bae97034114 | 53 | * (0) no error |
POTLESS_2 | 6:8bae97034114 | 54 | * |
POTLESS_2 | 6:8bae97034114 | 55 | * (1) A hard error occurred in the low level disk I/O layer |
POTLESS_2 | 6:8bae97034114 | 56 | * |
POTLESS_2 | 6:8bae97034114 | 57 | * (2) Assertion failed |
POTLESS_2 | 6:8bae97034114 | 58 | * |
POTLESS_2 | 6:8bae97034114 | 59 | * (3) The physical drive cannot work |
POTLESS_2 | 6:8bae97034114 | 60 | * |
POTLESS_2 | 6:8bae97034114 | 61 | * (4) Could not find the file |
POTLESS_2 | 6:8bae97034114 | 62 | * |
POTLESS_2 | 6:8bae97034114 | 63 | * (5) Could not find the path |
POTLESS_2 | 0:794c15bd30b0 | 64 | * |
POTLESS_2 | 6:8bae97034114 | 65 | * (6) The path name format is invalid |
POTLESS_2 | 6:8bae97034114 | 66 | * |
POTLESS_2 | 6:8bae97034114 | 67 | * (7) Access denied due to prohibited access or directory full, Permission denied |
POTLESS_2 | 6:8bae97034114 | 68 | * |
POTLESS_2 | 6:8bae97034114 | 69 | * (8) Access denied due to prohibited access, File exists |
POTLESS_2 | 6:8bae97034114 | 70 | * |
POTLESS_2 | 6:8bae97034114 | 71 | * (9) The file/directory object is invalid, Bad address |
POTLESS_2 | 6:8bae97034114 | 72 | * |
POTLESS_2 | 6:8bae97034114 | 73 | * (10) The physical drive is write protected |
POTLESS_2 | 6:8bae97034114 | 74 | * |
POTLESS_2 | 6:8bae97034114 | 75 | * (11) The logical drive number is invalid |
POTLESS_2 | 6:8bae97034114 | 76 | * |
POTLESS_2 | 6:8bae97034114 | 77 | * (12) The volume has no work area, No such device or address |
POTLESS_2 | 0:794c15bd30b0 | 78 | * |
POTLESS_2 | 6:8bae97034114 | 79 | * (13) There is no valid FAT volume, No such file or directory |
POTLESS_2 | 6:8bae97034114 | 80 | * |
POTLESS_2 | 6:8bae97034114 | 81 | * (14) The f_mkfs() aborted due to any parameter error |
POTLESS_2 | 6:8bae97034114 | 82 | * |
POTLESS_2 | 6:8bae97034114 | 83 | * (15) Could not get a grant to access the volume within defined period, Bad file number |
POTLESS_2 | 0:794c15bd30b0 | 84 | * |
POTLESS_2 | 6:8bae97034114 | 85 | * (16) The operation is rejected according to the file sharing policy, Permission denied |
POTLESS_2 | 6:8bae97034114 | 86 | * |
POTLESS_2 | 6:8bae97034114 | 87 | * (17) LFN working buffer could not be allocated, Not enough space |
POTLESS_2 | 0:794c15bd30b0 | 88 | * |
POTLESS_2 | 6:8bae97034114 | 89 | * (18) Number of open files > _FS_LOCK, Too many open files in system |
POTLESS_2 | 6:8bae97034114 | 90 | * |
POTLESS_2 | 6:8bae97034114 | 91 | * (19) Given parameter is invalid, Exec format error |
POTLESS_2 | 0:794c15bd30b0 | 92 | */ |
POTLESS_2 | 0:794c15bd30b0 | 93 | |
POTLESS_2 | 0:794c15bd30b0 | 94 | class UTILS |
POTLESS_2 | 0:794c15bd30b0 | 95 | { |
POTLESS_2 | 0:794c15bd30b0 | 96 | |
POTLESS_2 | 0:794c15bd30b0 | 97 | public: |
POTLESS_2 | 0:794c15bd30b0 | 98 | |
POTLESS_2 | 0:794c15bd30b0 | 99 | /**Remapper une valeur dans une autre échelle. |
POTLESS_2 | 0:794c15bd30b0 | 100 | * @param float Valeur à remapper |
POTLESS_2 | 0:794c15bd30b0 | 101 | * @param float Minimum de l'échelle de la valeur |
POTLESS_2 | 0:794c15bd30b0 | 102 | * @param float Maximum de l'échelle de la valeur |
POTLESS_2 | 0:794c15bd30b0 | 103 | * @param float Minimum de la nouvelle échelle |
POTLESS_2 | 0:794c15bd30b0 | 104 | * @param float Maximum de de la nouvelle échelle |
POTLESS_2 | 0:794c15bd30b0 | 105 | */ |
POTLESS_2 | 0:794c15bd30b0 | 106 | static float Remap(float x, float in_min, float in_max, float out_min, float out_max); |
POTLESS_2 | 0:794c15bd30b0 | 107 | |
POTLESS_2 | 0:794c15bd30b0 | 108 | /**Contraint une valeur entre deux limites. |
POTLESS_2 | 0:794c15bd30b0 | 109 | * @param float Valeur à contraindre |
POTLESS_2 | 0:794c15bd30b0 | 110 | * @param float Minimum de la valeur |
POTLESS_2 | 0:794c15bd30b0 | 111 | * @param float Maximum de la valeur |
POTLESS_2 | 0:794c15bd30b0 | 112 | */ |
POTLESS_2 | 0:794c15bd30b0 | 113 | static float constrain(float x, float a, float b); |
POTLESS_2 | 0:794c15bd30b0 | 114 | |
POTLESS_2 | 8:23fd400c4edd | 115 | /**Fonction d'affichage des infos de la Flash. |
POTLESS_2 | 8:23fd400c4edd | 116 | */ |
POTLESS_2 | 8:23fd400c4edd | 117 | static void Flash_Infos(); |
POTLESS_2 | 8:23fd400c4edd | 118 | |
POTLESS_2 | 6:8bae97034114 | 119 | /**Fonction de stockage valeur sur la Flash. |
POTLESS_2 | 0:794c15bd30b0 | 120 | * @param float Val_To_Store, la valeur à stocker |
POTLESS_2 | 0:794c15bd30b0 | 121 | * @param char* Nom du fichier ou stocker cette valeur |
POTLESS_2 | 0:794c15bd30b0 | 122 | */ |
POTLESS_2 | 0:794c15bd30b0 | 123 | static void Store_A_Val(float Val_To_Store, char* File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 124 | |
POTLESS_2 | 6:8bae97034114 | 125 | /**Fonction de récupération d'une valeur stockée sur la Flash. |
POTLESS_2 | 0:794c15bd30b0 | 126 | * @param char* Nom du fichier ou stocker cette valeur |
POTLESS_2 | 0:794c15bd30b0 | 127 | * @returns |
POTLESS_2 | 0:794c15bd30b0 | 128 | * valeur de calibration des capteurs O2 |
POTLESS_2 | 0:794c15bd30b0 | 129 | */ |
POTLESS_2 | 0:794c15bd30b0 | 130 | static float Read_A_Val(char* File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 131 | |
POTLESS_2 | 6:8bae97034114 | 132 | /**Fonction d'enregistrement d'une chaine de charatères sur la Flash. |
POTLESS_2 | 0:794c15bd30b0 | 133 | * @param char* To_Store, chaine de charactères |
POTLESS_2 | 0:794c15bd30b0 | 134 | * @param char* Nom du fichier, s'il existe il est ouvert, sinon il est créé |
POTLESS_2 | 0:794c15bd30b0 | 135 | */ |
POTLESS_2 | 6:8bae97034114 | 136 | static void Write_Flash_File(char* To_Store, char* File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 137 | |
POTLESS_2 | 6:8bae97034114 | 138 | /**Fonction de lecture d'un fichier sur la Flash. |
POTLESS_2 | 0:794c15bd30b0 | 139 | * @param char* Nom du fichier |
POTLESS_2 | 0:794c15bd30b0 | 140 | */ |
POTLESS_2 | 6:8bae97034114 | 141 | static void Read_Flash_File(char* File_Name); |
POTLESS_2 | 8:23fd400c4edd | 142 | |
POTLESS_2 | 8:23fd400c4edd | 143 | /**Fonction de renvoie de la taille d'un fichier. |
POTLESS_2 | 8:23fd400c4edd | 144 | * @param char* Nom du fichier |
POTLESS_2 | 8:23fd400c4edd | 145 | */ |
POTLESS_2 | 8:23fd400c4edd | 146 | static void Get_File_Size(char* File_Name); |
POTLESS_2 | 8:23fd400c4edd | 147 | |
POTLESS_2 | 8:23fd400c4edd | 148 | /**Fonction de renvoie des infos d'un fichier. |
POTLESS_2 | 8:23fd400c4edd | 149 | * @param char* Nom du fichier |
POTLESS_2 | 8:23fd400c4edd | 150 | */ |
POTLESS_2 | 8:23fd400c4edd | 151 | static void Get_File_Infos(char* File_Name); |
POTLESS_2 | 8:23fd400c4edd | 152 | |
POTLESS_2 | 8:23fd400c4edd | 153 | /**Fonction de renvoie des infos d'un fichier. |
POTLESS_2 | 8:23fd400c4edd | 154 | * @param char* Nom du fichier |
POTLESS_2 | 8:23fd400c4edd | 155 | */ |
POTLESS_2 | 8:23fd400c4edd | 156 | static void Get_File_Infos_bis(char* File_Name); |
POTLESS_2 | 8:23fd400c4edd | 157 | |
POTLESS_2 | 6:8bae97034114 | 158 | /**Fonction d'éffaçage d'un fichier sur la Flash. |
POTLESS_2 | 8:23fd400c4edd | 159 | * @param char* Nom du fichier à effacer |
POTLESS_2 | 0:794c15bd30b0 | 160 | */ |
POTLESS_2 | 6:8bae97034114 | 161 | static void Delete_Flash_File(char* File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 162 | |
POTLESS_2 | 6:8bae97034114 | 163 | /**Fonction nettoyage de la Flash. |
POTLESS_2 | 6:8bae97034114 | 164 | */ |
POTLESS_2 | 6:8bae97034114 | 165 | static void Clean_Flash(); |
POTLESS_2 | 6:8bae97034114 | 166 | |
POTLESS_2 | 6:8bae97034114 | 167 | /**Fonction d'éffaçage d'un fichier sur la Flash. |
POTLESS_2 | 0:794c15bd30b0 | 168 | * @param char* Nom du fichier à effacer |
POTLESS_2 | 0:794c15bd30b0 | 169 | * @param char* Nouveau Nom du fichier |
POTLESS_2 | 0:794c15bd30b0 | 170 | */ |
POTLESS_2 | 6:8bae97034114 | 171 | static void Rename_Flash_File(char* Old_File_Name, char* New_File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 172 | |
POTLESS_2 | 6:8bae97034114 | 173 | /**Fonction montage de la Flash. |
POTLESS_2 | 0:794c15bd30b0 | 174 | */ |
POTLESS_2 | 6:8bae97034114 | 175 | static void Mount_Flash(); |
POTLESS_2 | 0:794c15bd30b0 | 176 | |
POTLESS_2 | 6:8bae97034114 | 177 | /**Fonction demontage de la Flash. |
POTLESS_2 | 0:794c15bd30b0 | 178 | */ |
POTLESS_2 | 6:8bae97034114 | 179 | static void UnMount_Flash(); |
POTLESS_2 | 0:794c15bd30b0 | 180 | |
POTLESS_2 | 6:8bae97034114 | 181 | /**Fonction formatage de la Flash. |
POTLESS_2 | 0:794c15bd30b0 | 182 | */ |
POTLESS_2 | 6:8bae97034114 | 183 | static void Format_Flash(); |
POTLESS_2 | 2:5af7a1fb1903 | 184 | |
POTLESS_2 | 2:5af7a1fb1903 | 185 | /**Fonction DIR. |
POTLESS_2 | 2:5af7a1fb1903 | 186 | * @param char* Nom du répertoire |
POTLESS_2 | 2:5af7a1fb1903 | 187 | */ |
POTLESS_2 | 6:8bae97034114 | 188 | static void Dir_Flash(char* Dir_Name = ""); |
POTLESS_2 | 3:01677db45b2a | 189 | |
POTLESS_2 | 3:01677db45b2a | 190 | /**Fonction de numérotage des fichiers log. |
POTLESS_2 | 3:01677db45b2a | 191 | * @returns |
POTLESS_2 | 3:01677db45b2a | 192 | * Index du nouveau fichier log |
POTLESS_2 | 3:01677db45b2a | 193 | */ |
POTLESS_2 | 3:01677db45b2a | 194 | static int File_Index(); |
POTLESS_2 | 3:01677db45b2a | 195 | |
POTLESS_2 | 3:01677db45b2a | 196 | /**Fonction de test si un fichier existe. |
POTLESS_2 | 3:01677db45b2a | 197 | * @param char* Nom du fichier |
POTLESS_2 | 3:01677db45b2a | 198 | * @returns |
POTLESS_2 | 3:01677db45b2a | 199 | * true si le fichier existe, false s'il n'existe pas |
POTLESS_2 | 3:01677db45b2a | 200 | */ |
POTLESS_2 | 5:0f3b6e6677ef | 201 | static bool File_Exist(string File_Name); |
POTLESS_2 | 6:8bae97034114 | 202 | |
POTLESS_2 | 6:8bae97034114 | 203 | /**Fonction d'affichage du menu d'aide. |
POTLESS_2 | 6:8bae97034114 | 204 | */ |
POTLESS_2 | 6:8bae97034114 | 205 | static void Help(); |
POTLESS_2 | 3:01677db45b2a | 206 | |
POTLESS_2 | 0:794c15bd30b0 | 207 | private: |
POTLESS_2 | 0:794c15bd30b0 | 208 | //Rien... |
POTLESS_2 | 0:794c15bd30b0 | 209 | }; |
POTLESS_2 | 0:794c15bd30b0 | 210 | #endif |