//! //! \fn main //! \brief 1) Initialize the microcontroller and the shared hardware resources //! of the board. //! 2) Launch the Ctrl Panel modules. //! 3) Start FreeRTOS. //! \return Should never occur. //! \note //! int main(void) { // Disable the WDT. // wdt_disable(); //** //** 1) Initialize the microcontroller and the shared hardware resources of the board. //** // switch to external oscillator 0 pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP); // Init USB & MACB clock. prv_clk_gen_start(); // initialize AT45DBX resources: GPIO, SPI and AT45DBX prv_at45dbx_resources_init(); #if SD_MMC_SPI_MEM == ENABLE prv_sd_mmc_resources_init(); #endif // Setup the LED's for output. LED_Off( LED0 ); LED_Off( LED1 ); LED_Off( LED2 ); LED_Off( LED3 ); LED_Off( LED4 ); LED_Off( LED5 ); LED_Off( LED6 ); LED_Off( LED7 ); // vParTestInitialise(); // Init the memory module. if (false == ctrl_access_init()) { // TODO: Add msg on LCD. // gpio_clr_gpio_pin( 60 ); while (1); } /* check if the AT45DBX mem is OK */ while (CTRL_GOOD != mem_test_unit_ready( LUN_ID_AT45DBX_MEM )) { // TODO: Add msg on LCD. // gpio_clr_gpio_pin( 61 ); } // Init the FAT navigation module. if (false == b_fsaccess_init()) { // TODO: Add msg on LCD. // gpio_clr_gpio_pin( 62 ); while (true); } // Init the time module. v_cptime_Init(); //** //** 2) Launch the Control Panel supervisor task that will in turn create all //** the necessary tasks. //** vSupervisor_Start( mainSUPERVISOR_TASK_PRIORITY ); //** //** 3) Start FreeRTOS. //** // Use preemptive scheduler define configUSE_PREEMPTION as 1 in portmacro.h vTaskStartScheduler(); /* Should never reach this point. */ while (true); }
void IBN_FileAccess (u8 nParamsGet_u8,u8 CMD_u8,u32 Param_u32) { s32 FileID_s32; s32 Ret_s32; // testtt[1000] = 4; if (0 == nParamsGet_u8) { CI_LocalPrintf ("File access\r\n"); CI_LocalPrintf (" 0 = Set lun 0\r\n"); CI_LocalPrintf (" 1 = Mount\r\n"); CI_LocalPrintf (" 2 = Show free space\r\n"); CI_LocalPrintf ("11 = Set BUSY Lun 0\r\n"); CI_LocalPrintf ("12 = Update contend lun X\r\n"); CI_LocalPrintf ("16 = Copy test.txt to test1.txt\n\r"); CI_LocalPrintf ("17 = Format LUN X\n\r"); return; } switch (CMD_u8) { case 0 : fs_g_nav.u8_lun = 0; // On chip RAM break; #if LUN_2 == ENABLE case 1 : if (2 != nParamsGet_u8) { CI_LocalPrintf ("USAGE: fa 1 [lun]\r\n"); break; } b_fsaccess_init (); fs_g_nav.u8_lun = Param_u32; // On chip RAM virtual_test_unit_ready() ; if (TRUE == fat_mount ()) { CI_LocalPrintf ("Mount LUN %d OK\r\n",Param_u32); } else { CI_LocalPrintf ("Mount LUN %d FAIL - %d - %s\r\n",Param_u32,fs_g_status, IBN_FileSystemErrorText(fs_g_status)); } // nav_partition_mount (); break; #endif case 2 : CI_LocalPrintf ("Free mem = %d sectors\r\n",fat_getfreespace()); break; case 3 : FileID_s32 = open ("test.txt",O_CREAT|O_RDWR); CI_LocalPrintf ("Open = %d - %d - %s\r\n",FileID_s32,fs_g_status, IBN_FileSystemErrorText(fs_g_status)); Ret_s32 = write (FileID_s32,"Test\n",6); CI_LocalPrintf ("Write = %d \r\n",Ret_s32); /* if (TRUE == fat_cache_flush ()) { CI_LocalPrintf ("fat_cache_flush OK\r\n"); } else { CI_LocalPrintf ("fat_cache_flush FAIL - %d - %s\r\n",fs_g_status, IBN_FileSystemErrorText(fs_g_status)); } */ Ret_s32 = close (FileID_s32); CI_LocalPrintf ("Close = %d \r\n",Ret_s32); #if LUN_2 == ENABLE virtual_unit_state_e = CTRL_BUSY; // only for ram disk #endif sd_mmc_mci_unit_state_e = CTRL_BUSY; vTaskDelay (500); #if LUN_2 == ENABLE virtual_unit_state_e = CTRL_GOOD; #endif sd_mmc_mci_unit_state_e = CTRL_GOOD; break; case 4 : if (2 != nParamsGet_u8) { CI_LocalPrintf ("USAGE: fa 6 [lun]\r\n"); break; } FAI_Write (Param_u32); break; case 5 : FAI_ShowDirContent (); break; case 6: if (2 != nParamsGet_u8) { CI_LocalPrintf ("USAGE: fa 6 [lun]\r\n"); break; } FAI_mount(Param_u32); break; case 7 : FAI_free_space(Param_u32); break; case 8 : FAI_nb_drive(); break; case 9 : FAI_Dir (0); break; case 10 : if (TRUE == nav_drive_set (Param_u32)) { CI_LocalPrintf ("nav_drive_set OK\r\n"); } else { CI_LocalPrintf ("nav_drive_set FAIL - %d - %s\r\n",fs_g_status, IBN_FileSystemErrorText(fs_g_status)); } break; case 11 : #if LUN_2 == ENABLE CI_LocalPrintf ("Set LUN %d CTRL_BUSY\n\r",Param_u32); //virtual_unit_state_e = CTRL_BUSY; set_virtual_unit_busy (); #endif break; case 12 : CI_LocalPrintf ("Update LUN %d\n\r",Param_u32); FAI_UpdateContend (Param_u32);; break; case 13 : CI_LocalPrintf ("fat_cache_flush\n\r"); fat_cache_flush (); break; case 14 : CI_LocalPrintf ("fat_check_device\n\r"); fat_check_device (); break; case 15 : CI_LocalPrintf ("fat_check_device\n\r"); fat_read_dir (); break; case 16 : CI_LocalPrintf ("Copy test.txt to test1.txt\n\r"); { u8 F1[10]; u8 F2[10]; strcpy ((char*)F1,"test.txt"); strcpy ((char*)F2,"test1.txt"); FAI_CopyFile (F1,F2); } break; case 17 : CI_LocalPrintf ("Format LUN %d\n\r",Param_u32); nav_drive_set(Param_u32); if( !nav_drive_format(FS_FORMAT_FAT) ) { CI_LocalPrintf ("Format LUN %d - ERROR\n\r",Param_u32); } break; } }