void APP_Run(void){ /* SD card detection: PTE6 with pull-down! */ PORT_PDD_SetPinPullSelect(PORTE_BASE_PTR, 6, PORT_PDD_PULL_DOWN); PORT_PDD_SetPinPullEnable(PORTE_BASE_PTR, 6, PORT_PDD_PULL_ENABLE); if (FAT1_Init()!=ERR_OK) { /* initialize FAT driver */ Err(); } if (FAT1_mount(&fileSystemObject, (const TCHAR*)"0", 1) != FR_OK) { /* mount file system */ Err(); } initH3LI(); /* init accelerometer */ startLog(); /* start the logger */ while(counter<((MEASDUR/TICK_MS)-1)){ isNewDataAvailable(Z_AXIS_DA, &newDataAvailableFlag); /* check if new data available */ if(newDataAvailableFlag == TRUE){ logAccData(); /* read sensor and save on SD card */ } dataOverrun(Z_AXIS_OR, &dataOverrunFlag); /* data overrun? */ if(dataOverrunFlag == TRUE){ count_or++; /* count overruns */ } } stopLog(); /* stop the logger */ TI2_Disable(); /* disable the counter */ LED_G_Off(); }
static portTASK_FUNCTION(SDTask, pvParameters) { bool cardMounted = FALSE; static FAT1_FATFS fileSystemObject; (void)pvParameters; /* not used */ FAT1_Init(); /* initialize FAT module */ for(;;) { (void)FAT1_CheckCardPresence(&cardMounted, (unsigned char*)"0" /*volume*/, &fileSystemObject, CLS1_GetStdio()); FRTOS1_vTaskDelay(pdMS_TO_TICKS(50)); } }
static void DiskTest(void) { CLS1_ConstStdIOTypePtr io; io = CLS1_GetStdio(); FAT1_Init(); CLS1_SendStr((unsigned char*)"Waiting for disk to be inserted...\r\n", io->stdOut); while(!FAT1_isDiskPresent()) { /* wait until card is present */ } CLS1_SendStr((unsigned char*)"Mounting File system...\r\n", io->stdOut); FAT1_mount(0, &fileSystemObject); /* mount file system */ (void)Test(io); CLS1_SendStr((unsigned char*)"Finished test...\r\n", io->stdOut); for(;;) { LED2_Neg(); WAIT1_Waitms(100); } }
static void DiskTest(void) { CLS1_ConstStdIOTypePtr io; io = CLS1_GetStdio(); if (FAT1_Init()!=ERR_OK) { CLS1_SendStr((unsigned char*)"Failed FatFS initialization!\r\n", io->stdErr); return; } CLS1_SendStr((unsigned char*)"Waiting for disk to be inserted...\r\n", io->stdOut); while(!FAT1_isDiskPresent((uint8_t*)"0")) { /* wait until card is present */ } CLS1_SendStr((unsigned char*)"Mounting File system...\r\n", io->stdOut); if (FAT1_mount(&fileSystemObject, (const TCHAR*)"0", 1) != FR_OK) { /* mount file system */ CLS1_SendStr((unsigned char*)"Failed FatFS initialization!\r\n", io->stdErr); return; } (void)Test(io); CLS1_SendStr((unsigned char*)"Finished test...\r\n", io->stdOut); }
static portTASK_FUNCTION(ShellTask, pvParameters) { #if PL_HAS_RSTDIO static unsigned char radio_cmd_buf[48]; CLS1_ConstStdIOType *ioRemote = RSTDIO_GetStdioRx(); #endif #if CLS1_DEFAULT_SERIAL CLS1_ConstStdIOTypePtr ioLocal = CLS1_GetStdio(); #endif #if PL_HAS_SD_CARD bool cardMounted = FALSE; static FAT1_FATFS fileSystemObject; #endif (void)pvParameters; /* not used */ #if CLS1_DEFAULT_SERIAL (void)CLS1_ParseWithCommandTable((unsigned char*)CLS1_CMD_HELP, ioLocal, CmdParserTable); #endif #if PL_HAS_SD_CARD if (FAT1_Init()!=ERR_OK) { //CLS1_SendStr((uint8_t*)"FatFS Initialization failed. No card inserted?\r\n", ioLocal->stdErr); } #endif for(;;) { #if PL_HAS_SD_CARD (void)FAT1_CheckCardPresence(&cardMounted, 0 /*volume*/, &fileSystemObject, CLS1_GetStdio()); #endif #if CLS1_DEFAULT_SERIAL (void)CLS1_ReadAndParseWithCommandTable(localConsole_buf, sizeof(localConsole_buf), ioLocal, CmdParserTable); #endif #if PL_HAS_RSTDIO RSTDIO_Print(ioLocal); /* dispatch incoming messages */ (void)CLS1_ReadAndParseWithCommandTable(radio_cmd_buf, sizeof(radio_cmd_buf), ioRemote, CmdParserTable); #endif #if PL_HAS_BLUETOOTH (void)CLS1_ReadAndParseWithCommandTable(bluetooth_buf, sizeof(bluetooth_buf), &BT_stdio, CmdParserTable); #endif FRTOS1_vTaskDelay(50/portTICK_RATE_MS); } /* for */ }
static portTASK_FUNCTION(ShellTask, pvParameters) { #if PL_HAS_SD_CARD bool cardMounted = FALSE; static FAT1_FATFS fileSystemObject; #endif unsigned char buf[48]; (void)pvParameters; /* not used */ buf[0] = '\0'; (void)CLS1_ParseWithCommandTable((unsigned char*)CLS1_CMD_HELP, CLS1_GetStdio(), CmdParserTable); #if PL_HAS_SD_CARD FAT1_Init(); #endif for(;;) { #if PL_HAS_SD_CARD (void)FAT1_CheckCardPresence(&cardMounted, 0 /* volume */, &fileSystemObject, CLS1_GetStdio()); #endif (void)CLS1_ReadAndParseWithCommandTable(buf, sizeof(buf), CLS1_GetStdio(), CmdParserTable); FRTOS1_vTaskDelay(50/portTICK_RATE_MS); LED2_Neg(); } }
void APP_Run(void) { int16_t x,y,z; uint8_t res; #define ACCEL_VAL 2000 res = FX1_Enable(); /* enable accelerometer (just in case) */ if (res!=ERR_OK) { Err(); } if (FAT1_Init()!=ERR_OK) { Err(); } if (FAT1_mount(0, &fileSystemObject) != FR_OK) { /* mount file system */ Err(); } for(;;) { //LED1_Neg(); x = FX1_GetX(); y = FX1_GetY(); z = FX1_GetZ(); if (x>ACCEL_VAL || x<-ACCEL_VAL) { LED1_On(); LED2_Off(); LED3_Off(); } else if (y>ACCEL_VAL || y<-ACCEL_VAL) { LED1_Off(); LED2_On(); LED3_Off(); } else if (z>ACCEL_VAL || z<-ACCEL_VAL) { LED1_Off(); LED2_Off(); LED3_On(); } LogToFile(x, y, z); WAIT1_Waitms(1000); } }
static portTASK_FUNCTION(ShellTask, pvParameters) { static unsigned char localConsole_buf[48]; #if PL_HAS_RSTDIO static unsigned char radio_cmd_buf[48]; CLS1_ConstStdIOType *ioRemote = RSTDIO_GetStdioRx(); #endif #if PL_HAS_SEGGER_RTT static unsigned char rtt_cmd_buf[48]; #endif #if CLS1_DEFAULT_SERIAL CLS1_ConstStdIOTypePtr ioLocal = CLS1_GetStdio(); #endif #if PL_HAS_SD_CARD bool cardMounted = FALSE; static FAT1_FATFS fileSystemObject; #endif (void)pvParameters; /* not used */ #if PL_HAS_BLUETOOTH bluetooth_buf[0] = '\0'; #endif #if CLS1_DEFAULT_SERIAL localConsole_buf[0] = '\0'; #endif #if PL_HAS_RSTDIO radio_cmd_buf[0] = '\0'; #endif #if PL_HAS_SEGGER_RTT rtt_cmd_buf[0] = '\0'; #endif #if CLS1_DEFAULT_SERIAL (void)CLS1_ParseWithCommandTable((unsigned char*)CLS1_CMD_HELP, ioLocal, CmdParserTable); #endif #if PL_HAS_SEGGER_RTT (void)CLS1_ParseWithCommandTable((unsigned char*)CLS1_CMD_HELP, &RTT_stdio, CmdParserTable); #endif #if PL_HAS_SD_CARD FAT1_Init(); #endif for(;;) { #if PL_HAS_SD_CARD (void)FAT1_CheckCardPresence(&cardMounted, (unsigned char*)"0" /*volume*/, &fileSystemObject, CLS1_GetStdio()); #endif #if CLS1_DEFAULT_SERIAL (void)CLS1_ReadAndParseWithCommandTable(localConsole_buf, sizeof(localConsole_buf), ioLocal, CmdParserTable); #endif #if PL_HAS_SEGGER_RTT (void)CLS1_ReadAndParseWithCommandTable(rtt_cmd_buf, sizeof(rtt_cmd_buf), &RTT_stdio, CmdParserTable); #endif #if PL_HAS_RSTDIO RSTDIO_Print(ioLocal); /* dispatch incoming messages */ (void)CLS1_ReadAndParseWithCommandTable(radio_cmd_buf, sizeof(radio_cmd_buf), ioRemote, CmdParserTable); #endif #if PL_HAS_BLUETOOTH (void)CLS1_ReadAndParseWithCommandTable(bluetooth_buf, sizeof(bluetooth_buf), &BT_stdio, CmdParserTable); #endif #if PL_HAS_USB_CDC (void)CLS1_ReadAndParseWithCommandTable(cdc_buf, sizeof(cdc_buf), &CDC_stdio, CmdParserTable); #endif FRTOS1_vTaskDelay(50/portTICK_RATE_MS); } /* for */ }