добавила возможность отключать сообщения об ошибках. убрала лишнее подтягивание этой функции

This commit is contained in:
klassents 2024-10-15 14:52:36 +07:00
parent e77ae5935b
commit 0d8fb21261
7 changed files with 12 additions and 19 deletions

View File

@ -6,8 +6,6 @@
#include "WInterrupts.h" #include "WInterrupts.h"
#include "wiring_LL.h" #include "wiring_LL.h"
extern void ErrorMsgHandler(const char * msg);
typedef void (*voidFuncPtr)(void); typedef void (*voidFuncPtr)(void);
// empty irq handler // empty irq handler

View File

@ -19,7 +19,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 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 "WString.h"
#include "itoa.h" #include "itoa.h"

View File

@ -30,11 +30,13 @@ void post_init(void)
} }
// --------------------- other --------------------- // // --------------------- 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) extern "C" void ErrorMsgHandler(const char * msg)
{ {
// function works if Serial is used in sketch and user doesn't turn it off
#ifdef HardwareSerial_h #ifdef HardwareSerial_h
if(Serial) if(use_error_messages&&Serial)
Serial.println(msg); Serial.println(msg);
#endif #endif
} }

View File

@ -1,6 +1,10 @@
#ifndef _BOARD_H_ #ifndef _BOARD_H_
#define _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() // functions for init called before and after setup()
void pre_init(void) ; void pre_init(void) ;
void post_init(void); void post_init(void);

View File

@ -8,7 +8,6 @@ extern "C" {
#include "mik32_hal_gpio.h" #include "mik32_hal_gpio.h"
#include "mik32_hal_timer32.h" #include "mik32_hal_timer32.h"
extern void ErrorMsgHandler(const char * msg);
// -------------------------- Analog read -------------------------- // // -------------------------- Analog read -------------------------- //
#define ADC_SAMPLES_QTY 10 // samples quantity for averaging adc results #define ADC_SAMPLES_QTY 10 // samples quantity for averaging adc results

View File

@ -24,8 +24,6 @@
extern "C" { extern "C" {
#endif #endif
extern void ErrorMsgHandler(const char * msg);
// initialization // initialization
void pinMode(uint32_t PinNumber, uint32_t PinMode) void pinMode(uint32_t PinNumber, uint32_t PinMode)
{ {

View File

@ -16,14 +16,6 @@
#include "wiring_analog.h" #include "wiring_analog.h"
#include "wiring_LL.h" #include "wiring_LL.h"
#ifdef __cplusplus
extern "C" {
#endif
void ErrorMsgHandler(const char * msg);
#ifdef __cplusplus
}
#endif
bool spiNssPinIsBlocked = false; bool spiNssPinIsBlocked = false;
// list of pin numbers from both ports with pins inside the port // list of pin numbers from both ports with pins inside the port