Skip to content

Commit

Permalink
misc. CH32 and ESP32-S3 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Jun 19, 2024
1 parent 1681f7c commit 02cca0b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
5 changes: 5 additions & 0 deletions software/firmware/source/SoftRF/src/driver/GNSS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,12 @@ byte GNSS_setup() {
#else
int interrupt_num = digitalPinToInterrupt(SOC_GPIO_PIN_GNSS_PPS);
if (interrupt_num != NOT_AN_INTERRUPT) {
#if defined(plat_attachInterrupt_func)
plat_attachInterrupt_func(SOC_GPIO_PIN_GNSS_PPS, SoC->GNSS_PPS_handler,
RISING);
#else
attachInterrupt(interrupt_num, SoC->GNSS_PPS_handler, RISING);
#endif /* plat_attachInterrupt_func */
}
#endif
}
Expand Down
8 changes: 8 additions & 0 deletions software/firmware/source/SoftRF/src/platform/CH32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ eeprom_t eeprom_block;
settings_t *settings = &eeprom_block.field.settings;
#endif /* EXCLUDE_EEPROM */

void CH32_attachInterrupt_func(uint32_t pin, void (*userFunc)(void), int mode)
{
attachInterrupt(pin, GPIO_Mode_IN_FLOATING, userFunc, EXTI_Mode_Interrupt,
mode == RISING ? EXTI_Trigger_Rising :
mode == FALLING ? EXTI_Trigger_Falling :
EXTI_Trigger_Rising_Falling /* CHANGE */ );
}

static void CH32_setup()
{
#if SOC_GPIO_RADIO_LED_TX != SOC_UNUSED_PIN
Expand Down
12 changes: 6 additions & 6 deletions software/firmware/source/SoftRF/src/platform/CH32.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#ifndef PLATFORM_CH32_H
#define PLATFORM_CH32_H

#include <avr/dtostrf.h>

/* Maximum of tracked flying objects is now SoC-specific constant */
#define MAX_TRACKING_OBJECTS 8

Expand Down Expand Up @@ -49,10 +47,6 @@

#define SOC_ADC_VOLTAGE_DIV 2 /* TBD */

#ifndef strnlen
#define strnlen(x,y) strlen(x) /* TBD */
#endif

enum rst_reason {
REASON_DEFAULT_RST = 0, /* normal startup by power on */
REASON_WDT_RST = 1, /* hardware watch dog reset */
Expand Down Expand Up @@ -170,6 +164,12 @@ extern Adafruit_NeoPixel strip;
#define U8X8_OLED_I2C_BUS_TYPE U8X8_SSD1306_128X64_NONAME_HW_I2C
#endif /* USE_OLED */

extern void CH32_attachInterrupt_func(uint32_t pin, void (*)(void), int mode);

#define plat_attachInterrupt_func CH32_attachInterrupt_func

#define DEBUG 0 /* https://github.com/openwch/arduino_core_ch32/issues/125 */

#endif /* PLATFORM_CH32_H */

#endif /* ARDUINO_ARCH_CH32 */
7 changes: 7 additions & 0 deletions software/firmware/source/SoftRF/src/platform/ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,13 @@ static void ESP32_setup()
}
} else if (hw_info.model == SOFTRF_MODEL_MIDI) {

#if defined(ESP_IDF_VERSION_MAJOR) && ESP_IDF_VERSION_MAJOR >= 5
#define BOARD_F_XTAL_MHZ 26

rtc_clk_xtal_freq_update((rtc_xtal_freq_t) BOARD_F_XTAL_MHZ);
rtc_clk_cpu_freq_set_xtal();
#endif /* ESP_IDF_VERSION_MAJOR */

#if ARDUINO_USB_CDC_ON_BOOT
SerialOutput.begin(SERIAL_OUT_BR, SERIAL_OUT_BITS,
SOC_GPIO_PIN_S3_CONS_RX,
Expand Down

0 comments on commit 02cca0b

Please sign in to comment.