mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
* **New Features** * Added a HAL device module providing device enumeration, type queries and a HAL↔kernel bridge. * **Improvements** * Integrated HAL module into startup; standardized module names, includes and lifecycle logging; safer file append behavior; broader build support. * **API Changes** * Driver lifecycle now uses explicit add/remove semantics; C and HAL device type/lookup APIs clarified. * **Chores** * Added module README and Apache‑2.0 license; updated build configuration to include the new module. * **Fixes** * Updated tests and object file handling to behave correctly.
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#include "tt_hal_device.h"
|
|
|
|
#include <tactility/check.h>
|
|
|
|
#include <tactility/hal/Device.h>
|
|
|
|
static tt::hal::Device::Type toTactilityDeviceType(TtDeviceType type) {
|
|
switch (type) {
|
|
case DEVICE_TYPE_I2C:
|
|
return tt::hal::Device::Type::I2c;
|
|
case DEVICE_TYPE_DISPLAY:
|
|
return tt::hal::Device::Type::Display;
|
|
case DEVICE_TYPE_TOUCH:
|
|
return tt::hal::Device::Type::Touch;
|
|
case DEVICE_TYPE_SDCARD:
|
|
return tt::hal::Device::Type::SdCard;
|
|
case DEVICE_TYPE_KEYBOARD:
|
|
return tt::hal::Device::Type::Keyboard;
|
|
case DEVICE_TYPE_POWER:
|
|
return tt::hal::Device::Type::Power;
|
|
case DEVICE_TYPE_GPS:
|
|
return tt::hal::Device::Type::Gps;
|
|
default:
|
|
check(false, "Device::Type not supported");
|
|
}
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
bool tt_hal_device_find(TtDeviceType type, DeviceId* deviceIds, uint16_t* count, uint16_t maxCount) {
|
|
assert(maxCount > 0);
|
|
|
|
int16_t currentIndex = -1;
|
|
uint16_t maxIndex = maxCount - 1;
|
|
|
|
findDevices<tt::hal::Device>(toTactilityDeviceType(type), [&](const auto& device) {
|
|
currentIndex++;
|
|
deviceIds[currentIndex] = device->getId();
|
|
// Continue if there is storage capacity left
|
|
return currentIndex < maxIndex;
|
|
});
|
|
|
|
*count = currentIndex + 1;
|
|
|
|
return currentIndex >= 0;
|
|
}
|
|
|
|
}
|