This commit is contained in:
Ken Van Hoeylandt 2026-01-02 20:35:38 +01:00
parent 10cc269d9d
commit 94d9c1d611
10 changed files with 32 additions and 11 deletions

View File

@ -1,6 +1,8 @@
#include "Bq25896.h"
#define TAG "BQ27220"
#include <Tactility/Log.h>
constexpr auto* TAG = "BQ27220";
void Bq25896::powerOff() {
TT_LOG_I(TAG, "Power off");

View File

@ -1,6 +1,7 @@
#pragma once
#include <Tactility/hal/i2c/I2cDevice.h>
#include <Tactility/Log.h>
class Drv2605 : public tt::hal::i2c::I2cDevice {

View File

@ -33,7 +33,7 @@ bool tt_lock_acquire(LockHandle handle, TickType timeout) {
}
void tt_lock_release(LockHandle handle) {
return HANDLE_AS_LOCK(handle)->unlock();
HANDLE_AS_LOCK(handle)->unlock();
}
void tt_lock_free(LockHandle handle) {

View File

@ -6,8 +6,10 @@
#ifdef ESP_PLATFORM
static portMUX_TYPE critical_mutex;
#define TT_ENTER_CRITICAL() taskENTER_CRITICAL(&critical_mutex)
#define TT_EXIT_CRITICAL() taskEXIT_CRITICAL(&critical_mutex)
#else
#define TT_ENTER_CRITICAL() taskENTER_CRITICAL()
#define TT_EXIT_CRITICAL() taskEXIT_CRITICAL()
#endif
namespace tt::kernel::critical {
@ -34,7 +36,7 @@ void exit(CriticalInfo info) {
if (info.fromIsr) {
taskEXIT_CRITICAL_FROM_ISR(info.isrm);
} else if (info.kernelRunning) {
TT_ENTER_CRITICAL();
TT_EXIT_CRITICAL();
} else {
portENABLE_INTERRUPTS();
}

View File

@ -37,14 +37,17 @@ private:
Mutex mutex;
std::queue<Function> queue = {};
EventGroup eventFlag;
bool shutdown = false;
public:
explicit Dispatcher() = default;
~Dispatcher() {
mutex.lock();
mutex.unlock();
shutdown = true;
if (mutex.lock()) {
mutex.unlock();
}
}
/**
@ -62,6 +65,10 @@ public:
return false;
}
if (shutdown) {
return false;
}
queue.push(std::move(function));
if (queue.size() == BACKPRESSURE_WARNING_COUNT) {
#ifdef ESP_PLATFORM
@ -89,6 +96,10 @@ public:
return 0;
}
if (shutdown) {
return 0;
}
// Mutate
bool processing = true;
uint32_t consumed = 0;
@ -112,7 +123,7 @@ public:
#endif
}
} while (processing);
} while (processing && !shutdown);
return consumed;
}

View File

@ -79,7 +79,7 @@ public:
* @param[out] outError optional error output: this is set when the return value is false
* @return true on success
*/
uint32_t clear(uint32_t flags, uint32_t* outFlags = nullptr, Error* outError = nullptr) const {
bool clear(uint32_t flags, uint32_t* outFlags = nullptr, Error* outError = nullptr) const {
if (xPortInIsrContext() == pdTRUE) {
uint32_t result = xEventGroupGetBitsFromISR(handle.get());
if (xEventGroupClearBitsFromISR(handle.get(), flags) == pdFAIL) {

View File

@ -88,11 +88,12 @@ private:
portBASE_TYPE affinity = -1;
void setState(State newState) {
// mutex.lock();
mutex.lock();
state = newState;
if (stateCallback) {
stateCallback(state, stateCallbackContext);
}
mutex.unlock();
}
public:
@ -127,7 +128,7 @@ public:
void setStackSize(size_t newStackSize) {
mutex.lock();
assert(state == State::Stopped);
assert(stackSize % 4 == 0);
assert(newStackSize % 4 == 0);
stackSize = newStackSize;
mutex.unlock();
}

View File

@ -35,13 +35,13 @@ constexpr TickType_t getTicks() {
/** @return the amount of milliseconds that has passed in the main kernel tasks */
constexpr size_t getMillis() {
return getTicks() / portTICK_PERIOD_MS;
return getTicks() * portTICK_PERIOD_MS;
}
/** @return the microseconds that have passed since boot */
constexpr int64_t getMicrosSinceBoot() {
#ifdef ESP_PLATFORM
return static_cast<unsigned long>(esp_timer_get_time());
return esp_timer_get_time();
#else
timeval tv;
gettimeofday(&tv, nullptr);

View File

@ -48,6 +48,8 @@ int main(int argc, char** argv) {
assert(task_result == pdPASS);
vTaskStartScheduler();
return data.result;
}
extern "C" {

View File

@ -48,6 +48,8 @@ int main(int argc, char** argv) {
assert(task_result == pdPASS);
vTaskStartScheduler();
return data.result;
}
extern "C" {