mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 09:38:32 -04:00
Atmel provided hardware specifics.
This commit is contained in:
parent
5e6d50864c
commit
efc8243397
73 changed files with 24720 additions and 0 deletions
90
Demo/Common/drivers/Atmel/at91lib/utility/assert.h
Normal file
90
Demo/Common/drivers/Atmel/at91lib/utility/assert.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
Title: Assert
|
||||
|
||||
About: Purpose
|
||||
Definition of the ASSERT() macro, which is used for runtime condition
|
||||
verifying.
|
||||
|
||||
About: Usage
|
||||
1 - Use <ASSERT> in your code to check the value of function parameters,
|
||||
return values, etc. *Warning:* the ASSERT condition must not have
|
||||
any side-effect; otherwise, the program may not work properly
|
||||
anymore when assertions are disabled.
|
||||
2 - Use SANITY_CHECK to perform checks with a default error message
|
||||
(outputs the file and line number where the error occured). This
|
||||
reduces memory overhead caused by assertion error strings.
|
||||
3 - Initialize the <DBGU> to see failed assertions at run-time.
|
||||
4 - Disable assertions by defining the NOASSERT symbol at compilation
|
||||
time.
|
||||
*/
|
||||
|
||||
#ifndef ASSERT_H
|
||||
#define ASSERT_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Macro: ASSERT
|
||||
Check that the given condition is true, otherwise displays an error
|
||||
message and stops the program execution.
|
||||
|
||||
Parameters:
|
||||
condition - Condition to verify.
|
||||
string - Formatted string to output if the condition fails.
|
||||
... - Additional arguments depending on the formatted string.
|
||||
*/
|
||||
#if !defined(NOASSERT) && !defined(NOTRACE)
|
||||
|
||||
//char sanityError[] = "Sanity check failed at %s:%d\n\r";
|
||||
|
||||
#define ASSERT(condition, ...) { \
|
||||
if (!(condition)) { \
|
||||
printf(__VA_ARGS__); \
|
||||
while (1); \
|
||||
} \
|
||||
}
|
||||
#define SANITY_ERROR "Sanity check failed at %s:%d\n\r"
|
||||
#define SANITY_CHECK(condition) ASSERT(condition, SANITY_ERROR, __FILE__, __LINE__)
|
||||
#else
|
||||
#define ASSERT(...)
|
||||
#define SANITY_CHECK(...)
|
||||
#endif
|
||||
|
||||
#endif //#ifndef ASSERT_H
|
||||
|
187
Demo/Common/drivers/Atmel/at91lib/utility/led.c
Normal file
187
Demo/Common/drivers/Atmel/at91lib/utility/led.c
Normal file
|
@ -0,0 +1,187 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
Title: LED implementation
|
||||
|
||||
About: Purpose
|
||||
Implementation of LED-related functionalities.
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "led.h"
|
||||
#include <board.h>
|
||||
#include <pio/pio.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Internal variables
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifdef PINS_LEDS
|
||||
static const Pin pinsLeds[] = {PINS_LEDS};
|
||||
static const unsigned int numLeds = PIO_LISTSIZE(pinsLeds);
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Exported functions
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Function: LED_Configure
|
||||
Configures the pin associated with the given LED number.
|
||||
|
||||
Parameters:
|
||||
led - Number of the LED to configure.
|
||||
|
||||
Returns:
|
||||
1 if the LED exists and has been configured; otherwise 0.
|
||||
*/
|
||||
unsigned char LED_Configure(unsigned int led)
|
||||
{
|
||||
#ifdef PINS_LEDS
|
||||
// Check that LED exists
|
||||
if (led >= numLeds) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Configure LED
|
||||
return (PIO_Configure(&pinsLeds[led], 1));
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Function: LED_Set
|
||||
Turns a LED on.
|
||||
|
||||
Parameters:
|
||||
led - Number of the LED to turn on.
|
||||
|
||||
Returns:
|
||||
1 if the LED has been turned on; 0 otherwise.
|
||||
*/
|
||||
unsigned char LED_Set(unsigned int led)
|
||||
{
|
||||
#ifdef PINS_LEDS
|
||||
// Check if LED exists
|
||||
if (led >= numLeds) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Turn LED on
|
||||
if (pinsLeds[led].type == PIO_OUTPUT_0) {
|
||||
|
||||
PIO_Set(&pinsLeds[led]);
|
||||
}
|
||||
else {
|
||||
|
||||
PIO_Clear(&pinsLeds[led]);
|
||||
}
|
||||
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Function: LED_Clear
|
||||
Turns a LED off.
|
||||
|
||||
Parameters:
|
||||
led - Number of the LED to turn off.
|
||||
|
||||
Returns:
|
||||
1 if the LED has been turned off; 0 otherwise.
|
||||
*/
|
||||
unsigned char LED_Clear(unsigned int led)
|
||||
{
|
||||
#ifdef PINS_LEDS
|
||||
// Check if LED exists
|
||||
if (led >= numLeds) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Turn LED off
|
||||
if (pinsLeds[led].type == PIO_OUTPUT_0) {
|
||||
|
||||
PIO_Clear(&pinsLeds[led]);
|
||||
}
|
||||
else {
|
||||
|
||||
PIO_Set(&pinsLeds[led]);
|
||||
}
|
||||
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Function: LED_Toggle
|
||||
Toggles the current state of a LED.
|
||||
|
||||
Parameters:
|
||||
led - Number of the LED to toggle.
|
||||
|
||||
Returns:
|
||||
1 if the LED has been toggled; otherwise 0.
|
||||
*/
|
||||
unsigned char LED_Toggle(unsigned int led)
|
||||
{
|
||||
#ifdef PINS_LEDS
|
||||
// Check if LED exists
|
||||
if (led >= numLeds) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Toggle LED
|
||||
if (PIO_GetOutputDataStatus(&pinsLeds[led])) {
|
||||
|
||||
PIO_Clear(&pinsLeds[led]);
|
||||
}
|
||||
else {
|
||||
|
||||
PIO_Set(&pinsLeds[led]);
|
||||
}
|
||||
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
66
Demo/Common/drivers/Atmel/at91lib/utility/led.h
Normal file
66
Demo/Common/drivers/Atmel/at91lib/utility/led.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
Title: LED
|
||||
|
||||
About: Purpose
|
||||
Small set of functions for simple and portable LED usage.
|
||||
|
||||
About: Usage
|
||||
1 - Configure one or more LEDs using <LED_Configure> and
|
||||
<LED_ConfigureAll>.
|
||||
2 - Set, clear and toggle LEDs using <LED_Set>, <LED_Clear> and
|
||||
<LED_Toggle>.
|
||||
3 - Get the current status of a LED using <LED_Get>.
|
||||
|
||||
LEDs are numbered starting from 0; the number of LEDs depend on the
|
||||
board being used. All the functions defined here will compile properly
|
||||
regardless of whether the LED is defined or not; they will simply
|
||||
return 0 when a LED which does not exist is given as an argument.
|
||||
Also, these functions take into account how each LED is connected on to
|
||||
board; thus, <LED_Set> might change the level on the corresponding pin
|
||||
to 0 or 1, but it will always light the LED on; same thing for the other
|
||||
methods.
|
||||
*/
|
||||
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Exported functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern unsigned char LED_Configure(unsigned int led);
|
||||
extern unsigned char LED_Set(unsigned int led);
|
||||
extern unsigned char LED_Clear(unsigned int led);
|
||||
extern unsigned char LED_Toggle(unsigned int led);
|
||||
|
||||
#endif //#ifndef LED_H
|
||||
|
134
Demo/Common/drivers/Atmel/at91lib/utility/trace.h
Normal file
134
Demo/Common/drivers/Atmel/at91lib/utility/trace.h
Normal file
|
@ -0,0 +1,134 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
Title: Trace
|
||||
|
||||
About: Purpose
|
||||
Standard output methods for reporting debug information, warnings and
|
||||
errors, which can be turned on/off.
|
||||
|
||||
About: Usage
|
||||
1 - Initialize the DBGU using <trace_CONFIGURE>.
|
||||
2 - Uses the <trace_LOG> macro to output traces throughout the program.
|
||||
3 - Turn off all traces by defining the NOTRACE symbol during
|
||||
compilation.
|
||||
4 - Disable a group of trace by changing the value of <trace_LEVEL>
|
||||
during compilation; traces with a level below <trace_LEVEL> are not
|
||||
generated.
|
||||
*/
|
||||
|
||||
#ifndef TRACE_H
|
||||
#define TRACE_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !defined(NOTRACE)
|
||||
#include <board.h>
|
||||
#include <dbgu/dbgu.h>
|
||||
#include <pio/pio.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Constants: Trace levels
|
||||
trace_FATAL - Indicates a major error which prevents the program from
|
||||
going any further.
|
||||
trace_ERROR - Indicates an error which may not stop the program
|
||||
execution, but which indicates there is a problem with the code.
|
||||
trace_WARNING - Indicates that a minor error has happened. In most case
|
||||
it can be discarded safely; it may even be expected.
|
||||
trace_INFO - Informational trace about the program execution. Should
|
||||
enable the user to see the execution flow.
|
||||
trace_DEBUG - Traces whose only purpose is for debugging the program,
|
||||
and which do not produce meaningful information otherwise.
|
||||
*/
|
||||
#define trace_DEBUG 0
|
||||
#define trace_INFO 1
|
||||
#define trace_WARNING 2
|
||||
#define trace_ERROR 3
|
||||
#define trace_FATAL 4
|
||||
|
||||
/*
|
||||
Constant: trace_LEVEL
|
||||
Minimum level of traces that are output. By default, all traces are
|
||||
output; change the value of this symbol during compilation for a more
|
||||
restrictive behavior.
|
||||
*/
|
||||
#if !defined(trace_LEVEL)
|
||||
#define trace_LEVEL 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
Macro: trace_CONFIGURE
|
||||
Initializes the DBGU unless the NOTRACE symbol has been defined.
|
||||
|
||||
Parameters:
|
||||
mode - DBGU mode.
|
||||
baudrate - DBGU baudrate.
|
||||
mck - Master clock frequency.
|
||||
*/
|
||||
#if !defined(NOTRACE)
|
||||
#define trace_CONFIGURE(mode, baudrate, mck) { \
|
||||
const Pin pinsDbgu[] = {PINS_DBGU}; \
|
||||
PIO_Configure(pinsDbgu, PIO_LISTSIZE(pinsDbgu)); \
|
||||
DBGU_Configure(mode, baudrate, mck); \
|
||||
}
|
||||
#else
|
||||
#define trace_CONFIGURE(...)
|
||||
#endif
|
||||
|
||||
/*
|
||||
Macro: trace_LOG
|
||||
Outputs a formatted string using <printf> if the log level is high
|
||||
enough. Can be disabled by defining the NOTRACE symbol during
|
||||
compilation.
|
||||
|
||||
Parameters:
|
||||
level - Trace level (see <Trace levels>).
|
||||
format - Formatted string to output.
|
||||
... - Additional parameters, depending on the formatted string.
|
||||
*/
|
||||
#if !defined(NOTRACE)
|
||||
#define trace_LOG(level, ...) { \
|
||||
if (level >= trace_LEVEL) { \
|
||||
printf(__VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define trace_LOG(...)
|
||||
#endif
|
||||
|
||||
#endif //#ifndef TRACE_H
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue