Skip to content

Commit

Permalink
[CH32] disable battery voltage ADC for a while
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Oct 1, 2024
1 parent 0544fd7 commit d6bf5f1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
67 changes: 66 additions & 1 deletion software/firmware/source/SoftRF/src/platform/CH32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,67 @@ static void CH32_Button_fini()
#endif /* SOC_GPIO_PIN_BUTTON != SOC_UNUSED_PIN */
}

#if defined(USE_TINYUSB)
static void CH32_USB_setup() {
#if !defined(USBCON)
USBSerial.begin(SERIAL_OUT_BR);
#endif /* USBCON */
}

static void CH32_USB_loop() {

}

static void CH32_USB_fini() {
#if !defined(USBCON)
USBSerial.end();
#endif /* USBCON */
}

static int CH32_USB_available()
{
int rval = 0;

if (USBSerial) {
rval = USBSerial.available();
}

return rval;
}

static int CH32_USB_read()
{
int rval = -1;

if (USBSerial) {
rval = USBSerial.read();
}

return rval;
}

static size_t CH32_USB_write(const uint8_t *buffer, size_t size)
{
size_t rval = size;

if (USBSerial && (size < USBSerial.availableForWrite())) {
rval = USBSerial.write(buffer, size);
}

return rval;
}

IODev_ops_t CH32_USBSerial_ops = {
"CH32 USBSerial",
CH32_USB_setup,
CH32_USB_loop,
CH32_USB_fini,
CH32_USB_available,
CH32_USB_read,
CH32_USB_write
};
#endif /* USE_TINYUSB */

const SoC_ops_t CH32_ops = {
SOC_CH32,
"CH32",
Expand Down Expand Up @@ -617,8 +678,12 @@ const SoC_ops_t CH32_ops = {
CH32_SPI_begin,
CH32_swSer_begin,
CH32_swSer_enableRx,
NULL, /* TODO */
NULL,
#if defined(USE_TINYUSB)
&CH32_USBSerial_ops,
#else
NULL,
#endif /* USE_TINYUSB */
NULL,
CH32_Display_setup,
CH32_Display_loop,
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/SoftRF/src/platform/CH32.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ struct rst_info {

#define SOC_GPIO_PIN_LED SOC_UNUSED_PIN
#define SOC_GPIO_PIN_GNSS_PPS PA3
#define SOC_GPIO_PIN_BATTERY PA0
#define SOC_GPIO_PIN_BATTERY SOC_UNUSED_PIN /* PA0 TBD */
#define SOC_GPIO_PIN_BUTTON SOC_UNUSED_PIN /* PB3 */

#define SOC_GPIO_RADIO_LED_RX SOC_UNUSED_PIN
Expand Down

0 comments on commit d6bf5f1

Please sign in to comment.