mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
Fix serial commands handling
This commit is contained in:
1 parent
aa5f7c0092
commit
6d4324ef16
4 files changed
+50
-13
No files matched your search
+5
-2
@@ -39,6 +39,7 @@
|
||||
#include "app/scanner.h"
|
||||
#ifdef ENABLE_UART
|
||||
#include "app/uart.h"
|
||||
#include "scheduler.h"
|
||||
#endif
|
||||
#include "py32f0xx.h"
|
||||
#include "audio.h"
|
||||
@@ -1364,9 +1365,11 @@ void APP_TimeSlice10ms(void)
|
||||
|
||||
#ifdef ENABLE_UART
|
||||
if (UART_IsCommandAvailable()) {
|
||||
__disable_irq();
|
||||
// __disable_irq();
|
||||
SCHEDULER_Disable();
|
||||
UART_HandleCommand();
|
||||
__enable_irq();
|
||||
// __enable_irq();
|
||||
SCHEDULER_Enable();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+13
-11
@@ -29,7 +29,7 @@
|
||||
#include "driver/backlight.h"
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/crc.h"
|
||||
#include "driver/py25q16.h"
|
||||
#include "driver/eeprom.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/uart.h"
|
||||
#include "functions.h"
|
||||
@@ -45,6 +45,8 @@
|
||||
|
||||
#define DMA_INDEX(x, y) (((x) + (y)) % sizeof(UART_DMA_Buffer))
|
||||
|
||||
#define DMA_CHANNEL LL_DMA_CHANNEL_2
|
||||
|
||||
typedef struct {
|
||||
uint16_t ID;
|
||||
uint16_t Size;
|
||||
@@ -162,7 +164,8 @@ static union
|
||||
|
||||
static uint32_t Timestamp;
|
||||
static uint16_t gUART_WriteIndex;
|
||||
static bool bIsEncrypted = true;
|
||||
// static bool bIsEncrypted = true;
|
||||
#define bIsEncrypted true
|
||||
|
||||
static void SendReply(void *pReply, uint16_t Size)
|
||||
{
|
||||
@@ -285,7 +288,7 @@ static void CMD_051B(const uint8_t *pBuffer)
|
||||
|
||||
if (!bLocked)
|
||||
{
|
||||
PY25Q16_ReadBuffer(pCmd->Offset, Reply.Data.Data, pCmd->Size);
|
||||
EEPROM_ReadBuffer(pCmd->Offset, Reply.Data.Data, pCmd->Size);
|
||||
}
|
||||
|
||||
SendReply(&Reply, pCmd->Size + 8);
|
||||
@@ -314,7 +317,7 @@ static void CMD_051D(const uint8_t *pBuffer)
|
||||
Reply.Header.Size = sizeof(Reply.Data);
|
||||
Reply.Data.Offset = pCmd->Offset;
|
||||
|
||||
bIsLocked = bHasCustomAesKey ? gIsLocked : bHasCustomAesKey;
|
||||
bIsLocked = bHasCustomAesKey ? gIsLocked : false;
|
||||
|
||||
if (!bIsLocked)
|
||||
{
|
||||
@@ -329,8 +332,7 @@ static void CMD_051D(const uint8_t *pBuffer)
|
||||
|
||||
if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !bIsInLockScreen || pCmd->bAllowPassword)
|
||||
{
|
||||
// EEPROM_WriteBuffer(Offset, &pCmd->Data[i * 8U]);
|
||||
// TODO: To be implemented
|
||||
EEPROM_WriteBuffer(Offset, &pCmd->Data[i * 8U]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,7 +500,7 @@ bool UART_IsCommandAvailable(void)
|
||||
uint16_t Size;
|
||||
uint16_t Crc;
|
||||
uint16_t CommandLength;
|
||||
uint16_t DmaLength = sizeof(UART_DMA_Buffer) - LL_DMA_GetDataLength(DMA1, LL_DMA_CHANNEL_2);
|
||||
uint16_t DmaLength = sizeof(UART_DMA_Buffer) - LL_DMA_GetDataLength(DMA1, DMA_CHANNEL);
|
||||
|
||||
while (1)
|
||||
{
|
||||
@@ -566,11 +568,11 @@ bool UART_IsCommandAvailable(void)
|
||||
|
||||
gUART_WriteIndex = TailIndex;
|
||||
|
||||
if (UART_Command.Header.ID == 0x0514)
|
||||
bIsEncrypted = false;
|
||||
// if (UART_Command.Header.ID == 0x0514)
|
||||
// bIsEncrypted = false;
|
||||
|
||||
if (UART_Command.Header.ID == 0x6902)
|
||||
bIsEncrypted = true;
|
||||
// if (UART_Command.Header.ID == 0x6902)
|
||||
// bIsEncrypted = true;
|
||||
|
||||
if (bIsEncrypted)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "scheduler.h"
|
||||
#include "app/chFrScanner.h"
|
||||
#ifdef ENABLE_FMRADIO
|
||||
#include "app/fm.h"
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Copyright 2025 muzkr https://github.com/muzkr
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _SCHEDULER_H
|
||||
#define _SCHEDULER_H
|
||||
|
||||
#include "py32f0xx.h"
|
||||
|
||||
static void inline SCHEDULER_Enable()
|
||||
{
|
||||
NVIC_EnableIRQ(SysTick_IRQn);
|
||||
}
|
||||
|
||||
static void inline SCHEDULER_Disable()
|
||||
{
|
||||
NVIC_DisableIRQ(SysTick_IRQn);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user