Fix compilation errors when UART is disabled

This commit is contained in:
Juan Antonio
2023-12-14 20:04:06 +01:00
committed by egzumer
parent 80fa310646
commit 9dc79ce868
7 changed files with 64 additions and 51 deletions

View File

@@ -37,7 +37,10 @@
#include "app/main.h" #include "app/main.h"
#include "app/menu.h" #include "app/menu.h"
#include "app/scanner.h" #include "app/scanner.h"
#include "app/uart.h" #ifdef ENABLE_UART
#include "app/uart.h"
#include "debugging.h"
#endif
#include "ARMCM0.h" #include "ARMCM0.h"
#include "audio.h" #include "audio.h"
#include "board.h" #include "board.h"
@@ -70,8 +73,6 @@
#include "ui/status.h" #include "ui/status.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "debugging.h"
static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
@@ -1137,23 +1138,25 @@ void APP_TimeSlice10ms(void)
{ {
gFlashLightBlinkCounter++; gFlashLightBlinkCounter++;
#ifdef ENABLE_BOOT_BEEPS #ifdef ENABLE_BOOT_BEEPS
if (boot_counter_10ms > 0) if (boot_counter_10ms > 0 && (boot_counter_10ms % 25) == 0) {
if ((boot_counter_10ms % 25) == 0) AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL); }
#endif #endif
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
if (gRxVfo->Modulation == MODULATION_AM) if (gRxVfo->Modulation == MODULATION_AM) {
AM_fix_10ms(gEeprom.RX_VFO); AM_fix_10ms(gEeprom.RX_VFO);
#endif }
#endif
if (UART_IsCommandAvailable()) #ifdef ENABLE_UART
{ if (UART_IsCommandAvailable()) {
__disable_irq(); __disable_irq();
UART_HandleCommand(); UART_HandleCommand();
__enable_irq(); __enable_irq();
} }
#endif
if (gReducedService) if (gReducedService)
return; return;

10
board.c
View File

@@ -494,10 +494,12 @@ void BOARD_Init(void)
BACKLIGHT_InitHardware(); BACKLIGHT_InitHardware();
BOARD_ADC_Init(); BOARD_ADC_Init();
ST7565_Init(); ST7565_Init();
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
BK1080_Init(0, false); BK1080_Init(0, false);
#endif #endif
#if defined(ENABLE_UART) || defined(ENABLED_AIRCOPY)
CRC_Init(); CRC_Init();
#endif
} }

View File

@@ -1,35 +1,38 @@
#ifndef DEBUGGING_H #ifndef DEBUGGING_H
#define DEBUGGING_H #define DEBUGGING_H
#ifdef ENABLE_UART
#include "driver/uart.h" #include "driver/uart.h"
#include "driver/bk4819.h" #include "driver/bk4819.h"
#include "string.h" #include "string.h"
#include "external/printf/printf.h" #include "external/printf/printf.h"
#include "am_fix.h" #include "am_fix.h"
static inline void LogUart(const char *const str)
static inline void LogUart(const char * const str)
{ {
UART_Send(str, strlen(str)); UART_Send(str, strlen(str));
} }
static inline void LogRegUart(uint16_t reg) static inline void LogRegUart(uint16_t reg)
{ {
uint16_t regVal = BK4819_ReadRegister(reg); uint16_t regVal = BK4819_ReadRegister(reg);
char buf[32]; char buf[32];
sprintf(buf, "reg%02X: %04X\n", reg, regVal); sprintf(buf, "reg%02X: %04X\n", reg, regVal);
LogUart(buf); LogUart(buf);
} }
static inline void LogPrint() static inline void LogPrint()
{ {
uint16_t rssi = BK4819_GetRSSI(); uint16_t rssi = BK4819_GetRSSI();
uint16_t reg7e = BK4819_ReadRegister(0x7E); uint16_t reg7e = BK4819_ReadRegister(0x7E);
char buf[32]; char buf[32];
sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n", sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n", (reg7e >> 15),
(reg7e >> 15), (reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111, (reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi); (reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111,
LogUart(buf); (reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi);
LogUart(buf);
} }
#endif #endif
#endif

View File

@@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
#include "bsp/dp32g030/crc.h" #include "../bsp/dp32g030/crc.h"
#include "driver/crc.h" #include "crc.h"
void CRC_Init(void) void CRC_Init(void)
{ {
@@ -47,4 +47,3 @@ uint16_t CRC_Calculate(const void *pBuffer, uint16_t Size)
return Crc; return Crc;
} }

26
main.c
View File

@@ -31,7 +31,9 @@
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/system.h" #include "driver/system.h"
#include "driver/systick.h" #include "driver/systick.h"
#include "driver/uart.h" #ifdef ENABLE_UART
#include "driver/uart.h"
#endif
#include "helper/battery.h" #include "helper/battery.h"
#include "helper/boot.h" #include "helper/boot.h"
#include "misc.h" #include "misc.h"
@@ -42,16 +44,17 @@
#include "ui/menu.h" #include "ui/menu.h"
#include "version.h" #include "version.h"
void _putchar(char c) void _putchar(__attribute__((unused)) char c)
{ {
#ifdef ENABLE_UART
UART_Send((uint8_t *)&c, 1); UART_Send((uint8_t *)&c, 1);
#endif
} }
void Main(void) void Main(void)
{ {
unsigned int i;
BOOT_Mode_t BootMode;
// Enable clock gating of blocks we need // Enable clock gating of blocks we need
SYSCON_DEV_CLK_GATE = 0 SYSCON_DEV_CLK_GATE = 0
| SYSCON_DEV_CLK_GATE_GPIOA_BITS_ENABLE | SYSCON_DEV_CLK_GATE_GPIOA_BITS_ENABLE
@@ -66,11 +69,13 @@ void Main(void)
SYSTICK_Init(); SYSTICK_Init();
BOARD_Init(); BOARD_Init();
UART_Init();
boot_counter_10ms = 250; // 2.5 sec boot_counter_10ms = 250; // 2.5 sec
#ifdef ENABLE_UART
UART_Init();
UART_Send(UART_Version, strlen(UART_Version)); UART_Send(UART_Version, strlen(UART_Version));
#endif
// Not implementing authentic device checks // Not implementing authentic device checks
@@ -92,7 +97,7 @@ void Main(void)
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
for (i = 0; i < ARRAY_SIZE(gBatteryVoltages); i++) for (unsigned int i = 0; i < ARRAY_SIZE(gBatteryVoltages); i++)
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent); BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent);
BATTERY_GetReadings(false); BATTERY_GetReadings(false);
@@ -101,7 +106,7 @@ void Main(void)
AM_fix_init(); AM_fix_init();
#endif #endif
BootMode = BOOT_GetMode(); const BOOT_Mode_t BootMode = BOOT_GetMode();
if (BootMode == BOOT_MODE_F_LOCK) if (BootMode == BOOT_MODE_F_LOCK)
{ {
@@ -124,8 +129,9 @@ void Main(void)
{ // keys are pressed { // keys are pressed
UI_DisplayReleaseKeys(); UI_DisplayReleaseKeys();
BACKLIGHT_TurnOn(); BACKLIGHT_TurnOn();
i = 0;
while (i < 50) // 500ms // 500ms
for (int i = 0; i < 50;)
{ {
i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0; i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0;
SYSTEM_DelayMs(10); SYSTEM_DelayMs(10);

View File

@@ -22,7 +22,6 @@
#endif #endif
#include "driver/bk4819.h" #include "driver/bk4819.h"
#include "driver/eeprom.h" #include "driver/eeprom.h"
#include "driver/uart.h"
#include "misc.h" #include "misc.h"
#include "settings.h" #include "settings.h"
#include "ui/menu.h" #include "ui/menu.h"

View File

@@ -143,13 +143,14 @@ void UI_DisplayLock(void)
gKeyReading0 = Key; gKeyReading0 = Key;
} }
#ifdef ENABLE_UART
if (UART_IsCommandAvailable()) if (UART_IsCommandAvailable())
{ {
__disable_irq(); __disable_irq();
UART_HandleCommand(); UART_HandleCommand();
__enable_irq(); __enable_irq();
} }
#endif
if (gUpdateDisplay) if (gUpdateDisplay)
{ {
Render(); Render();