Skip to content

Commit

Permalink
Academy: add 'Uno R4 WiFi' board as one more of the Actions CI build …
Browse files Browse the repository at this point in the history
…targets
  • Loading branch information
lyusupov committed Feb 21, 2024
1 parent 824e405 commit 3cdda56
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 72 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
'arduino:samd:mzero_bl',
'arduino:avr:mega',
'arduino:renesas_uno:minima',
'arduino:renesas_uno:unor4wifi',
'rp2040:rp2040:generic',
'rp2040:rp2040:rpipicow'
]
Expand Down
23 changes: 17 additions & 6 deletions software/firmware/source/SoftRF/src/platform/ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,14 +1162,25 @@ static void ESP32_setup()

// axp_2xxx.enableDC1();

axp_2xxx.enableALDO2();
axp_2xxx.enableALDO4();
axp_2xxx.enableALDO2(); // Rev2.x - micro-SD Card LDO
axp_2xxx.enableALDO4(); // Rev2.x - GNSS LDO

axp_2xxx.enableBLDO1();
axp_2xxx.enableBLDO1(); // Rev2.x - Microphone LDO

axp_2xxx.disableBLDO2();
axp_2xxx.disableALDO3();
axp_2xxx.disableDC3();
axp_2xxx.disableBLDO2(); // Rev2.1 - SA8x8 DC boost , Rev2.0 - user LDO
axp_2xxx.disableALDO3(); // Rev2.1 - Audio amp. switch , Rev2.0 - user LDO
axp_2xxx.disableDLDO1(); // Rev2.1 - Download switch control
axp_2xxx.disableDC3(); // Rev2.0 - SA8x8 DC boost , Rev2.1 - user LDO

// The following supply voltages can be controlled by the user
axp_2xxx.disableALDO1();
axp_2xxx.disableDC5();

// The following power supplies are unavailable
axp_2xxx.disableDC2();
axp_2xxx.disableDC4();
axp_2xxx.disableCPUSLDO();
axp_2xxx.disableDLDO2();

axp_2xxx.setChargingLedMode(XPOWERS_CHG_LED_ON);

Expand Down
52 changes: 43 additions & 9 deletions software/firmware/source/SoftRF/src/platform/RA4M1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@
#include "../protocol/data/GDL90.h"
#include "../protocol/data/D1090.h"

#include <WDT.h>

#if !defined(ARDUINO_ARCH_RENESAS_UNO)
#error "ARDUINO UNO is the only one supported at this time"
#endif

typedef volatile uint32_t REG32;
#define pREG32 (REG32 *)

#define DEVICE_ID_HIGH (*(pREG32 (0x0080A044)))
#define DEVICE_ID_LOW (*(pREG32 (0x0080A048)))

// SX127x pin mapping
lmic_pinmap lmic_pins = {
.nss = SOC_GPIO_PIN_SS,
Expand Down Expand Up @@ -126,6 +122,35 @@ ACM AcmSerial(&UsbH, &AsyncOper);

static void RA4M1_setup()
{
if (1U == R_SYSTEM->RSTSR0_b.PORF) /* Power on Reset */
{
reset_info.reason = REASON_DEFAULT_RST;
}
else if (1U == R_SYSTEM->RSTSR1_b.IWDTRF) /* Independent WDT Reset */
{
reset_info.reason = REASON_WDT_RST;
}
else if (1U == R_SYSTEM->RSTSR1_b.WDTRF) /* Watchdog Timer Reset */
{
reset_info.reason = REASON_WDT_RST;
}
else if (1U == R_SYSTEM->RSTSR0_b.LVD0RF) /* Voltage monitor Reset */
{
reset_info.reason = REASON_WDT_RST;
}
else if (1U == R_SYSTEM->RSTSR0_b.DPSRSTF) /* Deep Software Standby Reset */
{
reset_info.reason = REASON_DEEP_SLEEP_AWAKE;
}
else if (1U == R_SYSTEM->RSTSR1_b.SWRF) /* Software Reset */
{
reset_info.reason = REASON_SOFT_RESTART;
}
else if (1U == R_SYSTEM->RSTSR2_b.CWSF) /* Warm start */
{
reset_info.reason = REASON_EXT_SYS_RST;
}

#if SOC_GPIO_RADIO_LED_TX != SOC_UNUSED_PIN
pinMode(SOC_GPIO_RADIO_LED_TX, OUTPUT);
digitalWrite(SOC_GPIO_RADIO_LED_TX, ! LED_STATE_ON);
Expand Down Expand Up @@ -227,6 +252,10 @@ static unsigned long rx_led_time_marker = 0;

static void RA4M1_loop()
{
if (wdt_is_active) {
WDT.refresh();
}

#if SOC_GPIO_RADIO_LED_TX != SOC_UNUSED_PIN
if (digitalRead(SOC_GPIO_RADIO_LED_TX) != LED_STATE_ON) {
if (tx_packets_counter != prev_tx_packets_counter) {
Expand Down Expand Up @@ -276,7 +305,8 @@ static void RA4M1_reset()
static uint32_t RA4M1_getChipId()
{
#if !defined(SOFTRF_ADDRESS)
uint32_t id = DEVICE_ID_LOW;
const bsp_unique_id_t* t = R_BSP_UniqueIdGet();
uint32_t id = t->unique_id_words[3];

return DevID_Mapper(id);
#else
Expand Down Expand Up @@ -533,12 +563,16 @@ static void RA4M1_UATModule_restart()

static void RA4M1_WDT_setup()
{
/* TBD */
WDT.begin(5000);
wdt_is_active = true;
}

static void RA4M1_WDT_fini()
{
/* TBD */
if (wdt_is_active) {
WDT.refresh(); /* TODO */
wdt_is_active = false;
}
}

#if SOC_GPIO_PIN_BUTTON != SOC_UNUSED_PIN
Expand Down
91 changes: 34 additions & 57 deletions software/firmware/source/SoftRF/src/platform/RA4M1.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@

#define LED_STATE_ON LOW // State when LED is litted

#if defined(ARDUINO_UNOR4_MINIMA)
#define SerialOutput SerialUSB
//#define SerialOutput Serial1
#define Serial_GNSS_In Serial1
#elif defined(ARDUINO_UNOR4_WIFI)
#define SerialOutput Serial1
#define Serial_GNSS_In Serial2
#else
#error "This Renesas R7FA4M1 build variant is not supported!"
#endif

#define USBSerial SerialUSB
#define Serial_GNSS_In Serial1
#define Serial_GNSS_Out Serial_GNSS_In
#define UATSerial SerialUSB

Expand All @@ -70,78 +76,64 @@ struct rst_info {
uint32_t depc;
};

#if defined(ARDUINO_UNOR4_MINIMA)

/* Peripherals */
#define SOC_GPIO_PIN_CONS_RX PIN_SERIAL_RX // PB23
#define SOC_GPIO_PIN_CONS_TX PIN_SERIAL_TX // PB22
#if defined(ARDUINO_UNOR4_WIFI)
#define SOC_GPIO_PIN_CONS_RX UART1_RX_PIN
#define SOC_GPIO_PIN_CONS_TX UART1_TX_PIN

#define SOC_GPIO_PIN_GNSS_RX PIN_SERIAL1_RX // PA11
#define SOC_GPIO_PIN_GNSS_TX PIN_SERIAL1_TX // PA10
#define SOC_GPIO_PIN_GNSS_RX UART2_RX_PIN
#define SOC_GPIO_PIN_GNSS_TX UART2_TX_PIN
#else
#define SOC_GPIO_PIN_CONS_RX 23 /* TBD */
#define SOC_GPIO_PIN_CONS_TX 22 /* TBD */

#define USE_ISP_PORT 1
#define SOC_GPIO_PIN_GNSS_RX UART1_RX_PIN
#define SOC_GPIO_PIN_GNSS_TX UART1_TX_PIN
#endif /* ARDUINO_UNOR4_WIFI */

#if USE_ISP_PORT
#define SOC_GPIO_PIN_STATUS LED_BUILTIN // PA17
#else
#define SOC_GPIO_PIN_STATUS PIN_LED_RXL // PB03
#endif /* USE_ISP_PORT */
#define SOC_GPIO_PIN_STATUS LED_BUILTIN
#define SOC_GPIO_PIN_BUZZER SOC_UNUSED_PIN

#define SOC_GPIO_PIN_RX3 SOC_UNUSED_PIN
#define SOC_GPIO_PIN_TX3 SOC_UNUSED_PIN

/* SPI */
#if USE_ISP_PORT
/* ISP port */
#define SOC_GPIO_PIN_MOSI PIN_SPI_MOSI // PB10
#define SOC_GPIO_PIN_MISO PIN_SPI_MISO // PB12
#define SOC_GPIO_PIN_SCK PIN_SPI_SCK // PB11
#else
/* Port B */
#define SOC_GPIO_PIN_MOSI 11 // PA16
#define SOC_GPIO_PIN_MISO 12 // PA19
#define SOC_GPIO_PIN_SCK 13 // PA17
#endif /* USE_ISP_PORT */
#define SOC_GPIO_PIN_SS 10 // PA18
//#define SOC_GPIO_PIN_SS 4 // NL
//#define SOC_GPIO_PIN_SS 5 // NL
#define SOC_GPIO_PIN_MOSI PIN_SPI_MOSI
#define SOC_GPIO_PIN_MISO PIN_SPI_MISO
#define SOC_GPIO_PIN_SCK PIN_SPI_SCK
#define SOC_GPIO_PIN_SS PIN_SPI_CS

/* NRF905 */
#define SOC_GPIO_PIN_TXE SOC_UNUSED_PIN
#define SOC_GPIO_PIN_CE SOC_UNUSED_PIN
#define SOC_GPIO_PIN_PWR SOC_UNUSED_PIN

/* SX1276 */
#define SOC_GPIO_PIN_RST 9 // PA07
#define SOC_GPIO_PIN_RST PIN_D9
#define SOC_GPIO_PIN_BUSY SOC_UNUSED_PIN
#define SOC_GPIO_PIN_DIO1 6 // PA20
#define SOC_GPIO_PIN_DIO1 PIN_D6

/* RF antenna switch */
#define SOC_GPIO_PIN_ANT_RXTX SOC_UNUSED_PIN

/* I2C */
#define SOC_GPIO_PIN_SDA PIN_WIRE_SDA // PA22
#define SOC_GPIO_PIN_SCL PIN_WIRE_SCL // PA23
#define SOC_GPIO_PIN_SDA WIRE_SDA_PIN
#define SOC_GPIO_PIN_SCL WIRE_SCL_PIN

#define SOC_GPIO_PIN_LED SOC_UNUSED_PIN
#define SOC_GPIO_PIN_GNSS_PPS PIN_A3 // PA04
#define SOC_GPIO_PIN_BATTERY PIN_A0 // PA02
#define SOC_GPIO_PIN_GNSS_PPS PIN_A3
#define SOC_GPIO_PIN_BATTERY PIN_A0
#define SOC_GPIO_PIN_BUTTON SOC_UNUSED_PIN

#if defined(USE_TINYUSB)
#define SOC_GPIO_RADIO_LED_RX PIN_LED_RXL
#define SOC_GPIO_RADIO_LED_TX PIN_LED_TXL
#else
#define SOC_GPIO_RADIO_LED_RX SOC_UNUSED_PIN
#define SOC_GPIO_RADIO_LED_TX SOC_UNUSED_PIN
#endif /* USE_TINYUSB */

#else
#error "This RA4M1 build variant is not supported!"
#if defined(ARDUINO_UNOR4_MINIMA)
#define EXCLUDE_WIFI
#elif defined(ARDUINO_UNOR4_WIFI)
#define EXCLUDE_WIFI /* TODO */
#endif

#define EXCLUDE_WIFI
#define EXCLUDE_CC13XX
#define EXCLUDE_TEST_MODE
#define EXCLUDE_WATCHOUT_MODE
Expand Down Expand Up @@ -186,20 +178,5 @@ extern Adafruit_NeoPixel strip;
#define U8X8_OLED_I2C_BUS_TYPE U8X8_SSD1306_128X64_NONAME_HW_I2C
#endif /* USE_OLED */

#if defined(USE_USB_HOST)

#if defined(Serial)
#undef Serial
#endif
#define Serial Serial1

#if defined(SerialOutput)
#undef SerialOutput
#endif
#define SerialOutput Serial1

#endif /* USE_USB_HOST */

#endif /* PLATFORM_RA4M1_H */

#endif /* ARDUINO_ARCH_RENESAS */

0 comments on commit 3cdda56

Please sign in to comment.