mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-19 09:42:11 +03:00
Merge remote-tracking branch 'arduino/ide-1.5.x' into HEAD
This commit is contained in:
@ -226,7 +226,7 @@ esplora.bootloader.lock_bits=0x2F
|
||||
esplora.build.mcu=atmega32u4
|
||||
esplora.build.f_cpu=16000000L
|
||||
esplora.build.vid=0x2341
|
||||
esplora.build.pid=0x8036
|
||||
esplora.build.pid=0x803c
|
||||
esplora.build.core=arduino
|
||||
esplora.build.variant=leonardo
|
||||
esplora.build.extra_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid}
|
||||
|
@ -41,12 +41,6 @@ extern "C"{
|
||||
|
||||
void yield(void);
|
||||
|
||||
#include "wiring.h"
|
||||
#include "wiring_digital.h"
|
||||
#include "wiring_analog.h"
|
||||
#include "wiring_shift.h"
|
||||
#include "WInterrupts.h"
|
||||
|
||||
/* sketch */
|
||||
extern void setup( void ) ;
|
||||
extern void loop( void ) ;
|
||||
@ -195,6 +189,12 @@ extern const PinDescription g_APinDescription[] ;
|
||||
// Include board variant
|
||||
#include "variant.h"
|
||||
|
||||
#include "wiring.h"
|
||||
#include "wiring_digital.h"
|
||||
#include "wiring_analog.h"
|
||||
#include "wiring_shift.h"
|
||||
#include "WInterrupts.h"
|
||||
|
||||
// USB Device
|
||||
#define USB_VID 0x2341 // arduino LLC vid
|
||||
#define USB_PID_LEONARDO 0x0034
|
||||
|
@ -155,18 +155,39 @@ void Serial_::end(void)
|
||||
|
||||
void Serial_::accept(void)
|
||||
{
|
||||
static uint32_t guard = 0;
|
||||
|
||||
// synchronized access to guard
|
||||
do {
|
||||
if (__LDREXW(&guard) != 0) {
|
||||
__CLREX();
|
||||
return; // busy
|
||||
}
|
||||
} while (__STREXW(1, &guard) != 0); // retry until write succeed
|
||||
|
||||
ring_buffer *buffer = &cdc_rx_buffer;
|
||||
uint32_t c = USBD_Recv(CDC_RX);
|
||||
uint32_t i = (uint32_t)(buffer->head+1) % CDC_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 != buffer->tail) {
|
||||
while (i != buffer->tail) {
|
||||
uint32_t c;
|
||||
if (!USBD_Available(CDC_RX)) {
|
||||
udd_ack_fifocon(CDC_RX);
|
||||
break;
|
||||
}
|
||||
c = USBD_Recv(CDC_RX);
|
||||
// c = UDD_Recv8(CDC_RX & 0xF);
|
||||
buffer->buffer[buffer->head] = c;
|
||||
buffer->head = i;
|
||||
|
||||
i = (i + 1) % CDC_SERIAL_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
// release the guard
|
||||
guard = 0;
|
||||
}
|
||||
|
||||
int Serial_::available(void)
|
||||
@ -202,6 +223,8 @@ int Serial_::read(void)
|
||||
{
|
||||
unsigned char c = buffer->buffer[buffer->tail];
|
||||
buffer->tail = (unsigned int)(buffer->tail + 1) % CDC_SERIAL_BUFFER_SIZE;
|
||||
if (USBD_Available(CDC_RX))
|
||||
accept();
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
@ -601,10 +601,8 @@ static void USB_ISR(void)
|
||||
udd_ack_out_received(CDC_RX);
|
||||
|
||||
// Handle received bytes
|
||||
while (USBD_Available(CDC_RX))
|
||||
if (USBD_Available(CDC_RX))
|
||||
SerialUSB.accept();
|
||||
|
||||
udd_ack_fifocon(CDC_RX);
|
||||
}
|
||||
|
||||
if (Is_udd_sof())
|
||||
|
@ -23,6 +23,7 @@ typedef void (*interruptCB)(void);
|
||||
static interruptCB callbacksPioA[32];
|
||||
static interruptCB callbacksPioB[32];
|
||||
static interruptCB callbacksPioC[32];
|
||||
static interruptCB callbacksPioD[32];
|
||||
|
||||
/* Configure PIO interrupt sources */
|
||||
static void __initialize() {
|
||||
@ -31,6 +32,7 @@ static void __initialize() {
|
||||
callbacksPioA[i] = NULL;
|
||||
callbacksPioB[i] = NULL;
|
||||
callbacksPioC[i] = NULL;
|
||||
callbacksPioD[i] = NULL;
|
||||
}
|
||||
|
||||
pmc_enable_periph_clk(ID_PIOA);
|
||||
@ -50,6 +52,12 @@ static void __initialize() {
|
||||
NVIC_ClearPendingIRQ(PIOC_IRQn);
|
||||
NVIC_SetPriority(PIOC_IRQn, 0);
|
||||
NVIC_EnableIRQ(PIOC_IRQn);
|
||||
|
||||
pmc_enable_periph_clk(ID_PIOD);
|
||||
NVIC_DisableIRQ(PIOD_IRQn);
|
||||
NVIC_ClearPendingIRQ(PIOD_IRQn);
|
||||
NVIC_SetPriority(PIOD_IRQn, 0);
|
||||
NVIC_EnableIRQ(PIOD_IRQn);
|
||||
}
|
||||
|
||||
|
||||
@ -77,6 +85,8 @@ void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode)
|
||||
callbacksPioB[pos] = callback;
|
||||
if (pio == PIOC)
|
||||
callbacksPioC[pos] = callback;
|
||||
if (pio == PIOD)
|
||||
callbacksPioD[pos] = callback;
|
||||
|
||||
// Configure the interrupt mode
|
||||
if (mode == CHANGE) {
|
||||
@ -156,6 +166,17 @@ void PIOC_Handler(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void PIOD_Handler(void) {
|
||||
uint32_t isr = PIOD->PIO_ISR;
|
||||
uint32_t i;
|
||||
for (i=0; i<32; i++, isr>>=1) {
|
||||
if ((isr & 0x1) == 0)
|
||||
continue;
|
||||
if (callbacksPioD[i])
|
||||
callbacksPioD[i]();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -49,13 +49,6 @@ void delay( uint32_t ms )
|
||||
yield();
|
||||
}
|
||||
|
||||
void delayMicroseconds( uint32_t us )
|
||||
{
|
||||
uint32_t start = micros();
|
||||
while ((micros() - start) < us)
|
||||
;
|
||||
}
|
||||
|
||||
#if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
|
||||
extern signed int putchar( signed int c ) ;
|
||||
/**
|
||||
|
@ -62,8 +62,16 @@ extern void delay( uint32_t dwMs ) ;
|
||||
*
|
||||
* \param dwUs the number of microseconds to pause (uint32_t)
|
||||
*/
|
||||
extern void delayMicroseconds( uint32_t dwUs ) ;
|
||||
|
||||
static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
|
||||
static inline void delayMicroseconds(uint32_t usec){
|
||||
uint32_t n = usec * (VARIANT_MCK / 3000000);
|
||||
asm volatile(
|
||||
"L_%=_delayMicroseconds:" "\n\t"
|
||||
"subs %0, #1" "\n\t"
|
||||
"bge L_%=_delayMicroseconds" "\n"
|
||||
: "+r" (n) :
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -19,6 +19,16 @@
|
||||
#ifndef _VARIANT_ARDUINO_DUE_X_
|
||||
#define _VARIANT_ARDUINO_DUE_X_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Frequency of the board main oscillator */
|
||||
#define VARIANT_MAINOSC 12000000
|
||||
|
||||
/** Master clock frequency */
|
||||
#define VARIANT_MCK 84000000
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
@ -40,23 +50,6 @@ extern "C"{
|
||||
# include <syscalls.h> /** RedHat Newlib minimal stub */
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#define ArduinoDueX_DevEd
|
||||
|
||||
/** Name of the board */
|
||||
#define VARIANT_NAME "Arduino_DueX_Dev_Ed"
|
||||
|
||||
/** Frequency of the board main oscillator */
|
||||
#define VARIANT_MAINOSC 12000000
|
||||
|
||||
/** Master clock frequency */
|
||||
#define VARIANT_MCK 84000000
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Pins
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
Reference in New Issue
Block a user