Updated AVR32 demos and added AVR32 UC3B demo.

This commit is contained in:
Richard Barry 2007-07-27 07:59:50 +00:00
parent 45e7e5ac55
commit 94c94d3c0e
164 changed files with 21458 additions and 3994 deletions

View file

@ -1,15 +1,16 @@
/******************************************************************************
* Exception and interrupt vectors.
/*This file is prepared for Doxygen automatic documentation generation.*/
/*! \file *********************************************************************
*
* This file has been built from the Newlib exception.S. It maps all events
* supported by a UC3.
* \brief Exception and interrupt vectors.
*
* This file maps all events supported by an AVR32UC.
*
* - Compiler: IAR EWAVR32
* - Supported devices: All AVR32A devices with an INTC module can be used.
* - Supported devices: All AVR32UC devices with an INTC module can be used.
* - AppNote:
*
* - author Atmel Corporation: http://www.atmel.com \n
* Support email: avr32@atmel.com
* \author Atmel Corporation: http://www.atmel.com \n
* Support and FAQ: http://support.atmel.no/
*
******************************************************************************/
@ -41,11 +42,14 @@
*/
#include <avr32/iouc3a0512.h>
#include <avr32/uc3a0512.h>
#include <avr32/io.h>
#include "intc.h"
//! @{
//! \verbatim
// Start of Exception Vector Table.
// EVBA must be aligned with a power of two strictly greater than the EVBA-
@ -66,107 +70,107 @@ _evba:
ORG 0x000
// Unrecoverable Exception.
_handle_Unrecoverable_Exception:
rjmp $
rjmp _handle_Unrecoverable_Exception
ORG 0x004
// TLB Multiple Hit: UNUSED IN AVR32A.
// TLB Multiple Hit: UNUSED IN AVR32UC.
_handle_TLB_Multiple_Hit:
rjmp $
rjmp _handle_TLB_Multiple_Hit
ORG 0x008
// Bus Error Data Fetch.
_handle_Bus_Error_Data_Fetch:
rjmp $
rjmp _handle_Bus_Error_Data_Fetch
ORG 0x00C
// Bus Error Instruction Fetch.
_handle_Bus_Error_Instruction_Fetch:
rjmp $
rjmp _handle_Bus_Error_Instruction_Fetch
ORG 0x010
// NMI.
_handle_NMI:
rjmp $
rjmp _handle_NMI
ORG 0x014
// Instruction Address.
_handle_Instruction_Address:
rjmp $
rjmp _handle_Instruction_Address
ORG 0x018
// ITLB Protection.
_handle_ITLB_Protection:
rjmp $
rjmp _handle_ITLB_Protection
ORG 0x01C
// Breakpoint.
_handle_Breakpoint:
rjmp $
rjmp _handle_Breakpoint
ORG 0x020
// Illegal Opcode.
_handle_Illegal_Opcode:
rjmp $
rjmp _handle_Illegal_Opcode
ORG 0x024
// Unimplemented Instruction.
_handle_Unimplemented_Instruction:
rjmp $
rjmp _handle_Unimplemented_Instruction
ORG 0x028
// Privilege Violation.
_handle_Privilege_Violation:
rjmp $
rjmp _handle_Privilege_Violation
ORG 0x02C
// Floating-Point: UNUSED IN AVR32A.
// Floating-Point: UNUSED IN AVR32UC.
_handle_Floating_Point:
rjmp $
rjmp _handle_Floating_Point
ORG 0x030
// Coprocessor Absent: UNUSED IN AVR32A.
// Coprocessor Absent: UNUSED IN AVR32UC.
_handle_Coprocessor_Absent:
rjmp $
rjmp _handle_Coprocessor_Absent
ORG 0x034
// Data Address (Read).
_handle_Data_Address_Read:
rjmp $
rjmp _handle_Data_Address_Read
ORG 0x038
// Data Address (Write).
_handle_Data_Address_Write:
rjmp $
rjmp _handle_Data_Address_Write
ORG 0x03C
// DTLB Protection (Read).
_handle_DTLB_Protection_Read:
rjmp $
rjmp _handle_DTLB_Protection_Read
ORG 0x040
// DTLB Protection (Write).
_handle_DTLB_Protection_Write:
rjmp $
rjmp _handle_DTLB_Protection_Write
ORG 0x044
// DTLB Modified: UNUSED IN AVR32A.
// DTLB Modified: UNUSED IN AVR32UC.
_handle_DTLB_Modified:
rjmp $
rjmp _handle_DTLB_Modified
ORG 0x050
// ITLB Miss: UNUSED IN AVR32A.
// ITLB Miss: UNUSED IN AVR32UC.
_handle_ITLB_Miss:
rjmp $
rjmp _handle_ITLB_Miss
ORG 0x060
// DTLB Miss (Read): UNUSED IN AVR32A.
// DTLB Miss (Read): UNUSED IN AVR32UC.
_handle_DTLB_Miss_Read:
rjmp $
rjmp _handle_DTLB_Miss_Read
ORG 0x070
// DTLB Miss (Write): UNUSED IN AVR32A.
// DTLB Miss (Write): UNUSED IN AVR32UC.
_handle_DTLB_Miss_Write:
rjmp $
rjmp _handle_DTLB_Miss_Write
ORG 0x100
// Supervisor Call.
@ -300,3 +304,7 @@ ipr_val:
END
//! \endverbatim
//! @}

View file

@ -8,7 +8,7 @@
* - AppNote:
*
* \author Atmel Corporation: http://www.atmel.com \n
* Support email: avr32@atmel.com
* Support and FAQ: http://support.atmel.no/
*
*****************************************************************************/
@ -50,12 +50,10 @@
/* Scheduler includes. */
#include "FreeRTOS.h"
/* Get rid of inline in task.h. */
#include "task.h"
/* AVR32 UC3 includes. */
#include <avr32/iouc3a0512.h>
#include <avr32/io.h>
#include <intrinsics.h>
#include "gpio.h"
@ -79,6 +77,10 @@ volatile unsigned portLONG ulCriticalNesting = 9999UL;
#if( configTICK_USE_TC==0 )
static void prvScheduleNextTick( void );
#endif
/* Setup the timer to generate the tick interrupts. */
static void prvSetupTimerInterrupt( void );
/*-----------------------------------------------------------*/
/*
@ -111,21 +113,27 @@ int __low_level_init(void)
/* Code section present if and only if the debug trace is activated. */
#if configDBG
{
static const usart_options_t usart_opt =
static const gpio_map_t DBG_USART_GPIO_MAP =
{
.baudrate = configDBG_USART_BAUDRATE,
.charlength = 8,
.paritytype = USART_NO_PARITY,
.stopbits = USART_1_STOPBIT,
.channelmode = USART_MODE_NORMAL
{ configDBG_USART_RX_PIN, configDBG_USART_RX_FUNCTION },
{ configDBG_USART_TX_PIN, configDBG_USART_TX_FUNCTION }
};
static const usart_options_t DBG_USART_OPTIONS =
{
.baudrate = configDBG_USART_BAUDRATE,
.charlength = 8,
.paritytype = USART_NO_PARITY,
.stopbits = USART_1_STOPBIT,
.channelmode = USART_NORMAL_CHMODE
};
/* Initialize the USART used for the debug trace with the configured parameters. */
extern volatile avr32_usart_t *volatile stdio_usart_base;
stdio_usart_base = configDBG_USART;
gpio_enable_module_pin(configDBG_USART_RX_PIN, configDBG_USART_RX_FUNCTION);
gpio_enable_module_pin(configDBG_USART_TX_PIN, configDBG_USART_TX_FUNCTION);
usart_init_rs232(configDBG_USART, &usart_opt, configCPU_CLOCK_HZ);
gpio_enable_module( DBG_USART_GPIO_MAP,
sizeof( DBG_USART_GPIO_MAP ) / sizeof( DBG_USART_GPIO_MAP[0] ) );
usart_init_rs232(configDBG_USART, &DBG_USART_OPTIONS, configCPU_CLOCK_HZ);
}
#endif
@ -159,15 +167,15 @@ static void vTick( void )
/* Save the context of the interrupted task. */
portSAVE_CONTEXT_OS_INT();
/* Schedule the COUNT&COMPARE match interrupt in (configCPU_CLOCK_HZ/configTICK_RATE_HZ)
clock cycles from now. */
#if( configTICK_USE_TC==1 )
/* Clear the interrupt flag. */
AVR32_TC.channel[configTICK_TC_CHANNEL].sr;
#else
/* Schedule the COUNT&COMPARE match interrupt in (configCPU_CLOCK_HZ/configTICK_RATE_HZ)
clock cycles from now. */
prvScheduleNextTick();
#endif
/* Because FreeRTOS is not supposed to run with nested interrupts, put all OS
calls in a critical section . */
portENTER_CRITICAL();
@ -219,10 +227,6 @@ void vPortExitCritical( void )
}
/*-----------------------------------------------------------*/
/* Setup the timer to generate the tick interrupts. */
static void prvSetupTimerInterrupt( void );
/*-----------------------------------------------------------*/
/*
* Initialise the stack of a task to look exactly as if a call to
* portSAVE_CONTEXT had been called.
@ -282,13 +286,39 @@ void vPortEndScheduler( void )
/* Schedule the COUNT&COMPARE match interrupt in (configCPU_CLOCK_HZ/configTICK_RATE_HZ)
clock cycles from now. */
#if( configTICK_USE_TC==0 )
static void prvScheduleFirstTick(void)
{
unsigned long lCycles;
lCycles = Get_system_register(AVR32_COUNT);
lCycles += (configCPU_CLOCK_HZ/configTICK_RATE_HZ);
// If lCycles ends up to be 0, make it 1 so that the COMPARE and exception
// generation feature does not get disabled.
if(0 == lCycles)
{
lCycles++;
}
Set_system_register(AVR32_COMPARE, lCycles);
}
static void prvScheduleNextTick(void)
{
unsigned long lCountVal, lCompareVal;
unsigned long lCycles, lCount;
lCountVal = Get_system_register(AVR32_COUNT);
lCompareVal = lCountVal + (configCPU_CLOCK_HZ/configTICK_RATE_HZ);
Set_system_register(AVR32_COMPARE, lCompareVal);
lCycles = Get_system_register(AVR32_COMPARE);
lCycles += (configCPU_CLOCK_HZ/configTICK_RATE_HZ);
// If lCycles ends up to be 0, make it 1 so that the COMPARE and exception
// generation feature does not get disabled.
if(0 == lCycles)
{
lCycles++;
}
lCount = Get_system_register(AVR32_COUNT);
if( lCycles < lCount )
{ // We missed a tick, recover for the next.
lCycles += (configCPU_CLOCK_HZ/configTICK_RATE_HZ);
}
Set_system_register(AVR32_COMPARE, lCycles);
}
#endif
/*-----------------------------------------------------------*/
@ -357,7 +387,7 @@ static void prvSetupTimerInterrupt(void)
/* Set the compare triggers.
Remember TC counter is 16-bits, so counting second is not possible!
That's why we configure it to count ms. */
tc_write_rc( tc, configTICK_TC_CHANNEL, ( configPBA_CLOCK_HZ / 4) / 1000 );
tc_write_rc( tc, configTICK_TC_CHANNEL, ( configPBA_CLOCK_HZ / 4) / configTICK_RATE_HZ );
tc_configure_interrupts( tc, configTICK_TC_CHANNEL, &tc_interrupt );
@ -367,7 +397,7 @@ static void prvSetupTimerInterrupt(void)
#else
{
INTC_register_interrupt((__int_handler)&vTick, AVR32_CORE_COMPARE_IRQ, INT0);
prvScheduleNextTick();
prvScheduleFirstTick();
}
#endif
}

View file

@ -8,7 +8,7 @@
* - AppNote:
*
* \author Atmel Corporation: http://www.atmel.com \n
* Support email: avr32@atmel.com
* Support and FAQ: http://support.atmel.no/
*
*****************************************************************************/
@ -61,7 +61,7 @@
* These settings should not be altered.
*-----------------------------------------------------------
*/
#include <avr32/iouc3a0512.h>
#include <avr32/io.h>
#include "intc.h"
#include "compiler.h"
@ -118,7 +118,7 @@
* The current source file name and line number are output with a colon before
* the formatted string.
* A carriage return and a linefeed are appended to the output.
* stdout is redirected by Newlib to the USART configured by configDBG_USART.
* stdout is redirected to the USART configured by configDBG_USART.
* The parameters are the same as for the standard printf function.
* There is no return value.
* SHALL NOT BE CALLED FROM WITHIN AN INTERRUPT as fputs and printf use malloc,
@ -508,11 +508,11 @@ extern void *pvPortRealloc( void *pv, size_t xSize );
\
/* With the cooperative scheduler, as there is no context switch by interrupt, */ \
/* there is also no context save. */ \
}
/*
* Input parameter: in R12, boolean. Perform a vTaskSwitchContext() if 1
*/
}
/*
* Input parameter: in R12, boolean. Perform a vTaskSwitchContext() if 1
*/
#define portEXIT_SWITCHING_ISR() \
{ \
__asm__ __volatile__ ( \
@ -523,14 +523,14 @@ extern void *pvPortRealloc( void *pv, size_t xSize );
/* there is also no context restore. */ \
"rete" \
); \
}
#else
/*
* ISR entry and exit macros. These are only required if a task switch
* is required from the ISR.
*/
}
#else
/*
* ISR entry and exit macros. These are only required if a task switch
* is required from the ISR.
*/
#define portENTER_SWITCHING_ISR() \
{ \
extern volatile unsigned portLONG ulCriticalNesting; \

View file

@ -1,5 +1,3 @@
/* This source file is part of the ATMEL FREERTOS-0.9.0 Release */
/*This file is prepared for Doxygen automatic documentation generation.*/
/*! \file *********************************************************************
*
@ -11,7 +9,7 @@
* - AppNote:
*
* \author Atmel Corporation: http://www.atmel.com \n
* Support email: avr32@atmel.com
* Support and FAQ: http://support.atmel.no/
*
******************************************************************************/
@ -44,7 +42,7 @@
#include <yfuns.h>
#include <avr32/iouc3a0512.h>
#include <avr32/io.h>
#include "usart.h"

View file

@ -1,5 +1,3 @@
/* This source file is part of the ATMEL FREERTOS-0.9.0 Release */
/*This file is prepared for Doxygen automatic documentation generation.*/
/*! \file *********************************************************************
*
@ -11,7 +9,7 @@
* - AppNote:
*
* \author Atmel Corporation: http://www.atmel.com \n
* Support email: avr32@atmel.com
* Support and FAQ: http://support.atmel.no/
*
******************************************************************************/
@ -44,7 +42,7 @@
#include <yfuns.h>
#include <avr32/iouc3a0512.h>
#include <avr32/io.h>
#include "usart.h"