/*! \brief Main function. Execution starts here. * * \retval 42 Fatal error. */ int main(void) { #ifndef FREERTOS_USED Enable_global_exception(); INTC_init_interrupts(); #endif pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP); init_dbg_rs232(FOSC0); pcl_configure_usb_clock(); usb_task_init(); #if USB_DEVICE_FEATURE == true device_template_task_init(); #endif #if USB_HOST_FEATURE == true host_template_task_init(); #endif #ifdef FREERTOS_USED vTaskStartScheduler(); portDBG_TRACE("FreeRTOS returned."); return 42; #else while (true) { usb_task(); #if USB_DEVICE_FEATURE == true device_template_task(); #endif #if USB_HOST_FEATURE == true host_template_task(); #endif } #endif // FREERTOS_USED }
/*! \brief Low-level initialization routine called during startup, before the * main function. */ int __low_level_init(void) { // Enable exceptions. Enable_global_exception(); // Initialize interrupt handling. INTC_init_interrupts(); // Request initialization of data segments. return 1; }
/*! \brief Initializes MCU exceptions. */ static void init_exceptions(void) { #if __GNUC__ && __AVR32__ // Import the Exception Vector Base Address. extern void _evba; // Load the Exception Vector Base Address in the corresponding system // register. Set_system_register(AVR32_EVBA, (int)&_evba); #endif // Enable exceptions globally. Enable_global_exception(); }
/*! \brief Low-level initialization routine called during startup, before the * main function. */ int __low_level_init(void) { // Enable exceptions. Enable_global_exception(); // Initialize interrupt handling. INTC_init_interrupts(); // Initialize the USART used for the debug trace with the configured parameters. extern volatile avr32_usart_t *volatile stdio_usart_base; stdio_usart_base = DBG_USART; // Request initialization of data segments. return 1; }
/*! \brief Low-level initialization routine called during startup, before the * main function. * * This version comes in replacement to the default one provided by the Newlib * add-ons library. * Newlib add-ons' _init_startup only calls init_exceptions, but Newlib add-ons' * exception and interrupt vectors are defined in the same section and Newlib * add-ons' interrupt vectors are not compatible with the interrupt management * of the INTC module. * More low-level initializations are besides added here. */ int _init_startup(void) { // Import the Exception Vector Base Address. extern void _evba; // Load the Exception Vector Base Address in the corresponding system register. Set_system_register(AVR32_EVBA, (int)&_evba); // Enable exceptions. Enable_global_exception(); // Initialize interrupt handling. INTC_init_interrupts(); // Don't-care value for GCC. return 1; }
/*! \brief Low-level initialization routine called during startup, before the * main function. * * This version comes in replacement to the default one provided by the Newlib * add-ons library. * Newlib add-ons' _init_startup only calls init_exceptions, but Newlib add-ons' * exception and interrupt vectors are defined in the same section and Newlib * add-ons' interrupt vectors are not compatible with the interrupt management * of the INTC module. * More low-level initializations are besides added here. */ int _init_startup(void) { // Import the Exception Vector Base Address. extern void _evba; // Load the Exception Vector Base Address in the corresponding system register. Set_system_register(AVR32_EVBA, (int)&_evba); // Enable exceptions. Enable_global_exception(); // Initialize interrupt handling. INTC_init_interrupts(); // Initialize the USART used for the debug trace with the configured parameters. set_usart_base( ( void * ) DBG_USART ); // Don't-care value for GCC. return 1; }
/*! \brief Low-level initialization routine called during startup, before the * main function. * * This version comes in replacement to the default one provided by the Newlib * add-ons library. * Newlib add-ons' _init_startup only calls init_exceptions, but Newlib add-ons' * exception and interrupt vectors are defined in the same section and Newlib * add-ons' interrupt vectors are not compatible with the interrupt management * of the INTC module. * More low-level initializations are besides added here. */ int _init_startup(void) { // Import the Exception Vector Base Address. extern void _evba; // Load the Exception Vector Base Address in the corresponding system register. Set_system_register(AVR32_EVBA, (int)&_evba); // Enable exceptions. Enable_global_exception(); // Initialize interrupt handling. INTC_init_interrupts(); // Give the used CPU clock frequency to Newlib, so it can work properly. set_cpu_hz(pcl_freq_param.pba_f); // Initialize the USART used for the debug trace with the configured parameters. set_usart_base( ( void * ) DBG_USART ); // Don't-care value for GCC. return 1; }
/*! \brief Initializes STDIO. */ static void init_stdio(void) { #if (defined __GNUC__) && (defined __AVR32__) static const gpio_map_t STDIO_USART_GPIO_MAP = { {STDIO_USART_RX_PIN, STDIO_USART_RX_FUNCTION}, {STDIO_USART_TX_PIN, STDIO_USART_TX_FUNCTION} }; // Initialize the USART used for STDIO. set_usart_base((void *)STDIO_USART); gpio_enable_module(STDIO_USART_GPIO_MAP, sizeof(STDIO_USART_GPIO_MAP) / sizeof(STDIO_USART_GPIO_MAP[0])); usart_init(STDIO_USART_BAUDRATE); #elif (defined __ICCAVR32__) static const gpio_map_t STDIO_USART_GPIO_MAP = { {STDIO_USART_RX_PIN, STDIO_USART_RX_FUNCTION}, {STDIO_USART_TX_PIN, STDIO_USART_TX_FUNCTION} }; static const usart_options_t STDIO_USART_OPTIONS = { .baudrate = STDIO_USART_BAUDRATE, .charlength = 8, .paritytype = USART_NO_PARITY, .stopbits = USART_1_STOPBIT, .channelmode = USART_NORMAL_CHMODE }; // Initialize the USART used for STDIO. extern volatile avr32_usart_t *volatile stdio_usart_base; stdio_usart_base = STDIO_USART; gpio_enable_module(STDIO_USART_GPIO_MAP, sizeof(STDIO_USART_GPIO_MAP) / sizeof(STDIO_USART_GPIO_MAP[0])); usart_init_rs232(STDIO_USART, &STDIO_USART_OPTIONS, FPBA_HZ); #endif } #if (defined __GNUC__) /*! \brief Low-level initialization routine called during startup, before the * main function. * * This version comes in replacement to the default one provided by the Newlib * add-ons library. * Newlib add-ons' _init_startup only calls init_exceptions, but Newlib add-ons' * exception and interrupt vectors are defined in the same section and Newlib * add-ons' interrupt vectors are not compatible with the interrupt management * of the INTC module. * More low-level initializations are besides added here. */ int _init_startup(void) { // Import the Exception Vector Base Address. extern void _evba; // Load the Exception Vector Base Address in the corresponding system register. Set_system_register(AVR32_EVBA, (int)&_evba); // Enable exceptions. Enable_global_exception(); // Initialize interrupt handling. irq_initialize_vectors(); cpu_irq_enable(); init_stdio(); // Don't-care value for GCC. return 1; } #elif (defined __ICCAVR32__) /*! \brief Low-level initialization routine called during startup, before the * main function. */ int __low_level_init(void) { // Enable exceptions. Enable_global_exception(); // Initialize interrupt handling. irq_initialize_vectors(); cpu_irq_enable(); init_stdio(); // Request initialization of data segments. return 1; }
static void init_exceptions(void) { extern void _evba; Set_system_register(AVR32_EVBA, (int)&_evba); Enable_global_exception(); }