SPI HAL implemented and more (#207)

- Cleanup unused code and move ISR/IRQ checks to `Kernel.h`
- Improve clang-format
- Fix for LVGL lock transfer: ensure lock isn't activate when changing the lock
- Implement SPI HAL
- Remove `initHardware` HAL configuration entry
- Fix `I2cScanner`: don't scan when port isn't started
This commit is contained in:
Ken Van Hoeylandt
2025-02-08 00:21:50 +01:00
committed by GitHub
parent 88b3bfbe3e
commit c1f55429b6
41 changed files with 634 additions and 428 deletions
@@ -2,36 +2,8 @@
#include "CoreExtraDefines.h"
#ifdef ESP_PLATFORM
#else
#include "portmacro.h"
#endif
#define TT_RETURNS_NONNULL __attribute__((returns_nonnull))
#define TT_WARN_UNUSED __attribute__((warn_unused_result))
#define TT_UNUSED __attribute__((unused))
#define TT_WEAK __attribute__((weak))
#define TT_PACKED __attribute__((packed))
#define TT_PLACE_IN_SECTION(x) __attribute__((section(x)))
#define TT_ALIGN(n) __attribute__((aligned(n)))
// Used by portENABLE_INTERRUPTS and portDISABLE_INTERRUPTS?
#ifdef ESP_PLATFORM
#define TT_IS_IRQ_MODE() (xPortInIsrContext() == pdTRUE)
#else
#define TT_IS_IRQ_MODE() false
#endif
#define TT_IS_ISR() (TT_IS_IRQ_MODE())
#define TT_CHECK_RETURN __attribute__((__warn_unused_result__))
// region Variable arguments support
// Adapted from https://stackoverflow.com/a/78848701/3848666
+12 -1
View File
@@ -37,13 +37,24 @@ public:
ErrorISR = 0xFFFFFFFAU, ///< TtStatusErrorISR (-6).
};
/** Set the bitmask for 1 or more flags that we might be waiting for */
uint32_t set(uint32_t flags) const;
/** Clear the specified flags */
uint32_t clear(uint32_t flags) const;
/** Get the currently set flags */
uint32_t get() const;
/** Await for flags to be set
* @param[in] flags the bitmask of the flags that we want to wait for
* @param[in] options the trigger behaviour: WaitAny, WaitAll, NoClear (NoClear can be combined with either WaitAny or WaitAll)
* @param[in] timeoutTicks the maximum amount of ticks to wait
*/
uint32_t wait(
uint32_t flags,
uint32_t options = WaitAny,
uint32_t timeout = (uint32_t)portMAX_DELAY
uint32_t timeoutTicks = (uint32_t)portMAX_DELAY
) const;
};
@@ -22,6 +22,6 @@ void log(LogLevel level, const char* tag, const char* format, ...);
#define TT_LOG_D(tag, format, ...) \
tt::log(tt::LogLevel::Debug, tag, format, ##__VA_ARGS__)
#define TT_LOG_V(tag, format, ...) \
tt::log(tt::LogLevel::Trace, tag, format, ##__VA_ARGS__)
tt::log(tt::LogLevel::Verbose, tag, format, ##__VA_ARGS__)
#endif // ESP_PLATFORM
+2 -1
View File
@@ -8,6 +8,7 @@
#include "RtosCompatSemaphore.h"
#include "Check.h"
#include "Lockable.h"
#include "kernel/Kernel.h"
#include <memory>
namespace tt {
@@ -29,7 +30,7 @@ private:
struct SemaphoreHandleDeleter {
void operator()(QueueHandle_t handleToDelete) {
assert(!TT_IS_IRQ_MODE());
assert(!kernel::isIsr());
vSemaphoreDelete(handleToDelete);
}
};
+2 -1
View File
@@ -1,5 +1,6 @@
#pragma once
#include "kernel/Kernel.h"
#include "Lockable.h"
#include <cassert>
#include <memory>
@@ -24,7 +25,7 @@ private:
struct SemaphoreHandleDeleter {
void operator()(QueueHandle_t handleToDelete) {
assert(!TT_IS_IRQ_MODE());
assert(!kernel::isIsr());
vSemaphoreDelete(handleToDelete);
}
};
@@ -42,6 +42,7 @@ std::string join(const std::vector<std::string>& input, const std::string& delim
/**
* Returns the lowercase value of a string.
* @warning This only works for strings with 1 byte per character
* @param[in] the string with lower and/or uppercase characters
* @return a string with only lowercase characters
*/
@@ -14,6 +14,13 @@ typedef enum {
PlatformSimulator
} Platform;
/** Return true when called from an Interrupt Service Routine (~IRQ mode) */
#ifdef ESP_PLATFORM
inline constexpr bool isIsr() { return (xPortInIsrContext() == pdTRUE); }
#else
inline constexpr bool isIsr() { return false; }
#endif
/** Check if kernel is running
* @return true if the FreeRTOS kernel is running, false otherwise
*/