Browse Source

update

transmit_disinfection
zhaohe 11 months ago
parent
commit
a3f7743a96
  1. 4
      mutex.cpp
  2. 3
      mutex.hpp
  3. 2
      zadc.hpp
  4. 2
      zspi.hpp

4
mutex.cpp

@ -6,7 +6,7 @@ using namespace iflytop;
/******************************************************************************* /*******************************************************************************
* zmutex * * zmutex *
*******************************************************************************/ *******************************************************************************/
zmutex::zmutex() {}
zmutex::zmutex(const char* name) { this->name = name; }
zmutex::~zmutex() { vSemaphoreDelete(recursiveMutex); } zmutex::~zmutex() { vSemaphoreDelete(recursiveMutex); }
void zmutex::init() { void zmutex::init() {
recursiveMutex = xSemaphoreCreateRecursiveMutex(); recursiveMutex = xSemaphoreCreateRecursiveMutex();
@ -15,7 +15,9 @@ void zmutex::init() {
bool zmutex::isInit() { return recursiveMutex != NULL; } bool zmutex::isInit() { return recursiveMutex != NULL; }
void zmutex::lock() { void zmutex::lock() {
// ZASSERT(recursiveMutex != NULL); // ZASSERT(recursiveMutex != NULL);
if (recursiveMutex == NULL) { if (recursiveMutex == NULL) {
ZLOGE(TAG, "%s recursiveMutex NULL, init it", name);
ZASSERT(recursiveMutex != NULL); ZASSERT(recursiveMutex != NULL);
} }
xSemaphoreTakeRecursive(recursiveMutex, portMAX_DELAY); xSemaphoreTakeRecursive(recursiveMutex, portMAX_DELAY);

3
mutex.hpp

@ -5,9 +5,10 @@ namespace iflytop {
class zmutex { class zmutex {
public: public:
SemaphoreHandle_t recursiveMutex; SemaphoreHandle_t recursiveMutex;
const char* name = nullptr;
public: public:
zmutex();
zmutex(const char* name);
~zmutex(); ~zmutex();
void init(); void init();

2
zadc.hpp

@ -14,7 +14,7 @@ class ZADC {
int32_t m_samplingTime = ADC_SAMPLETIME_480CYCLES; int32_t m_samplingTime = ADC_SAMPLETIME_480CYCLES;
bool inited = false; bool inited = false;
zmutex m_mutex;
zmutex m_mutex = {"ZADC"};
int32_t m_cacheVal = 0; int32_t m_cacheVal = 0;
const char* m_name = "not set"; const char* m_name = "not set";

2
zspi.hpp

@ -9,7 +9,7 @@ namespace iflytop {
class ZSPI { class ZSPI {
private: private:
SPI_HandleTypeDef *m_hspi = NULL; SPI_HandleTypeDef *m_hspi = NULL;
zmutex m_mutex;
zmutex m_mutex= {"ZSPI"};
public: public:
ZSPI(){}; ZSPI(){};

Loading…
Cancel
Save