1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-29 18:52:13 +01:00

Fixed delayMicrosecond() when interrupts are disabled

This commit is contained in:
Cristian Maglie 2013-02-13 15:37:13 +01:00
parent 74e991c0db
commit 7f7637c782
5 changed files with 30 additions and 32 deletions

View File

@ -1,8 +1,12 @@
ARDUINO 1.5.3 BETA ARDUINO 1.5.3 BETA
[ide]
* Removed useless baud rates from serial monitor * Removed useless baud rates from serial monitor
[arduino core]
* sam: Fixed delayMicrosecond() when interrupts are disabled
ARDUINO 1.5.2 BETA - 2013.02.06 ARDUINO 1.5.2 BETA - 2013.02.06
[ide] [ide]

View File

@ -41,12 +41,6 @@ extern "C"{
void yield(void); void yield(void);
#include "wiring.h"
#include "wiring_digital.h"
#include "wiring_analog.h"
#include "wiring_shift.h"
#include "WInterrupts.h"
/* sketch */ /* sketch */
extern void setup( void ) ; extern void setup( void ) ;
extern void loop( void ) ; extern void loop( void ) ;
@ -195,6 +189,12 @@ extern const PinDescription g_APinDescription[] ;
// Include board variant // Include board variant
#include "variant.h" #include "variant.h"
#include "wiring.h"
#include "wiring_digital.h"
#include "wiring_analog.h"
#include "wiring_shift.h"
#include "WInterrupts.h"
// USB Device // USB Device
#define USB_VID 0x2341 // arduino LLC vid #define USB_VID 0x2341 // arduino LLC vid
#define USB_PID_LEONARDO 0x0034 #define USB_PID_LEONARDO 0x0034

View File

@ -49,13 +49,6 @@ void delay( uint32_t ms )
yield(); yield();
} }
void delayMicroseconds( uint32_t us )
{
uint32_t start = micros();
while ((micros() - start) < us)
;
}
#if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */ #if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
extern signed int putchar( signed int c ) ; extern signed int putchar( signed int c ) ;
/** /**

View File

@ -62,8 +62,16 @@ extern void delay( uint32_t dwMs ) ;
* *
* \param dwUs the number of microseconds to pause (uint32_t) * \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 #ifdef __cplusplus
} }

View File

@ -19,6 +19,16 @@
#ifndef _VARIANT_ARDUINO_DUE_X_ #ifndef _VARIANT_ARDUINO_DUE_X_
#define _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 * Headers
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -40,23 +50,6 @@ extern "C"{
# include <syscalls.h> /** RedHat Newlib minimal stub */ # include <syscalls.h> /** RedHat Newlib minimal stub */
#endif #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 * Pins
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/