mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 11:08:20 +00:00
Port K1 drivers
Port drivers: gpio, keyboad, system, systick, uart, flashlight
This commit is contained in:
1 parent
60ba4cbea6
commit
ebac7e87f3
11 files changed
+246
-226
No files matched your search
+13
-9
@@ -1,9 +1,13 @@
|
||||
#ifdef ENABLE_FLASHLIGHT
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "app/flashlight.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "flashlight.h"
|
||||
#define FLASHLIGHT_PIN GPIO_PIN_MASK(GPIOC_PIN_FLASHLIGHT)
|
||||
static inline void Flashlight_TurnOn(){ LL_GPIO_SetOutputPin(GPIOC, FLASHLIGHT_PIN); }
|
||||
static inline void Flashlight_TurnOff(){ LL_GPIO_ResetOutputPin(GPIOC, FLASHLIGHT_PIN); }
|
||||
static inline void Flashlight_Toggle(){ LL_GPIO_TogglePin(GPIOC, FLASHLIGHT_PIN); }
|
||||
|
||||
#if !defined(ENABLE_FEAT_F4HWN) || defined(ENABLE_FEAT_F4HWN_RESCUE_OPS)
|
||||
enum FlashlightMode_t gFlashLightState;
|
||||
@@ -11,7 +15,7 @@
|
||||
void FlashlightTimeSlice()
|
||||
{
|
||||
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) {
|
||||
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
Flashlight_Toggle();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,9 +32,9 @@
|
||||
|
||||
if (gFlashLightBlinkCounter == next) {
|
||||
if (c==0) {
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
Flashlight_TurnOff();
|
||||
} else {
|
||||
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
Flashlight_Toggle();
|
||||
}
|
||||
|
||||
if (c >= 18) {
|
||||
@@ -51,7 +55,7 @@
|
||||
switch (gFlashLightState) {
|
||||
case FLASHLIGHT_OFF:
|
||||
gFlashLightState++;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
Flashlight_TurnOn();
|
||||
break;
|
||||
case FLASHLIGHT_ON:
|
||||
case FLASHLIGHT_BLINK:
|
||||
@@ -60,7 +64,7 @@
|
||||
case FLASHLIGHT_SOS:
|
||||
default:
|
||||
gFlashLightState = 0;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
Flashlight_TurnOff();
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -70,11 +74,11 @@
|
||||
|
||||
if(gFlashLightState)
|
||||
{
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
Flashlight_TurnOff();
|
||||
}
|
||||
else
|
||||
{
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
Flashlight_TurnOn();
|
||||
}
|
||||
|
||||
gFlashLightState = (gFlashLightState) ? false : true;
|
||||
|
||||
+10
-8
@@ -1,4 +1,5 @@
|
||||
/* Copyright 2023 Dual Tachyon
|
||||
/* Copyright 2025 muzkr https://github.com/muzkr
|
||||
* Copyright 2023 Dual Tachyon
|
||||
* https://github.com/DualTachyon
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -24,9 +25,7 @@
|
||||
#endif
|
||||
#include "app/uart.h"
|
||||
#include "board.h"
|
||||
#include "bsp/dp32g030/dma.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "driver/aes.h"
|
||||
#include "py32f071_ll_dma.h"
|
||||
#include "driver/backlight.h"
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/crc.h"
|
||||
@@ -218,6 +217,8 @@ static void SendVersion(void)
|
||||
#ifndef ENABLE_FEAT_F4HWN
|
||||
static bool IsBadChallenge(const uint32_t *pKey, const uint32_t *pIn, const uint32_t *pResponse)
|
||||
{
|
||||
// PY32 has no AES hardware
|
||||
/*
|
||||
unsigned int i;
|
||||
uint32_t IV[4];
|
||||
|
||||
@@ -231,6 +232,7 @@ static bool IsBadChallenge(const uint32_t *pKey, const uint32_t *pIn, const uint
|
||||
for (i = 0; i < 4; i++)
|
||||
if (IV[i] != pResponse[i])
|
||||
return true;
|
||||
*/
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -489,9 +491,9 @@ bool UART_IsCommandAvailable(void)
|
||||
uint16_t Index;
|
||||
uint16_t TailIndex;
|
||||
uint16_t Size;
|
||||
uint16_t CRC;
|
||||
uint16_t Crc;
|
||||
uint16_t CommandLength;
|
||||
uint16_t DmaLength = DMA_CH0->ST & 0xFFFU;
|
||||
uint16_t DmaLength = sizeof(UART_DMA_Buffer) - LL_DMA_GetDataLength(DMA1, LL_DMA_CHANNEL_2);
|
||||
|
||||
while (1)
|
||||
{
|
||||
@@ -572,9 +574,9 @@ bool UART_IsCommandAvailable(void)
|
||||
UART_Command.Buffer[i] ^= Obfuscation[i % 16];
|
||||
}
|
||||
|
||||
CRC = UART_Command.Buffer[Size] | (UART_Command.Buffer[Size + 1] << 8);
|
||||
Crc = UART_Command.Buffer[Size] | (UART_Command.Buffer[Size + 1] << 8);
|
||||
|
||||
return (CRC_Calculate(UART_Command.Buffer, Size) != CRC) ? false : true;
|
||||
return (CRC_Calculate(UART_Command.Buffer, Size) != Crc) ? false : true;
|
||||
}
|
||||
|
||||
void UART_HandleCommand(void)
|
||||
|
||||
Reference in new issue
Block a user