Refactor LVGL code into kernel module (#472)
* **New Features** * Added a standalone LVGL module and enabled LVGL support in the simulator for richer local UI testing. * **Refactor** * HAL and LVGL split into distinct modules; startup and device attach/detach flows reorganized for clearer lifecycle management. * Public APIs tightened with clearer nullability/documentation. * **Bug Fixes** * More consistent LVGL start/stop and device attach/detach behavior for improved stability.
This commit is contained in:
committed by
GitHub
parent
3fe1dc0312
commit
9f721e6655
@@ -181,7 +181,7 @@ static inline void device_unlock(struct Device* device) {
|
||||
}
|
||||
|
||||
static inline const struct DeviceType* device_get_type(struct Device* device) {
|
||||
return device->internal.driver ? device->internal.driver->deviceType : NULL;
|
||||
return device->internal.driver ? device->internal.driver->device_type : NULL;
|
||||
}
|
||||
/**
|
||||
* Iterate through all the known devices
|
||||
|
||||
@@ -20,13 +20,13 @@ struct Driver {
|
||||
/** Array of const char*, terminated by NULL */
|
||||
const char**compatible;
|
||||
/** Function to initialize the driver for a device */
|
||||
error_t (*startDevice)(struct Device* dev);
|
||||
error_t (*start_device)(struct Device* dev);
|
||||
/** Function to deinitialize the driver for a device */
|
||||
error_t (*stopDevice)(struct Device* dev);
|
||||
error_t (*stop_device)(struct Device* dev);
|
||||
/** Contains the driver's functions */
|
||||
const void* api;
|
||||
/** Which type of devices this driver creates (can be NULL) */
|
||||
const struct DeviceType* deviceType;
|
||||
const struct DeviceType* device_type;
|
||||
/** The module that owns this driver. When it is NULL, the system owns the driver and it cannot be removed from registration. */
|
||||
const struct Module* owner;
|
||||
/** Internal data */
|
||||
@@ -54,7 +54,7 @@ bool driver_is_compatible(struct Driver* driver, const char* compatible);
|
||||
struct Driver* driver_find_compatible(const char* compatible);
|
||||
|
||||
static inline const struct DeviceType* driver_get_device_type(struct Driver* driver) {
|
||||
return driver->deviceType;
|
||||
return driver->device_type;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
#include "defines.h"
|
||||
@@ -17,8 +20,16 @@
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Projects that include this header must align with Tactility's frequency (e.g. apps)
|
||||
#ifdef __cplusplus
|
||||
static_assert(configTICK_RATE_HZ == 1000);
|
||||
#else
|
||||
static_assert(configTICK_RATE_HZ == 1000, "configTICK_RATE_HZ must be 1000");
|
||||
#endif
|
||||
|
||||
static inline uint32_t get_tick_frequency() {
|
||||
return configTICK_RATE_HZ;
|
||||
@@ -54,26 +65,30 @@ static inline int64_t get_micros_since_boot() {
|
||||
#ifdef ESP_PLATFORM
|
||||
return esp_timer_get_time();
|
||||
#else
|
||||
timespec ts;
|
||||
struct timespec ts;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
|
||||
return (static_cast<int64_t>(ts.tv_sec) * 1000000LL) + (ts.tv_nsec / 1000);
|
||||
return ((int64_t)ts.tv_sec * 1000000LL) + (ts.tv_nsec / 1000);
|
||||
}
|
||||
timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
return (static_cast<int64_t>(tv.tv_sec) * 1000000LL) + tv.tv_usec;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return ((int64_t)tv.tv_sec * 1000000LL) + tv.tv_usec;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Convert seconds to ticks */
|
||||
static inline TickType_t seconds_to_ticks(uint32_t seconds) {
|
||||
return static_cast<uint64_t>(seconds) * 1000U / portTICK_PERIOD_MS;
|
||||
return (uint64_t)seconds * 1000U / portTICK_PERIOD_MS;
|
||||
}
|
||||
|
||||
/** Convert milliseconds to ticks */
|
||||
static inline TickType_t millis_to_ticks(uint32_t milliSeconds) {
|
||||
#if configTICK_RATE_HZ == 1000
|
||||
return static_cast<TickType_t>(milliSeconds);
|
||||
return (TickType_t)milliSeconds;
|
||||
#else
|
||||
return static_cast<TickType_t>(((float)configTICK_RATE_HZ) / 1000.0f * (float)milliSeconds);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user