Added SETTINGS_SaveFM.

This commit is contained in:
Dual Tachyon 2023-08-26 23:51:49 +01:00
parent 55c512fe20
commit db6d255984
5 changed files with 38 additions and 0 deletions

1
app.c
View File

@ -1381,6 +1381,7 @@ static void APP_ProcessKey(KEY_Code_t CurrentKey, bool bKeyPressed, bool bKeyHel
gFlagSaveSettings = false;
}
if (gFlagSaveFM) {
SETTINGS_SaveFM();
gFlagSaveFM = false;
}
if (g_200003A7 != 0) {

View File

@ -14,11 +14,13 @@
* limitations under the License.
*/
#include <stdbool.h>
#include "bsp/dp32g030/dma.h"
#include "bsp/dp32g030/syscon.h"
#include "bsp/dp32g030/uart.h"
#include "driver/uart.h"
static bool UART_IsLogEnabled;
uint8_t UART_DMA_Buffer[256];
void UART_Init(void)
@ -94,6 +96,13 @@ void UART_Send(const void *pBuffer, uint32_t Size)
}
}
void UART_LogSend(const void *pBuffer, uint32_t Size)
{
if (UART_IsLogEnabled) {
UART_Send(pBuffer, Size);
}
}
// TODO: Not part of the original FW, but used for easier testing
void UART_Print(const char *pString)
{

View File

@ -24,6 +24,7 @@ extern uint8_t UART_DMA_Buffer[256];
void UART_Init(void);
void UART_Send(const void *pBuffer, uint32_t Size);
void UART_LogSend(const void *pBuffer, uint32_t Size);
void UART_Print(const char *pString);
#endif

View File

@ -14,7 +14,32 @@
* limitations under the License.
*/
#include <string.h>
#include "driver/eeprom.h"
#include "driver/uart.h"
#include "fm.h"
#include "settings.h"
EEPROM_Config_t gEeprom;
void SETTINGS_SaveFM(void)
{
uint8_t i;
struct {
uint16_t Frequency;
uint8_t Channel;
bool IsChannelSelected;
uint8_t Padding[4];
} State;
UART_LogSend("sFm\r\n", 5);
memset(&State, 0xFF, sizeof(State));
State.Channel = gEeprom.FM_CurrentChannel;
State.Frequency = gEeprom.FM_CurrentFrequency;
State.IsChannelSelected = gEeprom.FM_IsChannelSelected;
EEPROM_WriteBuffer(0x0E88, &State);
for (i = 0; i < 5; i++) {
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
}
}

View File

@ -168,5 +168,7 @@ typedef struct {
extern EEPROM_Config_t gEeprom;
void SETTINGS_SaveFM(void);
#endif