int main(void) { irq_initialize_vectors(); cpu_irq_enable(); sysclk_init(); board_init(); configure_console(); ctrl_access_init(); // Required with FreeRTOS //memories_initialization(); // Create a semaphore to manage the memories data transfer vSemaphoreCreateBinary(main_trans_semphr); Assert( main_trans_semphr != NULL ); // Start USB stack to authorize VBus monitoring // udc_start(); // Create a task to process data transfer /** xTaskCreate(main_memories_trans_task, ((const signed portCHAR *)"DATA TRANSFER"), #if defined(CONF_BOARD_NAND) 3072/sizeof(portSTACK_TYPE), // NF require large stack #else 256, #endif NULL, tskIDLE_PRIORITY + 1, NULL); */ initThreads(); initBMS(); // Uncomment the following line, if you want FreeRTOS to always run // when USB cable is unplugged. // IDLE is the sleep level required by the Timer counter used by FreeRTOS. // sleepmgr_lock_mode(SLEEPMGR_IDLE); // Start OS scheduler vTaskStartScheduler(); return 0; }
//! //! \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); }
int main (void) { pcl_freq_param_t local_pcl_freq_param; /* USART_Int_Test (); return (0); */ // Configure system clocks. local_pcl_freq_param = pcl_freq_param; if (pcl_configure_clocks (&local_pcl_freq_param) != PASS) { return 42; } /* Load the Exception Vector Base Address in the corresponding system register. */ Set_system_register (AVR32_EVBA, (int) &_evba); /* Enable exceptions. */ ENABLE_ALL_EXCEPTIONS (); /* Initialize interrupt handling. */ INTC_init_interrupts (); #if ((defined SD_MMC_MCI_0_MEM) && (SD_MMC_MCI_0_MEM == ENABLE)) || ((defined SD_MMC_MCI_1_MEM) && (SD_MMC_MCI_1_MEM == ENABLE)) sd_mmc_mci_resources_init (); #endif #ifdef FREERTOS_USED if (!ctrl_access_init ()) { return 42; } #endif // FREERTOS_USED // Init Hmatrix bus init_hmatrix (); // Initialize USB clock. pcl_configure_usb_clock (); /* SmartCard_test (); return 42; Test_ALL_Pins (); Test_MCI_Pins (); Test_LEDs_Pins (); TestUart0 (); while (1); return (0); */ #ifdef TIME_MEASURING_ENABLE TIME_MEASURING_Init (); #endif // For debugging BUFFERED_SIO_Init (); #ifdef INTERPRETER_ENABLE IDF_task_init (); #endif // Internal work task - FAT Access IW_task_init (); // Initialize USB tasks. usb_task_init (); #if USB_DEVICE_FEATURE == ENABLED #ifdef USB_MSD device_mass_storage_task_init (); #endif // USB_MSD #endif // CCID_Test_task_init (); #ifdef USB_CCID USB_CCID_task_init (); #endif DFU_DisableFirmwareUpdate (); // Stick always starts in application mode /**/ // Protect bootloader #ifdef STICK_20_A_MUSTER_PROD // flashc_set_bootloader_protected_size (0x2000); // flashc_activate_security_bit (); // Debugging disabled, only chip erase works (bootloader is save) , AES storage keys and setup // are erased flashc_lock_external_privileged_fetch (TRUE); // Disable external instruction fetch #endif // DFU_FirmwareResetUserpage (); // Set BOD33 detection reset to 3.06 Volt pm_bod33_ResetDisable (); pm_bod33_set_level (AVR32_PM_BOD33_LEVEL_306_VOLT); pm_bod33_ResetEnable (); // ushell_task_init(pcl_freq_param.pba_f); // Create the semaphore vSemaphoreCreateBinary (AES_semphr); // Wait for the semaphore while (!xSemaphoreTake (AES_semphr, portMAX_DELAY)); // Release the semaphore in order to start a new device/host task portBASE_TYPE task_woken = pdFALSE; /* taskENTER_CRITICAL (); xSemaphoreGiveFromISR (AES_semphr, &task_woken); taskEXIT_CRITICAL (); */ taskENTER_CRITICAL (); xSemaphoreGive (AES_semphr); taskEXIT_CRITICAL (); // Start stick vTaskStartScheduler (); // It never gets to this point return 42; }