Microchip® Advanced Software Framework

sau_example.c File Reference

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
#define HSB_PBB_START_ADDR   0XFFFE0000
#define NB_CONFIG_MPU_ENTRIES   5
#define PRINT_EXAMPLE_CHAR   0x41

Referenced by main().

#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

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

Parameters
*sppointer to stack before the exception (provided through R12). At this point, sp[0]=SR, sp[1]=PC.
exception_addressaddress of the offending instruction
exception_causeexception cause(==(EVBA offset of the exception)>>2)

References disable_mpu().

static void led_display_chaser_infinitely ( void  )
static

Toggle the LED0 and LED1 infinitely.

Note
This is used to show the end of this demo.

References i, and max.

Referenced by main().

static void leds_toggle_infinitely ( void  )
static

Toggle the LEDs infinitely.

Note
This is used to show errors in case of any MPU configuration.

References i.

Referenced by mpu_memory_protect_config().

void sau_config_to_usart ( void  )
static void sau_int_handler ( void  )
static

The SAU interrupt handler.

Note
The `__attribute__((interrupt))' (under GNU GCC for AVR32) and `__interrupt' (under IAR Embedded Workbench for Atmel AVR32) C function attributes are used to manage the `rete' instruction.

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().