Skip to content

Commit 8160a78

Browse files
authored
Merge pull request #28 from sparkfun/timeRename
Rename seconds() to secs() to avoid collisions with sketch variables
2 parents bc639cd + d966f8a commit 8160a78

File tree

2 files changed

+34
-26
lines changed

2 files changed

+34
-26
lines changed

cores/arduino/ard_sup/ap3_timing.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ SOFTWARE.
2424

2525
#include "Arduino.h"
2626

27-
#define AP3_STIMER_FREQ_HZ (3000000)
28-
#define AP3_STIMER_FREQ_KHZ (AP3_STIMER_FREQ_HZ/1000)
29-
#define AP3_STIMER_FREQ_MHZ (AP3_STIMER_FREQ_HZ/1000000)
27+
#define AP3_STIMER_FREQ_HZ (3000000)
28+
#define AP3_STIMER_FREQ_KHZ (AP3_STIMER_FREQ_HZ / 1000)
29+
#define AP3_STIMER_FREQ_MHZ (AP3_STIMER_FREQ_HZ / 1000000)
3030

31-
unsigned long micros( void );
32-
unsigned long millis( void );
33-
unsigned long seconds( void );
34-
unsigned long systicks( void );
35-
unsigned long sysoverflows( void );
31+
unsigned long micros(void);
32+
unsigned long millis(void);
33+
unsigned long secs(void);
34+
unsigned long systicks(void);
35+
unsigned long sysoverflows(void);
3636
void delay(uint32_t ms);
3737
void delayMicroseconds(uint32_t us);
3838

cores/arduino/ard_sup/timing/ap3_timing.cpp

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,56 @@ SOFTWARE.
2424
volatile uint32_t ap3_stimer_overflows = 0x00;
2525
uint64_t ticks = 0;
2626

27-
void _fill_ticks( void ){
27+
void _fill_ticks(void)
28+
{
2829
ticks = ap3_stimer_overflows;
2930
ticks <<= 32;
3031
ticks |= (am_hal_stimer_counter_get() & 0xFFFFFFFF);
3132
}
3233

33-
unsigned long micros( void ){
34+
unsigned long micros(void)
35+
{
3436
_fill_ticks();
35-
return (uint32_t)(ticks/AP3_STIMER_FREQ_MHZ);
37+
return (uint32_t)(ticks / AP3_STIMER_FREQ_MHZ);
3638
}
3739

38-
unsigned long millis( void ){
40+
unsigned long millis(void)
41+
{
3942
_fill_ticks();
40-
return (uint32_t)(ticks/AP3_STIMER_FREQ_KHZ);
43+
return (uint32_t)(ticks / AP3_STIMER_FREQ_KHZ);
4144
}
4245

43-
unsigned long seconds( void ){
46+
unsigned long secs(void)
47+
{
4448
_fill_ticks();
45-
return (uint32_t)(ticks/AP3_STIMER_FREQ_HZ);
49+
return (uint32_t)(ticks / AP3_STIMER_FREQ_HZ);
4650
}
4751

48-
unsigned long systicks( void ){
52+
unsigned long systicks(void)
53+
{
4954
return am_hal_stimer_counter_get();
5055
}
5156

52-
unsigned long sysoverflows( void ){
57+
unsigned long sysoverflows(void)
58+
{
5359
return ap3_stimer_overflows;
5460
}
5561

56-
void delay(uint32_t ms){
62+
void delay(uint32_t ms)
63+
{
5764
am_util_delay_ms(ms);
5865
}
5966

60-
void delayMicroseconds(uint32_t us){
67+
void delayMicroseconds(uint32_t us)
68+
{
6169
am_util_delay_us(us);
6270
}
6371

64-
extern "C" void am_stimer_isr(void){
65-
am_hal_stimer_int_clear(AM_HAL_STIMER_INT_OVERFLOW);
66-
ap3_stimer_overflows += 1;
67-
// At the fastest rate (3MHz) the 64 bits of the stimer
68-
// along with this overflow counter can keep track of
69-
// the time for ~ 195,000 years without wrapping to 0
72+
extern "C" void am_stimer_isr(void)
73+
{
74+
am_hal_stimer_int_clear(AM_HAL_STIMER_INT_OVERFLOW);
75+
ap3_stimer_overflows += 1;
76+
// At the fastest rate (3MHz) the 64 bits of the stimer
77+
// along with this overflow counter can keep track of
78+
// the time for ~ 195,000 years without wrapping to 0
7079
}
71-

0 commit comments

Comments
 (0)