Example of usage of the Software Framework SAU driver in AVR UC3.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include <avr32/io.h>
#include "compiler.h"
#include "print_funcs.h"
#include "gpio.h"
#include "mpu.h"
#include "sau.h"
#include "cycle_counter.h"
#include "usart.h"
#include "intc.h"
#include "power_clocks_lib.h"
#include "sysclk.h"
Macros | |
#define | EXAMPLE_SAU_SLAVE_USART AVR32_USART3_ADDRESS |
#define | EXAMPLE_TARGET_PBACLK_FREQ_HZ 15000000 |
#define | EXAMPLE_UNLOCK_CLOCK_CYCLES 200 |
#define | EXAMPLE_UNLOCK_KEY 0x55 |
#define | EXAMPLE_WRONG_UNLOCK_KEY 0x66 |
#define | HSB_PBA_START_ADDR 0XFFFF0000 |
#define | HSB_PBB_START_ADDR 0XFFFE0000 |
#define | NB_CONFIG_MPU_ENTRIES 5 |
#define | PRINT_EXAMPLE_CHAR 0x41 |
#define | REGION_0_FLASH_INDEX 0 |
#define | REGION_1_STACK_INDEX 1 |
#define | REGION_2_PERIPHERALS_INDEX 2 |
#define | REGION_3_SAU_HSB_INDEX 3 |
#define | REGION_4_SAU_INDEX 4 |
#define | USART_CSR_CHANNEL 0 |
#define | USART_RHR_CHANNEL 2 |
#define | USART_THR_CHANNEL 1 |
Functions | |
void | attempt_read_UR (void) |
void | handle_exception (unsigned int *sp, unsigned long exception_address, unsigned int exception_cause) |
Handle exception; called by the _evba assembly function. More... | |
static void | led_display_chaser_infinitely (void) |
Toggle the LED0 and LED1 infinitely. More... | |
static void | leds_toggle_infinitely (void) |
Toggle the LEDs infinitely. More... | |
void | main (void) |
void | mpu_memory_protect_config (void) |
MPU configuration in this example. More... | |
void | sau_config_to_usart (void) |
SAU configuration for USART registers. More... | |
static void | sau_int_handler (void) |
The SAU interrupt handler. More... | |
bool | sau_usart_tx_ready () |
Variables | |
mpu_entry_t | dmpu_entries [NB_CONFIG_MPU_ENTRIES] |
#define EXAMPLE_SAU_SLAVE_USART AVR32_USART3_ADDRESS |
Referenced by sau_config_to_usart().
#define EXAMPLE_TARGET_PBACLK_FREQ_HZ 15000000 |
Referenced by main().
#define EXAMPLE_UNLOCK_CLOCK_CYCLES 200 |
Referenced by main().
#define EXAMPLE_UNLOCK_KEY 0x55 |
Referenced by main().
#define EXAMPLE_WRONG_UNLOCK_KEY 0x66 |
Referenced by main().
#define HSB_PBA_START_ADDR 0XFFFF0000 |
Referenced by mpu_memory_protect_config().
#define HSB_PBB_START_ADDR 0XFFFE0000 |
Referenced by mpu_memory_protect_config().
#define NB_CONFIG_MPU_ENTRIES 5 |
#define PRINT_EXAMPLE_CHAR 0x41 |
Referenced by main().
#define REGION_0_FLASH_INDEX 0 |
Referenced by mpu_memory_protect_config().
#define REGION_1_STACK_INDEX 1 |
Referenced by mpu_memory_protect_config().
#define REGION_2_PERIPHERALS_INDEX 2 |
Referenced by mpu_memory_protect_config().
#define REGION_3_SAU_HSB_INDEX 3 |
Referenced by mpu_memory_protect_config().
#define REGION_4_SAU_INDEX 4 |
Referenced by mpu_memory_protect_config().
#define USART_CSR_CHANNEL 0 |
Referenced by main(), sau_config_to_usart(), and sau_usart_tx_ready().
#define USART_RHR_CHANNEL 2 |
Referenced by sau_config_to_usart().
#define USART_THR_CHANNEL 1 |
Referenced by main(), and sau_config_to_usart().
void attempt_read_UR | ( | void | ) |
Referenced by main().
void handle_exception | ( | unsigned int * | sp, |
unsigned long | exception_address, | ||
unsigned int | exception_cause | ||
) |
Handle exception; called by the _evba assembly function.
AVR32_EVBA_OFFSET_ITLB_PROT AVR32_EVBA_OFFSET_DTLB_PROT_x
*sp | pointer to stack before the exception (provided through R12). At this point, sp[0]=SR, sp[1]=PC. |
exception_address | address of the offending instruction |
exception_cause | exception cause(==(EVBA offset of the exception)>>2) |
References disable_mpu().
|
static |
|
static |
Toggle the LEDs infinitely.
References i.
Referenced by mpu_memory_protect_config().
void main | ( | void | ) |
References attempt_read_UR(), Enable_global_exception, Enable_global_interrupt, EXAMPLE_TARGET_PBACLK_FREQ_HZ, EXAMPLE_UNLOCK_CLOCK_CYCLES, EXAMPLE_UNLOCK_KEY, EXAMPLE_WRONG_UNLOCK_KEY, gpio_set_gpio_pin(), init_dbg_rs232(), INTC_register_interrupt(), led_display_chaser_infinitely(), mpu_memory_protect_config(), print_dbg(), PRINT_EXAMPLE_CHAR, sau_clear_error_flags, sau_config_to_usart(), sau_disable_buserr_resp, sau_disable_interrupt, sau_enable_buserr_resp, sau_enable_interrupt, sau_enable_open_mode, sau_int_handler(), sau_lock_channels(), sau_status_check, sau_unlock_channel(), sau_usart_tx_ready(), sau_write_channel(), sysclk_init(), USART_CSR_CHANNEL, and USART_THR_CHANNEL.
void mpu_memory_protect_config | ( | void | ) |
MPU configuration in this example.
References mpu_entry_t::addr, enable_mpu(), HSB_PBA_START_ADDR, HSB_PBB_START_ADDR, leds_toggle_infinitely(), MPU_APRA_ID, MPU_APRB_ID, mpu_convert_kbsize_to_eregionsize(), MPU_PRIVR_UNPRIVNONE, MPU_PRIVRW_UNPRIVNONE, MPU_PRIVRX_UNPRIVRX, MPU_REGION_SIZE_32KB, MPU_REGION_SIZE_64KB, print_dbg(), REGION_0_FLASH_INDEX, REGION_1_STACK_INDEX, REGION_2_PERIPHERALS_INDEX, REGION_3_SAU_HSB_INDEX, REGION_4_SAU_INDEX, select_subregion(), set_access_permissions(), set_mpu_entry(), mpu_entry_t::size, and mpu_entry_t::valid.
Referenced by main().
void sau_config_to_usart | ( | void | ) |
SAU configuration for USART registers.
References EXAMPLE_SAU_SLAVE_USART, sau_configure_channels(), sau_enable, sau_enter_setup, USART_CSR_CHANNEL, USART_RHR_CHANNEL, and USART_THR_CHANNEL.
Referenced by main().
|
static |
The SAU interrupt handler.
References print_dbg(), sau_clear_error_flags, and sau_status_check.
Referenced by main().
bool sau_usart_tx_ready | ( | ) |
References sau_read_channel(), and USART_CSR_CHANNEL.
Referenced by main().
mpu_entry_t dmpu_entries[NB_CONFIG_MPU_ENTRIES] |