PMC Clock Switching example for SAM.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
#include "stdio_serial.h"
#include "conf_board.h"
#include "conf_pmc_clock_switching_example.h"
Macros | |
#define | GCLK_ID PMC_PCK_0 |
Programmable Clock ID for the example by default. More... | |
#define | GCLK_PIN PIN_PCK0 |
Programmable Clock Pin for the example by default. More... | |
#define | GCLK_PIN_MUX PIN_PCK0_MUX |
Programmable Clock Pin Mux for the example by default. More... | |
#define | PMC_CLOCK_SWITCHING_EXAMPLE_BAUDRATE (2400) |
PMC External Xtal 12Mhz. More... | |
#define | PMC_CLOCK_SWITCHING_EXAMPLE_FIXED_PLLA (8192000) |
Fixed PLLA test clock, 8.192Mhz. More... | |
#define | PMC_PCK_PRES_CLK_1 PMC_PCK_PRES(0) |
#define | PMC_PCK_PRES_CLK_16 PMC_PCK_PRES(4) |
#define | PMC_PCK_PRES_CLK_2 PMC_PCK_PRES(1) |
#define | PMC_PCK_PRES_CLK_32 PMC_PCK_PRES(5) |
#define | PMC_PCK_PRES_CLK_4 PMC_PCK_PRES(2) |
#define | PMC_PCK_PRES_CLK_64 PMC_PCK_PRES(6) |
#define | PMC_PCK_PRES_CLK_8 PMC_PCK_PRES(3) |
#define | STRING_EOL "\r" |
#define | STRING_HEADER |
Functions | |
static void | button1_handler (uint32_t ul_id, uint32_t ul_mask) |
Handler for Button 1 rising edge interrupt. More... | |
static void | config_uart_and_pck (uint32_t ul_clock_source, uint32_t ul_prescaler, uint32_t ul_master_clock) |
Configure UART with the given master clock, and Configure PCK with the given divider source of master clock and prescaler. More... | |
static void | configure_buttons (void) |
Configure the Push buttons. More... | |
static void | configure_console (void) |
Configure the Console Uart. More... | |
int | main (void) |
Application entry point for pmc_clock switch example. More... | |
Variables | |
static volatile uint8_t | gs_uc_wait_button = 0 |
User push button activated flag. More... | |
#define GCLK_ID PMC_PCK_0 |
Programmable Clock ID for the example by default.
Referenced by config_uart_and_pck().
#define GCLK_PIN_MUX PIN_PCK0_MUX |
Programmable Clock Pin Mux for the example by default.
Referenced by main().
#define PMC_CLOCK_SWITCHING_EXAMPLE_BAUDRATE (2400) |
PMC External Xtal 12Mhz.
Referenced by config_uart_and_pck().
#define PMC_CLOCK_SWITCHING_EXAMPLE_FIXED_PLLA (8192000) |
Fixed PLLA test clock, 8.192Mhz.
Referenced by main().
#define PMC_PCK_PRES_CLK_1 PMC_PCK_PRES(0) |
Referenced by main().
#define PMC_PCK_PRES_CLK_16 PMC_PCK_PRES(4) |
Referenced by main().
#define PMC_PCK_PRES_CLK_2 PMC_PCK_PRES(1) |
Referenced by main().
#define PMC_PCK_PRES_CLK_32 PMC_PCK_PRES(5) |
#define PMC_PCK_PRES_CLK_4 PMC_PCK_PRES(2) |
#define PMC_PCK_PRES_CLK_64 PMC_PCK_PRES(6) |
#define PMC_PCK_PRES_CLK_8 PMC_PCK_PRES(3) |
#define STRING_EOL "\r" |
#define STRING_HEADER |
Referenced by main().
|
static |
Handler for Button 1 rising edge interrupt.
Handle process led1 status change.
References gs_uc_wait_button, PIN_PUSHBUTTON_1_ID, and PIN_PUSHBUTTON_1_MASK.
Referenced by configure_buttons().
|
static |
Configure UART with the given master clock, and Configure PCK with the given divider source of master clock and prescaler.
ul_clock_source | The master clock divider source. |
ul_prescaler | Master Clock prescaler. |
ul_master_clock | Frequency of the master clock (in Hz). |
References sam_usart_opt_t::baudrate, BOARD_FREQ_SLCK_XTAL, sam_usart_opt_t::channel_mode, sam_usart_opt_t::char_length, CONF_UART_CHAR_LENGTH, CONF_UART_PARITY, CONF_UART_STOP_BITS, CONFIG_SYSCLK_DIV, CONSOLE_UART, CONSOLE_UART_ID, GCLK_ID, sam_usart_opt_t::parity_type, PMC_CLOCK_SWITCHING_EXAMPLE_BAUDRATE, pmc_disable_pck(), pmc_enable_pck(), pmc_enable_periph_clk(), pmc_switch_pck_to_mainck(), pmc_switch_pck_to_pllack(), pmc_switch_pck_to_pllbck(), pmc_switch_pck_to_sclk(), sam_usart_opt_t::stop_bits, uart_init(), usart_enable_rx(), usart_enable_tx(), and usart_init_rs232().
Referenced by main().
|
static |
Configure the Push buttons.
Configure the PIO as inputs and generate corresponding interrupt when pressed or released.
References button1_handler(), PIN_PUSHBUTTON_1_ATTR, PIN_PUSHBUTTON_1_ID, PIN_PUSHBUTTON_1_MASK, PIN_PUSHBUTTON_1_PIO, pio_enable_interrupt(), pio_handler_set(), pio_set_debounce_filter(), and pmc_enable_periph_clk().
Referenced by main().
|
static |
Configure the Console Uart.
References uart_rs232_options::baudrate, CONF_UART, CONF_UART_BAUDRATE, CONF_UART_CHAR_LENGTH, CONF_UART_PARITY, CONF_UART_STOP_BITS, CONSOLE_UART_ID, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
int main | ( | void | ) |
Application entry point for pmc_clock switch example.
References BOARD_FREQ_MAINCK_XTAL, BOARD_FREQ_SLCK_XTAL, board_init(), BOARD_OSC_STARTUP_US, BUTTON_NAME, CONF_UART, config_uart_and_pck(), configure_buttons(), configure_console(), GCLK_PIN, GCLK_PIN_MUX, gs_uc_wait_button, ioport_disable_pin(), ioport_set_pin_mode(), PMC_CLOCK_SWITCHING_EXAMPLE_FIXED_PLLA, pmc_disable_pllbck(), pmc_enable_pllack(), pmc_enable_pllbck(), PMC_OSC_XTAL, PMC_PCK_PRES_CLK_1, PMC_PCK_PRES_CLK_16, PMC_PCK_PRES_CLK_2, pmc_switch_mainck_to_fastrc(), pmc_switch_mainck_to_xtal(), pmc_switch_mck_to_mainck(), pmc_switch_mck_to_pllack(), pmc_switch_mck_to_pllbck(), pmc_switch_mck_to_sclk(), pmc_switch_sclk_to_32kxtal(), STRING_HEADER, sysclk_init(), uart_is_tx_empty(), and usart_is_tx_empty().
|
static |
User push button activated flag.
Referenced by button1_handler(), and main().