Skip to content

Commit 7f7637c

Browse files
committed
Fixed delayMicrosecond() when interrupts are disabled
1 parent 74e991c commit 7f7637c

File tree

5 files changed

+30
-32
lines changed

5 files changed

+30
-32
lines changed

build/shared/revisions.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11

22
ARDUINO 1.5.3 BETA
33

4+
[ide]
45
* Removed useless baud rates from serial monitor
56

7+
[arduino core]
8+
* sam: Fixed delayMicrosecond() when interrupts are disabled
9+
610
ARDUINO 1.5.2 BETA - 2013.02.06
711

812
[ide]

hardware/arduino/sam/cores/arduino/Arduino.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ extern "C"{
4141

4242
void yield(void);
4343

44-
#include "wiring.h"
45-
#include "wiring_digital.h"
46-
#include "wiring_analog.h"
47-
#include "wiring_shift.h"
48-
#include "WInterrupts.h"
49-
5044
/* sketch */
5145
extern void setup( void ) ;
5246
extern void loop( void ) ;
@@ -195,6 +189,12 @@ extern const PinDescription g_APinDescription[] ;
195189
// Include board variant
196190
#include "variant.h"
197191

192+
#include "wiring.h"
193+
#include "wiring_digital.h"
194+
#include "wiring_analog.h"
195+
#include "wiring_shift.h"
196+
#include "WInterrupts.h"
197+
198198
// USB Device
199199
#define USB_VID 0x2341 // arduino LLC vid
200200
#define USB_PID_LEONARDO 0x0034

hardware/arduino/sam/cores/arduino/wiring.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ void delay( uint32_t ms )
4949
yield();
5050
}
5151

52-
void delayMicroseconds( uint32_t us )
53-
{
54-
uint32_t start = micros();
55-
while ((micros() - start) < us)
56-
;
57-
}
58-
5952
#if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
6053
extern signed int putchar( signed int c ) ;
6154
/**

hardware/arduino/sam/cores/arduino/wiring.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ extern void delay( uint32_t dwMs ) ;
6262
*
6363
* \param dwUs the number of microseconds to pause (uint32_t)
6464
*/
65-
extern void delayMicroseconds( uint32_t dwUs ) ;
66-
65+
static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
66+
static inline void delayMicroseconds(uint32_t usec){
67+
uint32_t n = usec * (VARIANT_MCK / 3000000);
68+
asm volatile(
69+
"L_%=_delayMicroseconds:" "\n\t"
70+
"subs %0, #1" "\n\t"
71+
"bge L_%=_delayMicroseconds" "\n"
72+
: "+r" (n) :
73+
);
74+
}
6775

6876
#ifdef __cplusplus
6977
}

hardware/arduino/sam/variants/arduino_due_x/variant.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
#ifndef _VARIANT_ARDUINO_DUE_X_
2020
#define _VARIANT_ARDUINO_DUE_X_
2121

22+
/*----------------------------------------------------------------------------
23+
* Definitions
24+
*----------------------------------------------------------------------------*/
25+
26+
/** Frequency of the board main oscillator */
27+
#define VARIANT_MAINOSC 12000000
28+
29+
/** Master clock frequency */
30+
#define VARIANT_MCK 84000000
31+
2232
/*----------------------------------------------------------------------------
2333
* Headers
2434
*----------------------------------------------------------------------------*/
@@ -40,23 +50,6 @@ extern "C"{
4050
# include <syscalls.h> /** RedHat Newlib minimal stub */
4151
#endif
4252

43-
/*----------------------------------------------------------------------------
44-
* Definitions
45-
*----------------------------------------------------------------------------*/
46-
47-
/*----------------------------------------------------------------------------*/
48-
49-
#define ArduinoDueX_DevEd
50-
51-
/** Name of the board */
52-
#define VARIANT_NAME "Arduino_DueX_Dev_Ed"
53-
54-
/** Frequency of the board main oscillator */
55-
#define VARIANT_MAINOSC 12000000
56-
57-
/** Master clock frequency */
58-
#define VARIANT_MCK 84000000
59-
6053
/*----------------------------------------------------------------------------
6154
* Pins
6255
*----------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)