diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index 9c4ad1a..93a9353 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -6,8 +6,6 @@ #include "WInterrupts.h" #include "wiring_LL.h" -extern void ErrorMsgHandler(const char * msg); - typedef void (*voidFuncPtr)(void); // empty irq handler diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index 1f06d2b..401c657 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#pragma GCC diagnostic ignored "-Wrestrict" // для GCC и Clang +#pragma GCC diagnostic ignored "-Wrestrict" // for GCC and Clang #include "WString.h" #include "itoa.h" diff --git a/cores/arduino/board.cpp b/cores/arduino/board.cpp index 04bfa4c..876cb87 100644 --- a/cores/arduino/board.cpp +++ b/cores/arduino/board.cpp @@ -30,13 +30,15 @@ void post_init(void) } // --------------------- other --------------------- // -// print text if Serial is enabled +volatile bool use_error_messages = true; +// print error message to Serial extern "C" void ErrorMsgHandler(const char * msg) { -#ifdef HardwareSerial_h - if(Serial) - Serial.println(msg); -#endif + // function works if Serial is used in sketch and user doesn't turn it off + #ifdef HardwareSerial_h + if(use_error_messages&&Serial) + Serial.println(msg); + #endif } diff --git a/cores/arduino/board.h b/cores/arduino/board.h index ad1ae06..61599a0 100644 --- a/cores/arduino/board.h +++ b/cores/arduino/board.h @@ -1,6 +1,10 @@ #ifndef _BOARD_H_ #define _BOARD_H_ +extern volatile bool use_error_messages; +#define DISABLE_ERROR_MESSAGES() (use_error_messages = false) +#define ENABLE_ERROR_MESSAGES() (use_error_messages = true) + // functions for init called before and after setup() void pre_init(void) ; void post_init(void); diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index 8af6dfe..c7e5c35 100644 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -8,7 +8,6 @@ extern "C" { #include "mik32_hal_gpio.h" #include "mik32_hal_timer32.h" -extern void ErrorMsgHandler(const char * msg); // -------------------------- Analog read -------------------------- // #define ADC_SAMPLES_QTY 10 // samples quantity for averaging adc results diff --git a/cores/arduino/wiring_digital.c b/cores/arduino/wiring_digital.c index 9f82c27..1894c4f 100644 --- a/cores/arduino/wiring_digital.c +++ b/cores/arduino/wiring_digital.c @@ -24,8 +24,6 @@ extern "C" { #endif -extern void ErrorMsgHandler(const char * msg); - // initialization void pinMode(uint32_t PinNumber, uint32_t PinMode) { diff --git a/variants/standart/variant.c b/variants/standart/variant.c index ed0f3b6..a54ee4d 100644 --- a/variants/standart/variant.c +++ b/variants/standart/variant.c @@ -16,14 +16,6 @@ #include "wiring_analog.h" #include "wiring_LL.h" -#ifdef __cplusplus -extern "C" { -#endif -void ErrorMsgHandler(const char * msg); -#ifdef __cplusplus -} -#endif - bool spiNssPinIsBlocked = false; // list of pin numbers from both ports with pins inside the port