From 97e87257b0290af987403f8ced135ce8520dd18a Mon Sep 17 00:00:00 2001 From: Gatsby Date: Tue, 29 Oct 2024 21:36:28 +0800 Subject: [PATCH] fix: correct external function handling --- cx9261adriver_c.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/cx9261adriver_c.cpp b/cx9261adriver_c.cpp index d4f5679..e0376ef 100644 --- a/cx9261adriver_c.cpp +++ b/cx9261adriver_c.cpp @@ -513,37 +513,37 @@ void CX9261A_setSetPinFunc(CX9261A_SetPinFunc func) { #ifdef USE_LOGGING void CX9261A::logging(const std::string& msg) { - if(loggingFunc != NULL) { - loggingFunc(msg.c_str()); + if(loggingFunc == NULL) { + exit(-1); } - exit(-1); + return loggingFunc(msg.c_str()); } #endif void CX9261A::writeSpi(int address, int value) { - if(writeSpiFunc != NULL) { - writeSpiFunc(address, value); + if(writeSpiFunc == NULL) { + exit(-1); } - exit(-1); + return writeSpiFunc(address, value); } int CX9261A::readSpi(int address) { - if(readSpiFunc != NULL) { - return readSpiFunc(address); + if(readSpiFunc == NULL) { + exit(-1); } - exit(-1); + return readSpiFunc(address); } void CX9261A::pause(double ms) { - if(pauseFunc != NULL) { - return pauseFunc(ms); + if(pauseFunc == NULL) { + exit(-1); } - exit(-1); + return pauseFunc(ms); } void CX9261A::setPin(int pin, int value) { - if(setPinFunc != NULL) { - return setPinFunc(pin, value); + if(setPinFunc == NULL) { + exit(-1); } - exit(-1); + return setPinFunc(pin, value); } \ No newline at end of file