Skip to content

Commit

Permalink
Fix compilation errors when UART is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
JuantAldea authored and egzumer committed Dec 14, 2023
1 parent 80fa310 commit 9dc79ce
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 51 deletions.
31 changes: 17 additions & 14 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
#include "app/main.h"
#include "app/menu.h"
#include "app/scanner.h"
#include "app/uart.h"
#ifdef ENABLE_UART
#include "app/uart.h"
#include "debugging.h"
#endif
#include "ARMCM0.h"
#include "audio.h"
#include "board.h"
Expand Down Expand Up @@ -70,8 +73,6 @@
#include "ui/status.h"
#include "ui/ui.h"

#include "debugging.h"

static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);


Expand Down Expand Up @@ -1137,23 +1138,25 @@ void APP_TimeSlice10ms(void)
{
gFlashLightBlinkCounter++;

#ifdef ENABLE_BOOT_BEEPS
if (boot_counter_10ms > 0)
if ((boot_counter_10ms % 25) == 0)
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
#endif
#ifdef ENABLE_BOOT_BEEPS
if (boot_counter_10ms > 0 && (boot_counter_10ms % 25) == 0) {
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
}
#endif

#ifdef ENABLE_AM_FIX
if (gRxVfo->Modulation == MODULATION_AM)
AM_fix_10ms(gEeprom.RX_VFO);
#endif
#ifdef ENABLE_AM_FIX
if (gRxVfo->Modulation == MODULATION_AM) {
AM_fix_10ms(gEeprom.RX_VFO);
}
#endif

if (UART_IsCommandAvailable())
{
#ifdef ENABLE_UART
if (UART_IsCommandAvailable()) {
__disable_irq();
UART_HandleCommand();
__enable_irq();
}
#endif

if (gReducedService)
return;
Expand Down
14 changes: 8 additions & 6 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
FLASH_Init(FLASH_READ_MODE_1_CYCLE);
FLASH_ConfigureTrimValues();
SYSTEM_ConfigureClocks();

overlay_FLASH_MainClock = 48000000;
overlay_FLASH_ClockMultiplier = 48;

FLASH_Init(FLASH_READ_MODE_2_CYCLE);
}
#endif
Expand Down Expand Up @@ -494,10 +494,12 @@ void BOARD_Init(void)
BACKLIGHT_InitHardware();
BOARD_ADC_Init();
ST7565_Init();
#ifdef ENABLE_FMRADIO
#ifdef ENABLE_FMRADIO
BK1080_Init(0, false);
#endif
CRC_Init();
}
#endif

#if defined(ENABLE_UART) || defined(ENABLED_AIRCOPY)
CRC_Init();
#endif

}
33 changes: 18 additions & 15 deletions debugging.h
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
#ifndef DEBUGGING_H
#define DEBUGGING_H

#ifdef ENABLE_UART

#include "driver/uart.h"
#include "driver/bk4819.h"
#include "string.h"
#include "external/printf/printf.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)
{
uint16_t regVal = BK4819_ReadRegister(reg);
char buf[32];
sprintf(buf, "reg%02X: %04X\n", reg, regVal);
LogUart(buf);
uint16_t regVal = BK4819_ReadRegister(reg);
char buf[32];
sprintf(buf, "reg%02X: %04X\n", reg, regVal);
LogUart(buf);
}


static inline void LogPrint()
{
uint16_t rssi = BK4819_GetRSSI();
uint16_t reg7e = BK4819_ReadRegister(0x7E);
char buf[32];
sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n",
(reg7e >> 15), (reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111, (reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi);
LogUart(buf);
uint16_t rssi = BK4819_GetRSSI();
uint16_t reg7e = BK4819_ReadRegister(0x7E);
char buf[32];
sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n", (reg7e >> 15),
(reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111,
(reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi);
LogUart(buf);
}

#endif
#endif

#endif
5 changes: 2 additions & 3 deletions driver/crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#include "bsp/dp32g030/crc.h"
#include "driver/crc.h"
#include "../bsp/dp32g030/crc.h"
#include "crc.h"

void CRC_Init(void)
{
Expand Down Expand Up @@ -47,4 +47,3 @@ uint16_t CRC_Calculate(const void *pBuffer, uint16_t Size)

return Crc;
}

28 changes: 17 additions & 11 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
#include "driver/gpio.h"
#include "driver/system.h"
#include "driver/systick.h"
#include "driver/uart.h"
#ifdef ENABLE_UART
#include "driver/uart.h"
#endif
#include "helper/battery.h"
#include "helper/boot.h"
#include "misc.h"
Expand All @@ -42,16 +44,17 @@
#include "ui/menu.h"
#include "version.h"

void _putchar(char c)
void _putchar(__attribute__((unused)) char c)
{

#ifdef ENABLE_UART
UART_Send((uint8_t *)&c, 1);
#endif

}

void Main(void)
{
unsigned int i;
BOOT_Mode_t BootMode;

// Enable clock gating of blocks we need
SYSCON_DEV_CLK_GATE = 0
| SYSCON_DEV_CLK_GATE_GPIOA_BITS_ENABLE
Expand All @@ -66,11 +69,13 @@ void Main(void)

SYSTICK_Init();
BOARD_Init();
UART_Init();

boot_counter_10ms = 250; // 2.5 sec

#ifdef ENABLE_UART
UART_Init();
UART_Send(UART_Version, strlen(UART_Version));
#endif

// Not implementing authentic device checks

Expand All @@ -92,7 +97,7 @@ void Main(void)

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);

BATTERY_GetReadings(false);
Expand All @@ -101,8 +106,8 @@ void Main(void)
AM_fix_init();
#endif

BootMode = BOOT_GetMode();
const BOOT_Mode_t BootMode = BOOT_GetMode();

if (BootMode == BOOT_MODE_F_LOCK)
{
gF_LOCK = true; // flag to say include the hidden menu items
Expand All @@ -124,8 +129,9 @@ void Main(void)
{ // keys are pressed
UI_DisplayReleaseKeys();
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;
SYSTEM_DelayMs(10);
Expand Down
1 change: 0 additions & 1 deletion settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#endif
#include "driver/bk4819.h"
#include "driver/eeprom.h"
#include "driver/uart.h"
#include "misc.h"
#include "settings.h"
#include "ui/menu.h"
Expand Down
3 changes: 2 additions & 1 deletion ui/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ void UI_DisplayLock(void)
gKeyReading0 = Key;
}

#ifdef ENABLE_UART
if (UART_IsCommandAvailable())
{
__disable_irq();
UART_HandleCommand();
__enable_irq();
}

#endif
if (gUpdateDisplay)
{
Render();
Expand Down

0 comments on commit 9dc79ce

Please sign in to comment.