Skip to content

Commit

Permalink
[nRF52] further build update
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Jul 11, 2024
1 parent 4819359 commit e3e99e2
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 71 deletions.
2 changes: 2 additions & 0 deletions software/firmware/source/SoftRF/SoftRF.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ enum
IMU_BNO080,
IMU_ICM20948,
IMU_QMI8658,
IMU_BHI260AP,
};

enum
Expand All @@ -268,6 +269,7 @@ enum
MAG_AK09916,
MAG_IIS2MDC,
MAG_QMC6310,
MAG_BMM150,
};

extern ufo_t ThisAircraft;
Expand Down
1 change: 1 addition & 0 deletions software/firmware/source/SoftRF/src/driver/LED.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ enum
DISPLAY_EPD_2_7,
DISPLAY_EPD_1_54,
DISPLAY_EPD_2_13,
DISPLAY_EPD_3_71,
};

void LED_setup();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

/* Peripherals */
#define SOC_GPIO_PIN_CONS_TULTIMA_RX SOC_UNUSED_PIN
#define SOC_GPIO_PIN_CONS_TULTIMA_TX SOC_UNUSED_PIN

#define SOC_GPIO_PIN_GNSS_TULTIMA_RX _PINNUM(1, 7) // P1.07
#define SOC_GPIO_PIN_GNSS_TULTIMA_TX _PINNUM(1, 5) // P1.05

#define SOC_GPIO_PIN_GNSS_TULTIMA_PPS _PINNUM(1, 6) // P1.06
#define SOC_GPIO_PIN_GNSS_TULTIMA_IRQ _PINNUM(1, 4) // P1.04
#define SOC_GPIO_PIN_GNSS_TULTIMA_RST SOC_UNUSED_PIN

/* SPI */
#define SOC_GPIO_PIN_TULTIMA_MOSI _PINNUM(0, 27) // P0.27
#define SOC_GPIO_PIN_TULTIMA_MISO _PINNUM(1, 14) // P0.14
#define SOC_GPIO_PIN_TULTIMA_SCK _PINNUM(0, 3) // P0.03
#define SOC_GPIO_PIN_TULTIMA_SS _PINNUM(0, 23) // P0.23

/* SX1262 or SX1276 */
#define SOC_GPIO_PIN_TULTIMA_RST _PINNUM(0, 25) // P0.25
#define SOC_GPIO_PIN_TULTIMA_DIO1 _PINNUM(0, 15) // P0.15
#define SOC_GPIO_PIN_TULTIMA_BUSY _PINNUM(0, 17) // P0.17

/* I2C */
#define SOC_GPIO_PIN_TULTIMA_SDA _PINNUM(1, 1) // P1.01
#define SOC_GPIO_PIN_TULTIMA_SCL _PINNUM(1, 3) // P1.03

/* buttons */
#define SOC_GPIO_PIN_TULTIMA_BUTTON1 _PINNUM(0, 10) // P0.10
#define SOC_GPIO_PIN_TULTIMA_BUTTON2 _PINNUM(1, 12) // P1.12

/* E-paper */
#define SOC_GPIO_PIN_EPD_TULTIMA_MISO _PINNUM(0, 14) // P0.14
#define SOC_GPIO_PIN_EPD_TULTIMA_MOSI _PINNUM(0, 26) // P0.26
#define SOC_GPIO_PIN_EPD_TULTIMA_SCK _PINNUM(0, 4) // P0.04
#define SOC_GPIO_PIN_EPD_TULTIMA_SS _PINNUM(0, 11) // P0.11
#define SOC_GPIO_PIN_EPD_TULTIMA_DC _PINNUM(0, 7) // P0.07
#define SOC_GPIO_PIN_EPD_TULTIMA_RST _PINNUM(1, 8) // P1.08
#define SOC_GPIO_PIN_EPD_TULTIMA_BUSY _PINNUM(0, 5) // P0.05
#define SOC_GPIO_PIN_EPD_TULTIMA_BLGT _PINNUM(1, 11) // P1.11

/* W25Q128JVPIQ SPI flash */
#define SOC_GPIO_PIN_SFL_TULTIMA_MOSI _PINNUM(1, 10) // P1.10
#define SOC_GPIO_PIN_SFL_TULTIMA_MISO _PINNUM(0, 29) // P0.29
#define SOC_GPIO_PIN_SFL_TULTIMA_SCK _PINNUM(1, 13) // P1.13
#define SOC_GPIO_PIN_SFL_TULTIMA_SS _PINNUM(0, 2) // P0.02
#define SOC_GPIO_PIN_SFL_TULTIMA_HOLD _PINNUM(1, 15) // P1.15
#define SOC_GPIO_PIN_SFL_TULTIMA_WP _PINNUM(0, 31) // P0.31

/* I2S */
#define SOC_GPIO_PIN_I2S_TULTIMA_LRCK _PINNUM(1, 0) // P1.00
#define SOC_GPIO_PIN_I2S_TULTIMA_BCK _PINNUM(0, 24) // P0.24
#define SOC_GPIO_PIN_I2S_TULTIMA_DOUT _PINNUM(0, 22) // P0.22
#define SOC_GPIO_PIN_I2S_TULTIMA_MCK SOC_UNUSED_PIN
81 changes: 47 additions & 34 deletions software/firmware/source/SoftRF/src/platform/nRF52.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,6 @@ static void nRF52_msc_flush_cb (void)
#define WAV_FILE_PREFIX "/Audio/"
#define WAV_FILE_SUFFIX ".wav"

#define SOC_GPIO_PIN_I2S_MCK _PINNUM(0, 6) // P0.06
#define SOC_GPIO_PIN_I2S_LRCK _PINNUM(1, 6) // P1.06
#define SOC_GPIO_PIN_I2S_BCK _PINNUM(0, 8) // P0.08
#define SOC_GPIO_PIN_I2S_DOUT _PINNUM(1, 7) // P1.07

#define I2S_DATA_BLOCK_WORDS 8192

/* these are data structures to process wav file */
Expand Down Expand Up @@ -377,9 +372,9 @@ void I2S_begin(uint8_t pinSDOUT, uint8_t pinSCK, uint8_t pinLRCK, int8_t pinMCK)
// Enable transmission
NRF_I2S->CONFIG.TXEN = (I2S_CONFIG_TXEN_TXEN_ENABLE << I2S_CONFIG_TXEN_TXEN_Pos);
// Enable MCK generator
NRF_I2S->CONFIG.MCKEN = (I2S_CONFIG_MCKEN_MCKEN_ENABLE << I2S_CONFIG_MCKEN_MCKEN_Pos);
NRF_I2S->CONFIG.MCKFREQ = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV11 << I2S_CONFIG_MCKFREQ_MCKFREQ_Pos;
NRF_I2S->CONFIG.RATIO = I2S_CONFIG_RATIO_RATIO_64X << I2S_CONFIG_RATIO_RATIO_Pos;
// NRF_I2S->CONFIG.MCKEN = (I2S_CONFIG_MCKEN_MCKEN_ENABLE << I2S_CONFIG_MCKEN_MCKEN_Pos);
// NRF_I2S->CONFIG.MCKFREQ = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV11 << I2S_CONFIG_MCKFREQ_MCKFREQ_Pos;
// NRF_I2S->CONFIG.RATIO = I2S_CONFIG_RATIO_RATIO_64X << I2S_CONFIG_RATIO_RATIO_Pos;
// Master mode, 16Bit, left aligned
NRF_I2S->CONFIG.MODE = I2S_CONFIG_MODE_MODE_MASTER << I2S_CONFIG_MODE_MODE_Pos;
NRF_I2S->CONFIG.SWIDTH = I2S_CONFIG_SWIDTH_SWIDTH_16BIT << I2S_CONFIG_SWIDTH_SWIDTH_Pos;
Expand All @@ -393,7 +388,7 @@ void I2S_begin(uint8_t pinSDOUT, uint8_t pinSCK, uint8_t pinLRCK, int8_t pinMCK)
NRF_I2S->PSEL.SCK = (pinSCK << I2S_PSEL_SCK_PIN_Pos);
NRF_I2S->PSEL.LRCK = (pinLRCK << I2S_PSEL_LRCK_PIN_Pos);
NRF_I2S->PSEL.SDOUT = (pinSDOUT << I2S_PSEL_SDOUT_PIN_Pos);
NRF_I2S->PSEL.MCK = (pinMCK << I2S_PSEL_MCK_PIN_Pos);
// NRF_I2S->PSEL.MCK = (pinMCK << I2S_PSEL_MCK_PIN_Pos);
}

void I2S_stop()
Expand Down Expand Up @@ -536,10 +531,10 @@ static bool play_file(char *filename)
state = DATA;
}

I2S_begin(SOC_GPIO_PIN_I2S_DOUT,
SOC_GPIO_PIN_I2S_BCK,
SOC_GPIO_PIN_I2S_LRCK,
SOC_GPIO_PIN_I2S_MCK);
I2S_begin(SOC_GPIO_PIN_I2S_TULTIMA_DOUT,
SOC_GPIO_PIN_I2S_TULTIMA_BCK,
SOC_GPIO_PIN_I2S_TULTIMA_LRCK,
SOC_GPIO_PIN_I2S_TULTIMA_MCK);
I2S_setSampleRate(wavProps.sampleRate);
}
break;
Expand Down Expand Up @@ -1044,7 +1039,8 @@ static void nRF52_post_init()
{
if (nRF52_board == NRF52_LILYGO_TECHO_REV_0 ||
nRF52_board == NRF52_LILYGO_TECHO_REV_1 ||
nRF52_board == NRF52_LILYGO_TECHO_REV_2) {
nRF52_board == NRF52_LILYGO_TECHO_REV_2 ||
nRF52_board == NRF52_LILYGO_TULTIMA) {

#if 0
char strbuf[32];
Expand All @@ -1065,7 +1061,9 @@ static void nRF52_post_init()
#endif

Serial.println();
Serial.print (F("LilyGO T-Echo ("));
Serial.print (F("LilyGO T-"));
Serial.print (nRF52_board == NRF52_LILYGO_TULTIMA ? F("Ultima") : F("Echo"));
Serial.print (F(" ("));
Serial.print (hw_info.revision > 2 ?
Hardware_Rev[3] : Hardware_Rev[hw_info.revision]);
Serial.println(F(") Power-on Self Test"));
Expand All @@ -1076,15 +1074,23 @@ static void nRF52_post_init()

Serial.print(F("RADIO : "));
Serial.println(hw_info.rf == RF_IC_SX1262 ||
hw_info.rf == RF_IC_SX1276 ? F("PASS") : F("FAIL"));
hw_info.rf == RF_IC_SX1262 ||
hw_info.rf == RF_IC_LR112X ? F("PASS") : F("FAIL"));
Serial.flush();
Serial.print(F("GNSS : "));
Serial.println(hw_info.gnss == ((hw_info.revision == 0 || hw_info.revision == 1) ?
GNSS_MODULE_GOKE : GNSS_MODULE_AT65)
? F("PASS") : F("FAIL"));
if (nRF52_board == NRF52_LILYGO_TULTIMA) {
Serial.println(hw_info.gnss == GNSS_MODULE_U10 ? F("PASS") : F("FAIL"));
} else if (nRF52_board == NRF52_LILYGO_TECHO_REV_0 ||
nRF52_board == NRF52_LILYGO_TECHO_REV_1) {
Serial.println(hw_info.gnss == GNSS_MODULE_GOKE ? F("PASS") : F("FAIL"));
} else {
Serial.println(hw_info.gnss == GNSS_MODULE_AT65 ? F("PASS") : F("FAIL"));
}

Serial.flush();
Serial.print(F("DISPLAY : "));
Serial.println(hw_info.display == DISPLAY_EPD_1_54 ? F("PASS") : F("FAIL"));
Serial.println(hw_info.display == DISPLAY_EPD_1_54 ||
hw_info.display == DISPLAY_EPD_3_71 ? F("PASS") : F("FAIL"));
Serial.flush();
Serial.print(F("RTC : "));
Serial.println(hw_info.rtc == RTC_PCF8563 ? F("PASS") : F("FAIL"));
Expand All @@ -1094,18 +1100,24 @@ static void nRF52_post_init()
Serial.flush();

if (nRF52_board == NRF52_LILYGO_TECHO_REV_1 ||
nRF52_board == NRF52_LILYGO_TECHO_REV_2) {
nRF52_board == NRF52_LILYGO_TECHO_REV_2 ||
nRF52_board == NRF52_LILYGO_TULTIMA) {
Serial.print(F("BMx280 : "));
Serial.println(hw_info.baro == BARO_MODULE_BMP280 ? F("PASS") : F("N/A"));
Serial.flush();
}

#if !defined(EXCLUDE_IMU)
Serial.println();
Serial.println(F("External components:"));
Serial.print(F("IMU : "));
Serial.println(hw_info.imu == IMU_MPU9250 ||
hw_info.imu == IMU_ICM20948 ? F("PASS") : F("N/A"));
if (nRF52_board != NRF52_LILYGO_TULTIMA) {
Serial.println();
Serial.println(F("External components:"));
Serial.print(F("IMU : "));
Serial.println(hw_info.imu == IMU_MPU9250 ||
hw_info.imu == IMU_ICM20948 ? F("PASS") : F("N/A"));
} else {
Serial.print(F("IMU : "));
Serial.println(hw_info.imu == IMU_BHI260AP ? F("PASS") : F("FAIL"));
}
Serial.flush();
#endif /* EXCLUDE_IMU */

Expand All @@ -1114,16 +1126,17 @@ static void nRF52_post_init()
Serial.println();
Serial.flush();

if (nRF52_board == NRF52_LILYGO_TULTIMA) {
#if defined(USE_EXT_I2S_DAC)
char filename[MAX_FILENAME_LEN];
strcpy(filename, WAV_FILE_PREFIX);
strcat(filename, "POST");
strcat(filename, WAV_FILE_SUFFIX);
if (FATFS_is_mounted && fatfs.exists(filename)) {
play_file(filename);
}
char filename[MAX_FILENAME_LEN];
strcpy(filename, WAV_FILE_PREFIX);
strcat(filename, "POST");
strcat(filename, WAV_FILE_SUFFIX);
if (FATFS_is_mounted && fatfs.exists(filename)) {
play_file(filename);
}
#endif /* USE_EXT_I2S_DAC */

}
} else if (nRF52_board == NRF52_NORDIC_PCA10059) {
Serial.println();
Serial.println(F("Board: Nordic PCA10059 USB Dongle"));
Expand Down
40 changes: 3 additions & 37 deletions software/firmware/source/SoftRF/src/platform/nRF52.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,6 @@ struct rst_info {
#define SOC_GPIO_PIN_GNSS_WKE _PINNUM(1, 2) // P1.02
#define SOC_GPIO_PIN_GNSS_RST _PINNUM(1, 5) // P1.05 (REV_2 only)

#define SOC_GPIO_PIN_GNSS_TULTIMA_RX _PINNUM(1, 7) // P1.07
#define SOC_GPIO_PIN_GNSS_TULTIMA_TX _PINNUM(1, 5) // P1.05

#define SOC_GPIO_PIN_GNSS_TULTIMA_PPS _PINNUM(1, 6) // P1.06
#define SOC_GPIO_PIN_GNSS_TULTIMA_IRQ _PINNUM(1, 4) // P1.04
#define SOC_GPIO_PIN_GNSS_TULTIMA_RST SOC_UNUSED_PIN // TBD

#define SOC_GPIO_PIN_LED SOC_UNUSED_PIN

#define SOC_GPIO_LED_TECHO_REV_0_GREEN _PINNUM(0, 13) // P0.13 (Green)
Expand Down Expand Up @@ -191,11 +184,6 @@ struct rst_info {
#define SOC_GPIO_PIN_WB_SCK _PINNUM(1, 11) // P1.11
#define SOC_GPIO_PIN_WB_SS _PINNUM(1, 10) // P1.10

#define SOC_GPIO_PIN_TULTIMA_MOSI _PINNUM(0, 27) // P0.27
#define SOC_GPIO_PIN_TULTIMA_MISO _PINNUM(1, 14) // P0.14
#define SOC_GPIO_PIN_TULTIMA_SCK _PINNUM(0, 3) // P0.03
#define SOC_GPIO_PIN_TULTIMA_SS _PINNUM(0, 23) // P0.23

/* NRF905 */
#define SOC_GPIO_PIN_TXE SOC_UNUSED_PIN
#define SOC_GPIO_PIN_CE SOC_UNUSED_PIN
Expand All @@ -216,10 +204,6 @@ struct rst_info {
#define SOC_GPIO_PIN_WB_DIO1 _PINNUM(1, 15) // P1.15
#define SOC_GPIO_PIN_WB_BUSY _PINNUM(1, 14) // P1.14

#define SOC_GPIO_PIN_TULTIMA_RST _PINNUM(0, 25) // P0.25
#define SOC_GPIO_PIN_TULTIMA_DIO1 _PINNUM(0, 15) // P0.15
#define SOC_GPIO_PIN_TULTIMA_BUSY _PINNUM(0, 17) // P0.17

/* RF antenna switch */
#define SOC_GPIO_PIN_ANT_RXTX SOC_UNUSED_PIN
#define SOC_GPIO_PIN_WB_TXEN _PINNUM(1, 7) // P1.07
Expand All @@ -229,9 +213,6 @@ struct rst_info {
#define SOC_GPIO_PIN_SDA _PINNUM(0, 26) // P0.26
#define SOC_GPIO_PIN_SCL _PINNUM(0, 27) // P0.27

#define SOC_GPIO_PIN_TULTIMA_SDA _PINNUM(1, 1) // P1.01
#define SOC_GPIO_PIN_TULTIMA_SCL _PINNUM(1, 3) // P1.03

/* buttons */
#define SOC_GPIO_PIN_TECHO_REV_0_BUTTON _PINNUM(1, 10) // P1.10
#define SOC_GPIO_PIN_TECHO_REV_1_BUTTON SOC_GPIO_PIN_TECHO_REV_0_BUTTON
Expand All @@ -253,15 +234,6 @@ struct rst_info {
#define SOC_GPIO_PIN_EPD_BUSY _PINNUM(0, 3) // P0.03
#define SOC_GPIO_PIN_EPD_BLGT _PINNUM(1, 11) // P1.11

#define SOC_GPIO_PIN_EPD_TULTIMA_MISO _PINNUM(0, 14) // P0.14
#define SOC_GPIO_PIN_EPD_TULTIMA_MOSI _PINNUM(0, 26) // P0.26
#define SOC_GPIO_PIN_EPD_TULTIMA_SCK _PINNUM(0, 4) // P0.04
#define SOC_GPIO_PIN_EPD_TULTIMA_SS _PINNUM(0, 11) // P0.11
#define SOC_GPIO_PIN_EPD_TULTIMA_DC _PINNUM(0, 7) // P0.07
#define SOC_GPIO_PIN_EPD_TULTIMA_RST _PINNUM(1, 8) // P1.08
#define SOC_GPIO_PIN_EPD_TULTIMA_BUSY _PINNUM(0, 5) // P0.05
#define SOC_GPIO_PIN_EPD_TULTIMA_BLGT _PINNUM(1, 11) // P1.11

/* Power: EINK, RGB, CN1 (, RF) REV_2: FLASH, GNSS, SENSOR */
#define SOC_GPIO_PIN_IO_PWR _PINNUM(0, 12) // P0.12
/* REV_2 power: RF */
Expand All @@ -277,17 +249,11 @@ struct rst_info {
#define SOC_GPIO_PIN_SFL_HOLD _PINNUM(0, 5) // P0.05 (REV_1 and REV_2)
#define SOC_GPIO_PIN_SFL_WP _PINNUM(0, 7) // P0.07 (REV_1 and REV_2)

/* W25Q128JVPIQ SPI flash */
#define SOC_GPIO_PIN_SFL_TULTIMA_MOSI _PINNUM(1, 10) // P1.10
#define SOC_GPIO_PIN_SFL_TULTIMA_MISO _PINNUM(0, 29) // P0.29
#define SOC_GPIO_PIN_SFL_TULTIMA_SCK _PINNUM(1, 13) // P1.13
#define SOC_GPIO_PIN_SFL_TULTIMA_SS _PINNUM(0, 2) // P0.02
#define SOC_GPIO_PIN_SFL_TULTIMA_HOLD _PINNUM(1, 15) // P1.15
#define SOC_GPIO_PIN_SFL_TULTIMA_WP _PINNUM(0, 31) // P0.31

/* RTC */
#define SOC_GPIO_PIN_R_INT _PINNUM(0, 16) // P0.16

#include "iomap/LilyGO_TUltima.h"

#define EXCLUDE_WIFI
//#define EXCLUDE_OTA
//#define USE_ARDUINO_WIFI
Expand Down Expand Up @@ -359,12 +325,12 @@ struct rst_info {
#if !defined(ARDUINO_ARCH_MBED)
#define USE_BLE_MIDI
#define ENABLE_REMOTE_ID
#define USE_EXT_I2S_DAC
#else
#undef USE_EPAPER
#define EXCLUDE_BLUETOOTH
#define EXCLUDE_IMU
#endif /* ARDUINO_ARCH_MBED */
//#define USE_EXT_I2S_DAC
#define EXCLUDE_PMU

/* FTD-012 data port protocol version 8 and 9 */
Expand Down

0 comments on commit e3e99e2

Please sign in to comment.