Reduce warnings, extern "C" cleanup (#20279)

This commit is contained in:
Scott Lahteine 2020-11-25 21:40:56 -06:00
parent 0c24347cdb
commit 664e9d6dfe
26 changed files with 170 additions and 122 deletions

View file

@ -122,12 +122,16 @@ inline uint8_t HAL_get_reset_source() { return MCUSR; }
inline void HAL_reboot() {} // reboot the board or restart the bootloader inline void HAL_reboot() {} // reboot the board or restart the bootloader
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
extern "C" { #pragma GCC diagnostic ignored "-Wunused-function"
int freeMemory(); #endif
}
#pragma GCC diagnostic pop extern "C" int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
// ADC // ADC
#ifdef DIDR2 #ifdef DIDR2

View file

@ -153,10 +153,16 @@ void HAL_init();
// //
void _delay_ms(const int delay); void _delay_ms(const int delay);
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory(); int freeMemory();
#pragma GCC diagnostic pop
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -100,10 +100,16 @@ inline void HAL_reboot() {} // reboot the board or restart the bootloader
void _delay_ms(int delay); void _delay_ms(int delay);
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory(); int freeMemory();
#pragma GCC diagnostic pop
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
void analogWrite(pin_t pin, int value); void analogWrite(pin_t pin, int value);

View file

@ -91,9 +91,11 @@ typedef uint64_t hal_timer_t;
#define HAL_PWM_TIMER_ISR() extern "C" void pwmTC_Handler() #define HAL_PWM_TIMER_ISR() extern "C" void pwmTC_Handler()
#endif #endif
extern "C" void tempTC_Handler(); extern "C" {
extern "C" void stepTC_Handler(); void tempTC_Handler();
extern "C" void pwmTC_Handler(); void stepTC_Handler();
void pwmTC_Handler();
}
// ------------------------ // ------------------------
// Types // Types

View file

@ -23,6 +23,10 @@
#include "platforms.h" #include "platforms.h"
#ifndef GCC_VERSION
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif
#include HAL_PATH(.,HAL.h) #include HAL_PATH(.,HAL.h)
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2

View file

@ -27,18 +27,13 @@
HalSerial usb_serial; HalSerial usb_serial;
// U8glib required functions // U8glib required functions
extern "C" void u8g_xMicroDelay(uint16_t val) { extern "C" {
DELAY_US(val); void u8g_xMicroDelay(uint16_t val) { DELAY_US(val); }
} void u8g_MicroDelay() { u8g_xMicroDelay(1); }
extern "C" void u8g_MicroDelay() { void u8g_10MicroDelay() { u8g_xMicroDelay(10); }
u8g_xMicroDelay(1); void u8g_Delay(uint16_t val) { delay(val); }
}
extern "C" void u8g_10MicroDelay() {
u8g_xMicroDelay(10);
}
extern "C" void u8g_Delay(uint16_t val) {
delay(val);
} }
//************************// //************************//
// return free heap space // return free heap space

View file

@ -79,10 +79,16 @@ extern HalSerial usb_serial;
inline void HAL_init() {} inline void HAL_init() {}
// Utility functions // Utility functions
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory(); int freeMemory();
#pragma GCC diagnostic pop
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
// ADC // ADC
#define HAL_ADC_VREF 5.0 #define HAL_ADC_VREF 5.0

View file

@ -67,8 +67,11 @@ void cli(); // Disable
void sei(); // Enable void sei(); // Enable
void attachInterrupt(uint32_t pin, void (*callback)(), uint32_t mode); void attachInterrupt(uint32_t pin, void (*callback)(), uint32_t mode);
void detachInterrupt(uint32_t pin); 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 // Program Memory
#define pgm_read_ptr(addr) (*((void**)(addr))) #define pgm_read_ptr(addr) (*((void**)(addr)))
@ -92,9 +95,7 @@ using std::memcpy;
#define strlen_P strlen #define strlen_P strlen
// Time functions // Time functions
extern "C" { extern "C" void delay(const int milis);
void delay(const int milis);
}
void _delay_ms(const int delay); void _delay_ms(const int delay);
void delayMicroseconds(unsigned long); void delayMicroseconds(unsigned long);
uint32_t millis(); uint32_t millis();

View file

@ -32,18 +32,13 @@
uint32_t HAL_adc_reading = 0; uint32_t HAL_adc_reading = 0;
// U8glib required functions // U8glib required functions
extern "C" void u8g_xMicroDelay(uint16_t val) { extern "C" {
DELAY_US(val); void u8g_xMicroDelay(uint16_t val) { DELAY_US(val); }
} void u8g_MicroDelay() { u8g_xMicroDelay(1); }
extern "C" void u8g_MicroDelay() { void u8g_10MicroDelay() { u8g_xMicroDelay(10); }
u8g_xMicroDelay(1); void u8g_Delay(uint16_t val) { delay(val); }
}
extern "C" void u8g_10MicroDelay() {
u8g_xMicroDelay(10);
}
extern "C" void u8g_Delay(uint16_t val) {
delay(val);
} }
//************************// //************************//
// return free heap space // return free heap space

View file

@ -107,10 +107,16 @@ extern "C" volatile uint32_t _millis;
// //
// Utility functions // Utility functions
// //
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory(); int freeMemory();
#pragma GCC diagnostic pop
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
// //
// ADC API // ADC API

View file

@ -26,30 +26,19 @@
#if USING_SERIAL_0 #if USING_SERIAL_0
MarlinSerial MSerial(LPC_UART0); MarlinSerial MSerial(LPC_UART0);
extern "C" void UART0_IRQHandler() { extern "C" void UART0_IRQHandler() { MSerial.IRQHandler(); }
MSerial.IRQHandler();
}
#endif #endif
#if USING_SERIAL_1 #if USING_SERIAL_1
MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1); MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1);
extern "C" void UART1_IRQHandler() { extern "C" void UART1_IRQHandler() { MSerial1.IRQHandler(); }
MSerial1.IRQHandler();
}
#endif #endif
#if USING_SERIAL_2 #if USING_SERIAL_2
MarlinSerial MSerial2(LPC_UART2); MarlinSerial MSerial2(LPC_UART2);
extern "C" void UART2_IRQHandler() { extern "C" void UART2_IRQHandler() { MSerial2.IRQHandler(); }
MSerial2.IRQHandler();
}
#endif #endif
#if USING_SERIAL_3 #if USING_SERIAL_3
MarlinSerial MSerial3(LPC_UART3); MarlinSerial MSerial3(LPC_UART3);
extern "C" void UART3_IRQHandler() { extern "C" void UART3_IRQHandler() { MSerial3.IRQHandler(); }
MSerial3.IRQHandler();
}
#endif #endif
#endif // TARGET_LPC1768 #endif // TARGET_LPC1768

View file

@ -31,18 +31,18 @@
#include <CDCSerial.h> #include <CDCSerial.h>
#include <usb/mscuser.h> #include <usb/mscuser.h>
extern "C" {
#include <debug_frmwrk.h>
}
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
#include "../../core/millis_t.h" #include "../../core/millis_t.h"
#include "../../sd/cardreader.h" #include "../../sd/cardreader.h"
extern uint32_t MSC_SD_Init(uint8_t pdrv); 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(); } void SysTick_Callback() { disk_timerproc(); }

View file

@ -135,10 +135,16 @@ void HAL_idletask();
// //
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory(); int freeMemory();
#pragma GCC diagnostic pop
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -140,15 +140,19 @@ void _delay_ms(const int delay);
extern "C" char* _sbrk(int incr); extern "C" char* _sbrk(int incr);
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
static inline int freeMemory() { static inline int freeMemory() {
volatile char top; volatile char top;
return &top - reinterpret_cast<char*>(_sbrk(0)); return &top - reinterpret_cast<char*>(_sbrk(0));
} }
#pragma GCC diagnostic pop #if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
// //
// ADC // ADC

View file

@ -189,8 +189,10 @@ inline void HAL_reboot() {} // reboot the board or restart the bootloader
void _delay_ms(const int delay); void _delay_ms(const int delay);
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
/* /*
extern "C" { extern "C" {
@ -213,7 +215,9 @@ static int freeMemory() {
return &top - reinterpret_cast<char*>(_sbrk(0)); return &top - reinterpret_cast<char*>(_sbrk(0));
} }
#pragma GCC diagnostic pop #if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
// //
// ADC // ADC

View file

@ -129,8 +129,10 @@ timer_dev* get_timer_dev(int number);
#define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler() #define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler()
#endif #endif
extern "C" void tempTC_Handler(); extern "C" {
extern "C" void stepTC_Handler(); void tempTC_Handler();
void stepTC_Handler();
}
// ------------------------ // ------------------------
// Public Variables // Public Variables

View file

@ -162,15 +162,19 @@ int freeMemory() {
} }
*/ */
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
static inline int freeMemory() { static inline int freeMemory() {
volatile char top; volatile char top;
return &top - reinterpret_cast<char*>(_sbrk(0)); return &top - reinterpret_cast<char*>(_sbrk(0));
} }
#pragma GCC diagnostic pop #if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
// //
// ADC // ADC

View file

@ -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); HAL_TIM_Base_Start_IT(&TimerHandle[timer_num].handle);
} }
extern "C" void TIM5_IRQHandler() { extern "C" {
((void(*)())TimerHandle[0].callback)(); void TIM5_IRQHandler() { ((void(*)())TimerHandle[0].callback)(); }
} void TIM7_IRQHandler() { ((void(*)())TimerHandle[1].callback)(); }
extern "C" void TIM7_IRQHandler() {
((void(*)())TimerHandle[1].callback)();
} }
void HAL_timer_enable_interrupt(const uint8_t timer_num) { void HAL_timer_enable_interrupt(const uint8_t timer_num) {

View file

@ -83,11 +83,9 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
} }
//forward the interrupt //forward the interrupt
extern "C" void TIM5_IRQHandler() { extern "C" {
((void(*)())timerConfig[0].callback)(); void TIM5_IRQHandler() { ((void(*)())timerConfig[0].callback)(); }
} void TIM7_IRQHandler() { ((void(*)())timerConfig[1].callback)(); }
extern "C" void TIM7_IRQHandler() {
((void(*)())timerConfig[1].callback)();
} }
void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare) { void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare) {

View file

@ -97,12 +97,16 @@ inline void HAL_reboot() {} // reboot the board or restart the bootloader
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
extern "C" { #pragma GCC diagnostic ignored "-Wunused-function"
int freeMemory(); #endif
}
#pragma GCC diagnostic pop extern "C" int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
// ADC // ADC

View file

@ -103,12 +103,16 @@ inline void HAL_reboot() {} // reboot the board or restart the bootloader
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
extern "C" { #pragma GCC diagnostic ignored "-Wunused-function"
int freeMemory(); #endif
}
#pragma GCC diagnostic pop extern "C" int freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
// ADC // ADC

View file

@ -120,12 +120,16 @@ uint8_t HAL_get_reset_source();
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
#pragma GCC diagnostic push #if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic push
extern "C" { #pragma GCC diagnostic ignored "-Wunused-function"
uint32_t freeMemory(); #endif
}
#pragma GCC diagnostic pop extern "C" uint32_t freeMemory();
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
// ADC // ADC

View file

@ -78,8 +78,10 @@ typedef uint32_t hal_timer_t;
#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 #endif
extern "C" void stepTC_Handler(); extern "C" {
extern "C" void tempTC_Handler(); void stepTC_Handler();
void tempTC_Handler();
}
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);

View file

@ -106,8 +106,10 @@ struct duration_t {
return this->value; return this->value;
} }
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-overflow" #pragma GCC diagnostic ignored "-Wformat-overflow"
#endif
/** /**
* @brief Formats the duration as a string * @brief Formats the duration as a string
@ -167,5 +169,7 @@ struct duration_t {
} }
} }
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
}; };