cherry pick backport fix for cardputer
This commit is contained in:
+55
-1
@@ -1,13 +1,65 @@
|
|||||||
#include "AudioBoard.h"
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
|
#ifdef M5STACK_CARDPUTER_ADV
|
||||||
|
|
||||||
|
#include "AudioBoard.h"
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
DriverPins PinsAudioBoardES8311;
|
DriverPins PinsAudioBoardES8311;
|
||||||
AudioBoard board(AudioDriverES8311, PinsAudioBoardES8311);
|
AudioBoard board(AudioDriverES8311, PinsAudioBoardES8311);
|
||||||
|
|
||||||
|
// PI4IOE5V6408 on the optional Cap LoRa-1262 (and Cap LoRa868).
|
||||||
|
#define PI4IO_ADDR 0x43
|
||||||
|
#define PI4IO_REG_IO_DIR 0x03
|
||||||
|
#define PI4IO_REG_OUT_SET 0x05
|
||||||
|
#define PI4IO_REG_OUT_H_IM 0x07
|
||||||
|
|
||||||
|
static TwoWire *findLoraCapBus()
|
||||||
|
{
|
||||||
|
TwoWire *candidates[] = {&Wire1, &Wire};
|
||||||
|
for (size_t i = 0; i < sizeof(candidates) / sizeof(candidates[0]); ++i) {
|
||||||
|
candidates[i]->beginTransmission(PI4IO_ADDR);
|
||||||
|
if (candidates[i]->endTransmission() == 0) {
|
||||||
|
return candidates[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool pi4ioWrite(TwoWire *bus, uint8_t reg, uint8_t val)
|
||||||
|
{
|
||||||
|
bus->beginTransmission(PI4IO_ADDR);
|
||||||
|
bus->write(reg);
|
||||||
|
bus->write(val);
|
||||||
|
uint8_t status = bus->endTransmission();
|
||||||
|
if (status != 0) {
|
||||||
|
LOG_DEBUG("PI4IO write reg=0x%02x val=0x%02x failed, I2C status=%u", reg, val, status);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void initLoraCap()
|
||||||
|
{
|
||||||
|
TwoWire *bus = findLoraCapBus();
|
||||||
|
if (!bus) {
|
||||||
|
LOG_ERROR("Cap LoRa-1262 not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool ok = pi4ioWrite(bus, PI4IO_REG_IO_DIR, 0b00000001);
|
||||||
|
ok = ok && pi4ioWrite(bus, PI4IO_REG_OUT_H_IM, 0b00000001);
|
||||||
|
ok = ok && pi4ioWrite(bus, PI4IO_REG_OUT_SET, 0b00000001);
|
||||||
|
if (!ok) {
|
||||||
|
LOG_ERROR("Antenna switch init failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// M5stack Cardputer ADV specific init
|
// M5stack Cardputer ADV specific init
|
||||||
|
|
||||||
void lateInitVariant()
|
void lateInitVariant()
|
||||||
{
|
{
|
||||||
|
initLoraCap();
|
||||||
|
|
||||||
// AudioDriverLogger.begin(Serial, AudioDriverLogLevel::Debug);
|
// AudioDriverLogger.begin(Serial, AudioDriverLogLevel::Debug);
|
||||||
// I2C: function, scl, sda
|
// I2C: function, scl, sda
|
||||||
PinsAudioBoardES8311.addI2C(PinFunction::CODEC, Wire);
|
PinsAudioBoardES8311.addI2C(PinFunction::CODEC, Wire);
|
||||||
@@ -38,3 +90,5 @@ void lateInitVariant()
|
|||||||
es8311_write_reg(0x32, 0xBF); // DAC volume (0dB)
|
es8311_write_reg(0x32, 0xBF); // DAC volume (0dB)
|
||||||
es8311_write_reg(0x37, 0x08); // EQ bypass
|
es8311_write_reg(0x37, 0x08); // EQ bypass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -10,9 +10,6 @@ build_flags =
|
|||||||
-D M5STACK_CARDPUTER_ADV
|
-D M5STACK_CARDPUTER_ADV
|
||||||
-D ARDUINO_USB_CDC_ON_BOOT=1
|
-D ARDUINO_USB_CDC_ON_BOOT=1
|
||||||
-I variants/esp32s3/m5stack_cardputer_adv
|
-I variants/esp32s3/m5stack_cardputer_adv
|
||||||
build_src_filter =
|
|
||||||
${esp32s3_base.build_src_filter}
|
|
||||||
+<../variants/esp32s3/m5stack_cardputer_adv>
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${esp32s3_base.lib_deps}
|
${esp32s3_base.lib_deps}
|
||||||
# renovate: datasource=git-refs depName=meshtastic-st7789 packageName=https://github.com/meshtastic/st7789 gitBranch=main
|
# renovate: datasource=git-refs depName=meshtastic-st7789 packageName=https://github.com/meshtastic/st7789 gitBranch=main
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#define ST7789_BUSY -1
|
#define ST7789_BUSY -1
|
||||||
// #define VTFT_CTRL 38
|
// #define VTFT_CTRL 38
|
||||||
#define VTFT_LEDA 38
|
#define VTFT_LEDA 38
|
||||||
|
#define TFT_BACKLIGHT_ON HIGH
|
||||||
// #define ST7789_BL (32+6)
|
// #define ST7789_BL (32+6)
|
||||||
#define ST7789_SPI_HOST SPI2_HOST
|
#define ST7789_SPI_HOST SPI2_HOST
|
||||||
// #define TFT_BL (32+6)
|
// #define TFT_BL (32+6)
|
||||||
|
|||||||
Reference in New Issue
Block a user