mirror of
https://github.com/esp8266/Arduino.git
synced 2025-12-01 17:57:53 +03:00
[sam] daily commit: EWARM project working, GCC compiling but fail due to missing match for Reset_Handler
This commit is contained in:
@@ -1,83 +1,28 @@
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
|
||||
#ifndef Arduino_h
|
||||
#define Arduino_h
|
||||
|
||||
#include <stdint.h>
|
||||
//#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#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 <20>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
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#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 ;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,19 @@
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
|
||||
#ifndef HardwareSerial_h
|
||||
#define HardwareSerial_h
|
||||
|
||||
#include <stdint.h>
|
||||
#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
|
||||
|
||||
29
hardware/sam/cores/sam/RingBuffer.cpp
Normal file
29
hardware/sam/cores/sam/RingBuffer.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
|
||||
#include "RingBuffer.h"
|
||||
#include <string.h>
|
||||
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
|
||||
28
hardware/sam/cores/sam/RingBuffer.h
Normal file
28
hardware/sam/cores/sam/RingBuffer.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
|
||||
#ifndef _RING_BUFFER_
|
||||
#define _RING_BUFFER_
|
||||
|
||||
#include <stdint.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
|
||||
|
||||
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_ */
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef Stream_h
|
||||
#define Stream_h
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include "Print.h"
|
||||
|
||||
class Stream : public Print
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
|
||||
#ifndef _WIRING_TONE_
|
||||
#define _WIRING_TONE_
|
||||
|
||||
|
||||
#endif /* _WIRING_TONE_ */
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "UART.h"
|
||||
|
||||
// Constructors ////////////////////////////////////////////////////////////////
|
||||
|
||||
UARTClass::UARTClass( Uart* pUart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer )
|
||||
{
|
||||
_rx_buffer = pRx_buffer ;
|
||||
_tx_buffer = pTx_buffer ;
|
||||
|
||||
_pUart=pUart ;
|
||||
_dwIrq=dwIrq ;
|
||||
_dwId=dwId ;
|
||||
}
|
||||
|
||||
// Public Methods //////////////////////////////////////////////////////////////
|
||||
|
||||
void UARTClass::begin( const uint32_t dwBaudRate )
|
||||
{
|
||||
/* Configure PMC */
|
||||
PMC_EnablePeripheral( _dwId ) ;
|
||||
|
||||
/* Reset and disable receiver & transmitter */
|
||||
_pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS ;
|
||||
|
||||
/* Configure mode */
|
||||
_pUart->UART_MR = UART_MR_PAR_NO ;
|
||||
|
||||
/* Configure baudrate */
|
||||
/* Asynchronous, no oversampling */
|
||||
_pUart->UART_BRGR = (VARIANT_MCK / dwBaudRate) / 16 ;
|
||||
|
||||
/* Disable PDC channel */
|
||||
_pUart->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS ;
|
||||
|
||||
/* Enable receiver and transmitter */
|
||||
_pUart->UART_CR = UART_CR_RXEN | UART_CR_TXEN ;
|
||||
}
|
||||
|
||||
void UARTClass::end( void )
|
||||
{
|
||||
// wait for transmission of outgoing data
|
||||
while ( _tx_buffer->head != _tx_buffer->tail )
|
||||
{
|
||||
}
|
||||
|
||||
// clear any received data
|
||||
_rx_buffer->head = _rx_buffer->tail ;
|
||||
|
||||
PMC_DisablePeripheral( _dwId ) ;
|
||||
}
|
||||
|
||||
int UARTClass::available( void )
|
||||
{
|
||||
return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE ;
|
||||
}
|
||||
|
||||
int UARTClass::peek( void )
|
||||
{
|
||||
if ( _rx_buffer->head == _rx_buffer->tail )
|
||||
{
|
||||
return -1 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _rx_buffer->buffer[_rx_buffer->tail] ;
|
||||
}
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
return -1 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char c = _rx_buffer->buffer[_rx_buffer->tail] ;
|
||||
|
||||
_rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE ;
|
||||
|
||||
return c ;
|
||||
}
|
||||
}
|
||||
|
||||
void UARTClass::flush( void )
|
||||
{
|
||||
while ( _tx_buffer->head != _tx_buffer->tail )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void UARTClass::write( const uint8_t c )
|
||||
{
|
||||
int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE ;
|
||||
|
||||
// If the output buffer is full, there's nothing for it other than to
|
||||
// wait for the interrupt handler to empty it a bit
|
||||
while ( i == _tx_buffer->tail )
|
||||
{
|
||||
}
|
||||
|
||||
_tx_buffer->buffer[_tx_buffer->head] = c ;
|
||||
_tx_buffer->head = i ;
|
||||
|
||||
/* Wait for the transmitter to be ready */
|
||||
while ( (_pUart->UART_SR & UART_SR_TXEMPTY) == 0 ) ;
|
||||
|
||||
/* Send character */
|
||||
_pUart->UART_THR=c ;
|
||||
}
|
||||
|
||||
void UARTClass::IrqHandler( void )
|
||||
{
|
||||
// RX char IT
|
||||
unsigned char c = _pUart->UART_RHR ;
|
||||
store_char( c, _rx_buffer ) ;
|
||||
|
||||
// TX FIFO empty IT
|
||||
if ( _tx_buffer->head == _tx_buffer->tail )
|
||||
{
|
||||
// Buffer empty, so disable interrupts
|
||||
}
|
||||
else
|
||||
{
|
||||
// There is more data in the output buffer. Send the next byte
|
||||
c = _tx_buffer->buffer[_tx_buffer->tail] ;
|
||||
_tx_buffer->tail = (_tx_buffer->tail + 1) % SERIAL_BUFFER_SIZE ;
|
||||
|
||||
_pUart->UART_THR = c ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef _UART_
|
||||
#define _UART_
|
||||
|
||||
// UART.cpp need this class to be predefined
|
||||
class UARTClass ;
|
||||
|
||||
#include "wiring_private.h"
|
||||
|
||||
class UARTClass : public HardwareSerial
|
||||
{
|
||||
protected:
|
||||
Uart* _pUart ;
|
||||
IRQn_Type _dwIrq ;
|
||||
uint32_t _dwId ;
|
||||
|
||||
public:
|
||||
UARTClass( Uart* pUart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer ) ;
|
||||
|
||||
void begin( const uint32_t dwBaudRate ) ;
|
||||
void end( void ) ;
|
||||
int available( void ) ;
|
||||
int peek( void ) ;
|
||||
int read( void ) ;
|
||||
void flush( void ) ;
|
||||
void write( const uint8_t c ) ;
|
||||
|
||||
void IrqHandler( void ) ;
|
||||
|
||||
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 // _UART_
|
||||
@@ -1,137 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "USART.h"
|
||||
|
||||
// Constructors ////////////////////////////////////////////////////////////////
|
||||
|
||||
USARTClass::USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer )
|
||||
{
|
||||
_rx_buffer = pRx_buffer ;
|
||||
_tx_buffer = pTx_buffer ;
|
||||
|
||||
_pUsart=pUsart ;
|
||||
_dwIrq=dwIrq ;
|
||||
_dwId=dwId ;
|
||||
}
|
||||
|
||||
// Public Methods //////////////////////////////////////////////////////////////
|
||||
|
||||
void USARTClass::begin( const uint32_t dwBaudRate )
|
||||
{
|
||||
/* Configure PMC */
|
||||
PMC_EnablePeripheral( _dwId ) ;
|
||||
|
||||
/* Reset and disable receiver & transmitter */
|
||||
_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 |
|
||||
US_MR_NBSTOP_1_BIT | US_MR_CHMODE_NORMAL;
|
||||
|
||||
/* Configure baudrate */
|
||||
/* Asynchronous, no oversampling */
|
||||
_pUsart->US_BRGR = (VARIANT_MCK / dwBaudRate) / 16 ;
|
||||
|
||||
/* Disable PDC channel */
|
||||
_pUsart->US_PTCR = US_PTCR_RXTDIS | US_PTCR_TXTDIS ;
|
||||
|
||||
/* Enable receiver and transmitter */
|
||||
_pUsart->US_CR = US_CR_RXEN | US_CR_TXEN ;
|
||||
}
|
||||
|
||||
void USARTClass::end()
|
||||
{
|
||||
// wait for transmission of outgoing data
|
||||
while ( _tx_buffer->head != _tx_buffer->tail )
|
||||
{
|
||||
}
|
||||
|
||||
// clear any received data
|
||||
_rx_buffer->head = _rx_buffer->tail ;
|
||||
|
||||
PMC_DisablePeripheral( _dwId ) ;
|
||||
}
|
||||
|
||||
int USARTClass::available( void )
|
||||
{
|
||||
return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE ;
|
||||
}
|
||||
|
||||
int USARTClass::peek( void )
|
||||
{
|
||||
if ( _rx_buffer->head == _rx_buffer->tail )
|
||||
{
|
||||
return -1 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _rx_buffer->buffer[_rx_buffer->tail] ;
|
||||
}
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
return -1 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char c = _rx_buffer->buffer[_rx_buffer->tail] ;
|
||||
|
||||
_rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE ;
|
||||
|
||||
return c ;
|
||||
}
|
||||
}
|
||||
|
||||
void USARTClass::flush( void )
|
||||
{
|
||||
while ( _tx_buffer->head != _tx_buffer->tail )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void USARTClass::write( uint8_t c )
|
||||
{
|
||||
int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE ;
|
||||
|
||||
// If the output buffer is full, there's nothing for it other than to
|
||||
// wait for the interrupt handler to empty it a bit
|
||||
while ( i == _tx_buffer->tail )
|
||||
{
|
||||
}
|
||||
|
||||
_tx_buffer->buffer[_tx_buffer->head] = c ;
|
||||
_tx_buffer->head = i ;
|
||||
|
||||
/* Wait for the transmitter to be ready */
|
||||
while ( (_pUsart->US_CSR & US_CSR_TXEMPTY) == 0 ) ;
|
||||
|
||||
/* Send character */
|
||||
_pUsart->US_THR=c ;
|
||||
}
|
||||
|
||||
void USARTClass::IrqHandler( void )
|
||||
{
|
||||
// RX char IT
|
||||
unsigned char c = _pUsart->US_RHR ;
|
||||
store_char( c, _rx_buffer ) ;
|
||||
|
||||
// TX FIFO empty IT
|
||||
if ( _tx_buffer->head == _tx_buffer->tail )
|
||||
{
|
||||
// Buffer empty, so disable interrupts
|
||||
}
|
||||
else
|
||||
{
|
||||
// There is more data in the output buffer. Send the next byte
|
||||
c = _tx_buffer->buffer[_tx_buffer->tail] ;
|
||||
_tx_buffer->tail = (_tx_buffer->tail + 1) % SERIAL_BUFFER_SIZE ;
|
||||
|
||||
_pUsart->US_THR = c ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef _USART_
|
||||
#define _USART_
|
||||
|
||||
// USART.cpp need this class to be predefined
|
||||
class USARTClass ;
|
||||
|
||||
#include "wiring_private.h"
|
||||
|
||||
class USARTClass : public HardwareSerial
|
||||
{
|
||||
protected:
|
||||
Usart* _pUsart ;
|
||||
IRQn_Type _dwIrq ;
|
||||
uint32_t _dwId ;
|
||||
|
||||
public:
|
||||
USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, ring_buffer* pRx_buffer, ring_buffer *pTx_buffer ) ;
|
||||
|
||||
void begin( const uint32_t dwBaudRate ) ;
|
||||
void end( void ) ;
|
||||
int available( void ) ;
|
||||
int peek( void ) ;
|
||||
int read( void ) ;
|
||||
void flush( void ) ;
|
||||
void write( const uint8_t c ) ;
|
||||
|
||||
void IrqHandler( void ) ;
|
||||
|
||||
void write( const char *str ) ;
|
||||
void write( const uint8_t *buffer, size_t size ) ;
|
||||
// using Print::write ; // pull in write(str) and write(buf, size) from Print
|
||||
};
|
||||
|
||||
#endif // _USART_
|
||||
@@ -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 ;
|
||||
}
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
@@ -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 $@
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -30,7 +30,8 @@ vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH)
|
||||
|
||||
VPATH+=$(PROJECT_BASE_PATH)
|
||||
|
||||
INCLUDES = -I$(PROJECT_BASE_PATH)
|
||||
INCLUDES =
|
||||
INCLUDES += -I$(PROJECT_BASE_PATH)
|
||||
INCLUDES += -I$(SYSTEM_PATH)
|
||||
INCLUDES += -I$(SYSTEM_PATH)/libsam
|
||||
INCLUDES += -I$(VARIANT_PATH)
|
||||
@@ -134,16 +135,12 @@ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c
|
||||
|
||||
$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp
|
||||
# @$(CC) -c $(CPPFLAGS) $< -o $@
|
||||
$(CC) -xc++ -c $(CPPFLAGS) $< -o $@
|
||||
|
||||
$(OUTPUT_PATH)/variant.o: $(VARIANT_PATH)/variant.cpp
|
||||
# @$(CC) -c $(CPPFLAGS) $< -o $@
|
||||
@$(CXX) -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)) $(OUTPUT_PATH)/variant.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"
|
||||
|
||||
@@ -257,7 +257,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>CCRequirePrototypes</name>
|
||||
<state>0</state>
|
||||
<state>1</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCMultibyteSupport</name>
|
||||
@@ -887,7 +887,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>IarchiveOutput</name>
|
||||
<state>S:\projets\Arduino_project\github\arduino_arm_git\hardware\sam\cores\sam\build_iar\Debug\Exe\libarduino_sam3s_ek_ewarm_dbg.a</state>
|
||||
<state>$PROJ_DIR$\..\libarduino_sam3s_ek_ewarm_dbg.a</state>
|
||||
</option>
|
||||
</data>
|
||||
</settings>
|
||||
@@ -2692,9 +2692,6 @@
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\binary.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\HardwareSerial.cpp</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\HardwareSerial.h</name>
|
||||
</file>
|
||||
@@ -2713,6 +2710,12 @@
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\Print.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\RingBuffer.cpp</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\RingBuffer.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\Stream.h</name>
|
||||
</file>
|
||||
@@ -2735,22 +2738,7 @@
|
||||
</excluded>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\UART.cpp</name>
|
||||
<excluded>
|
||||
<configuration>Debug</configuration>
|
||||
</excluded>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\UART.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\USART.cpp</name>
|
||||
<excluded>
|
||||
<configuration>Debug</configuration>
|
||||
</excluded>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\USART.h</name>
|
||||
<name>$PROJ_DIR$\..\Tone.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\WCharacter.h</name>
|
||||
@@ -2776,6 +2764,9 @@
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\wiring_analog.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\wiring_constants.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\wiring_digital.c</name>
|
||||
</file>
|
||||
|
||||
@@ -11,9 +11,9 @@ int main( void )
|
||||
setup() ;
|
||||
|
||||
for ( ; ; )
|
||||
{
|
||||
{
|
||||
loop() ;
|
||||
}
|
||||
}
|
||||
|
||||
// return 0 ;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "variant.h"
|
||||
#include "syscalls.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -294,6 +294,7 @@
|
||||
<option>
|
||||
<name>CCIncludePath2</name>
|
||||
<state>$PROJ_DIR$\..\..</state>
|
||||
<state>$PROJ_DIR$\..\..\..\..\variants</state>
|
||||
<state>$PROJ_DIR$\..\..\..\..\variants\sam3s_ek</state>
|
||||
<state>$PROJ_DIR$\..\..\..\..\system</state>
|
||||
</option>
|
||||
@@ -1816,26 +1817,14 @@
|
||||
<name>sam3u_ek</name>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<name>variants</name>
|
||||
<group>
|
||||
<name>sam3s_ek</name>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\..\..\variants\sam3s_ek\pins_arduino.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\..\..\variants\sam3s_ek\variant.cpp</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\..\..\variants\sam3s_ek\variant.h</name>
|
||||
</file>
|
||||
</group>
|
||||
</group>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\build_iar\Debug\Exe\libarduino_sam3s_ek_ewarm_dbg.a</name>
|
||||
<name>$PROJ_DIR$\..\..\libarduino_sam3s_ek_ewarm_dbg.a</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\..\..\system\libsam\build_iar\Debug\Exe\libsam_sam3s4c_ewarm_dbg.a</name>
|
||||
<name>$PROJ_DIR$\..\..\libsam_sam3s4c_ewarm_dbg.a</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\libvariant_sam3s_ek_ewarm_dbg.a</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\test.cpp</name>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 ) ;
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
|
||||
#ifndef _WIRING_ANALOG_
|
||||
#define _WIRING_ANALOG_
|
||||
|
||||
|
||||
78
hardware/sam/cores/sam/wiring_constants.h
Normal file
78
hardware/sam/cores/sam/wiring_constants.h
Normal file
@@ -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_ */
|
||||
@@ -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 ;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
typedef void (*voidFuncPtr)( void ) ;
|
||||
|
||||
/* Define attribute */
|
||||
#if defined ( __CC_ARM ) /* Keil <20>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
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
|
||||
#ifndef _WIRING_PULSE_
|
||||
#define _WIRING_PULSE_
|
||||
|
||||
|
||||
@@ -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"{
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
|
||||
#ifndef _WIRING_SHIFT_
|
||||
#define _WIRING_SHIFT_
|
||||
|
||||
|
||||
Reference in New Issue
Block a user