Skip to content

Commit

Permalink
Academy: bringup of Arduino Uno R4 WiFi
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Mar 16, 2024
1 parent 47e12e5 commit e638893
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 29 deletions.
24 changes: 18 additions & 6 deletions software/firmware/source/SoftRF/src/platform/RA4M1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ static bool RA4M1_EEPROM_begin(size_t size)

static void RA4M1_EEPROM_extension(int cmd)
{
#if defined(ARDUINO_UNOR4_WIFI)
if (cmd == EEPROM_EXT_DEFAULTS) {
settings->nmea_out = NMEA_UART;
}
#endif /* ARDUINO_UNOR4_WIFI */

if (cmd == EEPROM_EXT_LOAD) {
if (settings->mode != SOFTRF_MODE_NORMAL
#if !defined(EXCLUDE_TEST_MODE)
Expand All @@ -411,6 +417,7 @@ static void RA4M1_EEPROM_extension(int cmd)
settings->mode = SOFTRF_MODE_NORMAL;
}

#if defined(ARDUINO_UNOR4_MINIMA)
if (settings->nmea_out == NMEA_BLUETOOTH ||
settings->nmea_out == NMEA_UDP ||
settings->nmea_out == NMEA_TCP ) {
Expand All @@ -424,18 +431,17 @@ static void RA4M1_EEPROM_extension(int cmd)
settings->d1090 == D1090_UDP) {
settings->d1090 = D1090_USB;
}

#if defined(USE_USB_HOST)
if (settings->nmea_out != NMEA_OFF) {
#elif defined(ARDUINO_UNOR4_WIFI)
if (settings->nmea_out == NMEA_USB) {
settings->nmea_out = NMEA_UART;
}
if (settings->gdl90 != GDL90_OFF) {
if (settings->gdl90 == GDL90_USB) {
settings->gdl90 = GDL90_UART;
}
if (settings->d1090 != D1090_OFF) {
if (settings->d1090 == D1090_USB) {
settings->d1090 = D1090_UART;
}
#endif /* USE_USB_HOST */
#endif

/* AUTO and UK RF bands are deprecated since Release v1.3 */
if (settings->band == RF_BAND_AUTO || settings->band == RF_BAND_UK) {
Expand Down Expand Up @@ -666,6 +672,7 @@ static void RA4M1_Button_fini()
#endif /* SOC_GPIO_PIN_BUTTON != SOC_UNUSED_PIN */
}

#if !defined(ARDUINO_UNOR4_WIFI)
static void RA4M1_USB_setup()
{
if (USBSerial && USBSerial != Serial) {
Expand Down Expand Up @@ -847,6 +854,7 @@ IODev_ops_t RA4M1_USBSerial_ops = {
RA4M1_USB_read,
RA4M1_USB_write
};
#endif /* ARDUINO_UNOR4_WIFI */

const SoC_ops_t RA4M1_ops = {
SOC_RA4M1,
Expand Down Expand Up @@ -880,7 +888,11 @@ const SoC_ops_t RA4M1_ops = {
#else
NULL,
#endif /* EXCLUDE_BLUETOOTH */
#if !defined(ARDUINO_UNOR4_WIFI)
&RA4M1_USBSerial_ops,
#else
NULL,
#endif /* ARDUINO_UNOR4_WIFI */
NULL,
RA4M1_Display_setup,
RA4M1_Display_loop,
Expand Down
7 changes: 4 additions & 3 deletions software/firmware/source/SoftRF/src/platform/RA4M1.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
#define SerialOutput SerialUSB
#define Serial_GNSS_In Serial1
#elif defined(ARDUINO_UNOR4_WIFI)
#define SerialOutput Serial1
#define Serial_GNSS_In Serial2
#define SerialOutput Serial
#define Serial_GNSS_In Serial1
#else
#error "This Renesas R7FA4M1 build variant is not supported!"
#endif
Expand Down Expand Up @@ -138,7 +138,8 @@ struct rst_info {
#define USE_WIFI_CUSTOM true
#include <WiFiS3.h>
#define Serial_setDebugOutput(x) ({})
//#define EXCLUDE_BLUETOOTH
#define EXCLUDE_BLUETOOTH
#define EXCLUDE_SOFTRF_HEARTBEAT
#endif

#define EXCLUDE_CC13XX
Expand Down
21 changes: 14 additions & 7 deletions software/firmware/source/libraries/CRC/lib_crc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#endif

#if defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_AVR)
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_AVR) || \
defined(ARDUINO_ARCH_RENESAS)
#include <avr/pgmspace.h>
#endif

Expand Down Expand Up @@ -111,7 +112,8 @@ static unsigned short crc_tabkermit[256];
#if !defined(ESP8266) && !defined(__ASR6501__) && \
!defined(ARDUINO_ARCH_ASR650X) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(ARDUINO_ARCH_STM32) && !defined(ARDUINO_ARCH_AVR)
!defined(ARDUINO_ARCH_STM32) && !defined(ARDUINO_ARCH_AVR) && \
!defined(ARDUINO_ARCH_RENESAS)
static unsigned short crc_tabccitt[256];
#else
static const unsigned short crc_tabccitt[256] PROGMEM = {
Expand Down Expand Up @@ -190,7 +192,8 @@ unsigned short update_crc_ccitt( unsigned short crc, char c ) {
#if defined(ESP8266) || defined(__ASR6501__) || \
defined(ARDUINO_ARCH_ASR650X) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_AVR)
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_AVR) || \
defined(ARDUINO_ARCH_RENESAS)
crc = (crc << 8) ^ pgm_read_word(&crc_tabccitt[tmp]);
#else
crc = (crc << 8) ^ crc_tabccitt[tmp];
Expand Down Expand Up @@ -495,7 +498,8 @@ static void init_crcccitt_tab( void ) {
#if !defined(ESP8266) && !defined(__ASR6501__) && \
!defined(ARDUINO_ARCH_ASR650X) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(ARDUINO_ARCH_STM32) && !defined(ARDUINO_ARCH_AVR)
!defined(ARDUINO_ARCH_STM32) && !defined(ARDUINO_ARCH_AVR) && \
!defined(ARDUINO_ARCH_RENESAS)
int i, j;
unsigned short crc, c;

Expand Down Expand Up @@ -531,7 +535,8 @@ unsigned short update_crc_gdl90( unsigned short crc, char c ) {
tmp = (crc >> 8) ;
#if defined(ESP8266) || defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_AVR)
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_AVR) || \
defined(ARDUINO_ARCH_RENESAS)
crc = pgm_read_word(&crc_tabccitt[tmp]) ^ (crc << 8) ^ short_c;
#else
crc = crc_tabccitt[tmp] ^ (crc << 8) ^ short_c;
Expand All @@ -552,7 +557,8 @@ static const unsigned char crc8_table[256]
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || \
defined(ARDUINO_ARCH_ASR650X) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_AVR)
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_AVR) || \
defined(ARDUINO_ARCH_RENESAS)
PROGMEM
#endif
= {
Expand Down Expand Up @@ -590,7 +596,8 @@ void update_crc8(unsigned char *crc, unsigned char m)
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || \
defined(ARDUINO_ARCH_ASR650X) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_AVR)
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_AVR) || \
defined(ARDUINO_ARCH_RENESAS)
*crc = pgm_read_byte(&crc8_table[(*crc) ^ m]);
#else
*crc = crc8_table[(*crc) ^ m];
Expand Down
18 changes: 12 additions & 6 deletions software/firmware/source/libraries/OGN/ldpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
#include <math.h>
#endif

#if defined(__AVR__) || defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
#if defined(__AVR__) || defined(ENERGIA_ARCH_CC13XX) || \
defined(ENERGIA_ARCH_CC13X2) || defined(ARDUINO_ARCH_RENESAS)
#include <avr/pgmspace.h>
#endif

#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X)
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || \
defined(ARDUINO_ARCH_ASR650X)
#include <pgmspace.h>
#endif

Expand All @@ -23,7 +25,8 @@
static const uint32_t LDPC_ParityCheck_n208k160[48][7]
#if defined(__AVR__) || defined(ESP8266) || defined(ESP32) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X)
defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || \
defined(ARDUINO_ARCH_RENESAS)
PROGMEM
#endif
= { // parity check vectors: 48 vectors for 48 parity checks
Expand Down Expand Up @@ -150,7 +153,8 @@ PROGMEM
static const uint32_t LDPC_ParityGen_n208k160[48][5]
#if defined(__AVR__) || defined(ESP8266) || defined(ESP32) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X)
defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || \
defined(ARDUINO_ARCH_RENESAS)
PROGMEM
#endif
= { // Parity bits generator: 48 vectors to generate 48 parity bits
Expand Down Expand Up @@ -697,7 +701,8 @@ static void LDPC_Encode(const uint32_t *Data, uint32_t *Parity, uint8_t DataWord
{ uint8_t Count=0;
for(uint8_t Idx=0; Idx<DataWords; Idx++)
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_RENESAS)
{ Count+=Count1s(Data[Idx] & (uint32_t) pgm_read_dword(Gen+Idx)); }
#else
{ Count+=Count1s(Data[Idx]&Gen[Idx]); }
Expand Down Expand Up @@ -739,7 +744,8 @@ uint8_t LDPC_Check(const uint8_t *Data) // 20 data bytes followed by 6 parity by
const uint8_t *Check = (uint8_t *)LDPC_ParityCheck_n208k160[Row];
for(uint8_t Idx=0; Idx<26; Idx++)
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_RENESAS)
{ uint8_t And = Data[Idx]&pgm_read_byte(Check+Idx); Count+=Count1s(And); }
#else
{ uint8_t And = Data[Idx]&Check[Idx]; Count+=Count1s(And); }
Expand Down
13 changes: 8 additions & 5 deletions software/firmware/source/libraries/adsb_encoder/adsb_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
#if !defined(ESP8266) && !defined(ESP32) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(__ASR6501__) && !defined(ARDUINO_ARCH_STM32) && \
!defined(ARDUINO_ARCH_ASR650X)
!defined(ARDUINO_ARCH_ASR650X) && !defined(ARDUINO_ARCH_RENESAS)
static unsigned int crc_table[256];
#else
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X)
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || \
defined(ARDUINO_ARCH_ASR650X)
#include <pgmspace.h>
#endif

#if defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32)
defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_RENESAS)
#include <avr/pgmspace.h>
#endif

Expand Down Expand Up @@ -76,7 +77,8 @@ unsigned int modes_crc(unsigned char *buf, size_t len)
for (rem = 0, i = len; i > 0; --i) {
#if !defined(ESP8266) && !defined(ESP32) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(__ASR6501__) && !defined(ARDUINO_ARCH_STM32) && !defined(ARDUINO_ARCH_ASR650X)
!defined(__ASR6501__) && !defined(ARDUINO_ARCH_STM32) && \
!defined(ARDUINO_ARCH_ASR650X) && !defined(ARDUINO_ARCH_RENESAS)
rem = ((rem & 0x00ffff) << 8) ^ crc_table[*buf++ ^ ((rem & 0xff0000) >> 16)];
#else
rem = ((rem & 0x00ffff) << 8) ^ pgm_read_dword(&crc_table[*buf++ ^ ((rem & 0xff0000) >> 16)]);
Expand Down Expand Up @@ -634,7 +636,8 @@ int modescrc_module_init()
{
#if !defined(ESP8266) && !defined(ESP32) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(__ASR6501__) && !defined(ARDUINO_ARCH_STM32) && !defined(ARDUINO_ARCH_ASR650X)
!defined(__ASR6501__) && !defined(ARDUINO_ARCH_STM32) && \
!defined(ARDUINO_ARCH_ASR650X) && !defined(ARDUINO_ARCH_RENESAS)
int i;

for (i = 0; i < 256; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ 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_RP2040) || defined(ARDUINO_ARCH_RENESAS)

// Fix for STM32 HAL based cores.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ u1_t hal_checkTimer (u4_t time) {
return delta_time(time) <= 0;
}

#if defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_SAMD)
#if defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_SAMD) || \
defined(ARDUINO_ARCH_RENESAS)

// Fix for STM32 HAL based cores.

Expand Down

1 comment on commit e638893

@lyusupov
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Please sign in to comment.