[sam] state-of-the-art commit

This commit is contained in:
aethaniel 2011-07-11 01:51:24 +02:00
parent ef4abb62b0
commit 03c064e946
94 changed files with 551 additions and 1051 deletions

View File

@ -1,18 +1,18 @@
#ifndef Arduino_h
#define Arduino_h
#include <stdint.h>
//#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
//! Include SAM3S-EK BSP headers
#include "variant.h"
#include "binary.h"
#ifdef __cplusplus
extern "C"{
#endif
#endif // __cplusplus
#define HIGH 0x1
#define LOW 0x0
@ -45,7 +45,7 @@ extern "C"{
// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif
#endif // abs
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
@ -76,32 +76,33 @@ typedef unsigned int word;
#define bit(b) (1UL << (b))
typedef uint8_t boolean;
typedef uint8_t byte;
// TODO: to be checked
typedef uint8_t boolean ;
typedef uint8_t byte ;
void init(void);
void init( void ) ;
void pinMode(uint8_t, uint8_t);
void digitalWrite(uint8_t, uint8_t);
int digitalRead(uint8_t);
int analogRead(uint8_t);
void analogReference(uint8_t mode);
void analogWrite(uint8_t, int);
void pinMode( uint8_t, uint8_t ) ;
void digitalWrite( uint8_t, uint8_t ) ;
int digitalRead( uint8_t ) ;
int analogRead( uint8_t ) ;
void analogReference( uint8_t mode ) ;
void analogWrite( uint8_t, int ) ;
unsigned long millis(void);
unsigned long micros(void);
unsigned long millis( void ) ;
unsigned long micros( void ) ;
//void delay(unsigned long);
#define delay( dwMs ) Wait( dwMs )
void delayMicroseconds(unsigned int us);
void delayMicroseconds( unsigned int us ) ;
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
void shiftOut( uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val ) ;
uint8_t shiftIn( uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder ) ;
void attachInterrupt(uint8_t, void (*)(void), int mode);
void detachInterrupt(uint8_t);
void attachInterrupt( uint8_t, void (*)(void), int mode ) ;
void detachInterrupt( uint8_t ) ;
void setup(void);
void loop(void);
void setup( void ) ;
void loop( void ) ;
// Get the bit location within the hardware port of the given virtual pin.
// This comes from the pins_*.c file for the active board configuration.
@ -125,31 +126,68 @@ void loop(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __cplusplus
#ifdef __cplusplus
#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
# include "WCharacter.h"
# include "WString.h"
# include "HardwareSerial.h"
uint16_t makeWord(uint16_t w);
uint16_t makeWord(byte h, byte l);
uint16_t makeWord( uint16_t w ) ;
uint16_t makeWord( byte h, byte l ) ;
#define word(...) makeWord(__VA_ARGS__)
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
unsigned long pulseIn( uint8_t pin, uint8_t state, unsigned long timeout = 1000000L ) ;
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
void noTone(uint8_t _pin);
void tone( uint8_t _pin, unsigned int frequency, unsigned long duration = 0 ) ;
void noTone( uint8_t _pin ) ;
// WMath prototypes
long random(long);
long random(long, long);
void randomSeed(unsigned int);
long map(long, long, long, long, long);
long random( long ) ;
long random( long, long ) ;
void randomSeed( unsigned int ) ;
long map( long, long, long, long, long ) ;
#endif
#endif // __cplusplus
//! Include variant header
#include "variant.h"
//! Definitions and types for pins
typedef enum _EAnalogChannel
{
ADC0,
ADC1,
ADC2,
ADC3,
ADC4,
ADC5,
ADC6,
ADC7,
ADC8,
ADC9,
ADC10,
ADC11,
ADC12,
ADC13,
ADC14,
ADC15,
DAC0,
DAC1
} EAnalogChannel ;
/* Types used for the tables below */
typedef struct _PinDescription
{
Pio* pPort ;
uint32_t dwPin ;
uint32_t dwPeripheralId ;
EPioType dwPinType ;
uint32_t dwPinAttribute ;
EAnalogChannel dwAnalogChannel ;
} PinDescription ;
#include "pins_arduino.h"
#endif
#endif // Arduino_h

View File

@ -1,8 +1,9 @@
#include "wiring_private.h"
//#include "wiring_private.h"
#include <stdint.h>
#include "HardwareSerial.h"
inline void store_char( uint8_t c, ring_buffer *pBuffer )
extern void store_char( uint8_t c, ring_buffer* pBuffer )
{
int i = (unsigned int)(pBuffer->head + 1) % SERIAL_BUFFER_SIZE;

View File

@ -1,8 +1,7 @@
#ifndef HardwareSerial_h
#define HardwareSerial_h
#include <inttypes.h>
#include <stdint.h>
#include "Stream.h"
// Define constants and variables for buffering incoming serial data. We're
@ -34,6 +33,9 @@ class HardwareSerial : public Stream
virtual void write( const uint8_t c ) =0 ;
using Print::write ; // pull in write(str) and write(buf, size) from Print
};
} ;
// Complementary API
extern void store_char( uint8_t c, ring_buffer* pBuffer ) ;
#endif // HardwareSerial_h

View File

@ -43,10 +43,11 @@ void Print::write(const uint8_t *buffer, size_t size)
write(*buffer++);
}
void Print::print(const String &s)
void Print::print( const String &s )
{
for (int i = 0; i < s.length(); i++) {
write(s[i]);
for ( int i = 0 ; i < (int)s.length() ; i++ )
{
write( s[i] ) ;
}
}

View File

@ -3,13 +3,12 @@
#include <string.h>
#include "UART.h"
// Constructors ////////////////////////////////////////////////////////////////
UARTClass::UARTClass( ring_buffer* rx_buffer, ring_buffer* tx_buffer, Uart* pUart, IRQn_Type dwIrq, uint32_t dwId )
UARTClass::UARTClass( Uart* pUart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer )
{
_rx_buffer = rx_buffer ;
_tx_buffer = tx_buffer ;
_rx_buffer = pRx_buffer ;
_tx_buffer = pTx_buffer ;
_pUart=pUart ;
_dwIrq=dwIrq ;
@ -31,7 +30,7 @@ void UARTClass::begin( const uint32_t dwBaudRate )
/* Configure baudrate */
/* Asynchronous, no oversampling */
_pUart->UART_BRGR = (BOARD_MCK / dwBaudRate) / 16 ;
_pUart->UART_BRGR = (VARIANT_MCK / dwBaudRate) / 16 ;
/* Disable PDC channel */
_pUart->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS ;
@ -116,10 +115,9 @@ void UARTClass::write( const uint8_t c )
void UARTClass::IrqHandler( void )
{
/*
// RX char IT
unsigned char c = _pUart->UART_RHR ;
store_char(c, &rx_buffer3);
store_char( c, _rx_buffer ) ;
// TX FIFO empty IT
if ( _tx_buffer->head == _tx_buffer->tail )
@ -129,11 +127,10 @@ void UARTClass::IrqHandler( void )
else
{
// There is more data in the output buffer. Send the next byte
unsigned char c = _tx_buffer->buffer[_tx_buffer->tail] ;
c = _tx_buffer->buffer[_tx_buffer->tail] ;
_tx_buffer->tail = (_tx_buffer->tail + 1) % SERIAL_BUFFER_SIZE ;
_pUart->UART_THR = c ;
}
*/
}

View File

@ -1,7 +1,9 @@
#ifndef _UART_
#define _UART_
#include <inttypes.h>
// UART.cpp need this class to be predefined
class UARTClass ;
#include "wiring_private.h"
class UARTClass : public HardwareSerial
@ -12,7 +14,7 @@ class UARTClass : public HardwareSerial
uint32_t _dwId ;
public:
UARTClass( ring_buffer *rx_buffer, ring_buffer *tx_buffer, Uart* pUart, IRQn_Type dwIrq, uint32_t dwId ) ;
UARTClass( Uart* pUart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer ) ;
void begin( const uint32_t dwBaudRate ) ;
void end( void ) ;

View File

@ -5,10 +5,10 @@
// Constructors ////////////////////////////////////////////////////////////////
USARTClass::USARTClass( ring_buffer *rx_buffer, ring_buffer *tx_buffer, Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId )
USARTClass::USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer )
{
_rx_buffer = rx_buffer ;
_tx_buffer = tx_buffer ;
_rx_buffer = pRx_buffer ;
_tx_buffer = pTx_buffer ;
_pUsart=pUsart ;
_dwIrq=dwIrq ;
@ -19,7 +19,7 @@ USARTClass::USARTClass( ring_buffer *rx_buffer, ring_buffer *tx_buffer, Usart* p
void USARTClass::begin( const uint32_t dwBaudRate )
{
/* Configure PMC */
/* Configure PMC */
PMC_EnablePeripheral( _dwId ) ;
/* Reset and disable receiver & transmitter */
@ -31,7 +31,7 @@ void USARTClass::begin( const uint32_t dwBaudRate )
/* Configure baudrate */
/* Asynchronous, no oversampling */
_pUsart->US_BRGR = (BOARD_MCK / dwBaudRate) / 16 ;
_pUsart->US_BRGR = (VARIANT_MCK / dwBaudRate) / 16 ;
/* Disable PDC channel */
_pUsart->US_PTCR = US_PTCR_RXTDIS | US_PTCR_TXTDIS ;
@ -42,32 +42,96 @@ void USARTClass::begin( const uint32_t dwBaudRate )
void USARTClass::end()
{
// wait for transmission of outgoing data
while ( _tx_buffer->head != _tx_buffer->tail )
{
}
// clear any received data
_rx_buffer->head = _rx_buffer->tail ;
PMC_DisablePeripheral( _dwId ) ;
}
int USARTClass::available( void )
{
return 0 ;
return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE ;
}
int USARTClass::peek( void )
{
return 0 ;
if ( _rx_buffer->head == _rx_buffer->tail )
{
return -1 ;
}
else
{
return _rx_buffer->buffer[_rx_buffer->tail] ;
}
}
int USARTClass::read( void )
{
return 0 ;
// if the head isn't ahead of the tail, we don't have any characters
if ( _rx_buffer->head == _rx_buffer->tail )
{
return -1 ;
}
else
{
unsigned char c = _rx_buffer->buffer[_rx_buffer->tail] ;
_rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE ;
return c ;
}
}
void USARTClass::flush( void )
{
while ( _tx_buffer->head != _tx_buffer->tail )
{
}
}
void USARTClass::write( uint8_t c )
{
int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE ;
// If the output buffer is full, there's nothing for it other than to
// wait for the interrupt handler to empty it a bit
while ( i == _tx_buffer->tail )
{
}
_tx_buffer->buffer[_tx_buffer->head] = c ;
_tx_buffer->head = i ;
/* Wait for the transmitter to be ready */
while ( (_pUsart->US_CSR & US_CSR_TXEMPTY) == 0 ) ;
/* Send character */
_pUsart->US_THR=c ;
}
void USARTClass::IrqHandler( void )
{
// RX char IT
unsigned char c = _pUsart->US_RHR ;
store_char( c, _rx_buffer ) ;
// TX FIFO empty IT
if ( _tx_buffer->head == _tx_buffer->tail )
{
// Buffer empty, so disable interrupts
}
else
{
// There is more data in the output buffer. Send the next byte
c = _tx_buffer->buffer[_tx_buffer->tail] ;
_tx_buffer->tail = (_tx_buffer->tail + 1) % SERIAL_BUFFER_SIZE ;
_pUsart->US_THR = c ;
}
}

View File

@ -1,7 +1,9 @@
#ifndef _USART_
#define _USART_
#include <inttypes.h>
// USART.cpp need this class to be predefined
class USARTClass ;
#include "wiring_private.h"
class USARTClass : public HardwareSerial
@ -12,7 +14,7 @@ class USARTClass : public HardwareSerial
uint32_t _dwId ;
public:
USARTClass( ring_buffer *rx_buffer, ring_buffer *tx_buffer, Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId ) ;
USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer ) ;
void begin( const uint32_t dwBaudRate ) ;
void end( void ) ;

View File

@ -1,7 +1,5 @@
#include "board.h"
#include <inttypes.h>
#include <stdio.h>
//#include <inttypes.h>
//#include <stdio.h>
#include "wiring_private.h"

View File

@ -31,7 +31,7 @@
* Headers
*----------------------------------------------------------------------------*/
#include "board.h"
#include "Arduino.h"
/*----------------------------------------------------------------------------
* Exported variables
@ -130,8 +130,8 @@ void Reset_Handler( void )
{
uint32_t *pSrc, *pDest ;
/* Low level Initialize */
LowLevelInit() ;
/* Arduino board Low level Initialization */
init() ;
/* Initialize the relocate segment */
pSrc = &_etext ;

View File

@ -1,8 +1,8 @@
# Makefile for compiling libboard
# Makefile for compiling libArduino
.SUFFIXES: .o .a .c .s
CHIP=sam3s4
BOARD=sam3s_ek
VARIANT=sam3s_ek
LIBNAME=arduino_sam3s_ek
TOOLCHAIN=gcc
@ -15,22 +15,27 @@ OUTPUT_BIN = ../lib
# Libraries
PROJECT_BASE_PATH = ..
BSP_PATH = ../../../../tools
SYSTEM_PATH = ../../../system
CMSIS_PATH = $(SYSTEM_PATH)/CMSIS/CM3/CoreSupport
VARIANT_PATH = ../../../variants/sam3s-ek
#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
vpath %.h $(PROJECT_BASE_PATH) $(BSP_PATH)/libchip_sam3s $(BSP_PATH)/libboard_sam3s-ek
vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH)
vpath %.c $(PROJECT_BASE_PATH)
vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH)/sam3s_ek
vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH)
VPATH+=$(PROJECT_BASE_PATH)
INCLUDES = -I$(PROJECT_BASE_PATH)
INCLUDES = -I$(PROJECT_BASE_PATH)/sam3s_ek
INCLUDES += -I$(BSP_PATH)/libchip_sam3s
INCLUDES += -I$(BSP_PATH)/libboard_sam3s-ek
INCLUDES = -I$(PROJECT_BASE_PATH)
INCLUDES += -I$(SYSTEM_PATH)
INCLUDES += -I$(SYSTEM_PATH)/libsam
INCLUDES += -I$(VARIANT_PATH)
INCLUDES += -I$(VARIANT_PATH)
INCLUDES += -I$(CMSIS_PATH)
#-------------------------------------------------------------------------------
ifdef DEBUG
@ -76,7 +81,8 @@ CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp)
CPP_OBJ_TEMP = $(patsubst %.cpp, %.o, $(notdir $(CPP_SRC)))
# during development, remove some files
CPP_OBJ_FILTER=Tone.o WMath.o WString.o
CPP_OBJ_FILTER=Tone.o WMath.o
#WString.o
CPP_OBJ=$(filter-out $(CPP_OBJ_FILTER), $(CPP_OBJ_TEMP))
@ -103,6 +109,8 @@ sam3s_ek: create_output $(OUTPUT_LIB)
create_output:
@echo --- Preparing sam3s_ek files in $(OUTPUT_PATH) $(OUTPUT_BIN)
@echo -------------------------
@echo *$(INCLUDES)
@echo -------------------------
@echo *$(C_SRC)
@echo -------------------------
@echo *$(C_OBJ)
@ -127,7 +135,8 @@ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c
@$(CC) -c $(CFLAGS) $< -o $@
$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp
@$(CC) -c $(CPPFLAGS) $< -o $@
# @$(CC) -c $(CPPFLAGS) $< -o $@
$(CC) -xc++ -c $(CPPFLAGS) $< -o $@
$(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s
@$(AS) -c $(ASFLAGS) $< -o $@
@ -142,5 +151,5 @@ clean:
-@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1
-@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1
#$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: $(PROJECT_BASE_PATH)/board.h $(wildcard $(PROJECT_BASE_PATH)/include/*.h)
#$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: $(PROJECT_BASE_PATH)/board.h $(wildcard $(PROJECT_BASE_PATH)/include/*.h)
#$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: $(PROJECT_BASE_PATH)/chip.h $(wildcard $(PROJECT_BASE_PATH)/include/*.h)
#$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: $(PROJECT_BASE_PATH)/chip.h $(wildcard $(PROJECT_BASE_PATH)/include/*.h)

View File

@ -32,7 +32,7 @@ CFLAGS += -Wcast-align
#CFLAGS += -Wconversion
CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections
CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP)
CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D$(VARIANT)
# To reduce application size use only integer printf function.
CFLAGS += -Dprintf=iprintf

View File

@ -1,199 +0,0 @@
WInterrupts.o:
00000000 r LED_BLUE
00000001 r LED_GREEN
00000002 r LED_RED
00000005 r MISO
00000004 r MOSI
00000006 r SCK
00000003 r SS
00000000 T attachInterrupt
00000000 T detachInterrupt
00000000 b intFunc
wiring.o:
00000004 r APinDescription
U GetTickCount
U LowLevelInit
00000002 r MISO
00000001 r MOSI
00000000 t NVIC_SetPriority
U PIO_Configure
00000003 r SCK
00000000 r SS
00000000 t SysTick_Config
00000000 T SysTick_Handler
U TimeTick_Increment
U WDT_Disable
00000000 T Wait
00000000 T delayMicroseconds
00000000 T init
00000000 T micros
00000000 T millis
00000008 b timer0_fract
00000004 B timer0_millis
00000000 B timer0_overflow_count
wiring_shift.o:
00000004 r APinDescription
00000002 r MISO
00000001 r MOSI
00000003 r SCK
00000000 r SS
U digitalRead
U digitalWrite
00000000 T shiftIn
00000000 T shiftOut
HardwareSerial.o:
00000004 r _ZL15APinDescription
00000000 r _ZL2SS
00000003 r _ZL3SCK
00000002 r _ZL4MISO
00000001 r _ZL4MOSI
Print.o:
00000030 r _ZL15APinDescription
0000002b r _ZL2SS
0000002e r _ZL3SCK
0000002d r _ZL4MISO
0000002c r _ZL4MOSI
00000000 T _ZN5Print10printFloatEdh
00000000 T _ZN5Print11printNumberEmh
00000000 T _ZN5Print5printEPKc
00000000 T _ZN5Print5printERK6String
00000000 T _ZN5Print5printEc
00000000 T _ZN5Print5printEdi
00000000 T _ZN5Print5printEhi
00000000 T _ZN5Print5printEii
00000000 T _ZN5Print5printEji
00000000 T _ZN5Print5printEli
00000000 T _ZN5Print5printEmi
00000000 T _ZN5Print5writeEPKc
00000000 T _ZN5Print5writeEPKhj
00000000 T _ZN5Print7printlnEPKc
00000000 T _ZN5Print7printlnERK6String
00000000 T _ZN5Print7printlnEc
00000000 T _ZN5Print7printlnEdi
00000000 T _ZN5Print7printlnEhi
00000000 T _ZN5Print7printlnEii
00000000 T _ZN5Print7printlnEji
00000000 T _ZN5Print7printlnEli
00000000 T _ZN5Print7printlnEmi
00000000 T _ZN5Print7printlnEv
00000000 W _ZNK6String6lengthEv
U _ZNK6StringixEj
0000001c R _ZTI5Print
00000024 R _ZTS5Print
00000008 R _ZTV5Print
U _ZTVN10__cxxabiv117__class_type_infoE
U __aeabi_d2iz
U __aeabi_d2uiz
U __aeabi_dadd
U __aeabi_dcmplt
U __aeabi_ddiv
U __aeabi_dmul
U __aeabi_dsub
U __aeabi_i2d
U __aeabi_ui2d
U __aeabi_unwind_cpp_pr1
U __cxa_pure_virtual
UART.o:
U PMC_DisablePeripheral
U PMC_EnablePeripheral
00000048 r _ZL15APinDescription
00000043 r _ZL2SS
00000046 r _ZL3SCK
00000045 r _ZL4MISO
00000044 r _ZL4MOSI
00000000 W _ZN14HardwareSerialC1Ev
00000000 W _ZN14HardwareSerialC2Ev
00000000 n _ZN14HardwareSerialC5Ev
U _ZN5Print5writeEPKc
U _ZN5Print5writeEPKhj
00000000 W _ZN5PrintC1Ev
00000000 W _ZN5PrintC2Ev
00000000 n _ZN5PrintC5Ev
00000000 W _ZN6StreamC1Ev
00000000 W _ZN6StreamC2Ev
00000000 n _ZN6StreamC5Ev
00000000 T _ZN9UARTClass10IrqHandlerEv
00000000 T _ZN9UARTClass3endEv
00000000 T _ZN9UARTClass4peekEv
00000000 T _ZN9UARTClass4readEv
00000000 T _ZN9UARTClass5beginEm
00000000 T _ZN9UARTClass5flushEv
00000000 T _ZN9UARTClass5writeEh
00000000 T _ZN9UARTClass9availableEv
00000000 T _ZN9UARTClassC1EP12_ring_bufferS1_P4Uart4IRQnm
00000000 T _ZN9UARTClassC2EP12_ring_bufferS1_P4Uart4IRQnm
00000000 V _ZTI14HardwareSerial
U _ZTI5Print
00000000 V _ZTI6Stream
0000002c R _ZTI9UARTClass
00000000 V _ZTS14HardwareSerial
00000000 V _ZTS6Stream
00000038 R _ZTS9UARTClass
00000000 V _ZTV14HardwareSerial
U _ZTV5Print
00000000 V _ZTV6Stream
00000000 R _ZTV9UARTClass
U _ZTVN10__cxxabiv120__si_class_type_infoE
U __aeabi_unwind_cpp_pr1
U __cxa_pure_virtual
USART.o:
U PMC_EnablePeripheral
0000004c r _ZL15APinDescription
00000045 r _ZL2SS
00000048 r _ZL3SCK
00000047 r _ZL4MISO
00000046 r _ZL4MOSI
00000000 T _ZN10USARTClass10IrqHandlerEv
00000000 T _ZN10USARTClass3endEv
00000000 T _ZN10USARTClass4peekEv
00000000 T _ZN10USARTClass4readEv
00000000 T _ZN10USARTClass5beginEm
00000000 T _ZN10USARTClass5flushEv
00000000 T _ZN10USARTClass5writeEh
00000000 T _ZN10USARTClass9availableEv
00000000 T _ZN10USARTClassC1EP12_ring_bufferS1_P5Usart4IRQnm
00000000 T _ZN10USARTClassC2EP12_ring_bufferS1_P5Usart4IRQnm
00000000 W _ZN14HardwareSerialC1Ev
00000000 W _ZN14HardwareSerialC2Ev
00000000 n _ZN14HardwareSerialC5Ev
U _ZN5Print5writeEPKc
U _ZN5Print5writeEPKhj
00000000 W _ZN5PrintC1Ev
00000000 W _ZN5PrintC2Ev
00000000 n _ZN5PrintC5Ev
00000000 W _ZN6StreamC1Ev
00000000 W _ZN6StreamC2Ev
00000000 n _ZN6StreamC5Ev
0000002c R _ZTI10USARTClass
00000000 V _ZTI14HardwareSerial
U _ZTI5Print
00000000 V _ZTI6Stream
00000038 R _ZTS10USARTClass
00000000 V _ZTS14HardwareSerial
00000000 V _ZTS6Stream
00000000 R _ZTV10USARTClass
00000000 V _ZTV14HardwareSerial
U _ZTV5Print
00000000 V _ZTV6Stream
U _ZTVN10__cxxabiv120__si_class_type_infoE
U __aeabi_unwind_cpp_pr1
U __cxa_pure_virtual
main.o:
00000004 r _ZL15APinDescription
00000000 r _ZL2SS
00000003 r _ZL3SCK
00000002 r _ZL4MISO
00000001 r _ZL4MOSI
U __aeabi_unwind_cpp_pr0
U init
U loop
00000000 T main
U setup

View File

@ -1,135 +0,0 @@
WInterrupts.o:
00000000 T attachInterrupt
00000000 T detachInterrupt
00000000 b intFunc
wiring.o:
U GetTickCount
U LowLevelInit
U PIO_Configure
00000000 T SysTick_Handler
U TimeTick_Increment
U WDT_Disable
00000000 T Wait
00000000 T delayMicroseconds
00000000 T init
00000000 T micros
00000000 T millis
00000004 B timer0_millis
00000000 B timer0_overflow_count
wiring_shift.o:
U digitalRead
U digitalWrite
00000000 T shiftIn
00000000 T shiftOut
HardwareSerial.o:
Print.o:
00000000 T _ZN5Print10printFloatEdh
00000000 T _ZN5Print11printNumberEmh
00000000 T _ZN5Print5printEPKc
00000000 T _ZN5Print5printERK6String
00000000 T _ZN5Print5printEc
00000000 T _ZN5Print5printEdi
00000000 T _ZN5Print5printEhi
00000000 T _ZN5Print5printEii
00000000 T _ZN5Print5printEji
00000000 T _ZN5Print5printEli
00000000 T _ZN5Print5printEmi
00000000 T _ZN5Print5writeEPKc
00000000 T _ZN5Print5writeEPKhj
00000000 T _ZN5Print7printlnEPKc
00000000 T _ZN5Print7printlnERK6String
00000000 T _ZN5Print7printlnEc
00000000 T _ZN5Print7printlnEdi
00000000 T _ZN5Print7printlnEhi
00000000 T _ZN5Print7printlnEii
00000000 T _ZN5Print7printlnEji
00000000 T _ZN5Print7printlnEli
00000000 T _ZN5Print7printlnEmi
00000000 T _ZN5Print7printlnEv
U _ZNK6StringixEj
0000001c R _ZTI5Print
00000014 R _ZTS5Print
00000000 R _ZTV5Print
U _ZTVN10__cxxabiv117__class_type_infoE
U __aeabi_d2iz
U __aeabi_d2uiz
U __aeabi_dadd
U __aeabi_dcmplt
U __aeabi_ddiv
U __aeabi_dmul
U __aeabi_dsub
U __aeabi_i2d
U __aeabi_ui2d
U __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr1
U __cxa_pure_virtual
UART.o:
U PMC_DisablePeripheral
U PMC_EnablePeripheral
U _ZN5Print5writeEPKc
U _ZN5Print5writeEPKhj
00000000 T _ZN9UARTClass10IrqHandlerEv
00000000 T _ZN9UARTClass3endEv
00000000 T _ZN9UARTClass4peekEv
00000000 T _ZN9UARTClass4readEv
00000000 T _ZN9UARTClass5beginEm
00000000 T _ZN9UARTClass5flushEv
00000000 T _ZN9UARTClass5writeEh
00000000 T _ZN9UARTClass9availableEv
00000000 T _ZN9UARTClassC1EP12_ring_bufferS1_P4Uart4IRQnm
00000000 T _ZN9UARTClassC2EP12_ring_bufferS1_P4Uart4IRQnm
00000000 V _ZTI14HardwareSerial
U _ZTI5Print
00000000 V _ZTI6Stream
00000038 R _ZTI9UARTClass
00000000 V _ZTS14HardwareSerial
00000000 V _ZTS6Stream
0000002c R _ZTS9UARTClass
00000000 V _ZTV14HardwareSerial
00000000 V _ZTV6Stream
00000000 R _ZTV9UARTClass
U _ZTVN10__cxxabiv120__si_class_type_infoE
U __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr1
U __cxa_pure_virtual
USART.o:
U PMC_EnablePeripheral
00000000 T _ZN10USARTClass10IrqHandlerEv
00000000 T _ZN10USARTClass3endEv
00000000 T _ZN10USARTClass4peekEv
00000000 T _ZN10USARTClass4readEv
00000000 T _ZN10USARTClass5beginEm
00000000 T _ZN10USARTClass5flushEv
00000000 T _ZN10USARTClass5writeEh
00000000 T _ZN10USARTClass9availableEv
00000000 T _ZN10USARTClassC1EP12_ring_bufferS1_P5Usart4IRQnm
00000000 T _ZN10USARTClassC2EP12_ring_bufferS1_P5Usart4IRQnm
U _ZN5Print5writeEPKc
U _ZN5Print5writeEPKhj
0000003c R _ZTI10USARTClass
00000000 V _ZTI14HardwareSerial
U _ZTI5Print
00000000 V _ZTI6Stream
0000002c R _ZTS10USARTClass
00000000 V _ZTS14HardwareSerial
00000000 V _ZTS6Stream
00000000 R _ZTV10USARTClass
00000000 V _ZTV14HardwareSerial
00000000 V _ZTV6Stream
U _ZTVN10__cxxabiv120__si_class_type_infoE
U __aeabi_unwind_cpp_pr0
U __cxa_pure_virtual
main.o:
U __aeabi_unwind_cpp_pr1
U init
U loop
00000000 T main
U setup

View File

@ -39,7 +39,7 @@
*----------------------------------------------------------------------------*/
#include "board.h"
#include "variant.h"
#include <stdio.h>
#include <stdarg.h>

View File

@ -119,24 +119,75 @@ void delayMicroseconds(unsigned int us)
/*
* Cortex-M3 Systick IT handler
*/
void SysTick_Handler( void )
extern void SysTick_Handler( void )
{
// Increment tick count each ms
TimeTick_Increment() ;
}
//! Check Variant for PLL/Clock inits
#if defined sam3s_ek
#define VARIANT_PLLAR (CKGR_PLLAR_STUCKTO1 | \
CKGR_PLLAR_MULA( 0x0f ) | \
CKGR_PLLAR_PLLACOUNT( 0x1 ) | \
CKGR_PLLAR_DIVA( 0x3 ))
#else
#error "No settings for current VARIANT"
#endif
/**
* \brief Performs the low-level initialization of the chip.
* This includes EFC and master clock configuration.
* It also enable a low level on the pin NRST triggers a user reset.
*/
static void LowLevelInit_sam3s_ek( void )
{
/* Set 3 FWS for Embedded Flash Access @ 64MHz, we are now at 4MHz on Internal FastRC */
EFC->EEFC_FMR = EEFC_FMR_FWS( 3 ) ;
/* Initialize main oscillator */
if ( !(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL) )
{
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | CKGR_MOR_MOSCXTST(0x8) | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN ;
for ( ; !(PMC->PMC_SR & PMC_SR_MOSCXTS) ; ) ;
}
/* Switch to 3-20MHz Xtal oscillator */
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | CKGR_MOR_MOSCXTST(0x8) | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN | CKGR_MOR_MOSCSEL ;
for ( ; !(PMC->PMC_SR & PMC_SR_MOSCSELS) ; ) ;
PMC->PMC_MCKR = (PMC->PMC_MCKR & ~(uint32_t)PMC_MCKR_CSS_Msk) | PMC_MCKR_CSS_MAIN_CLK ;
for ( ; !(PMC->PMC_SR & PMC_SR_MCKRDY) ; ) ;
/* Initialize PLLA */
PMC->CKGR_PLLAR = VARIANT_PLLAR ;
for ( ; !(PMC->PMC_SR & PMC_SR_LOCKA) ; ) ;
/* Switch to main clock */
PMC->PMC_MCKR = ((PMC_MCKR_PRES_CLK | PMC_MCKR_CSS_PLLA_CLK) & ~PMC_MCKR_CSS_Msk) | PMC_MCKR_CSS_MAIN_CLK ;
for ( ; !(PMC->PMC_SR & PMC_SR_MCKRDY) ; ) ;
PMC->PMC_MCKR = (PMC_MCKR_PRES_CLK | PMC_MCKR_CSS_PLLA_CLK) ;
for ( ; !(PMC->PMC_SR & PMC_SR_MCKRDY) ; ) ;
}
void init( void )
{
// Disable watchdog
// Disable watchdog, common to all SAM variants
WDT_Disable( WDT ) ;
#if defined sam3s_ek
// Set Main clock to 64MHz using external 12MHz
LowLevelInit() ;
LowLevelInit_sam3s_ek() ;
#else
# error "Board/Variant not defined"
#endif
// Set Systick to 1ms interval
SysTick_Config( BOARD_MCK/1000 ) ;
// Set Systick to 1ms interval, common to all SAM3 variants
SysTick_Config( VARIANT_MCK/1000 ) ;
// Initialize Serial port UART0
// Initialize Serial port UART0, common to all SAM3 variants
PIO_Configure( APinDescription[PINS_UART].pPort, APinDescription[PINS_UART].dwPinType,
APinDescription[PINS_UART].dwPin, APinDescription[PINS_UART].dwPinAttribute ) ;
}

View File

@ -25,6 +25,7 @@
#ifndef WiringPrivate_h
#define WiringPrivate_h
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>

View File

@ -59,4 +59,6 @@
#include "include/usart.h"
#include "include/wdt.h"
#include "include/timetick.h"
#endif /* _LIB_SAM3S_ */

View File

@ -3,7 +3,7 @@ acc.o:
00000000 T ACC_Configure
00000000 T ACC_GetComparisionResult
00000000 T ACC_SetComparisionPair
00000030 r __FUNCTION__.5770
00000030 r __FUNCTION__.5780
U __assert_func
adc.o:
@ -22,11 +22,11 @@ adc.o:
00000000 T ADC_SetCompareMode
00000000 T ADC_SetComparisonWindow
00000000 T ADC_cfgFrequency
00000098 r __FUNCTION__.5791
00000080 r __FUNCTION__.5797
00000068 r __FUNCTION__.5802
00000098 r __FUNCTION__.5801
00000080 r __FUNCTION__.5807
00000068 r __FUNCTION__.5812
U __assert_func
00000000 d adwValue.5790
00000000 d adwValue.5800
00000000 t calcul_startup
async.o:
@ -41,7 +41,7 @@ dacc.o:
00000000 T DACC_Initialize
00000000 T DACC_SetConversionData
00000000 T DACC_WriteBuffer
00000034 r __FUNCTION__.5774
00000034 r __FUNCTION__.5784
U __assert_func
efc.o:
@ -54,10 +54,10 @@ efc.o:
00000000 T EFC_SetWaitState
00000000 T EFC_StartCommand
00000000 T EFC_TranslateAddress
00000000 b IAP_PerformCommand.6415
00000134 r __FUNCTION__.6377
00000120 r __FUNCTION__.6385
0000010c r __FUNCTION__.6397
00000000 b IAP_PerformCommand.6425
00000134 r __FUNCTION__.6387
00000120 r __FUNCTION__.6395
0000010c r __FUNCTION__.6407
U __assert_func
exceptions.o:
@ -123,13 +123,13 @@ flashd.o:
00000000 T FLASHD_SetGPNVM
00000000 T FLASHD_Unlock
00000000 T FLASHD_Write
00000198 r __FUNCTION__.6133
00000188 r __FUNCTION__.6149
00000178 r __FUNCTION__.6201
00000164 r __FUNCTION__.6210
00000154 r __FUNCTION__.6214
00000140 r __FUNCTION__.6218
0000012c r __FUNCTION__.6223
00000198 r __FUNCTION__.6143
00000188 r __FUNCTION__.6159
00000178 r __FUNCTION__.6211
00000164 r __FUNCTION__.6220
00000154 r __FUNCTION__.6224
00000140 r __FUNCTION__.6228
0000012c r __FUNCTION__.6233
U __assert_func
00000000 b _adwPageBuffer
00000000 d _aucPageBuffer
@ -159,7 +159,7 @@ pio_capture.o:
00000000 T PIO_CaptureInit
U PMC_EnablePeripheral
00000000 b _PioCaptureCopy
00000088 r __FUNCTION__.6371
00000088 r __FUNCTION__.6381
U __assert_func
pmc.o:
@ -168,13 +168,13 @@ pmc.o:
00000000 T PMC_EnableAllPeripherals
00000000 T PMC_EnablePeripheral
00000000 T PMC_IsPeriphEnabled
00000048 r __FUNCTION__.5764
00000030 r __FUNCTION__.5768
0000001c r __FUNCTION__.5790
00000048 r __FUNCTION__.5774
00000030 r __FUNCTION__.5778
0000001c r __FUNCTION__.5800
U __assert_func
pwmc.o:
00000284 r C.2.7069
00000284 r C.2.7084
00000000 t FindClockConfiguration
00000000 T PWMC_ConfigureChannel
00000000 T PWMC_ConfigureChannelExt
@ -201,14 +201,14 @@ pwmc.o:
00000000 T PWMC_SetSyncChannelUpdatePeriod
00000000 T PWMC_SetSyncChannelUpdateUnlock
00000000 T PWMC_WriteBuffer
000002b0 r __FUNCTION__.5768
0000026c r __FUNCTION__.5779
00000250 r __FUNCTION__.5794
00000238 r __FUNCTION__.5805
00000224 r __FUNCTION__.5816
00000210 r __FUNCTION__.5823
000001f0 r __FUNCTION__.5905
000001d4 r __FUNCTION__.5911
000002b0 r __FUNCTION__.5778
0000026c r __FUNCTION__.5789
00000250 r __FUNCTION__.5804
00000238 r __FUNCTION__.5815
00000224 r __FUNCTION__.5826
00000210 r __FUNCTION__.5833
000001f0 r __FUNCTION__.5915
000001d4 r __FUNCTION__.5921
U __assert_func
rtc.o:
@ -224,9 +224,9 @@ rtc.o:
00000000 T RTC_SetHourMode
00000000 T RTC_SetTime
00000000 T RTC_SetTimeAlarm
00000074 r __FUNCTION__.5765
00000064 r __FUNCTION__.5774
00000054 r __FUNCTION__.5779
00000074 r __FUNCTION__.5775
00000064 r __FUNCTION__.5784
00000054 r __FUNCTION__.5789
U __assert_func
rtt.o:
@ -235,8 +235,8 @@ rtt.o:
00000000 T RTT_GetTime
00000000 T RTT_SetAlarm
00000000 T RTT_SetPrescaler
00000048 r __FUNCTION__.5772
00000038 r __FUNCTION__.5780
00000048 r __FUNCTION__.5782
00000038 r __FUNCTION__.5790
U __assert_func
spi.o:
@ -300,9 +300,9 @@ tc.o:
00000000 T TC_FindMckDivisor
00000000 T TC_Start
00000000 T TC_Stop
0000006c r __FUNCTION__.5767
00000060 r __FUNCTION__.5773
00000058 r __FUNCTION__.5779
0000006c r __FUNCTION__.5777
00000060 r __FUNCTION__.5783
00000058 r __FUNCTION__.5789
U __assert_func
twi.o:
@ -321,18 +321,18 @@ twi.o:
00000000 T TWI_Stop
00000000 T TWI_TransferComplete
00000000 T TWI_WriteByte
00000180 r __FUNCTION__.6359
0000016c r __FUNCTION__.6374
00000160 r __FUNCTION__.6378
00000150 r __FUNCTION__.6385
00000140 r __FUNCTION__.6389
00000130 r __FUNCTION__.6394
00000120 r __FUNCTION__.6402
00000110 r __FUNCTION__.6416
00000100 r __FUNCTION__.6421
000000f0 r __FUNCTION__.6425
000000dc r __FUNCTION__.6430
000000c4 r __FUNCTION__.6434
00000180 r __FUNCTION__.6369
0000016c r __FUNCTION__.6384
00000160 r __FUNCTION__.6388
00000150 r __FUNCTION__.6395
00000140 r __FUNCTION__.6399
00000130 r __FUNCTION__.6404
00000120 r __FUNCTION__.6412
00000110 r __FUNCTION__.6426
00000100 r __FUNCTION__.6431
000000f0 r __FUNCTION__.6435
000000dc r __FUNCTION__.6440
000000c4 r __FUNCTION__.6444
U __assert_func
twid.o:
@ -352,10 +352,10 @@ twid.o:
U TWI_Stop
U TWI_TransferComplete
U TWI_WriteByte
000000b4 r __FUNCTION__.6364
000000a4 r __FUNCTION__.6371
00000098 r __FUNCTION__.6384
0000008c r __FUNCTION__.6406
000000b4 r __FUNCTION__.6374
000000a4 r __FUNCTION__.6381
00000098 r __FUNCTION__.6394
0000008c r __FUNCTION__.6416
U __assert_func
usart.o:
@ -374,7 +374,7 @@ usart.o:
00000000 T USART_SetTransmitterEnabled
00000000 T USART_Write
00000000 T USART_WriteBuffer
00000024 r __FUNCTION__.6158
00000024 r __FUNCTION__.6168
U __assert_func
wdt.o:
@ -385,3 +385,13 @@ wdt.o:
00000000 T WDT_Restart
core_cm3.o:
timetick.o:
00000000 T GetTickCount
00000000 t NVIC_SetPriority
00000000 T Sleep
00000000 t SysTick_Config
00000000 T TimeTick_Configure
00000000 T TimeTick_Increment
00000000 T Wait
00000000 b _dwTickCount

View File

@ -3,7 +3,7 @@ acc.o:
00000000 T ACC_Configure
00000000 T ACC_GetComparisionResult
00000000 T ACC_SetComparisionPair
00000000 r __FUNCTION__.5770
00000000 r __FUNCTION__.5780
U __assert_func
adc.o:
@ -22,8 +22,8 @@ adc.o:
00000000 T ADC_SetCompareMode
00000000 T ADC_SetComparisonWindow
00000000 T ADC_cfgFrequency
00000000 r __FUNCTION__.5797
00000015 r __FUNCTION__.5802
00000000 r __FUNCTION__.5807
00000015 r __FUNCTION__.5812
U __assert_func
async.o:
@ -38,7 +38,7 @@ dacc.o:
00000000 T DACC_Initialize
00000000 T DACC_SetConversionData
00000000 T DACC_WriteBuffer
00000000 r __FUNCTION__.5774
00000000 r __FUNCTION__.5784
U __assert_func
efc.o:
@ -51,10 +51,10 @@ efc.o:
00000000 T EFC_SetWaitState
00000000 T EFC_StartCommand
00000000 T EFC_TranslateAddress
00000000 b IAP_PerformCommand.6406
00000000 r __FUNCTION__.6368
00000015 r __FUNCTION__.6376
00000028 r __FUNCTION__.6388
00000000 b IAP_PerformCommand.6416
00000000 r __FUNCTION__.6378
00000015 r __FUNCTION__.6386
00000028 r __FUNCTION__.6398
U __assert_func
exceptions.o:
@ -120,12 +120,12 @@ flashd.o:
00000000 T FLASHD_SetGPNVM
00000000 T FLASHD_Unlock
00000000 T FLASHD_Write
00000000 r __FUNCTION__.6140
0000000d r __FUNCTION__.6192
0000001d r __FUNCTION__.6201
0000002f r __FUNCTION__.6205
0000003f r __FUNCTION__.6209
00000051 r __FUNCTION__.6214
00000000 r __FUNCTION__.6150
0000000d r __FUNCTION__.6202
0000001d r __FUNCTION__.6211
0000002f r __FUNCTION__.6215
0000003f r __FUNCTION__.6219
00000051 r __FUNCTION__.6224
U __assert_func
00000004 b _adwPageBuffer
00000000 b _dwUseIAP
@ -154,7 +154,7 @@ pio_capture.o:
00000000 T PIO_CaptureInit
U PMC_EnablePeripheral
00000000 b _PioCaptureCopy
00000000 r __FUNCTION__.6362
00000000 r __FUNCTION__.6372
U __assert_func
pmc.o:
@ -163,13 +163,13 @@ pmc.o:
00000000 T PMC_EnableAllPeripherals
00000000 T PMC_EnablePeripheral
00000000 T PMC_IsPeriphEnabled
00000000 r __FUNCTION__.5764
00000015 r __FUNCTION__.5768
0000002b r __FUNCTION__.5790
00000000 r __FUNCTION__.5774
00000015 r __FUNCTION__.5778
0000002b r __FUNCTION__.5800
U __assert_func
pwmc.o:
00000000 r C.1.6987
00000000 r C.1.7002
00000000 t FindClockConfiguration
00000000 T PWMC_ConfigureChannel
00000000 T PWMC_ConfigureChannelExt
@ -196,14 +196,14 @@ pwmc.o:
00000000 T PWMC_SetSyncChannelUpdatePeriod
00000000 T PWMC_SetSyncChannelUpdateUnlock
00000000 T PWMC_WriteBuffer
0000002c r __FUNCTION__.5768
00000043 r __FUNCTION__.5779
00000059 r __FUNCTION__.5794
00000072 r __FUNCTION__.5805
00000087 r __FUNCTION__.5816
00000099 r __FUNCTION__.5823
000000aa r __FUNCTION__.5905
000000c7 r __FUNCTION__.5911
0000002c r __FUNCTION__.5778
00000043 r __FUNCTION__.5789
00000059 r __FUNCTION__.5804
00000072 r __FUNCTION__.5815
00000087 r __FUNCTION__.5826
00000099 r __FUNCTION__.5833
000000aa r __FUNCTION__.5915
000000c7 r __FUNCTION__.5921
U __assert_func
rtc.o:
@ -219,9 +219,9 @@ rtc.o:
00000000 T RTC_SetHourMode
00000000 T RTC_SetTime
00000000 T RTC_SetTimeAlarm
00000000 r __FUNCTION__.5765
00000010 r __FUNCTION__.5774
0000001d r __FUNCTION__.5779
00000000 r __FUNCTION__.5775
00000010 r __FUNCTION__.5784
0000001d r __FUNCTION__.5789
U __assert_func
rtt.o:
@ -230,8 +230,8 @@ rtt.o:
00000000 T RTT_GetTime
00000000 T RTT_SetAlarm
00000000 T RTT_SetPrescaler
00000000 r __FUNCTION__.5772
0000000d r __FUNCTION__.5780
00000000 r __FUNCTION__.5782
0000000d r __FUNCTION__.5790
U __assert_func
spi.o:
@ -295,9 +295,9 @@ tc.o:
00000000 T TC_FindMckDivisor
00000000 T TC_Start
00000000 T TC_Stop
00000000 r __FUNCTION__.5767
0000000d r __FUNCTION__.5773
00000016 r __FUNCTION__.5779
00000000 r __FUNCTION__.5777
0000000d r __FUNCTION__.5783
00000016 r __FUNCTION__.5789
U __assert_func
twi.o:
@ -316,18 +316,18 @@ twi.o:
00000000 T TWI_Stop
00000000 T TWI_TransferComplete
00000000 T TWI_WriteByte
00000000 r __FUNCTION__.6350
00000014 r __FUNCTION__.6365
00000027 r __FUNCTION__.6369
00000030 r __FUNCTION__.6376
0000003e r __FUNCTION__.6380
0000004b r __FUNCTION__.6385
00000059 r __FUNCTION__.6393
00000068 r __FUNCTION__.6407
00000075 r __FUNCTION__.6412
00000083 r __FUNCTION__.6416
00000091 r __FUNCTION__.6421
000000a5 r __FUNCTION__.6425
00000000 r __FUNCTION__.6360
00000014 r __FUNCTION__.6375
00000027 r __FUNCTION__.6379
00000030 r __FUNCTION__.6386
0000003e r __FUNCTION__.6390
0000004b r __FUNCTION__.6395
00000059 r __FUNCTION__.6403
00000068 r __FUNCTION__.6417
00000075 r __FUNCTION__.6422
00000083 r __FUNCTION__.6426
00000091 r __FUNCTION__.6431
000000a5 r __FUNCTION__.6435
U __assert_func
twid.o:
@ -347,10 +347,10 @@ twid.o:
U TWI_Stop
U TWI_TransferComplete
U TWI_WriteByte
00000000 r __FUNCTION__.6355
00000010 r __FUNCTION__.6362
0000001d r __FUNCTION__.6375
00000027 r __FUNCTION__.6397
00000000 r __FUNCTION__.6365
00000010 r __FUNCTION__.6372
0000001d r __FUNCTION__.6385
00000027 r __FUNCTION__.6407
U __assert_func
usart.o:
@ -369,7 +369,7 @@ usart.o:
00000000 T USART_SetTransmitterEnabled
00000000 T USART_Write
00000000 T USART_WriteBuffer
00000000 r __FUNCTION__.6149
00000000 r __FUNCTION__.6159
U __assert_func
wdt.o:
@ -380,3 +380,11 @@ wdt.o:
00000000 T WDT_Restart
core_cm3.o:
timetick.o:
00000000 T GetTickCount
00000000 T Sleep
00000000 T TimeTick_Configure
00000000 T TimeTick_Increment
00000000 T Wait
00000000 b _dwTickCount

View File

@ -36,7 +36,7 @@
* Headers
*----------------------------------------------------------------------------*/
#include "board.h"
#include "chip.h"
/*----------------------------------------------------------------------------
* Local variables

View File

@ -1,23 +0,0 @@
# Makefile for compiling libboard
SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables
#-------------------------------------------------------------------------------
# Rules
#-------------------------------------------------------------------------------
all: sam3s_ek
.PHONY: sam3s_ek
sam3s_ek:
@echo --- Making sam3s_ek
@$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3s_ek.mk
@$(MAKE) $(SUBMAKE_OPTIONS) -f sam3s_ek.mk
.PHONY: clean
clean:
@echo --- Cleaning sam3s_ek
@$(MAKE) $(SUBMAKE_OPTIONS) -f sam3s_ek.mk $@
@$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3s_ek.mk $@

View File

@ -1,7 +0,0 @@
# Optimization level
# -O1 Optimize
# -O2 Optimize even more
# -O3 Optimize yet more
# -O0 Reduce compilation time and make debugging produce the expected results
# -Os Optimize for size
OPTIMIZATION = -g -O0 -DDEBUG

View File

@ -1,39 +0,0 @@
# Tool suffix when cross-compiling
#CROSS_COMPILE = ../../CodeSourcery_arm/bin/arm-none-eabi-
CROSS_COMPILE = C:/CodeSourcery_2011.03-42/bin/arm-none-eabi-
# Compilation tools
AR = $(CROSS_COMPILE)ar
CC = $(CROSS_COMPILE)gcc
AS = $(CROSS_COMPILE)as
#LD = $(CROSS_COMPILE)ld
#SIZE = $(CROSS_COMPILE)size
NM = $(CROSS_COMPILE)nm
#OBJCOPY = $(CROSS_COMPILE)objcopy
RM=cs-rm -Rf
SEP=/
# Flags
CFLAGS += -Wall -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int
CFLAGS += -Werror-implicit-function-declaration -Wmain -Wparentheses
CFLAGS += -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused
CFLAGS += -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef
CFLAGS += -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings
CFLAGS += -Wsign-compare -Waggregate-return -Wstrict-prototypes
CFLAGS += -Wmissing-prototypes -Wmissing-declarations
CFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations
CFLAGS += -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wlong-long
CFLAGS += -Wunreachable-code
CFLAGS += -Wcast-align
#CFLAGS += -Wmissing-noreturn
#CFLAGS += -Wconversion
# To reduce application size use only integer printf function.
CFLAGS += -Dprintf=iprintf
CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections
CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP)
ASFLAGS = -mcpu=cortex-m3 -mthumb -Wall -a -g $(INCLUDES)

View File

@ -1,7 +0,0 @@
# Optimization level
# -O1 Optimize
# -O2 Optimize even more
# -O3 Optimize yet more
# -O0 Reduce compilation time and make debugging produce the expected results
# -Os Optimize for size
OPTIMIZATION = -Os

View File

@ -1,122 +0,0 @@
# Makefile for compiling libboard
.SUFFIXES: .o .a .c .s
CHIP=sam3s4
BOARD=sam3s_ek
LIBNAME=libboard
TOOLCHAIN=gcc
#-------------------------------------------------------------------------------
# Path
#-------------------------------------------------------------------------------
# Output directories
OUTPUT_BIN = ../lib
# Libraries
PROJECT_BASE_PATH = ..
#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
vpath %.h $(PROJECT_BASE_PATH)/include
vpath %.c $(PROJECT_BASE_PATH)/source
vpath %.s $(PROJECT_BASE_PATH)/source
VPATH+=$(PROJECT_BASE_PATH)/source
INCLUDES = -I$(PROJECT_BASE_PATH)
INCLUDES += -I$(PROJECT_BASE_PATH)/include
INCLUDES += -I$(PROJECT_BASE_PATH)/../libchip_sam3s
#-------------------------------------------------------------------------------
ifdef DEBUG
include debug.mk
else
include release.mk
endif
#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------
include $(TOOLCHAIN).mk
#-------------------------------------------------------------------------------
ifdef DEBUG
OUTPUT_OBJ=debug
OUTPUT_LIB=$(LIBNAME)_$(BOARD)_$(TOOLCHAIN)_dbg.a
else
OUTPUT_OBJ=release
OUTPUT_LIB=$(LIBNAME)_$(BOARD)_$(TOOLCHAIN)_rel.a
endif
OUTPUT_PATH=$(OUTPUT_OBJ)_$(BOARD)
#-------------------------------------------------------------------------------
# C source files and objects
#-------------------------------------------------------------------------------
C_SRC=$(wildcard $(PROJECT_BASE_PATH)/source/*.c)
C_OBJ_TEMP = $(patsubst %.c, %.o, $(notdir $(C_SRC)))
# during development, remove some files
C_OBJ_FILTER=
C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP))
#-------------------------------------------------------------------------------
# Assembler source files and objects
#-------------------------------------------------------------------------------
A_SRC=$(wildcard $(PROJECT_BASE_PATH)/source/*.s)
A_OBJ_TEMP=$(patsubst %.s, %.o, $(notdir $(A_SRC)))
# during development, remove some files
A_OBJ_FILTER=
A_OBJ=$(filter-out $(A_OBJ_FILTER), $(A_OBJ_TEMP))
#-------------------------------------------------------------------------------
# Rules
#-------------------------------------------------------------------------------
all: $(BOARD)
$(BOARD): create_output $(OUTPUT_LIB)
.PHONY: create_output
create_output:
@echo --- Preparing $(BOARD) files $(OUTPUT_PATH) $(OUTPUT_BIN)
# @echo -------------------------
# @echo *$(C_SRC)
# @echo -------------------------
# @echo *$(C_OBJ)
# @echo -------------------------
# @echo *$(addprefix $(OUTPUT_PATH)/, $(C_OBJ))
# @echo -------------------------
# @echo *$(A_SRC)
# @echo -------------------------
-@mkdir $(subst /,$(SEP),$(OUTPUT_BIN)) 1>NUL 2>&1
-@mkdir $(OUTPUT_PATH) 1>NUL 2>&1
$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c
@$(CC) -c $(CFLAGS) $< -o $@
$(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s
@$(AS) -c $(ASFLAGS) $< -o $@
$(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ))
@$(AR) -r "$(OUTPUT_BIN)/$@" $^
@$(NM) "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt"
.PHONY: clean
clean:
@echo --- Cleaning $(BOARD) files [$(OUTPUT_PATH)$(SEP)*.o]
-@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1
-@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1
-@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB).txt 1>NUL 2>&1
# dependencies
$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: $(PROJECT_BASE_PATH)/board.h $(wildcard $(PROJECT_BASE_PATH)/include/*.h)

View File

@ -1,108 +0,0 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, 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.
* ----------------------------------------------------------------------------
*/
#ifndef _BITBANDING_
#define _BITBANDING_
/*----------------------------------------------------------------------------
* \file bitbanding.h
* Include Defines & macros for bit-banding.
*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
* Header files
*----------------------------------------------------------------------------*/
#include <stdint.h>
/*----------------------------------------------------------------------------
* Global Macros
*----------------------------------------------------------------------------*/
/**
* \brief Check if the address is in bit banding sram region.
*
* \note The address should be in area of 0x2000000 ~ 0x200FFFFF
*
* \param x The address to check.
*/
#define IS_BITBAND_SRAM_ADDR(x) \
( ((uint32_t)(x)) >= 0x20000000 && \
((uint32_t)(x)) < (0x20000000+0x100000) )
/**
* \brief Check if the address is in bit banding peripheral region
*
* \note The address should be in area of 0x4000000 ~ 0x400FFFFF
* \param x The address to check
*/
#define IS_BITBAND_PERIPH_ADDR(x) \
( ((uint32_t)(x)) >= 0x40000000 && \
((uint32_t)(x)) < (0x40000000+0x100000) )
/**
* \brief Calculate bit band alias address.
*
* Calculate the bit band alias address and return a pointer address to word.
*
* \param addr The byte address of bitbanding bit.
* \param bit The bit position of bitbanding bit.
* \callergraph
*/
#define BITBAND_ALIAS_ADDRESS(addr, bit) \
((volatile uint32_t*)((((uint32_t)(addr) & 0xF0000000) + 0x02000000) \
+((((uint32_t)(addr)&0xFFFFF)*32)\
+( (uint32_t)(bit)*4))))
/**
* \brief Bit write through bit banding.
*
* \param addr32 32-bit aligned byte address where the bit exists.
* \param bit Bit position.
* \param val The value that the bit is set to.
* \callergraph
*/
#define WRITE_BITBANDING(addr32, bit, val) do {\
*BITBAND_ALIAS_ADDRESS(addr32,bit) = (val); \
} while (0);
/**
* \brief Toggle bit through bit banding
*
* \param addr32 32-bit aligned byte address where the bit exists.
* \param bit Bit position.
*/
#define TOGGLE_BITBANDING(addr32, bit) do {\
volatile uint32_t * p = \
BITBAND_ALIAS_ADDRESS(addr32,bit); \
if (*p) *p = 0; \
else *p = 1; \
}while(0);
#endif /* #ifndef _BITBANDING_ */

View File

@ -1,46 +0,0 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, 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.
* ----------------------------------------------------------------------------
*/
/**
* \file
*
* Interface for the low-level initialization function.
*
*/
#ifndef BOARD_LOWLEVEL_H
#define BOARD_LOWLEVEL_H
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
extern void LowLevelInit( void ) ;
#endif /* BOARD_LOWLEVEL_H */

View File

@ -1,6 +1,9 @@
files to be used for Arduino API build:
flash_arduino.ld
files to be used for Arduino Bootloader build:
flash_arduino_bootloader.ld
files to be used for other uses of board
flash.ld
sram.ld

View File

@ -38,8 +38,8 @@ SEARCH_DIR(.)
/* Memory Spaces Definitions */
MEMORY
{
rom (rx) : ORIGIN = 0x00400000, LENGTH = 0x00040000 /* flash, 256K */
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x0000c000 /* sram, 48K */
rom (rx) : ORIGIN = 0x00404000, LENGTH = 0x0003c000 /* flash, 240KB = 256K minus 16KB of bootloader */
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x0000c000 /* sram, 48KB */
}
/* Section Definitions */

View File

@ -0,0 +1,140 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, 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.
* ----------------------------------------------------------------------------
*/
/*------------------------------------------------------------------------------
* Linker script for running in internal FLASH on the ATSAM3S4
*----------------------------------------------------------------------------*/
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
SEARCH_DIR(.)
/* Memory Spaces Definitions */
MEMORY
{
rom (rx) : ORIGIN = 0x00400000, LENGTH = 0x00004000 /* flash, 16KB */
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x0000c000 /* sram, 48KB */
}
/* Section Definitions */
SECTIONS
{
.text :
{
. = ALIGN(4);
_sfixed = .;
KEEP(*(.vectors .vectors.*))
*(.text .text.* .gnu.linkonce.t.*)
*(.glue_7t) *(.glue_7)
*(.rodata .rodata* .gnu.linkonce.r.*)
*(.ARM.extab* .gnu.linkonce.armextab.*)
/* Support C constructors, and C destructors in both user code
and the C library. This also provides support for C++ code. */
. = ALIGN(4);
KEEP(*(.init))
. = ALIGN(4);
__preinit_array_start = .;
KEEP (*(.preinit_array))
__preinit_array_end = .;
. = ALIGN(4);
__init_array_start = .;
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
__init_array_end = .;
. = ALIGN(0x4);
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*crtend.o(.ctors))
. = ALIGN(4);
KEEP(*(.fini))
. = ALIGN(4);
__fini_array_start = .;
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
__fini_array_end = .;
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*crtend.o(.dtors))
. = ALIGN(4);
_efixed = .; /* End of text section */
} > rom
/* .ARM.exidx is sorted, so has to go in its own output section. */
PROVIDE_HIDDEN (__exidx_start = .);
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > rom
PROVIDE_HIDDEN (__exidx_end = .);
. = ALIGN(4);
_etext = .;
.relocate : AT (_etext)
{
. = ALIGN(4);
_srelocate = .;
*(.ramfunc .ramfunc.*);
*(.data .data.*);
. = ALIGN(4);
_erelocate = .;
} > ram
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
. = ALIGN(4);
_sbss = . ;
_szero = .;
*(.bss .bss.*)
*(COMMON)
. = ALIGN(4);
_ebss = . ;
_ezero = .;
} > ram
/* stack section */
.stack (NOLOAD):
{
. = ALIGN(8);
*(.stack .stack.*)
} > ram
. = ALIGN(4);
_end = . ;
}

View File

@ -17,39 +17,6 @@ const static uint8_t SCK = 33 ;
#define PINS_UART (16u)
typedef enum _EAnalogChannel
{
ADC0,
ADC1,
ADC2,
ADC3,
ADC4,
ADC5,
ADC6,
ADC7,
ADC8,
ADC9,
ADC10,
ADC11,
ADC12,
ADC13,
ADC14,
ADC15,
DAC0,
DAC1
} EAnalogChannel ;
/* Types used for the tables below */
typedef struct _PinDescription
{
Pio* pPort ;
uint32_t dwPin ;
uint32_t dwPeripheralId ;
EPioType dwPinType ;
uint32_t dwPinAttribute ;
EAnalogChannel dwAnalogChannel ;
} PinDescription ;
static const PinDescription APinDescription[]=
{
// LEDS, 0..2

View File

@ -1,111 +0,0 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, 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.
* ----------------------------------------------------------------------------
*/
/**
* \file
*
* Provides the low-level initialization function that called on chip startup.
*/
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "board.h"
/*----------------------------------------------------------------------------
* Local definitions
*----------------------------------------------------------------------------*/
/* Clock settings at 48MHz */
#if (BOARD_MCK == 48000000)
#define BOARD_OSCOUNT (CKGR_MOR_MOSCXTST(0x8))
#define BOARD_PLLAR (CKGR_PLLAR_STUCKTO1 \
| CKGR_PLLAR_MULA(0x7) \
| CKGR_PLLAR_PLLACOUNT(0x1) \
| CKGR_PLLAR_DIVA(0x1))
#define BOARD_MCKR (PMC_MCKR_PRES_CLK_2 | PMC_MCKR_CSS_PLLA_CLK)
/* Clock settings at 64MHz */
#elif (BOARD_MCK == 64000000)
#define BOARD_OSCOUNT (CKGR_MOR_MOSCXTST(0x8))
#define BOARD_PLLAR (CKGR_PLLAR_STUCKTO1 \
| CKGR_PLLAR_MULA(0x0f) \
| CKGR_PLLAR_PLLACOUNT(0x1) \
| CKGR_PLLAR_DIVA(0x3))
#define BOARD_MCKR (PMC_MCKR_PRES_CLK | PMC_MCKR_CSS_PLLA_CLK)
#else
#error "No settings for current BOARD_MCK."
#endif
/* Define clock timeout */
#define CLOCK_TIMEOUT 0xFFFFFFFF
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
/**
* \brief Performs the low-level initialization of the chip.
* This includes EFC and master clock configuration.
* It also enable a low level on the pin NRST triggers a user reset.
*/
extern WEAK void LowLevelInit( void )
{
uint32_t dwTimeOut = 0 ;
/* Set 3 FWS for Embedded Flash Access @ 64MHz, we are now at 4MHz on Internal FastRC */
EFC->EEFC_FMR = EEFC_FMR_FWS( 3 ) ;
/* Initialize main oscillator */
if ( !(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL) )
{
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN;
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_MOSCXTS) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
}
/* Switch to 3-20MHz Xtal oscillator */
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN | CKGR_MOR_MOSCSEL;
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_MOSCSELS) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
PMC->PMC_MCKR = (PMC->PMC_MCKR & ~(uint32_t)PMC_MCKR_CSS_Msk) | PMC_MCKR_CSS_MAIN_CLK;
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_MCKRDY) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
/* Initialize PLLA */
PMC->CKGR_PLLAR = BOARD_PLLAR ;
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_LOCKA) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
/* Switch to main clock */
PMC->PMC_MCKR = (BOARD_MCKR & ~PMC_MCKR_CSS_Msk) | PMC_MCKR_CSS_MAIN_CLK;
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_MCKRDY) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
PMC->PMC_MCKR = BOARD_MCKR ;
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_MCKRDY) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
}

View File

@ -1,5 +1,5 @@
#ifndef _BOARD_
#define _BOARD_
#ifndef _VARIANT_
#define _VARIANT_
/*----------------------------------------------------------------------------
* Headers
@ -7,15 +7,11 @@
#include "libsam/chip.h"
#include "include/bitbanding.h"
#include "include/board_lowlevel.h"
#include "include/timetick.h"
/**
* Libc porting layers
*/
#if defined ( __GNUC__ ) /* GCC CS3 */
# include "include/syscalls.h" /** RedHat Newlib minimal stub */
# include <syscalls.h> /** RedHat Newlib minimal stub */
#endif
/*----------------------------------------------------------------------------
@ -25,29 +21,34 @@
/*----------------------------------------------------------------------------*/
/** Name of the board */
#define BOARD_NAME "SAM3S-EK"
#define VARIANT_NAME "SAM3S-EK"
/*
#define BOARD_REV_A
#define VARIANT_REV_A
*/
#define BOARD_REV_B
#define VARIANT_REV_B
/** Frequency of the board main oscillator */
#define BOARD_MAINOSC 12000000
#define VARIANT_MAINOSC 12000000
/** Master clock frequency (when using board_lowlevel.c) */
#define BOARD_MCK 64000000
/** Master clock frequency */
#define VARIANT_MCK 64000000
/*----------------------------------------------------------------------------
* Arduino objects
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
# ifdef __cplusplus
# include "UART.h"
# include "USART.h"
extern UARTClass Serial1 ;
extern UARTClass Serial2 ;
extern USARTClass Serial3 ;
extern USARTClass Serial4 ;
//extern USARTClass Serial3 ;
//extern USARTClass Serial4 ;
# endif
#endif /* #ifndef _BOARD_ */
#endif /* #ifndef _VARIANT_ */