/** * \brief Application entry point. * * \return Unused (ANSI-C compatibility). */ int main(void) { uint8_t uc_key; /* Initialize the SAM3 system */ SystemInit(); board_init(); WDT->WDT_MR = WDT_MR_WDDIS; /* Initialize the console uart */ configure_console(); /* Output example information */ puts(STRING_HEADER); /* configure LED. */ led_config(); /* configure push buttons. */ configure_buttons(); /* Set default priorities for 2 buttons. */ puts("Set INT1's priority higher than INT2.\r"); set_interrupt_priority(INT_PRIOR_HIGH, INT_PRIOR_LOW); /* Display the main menu. */ display_menu(); // Flash the LED. while (1) { while (uart_read(CONSOLE_UART, &uc_key)); switch (uc_key) { case '1': set_interrupt_priority(INT_PRIOR_LOW, INT_PRIOR_HIGH); puts("Set INT2's priority higher than INT1.\n\r\r"); break; case '2': set_interrupt_priority(INT_PRIOR_HIGH, INT_PRIOR_LOW); puts("Set INT1's priority higher than INT2.\n\r\r"); break; case 'h': display_menu(); break; default: puts("Invalid input.\r"); break; } } }
/** * \brief Application entry point. * * \return Unused (ANSI-C compatibility). */ int main(void) { uint8_t uc_key; /* Initialize the SAM4 system */ sysclk_init(); board_init(); WDT->WDT_MR = WDT_MR_WDDIS; /* Enable the pmc clocks of the push buttons for all SAM4. */ pmc_enable_periph_clk(ID_PIOA); pmc_enable_periph_clk(ID_PIOB); pmc_enable_periph_clk(ID_PIOC); /* Initialize the console uart */ configure_console(); /* Output example information */ puts(STRING_HEADER); /* PIO configuration for LEDs and Buttons. */ pio_handler_set_priority(PIOA, PIOA_IRQn, 0); pio_handler_set_priority(PIOB, PIOB_IRQn, 0); pio_handler_set_priority(PIOC, PIOC_IRQn, 0); /* configure LED. */ led_config(); /* configure push buttons. */ configure_buttons(); /* Set default priorities for 2 buttons. */ puts("Set INT1's priority higher than INT2.\r"); set_interrupt_priority(INT_PRIOR_HIGH, INT_PRIOR_LOW); /* Display the main menu. */ display_menu(); // Flash the LED. while (1) { while (uart_read(CONSOLE_UART, &uc_key)); switch (uc_key) { case '1': set_interrupt_priority(INT_PRIOR_LOW, INT_PRIOR_HIGH); puts("Set INT2's priority higher than INT1.\n\r\r"); break; case '2': set_interrupt_priority(INT_PRIOR_HIGH, INT_PRIOR_LOW); puts("Set INT1's priority higher than INT2.\n\r\r"); break; case 'h': display_menu(); break; default: puts("Invalid input.\r"); break; } } }