38 #include "ff_gen_drv.h" 39 #include "sd_diskio.h" 42 uint32_t byteswritten, bytesread;
47 volatile uint8_t SD_Log_Enabled = 0;
49 char newLine[] =
"\r\n";
51 extern void *LSM6DSM_X_0_handle;
52 extern void *LSM6DSM_G_0_handle;
53 extern void *LSM303AGR_M_0_handle;
54 extern void *LSM303AGR_X_0_handle;
55 extern void *LPS22HB_P_0_handle;
56 extern void *LPS22HB_T_0_handle;
57 extern void *HTS221_H_0_handle;
58 extern void *HTS221_T_0_handle;
68 if(FATFS_LinkDriver(&SD_Driver, SDPath) == 0)
71 if(f_mount(&SDFatFs, (TCHAR
const*)SDPath, 0) != FR_OK)
92 static uint16_t sdcard_file_counter = 0;
93 char header[] =
"T [ms],AccX [mg],AccY [mg],AccZ [mg],GyroX [mdps],GyroY [mdps],GyroZ [mdps],MagX [mgauss],MagY [mgauss],MagZ [mgauss],P [mB],T [�C],H [%]\r\n";
94 uint32_t byteswritten;
95 char file_name[30] = {0};
100 sprintf(file_name,
"%s%.3d%s",
"SensorTile_Log_N", sdcard_file_counter,
".csv");
101 sdcard_file_counter++;
105 if(f_open(&MyFile, (
char const*)file_name, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
107 sdcard_file_counter--;
111 if(f_write(&MyFile, (
const void*)&header,
sizeof(header)-1, (
void *)&byteswritten) != FR_OK)
118 uint8_t DATALOG_SD_writeBuf(
char *s, uint32_t size)
120 uint32_t byteswritten;
122 if(f_write(&MyFile, s, size, (
void *)&byteswritten) != FR_OK)
143 void DATALOG_SD_DeInit(
void)
145 FATFS_UnLinkDriver(SDPath);
155 uint32_t byteswritten;
156 f_write(&MyFile, (
const void*)&newLine, 2, (
void *)&byteswritten);
162 DrvStatusTypeDef ret = COMPONENT_OK;
164 mptr->ms_counter = HAL_GetTick();
168 mptr->acc.AXIS_X = 0;
169 mptr->acc.AXIS_Y = 0;
170 mptr->acc.AXIS_Z = 0;
171 ret = COMPONENT_ERROR;
176 mptr->gyro.AXIS_X = 0;
177 mptr->gyro.AXIS_Y = 0;
178 mptr->gyro.AXIS_Z = 0;
179 ret = COMPONENT_ERROR;
184 mptr->mag.AXIS_X = 0;
185 mptr->mag.AXIS_Y = 0;
186 mptr->mag.AXIS_Z = 0;
187 ret = COMPONENT_ERROR;
192 mptr->pressure = 0.0f;
193 ret = COMPONENT_ERROR;
198 mptr->humidity = 0.0f;
199 ret = COMPONENT_ERROR;
204 mptr->temperature = 0.0f;
205 ret = COMPONENT_ERROR;
219 void floatToInt(
float in, int32_t *out_int, int32_t *out_dec, int32_t dec_prec )
221 *out_int = (int32_t)in;
224 in = in - (float)(*out_int);
228 in = (float)(*out_int) - in;
230 *out_dec = (int32_t)trunc(in * pow(10, dec_prec));
uint8_t DATALOG_SD_Log_Enable(void)
Start SD-Card demo.
void BSP_LED_Off(Led_TypeDef Led)
Turns selected LED Off.
DrvStatusTypeDef BSP_HUMIDITY_Get_Hum(void *handle, float *humidity)
Get the humidity value.
DrvStatusTypeDef BSP_GYRO_Get_Axes(void *handle, SensorAxes_t *angular_velocity)
Get the gyroscope sensor axes.
DrvStatusTypeDef BSP_PRESSURE_Get_Press(void *handle, float *pressure)
Get the pressure value.
This file contains definitions for SensorTile.c file.
void DATALOG_SD_NewLine(void)
Write New Line to file.
Header for datalog_application.c module.
DrvStatusTypeDef BSP_MAGNETO_Get_Axes(void *handle, SensorAxes_t *magnetic_field)
Get the magnetometer sensor axes.
void DATALOG_SD_Log_Disable(void)
Disable SDCard Log.
DrvStatusTypeDef BSP_ACCELERO_Get_Axes(void *handle, SensorAxes_t *acceleration)
Get the accelerometer sensor axes.
void BSP_LED_On(Led_TypeDef Led)
Turns selected LED On.
DrvStatusTypeDef BSP_TEMPERATURE_Get_Temp(void *handle, float *temperature)
Get the temperature value.
void DATALOG_SD_Init(void)
Start SD-Card demo.
void floatToInt(float in, int32_t *out_int, int32_t *out_dec, int32_t dec_prec)
Splits a float into two integer values.
Header for usbd_cdc_interface.c file.