From d88f23133264c047aa9f1c21e1ee8d8082006d43 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 10 Dec 2024 15:35:29 +0100 Subject: [PATCH] Added ability to specify per-board transceiver OCP limit --- Boards.h | 3 +++ sx126x.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Boards.h b/Boards.h index bd91dd1..97a0e5a 100644 --- a/Boards.h +++ b/Boards.h @@ -227,6 +227,7 @@ #define HAS_TCXO true #define HAS_BUSY true #define DIO2_AS_RF_SWITCH true + #define OCP_TUNED 0x38 const int pin_busy = 32; const int pin_dio = 33; const int pin_tcxo_enable = -1; @@ -331,6 +332,7 @@ #define HAS_SLEEP true #define PIN_WAKEUP GPIO_NUM_0 #define WAKEUP_LEVEL 0 + #define OCP_TUNED 0x28 const int pin_btn_usr1 = 0; @@ -519,6 +521,7 @@ #define DIO2_AS_RF_SWITCH true #define HAS_BUSY true #define HAS_TCXO true + #define OCP_TUNED 0x38 #define HAS_DISPLAY true #define HAS_CONSOLE true diff --git a/sx126x.cpp b/sx126x.cpp index 7f220cb..dc1f141 100644 --- a/sx126x.cpp +++ b/sx126x.cpp @@ -771,7 +771,7 @@ void sx126x::setTxPower(int level, int outputPin) { if (level > 22) { level = 22; } else if (level < -9) { level = -9; } - writeRegister(REG_OCP_6X, 0x38); // 160mA limit, overcurrent protection + writeRegister(REG_OCP_6X, OCP_TUNED); // Use board-specific tuned OCP uint8_t tx_buf[2];