Skip to content

Commit 8fa6bba

Browse files
committed
ATLEDGE-184 SoftwareSerial Library
Port of SoftwareSerial Library for Arduino101 Tx works up to 384000 bps Rx works up to 57600 bps
1 parent 0e09421 commit 8fa6bba

File tree

7 files changed

+725
-0
lines changed

7 files changed

+725
-0
lines changed

cores/arduino/wiring.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,29 @@ void delayMicroseconds(uint32_t dwUs)
9898
while (arcv2_timer0_count_get() - init_count < clocks);
9999
}
100100

101+
static inline __attribute__ ((always_inline))
102+
void delayTicks(uint32_t ticks)
103+
{
104+
// Each tick is 1/32 uS
105+
// TODO: improve using asm
106+
if(ticks == 0)
107+
return;
108+
else if(ticks < 10)
109+
{
110+
// just do a 5 tick delay to be close enough
111+
__builtin_arc_nop();
112+
__builtin_arc_nop();
113+
__builtin_arc_nop();
114+
__builtin_arc_nop();
115+
__builtin_arc_nop();
116+
}
117+
else // compensate for the overhead
118+
{
119+
ticks -= 10;
120+
uint32_t init_count = arcv2_timer0_count_get();
121+
while (arcv2_timer0_count_get() - init_count < ticks);
122+
}
123+
}
101124

102125
#ifdef __cplusplus
103126
}

0 commit comments

Comments
 (0)