Skip to content

Commit

Permalink
[CH32] build with BASICMAC
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Nov 11, 2024
1 parent 1e57e38 commit dd4849c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
8 changes: 6 additions & 2 deletions software/firmware/source/SoftRF/src/platform/CH32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ lmic_pinmap lmic_pins = {
.rxe = LMIC_UNUSED_PIN,
.rst = SOC_GPIO_PIN_RST,
.dio = {LMIC_UNUSED_PIN, LMIC_UNUSED_PIN, LMIC_UNUSED_PIN},
.busy = LMIC_UNUSED_PIN,
.busy = SOC_GPIO_PIN_BUSY,
.tcxo = LMIC_UNUSED_PIN,
};

Expand Down Expand Up @@ -310,6 +310,10 @@ static void CH32_setup()
FATFS_is_mounted = fatfs.begin(SPIFlash);
}

#if defined(USE_RADIOLIB)
lmic_pins.dio[0] = SOC_GPIO_PIN_DIO1;
#endif /* USE_RADIOLIB */

Serial.begin(SERIAL_OUT_BR, SERIAL_OUT_BITS);

#if defined(USE_TINYUSB) && defined(USBCON)
Expand Down Expand Up @@ -340,7 +344,7 @@ static void CH32_post_init()
Serial.println(F("Built-in components:"));

Serial.print(F("RADIO : "));
Serial.println(hw_info.rf == RF_IC_SX1276 ? F("PASS") : F("FAIL"));
Serial.println(hw_info.rf != RF_IC_NONE ? F("PASS") : F("FAIL"));
Serial.print(F("GNSS : "));
Serial.println(hw_info.gnss != GNSS_MODULE_NONE ? F("PASS") : F("FAIL"));

Expand Down
10 changes: 6 additions & 4 deletions software/firmware/source/SoftRF/src/platform/CH32.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ struct rst_info {
#define SOC_GPIO_PIN_CE SOC_UNUSED_PIN
#define SOC_GPIO_PIN_PWR SOC_UNUSED_PIN

/* SX1276 */
#define SOC_GPIO_PIN_RST PB0
#define SOC_GPIO_PIN_BUSY SOC_UNUSED_PIN
#define SOC_GPIO_PIN_DIO1 PA8
/* SX12XX */
#define SOC_GPIO_PIN_RST PB0 /* D9 */
#define SOC_GPIO_PIN_BUSY PB9 /* D7 */
#define SOC_GPIO_PIN_DIO1 PA8 /* D2 */

/* RF antenna switch */
#define SOC_GPIO_PIN_ANT_RXTX SOC_UNUSED_PIN
Expand Down Expand Up @@ -258,6 +258,8 @@ struct rst_info {
#define USE_TIME_SLOTS
#define USE_OGN_ENCRYPTION

#define USE_BASICMAC
//#define EXCLUDE_SX1276 // - kb
#define USE_RADIOLIB
//#define ENABLE_RECORDER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ extern SoftSPI RadioSPI;
#define SPI RadioSPI
#endif /* ARDUINO_ARCH_RENESAS */

#if defined(ARDUINO_ARCH_CH32)
extern SPIClass RadioSPI;
#undef SPI
#define SPI RadioSPI
#endif /* ARDUINO_ARCH_CH32 */

#include "../basicmac.h"
#include "hal.h"
#define _GNU_SOURCE 1 // For fopencookie
Expand Down Expand Up @@ -552,8 +558,8 @@ u1_t hal_checkTimer (u4_t time) {
defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || \
defined(RASPBERRY_PI) || defined(ARDUINO_ARCH_SAMD) || \
defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_ARCH_ASR6601) || \
defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RP2350) || \
defined(ARDUINO_ARCH_RENESAS)
defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RP2350) || \
defined(ARDUINO_ARCH_RENESAS) || defined(ARDUINO_ARCH_CH32)

// Fix for STM32 HAL based cores.

Expand Down

0 comments on commit dd4849c

Please sign in to comment.