Make HAL ISR macros function-like

This commit is contained in:
Scott Lahteine 2019-03-10 20:43:59 -05:00
parent e3ce346f24
commit 1f7e220387
15 changed files with 31 additions and 32 deletions

View file

@ -197,7 +197,7 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t freque
#define HAL_timer_isr_epilogue(TIMER_NUM)
/* 18 cycles maximum latency */
#define HAL_STEP_TIMER_ISR \
#define HAL_STEP_TIMER_ISR() \
extern "C" void TIMER1_COMPA_vect (void) __attribute__ ((signal, naked, used, externally_visible)); \
extern "C" void TIMER1_COMPA_vect_bottom (void) asm ("TIMER1_COMPA_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \
void TIMER1_COMPA_vect (void) { \
@ -270,7 +270,7 @@ void TIMER1_COMPA_vect (void) { \
void TIMER1_COMPA_vect_bottom(void)
/* 14 cycles maximum latency */
#define HAL_TEMP_TIMER_ISR \
#define HAL_TEMP_TIMER_ISR() \
extern "C" void TIMER0_COMPB_vect (void) __attribute__ ((signal, naked, used, externally_visible)); \
extern "C" void TIMER0_COMPB_vect_bottom(void) asm ("TIMER0_COMPB_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \
void TIMER0_COMPB_vect (void) { \

View file

@ -65,9 +65,9 @@ typedef uint32_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define HAL_STEP_TIMER_ISR void TC3_Handler()
#define HAL_TEMP_TIMER_ISR void TC4_Handler()
#define HAL_TONE_TIMER_ISR void TC6_Handler()
#define HAL_STEP_TIMER_ISR() void TC3_Handler()
#define HAL_TEMP_TIMER_ISR() void TC4_Handler()
#define HAL_TONE_TIMER_ISR() void TC6_Handler()
// --------------------------------------------------------------------------
// Types

View file

@ -45,7 +45,7 @@ void noTone(const pin_t _pin) {
extDigitalWrite(_pin, LOW);
}
HAL_TONE_TIMER_ISR {
HAL_TONE_TIMER_ISR() {
static uint8_t pin_state = 0;
HAL_timer_isr_prologue(TONE_TIMER_NUM);

View file

@ -69,8 +69,8 @@ typedef uint64_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define HAL_TEMP_TIMER_ISR extern "C" void tempTC_Handler(void)
#define HAL_STEP_TIMER_ISR extern "C" void stepTC_Handler(void)
#define HAL_TEMP_TIMER_ISR() extern "C" void tempTC_Handler(void)
#define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler(void)
extern "C" void tempTC_Handler(void);
extern "C" void stepTC_Handler(void);

View file

@ -32,8 +32,8 @@
* This has many limitations and is not fit for the purpose
*/
HAL_STEP_TIMER_ISR;
HAL_TEMP_TIMER_ISR;
HAL_STEP_TIMER_ISR();
HAL_TEMP_TIMER_ISR();
Timer timers[2];

View file

@ -63,12 +63,12 @@ typedef uint32_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define HAL_STEP_TIMER_ISR extern "C" void TIMER0_IRQHandler(void)
#define HAL_TEMP_TIMER_ISR extern "C" void TIMER1_IRQHandler(void)
#define HAL_STEP_TIMER_ISR() extern "C" void TIMER0_IRQHandler(void)
#define HAL_TEMP_TIMER_ISR() extern "C" void TIMER1_IRQHandler(void)
// PWM timer
#define HAL_PWM_TIMER
#define HAL_PWM_TIMER_ISR extern "C" void TIMER3_IRQHandler(void)
#define HAL_PWM_TIMER_ISR() extern "C" void TIMER3_IRQHandler(void)
#define HAL_PWM_TIMER_IRQn

View file

@ -88,8 +88,8 @@ typedef uint32_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define HAL_STEP_TIMER_ISR _HAL_TIMER_ISR(STEP_TIMER_NUM)
#define HAL_TEMP_TIMER_ISR _HAL_TIMER_ISR(TEMP_TIMER_NUM)
#define HAL_STEP_TIMER_ISR() _HAL_TIMER_ISR(STEP_TIMER_NUM)
#define HAL_TEMP_TIMER_ISR() _HAL_TIMER_ISR(TEMP_TIMER_NUM)
// Timer references by index
#define STEP_TIMER _HAL_TIMER(STEP_TIMER_NUM)

View file

@ -137,8 +137,8 @@
extern void Step_Handler(stimer_t *htim);
extern void Temp_Handler(stimer_t *htim);
#define HAL_STEP_TIMER_ISR void Step_Handler(stimer_t *htim)
#define HAL_TEMP_TIMER_ISR void Temp_Handler(stimer_t *htim)
#define HAL_STEP_TIMER_ISR() void Step_Handler(stimer_t *htim)
#define HAL_TEMP_TIMER_ISR() void Temp_Handler(stimer_t *htim)
// --------------------------------------------------------------------------
// Types

View file

@ -85,9 +85,8 @@ timer_dev* get_timer_dev(int number);
// TODO change this
#define HAL_TEMP_TIMER_ISR extern "C" void tempTC_Handler(void)
#define HAL_STEP_TIMER_ISR extern "C" void stepTC_Handler(void)
#define HAL_TEMP_TIMER_ISR() extern "C" void tempTC_Handler(void)
#define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler(void)
extern "C" void tempTC_Handler(void);
extern "C" void stepTC_Handler(void);

View file

@ -65,13 +65,13 @@
#ifdef STM32GENERIC
extern void TC5_Handler();
extern void TC7_Handler();
#define HAL_STEP_TIMER_ISR void TC5_Handler()
#define HAL_TEMP_TIMER_ISR void TC7_Handler()
#define HAL_STEP_TIMER_ISR() void TC5_Handler()
#define HAL_TEMP_TIMER_ISR() void TC7_Handler()
#else
extern void TC5_Handler(stimer_t *htim);
extern void TC7_Handler(stimer_t *htim);
#define HAL_STEP_TIMER_ISR void TC5_Handler(stimer_t *htim)
#define HAL_TEMP_TIMER_ISR void TC7_Handler(stimer_t *htim)
#define HAL_STEP_TIMER_ISR() void TC5_Handler(stimer_t *htim)
#define HAL_TEMP_TIMER_ISR() void TC7_Handler(stimer_t *htim)
#endif

View file

@ -66,8 +66,8 @@
extern void TC5_Handler();
extern void TC7_Handler();
#define HAL_STEP_TIMER_ISR void TC5_Handler()
#define HAL_TEMP_TIMER_ISR void TC7_Handler()
#define HAL_STEP_TIMER_ISR() void TC5_Handler()
#define HAL_TEMP_TIMER_ISR() void TC7_Handler()
// --------------------------------------------------------------------------
// Types

View file

@ -72,8 +72,8 @@ typedef uint32_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define HAL_STEP_TIMER_ISR extern "C" void ftm0_isr(void) //void TC3_Handler()
#define HAL_TEMP_TIMER_ISR extern "C" void ftm1_isr(void) //void TC4_Handler()
#define HAL_STEP_TIMER_ISR() extern "C" void ftm0_isr(void) //void TC3_Handler()
#define HAL_TEMP_TIMER_ISR() extern "C" void ftm1_isr(void) //void TC4_Handler()
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);

View file

@ -71,8 +71,8 @@ typedef uint32_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
#define HAL_STEP_TIMER_ISR extern "C" void ftm0_isr(void) //void TC3_Handler()
#define HAL_TEMP_TIMER_ISR extern "C" void ftm1_isr(void) //void TC4_Handler()
#define HAL_STEP_TIMER_ISR() extern "C" void ftm0_isr(void) //void TC3_Handler()
#define HAL_TEMP_TIMER_ISR() extern "C" void ftm1_isr(void) //void TC4_Handler()
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);

View file

@ -1246,7 +1246,7 @@ void Stepper::set_directions() {
* Directly pulses the stepper motors at high frequency.
*/
HAL_STEP_TIMER_ISR {
HAL_STEP_TIMER_ISR() {
HAL_timer_isr_prologue(STEP_TIMER_NUM);
Stepper::isr();

View file

@ -2295,7 +2295,7 @@ void Temperature::readings_ready() {
* - For ENDSTOP_INTERRUPTS_FEATURE check endstops if flagged
* - Call planner.tick to count down its "ignore" time
*/
HAL_TEMP_TIMER_ISR {
HAL_TEMP_TIMER_ISR() {
HAL_timer_isr_prologue(TEMP_TIMER_NUM);
Temperature::isr();