Skip to content

Commit

Permalink
extern "C" cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Nov 26, 2020
1 parent 45dc079 commit b9e502e
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 83 deletions.
8 changes: 5 additions & 3 deletions Marlin/src/HAL/ESP32/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ typedef uint64_t hal_timer_t;
#define HAL_PWM_TIMER_ISR() extern "C" void pwmTC_Handler()
#endif

extern "C" void tempTC_Handler();
extern "C" void stepTC_Handler();
extern "C" void pwmTC_Handler();
extern "C" {
void tempTC_Handler();
void stepTC_Handler();
void pwmTC_Handler();
}

// ------------------------
// Types
Expand Down
17 changes: 6 additions & 11 deletions Marlin/src/HAL/LINUX/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,13 @@
HalSerial usb_serial;

// U8glib required functions
extern "C" void u8g_xMicroDelay(uint16_t val) {
DELAY_US(val);
}
extern "C" void u8g_MicroDelay() {
u8g_xMicroDelay(1);
}
extern "C" void u8g_10MicroDelay() {
u8g_xMicroDelay(10);
}
extern "C" void u8g_Delay(uint16_t val) {
delay(val);
extern "C" {
void u8g_xMicroDelay(uint16_t val) { DELAY_US(val); }
void u8g_MicroDelay() { u8g_xMicroDelay(1); }
void u8g_10MicroDelay() { u8g_xMicroDelay(10); }
void u8g_Delay(uint16_t val) { delay(val); }
}

//************************//

// return free heap space
Expand Down
11 changes: 6 additions & 5 deletions Marlin/src/HAL/LINUX/include/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ void cli(); // Disable
void sei(); // Enable
void attachInterrupt(uint32_t pin, void (*callback)(), uint32_t mode);
void detachInterrupt(uint32_t pin);
extern "C" void GpioEnableInt(uint32_t port, uint32_t pin, uint32_t mode);
extern "C" void GpioDisableInt(uint32_t port, uint32_t pin);

extern "C" {
void GpioEnableInt(uint32_t port, uint32_t pin, uint32_t mode);
void GpioDisableInt(uint32_t port, uint32_t pin);
}

// Program Memory
#define pgm_read_ptr(addr) (*((void**)(addr)))
Expand All @@ -92,9 +95,7 @@ using std::memcpy;
#define strlen_P strlen

// Time functions
extern "C" {
void delay(const int milis);
}
extern "C" void delay(const int milis);
void _delay_ms(const int delay);
void delayMicroseconds(unsigned long);
uint32_t millis();
Expand Down
17 changes: 6 additions & 11 deletions Marlin/src/HAL/LPC1768/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,13 @@
uint32_t HAL_adc_reading = 0;

// U8glib required functions
extern "C" void u8g_xMicroDelay(uint16_t val) {
DELAY_US(val);
}
extern "C" void u8g_MicroDelay() {
u8g_xMicroDelay(1);
}
extern "C" void u8g_10MicroDelay() {
u8g_xMicroDelay(10);
}
extern "C" void u8g_Delay(uint16_t val) {
delay(val);
extern "C" {
void u8g_xMicroDelay(uint16_t val) { DELAY_US(val); }
void u8g_MicroDelay() { u8g_xMicroDelay(1); }
void u8g_10MicroDelay() { u8g_xMicroDelay(10); }
void u8g_Delay(uint16_t val) { delay(val); }
}

//************************//

// return free heap space
Expand Down
45 changes: 18 additions & 27 deletions Marlin/src/HAL/LPC1768/MarlinSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,23 @@
#include "../../inc/MarlinConfigPre.h"
#include "MarlinSerial.h"

#if USING_SERIAL_0
MarlinSerial MSerial(LPC_UART0);
extern "C" void UART0_IRQHandler() {
MSerial.IRQHandler();
}
#endif

#if USING_SERIAL_1
MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1);
extern "C" void UART1_IRQHandler() {
MSerial1.IRQHandler();
}
#endif

#if USING_SERIAL_2
MarlinSerial MSerial2(LPC_UART2);
extern "C" void UART2_IRQHandler() {
MSerial2.IRQHandler();
}
#endif

#if USING_SERIAL_3
MarlinSerial MSerial3(LPC_UART3);
extern "C" void UART3_IRQHandler() {
MSerial3.IRQHandler();
}
#endif
extern "C" {
#if USING_SERIAL_0
MarlinSerial MSerial(LPC_UART0);
void UART0_IRQHandler() { MSerial.IRQHandler(); }
#endif
#if USING_SERIAL_1
MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1);
void UART1_IRQHandler() { MSerial1.IRQHandler(); }
#endif
#if USING_SERIAL_2
MarlinSerial MSerial2(LPC_UART2);
void UART2_IRQHandler() { MSerial2.IRQHandler(); }
#endif
#if USING_SERIAL_3
MarlinSerial MSerial3(LPC_UART3);
void UART3_IRQHandler() { MSerial3.IRQHandler(); }
#endif
}

#endif // TARGET_LPC1768
12 changes: 6 additions & 6 deletions Marlin/src/HAL/LPC1768/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
#include <CDCSerial.h>
#include <usb/mscuser.h>

extern "C" {
#include <debug_frmwrk.h>
}

#include "../../inc/MarlinConfig.h"
#include "../../core/millis_t.h"

#include "../../sd/cardreader.h"

extern uint32_t MSC_SD_Init(uint8_t pdrv);
extern "C" int isLPC1769();
extern "C" void disk_timerproc();

extern "C" {
#include <debug_frmwrk.h>
extern "C" int isLPC1769();
extern "C" void disk_timerproc();
}

void SysTick_Callback() { disk_timerproc(); }

Expand Down
6 changes: 4 additions & 2 deletions Marlin/src/HAL/STM32F1/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ timer_dev* get_timer_dev(int number);
#define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler()
#endif

extern "C" void tempTC_Handler();
extern "C" void stepTC_Handler();
extern "C" {
void tempTC_Handler();
void stepTC_Handler();
}

// ------------------------
// Public Variables
Expand Down
8 changes: 3 additions & 5 deletions Marlin/src/HAL/STM32_F4_F7/STM32F4/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
HAL_TIM_Base_Start_IT(&TimerHandle[timer_num].handle);
}

extern "C" void TIM5_IRQHandler() {
((void(*)())TimerHandle[0].callback)();
}
extern "C" void TIM7_IRQHandler() {
((void(*)())TimerHandle[1].callback)();
extern "C" {
void TIM5_IRQHandler() { ((void(*)())TimerHandle[0].callback)(); }
void TIM7_IRQHandler() { ((void(*)())TimerHandle[1].callback)(); }
}

void HAL_timer_enable_interrupt(const uint8_t timer_num) {
Expand Down
8 changes: 3 additions & 5 deletions Marlin/src/HAL/STM32_F4_F7/STM32F7/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
}

//forward the interrupt
extern "C" void TIM5_IRQHandler() {
((void(*)())timerConfig[0].callback)();
}
extern "C" void TIM7_IRQHandler() {
((void(*)())timerConfig[1].callback)();
extern "C" {
void TIM5_IRQHandler() { ((void(*)())timerConfig[0].callback)(); }
void TIM7_IRQHandler() { ((void(*)())timerConfig[1].callback)(); }
}

void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare) {
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/TEENSY31_32/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ typedef uint32_t hal_timer_t;
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)

#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() extern "C" void ftm0_isr() //void TC3_Handler()
#define HAL_STEP_TIMER_ISR() extern "C" void ftm0_isr() //void TC3_Handler()
#endif
#ifndef HAL_TEMP_TIMER_ISR
#define HAL_TEMP_TIMER_ISR() extern "C" void ftm1_isr() //void TC4_Handler()
#define HAL_TEMP_TIMER_ISR() extern "C" void ftm1_isr() //void TC4_Handler()
#endif

void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/TEENSY35_36/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ typedef uint32_t hal_timer_t;
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)

#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() extern "C" void ftm0_isr() //void TC3_Handler()
#define HAL_STEP_TIMER_ISR() extern "C" void ftm0_isr() //void TC3_Handler()
#endif
#ifndef HAL_TEMP_TIMER_ISR
#define HAL_TEMP_TIMER_ISR() extern "C" void ftm1_isr() //void TC4_Handler()
#define HAL_TEMP_TIMER_ISR() extern "C" void ftm1_isr() //void TC4_Handler()
#endif

void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
Expand Down
10 changes: 6 additions & 4 deletions Marlin/src/HAL/TEENSY40_41/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,16 @@ typedef uint32_t hal_timer_t;
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)

#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler() // GPT1_Handler()
#define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler() // GPT1_Handler()
#endif
#ifndef HAL_TEMP_TIMER_ISR
#define HAL_TEMP_TIMER_ISR() extern "C" void tempTC_Handler() // GPT2_Handler()
#define HAL_TEMP_TIMER_ISR() extern "C" void tempTC_Handler() // GPT2_Handler()
#endif

extern "C" void stepTC_Handler();
extern "C" void tempTC_Handler();
extern "C" {
void stepTC_Handler();
void tempTC_Handler();
}

void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);

Expand Down

0 comments on commit b9e502e

Please sign in to comment.