forked from mirror/uv-k5-firmware
Completed systick handler.
This commit is contained in:
parent
714317c300
commit
37afa8c956
2
Makefile
2
Makefile
@ -48,7 +48,9 @@ OBJS += gui.o
|
||||
OBJS += helper.o
|
||||
OBJS += misc.o
|
||||
OBJS += radio.o
|
||||
OBJS += scheduler.o
|
||||
OBJS += settings.o
|
||||
|
||||
OBJS += main.o
|
||||
|
||||
TOP := $(shell pwd)
|
||||
|
4
audio.c
4
audio.c
@ -53,8 +53,8 @@ static const uint8_t VoiceClipLengthEnglish[76] = {
|
||||
uint8_t gVoiceID[8];
|
||||
uint8_t gVoiceReadIndex;
|
||||
uint8_t gVoiceWriteIndex;
|
||||
uint8_t gCountdownToPlayNextVoice;
|
||||
bool gFlagPlayQueuedVoice;
|
||||
volatile uint16_t gCountdownToPlayNextVoice;
|
||||
volatile bool gFlagPlayQueuedVoice;
|
||||
|
||||
void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
||||
{
|
||||
|
4
audio.h
4
audio.h
@ -113,8 +113,8 @@ typedef enum VOICE_ID_t VOICE_ID_t;
|
||||
extern uint8_t gVoiceID[8];
|
||||
extern uint8_t gVoiceReadIndex;
|
||||
extern uint8_t gVoiceWriteIndex;
|
||||
extern uint8_t gCountdownToPlayNextVoice;
|
||||
extern bool gFlagPlayQueuedVoice;
|
||||
extern volatile uint16_t gCountdownToPlayNextVoice;
|
||||
extern volatile bool gFlagPlayQueuedVoice;
|
||||
|
||||
void AUDIO_PlayBeep(BEEP_Type_t Beep);
|
||||
void AUDIO_PlayVoice(VOICE_ID_t VoiceID);
|
||||
|
@ -31,7 +31,7 @@ bool gChargingWithTypeC;
|
||||
bool gLowBattery;
|
||||
bool gLowBatteryBlink;
|
||||
|
||||
uint16_t gBatterySave;
|
||||
volatile uint16_t gBatterySave;
|
||||
|
||||
void BATTERY_GetReadings(bool bDisplayBatteryLevel)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ extern bool gChargingWithTypeC;
|
||||
extern bool gLowBattery;
|
||||
extern bool gLowBatteryBlink;
|
||||
|
||||
extern uint16_t gBatterySave;
|
||||
extern volatile uint16_t gBatterySave;
|
||||
|
||||
void BATTERY_GetReadings(bool bDisplayBatteryLevel);
|
||||
|
||||
|
@ -52,8 +52,3 @@ void SYSTICK_DelayUs(uint32_t Delay)
|
||||
} while (i < Delay * gTickMultiplier);
|
||||
}
|
||||
|
||||
void SystickHandler(void)
|
||||
{
|
||||
gMaybeVsync = 1;
|
||||
}
|
||||
|
||||
|
4
gui.c
4
gui.c
@ -34,8 +34,8 @@
|
||||
|
||||
GUI_DisplayType_t gScreenToDisplay;
|
||||
uint8_t g_200003C6;
|
||||
uint8_t g_20000380;
|
||||
uint8_t g_20000390;
|
||||
volatile uint8_t g_20000380;
|
||||
volatile uint8_t g_20000390;
|
||||
uint8_t g_200003BA;
|
||||
uint8_t g_200003BB;
|
||||
uint8_t gWasFKeyPressed;
|
||||
|
4
gui.h
4
gui.h
@ -33,8 +33,8 @@ typedef enum GUI_DisplayType_t GUI_DisplayType_t;
|
||||
|
||||
extern GUI_DisplayType_t gScreenToDisplay;
|
||||
extern uint8_t g_200003C6;
|
||||
extern uint8_t g_20000380;
|
||||
extern uint8_t g_20000390;
|
||||
extern volatile uint8_t g_20000380;
|
||||
extern volatile uint8_t g_20000390;
|
||||
extern uint8_t g_200003BA;
|
||||
extern uint8_t g_200003BB;
|
||||
extern uint8_t gWasFKeyPressed;
|
||||
|
40
misc.c
40
misc.c
@ -48,11 +48,13 @@ uint8_t gEEPROM_1F8E;
|
||||
|
||||
uint8_t gMR_ChannelParameters[207];
|
||||
|
||||
uint16_t g_2000032E;
|
||||
uint16_t g_2000033A;
|
||||
uint16_t g_2000033E = 1000;
|
||||
uint8_t g_20000342;
|
||||
uint8_t g_20000356;
|
||||
uint8_t g_2000032D;
|
||||
volatile uint16_t g_2000032E;
|
||||
volatile uint16_t g_2000033A;
|
||||
volatile uint16_t g_2000033E = 1000;
|
||||
volatile uint16_t g_20000342;
|
||||
volatile uint16_t g_2000034C;
|
||||
volatile uint16_t g_20000356;
|
||||
uint8_t g_2000036B;
|
||||
uint8_t g_2000036D;
|
||||
uint8_t g_2000036E;
|
||||
@ -66,7 +68,7 @@ uint8_t g_20000377;
|
||||
uint8_t g_20000378;
|
||||
uint8_t g_20000379;
|
||||
uint8_t g_2000037E;
|
||||
uint8_t g_20000381;
|
||||
volatile uint8_t g_20000381;
|
||||
uint8_t g_20000383;
|
||||
uint16_t g_2000038E;
|
||||
uint8_t g_200003A9;
|
||||
@ -98,7 +100,7 @@ uint8_t g_20000D0C[16];
|
||||
|
||||
bool gIs_A_Scan;
|
||||
bool gIsNoaaMode;
|
||||
bool gMaybeVsync;
|
||||
volatile bool gMaybeVsync;
|
||||
bool gNoaaChannel;
|
||||
bool gUpdateDisplay;
|
||||
uint8_t gA_Scan_Channel;
|
||||
@ -111,15 +113,21 @@ uint8_t gScanChannel;
|
||||
uint32_t gScanFrequency;
|
||||
uint8_t gScanState;
|
||||
uint8_t gShowChPrefix;
|
||||
uint8_t gSystickCountdown2;
|
||||
uint8_t gSystickCountdown3;
|
||||
uint8_t gSystickCountdown4;
|
||||
uint8_t gSystickFlag0;
|
||||
uint8_t gSystickFlag10;
|
||||
uint8_t gSystickFlag5;
|
||||
uint8_t gSystickFlag6;
|
||||
uint8_t gSystickFlag7;
|
||||
uint8_t gSystickFlag8;
|
||||
volatile uint16_t gSystickCountdown2;
|
||||
volatile uint8_t gSystickCountdown3;
|
||||
volatile uint8_t gSystickCountdown4;
|
||||
volatile uint16_t gSystickCountdown11;
|
||||
volatile bool gSystickFlag0;
|
||||
volatile bool gSystickFlag1;
|
||||
volatile bool gSystickFlag5;
|
||||
volatile bool gSystickFlag6;
|
||||
volatile bool gSystickFlag7;
|
||||
volatile bool gSystickFlag8;
|
||||
volatile bool gSystickFlag9;
|
||||
volatile bool gSystickFlag10;
|
||||
volatile bool gSystickFlag11;
|
||||
|
||||
volatile uint16_t ScanPauseDelayIn10msec;
|
||||
|
||||
// --------
|
||||
|
||||
|
40
misc.h
40
misc.h
@ -51,11 +51,13 @@ extern uint8_t gEEPROM_1F8E;
|
||||
|
||||
extern uint8_t gMR_ChannelParameters[207];
|
||||
|
||||
extern uint16_t g_2000032E;
|
||||
extern uint16_t g_2000033A;
|
||||
extern uint16_t g_2000033E;
|
||||
extern uint8_t g_20000342;
|
||||
extern uint8_t g_20000356;
|
||||
extern uint8_t g_2000032D;
|
||||
extern volatile uint16_t g_2000032E;
|
||||
extern volatile uint16_t g_2000033A;
|
||||
extern volatile uint16_t g_2000033E;
|
||||
extern volatile uint16_t g_20000342;
|
||||
extern volatile uint16_t g_2000034C;
|
||||
extern volatile uint16_t g_20000356;
|
||||
extern uint8_t g_2000036B;
|
||||
extern uint8_t g_2000036D;
|
||||
extern uint8_t g_2000036E;
|
||||
@ -69,7 +71,7 @@ extern uint8_t g_20000377;
|
||||
extern uint8_t g_20000378;
|
||||
extern uint8_t g_20000379;
|
||||
extern uint8_t g_2000037E;
|
||||
extern uint8_t g_20000381;
|
||||
extern volatile uint8_t g_20000381;
|
||||
extern uint8_t g_20000383;
|
||||
extern uint16_t g_2000038E;
|
||||
extern uint8_t g_200003A9;
|
||||
@ -101,7 +103,7 @@ extern uint8_t g_20000D0C[16];
|
||||
|
||||
extern bool gIs_A_Scan;
|
||||
extern bool gIsNoaaMode;
|
||||
extern bool gMaybeVsync;
|
||||
extern volatile bool gMaybeVsync;
|
||||
extern bool gNoaaChannel;
|
||||
extern bool gUpdateDisplay;
|
||||
extern uint8_t gA_Scan_Channel;
|
||||
@ -114,15 +116,21 @@ extern uint8_t gScanChannel;
|
||||
extern uint32_t gScanFrequency;
|
||||
extern uint8_t gScanState;
|
||||
extern uint8_t gShowChPrefix;
|
||||
extern uint8_t gSystickCountdown2;
|
||||
extern uint8_t gSystickCountdown3;
|
||||
extern uint8_t gSystickCountdown4;
|
||||
extern uint8_t gSystickFlag0;
|
||||
extern uint8_t gSystickFlag10;
|
||||
extern uint8_t gSystickFlag5;
|
||||
extern uint8_t gSystickFlag6;
|
||||
extern uint8_t gSystickFlag7;
|
||||
extern uint8_t gSystickFlag8;
|
||||
extern volatile uint16_t gSystickCountdown2;
|
||||
extern volatile uint8_t gSystickCountdown3;
|
||||
extern volatile uint8_t gSystickCountdown4;
|
||||
extern volatile uint16_t gSystickCountdown11;
|
||||
extern volatile bool gSystickFlag0;
|
||||
extern volatile bool gSystickFlag1;
|
||||
extern volatile bool gSystickFlag5;
|
||||
extern volatile bool gSystickFlag6;
|
||||
extern volatile bool gSystickFlag7;
|
||||
extern volatile bool gSystickFlag8;
|
||||
extern volatile bool gSystickFlag9;
|
||||
extern volatile bool gSystickFlag10;
|
||||
extern volatile bool gSystickFlag11;
|
||||
|
||||
extern volatile uint16_t ScanPauseDelayIn10msec;
|
||||
|
||||
// --------
|
||||
|
||||
|
128
scheduler.c
Normal file
128
scheduler.c
Normal file
@ -0,0 +1,128 @@
|
||||
/* Copyright 2023 Dual Tachyon
|
||||
* https://github.com/DualTachyon
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "audio.h"
|
||||
#include "battery.h"
|
||||
#include "functions.h"
|
||||
#include "gui.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
|
||||
static uint32_t gGlobalSysTickCounter;
|
||||
|
||||
void SystickHandler(void)
|
||||
{
|
||||
gGlobalSysTickCounter += 1;
|
||||
gMaybeVsync = 1;
|
||||
if ((gGlobalSysTickCounter % 50) == 0) {
|
||||
g_2000032E = 1;
|
||||
if (g_2000033E != 0) {
|
||||
g_2000033E--;
|
||||
if (g_2000033E == 0) {
|
||||
gSystickFlag0 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((gGlobalSysTickCounter & 3) == 0) {
|
||||
gSystickFlag1 = 1;
|
||||
}
|
||||
if (gSystickCountdown2 != 0) {
|
||||
gSystickCountdown2--;
|
||||
}
|
||||
if (gSystickCountdown3 != 0) {
|
||||
gSystickCountdown3--;
|
||||
}
|
||||
if (gSystickCountdown4 != 0) {
|
||||
gSystickCountdown4--;
|
||||
}
|
||||
if (gCurrentFunction == FUNCTION_0 && g_2000032E != 0) {
|
||||
g_2000032E--;
|
||||
if (g_2000032E == 0) {
|
||||
gSystickFlag5 = 1;
|
||||
}
|
||||
}
|
||||
if (gCurrentFunction == FUNCTION_POWER_SAVE && gBatterySave != 0) {
|
||||
gBatterySave--;
|
||||
if (gBatterySave == 0) {
|
||||
gSystickFlag6 = 1;
|
||||
}
|
||||
}
|
||||
if (g_20000380 == 0 && g_20000381 == 0 && gEeprom.DUAL_WATCH != 0) {
|
||||
if (gCurrentFunction != FUNCTION_2 && gCurrentFunction != FUNCTION_TRANSMIT) {
|
||||
if (gCurrentFunction != FUNCTION_4) {
|
||||
if (g_2000033A != 0) {
|
||||
g_2000033A--;
|
||||
if (g_2000033A == 0) {
|
||||
gSystickFlag7 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_20000380 == 0 && g_20000381 == 0 && gEeprom.DUAL_WATCH == 0) {
|
||||
if (gIsNoaaMode && gCurrentFunction != FUNCTION_2 && gCurrentFunction != FUNCTION_TRANSMIT) {
|
||||
if (gCurrentFunction != FUNCTION_4) {
|
||||
if (g_20000356 != 0) {
|
||||
g_20000356--;
|
||||
if (g_20000356 == 0) {
|
||||
gSystickFlag8 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_20000380 != 0 || g_20000381 == 1) {
|
||||
if (gCurrentFunction != FUNCTION_2 && gCurrentFunction != FUNCTION_TRANSMIT) {
|
||||
if (ScanPauseDelayIn10msec != 0) {
|
||||
ScanPauseDelayIn10msec--;
|
||||
if (ScanPauseDelayIn10msec == 0) {
|
||||
gSystickFlag9 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_20000342 != 0) {
|
||||
g_20000342--;
|
||||
if (g_20000342 == 0) {
|
||||
gSystickFlag10 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (gCountdownToPlayNextVoice != 0) {
|
||||
gCountdownToPlayNextVoice--;
|
||||
if (gCountdownToPlayNextVoice == 0) {
|
||||
gFlagPlayQueuedVoice = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_20000390 != 0 && gCurrentFunction != FUNCTION_2) {
|
||||
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_4) {
|
||||
if (g_2000034C != 0) {
|
||||
g_2000034C--;
|
||||
if (g_2000034C == 0) {
|
||||
gSystickFlag11 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gSystickCountdown11 != 0) {
|
||||
gSystickCountdown11--;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user