Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit f9ee49b

Browse files
authored
v1.2.0
### Releases v1.2.0 1. Add better debug feature. 2. Optimize code and examples to reduce RAM usage 3. Add Table of Contents
1 parent d988189 commit f9ee49b

File tree

4 files changed

+34
-25
lines changed

4 files changed

+34
-25
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ Before using any Timer, you have to make sure the Timer has not been used by any
346346

347347
### 1. Using only Hardware Timer directly
348348

349-
#### 1.1 Init Hardware Timer
349+
### 1.1 Init Hardware Timer
350350

351351
```
352352
// You can select Teensy Hardware Timer from TEENSY_TIMER_1 or TEENSY_TIMER_3
@@ -355,7 +355,7 @@ Before using any Timer, you have to make sure the Timer has not been used by any
355355
TeensyTimer ITimer0(TEENSY_TIMER_1);
356356
```
357357

358-
#### 1.2 Set Hardware Timer Interval and attach Timer Interrupt Handler function
358+
### 1.2 Set Hardware Timer Interval and attach Timer Interrupt Handler function
359359

360360
Use one of these functions with **interval in unsigned long milliseconds**
361361

@@ -438,7 +438,7 @@ void setup()
438438

439439
The 16 ISR_based Timers, designed for long timer intervals, only support using **unsigned long millisec intervals**. If you have to use much higher frequency or sub-millisecond interval, you have to use the Hardware Timers directly as in [1.3 Set Hardware Timer Frequency and attach Timer Interrupt Handler function](#13-set-hardware-timer-frequency-and-attach-timer-interrupt-handler-function)
440440

441-
#### 2.2 Init Hardware Timer and ISR-based Timer
441+
### 2.2 Init Hardware Timer and ISR-based Timer
442442

443443
```
444444
// You can select Teensy Hardware Timer from TEENSY_TIMER_1 or TEENSY_TIMER_3
@@ -451,7 +451,7 @@ TeensyTimer ITimer(TEENSY_TIMER_1);
451451
Teensy_ISR_Timer ISR_Timer;
452452
```
453453

454-
#### 2.3 Set Hardware Timer Interval and attach Timer Interrupt Handler functions
454+
### 2.3 Set Hardware Timer Interval and attach Timer Interrupt Handler functions
455455

456456
```
457457
void TimerHandler(void)

src/TeensyTimerInterrupt.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131

3232
#pragma once
3333

34+
#ifndef TEENSYTIMERINTERRUPT_H
35+
#define TEENSYTIMERINTERRUPT_H
36+
3437
#if !( defined(CORE_TEENSY) || defined(TEENSYDUINO) )
3538
#error This code is designed to run on Teensy platform! Please check your Tools->Board setting.
3639
#endif
@@ -116,7 +119,7 @@ class TeensyTimerInterrupt
116119
}
117120

118121
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
119-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
122+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
120123
bool setFrequency(float frequency, timerCallback callback) __attribute__((always_inline))
121124
{
122125
return setInterval((float) (1000000.0f / frequency), callback);
@@ -232,7 +235,7 @@ class TeensyTimerInterrupt
232235
}
233236

234237
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
235-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
238+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
236239
bool attachInterruptInterval(unsigned long interval, timerCallback callback) __attribute__((always_inline))
237240
{
238241
return setInterval(interval, callback);
@@ -457,7 +460,7 @@ class TeensyTimerInterrupt
457460
}
458461

459462
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
460-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
463+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
461464
bool setFrequency(float frequency, timerCallback callback) __attribute__((always_inline))
462465
{
463466
return setInterval((float) (1000000.0f / frequency), callback);
@@ -601,7 +604,7 @@ class TeensyTimerInterrupt
601604
}
602605

603606
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
604-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
607+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
605608
bool attachInterruptInterval(unsigned long interval, timerCallback callback) __attribute__((always_inline))
606609
{
607610
return setInterval(interval, callback);
@@ -828,7 +831,7 @@ class TeensyTimerInterrupt
828831
}
829832

830833
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
831-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
834+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
832835
bool setFrequency(float frequency, timerCallback callback) __attribute__((always_inline))
833836
{
834837
return setInterval((float) (1000000.0f / frequency), callback);
@@ -962,7 +965,7 @@ class TeensyTimerInterrupt
962965
}
963966

964967
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
965-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
968+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
966969
bool attachInterruptInterval(unsigned long interval, timerCallback callback) __attribute__((always_inline))
967970
{
968971
return setInterval(interval, callback);
@@ -1098,4 +1101,4 @@ ISR(TIMER3_OVF_vect)
10981101

10991102
////////////////////////////////////////////////////////////////////////////////
11001103

1101-
1104+
#endif // TEENSYTIMERINTERRUPT_H

src_cpp/TeensyTimerInterrupt.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131

3232
#pragma once
3333

34+
#ifndef TEENSYTIMERINTERRUPT_H
35+
#define TEENSYTIMERINTERRUPT_H
36+
3437
#if !( defined(CORE_TEENSY) || defined(TEENSYDUINO) )
3538
#error This code is designed to run on Teensy platform! Please check your Tools->Board setting.
3639
#endif
@@ -116,7 +119,7 @@ class TeensyTimerInterrupt
116119
}
117120

118121
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
119-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
122+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
120123
bool setFrequency(float frequency, timerCallback callback) __attribute__((always_inline))
121124
{
122125
return setInterval((float) (1000000.0f / frequency), callback);
@@ -232,7 +235,7 @@ class TeensyTimerInterrupt
232235
}
233236

234237
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
235-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
238+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
236239
bool attachInterruptInterval(unsigned long interval, timerCallback callback) __attribute__((always_inline))
237240
{
238241
return setInterval(interval, callback);
@@ -457,7 +460,7 @@ class TeensyTimerInterrupt
457460
}
458461

459462
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
460-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
463+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
461464
bool setFrequency(float frequency, timerCallback callback) __attribute__((always_inline))
462465
{
463466
return setInterval((float) (1000000.0f / frequency), callback);
@@ -601,7 +604,7 @@ class TeensyTimerInterrupt
601604
}
602605

603606
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
604-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
607+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
605608
bool attachInterruptInterval(unsigned long interval, timerCallback callback) __attribute__((always_inline))
606609
{
607610
return setInterval(interval, callback);
@@ -828,7 +831,7 @@ class TeensyTimerInterrupt
828831
}
829832

830833
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
831-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
834+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
832835
bool setFrequency(float frequency, timerCallback callback) __attribute__((always_inline))
833836
{
834837
return setInterval((float) (1000000.0f / frequency), callback);
@@ -962,7 +965,7 @@ class TeensyTimerInterrupt
962965
}
963966

964967
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
965-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
968+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
966969
bool attachInterruptInterval(unsigned long interval, timerCallback callback) __attribute__((always_inline))
967970
{
968971
return setInterval(interval, callback);
@@ -1098,4 +1101,4 @@ ISR(TIMER3_OVF_vect)
10981101

10991102
////////////////////////////////////////////////////////////////////////////////
11001103

1101-
1104+
#endif // TEENSYTIMERINTERRUPT_H

src_h/TeensyTimerInterrupt.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131

3232
#pragma once
3333

34+
#ifndef TEENSYTIMERINTERRUPT_H
35+
#define TEENSYTIMERINTERRUPT_H
36+
3437
#if !( defined(CORE_TEENSY) || defined(TEENSYDUINO) )
3538
#error This code is designed to run on Teensy platform! Please check your Tools->Board setting.
3639
#endif
@@ -116,7 +119,7 @@ class TeensyTimerInterrupt
116119
}
117120

118121
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
119-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
122+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
120123
bool setFrequency(float frequency, timerCallback callback) __attribute__((always_inline))
121124
{
122125
return setInterval((float) (1000000.0f / frequency), callback);
@@ -232,7 +235,7 @@ class TeensyTimerInterrupt
232235
}
233236

234237
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
235-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
238+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
236239
bool attachInterruptInterval(unsigned long interval, timerCallback callback) __attribute__((always_inline))
237240
{
238241
return setInterval(interval, callback);
@@ -457,7 +460,7 @@ class TeensyTimerInterrupt
457460
}
458461

459462
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
460-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
463+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
461464
bool setFrequency(float frequency, timerCallback callback) __attribute__((always_inline))
462465
{
463466
return setInterval((float) (1000000.0f / frequency), callback);
@@ -601,7 +604,7 @@ class TeensyTimerInterrupt
601604
}
602605

603606
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
604-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
607+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
605608
bool attachInterruptInterval(unsigned long interval, timerCallback callback) __attribute__((always_inline))
606609
{
607610
return setInterval(interval, callback);
@@ -828,7 +831,7 @@ class TeensyTimerInterrupt
828831
}
829832

830833
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
831-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
834+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
832835
bool setFrequency(float frequency, timerCallback callback) __attribute__((always_inline))
833836
{
834837
return setInterval((float) (1000000.0f / frequency), callback);
@@ -962,7 +965,7 @@ class TeensyTimerInterrupt
962965
}
963966

964967
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
965-
// No params and duration now. To be addes in the future by adding similar functions here or to NRF52-hal-timer.c
968+
// No params and duration now. To be added in the future by adding similar functions here or to NRF52-hal-timer.c
966969
bool attachInterruptInterval(unsigned long interval, timerCallback callback) __attribute__((always_inline))
967970
{
968971
return setInterval(interval, callback);
@@ -1098,4 +1101,4 @@ ISR(TIMER3_OVF_vect)
10981101

10991102
////////////////////////////////////////////////////////////////////////////////
11001103

1101-
1104+
#endif // TEENSYTIMERINTERRUPT_H

0 commit comments

Comments
 (0)