Device migrations and driver improvements (#576)
This commit is contained in:
committed by
GitHub
parent
2fbc44466a
commit
a3fda9ad8f
@@ -2,5 +2,5 @@ file(GLOB_RECURSE SOURCE_FILES source/*.c*)
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
REQUIRES TactilityKernel axp192-module
|
||||
REQUIRES TactilityKernel
|
||||
)
|
||||
|
||||
@@ -21,3 +21,5 @@ display.dpi=200
|
||||
cdn.warningMessage=This board implementation concerns the original Core2 hardware and **not** the v1.1 variant
|
||||
|
||||
lvgl.colorDepth=16
|
||||
|
||||
sdkconfig.CONFIG_CODEC_DUMMY_SUPPORT=y
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
dependencies:
|
||||
- Platforms/platform-esp32
|
||||
- Drivers/audio-stream-module
|
||||
- Drivers/pdm-mic-module
|
||||
- Drivers/dummy-i2s-amp-module
|
||||
- Drivers/mpu6886-module
|
||||
- Drivers/bm8563-module
|
||||
- Drivers/axp192-module
|
||||
- Drivers/ft6x36-module
|
||||
- Drivers/ft5x06-module
|
||||
- Drivers/ili9341-module
|
||||
dts: m5stack,core2.dts
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
#include <tactility/bindings/esp32_grove.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_i2s.h>
|
||||
#include <tactility/bindings/esp32_sdspi.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
#include <bindings/mpu6886.h>
|
||||
#include <bindings/bm8563.h>
|
||||
#include <bindings/axp192.h>
|
||||
#include <bindings/ft6x36.h>
|
||||
#include <bindings/ft5x06.h>
|
||||
#include <bindings/ili9341.h>
|
||||
#include <tactility/bindings/esp32_sdspi.h>
|
||||
#include <bindings/dummy_i2s_amp.h>
|
||||
#include <bindings/pdm_mic.h>
|
||||
|
||||
// Reference: https://docs.m5stack.com/en/core/Core2
|
||||
/ {
|
||||
@@ -50,10 +52,23 @@
|
||||
axp192 {
|
||||
compatible = "x-powers,axp192";
|
||||
reg = <0x34>;
|
||||
dcdc1-enable; // ESP32 + peripherals main 3V3 rail - must stay on
|
||||
dcdc1-voltage = <3300>;
|
||||
dcdc3-enable; // LCD backlight
|
||||
dcdc3-voltage = <3300>;
|
||||
ldo2-enable; // LCD logic + SD card
|
||||
ldo2-voltage = <3300>;
|
||||
// ldo3 (vibration motor) intentionally left disabled
|
||||
exten-enable; // 5V boost (speaker amp etc.)
|
||||
gpio1-pwm; // GPIO1 as PWM1 output, drives the notification LED
|
||||
gpio1-pwm1-duty-cycle = <255>; // 255 = LED off
|
||||
};
|
||||
|
||||
// FT6x36 driver doesn't reliably work when power cycling,
|
||||
// or when the driver was powering on with its own power supply (not USB-C).
|
||||
// The driver would not find the device and init would fail.
|
||||
touch {
|
||||
compatible = "focaltech,ft6x36";
|
||||
compatible = "focaltech,ft5x06";
|
||||
reg = <0x38>;
|
||||
x-max = <320>;
|
||||
y-max = <240>;
|
||||
@@ -96,8 +111,6 @@
|
||||
};
|
||||
};
|
||||
|
||||
// NS4168: Speaker and microphone
|
||||
// TODO: Init microphone via I2C: https://github.com/m5stack/M5Unified/blob/a6256725481f1bc366655fa48cf03b6095e30ad1/src/M5Unified.cpp#L391C19-L391C44
|
||||
i2s0 {
|
||||
compatible = "espressif,esp32-i2s";
|
||||
port = <I2S_NUM_0>;
|
||||
@@ -106,4 +119,15 @@
|
||||
pin-data-out = <&gpio0 2 GPIO_FLAG_NONE>;
|
||||
pin-data-in = <&gpio0 34 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
speaker0 {
|
||||
compatible = "nsiway,ns4168";
|
||||
i2s = <&i2s0>;
|
||||
};
|
||||
|
||||
mic0 {
|
||||
compatible = "generic,spm1423";
|
||||
i2s = <&i2s0>;
|
||||
channels = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,47 +1,15 @@
|
||||
#include <drivers/axp192.h>
|
||||
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/device_listener.h>
|
||||
#include <tactility/error.h>
|
||||
#include <tactility/module.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
extern "C" {
|
||||
|
||||
static void configure_axp192(Device* axp192) {
|
||||
check(axp192_set_rail_voltage(axp192, AXP192_RAIL_LDO2, 3300) == ERROR_NONE); // LCD + SD
|
||||
check(axp192_set_rail_voltage(axp192, AXP192_RAIL_DCDC3, 3300) == ERROR_NONE); // LCD backlight
|
||||
|
||||
check(axp192_set_rail_enabled(axp192, AXP192_RAIL_LDO2, true) == ERROR_NONE);
|
||||
check(axp192_set_rail_enabled(axp192, AXP192_RAIL_LDO3, false) == ERROR_NONE); // VIB_MOTOR stop
|
||||
check(axp192_set_rail_enabled(axp192, AXP192_RAIL_DCDC3, true) == ERROR_NONE);
|
||||
|
||||
check(axp192_set_pwm1_duty_cycle(axp192, 255) == ERROR_NONE); // PWM 255 (LED off)
|
||||
check(axp192_set_gpio1_pwm1_output(axp192) == ERROR_NONE); // GPIO1: PWM
|
||||
}
|
||||
|
||||
static void on_device_event(Device* device, DeviceEvent event, void* context) {
|
||||
(void)context;
|
||||
if (event == DEVICE_EVENT_STARTED && strcmp(device->name, "axp192") == 0) {
|
||||
configure_axp192(device);
|
||||
}
|
||||
}
|
||||
|
||||
static error_t start() {
|
||||
device_listener_add(on_device_event, nullptr);
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
static error_t stop() {
|
||||
device_listener_remove(on_device_event);
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
struct Module m5stack_core2_module = {
|
||||
// AXP192 rail/GPIO1 bring-up is now devicetree-configured (see m5stack,core2.dts's axp192 node
|
||||
// and axp192-module's start()), replacing what used to be done by hand here via a
|
||||
// DEVICE_EVENT_STARTED device_listener.
|
||||
Module m5stack_core2_module = {
|
||||
.name = "m5stack-core2",
|
||||
.start = start,
|
||||
.stop = stop,
|
||||
.start = [] -> error_t { return ERROR_NONE; },
|
||||
.stop = [] -> error_t { return ERROR_NONE; },
|
||||
.symbols = nullptr,
|
||||
.internal = nullptr
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user