temperature: Fixing issues.

*We are running out of memory.
*Less safe I2C transaction.
*Discovered a bug in clock.
This commit is contained in:
RedHawk 2023-05-17 17:21:55 +03:00
parent fc2a05a9d8
commit b891695bfc
5 changed files with 10 additions and 10 deletions

View File

@ -93,7 +93,7 @@ void Clock::updateClock()
diff_overflows = (old_overflows <= this->_overflows) diff_overflows = (old_overflows <= this->_overflows)
//Usually it is new amount of overflows - old. //Usually it is new amount of overflows - old.
? (this->_overflows - old_overflows) ? (this->_overflows - old_overflows)
//It is possible that overflows counter will overflow. //It is possible that overflows counter will overflow. (Seems that it causes the timer to get insane count when it works.)
: (0xffffffffffffffff - old_overflows + this->_overflows); : (0xffffffffffffffff - old_overflows + this->_overflows);
//First case -> no overflow //First case -> no overflow

View File

@ -103,7 +103,7 @@ I2C::transaction (uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize,
I2CM_XFER_T i2cmXferRec; I2CM_XFER_T i2cmXferRec;
// make sure that master is idle // make sure that master is idle
while (Chip_I2CM_StateChanged(this->device) == 0); //while (Chip_I2CM_StateChanged(this->device) == 0);
/* Setup I2C transfer record */ /* Setup I2C transfer record */
i2cmXferRec.slaveAddr = devAddr; i2cmXferRec.slaveAddr = devAddr;

View File

@ -121,19 +121,19 @@ void thread_master(void* pvParams) {
LOG_INFO("Master is creating tasks"); LOG_INFO("Master is creating tasks");
manager->tm->createTask(thread_manager, "manager", manager->tm->createTask(thread_manager, "manager",
configMINIMAL_STACK_SIZE * 14,tskIDLE_PRIORITY + 1UL, configMINIMAL_STACK_SIZE * 13,tskIDLE_PRIORITY + 1UL,
static_cast<void*>(manager)); static_cast<void*>(manager));
manager->tm->createTask(thread_rotary, "rotary", manager->tm->createTask(thread_rotary, "rotary",
configMINIMAL_STACK_SIZE * 9,tskIDLE_PRIORITY + 1UL, configMINIMAL_STACK_SIZE * 8,tskIDLE_PRIORITY + 1UL,
static_cast<void*>(manager)); static_cast<void*>(manager));
manager->tm->createTask(thread_user_interface, "user_interface", manager->tm->createTask(thread_user_interface, "user_interface",
configMINIMAL_STACK_SIZE * 9,tskIDLE_PRIORITY + 1UL, configMINIMAL_STACK_SIZE * 8,tskIDLE_PRIORITY + 1UL,
static_cast<void*>(manager)); static_cast<void*>(manager));
manager->tm->createTask(thread_relay, "relay", manager->tm->createTask(thread_relay, "relay",
configMINIMAL_STACK_SIZE * 9,tskIDLE_PRIORITY + 1UL, configMINIMAL_STACK_SIZE * 8,tskIDLE_PRIORITY + 1UL,
static_cast<void*>(manager)); static_cast<void*>(manager));
manager->tm->createTask(thread_temperature, "temperature", manager->tm->createTask(thread_temperature, "temperature",
configMINIMAL_STACK_SIZE * 9,tskIDLE_PRIORITY + 1UL, configMINIMAL_STACK_SIZE * 8,tskIDLE_PRIORITY + 1UL,
static_cast<void*>(manager)); static_cast<void*>(manager));
LOG_INFO("Master created tasks"); LOG_INFO("Master created tasks");
m.taskFunction(); m.taskFunction();

View File

@ -51,7 +51,7 @@ uint8_t SensorTempTC74::read()
if (this->on_standby()) if (this->on_standby())
{ {
this->remove_standby(); this->remove_standby();
vTaskDelay(1); vTaskDelay(3000);
} }
//if ready and up - read //if ready and up - read
@ -64,7 +64,7 @@ uint8_t SensorTempTC74::read()
LOG_WARNING("Unable to read temperature sensor [%d] value.", this->_dev_addr); LOG_WARNING("Unable to read temperature sensor [%d] value.", this->_dev_addr);
//set standy. //set standy.
this->set_standby(); //this->set_standby();
return data; return data;
} }

View File

@ -33,7 +33,7 @@ void Temperature::taskFunction()
void thread_temperature(void* pvParams) void thread_temperature(void* pvParams)
{ {
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams); ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);
I2C_config conf{0x4a, 55000}; I2C_config conf{0x4a, 100000};
I2C i2c(conf); I2C i2c(conf);
Temperature t(manager->qm, &i2c); Temperature t(manager->qm, &i2c);
t.taskFunction(); t.taskFunction();