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

3
mutex.hpp

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

2
zadc.hpp

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

2
zspi.hpp

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

Loading…
Cancel
Save