PIO Alternate Function Example.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | BUFFER_SIZE (IFLASH_PAGE_SIZE / 4) |
Buffer size. More... | |
#define | FLASH_WAIT_STATE_NBR (6) |
Flash wait state number. More... | |
#define | MAX_SHIFTING_NUMBER (32) |
The MAX value of shifting. More... | |
#define | STRING_EOL "\r" |
#define | STRING_HEADER |
Functions | |
static void | button_handler (uint32_t id, uint32_t mask) |
Handler for Button 1 rising edge interrupt. More... | |
static void | configure_button (void) |
Configure the push button. More... | |
static void | configure_console (void) |
Configure UART for debug message output. More... | |
int | main (void) |
pio_alternate_function Application entry point. More... | |
Variables | |
volatile uint32_t | g_button_event = 0 |
Pushbutton #1 pin event flag. More... | |
#define BUFFER_SIZE (IFLASH_PAGE_SIZE / 4) |
Buffer size.
Referenced by main().
#define FLASH_WAIT_STATE_NBR (6) |
Flash wait state number.
Referenced by main().
#define MAX_SHIFTING_NUMBER (32) |
The MAX value of shifting.
Referenced by main().
#define STRING_EOL "\r" |
#define STRING_HEADER |
Referenced by main().
|
static |
Handler for Button 1 rising edge interrupt.
Set button1 event flag (g_button_event).
References g_button_event.
Referenced by configure_button().
|
static |
Configure the push button.
Configure the PIOs as inputs and generate corresponding interrupt when pressed or released.
References button_handler(), pio_enable_interrupt(), pio_set_debounce_filter(), and pmc_enable_periph_clk().
Referenced by main().
|
static |
Configure UART for debug message output.
References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
int main | ( | void | ) |
pio_alternate_function Application entry point.
Program the test page of internal flash with pattern 0x00000001,0x00000002,...,0x80000000. If the ERASE is in PIO mode, putting jumper on ERASE has no effect. That is, this pin could be used as general purpose I/O line. Otherwise, the content of flash will be erased to 0xFFFFFFFF.
Ask the user to close the erase jumper and then open it(200ms minimum).
Disable the PIO line interrupts to eliminate the wrong check of key press.
Ask the user to close the erase jumper and then open it(200ms minimum).
Remind the users that after closing the erase jumper and then opening it, codes are gone.
References board_init(), BUFFER_SIZE, configure_button(), configure_console(), FLASH_ACCESS_MODE_128, flash_init(), FLASH_RC_OK, flash_unlock(), FLASH_WAIT_STATE_NBR, flash_write(), g_button_event, MAX_SHIFTING_NUMBER, pio_disable_interrupt(), STRING_HEADER, and sysclk_init().
volatile uint32_t g_button_event = 0 |
Pushbutton #1 pin event flag.
Referenced by button_handler(), and main().