mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-10-17 10:55:06 +00:00
- Standardized keyboard input using Unicode-based key codes across supported devices and the simulator. Keyboards don't emit `LV_KEY_*` anymore. - Refactored lilygo encoder driver into a reusable GPIO rotary encoder driver (see `Drivers/gpio-encoder-module/`). Added more features to the config file. - Improved LVGL keyboard device management, including duplicate prevention and reliable reconnects. - LVGL file mutex now registers with lvgl start/stop - Improved LVGL startup/shutdown stability and memory allocation reliability. - Increased simulator LVGL memory capacity and improved USB device-class handling.
64 lines
2.0 KiB
C
64 lines
2.0 KiB
C
// SPDX-License-Identifier: Apache-2.0
|
|
#pragma once
|
|
|
|
#include <tactility/freertos/freertos.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* @brief Set of lock/try_lock/unlock callbacks backing a filesystem mount's mutex.
|
|
* Any field left null is treated as a no-op by file_mutex_lock/try_lock/unlock.
|
|
*/
|
|
struct FileMutex {
|
|
void (*lock)();
|
|
bool (*try_lock)(uint32_t timeout);
|
|
void (*unlock)();
|
|
};
|
|
|
|
typedef uint32_t FileMutexId;
|
|
|
|
#define FILE_MUTEX_ID_INVALID ((FileMutexId)0)
|
|
|
|
/**
|
|
* @brief Registers a mutex for a mount path (e.g. "/sdcard") and its descendants.
|
|
* @param[in] mutex callbacks to associate with the path; a copy is stored
|
|
* @param[in] path mount path this mutex serializes access to
|
|
* @return the id of the new entry, or the id of the existing entry if path is already registered
|
|
* @note If a mutex is already registered for this exact path, no new entry is created and the
|
|
* existing entry's id is returned; the existing callbacks are left unchanged.
|
|
*/
|
|
FileMutexId file_mutex_add(const struct FileMutex* mutex, const char* path);
|
|
|
|
/**
|
|
* @brief Removes a previously added mutex registration.
|
|
* @param[in] id id returned by file_mutex_add(); a stale or unknown id is a no-op
|
|
*/
|
|
void file_mutex_remove(FileMutexId id);
|
|
|
|
/**
|
|
* @brief Looks up the mutex registered for path or one of its ancestor mount paths.
|
|
* @param[out] mutex receives the matching mutex, or an all-null (no-op) mutex if none matches
|
|
* @param[in] path file or directory path to look up
|
|
*/
|
|
void file_mutex_get(struct FileMutex* mutex, const char* path);
|
|
|
|
/** @brief Locks mutex. No-op if mutex->lock is null. */
|
|
void file_mutex_lock(const struct FileMutex* mutex);
|
|
|
|
/**
|
|
* @brief Attempts to lock mutex within timeout.
|
|
* @return true if locked (or mutex->try_lock is null), false on timeout
|
|
*/
|
|
bool file_mutex_try_lock(const struct FileMutex* mutex, TickType_t timeout);
|
|
|
|
/** @brief Unlocks mutex. No-op if mutex->unlock is null. */
|
|
void file_mutex_unlock(const struct FileMutex* mutex);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|