Smart tab5keyboard (#533)

This commit is contained in:
Shadowtrance
2026-06-20 06:14:07 +10:00
committed by GitHub
parent e8b9a1f2a9
commit 594b8bd27e
34 changed files with 528 additions and 137 deletions
@@ -43,6 +43,16 @@ properties:
type: int
required: true
description: Bus width in bits
slot:
type: int
default: 1
enum: [0, 1]
description: SDMMC host slot number (SDMMC_HOST_SLOT_0 or SDMMC_HOST_SLOT_1). On ESP32-P4, slot 0 uses the dedicated (non-GPIO-matrix) pins.
max-freq-khz:
type: int
default: 20000
minimum: 1
description: Maximum SDMMC clock frequency in kHz (e.g. 40000 for SDMMC_FREQ_HIGHSPEED)
wp-active-high:
type: boolean
default: false
@@ -2,6 +2,8 @@
#pragma once
#include <tactility/drivers/gpio.h>
#include <tactility/device.h>
#include <driver/i2c_types.h>
#include <driver/i2c_master.h>
#ifdef __cplusplus
@@ -18,8 +20,18 @@ struct Esp32I2cMasterConfig {
struct GpioPinSpec pinScl;
};
/**
* Returns the i2c_master_bus_handle_t for an esp32_i2c_master Device.
* The device must be started. Returns NULL if the device has no driver data.
*/
i2c_master_bus_handle_t esp32_i2c_master_get_bus_handle(struct Device* device);
/**
* Returns the SCL clock frequency (Hz) configured for an esp32_i2c_master Device.
* Reads directly from the device tree config, so the device does not need to be started.
*/
uint32_t esp32_i2c_master_get_clock_frequency(struct Device* device);
#ifdef __cplusplus
}
#endif
@@ -3,6 +3,7 @@
#include <soc/soc_caps.h>
#if SOC_SDMMC_HOST_SUPPORTED
#include <driver/sdmmc_default_configs.h>
#include <sd_protocol_types.h>
#include <stdbool.h>
#include <stdint.h>
@@ -26,6 +27,8 @@ struct Esp32SdmmcConfig {
struct GpioPinSpec pin_cd;
struct GpioPinSpec pin_wp;
uint8_t bus_width;
int32_t slot;
int32_t max_freq_khz;
bool wp_active_high;
bool enable_uhs;
bool pullups;
@@ -286,6 +286,14 @@ static error_t stop(Device* device) {
return ERROR_NONE;
}
i2c_master_bus_handle_t esp32_i2c_master_get_bus_handle(struct Device* device) {
return GET_DATA(device)->bus_handle;
}
uint32_t esp32_i2c_master_get_clock_frequency(struct Device* device) {
return GET_CONFIG(device)->clockFrequency;
}
static constexpr I2cControllerApi ESP32_I2C_MASTER_API = {
.read = read,
.write = write,
@@ -308,8 +316,4 @@ Driver esp32_i2c_master_driver = {
.internal = nullptr
};
i2c_master_bus_handle_t esp32_i2c_master_get_bus_handle(Device* device) {
return GET_DATA(device)->bus_handle;
}
} // extern "C"
@@ -10,6 +10,8 @@
#include <driver/sdmmc_host.h>
#include <esp_vfs_fat.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <sdmmc_cmd.h>
#include <string>
@@ -76,6 +78,8 @@ static error_t mount(void* data) {
};
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
host.slot = config->slot;
host.max_freq_khz = config->max_freq_khz;
#if SOC_SD_PWR_CTRL_SUPPORTED
// Treat non-positive values as disabled to remain safe with zero-initialized configs.
@@ -89,6 +93,10 @@ static error_t mount(void* data) {
return ERROR_NOT_SUPPORTED;
}
host.pwr_ctrl_handle = fs_data->pwr_ctrl_handle;
// On cold boot the SD card needs time for its supply rail to ramp up after the
// on-chip LDO is enabled, otherwise the initial ACMD41 (send_op_cond) times out.
vTaskDelay(pdMS_TO_TICKS(10));
}
#endif