Microchip® Advanced Software Framework

pio_alternate_function_example.c File Reference

PIO Alternate Function Example.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "asf.h"
#include "conf_board.h"
#include "conf_clock.h"
#include "conf_example.h"

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
Value:
"-- PIO Alternate Function Example --\r\n" \
"-- "BOARD_NAME" --\r\n" \
"-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
#define BOARD_NAME
Name of the board.
Definition: same70_xplained.h:75
#define STRING_EOL
Definition: pio_alternate_function_example.c:99

Referenced by main().

static void button_handler ( uint32_t  id,
uint32_t  mask 
)
static

Handler for Button 1 rising edge interrupt.

Set button1 event flag (g_button_event).

References g_button_event, PUSH_BUTTON_ID, and PUSH_BUTTON_PIN_MSK.

Referenced by configure_button().

static void configure_button ( void  )
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_handler_set(), pio_set_debounce_filter(), pmc_enable_periph_clk(), PUSH_BUTTON_ATTR, PUSH_BUTTON_ID, PUSH_BUTTON_PIN_MSK, and PUSH_BUTTON_PIO.

Referenced by main().

static void configure_console ( void  )
static
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.

Returns
Unused (ANSI-C compatibility).

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, BUTTON_STRING, configure_button(), configure_console(), FLASH_ACCESS_MODE_128, flash_erase_sector(), flash_init(), FLASH_RC_OK, flash_unlock(), FLASH_WAIT_STATE_NBR, flash_write(), g_button_event, matrix_set_system_io(), MAX_SHIFTING_NUMBER, PIN_ERASE_MODE_MSK, PIN_PIO_MODE_MSK, pio_disable_interrupt(), PUSH_BUTTON_PIN_MSK, PUSH_BUTTON_PIO, STRING_HEADER, sysclk_init(), and TEST_PAGE_ADDRESS.

volatile uint32_t g_button_event = 0

Pushbutton #1 pin event flag.

Referenced by button_handler(), and main().