Ability to disable AIRCOPY, overlay and UART.

This commit is contained in:
Dual Tachyon 2023-09-13 21:26:18 +01:00
parent 1ce3c5ff94
commit 779449ca50
16 changed files with 137 additions and 5 deletions

View File

@ -1,5 +1,9 @@
TARGET = firmware
ENABLE_AIRCOPY := 1
ENABLE_OVERLAY := 1
ENABLE_UART := 1
BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
@ -8,18 +12,26 @@ OBJS =
# Startup files
OBJS += start.o
OBJS += init.o
ifeq ($(ENABLE_OVERLAY),1)
OBJS += sram-overlay.o
endif
OBJS += external/printf/printf.o
# Drivers
OBJS += driver/adc.o
ifeq ($(ENABLE_UART),1)
OBJS += driver/aes.o
endif
OBJS += driver/backlight.o
OBJS += driver/bk1080.o
OBJS += driver/bk4819.o
ifeq ($(filter $(ENABLE_AIRCOPY) $(ENABLE_UART),1),1)
OBJS += driver/crc.o
endif
OBJS += driver/eeprom.o
ifeq ($(ENABLE_OVERLAY),1)
OBJS += driver/flash.o
endif
OBJS += driver/gpio.o
OBJS += driver/i2c.o
OBJS += driver/keyboard.o
@ -27,11 +39,15 @@ OBJS += driver/spi.o
OBJS += driver/st7565.o
OBJS += driver/system.o
OBJS += driver/systick.o
ifeq ($(ENABLE_UART),1)
OBJS += driver/uart.o
endif
# Main
OBJS += app/action.o
ifeq ($(ENABLE_AIRCOPY),1)
OBJS += app/aircopy.o
endif
OBJS += app/app.o
OBJS += app/dtmf.o
OBJS += app/fm.o
@ -39,7 +55,9 @@ OBJS += app/generic.o
OBJS += app/main.o
OBJS += app/menu.o
OBJS += app/scanner.o
ifeq ($(ENABLE_UART),1)
OBJS += app/uart.o
endif
OBJS += audio.o
OBJS += bitmaps.o
OBJS += board.o
@ -53,7 +71,9 @@ OBJS += misc.o
OBJS += radio.o
OBJS += scheduler.o
OBJS += settings.o
ifeq ($(ENABLE_AIRCOPY),1)
OBJS += ui/aircopy.o
endif
OBJS += ui/battery.o
OBJS += ui/fmradio.o
OBJS += ui/helper.o
@ -76,7 +96,7 @@ else
TOP := $(shell pwd)
endif
AS = arm-none-eabi-as
AS = arm-none-eabi-gcc
CC = arm-none-eabi-gcc
LD = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
@ -84,10 +104,22 @@ SIZE = arm-none-eabi-size
GIT_HASH := $(shell git rev-parse --short HEAD)
ASFLAGS = -mcpu=cortex-m0
ASFLAGS = -c -mcpu=cortex-m0
ifeq ($(ENABLE_OVERLAY),1)
ASFLAGS += -DENABLE_OVERLAY
endif
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
ifeq ($(ENABLE_AIRCOPY),1)
CFLAGS += -DENABLE_AIRCOPY
endif
ifeq ($(ENABLE_OVERLAY),1)
CFLAGS += -DENABLE_OVERLAY
endif
ifeq ($(ENABLE_UART),1)
CFLAGS += -DENABLE_UART
endif
LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
ifeq ($(DEBUG),1)

View File

@ -16,7 +16,9 @@
#include <string.h>
#include "app/action.h"
#if defined(ENABLE_AIRCOPY)
#include "app/aircopy.h"
#endif
#include "app/app.h"
#include "app/dtmf.h"
#include "app/fm.h"
@ -24,7 +26,9 @@
#include "app/main.h"
#include "app/menu.h"
#include "app/scanner.h"
#if defined(ENABLE_UART)
#include "app/uart.h"
#endif
#include "ARMCM0.h"
#include "audio.h"
#include "board.h"
@ -44,7 +48,9 @@
#include "misc.h"
#include "radio.h"
#include "settings.h"
#if defined(ENABLE_OVERLAY)
#include "sram-overlay.h"
#endif
#include "ui/battery.h"
#include "ui/inputbox.h"
#include "ui/menu.h"
@ -535,6 +541,7 @@ void APP_CheckRadioInterrupts(void)
g_SquelchLost = false;
BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false);
}
#if defined(ENABLE_AIRCOPY)
if (Mask & BK4819_REG_02_FSK_FIFO_ALMOST_FULL && gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 0) {
uint8_t i;
@ -543,6 +550,7 @@ void APP_CheckRadioInterrupts(void)
}
AIRCOPY_StorePacket();
}
#endif
}
}
@ -732,7 +740,11 @@ void APP_CheckKeys(void)
{
KEY_Code_t Key;
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)) {
if (gSetting_KILLED
#if defined(ENABLE_AIRCOPY)
|| (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)
#endif
) {
return;
}
@ -802,11 +814,13 @@ void APP_TimeSlice10ms(void)
{
gFlashLightBlinkCounter++;
#if defined(ENABLE_UART)
if (UART_IsCommandAvailable()) {
__disable_irq();
UART_HandleCommand();
__enable_irq();
}
#endif
if (gReducedService) {
return;
@ -987,6 +1001,7 @@ void APP_TimeSlice10ms(void)
}
}
#if defined(ENABLE_AIRCOPY)
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1) {
if (gAircopySendCountdown) {
gAircopySendCountdown--;
@ -996,6 +1011,7 @@ void APP_TimeSlice10ms(void)
}
}
}
#endif
APP_CheckKeys();
}
@ -1020,7 +1036,11 @@ void APP_TimeSlice500ms(void)
if (gReducedService) {
BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent);
if (gBatteryCurrent > 500 || gBatteryCalibration[3] < gBatteryCurrentVoltage) {
#if defined(ENABLE_OVERLAY)
overlay_FLASH_RebootToBootloader();
#else
NVIC_SystemReset();
#endif
}
return;
}
@ -1048,7 +1068,11 @@ void APP_TimeSlice500ms(void)
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
}
}
if (gScreenToDisplay != DISPLAY_AIRCOPY && (gScreenToDisplay != DISPLAY_SCANNER || (gScanCssState >= SCAN_CSS_STATE_FOUND))) {
if (
#if defined(ENABLE_AIRCOPY)
gScreenToDisplay != DISPLAY_AIRCOPY &&
#endif
(gScreenToDisplay != DISPLAY_SCANNER || (gScanCssState >= SCAN_CSS_STATE_FOUND))) {
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown && !gDTMF_InputMode) {
gKeyLockCountdown--;
if (gKeyLockCountdown == 0) {
@ -1406,13 +1430,19 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case DISPLAY_SCANNER:
SCANNER_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
#if defined(ENABLE_AIRCOPY)
case DISPLAY_AIRCOPY:
AIRCOPY_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
#endif
default:
break;
}
} else if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY) {
} else if (gScreenToDisplay != DISPLAY_SCANNER
#if defined(ENABLE_AIRCOPY)
&& gScreenToDisplay != DISPLAY_AIRCOPY
#endif
) {
ACTION_Handle(Key, bKeyPressed, bKeyHeld);
} else if (!bKeyHeld && bKeyPressed) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;

View File

@ -15,6 +15,9 @@
*/
#include <string.h>
#if !defined(ENABLE_OVERLAY)
#include "ARMCM0.h"
#endif
#include "app/dtmf.h"
#include "app/generic.h"
#include "app/menu.h"
@ -28,7 +31,9 @@
#include "frequencies.h"
#include "misc.h"
#include "settings.h"
#if defined(ENABLE_OVERLAY)
#include "sram-overlay.h"
#endif
#include "ui/inputbox.h"
#include "ui/menu.h"
#include "ui/ui.h"
@ -980,7 +985,11 @@ static void MENU_Key_MENU(bool bKeyPressed, bool bKeyHeld)
AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM);
AUDIO_PlaySingleVoice(true);
MENU_AcceptSetting();
#if defined(ENABLE_OVERLAY)
overlay_FLASH_RebootToBootloader();
#else
NVIC_SystemReset();
#endif
}
gFlagAcceptSetting = true;
gIsInSubMenu = false;

View File

@ -15,6 +15,9 @@
*/
#include <string.h>
#if !defined(ENABLE_OVERLAY)
#include "ARMCM0.h"
#endif
#include "app/fm.h"
#include "app/uart.h"
#include "board.h"
@ -29,7 +32,9 @@
#include "functions.h"
#include "misc.h"
#include "settings.h"
#if defined(ENABLE_OVERLAY)
#include "sram-overlay.h"
#endif
#include "version.h"
#define DMA_INDEX(x, y) (((x) + (y)) % sizeof(UART_DMA_Buffer))
@ -510,7 +515,11 @@ void UART_HandleCommand(void)
break;
case 0x05DD:
#if defined(ENABLE_OVERLAY)
overlay_FLASH_RebootToBootloader();
#else
NVIC_SystemReset();
#endif
break;
}
}

View File

@ -69,9 +69,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
return;
}
#if defined(ENABLE_AIRCOPY)
if (gScreenToDisplay == DISPLAY_AIRCOPY) {
return;
}
#endif
if (gCurrentFunction == FUNCTION_RECEIVE) {
return;
}

View File

@ -36,8 +36,11 @@
#include "helper/battery.h"
#include "misc.h"
#include "settings.h"
#if defined(ENABLE_OVERLAY)
#include "sram-overlay.h"
#endif
#if defined(ENABLE_OVERLAY)
void BOARD_FLASH_Init(void)
{
FLASH_Init(FLASH_READ_MODE_1_CYCLE);
@ -47,6 +50,7 @@ void BOARD_FLASH_Init(void)
overlay_FLASH_ClockMultiplier = 48;
FLASH_Init(FLASH_READ_MODE_2_CYCLE);
}
#endif
void BOARD_GPIO_Init(void)
{
@ -336,7 +340,9 @@ void BOARD_Init(void)
BOARD_ADC_Init();
ST7565_Init();
BK1080_Init(0, false);
#if defined(ENABLE_AIRCOPY) || defined(ENABLE_UART)
CRC_Init();
#endif
}
void BOARD_EEPROM_Init(void)

View File

@ -491,6 +491,7 @@ void BK4819_TurnsOffTones_TurnsOnRX(void)
);
}
#if defined(ENABLE_AIRCOPY)
void BK4819_SetupAircopy(void)
{
BK4819_WriteRegister(BK4819_REG_70, 0x00E0); // Enable Tone2, tuning gain 48
@ -508,6 +509,7 @@ void BK4819_ResetFSK(void)
SYSTEM_DelayMs(30);
BK4819_Idle();
}
#endif
void BK4819_Idle(void)
{
@ -828,6 +830,7 @@ uint8_t BK4819_GetCTCType(void)
return (BK4819_ReadRegister(BK4819_REG_0C) >> 10) & 3;
}
#if defined(ENABLE_AIRCOPY)
void BK4819_SendFSKData(uint16_t *pData)
{
uint8_t i;
@ -882,6 +885,7 @@ void BK4819_PrepareFSKReceive(void)
// FSK SyncLength Selection
BK4819_WriteRegister(BK4819_REG_59, 0x3068);
}
#endif
void BK4819_PlayRoger(void)
{

View File

@ -46,9 +46,11 @@ BOOT_Mode_t BOOT_GetMode(void)
if (Keys[0] == KEY_SIDE1) {
return BOOT_MODE_F_LOCK;
}
#if defined(ENABLE_AIRCOPY)
if (Keys[0] == KEY_SIDE2) {
return BOOT_MODE_AIRCOPY;
}
#endif
}
return BOOT_MODE_NORMAL;
@ -62,6 +64,7 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
GUI_SelectNextDisplay(DISPLAY_MENU);
gMenuListCount = 57;
gF_LOCK = true;
#if defined(ENABLE_AIRCOPY)
} else if (Mode == BOOT_MODE_AIRCOPY) {
gEeprom.DUAL_WATCH = DUAL_WATCH_OFF;
gEeprom.BATTERY_SAVE = 0;
@ -83,6 +86,7 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
BK4819_ResetFSK();
gAircopyState = AIRCOPY_READY;
GUI_SelectNextDisplay(DISPLAY_AIRCOPY);
#endif
} else {
GUI_SelectNextDisplay(DISPLAY_MAIN);
}

8
main.c
View File

@ -26,7 +26,9 @@
#include "driver/gpio.h"
#include "driver/system.h"
#include "driver/systick.h"
#if defined(ENABLE_UART)
#include "driver/uart.h"
#endif
#include "helper/battery.h"
#include "helper/boot.h"
#include "misc.h"
@ -35,11 +37,15 @@
#include "ui/lock.h"
#include "ui/welcome.h"
#if defined(ENABLE_UART)
static const char Version[] = "UV-K5 Firmware, Open Edition, OEFW-"GIT_HASH"\r\n";
#endif
void _putchar(char c)
{
#if defined(ENABLE_UART)
UART_Send((uint8_t *)&c, 1);
#endif
}
void Main(void)
@ -61,8 +67,10 @@ void Main(void)
SYSTICK_Init();
BOARD_Init();
#if defined(ENABLE_UART)
UART_Init();
UART_Send(Version, sizeof(Version));
#endif
// Not implementing authentic device checks

2
misc.c
View File

@ -119,7 +119,9 @@ uint8_t gPttDebounceCounter;
uint8_t gMenuListCount;
uint8_t gBackupCROSS_BAND_RX_TX;
uint8_t gScanDelay;
#if defined(ENABLE_AIRCOPY)
uint8_t gAircopySendCountdown;
#endif
uint8_t gFSKWriteIndex;
uint8_t gNeverUsed;

2
misc.h
View File

@ -170,7 +170,9 @@ extern uint8_t gPttDebounceCounter;
extern uint8_t gMenuListCount;
extern uint8_t gBackupCROSS_BAND_RX_TX;
extern uint8_t gScanDelay;
#if defined(ENABLE_AIRCOPY)
extern uint8_t gAircopySendCountdown;
#endif
extern uint8_t gFSKWriteIndex;
extern uint8_t gNeverUsed;

View File

@ -17,7 +17,9 @@
#include <string.h>
#include "app/fm.h"
#include "driver/eeprom.h"
#if defined(ENABLE_UART)
#include "driver/uart.h"
#endif
#include "misc.h"
#include "settings.h"
@ -33,7 +35,9 @@ void SETTINGS_SaveFM(void)
uint8_t Padding[4];
} State;
#if defined(ENABLE_UART)
UART_LogSend("sFm\r\n", 5);
#endif
memset(&State, 0xFF, sizeof(State));
State.Channel = gEeprom.FM_SelectedChannel;
@ -50,7 +54,9 @@ void SETTINGS_SaveVfoIndices(void)
{
uint8_t State[8];
#if defined(ENABLE_UART)
UART_LogSend("sidx\r\n", 6);
#endif
State[0] = gEeprom.ScreenChannel[0];
State[1] = gEeprom.MrChannel[0];
@ -69,7 +75,9 @@ void SETTINGS_SaveSettings(void)
uint8_t State[8];
uint32_t Password[2];
#if defined(ENABLE_UART)
UART_LogSend("spub\r\n", 6);
#endif
State[0] = gEeprom.CHAN_1_CALL;
State[1] = gEeprom.SQUELCH_LEVEL;
@ -168,7 +176,9 @@ void SETTINGS_SaveSettings(void)
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode)
{
#if defined(ENABLE_UART)
UART_LogSend("schn\r\n", 6);
#endif
if (IS_NOT_NOAA_CHANNEL(Channel)) {
uint16_t OffsetMR;
@ -222,7 +232,9 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool bUpdate)
{
#if defined(ENABLE_UART)
UART_LogSend("svalid\r\n", 8);
#endif
if (IS_NOT_NOAA_CHANNEL(Channel)) {
uint8_t State[8];

View File

@ -245,7 +245,9 @@ HandlerReset:
mov sp, r0
bl DATA_Init
bl BSS_Init
#if defined(ENABLE_OVERLAY)
bl BOARD_FLASH_Init
#endif
bl Main
b .

View File

@ -16,7 +16,9 @@
#include <string.h>
#include "ARMCM0.h"
#if defined(ENABLE_UART)
#include "app/uart.h"
#endif
#include "audio.h"
#include "driver/keyboard.h"
#include "driver/st7565.h"
@ -109,11 +111,13 @@ void UI_DisplayLock(void)
gKeyReading0 = Key;
}
#if defined(ENABLE_UART)
if (UART_IsCommandAvailable()) {
__disable_irq();
UART_HandleCommand();
__enable_irq();
}
#endif
if (gUpdateDisplay) {
Render();

View File

@ -20,7 +20,9 @@
#include "app/scanner.h"
#include "driver/keyboard.h"
#include "misc.h"
#if defined(ENABLE_AIRCOPY)
#include "ui/aircopy.h"
#endif
#include "ui/fmradio.h"
#include "ui/inputbox.h"
#include "ui/main.h"
@ -50,9 +52,11 @@ void GUI_DisplayScreen(void)
case DISPLAY_SCANNER:
UI_DisplayScanner();
break;
#if defined(ENABLE_AIRCOPY)
case DISPLAY_AIRCOPY:
UI_DisplayAircopy();
break;
#endif
default:
break;
}

View File

@ -25,7 +25,9 @@ enum GUI_DisplayType_t {
DISPLAY_FM = 0x01U,
DISPLAY_MENU = 0x02U,
DISPLAY_SCANNER = 0x03U,
#if defined(ENABLE_AIRCOPY)
DISPLAY_AIRCOPY = 0x04U,
#endif
DISPLAY_INVALID = 0xFFU,
};