From 79ee7a1f6a2a0351f88a51b1060824cebec8a23f Mon Sep 17 00:00:00 2001 From: Thibaut VIARD Date: Fri, 9 Sep 2011 19:15:21 +0200 Subject: [PATCH] [sam] daily commit: EWARM project working, GCC compiling but fail due to missing match for Reset_Handler --- hardware/sam/cores/sam/Arduino.h | 132 +- hardware/sam/cores/sam/HardwareSerial.cpp | 18 - hardware/sam/cores/sam/HardwareSerial.h | 25 +- hardware/sam/cores/sam/RingBuffer.cpp | 29 + hardware/sam/cores/sam/RingBuffer.h | 28 + hardware/sam/cores/sam/Stream.h | 2 +- hardware/sam/cores/sam/Tone.h | 9 + hardware/sam/cores/sam/WMath.cpp | 35 +- hardware/sam/cores/sam/WMath.h | 10 + hardware/sam/cores/sam/build_gcc/Makefile | 8 +- .../build_gcc/debug_sam3s_ek/WInterrupts.o | Bin 7636 -> 0 bytes .../cores/sam/build_gcc/debug_sam3s_ek/itoa.o | Bin 3956 -> 0 bytes .../build_gcc/debug_sam3s_ek/syscalls_sam3.o | Bin 9948 -> 0 bytes ...ino_sam3s_ek.mk => libarduino_sam3s_ek.mk} | 11 +- .../sam/cores/sam/build_iar/libarduino.ewp | 33 +- hardware/sam/cores/sam/main.cpp | 4 +- hardware/sam/cores/sam/syscalls_sam3.c | 2 +- .../cores/sam/validation/build_gcc/test.mk | 60 +- .../cores/sam/validation/build_iar/test.ewp | 23 +- hardware/sam/cores/sam/validation/test.cpp | 15 +- hardware/sam/cores/sam/wiring.c | 64 +- hardware/sam/cores/sam/wiring.h | 38 +- hardware/sam/cores/sam/wiring_analog.h | 4 + hardware/sam/cores/sam/wiring_constants.h | 78 + hardware/sam/cores/sam/wiring_digital.c | 68 +- hardware/sam/cores/sam/wiring_digital.h | 22 +- hardware/sam/cores/sam/wiring_private.h | 40 +- hardware/sam/cores/sam/wiring_pulse.h | 4 + hardware/sam/cores/sam/wiring_shift.c | 24 +- hardware/sam/cores/sam/wiring_shift.h | 4 + hardware/sam/system/libsam/build_gcc/sam3.mk | 11 +- .../sam/system/libsam/build_iar/libsam.ewp | 2 +- .../sam/system/libsam/build_iar/libsam.eww | 7 + .../system/libsam/cmsis/cmsis_example/main.c | 95 - .../sam3n4c_sam3s_ek/conf_board.h | 44 - .../sam3s4c_sam3s_ek/conf_board.h | 44 - .../sam3sd8c_sam3s_ek2/conf_board.h | 44 - .../sam3u4e_sam3s_ek/conf_board.h | 44 - .../sam3x8h_sam3x_ek/conf_board.h | 44 - .../cmsis/sam3s/source/templates/exceptions.c | 4 +- .../cmsis/sam3s/source/templates/exceptions.h | 2 +- .../source/templates/iar/startup_sam3s.c | 8 +- hardware/sam/system/libsam/source/pio.c | 22 +- .../pins_arduino.h | 0 .../{Arduino_Due => arduino_due}/variant.cpp | 0 .../{Arduino_Due => arduino_due}/variant.h | 0 .../{cores/sam => variants/common}/UART.cpp | 54 +- .../sam/{cores/sam => variants/common}/UART.h | 12 +- .../{cores/sam => variants/common}/USART.cpp | 51 +- .../{cores/sam => variants/common}/USART.h | 16 +- .../sam/variants/common/cortex_handlers.cpp | 50 + .../sam/variants/sam3s_ek/build_gcc/Makefile | 24 + .../sam/variants/sam3s_ek/build_gcc/debug.mk | 7 + .../sam/variants/sam3s_ek/build_gcc/gcc.mk | 64 + .../sam3s_ek/build_gcc/libvariant_sam3s_ek.mk | 156 ++ .../variants/sam3s_ek/build_gcc/release.mk | 8 + .../build_iar/libvariant_sam3s_ek.ewd | 1769 ++++++++++++++++ .../build_iar/libvariant_sam3s_ek.ewp | 1824 +++++++++++++++++ hardware/sam/variants/sam3s_ek/pins_arduino.h | 29 +- hardware/sam/variants/sam3s_ek/variant.cpp | 67 +- hardware/sam/variants/sam3s_ek/variant.h | 58 +- 61 files changed, 4493 insertions(+), 857 deletions(-) delete mode 100644 hardware/sam/cores/sam/HardwareSerial.cpp create mode 100644 hardware/sam/cores/sam/RingBuffer.cpp create mode 100644 hardware/sam/cores/sam/RingBuffer.h delete mode 100644 hardware/sam/cores/sam/build_gcc/debug_sam3s_ek/WInterrupts.o delete mode 100644 hardware/sam/cores/sam/build_gcc/debug_sam3s_ek/itoa.o delete mode 100644 hardware/sam/cores/sam/build_gcc/debug_sam3s_ek/syscalls_sam3.o rename hardware/sam/cores/sam/build_gcc/{arduino_sam3s_ek.mk => libarduino_sam3s_ek.mk} (95%) create mode 100644 hardware/sam/cores/sam/wiring_constants.h delete mode 100644 hardware/sam/system/libsam/cmsis/cmsis_example/main.c delete mode 100644 hardware/sam/system/libsam/cmsis/cmsis_example/sam3n4c_sam3s_ek/conf_board.h delete mode 100644 hardware/sam/system/libsam/cmsis/cmsis_example/sam3s4c_sam3s_ek/conf_board.h delete mode 100644 hardware/sam/system/libsam/cmsis/cmsis_example/sam3sd8c_sam3s_ek2/conf_board.h delete mode 100644 hardware/sam/system/libsam/cmsis/cmsis_example/sam3u4e_sam3s_ek/conf_board.h delete mode 100644 hardware/sam/system/libsam/cmsis/cmsis_example/sam3x8h_sam3x_ek/conf_board.h rename hardware/sam/variants/{Arduino_Due => arduino_due}/pins_arduino.h (100%) rename hardware/sam/variants/{Arduino_Due => arduino_due}/variant.cpp (100%) rename hardware/sam/variants/{Arduino_Due => arduino_due}/variant.h (100%) rename hardware/sam/{cores/sam => variants/common}/UART.cpp (58%) rename hardware/sam/{cores/sam => variants/common}/UART.h (73%) rename hardware/sam/{cores/sam => variants/common}/USART.cpp (59%) rename hardware/sam/{cores/sam => variants/common}/USART.h (60%) create mode 100644 hardware/sam/variants/common/cortex_handlers.cpp create mode 100644 hardware/sam/variants/sam3s_ek/build_gcc/Makefile create mode 100644 hardware/sam/variants/sam3s_ek/build_gcc/debug.mk create mode 100644 hardware/sam/variants/sam3s_ek/build_gcc/gcc.mk create mode 100644 hardware/sam/variants/sam3s_ek/build_gcc/libvariant_sam3s_ek.mk create mode 100644 hardware/sam/variants/sam3s_ek/build_gcc/release.mk create mode 100644 hardware/sam/variants/sam3s_ek/build_iar/libvariant_sam3s_ek.ewd create mode 100644 hardware/sam/variants/sam3s_ek/build_iar/libvariant_sam3s_ek.ewp diff --git a/hardware/sam/cores/sam/Arduino.h b/hardware/sam/cores/sam/Arduino.h index 15e8709ab..e1c72afe4 100644 --- a/hardware/sam/cores/sam/Arduino.h +++ b/hardware/sam/cores/sam/Arduino.h @@ -1,83 +1,28 @@ +/* + %atmel_license% +*/ + #ifndef Arduino_h #define Arduino_h #include -//#include - #include #include #include +#include "libsam/chip.h" #include "binary.h" #ifdef __cplusplus extern "C"{ #endif // __cplusplus -#define HIGH 0x1 -#define LOW 0x0 +#include "wiring_constants.h" -#define INPUT 0x0 -#define OUTPUT 0x1 +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( ((a) * (SystemCoreClock / 1000L)) / 1000L ) -#define true 0x1 -#define false 0x0 - -#define PI 3.1415926535897932384626433832795 -#define HALF_PI 1.5707963267948966192313216916398 -#define TWO_PI 6.283185307179586476925286766559 -#define DEG_TO_RAD 0.017453292519943295769236907684886 -#define RAD_TO_DEG 57.295779513082320876798154814105 - -#define SERIAL 0x0 -#define DISPLAY 0x1 - -#define LSBFIRST 0 -#define MSBFIRST 1 - -#define CHANGE 1 -#define FALLING 2 -#define RISING 3 - -#define DEFAULT 1 -#define EXTERNAL 0 - -// undefine stdlib's abs if encountered -#ifdef abs -#undef abs -#endif // abs - -#define min(a,b) ((a)<(b)?(a):(b)) -#define max(a,b) ((a)>(b)?(a):(b)) -#define abs(x) ((x)>0?(x):-(x)) -#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) -#define radians(deg) ((deg)*DEG_TO_RAD) -#define degrees(rad) ((rad)*RAD_TO_DEG) -#define sq(x) ((x)*(x)) - -#define interrupts() __enable_irq() -#define noInterrupts() __disable_irq() - -#define clockCyclesPerMicrosecond() ( VARIANT_MCK / 1000000L ) -#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (VARIANT_MCK / 1000L) ) -#define microsecondsToClockCycles(a) ( ((a) * (VARIANT_MCK / 1000L)) / 1000L ) - -#define lowByte(w) ((uint8_t) ((w) & 0xff)) -#define highByte(w) ((uint8_t) ((w) >> 8)) - -#define bitRead(value, bit) (((value) >> (bit)) & 0x01) -#define bitSet(value, bit) ((value) |= (1UL << (bit))) -#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) -#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) - -typedef unsigned int word; - -#define bit(b) (1UL << (b)) - -// TODO: to be checked -typedef uint8_t boolean ; -typedef uint8_t byte ; #include "wiring.h" #include "wiring_digital.h" @@ -93,8 +38,8 @@ extern void loop( void ) ; // // These perform slightly better as macros compared to inline functions // -#define digitalPinToPort( Pin ) ( APinDescription[Pin]->pPort ) -#define digitalPinToBitMask( Pin ) ( APinDescription[Pin]->dwPin ) +#define digitalPinToPort( ulPin ) ( g_APinDescription[ulPin]->pPort ) +#define digitalPinToBitMask( ulPin ) ( g_APinDescription[ulPin]->dwPin ) #define digitalPinToTimer( P ) ( ) #define analogInPinToBit( P ) ( P ) #define portOutputRegister( P ) ( ) @@ -107,31 +52,18 @@ extern void loop( void ) ; #define NOT_ON_TIMER 0 #define TIMER0 1 -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus +typedef void (*voidFuncPtr)( void ) ; +/* Define attribute */ +#if defined ( __CC_ARM ) /* Keil µVision 4 */ + #define WEAK (__attribute__ ((weak))) +#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */ + #define WEAK __weak +#elif defined ( __GNUC__ ) /* GCC CS */ + #define WEAK __attribute__ ((weak)) +#endif - -#ifdef __cplusplus -#include "WCharacter.h" -#include "WString.h" -#include "HardwareSerial.h" - -uint16_t makeWord( uint16_t w ) ; -uint16_t makeWord( byte h, byte l ) ; - -#define word(...) makeWord(__VA_ARGS__) - -#include "Tone.h" -#include "WMath.h" - -#endif // __cplusplus - -//! Include variant header -#include "variant.h" - -//! Definitions and types for pins +/* Definitions and types for pins */ typedef enum _EAnalogChannel { ADC0, @@ -158,15 +90,23 @@ typedef enum _EAnalogChannel typedef struct _PinDescription { Pio* pPort ; - uint32_t dwPin ; - uint32_t dwPeripheralId ; - EPioType dwPinType ; - uint32_t dwPinAttribute ; - EAnalogChannel dwAnalogChannel ; + uint32_t ulPin ; + uint32_t ulPeripheralId ; + EPioType ulPinType ; + uint32_t ulPinAttribute ; + EAnalogChannel ulAnalogChannel ; } PinDescription ; -extern const PinDescription APinDescription[] ; +extern const PinDescription g_APinDescription[] ; -#include "pins_arduino.h" +#ifdef __cplusplus +} // extern "C" + +#include "WCharacter.h" +#include "WString.h" +#include "Tone.h" +#include "WMath.h" +#include "HardwareSerial.h" +#endif // __cplusplus #endif // Arduino_h diff --git a/hardware/sam/cores/sam/HardwareSerial.cpp b/hardware/sam/cores/sam/HardwareSerial.cpp deleted file mode 100644 index ea3032ad8..000000000 --- a/hardware/sam/cores/sam/HardwareSerial.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include - -#include "HardwareSerial.h" - -extern void store_char( uint8_t c, ring_buffer* pBuffer ) -{ - int i = (unsigned int)(pBuffer->head + 1) % SERIAL_BUFFER_SIZE; - - // if we should be storing the received character into the location - // just before the tail (meaning that the head would advance to the - // current location of the tail), we're about to overflow the buffer - // and so we don't write the character or advance the head. - if ( i != pBuffer->tail ) - { - pBuffer->buffer[pBuffer->head] = c ; - pBuffer->head = i ; - } -} diff --git a/hardware/sam/cores/sam/HardwareSerial.h b/hardware/sam/cores/sam/HardwareSerial.h index 2a4644fc5..99f0bb09f 100644 --- a/hardware/sam/cores/sam/HardwareSerial.h +++ b/hardware/sam/cores/sam/HardwareSerial.h @@ -1,27 +1,19 @@ +/* + %atmel_license% +*/ + #ifndef HardwareSerial_h #define HardwareSerial_h #include #include "Stream.h" - -// Define constants and variables for buffering incoming serial data. We're -// using a ring buffer (I think), in which head is the index of the location -// to which to write the next incoming character and tail is the index of the -// location from which to read. -#define SERIAL_BUFFER_SIZE 64 - -typedef struct _ring_buffer -{ - uint8_t buffer[SERIAL_BUFFER_SIZE] ; - volatile int head ; - volatile int tail ; -} ring_buffer ; +#include "RingBuffer.h" class HardwareSerial : public Stream { protected: - ring_buffer *_rx_buffer ; - ring_buffer *_tx_buffer ; + RingBuffer *_rx_buffer ; + RingBuffer *_tx_buffer ; public: virtual void begin( const uint32_t dwBaudRate ) =0 ; @@ -37,7 +29,4 @@ class HardwareSerial : public Stream // 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 diff --git a/hardware/sam/cores/sam/RingBuffer.cpp b/hardware/sam/cores/sam/RingBuffer.cpp new file mode 100644 index 000000000..9637b380e --- /dev/null +++ b/hardware/sam/cores/sam/RingBuffer.cpp @@ -0,0 +1,29 @@ +/* + %atmel_license% +*/ + +#include "RingBuffer.h" +#include + +RingBuffer::RingBuffer( void ) +{ + memset( _aucBuffer, 0, SERIAL_BUFFER_SIZE ) ; + _iHead=0 ; + _iTail=0 ; +} + +void RingBuffer::store_char( uint8_t c ) +{ + int i = (uint32_t)(_iHead + 1) % SERIAL_BUFFER_SIZE ; + + // if we should be storing the received character into the location + // just before the tail (meaning that the head would advance to the + // current location of the tail), we're about to overflow the buffer + // and so we don't write the character or advance the head. + if ( i != _iTail ) + { + _aucBuffer[_iHead] = c ; + _iHead = i ; + } +} + diff --git a/hardware/sam/cores/sam/RingBuffer.h b/hardware/sam/cores/sam/RingBuffer.h new file mode 100644 index 000000000..7ee28dea8 --- /dev/null +++ b/hardware/sam/cores/sam/RingBuffer.h @@ -0,0 +1,28 @@ +/* + %atmel_license% +*/ + +#ifndef _RING_BUFFER_ +#define _RING_BUFFER_ + +#include + +// Define constants and variables for buffering incoming serial data. We're +// using a ring buffer (I think), in which head is the index of the location +// to which to write the next incoming character and tail is the index of the +// location from which to read. +#define SERIAL_BUFFER_SIZE 64 + +class RingBuffer +{ + public: + uint8_t _aucBuffer[SERIAL_BUFFER_SIZE] ; + int _iHead ; + int _iTail ; + + public: + RingBuffer( void ) ; + void store_char( uint8_t c ) ; +} ; + +#endif /* _RING_BUFFER_ */ diff --git a/hardware/sam/cores/sam/Stream.h b/hardware/sam/cores/sam/Stream.h index 93d8275dc..aaa189f4d 100644 --- a/hardware/sam/cores/sam/Stream.h +++ b/hardware/sam/cores/sam/Stream.h @@ -20,7 +20,7 @@ #ifndef Stream_h #define Stream_h -#include +#include #include "Print.h" class Stream : public Print diff --git a/hardware/sam/cores/sam/Tone.h b/hardware/sam/cores/sam/Tone.h index e69de29bb..7f13065bf 100644 --- a/hardware/sam/cores/sam/Tone.h +++ b/hardware/sam/cores/sam/Tone.h @@ -0,0 +1,9 @@ +/* + %atmel_license% +*/ + +#ifndef _WIRING_TONE_ +#define _WIRING_TONE_ + + +#endif /* _WIRING_TONE_ */ diff --git a/hardware/sam/cores/sam/WMath.cpp b/hardware/sam/cores/sam/WMath.cpp index 8aeb8b9ff..49a63cf76 100644 --- a/hardware/sam/cores/sam/WMath.cpp +++ b/hardware/sam/cores/sam/WMath.cpp @@ -1,26 +1,5 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - /* - Part of the Wiring project - http://wiring.org.co - Copyright (c) 2004-06 Hernando Barragan - Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/ - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id$ + %atmel_license% */ extern "C" { @@ -28,7 +7,7 @@ extern "C" { #include "stdint.h" } -void randomSeed( uint32_t dwSeed ) +extern void randomSeed( uint32_t dwSeed ) { if ( dwSeed != 0 ) { @@ -36,7 +15,7 @@ void randomSeed( uint32_t dwSeed ) } } -long random( long howbig ) +extern long random( long howbig ) { if ( howbig == 0 ) { @@ -46,7 +25,7 @@ long random( long howbig ) return rand() % howbig; } -long random( long howsmall, long howbig ) +extern long random( long howsmall, long howbig ) { if (howsmall >= howbig) { @@ -58,17 +37,17 @@ long random( long howsmall, long howbig ) return random(diff) + howsmall; } -long map(long x, long in_min, long in_max, long out_min, long out_max) +extern long map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } -uint32_t makeWord( uint32_t w ) +extern uint16_t makeWord( uint32_t w ) { return w ; } -uint32_t makeWord( uint8_t h, uint8_t l ) +extern uint16_t makeWord( uint8_t h, uint8_t l ) { return (h << 8) | l ; } diff --git a/hardware/sam/cores/sam/WMath.h b/hardware/sam/cores/sam/WMath.h index 392ef88a6..5cf425b41 100644 --- a/hardware/sam/cores/sam/WMath.h +++ b/hardware/sam/cores/sam/WMath.h @@ -1,3 +1,7 @@ +/* + %atmel_license% +*/ + #ifndef _WIRING_MATH_ #define _WIRING_MATH_ @@ -6,4 +10,10 @@ extern long random( long, long ) ; extern void randomSeed( uint32_t dwSeed ) ; extern long map( long, long, long, long, long ) ; +extern uint16_t makeWord( uint16_t w ) ; +extern uint16_t makeWord( byte h, byte l ) ; + +#define word(...) makeWord(__VA_ARGS__) + + #endif /* _WIRING_MATH_ */ diff --git a/hardware/sam/cores/sam/build_gcc/Makefile b/hardware/sam/cores/sam/build_gcc/Makefile index a1364e34e..f6d40e422 100644 --- a/hardware/sam/cores/sam/build_gcc/Makefile +++ b/hardware/sam/cores/sam/build_gcc/Makefile @@ -12,13 +12,13 @@ all: sam3s_ek .PHONY: sam3s_ek sam3s_ek: @echo --- Making sam3s_ek - @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f arduino_sam3s_ek.mk -# @$(MAKE) $(SUBMAKE_OPTIONS) -f arduino_sam3s_ek.mk + @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_sam3s_ek.mk +# @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_sam3s_ek.mk .PHONY: clean clean: @echo --- Cleaning sam3s_ek - @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f arduino_sam3s_ek.mk $@ -# @$(MAKE) $(SUBMAKE_OPTIONS) -f arduino_sam3s_ek.mk $@ + @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_sam3s_ek.mk $@ +# @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_sam3s_ek.mk $@ diff --git a/hardware/sam/cores/sam/build_gcc/debug_sam3s_ek/WInterrupts.o b/hardware/sam/cores/sam/build_gcc/debug_sam3s_ek/WInterrupts.o deleted file mode 100644 index ce252e78765d082e801c4487cc1637f075c993ed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7636 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 diff --git a/hardware/sam/cores/sam/build_gcc/debug_sam3s_ek/itoa.o b/hardware/sam/cores/sam/build_gcc/debug_sam3s_ek/itoa.o deleted file mode 100644 index 4ba59270fe48782fc956b8fc91f85d0460665fc1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3956 zcmai1U2GiH6+U-n{~S9@;ux}VC~R6&T$wCRVo_hr}ckbPt zO)KR{_kQQ+p6{OfGc&tS-g)m)rIc7vGA=z!F9Qw^)zQwq*hQrrxkckObv ziKM6c%uGSuHq@UaGJr9fCrXiRDAv)nCDhM=>M!VS){g$pQK^5yR1VxF-Y zB2Ac%5iyxK6spw+t_7(@#c{q2e&#IjM#YP>2va{)rI+w#a;JSgOPi_d(1uRZe2VyMBrxj__m9^lx-0%prFuLd&VzPBFyehahexjPG;U^;j^w-#J`&zX+;!u;k>ocYZU zTJMbRIy%33#{GV7esj)!bM(S_cWcsp|GeAi1e~`6zTvx{>bS%6n=c{bAFT_c>+s3M zyMN;>1MiXdLT>)!{my7N$NB`m!-0!6r?+vN&@S8;Vq9I6NV^bXpx8IL}D*7iR1GB{MCAG zIj=iDI<27I4D;<;tFm147xQ%W8BPBYzuEHT{^??)S%26MTgBPtV!KkSpVoFcEG}2V zpj|3@#_cs%PQz6U;CR$)`o)&FQY_b-eoJemcBQ&_dbwPdULk!mvJyFV;(`2JeyVU& z;b5R!-n~*`;Q-z)VB2T0cSWdqOMfC-JIH^M%6Vu z-yyV%5GBsz*`e)t^Y(;CGMmlJX7jTzsArt*Y1r{Nk5I>Ry|@%wYb&8w0*1{91FNBy zPzsA)=t-f}YC-i&?d8*6sf44GLesArPo=h0kK5Hs&5vwSU|@96IzxN(PQ?hS^>RGF z(Js}z6(2M9=729;YxMiPrdM0;cUezVDpn$ea(!jR$MFk=b!mwE>wZs0br6#89 zZRBONy@>OP;dxM^?_i{}j~*eBeb711r4w@LIP=uW^@wHAE;sH5jIlXTHQ)18jM&%_ z*j8ugcWCwzr)^`?&meWgmahRl&i69-c-O61zA7AXzOymD zLBuTIlhEy&$Wg?>a1JXrwhl*}?|JZTz{mQqm0i9UpxYd%@@Mez4q36W=irF*4PDV& zFVrsIOVDi&IsOU0VJb#!?1!-9d?PWworu}>{sy|uA;qWQ8>eE##?Hfz^IZ)-erUK} z{BrB^{Rz6wfhzkjQTKxsi}7m|=bHjw9zOD2iDv8Lk1X;{qET)^AQ78@D%*z!?YLWU zi6`K*V#j?1NBl?wj5}Zl0WG!u0T%QB0OL-^Y}QBVpvBj5Dz=VM#Oyk_=a{!E{|4WX zoeW;95^;sQ@-{B#IXJI@XAc_rcA#<2INt^?-RI%6V)?9XG44;u7MIx-w_8Qza{DUb zeDN7++g-5Zv8b51`pNG(TvW|xxF-X`XOA`U9pE6&yR?WFNqlEH-{2+rgL?eW?QqT3 zH87q}VozMb;l#uho=Q(#%@((L6MN#yZasqg9|=#mC$3y-$8SFC-y>J`hIikOT>m+= zVb*VclaGaBKb>QXf^S*Xui2k(e0Ms$Kg1Eyt01yk;yxla@;V}3zWjF3f5_mp!C8az z2ES(TTLyU!%=@;%RfA6$JWIrZK5LNQBL`djhKavLM3L_peAmQz>BzgEi2SdcxSkJ} z{AJqs|3_gwVGvZ>=Kj;q-6isO4sp!jxWU6jBz@W79R|N@@T9?028#w44C;MGcPaMG d&!RXU^V>S1>Unj&=&)3AaPYR?DP!CE{tMSS){6iD diff --git a/hardware/sam/cores/sam/build_gcc/debug_sam3s_ek/syscalls_sam3.o b/hardware/sam/cores/sam/build_gcc/debug_sam3s_ek/syscalls_sam3.o deleted file mode 100644 index 2352bdf2a9ccf89e960f46ec5d5a34238d36f6a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9948 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 Y6#h67c~7-~%!i14^?G1F "$(OUTPUT_BIN)/$@.txt" diff --git a/hardware/sam/cores/sam/build_iar/libarduino.ewp b/hardware/sam/cores/sam/build_iar/libarduino.ewp index b2a92e62f..6da66c6fd 100644 --- a/hardware/sam/cores/sam/build_iar/libarduino.ewp +++ b/hardware/sam/cores/sam/build_iar/libarduino.ewp @@ -257,7 +257,7 @@ @@ -2692,9 +2692,6 @@ $PROJ_DIR$\..\binary.h - - $PROJ_DIR$\..\HardwareSerial.cpp - $PROJ_DIR$\..\HardwareSerial.h @@ -2713,6 +2710,12 @@ $PROJ_DIR$\..\Print.h + + $PROJ_DIR$\..\RingBuffer.cpp + + + $PROJ_DIR$\..\RingBuffer.h + $PROJ_DIR$\..\Stream.h @@ -2735,22 +2738,7 @@ - $PROJ_DIR$\..\UART.cpp - - Debug - - - - $PROJ_DIR$\..\UART.h - - - $PROJ_DIR$\..\USART.cpp - - Debug - - - - $PROJ_DIR$\..\USART.h + $PROJ_DIR$\..\Tone.h $PROJ_DIR$\..\WCharacter.h @@ -2776,6 +2764,9 @@ $PROJ_DIR$\..\wiring_analog.h + + $PROJ_DIR$\..\wiring_constants.h + $PROJ_DIR$\..\wiring_digital.c diff --git a/hardware/sam/cores/sam/main.cpp b/hardware/sam/cores/sam/main.cpp index 9f61d165e..626972e5a 100644 --- a/hardware/sam/cores/sam/main.cpp +++ b/hardware/sam/cores/sam/main.cpp @@ -11,9 +11,9 @@ int main( void ) setup() ; for ( ; ; ) - { + { loop() ; - } + } // return 0 ; } diff --git a/hardware/sam/cores/sam/syscalls_sam3.c b/hardware/sam/cores/sam/syscalls_sam3.c index 844db5cb9..98de4bf05 100644 --- a/hardware/sam/cores/sam/syscalls_sam3.c +++ b/hardware/sam/cores/sam/syscalls_sam3.c @@ -39,7 +39,7 @@ *----------------------------------------------------------------------------*/ -#include "variant.h" +#include "syscalls.h" #include #include diff --git a/hardware/sam/cores/sam/validation/build_gcc/test.mk b/hardware/sam/cores/sam/validation/build_gcc/test.mk index 0a4ca1739..15b81e713 100644 --- a/hardware/sam/cores/sam/validation/build_gcc/test.mk +++ b/hardware/sam/cores/sam/validation/build_gcc/test.mk @@ -1,7 +1,7 @@ # Makefile for compiling libArduino .SUFFIXES: .o .a .c .s -CHIP=sam3s4 +CHIP=__SAM3S4C__ VARIANT=sam3s_ek TOOLCHAIN=gcc @@ -9,14 +9,11 @@ TOOLCHAIN=gcc # Path #------------------------------------------------------------------------------- -# Output directories -OUTPUT_PATH = . - # Libraries -PROJECT_BASE_PATH = . -SYSTEM_PATH = ../../../system +PROJECT_BASE_PATH = ./.. +SYSTEM_PATH = ../../../../system CMSIS_BASE_PATH = $(SYSTEM_PATH)/CMSIS/Include -VARIANT_PATH = ../../../variants/sam3s-ek +VARIANT_PATH = ../../../../variants/$(VARIANT) ifeq ($(CHIP), __SAM3S4C__) CHIP_NAME=sam3s4c @@ -33,7 +30,10 @@ CHIP_SERIE=sam3xa else endif -CMSIS_CHIP_PATH=$(PROJECT_BASE_PATH)/../cmsis/$(CHIP_SERIE) +CMSIS_CHIP_PATH=$(SYSTEM_PATH)/libsam/cmsis/$(CHIP_SERIE) + +# Output directories +OUTPUT_PATH = debug_$(VARIANT) #------------------------------------------------------------------------------- # Files @@ -46,6 +46,7 @@ VPATH+=$(PROJECT_BASE_PATH) INCLUDES = -I$(PROJECT_BASE_PATH)/.. INCLUDES += -I$(VARIANT_PATH) +INCLUDES += -I$(VARIANT_PATH)/.. INCLUDES += -I$(SYSTEM_PATH) INCLUDES += -I$(SYSTEM_PATH)/libsam INCLUDES += -I$(CMSIS_BASE_PATH) @@ -66,16 +67,16 @@ include $(TOOLCHAIN).mk #------------------------------------------------------------------------------- ifdef DEBUG OUTPUT_OBJ=debug -OUTPUT_BIN=test_$(TOOLCHAIN)_dbg -LIBS=-Wl,--start-group -lgcc -lc -lchip_$(CHIP)_$(TOOLCHAIN)_dbg -larduino_$(VARIANT)_$(TOOLCHAIN)_dbg -Wl,--end-group +LIBS_POSTFIX=dbg else OUTPUT_OBJ=release -OUTPUT_BIN=test_$(TOOLCHAIN)_rel -#LIBS=-L../libchip_$(CHIP)_$(TOOLCHAIN)_rel.a -L../arduino_$(VARIANT)_$(TOOLCHAIN)_rel.a -LIBS=-Wl,--start-group -lgcc -lc -lchip_$(CHIP)_$(TOOLCHAIN)_rel -larduino_$(VARIANT)_$(TOOLCHAIN)_rel -lstdc++ -Wl,--end-group +LIBS_POSTFIX=rel endif -//OUTPUT_PATH=$(OUTPUT_OBJ)_test.elf +OUTPUT_BIN=test_$(TOOLCHAIN)_$(LIBS_POSTFIX) +#LIBS=-L../libsam_$(CHIP_NAME)_$(TOOLCHAIN)_rel.a -L../arduino_$(VARIANT)_$(TOOLCHAIN)_rel.a +#-lstdc++ +LIBS=-Wl,--start-group -lgcc -lc -lsam_$(CHIP_NAME)_$(TOOLCHAIN)_$(LIBS_POSTFIX) -larduino_$(VARIANT)_$(TOOLCHAIN)_$(LIBS_POSTFIX) -lvariant_$(VARIANT)_$(TOOLCHAIN)_$(LIBS_POSTFIX) -Wl,--end-group LIB_PATH =-L$(PROJECT_BASE_PATH)/.. LIB_PATH+=-L=/lib/thumb2 @@ -100,11 +101,35 @@ CPP_OBJ=$(filter-out $(CPP_OBJ_FILTER), $(CPP_OBJ_TEMP)) #------------------------------------------------------------------------------- all: test -test: $(OUTPUT_BIN) +test: create_output $(OUTPUT_BIN) + +.PHONY: create_output +create_output: + @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) + @echo ------------------------- + @echo *$(INCLUDES) + @echo ------------------------- + @echo *$(C_SRC) + @echo ------------------------- + @echo *$(C_OBJ) + @echo ------------------------- + @echo *$(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) + @echo ------------------------- + @echo *$(CPP_SRC) + @echo ------------------------- + @echo *$(CPP_OBJ) + @echo ------------------------- + @echo *$(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) + @echo ------------------------- + @echo *$(A_SRC) + @echo ------------------------- + + -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 $(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp # @$(CC) -c $(CPPFLAGS) $< -o $@ - @$(CXX) -c $(CPPFLAGS) $< -o $@ +# @$(CXX) -c $(CPPFLAGS) $< -o $@ + $(CXX) -v -c $(CPPFLAGS) $< -o $@ $(OUTPUT_BIN): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) $(CC) $(LIB_PATH) $(LDFLAGS) -T"$(VARIANT_PATH)/linker_scripts/gcc/flash.ld" -Wl,-Map,$(OUTPUT_PATH)/$@.map -o $(OUTPUT_PATH)/$@.elf $^ $(LIBS) @@ -112,7 +137,6 @@ $(OUTPUT_BIN): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH) $(OBJCOPY) -O binary $(OUTPUT_PATH)/$@.elf $(OUTPUT_PATH)/$@.bin $(SIZE) $^ $(OUTPUT_PATH)/$@.elf - .PHONY: clean clean: @echo --- Cleaning test files @@ -123,4 +147,4 @@ clean: -@$(RM) $(OUTPUT_PATH)/$(OUTPUT_BIN).map 1>NUL 2>&1 debug: test - $(GDB) -x "$(VARIANT_PATH)/debug_scripts/gcc/flash.gdb" -ex "reset" -readnow -se $(OUTPUT_PATH)/$(OUTPUT_BIN).elf + $(GDB) -x "$(VARIANT_PATH)/debug_scripts/gcc/$(VARIANT)_flash.gdb" -ex "reset" -readnow -se $(OUTPUT_PATH)/$(OUTPUT_BIN).elf diff --git a/hardware/sam/cores/sam/validation/build_iar/test.ewp b/hardware/sam/cores/sam/validation/build_iar/test.ewp index 1dd1d9329..c22825fb8 100644 --- a/hardware/sam/cores/sam/validation/build_iar/test.ewp +++ b/hardware/sam/cores/sam/validation/build_iar/test.ewp @@ -294,6 +294,7 @@ @@ -1816,26 +1817,14 @@ sam3u_ek - - variants - - sam3s_ek - - $PROJ_DIR$\..\..\..\..\variants\sam3s_ek\pins_arduino.h - - - $PROJ_DIR$\..\..\..\..\variants\sam3s_ek\variant.cpp - - - $PROJ_DIR$\..\..\..\..\variants\sam3s_ek\variant.h - - - - $PROJ_DIR$\..\..\build_iar\Debug\Exe\libarduino_sam3s_ek_ewarm_dbg.a + $PROJ_DIR$\..\..\libarduino_sam3s_ek_ewarm_dbg.a - $PROJ_DIR$\..\..\..\..\system\libsam\build_iar\Debug\Exe\libsam_sam3s4c_ewarm_dbg.a + $PROJ_DIR$\..\..\libsam_sam3s4c_ewarm_dbg.a + + + $PROJ_DIR$\..\..\libvariant_sam3s_ek_ewarm_dbg.a $PROJ_DIR$\..\test.cpp diff --git a/hardware/sam/cores/sam/validation/test.cpp b/hardware/sam/cores/sam/validation/test.cpp index 060c7493f..9590f6e4c 100644 --- a/hardware/sam/cores/sam/validation/test.cpp +++ b/hardware/sam/cores/sam/validation/test.cpp @@ -1,4 +1,8 @@ -#include "../Arduino.h" +/* + %atmel_license% +*/ + +#include "variant.h" void setup( void ) { @@ -11,7 +15,7 @@ void setup( void ) pinMode( PIN_LED_GREEN, OUTPUT ) ; digitalWrite( PIN_LED_GREEN, HIGH ) ; -// Serial1.begin( 19200 ) ; + Serial.begin( 19200 ) ; } void loop( void ) @@ -23,7 +27,8 @@ void loop( void ) digitalWrite( PIN_LED_GREEN, HIGH ) ; // set the red LED on delay( 1000 ) ; // wait for a second - //Serial1.println( "test1" ) ; // send an initial string - //delay( 1000 ) ; // wait for a second - //Serial1.println( "test2" ) ; // send an initial string +// Serial.write( '*' ) ; // send an initial char +// Serial.println( "test1" ) ; // send an initial string +// delay( 1000 ) ; // wait for a second +// Serial.println( "test2" ) ; // send an initial string } diff --git a/hardware/sam/cores/sam/wiring.c b/hardware/sam/cores/sam/wiring.c index e590c2271..2a564de3e 100644 --- a/hardware/sam/cores/sam/wiring.c +++ b/hardware/sam/cores/sam/wiring.c @@ -1,31 +1,11 @@ /* - wiring.c - Partial implementation of the Wiring API for the ATmega8. - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id$ + %atmel_license% */ -#include "wiring_private.h" +#include "Arduino.h" #ifdef __cplusplus - extern "C" { +extern "C" { #endif uint32_t millis( void ) @@ -42,23 +22,14 @@ uint32_t micros( void ) dwTicks=SysTick->VAL ; __enable_irq() ; - return (GetTickCount()*1000) + ((SysTick->LOAD + 1 - dwTicks)/(VARIANT_MCK/1000000)) ; + return (GetTickCount()*1000) + ((SysTick->LOAD + 1 - dwTicks)/(SystemCoreClock/1000000)) ; } -/// \brief Pauses the program for the amount of time (in miliseconds) specified as parameter. -/// (There are 1000 milliseconds in a second.) -/// -/// \param dwMs the number of milliseconds to pause (uint32_t) -/// void delay( uint32_t dwMs ) { Wait( dwMs ) ; } -/// \brief Pauses the program for the amount of time (in microseconds) specified as parameter. -/// -/// \param dwUs the number of microseconds to pause (uint32_t) -/// void delayMicroseconds( uint32_t dwUs ) { uint32_t dwStartMicros=micros() ; @@ -78,30 +49,8 @@ extern void SysTick_Handler( void ) TimeTick_Increment() ; } -extern void init( void ) -{ - SystemInit() ; - - /* Set Systick to 1ms interval, common to all SAM3 variants */ - if ( SysTick_Config( SystemCoreClock / 1000 ) ) - { - /* Capture error */ - while ( 1 ) ; - } - - /* Disable watchdog, common to all SAM variants */ - WDT_Disable( WDT ) ; - - // 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 ) ; - - // Switch off Power LED - PIO_Configure( APinDescription[PIN_LED_RED].pPort, APinDescription[PIN_LED_RED].dwPinType, - APinDescription[PIN_LED_RED].dwPin, APinDescription[PIN_LED_RED].dwPinAttribute ) ; - PIO_Clear( APinDescription[PIN_LED_RED].pPort, APinDescription[PIN_LED_RED].dwPin ) ; -} - +#if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */ +extern signed int putchar( signed int c ) ; /** * \brief * @@ -113,6 +62,7 @@ extern WEAK signed int putchar( signed int c ) { return c ; } +#endif /* __ICCARM__ */ #ifdef __cplusplus } diff --git a/hardware/sam/cores/sam/wiring.h b/hardware/sam/cores/sam/wiring.h index 4eb1c187f..7295ae4d4 100644 --- a/hardware/sam/cores/sam/wiring.h +++ b/hardware/sam/cores/sam/wiring.h @@ -1,19 +1,53 @@ +/* + %atmel_license% +*/ + #ifndef _WIRING_ #define _WIRING_ #ifdef __cplusplus - extern "C" { +extern "C" { #endif - +/** + * + */ extern void init( void ) ; +/** + * \brief Returns the number of milliseconds since the Arduino board began running the current program. + * + * This number will overflow (go back to zero), after approximately 50 days. + * + * \return Number of milliseconds since the program started (uint32_t) + */ extern uint32_t millis( void ) ; +/** + * \brief Returns the number of microseconds since the Arduino board began running the current program. + * + * This number will overflow (go back to zero), after approximately 70 minutes. On 16 MHz Arduino boards + * (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is + * always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution + * of eight microseconds. + * + * \note There are 1,000 microseconds in a millisecond and 1,000,000 microseconds in a second. + */ extern uint32_t micros( void ) ; +/** + * \brief Pauses the program for the amount of time (in miliseconds) specified as parameter. + * (There are 1000 milliseconds in a second.) + * + * \param dwMs the number of milliseconds to pause (uint32_t) + */ extern void delay( uint32_t dwMs ) ; +/** + * \brief Pauses the program for the amount of time (in microseconds) specified as parameter. + * + * \param dwUs the number of microseconds to pause (uint32_t) + */ extern void delayMicroseconds( uint32_t dwUs ) ; diff --git a/hardware/sam/cores/sam/wiring_analog.h b/hardware/sam/cores/sam/wiring_analog.h index 9b68cab25..d68aeeb9d 100644 --- a/hardware/sam/cores/sam/wiring_analog.h +++ b/hardware/sam/cores/sam/wiring_analog.h @@ -1,3 +1,7 @@ +/* + %atmel_license% +*/ + #ifndef _WIRING_ANALOG_ #define _WIRING_ANALOG_ diff --git a/hardware/sam/cores/sam/wiring_constants.h b/hardware/sam/cores/sam/wiring_constants.h new file mode 100644 index 000000000..81e3872fa --- /dev/null +++ b/hardware/sam/cores/sam/wiring_constants.h @@ -0,0 +1,78 @@ +/* + %atmel_license% +*/ + +#ifndef _WIRING_CONSTANTS_ +#define _WIRING_CONSTANTS_ + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +#define HIGH 0x1 +#define LOW 0x0 + +#define INPUT 0x0 +#define OUTPUT 0x1 + +#define true 0x1 +#define false 0x0 + +#define PI 3.1415926535897932384626433832795 +#define HALF_PI 1.5707963267948966192313216916398 +#define TWO_PI 6.283185307179586476925286766559 +#define DEG_TO_RAD 0.017453292519943295769236907684886 +#define RAD_TO_DEG 57.295779513082320876798154814105 + +#define SERIAL 0x0 +#define DISPLAY 0x1 + +#define LSBFIRST 0 +#define MSBFIRST 1 + +#define CHANGE 1 +#define FALLING 2 +#define RISING 3 + +#define DEFAULT 1 +#define EXTERNAL 0 + +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs + +#define min(a,b) ((a)<(b)?(a):(b)) +#define max(a,b) ((a)>(b)?(a):(b)) +#define abs(x) ((x)>0?(x):-(x)) +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + +typedef unsigned int word; + +#define bit(b) (1UL << (b)) + +// TODO: to be checked +typedef uint8_t boolean ; +typedef uint8_t byte ; + + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif /* _WIRING_CONSTANTS_ */ diff --git a/hardware/sam/cores/sam/wiring_digital.c b/hardware/sam/cores/sam/wiring_digital.c index 20444ddd5..adda40a30 100644 --- a/hardware/sam/cores/sam/wiring_digital.c +++ b/hardware/sam/cores/sam/wiring_digital.c @@ -1,57 +1,35 @@ /* - wiring_digital.c - digital input and output functions - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - Modified 28 September 2010 by Mark Sproul - - $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ + %atmel_license% */ -#include "wiring_private.h" +#include "Arduino.h" #ifdef __cplusplus extern "C" { #endif -extern void pinMode( uint32_t dwPin, uint32_t dwMode ) +extern void pinMode( uint32_t ulPin, uint32_t ulMode ) { - if ( APinDescription[dwPin].dwPinType == PIO_NOT_A_PIN ) + if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN ) { return ; } - switch ( dwMode ) + switch ( ulMode ) { case INPUT: /* Enable peripheral for clocking input */ - PMC_EnablePeripheral( APinDescription[dwPin].dwPeripheralId ) ; - PIO_Configure( APinDescription[dwPin].pPort, PIO_INPUT, APinDescription[dwPin].dwPin, 0 ) ; + PMC_EnablePeripheral( g_APinDescription[ulPin].ulPeripheralId ) ; + PIO_Configure( g_APinDescription[ulPin].pPort, PIO_INPUT, g_APinDescription[ulPin].ulPin, 0 ) ; break ; case OUTPUT: /* if all pins are output, disable PIO Controller clocking, reduce power consomption */ - if ( APinDescription[dwPin].pPort->PIO_OSR == 0xffffffff ) + if ( g_APinDescription[ulPin].pPort->PIO_OSR == 0xffffffff ) { - PMC_DisablePeripheral( APinDescription[dwPin].dwPeripheralId ) ; + PMC_DisablePeripheral( g_APinDescription[ulPin].ulPeripheralId ) ; } - PIO_Configure( APinDescription[dwPin].pPort, PIO_OUTPUT_1, APinDescription[dwPin].dwPin, APinDescription[dwPin].dwPinAttribute ) ; + PIO_Configure( g_APinDescription[ulPin].pPort, PIO_OUTPUT_1, g_APinDescription[ulPin].ulPin, g_APinDescription[ulPin].ulPinAttribute ) ; break ; default: @@ -59,24 +37,32 @@ extern void pinMode( uint32_t dwPin, uint32_t dwMode ) } } -extern void digitalWrite( uint32_t dwPin, uint32_t dwVal ) +extern void digitalWrite( uint32_t ulPin, uint32_t ulVal ) { - if ( APinDescription[dwPin].dwPinType == PIO_NOT_A_PIN ) - { - return ; - } + /* Handle */ + if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN ) + { + return ; + } - PIO_SetOutput( APinDescription[dwPin].pPort, APinDescription[dwPin].dwPin, dwVal, 0, PIO_PULLUP ) ; + if ( PIO_GetOutputDataStatus( g_APinDescription[ulPin].pPort, g_APinDescription[ulPin].ulPin ) == 0 ) + { + PIO_PullUp( g_APinDescription[ulPin].pPort, g_APinDescription[ulPin].ulPin, 1 ) ; + } + else + { + PIO_SetOutput( g_APinDescription[ulPin].pPort, g_APinDescription[ulPin].ulPin, ulVal, 0, PIO_PULLUP ) ; + } } -extern int digitalRead( uint32_t dwPin ) +extern int digitalRead( uint32_t ulPin ) { - if ( APinDescription[dwPin].dwPinType == PIO_NOT_A_PIN ) + if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN ) { return LOW ; } - if ( PIO_Get( APinDescription[dwPin].pPort, PIO_INPUT, APinDescription[dwPin].dwPin ) == 1 ) + if ( PIO_Get( g_APinDescription[ulPin].pPort, PIO_INPUT, g_APinDescription[ulPin].ulPin ) == 1 ) { return HIGH ; } diff --git a/hardware/sam/cores/sam/wiring_digital.h b/hardware/sam/cores/sam/wiring_digital.h index bb61dfa2c..ff77bc53f 100644 --- a/hardware/sam/cores/sam/wiring_digital.h +++ b/hardware/sam/cores/sam/wiring_digital.h @@ -1,3 +1,7 @@ +/* + %atmel_license% +*/ + #ifndef _WIRING_DIGITAL_ #define _WIRING_DIGITAL_ @@ -5,18 +9,18 @@ extern "C" { #endif -/* +/** * \brief Configures the specified pin to behave either as an input or an output. See the description of digital pins for details. * - * \param dwPin the number of the pin whose mode you wish to set - * \param dwMode either INPUT or OUTPUT + * \param ulPin The number of the pin whose mode you wish to set + * \param ulMode Either INPUT or OUTPUT */ extern void pinMode( uint32_t dwPin, uint32_t dwMode ) ; -/* +/** * \brief Write a HIGH or a LOW value to a digital pin. * - * \desc If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the + * If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the * corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. * * If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal @@ -35,12 +39,14 @@ extern void pinMode( uint32_t dwPin, uint32_t dwMode ) ; */ extern void digitalWrite( uint32_t dwPin, uint32_t dwVal ) ; -/* +/** * \brief Reads the value from a specified digital pin, either HIGH or LOW. * - * \param dwPin the number of the digital pin you want to read (int) + * \param ulPin The number of the digital pin you want to read (int) + * + * \return HIGH or LOW */ -extern int digitalRead( uint32_t dwPin ) ; +extern int digitalRead( uint32_t ulPin ) ; #ifdef __cplusplus } diff --git a/hardware/sam/cores/sam/wiring_private.h b/hardware/sam/cores/sam/wiring_private.h index f422f3072..f6bb12864 100644 --- a/hardware/sam/cores/sam/wiring_private.h +++ b/hardware/sam/cores/sam/wiring_private.h @@ -1,25 +1,5 @@ /* - wiring_private.h - Internal header file. - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $ + %atmel_license% */ #ifndef WiringPrivate_h @@ -29,26 +9,18 @@ #include #include -#include "Arduino.h" - #ifdef __cplusplus extern "C"{ #endif -typedef void (*voidFuncPtr)( void ) ; - -/* Define attribute */ -#if defined ( __CC_ARM ) /* Keil µVision 4 */ - #define WEAK __attribute__ ((weak)) -#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */ - #define WEAK __weak -#elif defined ( __GNUC__ ) /* GCC CS */ - #define WEAK __attribute__ ((weak)) -#endif - +#include "libsam/chip.h" +#include "wiring_constants.h" #ifdef __cplusplus } // extern "C" + +#include "HardwareSerial.h" + #endif #endif diff --git a/hardware/sam/cores/sam/wiring_pulse.h b/hardware/sam/cores/sam/wiring_pulse.h index d43dcb9ab..de8cb65e2 100644 --- a/hardware/sam/cores/sam/wiring_pulse.h +++ b/hardware/sam/cores/sam/wiring_pulse.h @@ -1,3 +1,7 @@ +/* + %atmel_license% +*/ + #ifndef _WIRING_PULSE_ #define _WIRING_PULSE_ diff --git a/hardware/sam/cores/sam/wiring_shift.c b/hardware/sam/cores/sam/wiring_shift.c index 28708df69..4111d151b 100644 --- a/hardware/sam/cores/sam/wiring_shift.c +++ b/hardware/sam/cores/sam/wiring_shift.c @@ -1,28 +1,8 @@ /* - wiring_shift.c - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ + %atmel_license% */ -#include "wiring_private.h" +#include "Arduino.h" #ifdef __cplusplus extern "C"{ diff --git a/hardware/sam/cores/sam/wiring_shift.h b/hardware/sam/cores/sam/wiring_shift.h index ed9284bde..6d5ba7a12 100644 --- a/hardware/sam/cores/sam/wiring_shift.h +++ b/hardware/sam/cores/sam/wiring_shift.h @@ -1,3 +1,7 @@ +/* + %atmel_license% +*/ + #ifndef _WIRING_SHIFT_ #define _WIRING_SHIFT_ diff --git a/hardware/sam/system/libsam/build_gcc/sam3.mk b/hardware/sam/system/libsam/build_gcc/sam3.mk index d78f69840..81a2d90e1 100644 --- a/hardware/sam/system/libsam/build_gcc/sam3.mk +++ b/hardware/sam/system/libsam/build_gcc/sam3.mk @@ -2,7 +2,7 @@ .SUFFIXES: .o .a .c .s SUB_MAKEFILES=debug.mk gcc.mk release.mk win.mk sam3s.mk -LIBNAME=libchip +LIBNAME=libsam TOOLCHAIN=gcc ifeq ($(CHIP),) @@ -39,7 +39,7 @@ CHIP_SERIE=sam3xa else endif -CMSIS_CHIP_PATH=$(PROJECT_BASE_PATH)/../cmsis/$(CHIP_SERIE) +CMSIS_CHIP_PATH=$(PROJECT_BASE_PATH)/cmsis/$(CHIP_SERIE) #------------------------------------------------------------------------------- # Files @@ -88,8 +88,8 @@ OUTPUT_PATH=$(OUTPUT_OBJ)_$(CHIP_NAME) # C source files and objects #------------------------------------------------------------------------------- C_SRC=$(wildcard $(PROJECT_BASE_PATH)/source/*.c) -C_SRC+=$(wildcard $(CMSIS_CHIP_PATH)/*.c) -C_SRC+=$(wildcard $(CMSIS_CHIP_PATH)/gcc*.c) +C_SRC+=$(wildcard $(CMSIS_CHIP_PATH)/source/templates/*.c) +C_SRC+=$(wildcard $(CMSIS_CHIP_PATH)/source/templates/gcc/*.c) C_OBJ_TEMP=$(patsubst %.c, %.o, $(notdir $(C_SRC))) @@ -102,7 +102,6 @@ C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP)) # Assembler source files and objects #------------------------------------------------------------------------------- A_SRC=$(wildcard $(PROJECT_BASE_PATH)/source/*.s) -A_SRC+=$(wildcard $(CMSIS_BASE_PATH)/*.s) A_OBJ_TEMP=$(patsubst %.s, %.o, $(notdir $(A_SRC))) @@ -121,7 +120,7 @@ $(CHIP): create_output $(OUTPUT_LIB) .PHONY: create_output create_output: @echo --- Preparing $(CHIP) files $(OUTPUT_PATH) $(OUTPUT_BIN) -# @echo ------------------------- + @echo ------------------------- # @echo *$(C_SRC) # @echo ------------------------- # @echo *$(C_OBJ) diff --git a/hardware/sam/system/libsam/build_iar/libsam.ewp b/hardware/sam/system/libsam/build_iar/libsam.ewp index e6769d569..08609c801 100644 --- a/hardware/sam/system/libsam/build_iar/libsam.ewp +++ b/hardware/sam/system/libsam/build_iar/libsam.ewp @@ -888,7 +888,7 @@ diff --git a/hardware/sam/system/libsam/build_iar/libsam.eww b/hardware/sam/system/libsam/build_iar/libsam.eww index a916c49f1..1e4c9ea5d 100644 --- a/hardware/sam/system/libsam/build_iar/libsam.eww +++ b/hardware/sam/system/libsam/build_iar/libsam.eww @@ -7,6 +7,9 @@ $WS_DIR$\libsam.ewp + + $WS_DIR$\..\..\..\variants\sam3s_ek\build_iar\libvariant_sam3s_ek.ewp + $WS_DIR$\..\..\..\cores\sam\validation\build_iar\test.ewp @@ -21,6 +24,10 @@ libarduino Debug + + libsam3s_ek + Debug + test Debug diff --git a/hardware/sam/system/libsam/cmsis/cmsis_example/main.c b/hardware/sam/system/libsam/cmsis/cmsis_example/main.c deleted file mode 100644 index e7d579b79..000000000 --- a/hardware/sam/system/libsam/cmsis/cmsis_example/main.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - %atmel_license% -*/ - -/** \file cmsis example */ - -#include -#include -#include -#include "conf_board.h" - -//! counts 1ms timeTicks -volatile uint32_t dw_ms_ticks = 0; - -/** - * \brief SysTick_Handler. - */ -void SysTick_Handler(void) -{ - // increment counter necessary in delay() - dw_ms_ticks++; -} - -/** - * \brief delays number of tick Systicks (happens every 1 ms) - */ -__INLINE static void delay_ms(uint32_t dw_dly_ticks) -{ - uint32_t dw_cur_ticks; - - dw_cur_ticks = dw_ms_ticks; - while ((dw_ms_ticks - dw_cur_ticks) < dw_dly_ticks); -} - - /** - * \brief configer LED pins - */ -__INLINE static void led_config(void) -{ - // Setup LED Pin - LED0_PIO->PIO_PER = LED0_MASK; - LED0_PIO->PIO_OER = LED0_MASK; - LED0_PIO->PIO_PUDR = LED0_MASK; -} - -/** -* \brief Switch on LED -*/ -__INLINE static void led_on(uint32_t dw_led) -{ - // Turn On LED - LED0_PIO->PIO_CODR = dw_led; -} - -/** -* \brief Switch off LED -*/ -__INLINE static void led_off(uint32_t dw_led) -{ - // Turn Off LED - LED0_PIO->PIO_SODR = dw_led; -} - -/** - * \brief Application entry point. - * - * \return Unused (ANSI-C compatibility). - */ -int main(void) -{ - SystemInit(); - - WDT->WDT_MR = WDT_MR_WDDIS; - - // Setup SysTick Timer for 1 msec interrupts - if (SysTick_Config(SystemCoreClock / 1000)) { - // Capture error - while (1); - } - - led_config(); - - // Flash the LED - while(1) { - // Turn on the LED. - led_on (LED0_MASK); - // delay 1000 Msec. - delay_ms (1000); - - // Turn off the LED. - led_off(LED0_MASK); - // delay 1000 Msec. - delay_ms (1000); - } -} diff --git a/hardware/sam/system/libsam/cmsis/cmsis_example/sam3n4c_sam3s_ek/conf_board.h b/hardware/sam/system/libsam/cmsis/cmsis_example/sam3n4c_sam3s_ek/conf_board.h deleted file mode 100644 index fddc57852..000000000 --- a/hardware/sam/system/libsam/cmsis/cmsis_example/sam3n4c_sam3s_ek/conf_board.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * \file - * - * \brief Board configuration for clock example 1 - * - * Copyright (C) 2010 Atmel Corporation. All rights reserved. - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel AVR product. - * - * 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 - * EXPRESSLY AND SPECIFICALLY 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 CONF_BOARD_H_INCLUDED -#define CONF_BOARD_H_INCLUDED - -#define LED0_PIO PIOA -#define LED0_MASK (0x01 << 23) - -#endif /* CONF_BOARD_H_INCLUDED */ diff --git a/hardware/sam/system/libsam/cmsis/cmsis_example/sam3s4c_sam3s_ek/conf_board.h b/hardware/sam/system/libsam/cmsis/cmsis_example/sam3s4c_sam3s_ek/conf_board.h deleted file mode 100644 index 9fd3c435f..000000000 --- a/hardware/sam/system/libsam/cmsis/cmsis_example/sam3s4c_sam3s_ek/conf_board.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * \file - * - * \brief Board configuration for clock example 1 - * - * Copyright (C) 2010 Atmel Corporation. All rights reserved. - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel AVR product. - * - * 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 - * EXPRESSLY AND SPECIFICALLY 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 CONF_BOARD_H_INCLUDED -#define CONF_BOARD_H_INCLUDED - -#define LED0_PIO PIOA -#define LED0_MASK (0x01 << 19) - -#endif /* CONF_BOARD_H_INCLUDED */ diff --git a/hardware/sam/system/libsam/cmsis/cmsis_example/sam3sd8c_sam3s_ek2/conf_board.h b/hardware/sam/system/libsam/cmsis/cmsis_example/sam3sd8c_sam3s_ek2/conf_board.h deleted file mode 100644 index 9fd3c435f..000000000 --- a/hardware/sam/system/libsam/cmsis/cmsis_example/sam3sd8c_sam3s_ek2/conf_board.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * \file - * - * \brief Board configuration for clock example 1 - * - * Copyright (C) 2010 Atmel Corporation. All rights reserved. - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel AVR product. - * - * 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 - * EXPRESSLY AND SPECIFICALLY 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 CONF_BOARD_H_INCLUDED -#define CONF_BOARD_H_INCLUDED - -#define LED0_PIO PIOA -#define LED0_MASK (0x01 << 19) - -#endif /* CONF_BOARD_H_INCLUDED */ diff --git a/hardware/sam/system/libsam/cmsis/cmsis_example/sam3u4e_sam3s_ek/conf_board.h b/hardware/sam/system/libsam/cmsis/cmsis_example/sam3u4e_sam3s_ek/conf_board.h deleted file mode 100644 index 7a709fd26..000000000 --- a/hardware/sam/system/libsam/cmsis/cmsis_example/sam3u4e_sam3s_ek/conf_board.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * \file - * - * \brief Board configuration for clock example 1 - * - * Copyright (C) 2010 Atmel Corporation. All rights reserved. - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel AVR product. - * - * 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 - * EXPRESSLY AND SPECIFICALLY 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 CONF_BOARD_H_INCLUDED -#define CONF_BOARD_H_INCLUDED - -#define LED0_PIO PIOB -#define LED0_MASK (0x01 << 0) - -#endif /* CONF_BOARD_H_INCLUDED */ diff --git a/hardware/sam/system/libsam/cmsis/cmsis_example/sam3x8h_sam3x_ek/conf_board.h b/hardware/sam/system/libsam/cmsis/cmsis_example/sam3x8h_sam3x_ek/conf_board.h deleted file mode 100644 index 9ee4d8f3b..000000000 --- a/hardware/sam/system/libsam/cmsis/cmsis_example/sam3x8h_sam3x_ek/conf_board.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * \file - * - * \brief Board configuration for clock example 1 - * - * Copyright (C) 2010 Atmel Corporation. All rights reserved. - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel AVR product. - * - * 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 - * EXPRESSLY AND SPECIFICALLY 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 CONF_BOARD_H_INCLUDED -#define CONF_BOARD_H_INCLUDED - -#define LED0_PIO PIOB -#define LED0_MASK (0x01 << 12) - -#endif /* CONF_BOARD_H_INCLUDED */ diff --git a/hardware/sam/system/libsam/cmsis/sam3s/source/templates/exceptions.c b/hardware/sam/system/libsam/cmsis/sam3s/source/templates/exceptions.c index 61c21ce95..5ed6a5892 100644 --- a/hardware/sam/system/libsam/cmsis/sam3s/source/templates/exceptions.c +++ b/hardware/sam/system/libsam/cmsis/sam3s/source/templates/exceptions.c @@ -4,7 +4,7 @@ * * \par Purpose * - * This file provides basic support for Cortex-M processor based + * This file provides basic support for Cortex-M processor based * microcontrollers. * * \note @@ -81,7 +81,7 @@ extern void WDT_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler") /* Cortex-M3 core handlers */ #pragma weak Reset_Handler=Dummy_Handler #pragma weak NMI_Handler=Dummy_Handler -#pragma weak HardFault_Handler=Dummy_Handler +//#pragma weak HardFault_Handler=Dummy_Handler #pragma weak MemManage_Handler=Dummy_Handler #pragma weak BusFault_Handler=Dummy_Handler #pragma weak UsageFault_Handler=Dummy_Handler diff --git a/hardware/sam/system/libsam/cmsis/sam3s/source/templates/exceptions.h b/hardware/sam/system/libsam/cmsis/sam3s/source/templates/exceptions.h index f08330341..47e253821 100644 --- a/hardware/sam/system/libsam/cmsis/sam3s/source/templates/exceptions.h +++ b/hardware/sam/system/libsam/cmsis/sam3s/source/templates/exceptions.h @@ -4,7 +4,7 @@ * * \par Purpose * - * This file provides basic support for Cortex-M processor based + * This file provides basic support for Cortex-M processor based * microcontrollers. * * \author Atmel Corporation: http://www.atmel.com \n diff --git a/hardware/sam/system/libsam/cmsis/sam3s/source/templates/iar/startup_sam3s.c b/hardware/sam/system/libsam/cmsis/sam3s/source/templates/iar/startup_sam3s.c index 0e9fb1f57..2313739bc 100644 --- a/hardware/sam/system/libsam/cmsis/sam3s/source/templates/iar/startup_sam3s.c +++ b/hardware/sam/system/libsam/cmsis/sam3s/source/templates/iar/startup_sam3s.c @@ -73,7 +73,7 @@ const intvec_elem __vector_table[] = WDT_IrqHandler, /* 4 Watchdog Timer */ PMC_IrqHandler, /* 5 PMC */ EEFC_IrqHandler, /* 6 EEFC */ - Dummy_Handler, /* 7 Reserved */ + Dummy_Handler, /* 7 Reserved */ UART0_IrqHandler, /* 8 UART0 */ UART1_IrqHandler, /* 9 UART1 */ SMC_IrqHandler, /* 10 SMC */ @@ -82,8 +82,8 @@ const intvec_elem __vector_table[] = PIOC_IrqHandler, /* 13 Parallel IO Controller C */ USART0_IrqHandler, /* 14 USART 0 */ USART1_IrqHandler, /* 15 USART 1 */ - Dummy_Handler, /* 16 Reserved */ - Dummy_Handler, /* 17 Reserved */ + Dummy_Handler, /* 16 Reserved */ + Dummy_Handler, /* 17 Reserved */ MCI_IrqHandler, /* 18 MCI */ TWI0_IrqHandler, /* 19 TWI 0 */ TWI1_IrqHandler, /* 20 TWI 1 */ @@ -101,7 +101,7 @@ const intvec_elem __vector_table[] = CRCCU_IrqHandler, /* 32 CRC Calculation Unit */ ACC_IrqHandler, /* 33 Analog Comparator */ USBD_IrqHandler, /* 34 USB Device Port */ - Dummy_Handler /* 35 not used */ + Dummy_Handler /* 35 not used */ }; /* TEMPORARY PATCH FOR SCB */ diff --git a/hardware/sam/system/libsam/source/pio.c b/hardware/sam/system/libsam/source/pio.c index c88d78bae..e09a0decc 100644 --- a/hardware/sam/system/libsam/source/pio.c +++ b/hardware/sam/system/libsam/source/pio.c @@ -31,9 +31,6 @@ extern void PIO_DisableInterrupt( Pio *pPio, const uint32_t dwMask ) */ extern void PIO_PullUp( Pio *pPio, const uint32_t dwMask, const uint32_t dwPullUpEnable ) { - /* Disable interrupts on the pin(s) */ - pPio->PIO_IDR = dwMask ; - /* Enable the pull-up(s) if necessary */ if ( dwPullUpEnable ) { @@ -271,7 +268,11 @@ extern uint32_t PIO_Configure( Pio* pPio, const EPioType dwType, const uint32_t case PIO_PERIPH_B : case PIO_PERIPH_C : case PIO_PERIPH_D : + /* Put the pin under control of peripheral */ PIO_SetPeripheral( pPio, dwType, dwMask ) ; + /* Disable interrupts on the pin(s) */ + PIO_DisableInterrupt( pPio, dwMask ) ; + /* Enable Pullup */ PIO_PullUp( pPio, dwMask, (dwAttribute & PIO_PULLUP) ) ; break; @@ -305,13 +306,16 @@ extern uint32_t PIO_Configure( Pio* pPio, const EPioType dwType, const uint32_t */ extern uint32_t PIO_GetOutputDataStatus( const Pio* pPio, const uint32_t dwMask ) { - if ( (pPio->PIO_ODSR & dwMask) == 0 ) + /* Test if pin is under control of PIO */ + if ( (pPio->PIO_PSR & dwMask) != 0 ) + { + /* Test if pin is configured as output */ + if ( (pPio->PIO_OSR & dwMask) != 0 ) { - return 0 ; - } - else - { - return 1 ; + return 1 ; } + } + + return 0 ; } diff --git a/hardware/sam/variants/Arduino_Due/pins_arduino.h b/hardware/sam/variants/arduino_due/pins_arduino.h similarity index 100% rename from hardware/sam/variants/Arduino_Due/pins_arduino.h rename to hardware/sam/variants/arduino_due/pins_arduino.h diff --git a/hardware/sam/variants/Arduino_Due/variant.cpp b/hardware/sam/variants/arduino_due/variant.cpp similarity index 100% rename from hardware/sam/variants/Arduino_Due/variant.cpp rename to hardware/sam/variants/arduino_due/variant.cpp diff --git a/hardware/sam/variants/Arduino_Due/variant.h b/hardware/sam/variants/arduino_due/variant.h similarity index 100% rename from hardware/sam/variants/Arduino_Due/variant.h rename to hardware/sam/variants/arduino_due/variant.h diff --git a/hardware/sam/cores/sam/UART.cpp b/hardware/sam/variants/common/UART.cpp similarity index 58% rename from hardware/sam/cores/sam/UART.cpp rename to hardware/sam/variants/common/UART.cpp index b3e215e12..800db7756 100644 --- a/hardware/sam/cores/sam/UART.cpp +++ b/hardware/sam/variants/common/UART.cpp @@ -1,3 +1,7 @@ +/* + %atmel_license% +*/ + #include #include #include @@ -5,7 +9,7 @@ // Constructors //////////////////////////////////////////////////////////////// -UARTClass::UARTClass( Uart* pUart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer ) +UARTClass::UARTClass( Uart* pUart, IRQn_Type dwIrq, uint32_t dwId, RingBuffer* pRx_buffer, RingBuffer* pTx_buffer ) { _rx_buffer = pRx_buffer ; _tx_buffer = pTx_buffer ; @@ -30,7 +34,7 @@ void UARTClass::begin( const uint32_t dwBaudRate ) /* Configure baudrate */ /* Asynchronous, no oversampling */ - _pUart->UART_BRGR = (VARIANT_MCK / dwBaudRate) / 16 ; + _pUart->UART_BRGR = (SystemCoreClock / dwBaudRate) / 16 ; /* Disable PDC channel */ _pUart->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS ; @@ -42,45 +46,45 @@ void UARTClass::begin( const uint32_t dwBaudRate ) void UARTClass::end( void ) { // wait for transmission of outgoing data - while ( _tx_buffer->head != _tx_buffer->tail ) + while ( _tx_buffer->_iHead != _tx_buffer->_iTail ) { } // clear any received data - _rx_buffer->head = _rx_buffer->tail ; + _rx_buffer->_iHead = _rx_buffer->_iTail ; PMC_DisablePeripheral( _dwId ) ; } int UARTClass::available( void ) { - return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE ; + return (uint32_t)(SERIAL_BUFFER_SIZE + _rx_buffer->_iHead - _rx_buffer->_iTail) % SERIAL_BUFFER_SIZE ; } int UARTClass::peek( void ) { - if ( _rx_buffer->head == _rx_buffer->tail ) + if ( _rx_buffer->_iHead == _rx_buffer->_iTail ) { return -1 ; } else { - return _rx_buffer->buffer[_rx_buffer->tail] ; + return _rx_buffer->_aucBuffer[_rx_buffer->_iTail] ; } } int UARTClass::read( void ) { - // if the head isn't ahead of the tail, we don't have any characters - if ( _rx_buffer->head == _rx_buffer->tail ) + // if the head isn't ahead of the _iTail, we don't have any characters + if ( _rx_buffer->_iHead == _rx_buffer->_iTail ) { return -1 ; } else { - unsigned char c = _rx_buffer->buffer[_rx_buffer->tail] ; + unsigned char c = _rx_buffer->_aucBuffer[_rx_buffer->_iTail] ; - _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE ; + _rx_buffer->_iTail = (unsigned int)(_rx_buffer->_iTail + 1) % SERIAL_BUFFER_SIZE ; return c ; } @@ -88,49 +92,49 @@ int UARTClass::read( void ) void UARTClass::flush( void ) { - while ( _tx_buffer->head != _tx_buffer->tail ) + while ( _tx_buffer->_iHead != _tx_buffer->_iTail ) { } } -void UARTClass::write( const uint8_t c ) +void UARTClass::write( const uint8_t uc ) { - int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE ; + int i = (_tx_buffer->_iHead + 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 ) + while ( i == _tx_buffer->_iTail ) { } - _tx_buffer->buffer[_tx_buffer->head] = c ; - _tx_buffer->head = i ; + _tx_buffer->_aucBuffer[_tx_buffer->_iHead] = uc ; + _tx_buffer->_iHead = i ; /* Wait for the transmitter to be ready */ while ( (_pUart->UART_SR & UART_SR_TXEMPTY) == 0 ) ; /* Send character */ - _pUart->UART_THR=c ; + _pUart->UART_THR=uc ; } void UARTClass::IrqHandler( void ) { // RX char IT - unsigned char c = _pUart->UART_RHR ; - store_char( c, _rx_buffer ) ; + uint8_t uc = _pUart->UART_RHR ; + _rx_buffer->store_char( uc ) ; // TX FIFO empty IT - if ( _tx_buffer->head == _tx_buffer->tail ) + if ( _tx_buffer->_iHead == _tx_buffer->_iTail ) { // 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 ; - - _pUart->UART_THR = c ; + uc = _tx_buffer->_aucBuffer[_tx_buffer->_iTail] ; + _tx_buffer->_iTail = (_tx_buffer->_iTail + 1) % SERIAL_BUFFER_SIZE ; + + _pUart->UART_THR = uc ; } } diff --git a/hardware/sam/cores/sam/UART.h b/hardware/sam/variants/common/UART.h similarity index 73% rename from hardware/sam/cores/sam/UART.h rename to hardware/sam/variants/common/UART.h index d6adc5271..6f77ff9cf 100644 --- a/hardware/sam/cores/sam/UART.h +++ b/hardware/sam/variants/common/UART.h @@ -1,10 +1,10 @@ -#ifndef _UART_ -#define _UART_ +#ifndef _UART_CLASS_ +#define _UART_CLASS_ // UART.cpp need this class to be predefined -class UARTClass ; +//class UARTClass ; -#include "wiring_private.h" +#include "Arduino.h" class UARTClass : public HardwareSerial { @@ -14,7 +14,7 @@ class UARTClass : public HardwareSerial uint32_t _dwId ; public: - UARTClass( Uart* pUart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer ) ; + UARTClass( Uart* pUart, IRQn_Type dwIrq, uint32_t dwId, RingBuffer* pRx_buffer, RingBuffer* pTx_buffer ) ; void begin( const uint32_t dwBaudRate ) ; void end( void ) ; @@ -31,4 +31,4 @@ class UARTClass : public HardwareSerial // using Print::write ; // pull in write(str) and write(buf, size) from Print }; -#endif // _UART_ +#endif // _UART_CLASS_ diff --git a/hardware/sam/cores/sam/USART.cpp b/hardware/sam/variants/common/USART.cpp similarity index 59% rename from hardware/sam/cores/sam/USART.cpp rename to hardware/sam/variants/common/USART.cpp index 6a08c055d..4173eff1b 100644 --- a/hardware/sam/cores/sam/USART.cpp +++ b/hardware/sam/variants/common/USART.cpp @@ -5,7 +5,7 @@ // Constructors //////////////////////////////////////////////////////////////// -USARTClass::USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer ) +USARTClass::USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, RingBuffer* pRx_buffer, RingBuffer* pTx_buffer ) { _rx_buffer = pRx_buffer ; _tx_buffer = pTx_buffer ; @@ -26,12 +26,12 @@ void USARTClass::begin( const uint32_t dwBaudRate ) _pUsart->US_CR = US_CR_RSTRX | US_CR_RSTTX | US_CR_RXDIS | US_CR_TXDIS ; /* Configure mode */ - _pUsart->US_MR = US_MR_USART_MODE_NORMAL | US_MR_USCLKS_MCK | US_MR_CHRL_8_BIT | US_MR_PAR_NO | + _pUsart->US_MR = US_MR_USART_MODE_NORMAL | US_MR_USCLKS_MCK | US_MR_CHRL_8_BIT | US_MR_PAR_NO | US_MR_NBSTOP_1_BIT | US_MR_CHMODE_NORMAL; /* Configure baudrate */ /* Asynchronous, no oversampling */ - _pUsart->US_BRGR = (VARIANT_MCK / dwBaudRate) / 16 ; + _pUsart->US_BRGR = (SystemCoreClock / dwBaudRate) / 16 ; /* Disable PDC channel */ _pUsart->US_PTCR = US_PTCR_RXTDIS | US_PTCR_TXTDIS ; @@ -43,45 +43,45 @@ void USARTClass::begin( const uint32_t dwBaudRate ) void USARTClass::end() { // wait for transmission of outgoing data - while ( _tx_buffer->head != _tx_buffer->tail ) + while ( _tx_buffer->_iHead != _tx_buffer->_iTail ) { } // clear any received data - _rx_buffer->head = _rx_buffer->tail ; + _rx_buffer->_iHead = _rx_buffer->_iTail ; PMC_DisablePeripheral( _dwId ) ; } int USARTClass::available( void ) { - return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE ; + return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->_iHead - _rx_buffer->_iTail) % SERIAL_BUFFER_SIZE ; } int USARTClass::peek( void ) { - if ( _rx_buffer->head == _rx_buffer->tail ) + if ( _rx_buffer->_iHead == _rx_buffer->_iTail ) { return -1 ; } else { - return _rx_buffer->buffer[_rx_buffer->tail] ; + return _rx_buffer->_aucBuffer[_rx_buffer->_iTail] ; } } int USARTClass::read( void ) { - // if the head isn't ahead of the tail, we don't have any characters - if ( _rx_buffer->head == _rx_buffer->tail ) + // if the _iHead isn't ahead of the _iTail, we don't have any characters + if ( _rx_buffer->_iHead == _rx_buffer->_iTail ) { return -1 ; } else { - unsigned char c = _rx_buffer->buffer[_rx_buffer->tail] ; + unsigned char c = _rx_buffer->_aucBuffer[_rx_buffer->_iTail] ; - _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE ; + _rx_buffer->_iTail = (unsigned int)(_rx_buffer->_iTail + 1) % SERIAL_BUFFER_SIZE ; return c ; } @@ -89,49 +89,50 @@ int USARTClass::read( void ) void USARTClass::flush( void ) { - while ( _tx_buffer->head != _tx_buffer->tail ) + while ( _tx_buffer->_iHead != _tx_buffer->_iTail ) { } } -void USARTClass::write( uint8_t c ) +void USARTClass::write( uint8_t uc ) { - int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE ; + int i = (_tx_buffer->_iHead + 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 ) + while ( i == _tx_buffer->_iTail ) { } - _tx_buffer->buffer[_tx_buffer->head] = c ; - _tx_buffer->head = i ; + _tx_buffer->_aucBuffer[_tx_buffer->_iHead] = uc ; + _tx_buffer->_iHead = i ; /* Wait for the transmitter to be ready */ while ( (_pUsart->US_CSR & US_CSR_TXEMPTY) == 0 ) ; /* Send character */ - _pUsart->US_THR=c ; + _pUsart->US_THR=uc ; } void USARTClass::IrqHandler( void ) { // RX char IT - unsigned char c = _pUsart->US_RHR ; - store_char( c, _rx_buffer ) ; + uint8_t uc = _pUsart->US_RHR ; + + _rx_buffer->store_char( uc ) ; // TX FIFO empty IT - if ( _tx_buffer->head == _tx_buffer->tail ) + if ( _tx_buffer->_iHead == _tx_buffer->_iTail ) { // 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 ; + uc = _tx_buffer->_aucBuffer[_tx_buffer->_iTail] ; + _tx_buffer->_iTail = (_tx_buffer->_iTail + 1) % SERIAL_BUFFER_SIZE ; - _pUsart->US_THR = c ; + _pUsart->US_THR = uc ; } } diff --git a/hardware/sam/cores/sam/USART.h b/hardware/sam/variants/common/USART.h similarity index 60% rename from hardware/sam/cores/sam/USART.h rename to hardware/sam/variants/common/USART.h index 00aecc245..1cd638580 100644 --- a/hardware/sam/cores/sam/USART.h +++ b/hardware/sam/variants/common/USART.h @@ -1,10 +1,10 @@ -#ifndef _USART_ -#define _USART_ +#ifndef _USART_CLASS_ +#define _USART_CLASS_ // USART.cpp need this class to be predefined -class USARTClass ; +//class USARTClass ; -#include "wiring_private.h" +#include "Arduino.h" class USARTClass : public HardwareSerial { @@ -14,7 +14,7 @@ class USARTClass : public HardwareSerial uint32_t _dwId ; public: - USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer ) ; + USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, RingBuffer* pRx_buffer, RingBuffer* pTx_buffer ) ; void begin( const uint32_t dwBaudRate ) ; void end( void ) ; @@ -26,9 +26,9 @@ class USARTClass : public HardwareSerial void IrqHandler( void ) ; - void write( const char *str ) ; - void write( const uint8_t *buffer, size_t size ) ; + virtual void write( const char *str ) ; + virtual void write( const uint8_t *buffer, size_t size ) ; // using Print::write ; // pull in write(str) and write(buf, size) from Print }; -#endif // _USART_ +#endif // _USART_CLASS_ diff --git a/hardware/sam/variants/common/cortex_handlers.cpp b/hardware/sam/variants/common/cortex_handlers.cpp new file mode 100644 index 000000000..f4ddd48c5 --- /dev/null +++ b/hardware/sam/variants/common/cortex_handlers.cpp @@ -0,0 +1,50 @@ +#include "Arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern void NMI_Handler( void ) +{ + for ( ;; ) ; +} + +extern void HardFault_Handler( void ) +{ + for ( ;; ) ; +} + +extern void MemManage_Handler( void ) +{ + for ( ;; ) ; +} + +extern void BusFault_Handler( void ) +{ + for ( ;; ) ; +} + +extern void UsageFault_Handler( void ) +{ + for ( ;; ) ; +} + +extern void SVC_Handler( void ) +{ + for ( ;; ) ; +} + +extern void DebugMon_Handler( void ) +{ + for ( ;; ) ; +} + +extern void PendSV_Handler( void ) +{ + for ( ;; ) ; +} + +#ifdef __cplusplus +} +#endif + diff --git a/hardware/sam/variants/sam3s_ek/build_gcc/Makefile b/hardware/sam/variants/sam3s_ek/build_gcc/Makefile new file mode 100644 index 000000000..329cd5a87 --- /dev/null +++ b/hardware/sam/variants/sam3s_ek/build_gcc/Makefile @@ -0,0 +1,24 @@ +# Makefile for compiling libboard +BOARD = + +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 libvariant_sam3s_ek.mk +# @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_sam3s_ek.mk + +.PHONY: clean +clean: + @echo --- Cleaning sam3s_ek + @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_sam3s_ek.mk $@ +# @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_sam3s_ek.mk $@ + + diff --git a/hardware/sam/variants/sam3s_ek/build_gcc/debug.mk b/hardware/sam/variants/sam3s_ek/build_gcc/debug.mk new file mode 100644 index 000000000..3ab3f8066 --- /dev/null +++ b/hardware/sam/variants/sam3s_ek/build_gcc/debug.mk @@ -0,0 +1,7 @@ +# 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 diff --git a/hardware/sam/variants/sam3s_ek/build_gcc/gcc.mk b/hardware/sam/variants/sam3s_ek/build_gcc/gcc.mk new file mode 100644 index 000000000..a8d97cf5d --- /dev/null +++ b/hardware/sam/variants/sam3s_ek/build_gcc/gcc.mk @@ -0,0 +1,64 @@ + +# Tool suffix when cross-compiling +#CROSS_COMPILE = ../../../../tools/CodeSourcery_arm/bin/arm-none-eabi- +CROSS_COMPILE = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi- + +# Compilation tools +AR = $(CROSS_COMPILE)ar +CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ +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=\\ + +# --------------------------------------------------------------------------------------- +# C 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 + +CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -nostdlib +CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D$(VARIANT) + +# To reduce application size use only integer printf function. +CFLAGS += -Dprintf=iprintf + +# --------------------------------------------------------------------------------------- +# CPP Flags + +CPPFLAGS += -Wall -Wchar-subscripts -Wcomment -Wformat=2 +CPPFLAGS += -Wmain -Wparentheses -Wcast-align -Wunreachable-code +CPPFLAGS += -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused +CPPFLAGS += -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef +CPPFLAGS += -Wshadow -Wpointer-arith -Wwrite-strings +CPPFLAGS += -Wsign-compare -Waggregate-return -Wmissing-declarations +CPPFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations +CPPFLAGS += -Wpacked -Wredundant-decls -Winline -Wlong-long +#CPPFLAGS += -Wmissing-noreturn +#CPPFLAGS += -Wconversion + +CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fno-rtti -fno-exceptions +CPPFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) + +# To reduce application size use only integer printf function. +CPPFLAGS += -Dprintf=iprintf + +# --------------------------------------------------------------------------------------- +# ASM Flags + +ASFLAGS = -mcpu=cortex-m3 -mthumb -Wall -g $(OPTIMIZATION) $(INCLUDES) diff --git a/hardware/sam/variants/sam3s_ek/build_gcc/libvariant_sam3s_ek.mk b/hardware/sam/variants/sam3s_ek/build_gcc/libvariant_sam3s_ek.mk new file mode 100644 index 000000000..684a60cc9 --- /dev/null +++ b/hardware/sam/variants/sam3s_ek/build_gcc/libvariant_sam3s_ek.mk @@ -0,0 +1,156 @@ +# Makefile for compiling libArduino +.SUFFIXES: .o .a .c .s + +CHIP=__SAM3S4C__ +VARIANT=sam3s_ek +LIBNAME=libvariant_$(VARIANT) +TOOLCHAIN=gcc + +#------------------------------------------------------------------------------- +# Path +#------------------------------------------------------------------------------- + +# Output directories +OUTPUT_BIN = ../../../cores/sam + +# Libraries +PROJECT_BASE_PATH = .. +SYSTEM_PATH = ../../../system +CMSIS_PATH = $(SYSTEM_PATH)/CMSIS/Include +ARDUINO_PATH = ../../../cores/sam +VARIANT_BASE_PATH = ../../../variants +VARIANT_PATH = ../../../variants/$(VARIANT) +VARIANT_COMMON_PATH = ../../common + +#------------------------------------------------------------------------------- +# Files +#------------------------------------------------------------------------------- + +vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) $(VARIANT_COMMON_PATH) +#vpath %.c $(PROJECT_BASE_PATH) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) $(VARIANT_COMMON_PATH) + +VPATH+=$(PROJECT_BASE_PATH) + +INCLUDES = +#INCLUDES += -I$(PROJECT_BASE_PATH) +INCLUDES += -I$(ARDUINO_PATH) +INCLUDES += -I$(SYSTEM_PATH) +INCLUDES += -I$(SYSTEM_PATH)/libsam +INCLUDES += -I$(VARIANT_BASE_PATH) +INCLUDES += -I$(VARIANT_PATH) +INCLUDES += -I$(CMSIS_PATH) + +#------------------------------------------------------------------------------- +ifdef DEBUG +include debug.mk +else +include release.mk +endif + +#------------------------------------------------------------------------------- +# Tools +#------------------------------------------------------------------------------- + +include $(TOOLCHAIN).mk + +#------------------------------------------------------------------------------- +ifdef DEBUG +OUTPUT_OBJ=debug +OUTPUT_LIB_POSTFIX=dbg +else +OUTPUT_OBJ=release +OUTPUT_LIB_POSTFIX=rel +endif + +OUTPUT_LIB=$(LIBNAME)_$(TOOLCHAIN)_$(OUTPUT_LIB_POSTFIX).a +OUTPUT_PATH=$(OUTPUT_OBJ)_$(VARIANT) + +#------------------------------------------------------------------------------- +# C source files and objects +#------------------------------------------------------------------------------- +C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c) + +C_OBJ_TEMP = $(patsubst %.c, %.o, $(notdir $(C_SRC))) + +# during development, remove some files +C_OBJ_FILTER=wiring_analog.o wiring_pulse.o + +C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP)) + +#------------------------------------------------------------------------------- +# CPP source files and objects +#------------------------------------------------------------------------------- +CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp) +CPP_SRC+=$(wildcard $(VARIANT_COMMON_PATH)/*.cpp) + +CPP_OBJ_TEMP = $(patsubst %.cpp, %.o, $(notdir $(CPP_SRC))) + +# during development, remove some files +CPP_OBJ_FILTER=Tone.o + +CPP_OBJ=$(filter-out $(CPP_OBJ_FILTER), $(CPP_OBJ_TEMP)) + +#------------------------------------------------------------------------------- +# Assembler source files and objects +#------------------------------------------------------------------------------- +A_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.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: $(VARIANT) + +$(VARIANT): create_output $(OUTPUT_LIB) + +.PHONY: create_output +create_output: + @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) + @echo ------------------------- + @echo *$(INCLUDES) + @echo ------------------------- + @echo *$(C_SRC) + @echo ------------------------- + @echo *$(C_OBJ) + @echo ------------------------- + @echo *$(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) + @echo ------------------------- + @echo *$(CPP_SRC) + @echo ------------------------- + @echo *$(CPP_OBJ) + @echo ------------------------- + @echo *$(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) + @echo ------------------------- + @echo *$(A_SRC) + @echo ------------------------- + + -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + +$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c +# @$(CC) -v -c $(CFLAGS) $< -o $@ + @$(CC) -c $(CFLAGS) $< -o $@ + +$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp +# @$(CC) -c $(CPPFLAGS) $< -o $@ + $(CC) -xc++ -c $(CPPFLAGS) $< -o $@ + +$(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s + @$(AS) -c $(ASFLAGS) $< -o $@ + +$(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) + @$(AR) -v -r "$(OUTPUT_BIN)/$@" $^ + @$(NM) "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt" + + +.PHONY: clean +clean: + @echo --- Cleaning $(VARIANT) files [$(OUTPUT_PATH)$(SEP)*.o] + -@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1 + -@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1 diff --git a/hardware/sam/variants/sam3s_ek/build_gcc/release.mk b/hardware/sam/variants/sam3s_ek/build_gcc/release.mk new file mode 100644 index 000000000..b4e815985 --- /dev/null +++ b/hardware/sam/variants/sam3s_ek/build_gcc/release.mk @@ -0,0 +1,8 @@ + +# 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 diff --git a/hardware/sam/variants/sam3s_ek/build_iar/libvariant_sam3s_ek.ewd b/hardware/sam/variants/sam3s_ek/build_iar/libvariant_sam3s_ek.ewd new file mode 100644 index 000000000..3ca049b67 --- /dev/null +++ b/hardware/sam/variants/sam3s_ek/build_iar/libvariant_sam3s_ek.ewd @@ -0,0 +1,1769 @@ + + + + 2 + + Debug + + ARM + + 1 + + C-SPY + 2 + + 22 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARMSIM_ID + 2 + + 1 + 1 + 1 + + + + + + + + ANGEL_ID + 2 + + 0 + 1 + 1 + + + + + + + + + + + + GDBSERVER_ID + 2 + + 0 + 1 + 1 + + + + + + + + + + + IARROM_ID + 2 + + 1 + 1 + 1 + + + + + + + + + JLINK_ID + 2 + + 13 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LMIFTDI_ID + 2 + + 2 + 1 + 1 + + + + + + + + + + MACRAIGOR_ID + 2 + + 3 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + PEMICRO_ID + 2 + + 0 + 1 + 1 + + + + + + + + + + + + + + + + + RDI_ID + 2 + + 2 + 1 + 1 + + + + + + + + + + + + + + + + STLINK_ID + 2 + + 2 + 1 + 1 + + + + + + + + + + + THIRDPARTY_ID + 2 + + 0 + 1 + 1 + + + + + + + + XDS100_ID + 2 + + 0 + 1 + 1 + + + + + + + $TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\PowerPac\PowerPacRTOS.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB6_Plugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin + 1 + + + + + Release + + ARM + + 0 + + C-SPY + 2 + + 22 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARMSIM_ID + 2 + + 1 + 1 + 0 + + + + + + + + ANGEL_ID + 2 + + 0 + 1 + 0 + + + + + + + + + + + + GDBSERVER_ID + 2 + + 0 + 1 + 0 + + + + + + + + + + + IARROM_ID + 2 + + 1 + 1 + 0 + + + + + + + + + JLINK_ID + 2 + + 13 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LMIFTDI_ID + 2 + + 2 + 1 + 0 + + + + + + + + + + MACRAIGOR_ID + 2 + + 3 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + PEMICRO_ID + 2 + + 0 + 1 + 0 + + + + + + + + + + + + + + + + + RDI_ID + 2 + + 2 + 1 + 0 + + + + + + + + + + + + + + + + STLINK_ID + 2 + + 2 + 1 + 0 + + + + + + + + + + + THIRDPARTY_ID + 2 + + 0 + 1 + 0 + + + + + + + + XDS100_ID + 2 + + 0 + 1 + 0 + + + + + + + $TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\PowerPac\PowerPacRTOS.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB6_Plugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin + 1 + + + + + + diff --git a/hardware/sam/variants/sam3s_ek/build_iar/libvariant_sam3s_ek.ewp b/hardware/sam/variants/sam3s_ek/build_iar/libvariant_sam3s_ek.ewp new file mode 100644 index 000000000..7582210dc --- /dev/null +++ b/hardware/sam/variants/sam3s_ek/build_iar/libvariant_sam3s_ek.ewp @@ -0,0 +1,1824 @@ + + + + 2 + + Debug + + ARM + + 1 + + General + 3 + + 21 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 28 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 8 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 13 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + BILINK + 0 + + + + + Release + + ARM + + 0 + + General + 3 + + 21 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 28 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 13 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + common + + $PROJ_DIR$\..\..\common\cortex_handlers.cpp + + + $PROJ_DIR$\..\..\common\UART.cpp + + + $PROJ_DIR$\..\..\common\UART.h + + + $PROJ_DIR$\..\..\common\USART.cpp + + + $PROJ_DIR$\..\..\common\USART.h + + + + $PROJ_DIR$\..\pins_arduino.h + + + $PROJ_DIR$\..\variant.cpp + + + $PROJ_DIR$\..\variant.h + + + + diff --git a/hardware/sam/variants/sam3s_ek/pins_arduino.h b/hardware/sam/variants/sam3s_ek/pins_arduino.h index f25171cdd..ad7120a37 100644 --- a/hardware/sam/variants/sam3s_ek/pins_arduino.h +++ b/hardware/sam/variants/sam3s_ek/pins_arduino.h @@ -1,33 +1,12 @@ +/* + %atmel_license% +*/ + #ifndef Pins_Arduino_h #define Pins_Arduino_h //#ifdef ARDUINO_MAIN -#define PIN_LED_BLUE (0u) -#define PIN_LED_GREEN (1u) -#define PIN_LED_RED (2u) -#define PIN_LED PIN_LED_BLUE - -#define PIN_DAC0 (u) - -static const uint8_t SS = 34 ; -static const uint8_t MOSI = 32 ; -static const uint8_t MISO = 31 ; -static const uint8_t SCK = 33 ; - -#define PINS_UART (16u) - -#if defined VARIANT_REV_A -# define PIN_TSC_IRQ_WUP_ID (1UL << 3) -#elif defined VARIANT_REV_B -# define PIN_TSC_IRQ_WUP_ID (1UL << 15) -#else -#error "No board revision defined" -#endif - -#define BOARD_LCD_PINS PIN_EBI_DATA_BUS, PIN_EBI_NRD, PIN_EBI_NWE, PIN_EBI_NCS1, PIN_EBI_LCD_RS -#define BOARD_LCD_BASE 0x61000000 /** Define ILI9325 base address. */ -#define BOARD_LCD_RS (1 << 1) /** Define ILI9325 register select signal. */ //#endif // ARDUINO_MAIN diff --git a/hardware/sam/variants/sam3s_ek/variant.cpp b/hardware/sam/variants/sam3s_ek/variant.cpp index cb3753fdc..e3e5ca010 100644 --- a/hardware/sam/variants/sam3s_ek/variant.cpp +++ b/hardware/sam/variants/sam3s_ek/variant.cpp @@ -1,9 +1,13 @@ -#include "Arduino.h" +/* + %atmel_license% +*/ + +#include "variant.h" /* * Pins descriptions */ -extern const PinDescription APinDescription[]= +extern const PinDescription g_APinDescription[]= { // LEDS, 0..2 #if defined VARIANT_REV_A @@ -112,16 +116,15 @@ extern const PinDescription APinDescription[]= { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT } // END } ; -#if 0 /* * UART objects */ -ring_buffer rx_buffer1 = { { 0 }, 0, 0 } ; -ring_buffer tx_buffer1 = { { 0 }, 0, 0 } ; -ring_buffer rx_buffer2 = { { 0 }, 0, 0 } ; -ring_buffer tx_buffer2 = { { 0 }, 0, 0 } ; +RingBuffer rx_buffer1 ; +RingBuffer tx_buffer1 ; +RingBuffer rx_buffer2 ; +RingBuffer tx_buffer2 ; -UARTClass Serial1( UART0, UART0_IRQn, ID_UART0, &rx_buffer1, &tx_buffer1 ) ; +UARTClass Serial( UART0, UART0_IRQn, ID_UART0, &rx_buffer1, &tx_buffer1 ) ; UARTClass Serial2( UART1, UART1_IRQn, ID_UART1, &rx_buffer2, &tx_buffer2 ) ; #ifdef __cplusplus @@ -131,7 +134,7 @@ extern "C" { // IT handlers extern void UART0_IrqHandler( void ) { - Serial1.IrqHandler() ; + Serial.IrqHandler() ; } extern void UART1_IrqHandler( void ) @@ -142,18 +145,15 @@ extern void UART1_IrqHandler( void ) #ifdef __cplusplus } #endif -#endif // 0 // ---------------------------------------------------------------------------- -#if 0 - /* * USART objects */ -ring_buffer rx_buffer3 = { { 0 }, 0, 0 } ; -ring_buffer tx_buffer3 = { { 0 }, 0, 0 } ; -ring_buffer rx_buffer4 = { { 0 }, 0, 0 } ; -ring_buffer tx_buffer4 = { { 0 }, 0, 0 } ; +RingBuffer rx_buffer3 ; +RingBuffer tx_buffer3 ; +RingBuffer rx_buffer4 ; +RingBuffer tx_buffer4 ; USARTClass Serial3( USART0, USART0_IRQn, ID_USART0, &rx_buffer3, &tx_buffer3 ) ; USARTClass Serial4( USART1, USART1_IRQn, ID_USART1, &rx_buffer4, &tx_buffer4 ) ; @@ -177,6 +177,39 @@ extern void USART1_IrqHandler( void ) } #endif -#endif // 0 // ---------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/** + * + */ +extern void init( void ) +{ + SystemInit() ; + + /* Set Systick to 1ms interval, common to all SAM3 variants */ + if ( SysTick_Config( SystemCoreClock / 1000 ) ) + { + /* Capture error */ + while ( 1 ) ; + } + + /* Disable watchdog, common to all SAM variants */ + WDT_Disable( WDT ) ; + + // Initialize Serial port UART0, common to all SAM3 variants + PIO_Configure( g_APinDescription[PINS_UART].pPort, g_APinDescription[PINS_UART].ulPinType, + g_APinDescription[PINS_UART].ulPin, g_APinDescription[PINS_UART].ulPinAttribute ) ; + + // Switch off Power LED + PIO_Configure( g_APinDescription[PIN_LED_RED].pPort, g_APinDescription[PIN_LED_RED].ulPinType, + g_APinDescription[PIN_LED_RED].ulPin, g_APinDescription[PIN_LED_RED].ulPinAttribute ) ; + PIO_Clear( g_APinDescription[PIN_LED_RED].pPort, g_APinDescription[PIN_LED_RED].ulPin ) ; +} +#ifdef __cplusplus +} +#endif + diff --git a/hardware/sam/variants/sam3s_ek/variant.h b/hardware/sam/variants/sam3s_ek/variant.h index 726c4d3f1..ba39bfbef 100644 --- a/hardware/sam/variants/sam3s_ek/variant.h +++ b/hardware/sam/variants/sam3s_ek/variant.h @@ -1,3 +1,7 @@ +/* + %atmel_license% +*/ + #ifndef _VARIANT_ #define _VARIANT_ @@ -5,7 +9,9 @@ * Headers *----------------------------------------------------------------------------*/ -#include "libsam/chip.h" +#include "Arduino.h" +#include "common/UART.h" +#include "common/USART.h" /** * Libc porting layers @@ -27,10 +33,10 @@ /** Name of the board */ #define VARIANT_NAME "SAM3S-EK" -#define VARIANT_REV_A /* -#define VARIANT_REV_B +#define VARIANT_REV_A */ +#define VARIANT_REV_B /** Frequency of the board main oscillator */ #define VARIANT_MAINOSC 12000000 @@ -38,23 +44,49 @@ /** Master clock frequency */ #define VARIANT_MCK 64000000 +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PIN_LED_BLUE (0u) +#define PIN_LED_GREEN (1u) +#define PIN_LED_RED (2u) +#define PIN_LED PIN_LED_BLUE + +#define PIN_DAC0 (u) + +static const uint8_t SS = 34 ; +static const uint8_t MOSI = 32 ; +static const uint8_t MISO = 31 ; +static const uint8_t SCK = 33 ; + +#define PINS_UART (16u) + +#if defined VARIANT_REV_A +# define PIN_TSC_IRQ_WUP_ID (1UL << 3) +#elif defined VARIANT_REV_B +# define PIN_TSC_IRQ_WUP_ID (1UL << 15) +#else +#error "No board revision defined" +#endif + +#define BOARD_LCD_PINS PIN_EBI_DATA_BUS, PIN_EBI_NRD, PIN_EBI_NWE, PIN_EBI_NCS1, PIN_EBI_LCD_RS +#define BOARD_LCD_BASE 0x61000000 /** Define ILI9325 base address. */ +#define BOARD_LCD_RS (1 << 1) /** Define ILI9325 register select signal. */ + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -# ifdef __cplusplus -#if 0 -# include "UART.h" -# include "USART.h" +#ifdef __cplusplus -extern UARTClass Serial1 ; +extern UARTClass Serial ; extern UARTClass Serial2 ; -#endif // 0 -//extern USARTClass Serial3 ; -//extern USARTClass Serial4 ; +extern USARTClass Serial3 ; +extern USARTClass Serial4 ; -# endif +#endif -#endif /* #ifndef _VARIANT_ */ +#endif /* _VARIANT_ */