Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions variants/m5stack_cardputer/M5CardputerBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@
class M5CardputerBoard : public ESP32Board {
public:
void begin() {
// Step 1: Enable power to I/O expander on LoRa Cap (GPIO 46)
pinMode(46, OUTPUT);
digitalWrite(46, HIGH);
delay(100); // Give I/O expander time to power up

// Step 2: Initialize main I2C (SDA=2, SCL=1) before M5Cardputer keyboard init
// Step 1: Initialize main I2C (SDA=2, SCL=1) before M5Cardputer keyboard init
ESP32Board::begin();

// Step 3: Initialize M5Cardputer hardware with keyboard enabled
// Step 2: Initialize M5Cardputer hardware with keyboard enabled
auto cfg = M5.config();
cfg.clear_display = true;
cfg.internal_imu = false; // No IMU on Cardputer-Adv
Expand All @@ -30,13 +25,6 @@ class M5CardputerBoard : public ESP32Board {
delay(100);
M5Cardputer.Keyboard.begin();

M5.In_I2C.writeRegister8(0x43, 0x03, 0x00, 100000);
delay(10);
M5.In_I2C.writeRegister8(0x43, 0x01, 0xFF, 100000);
delay(200);

Serial.println("LoRa Cap I/O expander (PI4IOE at 0x43 on SDA=8,SCL=9) configured");

Serial.println("M5Stack Cardputer-Adv initialized");
Serial.print("Battery voltage: ");
Serial.print(getBattMilliVolts());
Expand Down
8 changes: 8 additions & 0 deletions variants/m5stack_cardputer/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "target.h"

M5CardputerBoard board;
m5::PI4IOE5V6408_Class ioe(0x43, 400000, &m5::In_I2C);;

static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi, SPISettings());
Expand Down Expand Up @@ -189,6 +190,13 @@ SensorManager sensors;
bool radio_init() {
fallback_clock.begin();
rtc_clock.begin(Wire);

if (ioe.begin()) {
Serial.printf("Using Cap LoRa-1262\n");
ioe.setDirection(0, true); // Output
ioe.setHighImpedance(0, false); // Disable high-impedance so pin can actually drive
ioe.digitalWrite(0, true); // High Level
}

// Hardware reset sequence for LoRa module
// This ensures proper initialization even if module is connected after power-on
Expand Down
3 changes: 3 additions & 0 deletions variants/m5stack_cardputer/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <M5CardputerBoard.h>
#include <utility/PI4IOE5V6408_Class.hpp>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#ifdef HAS_GPS
Expand Down Expand Up @@ -39,6 +40,8 @@ class CardputerSensorManager : public SensorManager {
extern M5CardputerBoard board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern m5::PI4IOE5V6408_Class ioe;

#ifdef HAS_GPS
extern CardputerSensorManager sensors;
#else
Expand Down