avec dfu

Fork of Utils by POTLESS

Committer:
POTLESS_2
Date:
Wed Feb 21 06:57:58 2018 +0000
Revision:
7:1bd8b236feb1
Parent:
6:8bae97034114
Child:
8:23fd400c4edd
quelques changements

Who changed what in which revision?

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