kopia lustrzana https://github.com/piotr022/UV_K5_playground
rodzic
dbe5d084df
commit
24b2139afb
|
@ -4,7 +4,7 @@
|
||||||
{
|
{
|
||||||
"svdFile": "./.vscode/stm32g030.svd",
|
"svdFile": "./.vscode/stm32g030.svd",
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"executable": "./build/src/par_runner/par_runner",
|
"executable": "./build/src/rssi_printer/rssi_printer",
|
||||||
"name": "kwaczek DBG",
|
"name": "kwaczek DBG",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"type": "cortex-debug",
|
"type": "cortex-debug",
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
{
|
{
|
||||||
"svdFile": "./.vscode/stm32g030.svd",
|
"svdFile": "./.vscode/stm32g030.svd",
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"executable": "./build/src/par_runner/par_runner",
|
"executable": "./build/src/rssi_printer/rssi_printer",
|
||||||
"name": "attach kwaczek",
|
"name": "attach kwaczek",
|
||||||
"request": "attach",
|
"request": "attach",
|
||||||
"type": "cortex-debug",
|
"type": "cortex-debug",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{
|
{
|
||||||
"label": "flash firmware",
|
"label": "flash firmware",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "openocd -f interface/cmsis-dap.cfg -f ./openocd_scripts/dp32g030.cfg -c 'reset halt' -c 'write_image ./build/src/par_runner/par_runner_with_bootloader.bin 0' -c 'shutdown'",
|
"command": "openocd -f interface/cmsis-dap.cfg -f ./openocd_scripts/dp32g030.cfg -c 'reset halt' -c 'write_image ./build/src/rssi_printer/rssi_printer_with_bootloader.bin 0' -c 'shutdown'",
|
||||||
"presentation": {
|
"presentation": {
|
||||||
"reveal": "always",
|
"reveal": "always",
|
||||||
"panel": "shared"
|
"panel": "shared"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
set(OPTI_FLAG s)
|
set(OPTI_FLAG s)
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE MinSizeRelease)
|
||||||
|
|
||||||
set(STM32_DEFINES "-DSTM32F0 -DSTM32F030x8 -DSTM32")
|
set(STM32_DEFINES "-DSTM32F0 -DSTM32F030x8 -DSTM32")
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ set(CMAKE_CXX_EXTENSIONS ON)
|
||||||
|
|
||||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||||
|
|
||||||
set(COMPILER_OPTIONS -mthumb -mcpu=cortex-m0plus -mfpu=auto -mfloat-abi=soft -fno-exceptions
|
set(COMPILER_OPTIONS -mthumb -mcpu=cortex-m0 -mfpu=auto -mfloat-abi=soft -fno-exceptions
|
||||||
-msoft-float -fdata-sections -ffunction-sections -Wall $<$<COMPILE_LANGUAGE:CXX>:-Wno-register> -Wno-unknown-pragmas
|
-msoft-float -fdata-sections -ffunction-sections -Wall $<$<COMPILE_LANGUAGE:CXX>:-Wno-register> -Wno-unknown-pragmas
|
||||||
-O${OPTI_FLAG} $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
-O${OPTI_FLAG} $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
||||||
$<$<CONFIG:Debug>:--debug -DDEBUG>
|
$<$<CONFIG:Debug>:--debug -DDEBUG>
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
add_subdirectory(g030_drivers)
|
add_subdirectory(g030_drivers)
|
||||||
add_subdirectory(f030_drivers)
|
add_subdirectory(f030_drivers)
|
||||||
|
add_subdirectory(k5_uv_system)
|
||||||
|
add_subdirectory(lcd)
|
|
@ -0,0 +1,20 @@
|
||||||
|
set(NAME uv_k5_system)
|
||||||
|
add_library(${NAME} STATIC)
|
||||||
|
|
||||||
|
target_include_directories(${NAME} INTERFACE
|
||||||
|
.
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${NAME} PRIVATE
|
||||||
|
.
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(${NAME} PRIVATE
|
||||||
|
system.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_options(${NAME} PRIVATE ${COMPILER_OPTIONS})
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
namespace System
|
namespace System
|
||||||
{
|
{
|
||||||
using VoidFxPointer = void(*)(void);
|
using VoidFxPointer = void(*)(void);
|
||||||
|
@ -16,7 +17,15 @@ namespace System
|
||||||
unsigned int u32StartPixel,
|
unsigned int u32StartPixel,
|
||||||
unsigned int u32StopPixel,
|
unsigned int u32StopPixel,
|
||||||
unsigned int u32LineNumber,
|
unsigned int u32LineNumber,
|
||||||
unsigned int u32Centered);
|
unsigned int u32PxPerChar,
|
||||||
|
unsigned int u32Centered,
|
||||||
|
unsigned int u32MenuLen,
|
||||||
|
unsigned int u32AsciiIdx,
|
||||||
|
unsigned int u32Unknown0,
|
||||||
|
unsigned int u32Unknown1,
|
||||||
|
unsigned int u32Unknown2,
|
||||||
|
unsigned int u32Unknown3
|
||||||
|
);
|
||||||
|
|
||||||
void(*FillScreenMemory)(unsigned int u32Param1);
|
void(*FillScreenMemory)(unsigned int u32Param1);
|
||||||
void(*DelayMs)(unsigned int u32Ms);
|
void(*DelayMs)(unsigned int u32Ms);
|
||||||
|
@ -24,6 +33,13 @@ namespace System
|
||||||
int(*WriteSerialData)(unsigned char* p8Data, unsigned char u8Len);
|
int(*WriteSerialData)(unsigned char* p8Data, unsigned char u8Len);
|
||||||
void(*BK4819Write)(unsigned int u32Address, unsigned int u32Data);
|
void(*BK4819Write)(unsigned int u32Address, unsigned int u32Data);
|
||||||
unsigned int(*BK4819Read)(unsigned int u32Address);
|
unsigned int(*BK4819Read)(unsigned int u32Address);
|
||||||
|
void(*FlushFramebufferToScreen)(void);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TOrgData
|
||||||
|
{
|
||||||
|
unsigned char* pDisplayBuffer;
|
||||||
|
unsigned char* pSmallDigs;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const TOrgFunctions OrgFunc_01_26 =
|
inline const TOrgFunctions OrgFunc_01_26 =
|
||||||
|
@ -35,5 +51,13 @@ namespace System
|
||||||
.WriteSerialData = (int(*)(unsigned char*, unsigned char))(0xBE44 + 1),
|
.WriteSerialData = (int(*)(unsigned char*, unsigned char))(0xBE44 + 1),
|
||||||
.BK4819Write = (decltype(TOrgFunctions::BK4819Write) (0xAF00 + 1)),
|
.BK4819Write = (decltype(TOrgFunctions::BK4819Write) (0xAF00 + 1)),
|
||||||
.BK4819Read = (decltype(TOrgFunctions::BK4819Read) (0xA960 + 1)),
|
.BK4819Read = (decltype(TOrgFunctions::BK4819Read) (0xA960 + 1)),
|
||||||
|
.FlushFramebufferToScreen = (decltype(TOrgFunctions::FlushFramebufferToScreen) (0xB638 + 1))
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const TOrgData OrgData_01_26 =
|
||||||
|
{
|
||||||
|
.pDisplayBuffer = (decltype(TOrgData::pDisplayBuffer)) 0x20000704,
|
||||||
|
.pSmallDigs = (decltype(TOrgData::pSmallDigs)) 0xD620,
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
set(NAME lcd)
|
||||||
|
|
||||||
|
add_library(${NAME} STATIC)
|
||||||
|
|
||||||
|
target_include_directories(${NAME} INTERFACE
|
||||||
|
.
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${NAME} PRIVATE
|
||||||
|
.
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(${NAME} PRIVATE
|
||||||
|
lcd.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${NAME}
|
||||||
|
uv_k5_system
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_options(${NAME} PRIVATE ${COMPILER_OPTIONS})
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
#include "lcd.hpp"
|
|
@ -0,0 +1,90 @@
|
||||||
|
#pragma once
|
||||||
|
#include <type_traits>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
struct ILcd
|
||||||
|
{
|
||||||
|
virtual void UpdateScreen() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<unsigned short _SizeX, unsigned short _SizeY, unsigned char _LineHeight>
|
||||||
|
struct IBitmap
|
||||||
|
{
|
||||||
|
constexpr IBitmap(const unsigned char* _pBuffStart) :pBuffStart(_pBuffStart){};
|
||||||
|
static constexpr auto SizeX = _SizeX;
|
||||||
|
static constexpr auto SizeY = _SizeY;
|
||||||
|
static constexpr auto LineHeight = _LineHeight;
|
||||||
|
static constexpr auto Lines = _SizeX / _LineHeight;
|
||||||
|
static constexpr unsigned short GetCoursorPosition(unsigned char u8Line, unsigned char u8XPos)
|
||||||
|
{
|
||||||
|
return (u8Line * SizeX) + u8XPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool GetPixel(unsigned char u8X, unsigned char u8Y) const = 0;
|
||||||
|
virtual void SetPixel(unsigned char u8X, unsigned char u8Y) const = 0;
|
||||||
|
virtual void* GetCoursorData(unsigned short u16CoursorPosition) const {return nullptr;}
|
||||||
|
|
||||||
|
const unsigned char* pBuffStart;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IFont
|
||||||
|
{
|
||||||
|
virtual bool GetPixel(char c8Character, unsigned char u8X, unsigned char u8Y) const = 0;
|
||||||
|
virtual unsigned char* GetRaw(char c8Character) const = 0;
|
||||||
|
virtual unsigned char GetSizeX(char c8Character) const = 0;
|
||||||
|
virtual unsigned char GetSizeY(char c8Character) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class BitmapType>
|
||||||
|
class CDisplay
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
constexpr CDisplay(BitmapType& _Bitmap)
|
||||||
|
:Bitmap(_Bitmap), pCurrentFont(nullptr), u16CoursorPosition(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void SetCoursor(unsigned char u8Line, unsigned char u8X) const
|
||||||
|
{
|
||||||
|
u16CoursorPosition = (u8Line * Bitmap.SizeX) + u8X;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetFont(const IFont* pFont) const
|
||||||
|
{
|
||||||
|
pCurrentFont = pFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char PrintCharacter(const char c8Character) const
|
||||||
|
{
|
||||||
|
if(!pCurrentFont)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto* const pFontRawData = pCurrentFont->GetRaw(c8Character);
|
||||||
|
auto* pCoursorPosition = Bitmap.GetCoursorData(u16CoursorPosition);
|
||||||
|
auto const CopySize = pCurrentFont->GetSizeY(c8Character) * (BitmapType::LineHeight / 8);
|
||||||
|
if(pCoursorPosition && !(BitmapType::LineHeight % 8))
|
||||||
|
{
|
||||||
|
if(pFontRawData)
|
||||||
|
memcpy(pCoursorPosition, pFontRawData, CopySize);
|
||||||
|
else
|
||||||
|
memset(pCoursorPosition, 0, CopySize);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16CoursorPosition += pCurrentFont->GetSizeY(c8Character);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print(const char* C8String)
|
||||||
|
{
|
||||||
|
for(unsigned char i = 0; i < strlen(C8String); i++)
|
||||||
|
{
|
||||||
|
PrintCharacter(C8String[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const BitmapType& Bitmap;
|
||||||
|
mutable const IFont* pCurrentFont;
|
||||||
|
mutable unsigned short u16CoursorPosition;
|
||||||
|
};
|
|
@ -0,0 +1,99 @@
|
||||||
|
#pragma once
|
||||||
|
#include "lcd.hpp"
|
||||||
|
|
||||||
|
struct TUV_K5Display : public IBitmap<128, 96, 8>
|
||||||
|
{
|
||||||
|
constexpr TUV_K5Display(const unsigned char* p8ScreenData) : IBitmap(p8ScreenData){};
|
||||||
|
bool GetPixel(unsigned char u8X, unsigned char u8Y) const override
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetPixel(unsigned char u8X, unsigned char u8Y) const override
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void* GetCoursorData(unsigned short u16CoursorPosition) const override
|
||||||
|
{
|
||||||
|
return (void*) (&pBuffStart[u16CoursorPosition]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TUV_K5SmallNumbers : public IFont
|
||||||
|
{
|
||||||
|
static constexpr auto FixedSizeY = 7;
|
||||||
|
constexpr TUV_K5SmallNumbers(unsigned char* _p8FontData)
|
||||||
|
:pFontData(_p8FontData){}
|
||||||
|
|
||||||
|
bool GetPixel(char c8Character, unsigned char u8X, unsigned char u8Y) const override
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char* GetRaw(char c8Character) const override
|
||||||
|
{
|
||||||
|
if(c8Character < '0' || c8Character > '9') // 45 - minus
|
||||||
|
{
|
||||||
|
if(c8Character == '-')
|
||||||
|
{
|
||||||
|
return pFontData + (FixedSizeY * 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pFontData + ((c8Character - '0') * FixedSizeY);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char GetSizeX(char c8Character) const override
|
||||||
|
{
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char GetSizeY(char c8Character) const override
|
||||||
|
{
|
||||||
|
return FixedSizeY;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char* const pFontData;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TUV_K5Small : public IFont
|
||||||
|
{
|
||||||
|
static constexpr auto FixedSizeY = 7;
|
||||||
|
constexpr TUV_K5Small(unsigned char* _p8FontData)
|
||||||
|
:pFontData(_p8FontData){}
|
||||||
|
|
||||||
|
bool GetPixel(char c8Character, unsigned char u8X, unsigned char u8Y) const override
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char* GetRaw(char c8Character) const override
|
||||||
|
{
|
||||||
|
if(c8Character < '0' || c8Character > '9') // 45 - minus
|
||||||
|
{
|
||||||
|
if(c8Character == '-')
|
||||||
|
{
|
||||||
|
return pFontData + (FixedSizeY * 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pFontData + ((c8Character - '0') * FixedSizeY);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char GetSizeX(char c8Character) const override
|
||||||
|
{
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char GetSizeY(char c8Character) const override
|
||||||
|
{
|
||||||
|
return FixedSizeY;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char* const pFontData;
|
||||||
|
};
|
|
@ -1,5 +1,5 @@
|
||||||
transport select swd
|
transport select swd
|
||||||
adapter speed 16000
|
adapter speed 32000
|
||||||
reset_config srst_only srst_nogate connect_assert_srst
|
reset_config srst_only srst_nogate connect_assert_srst
|
||||||
|
|
||||||
set _CHIP_NAME DP32G0xx
|
set _CHIP_NAME DP32G0xx
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
add_subdirectory(orginal_fw)
|
add_subdirectory(orginal_fw)
|
||||||
add_subdirectory(par_runner)
|
add_subdirectory(rssi_printer)
|
||||||
# add_subdirectory(ocl_loader)
|
# add_subdirectory(ocl_loader)
|
Plik binarny nie jest wyświetlany.
|
@ -1,38 +0,0 @@
|
||||||
#include "system/system.hpp"
|
|
||||||
#include "hardware/hardware.hpp"
|
|
||||||
#include "registers.hpp"
|
|
||||||
|
|
||||||
Hardware::THardware Hw;
|
|
||||||
const System::TOrgFunctions Fw = System::OrgFunc_01_26;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
System::JumpToOrginalFw();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiIrq_Handler(unsigned int u32IrqSource)
|
|
||||||
{
|
|
||||||
if(GPIOA->DATA & GPIO_PIN_3) // exit key
|
|
||||||
{
|
|
||||||
Hw.FlashLight.BlinkSync(1);
|
|
||||||
|
|
||||||
Fw.BK4819Write(0x58, 0b01111100110011);
|
|
||||||
for(int i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
Fw.BK4819Write(0x5F, 0xAB);
|
|
||||||
}
|
|
||||||
|
|
||||||
Fw.BK4819Read(0x1);
|
|
||||||
// Fw.BK4819Write(0x5D, 0xF << 5);
|
|
||||||
// Fw.BK4819Write(0x59, 0b1 << 11);
|
|
||||||
// Fw.BK4819Write(0x58, 0b01111100110011);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char u8Pa10_13 = (GPIOA->DATA >> 10) & 0xF;
|
|
||||||
if(u8Pa10_13)
|
|
||||||
{
|
|
||||||
Hw.FlashLight.BlinkSync(u8Pa10_13);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +1,9 @@
|
||||||
set(NAME par_runner)
|
set(NAME rssi_printer)
|
||||||
set(MCU_TARGET_FILES_DIR ../mcu_target_common)
|
set(MCU_TARGET_FILES_DIR ../mcu_target_common)
|
||||||
|
|
||||||
add_executable(${NAME}
|
add_executable(${NAME}
|
||||||
${MCU_TARGET_FILES_DIR}/stm32f030xc.s
|
${MCU_TARGET_FILES_DIR}/stm32f030xc.s
|
||||||
main.cpp
|
main.cpp
|
||||||
system/system.cpp
|
|
||||||
hardware/hardware.cpp
|
hardware/hardware.cpp
|
||||||
dp32g030.s
|
dp32g030.s
|
||||||
)
|
)
|
||||||
|
@ -12,6 +11,8 @@ add_executable(${NAME}
|
||||||
target_link_libraries(${NAME}
|
target_link_libraries(${NAME}
|
||||||
f030_drivers
|
f030_drivers
|
||||||
orginal_fw
|
orginal_fw
|
||||||
|
uv_k5_system
|
||||||
|
lcd
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${NAME} PUBLIC
|
target_include_directories(${NAME} PUBLIC
|
||||||
|
@ -68,6 +69,11 @@ add_custom_command(TARGET ${NAME}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(${NAME}_flash
|
add_custom_target(${NAME}_flash
|
||||||
COMMAND openocd -f interface/cmsis-dap.cfg -f ${PROJECT_SOURCE_DIR}/openocd_scripts/dp32g030.cfg -c "write_image ${PROJECT_SOURCE_DIR}/build/src/par_runner/par_runner.bin 0x1000" -c "halt" -c "shutdown"
|
COMMAND openocd -f interface/cmsis-dap.cfg -f ${PROJECT_SOURCE_DIR}/openocd_scripts/dp32g030.cfg -c "write_image ${PROJECT_SOURCE_DIR}/build/src/rssi_printer/rssi_printer.bin 0x1000" -c "halt" -c "shutdown"
|
||||||
|
DEPENDS ${NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(${NAME}_encoded
|
||||||
|
COMMAND python ${PROJECT_SOURCE_DIR}/tools/fw_tools/python-utils/fw_pack.py ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.bin ${CMAKE_CURRENT_SOURCE_DIR}/../orginal_fw/k5_26_encrypted_18to1300MHz.ver.bin ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_encoded.bin
|
||||||
DEPENDS ${NAME}
|
DEPENDS ${NAME}
|
||||||
)
|
)
|
|
@ -43,7 +43,7 @@ void TFlashLight::BlinkSync(unsigned char u8BlinksCnt)
|
||||||
for(unsigned char i = 0; i < u8BlinksCnt*2; i++)
|
for(unsigned char i = 0; i < u8BlinksCnt*2; i++)
|
||||||
{
|
{
|
||||||
Toggle();
|
Toggle();
|
||||||
System.Delay(100000);
|
System.Delay(200000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Off();
|
Off();
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include "system.hpp"
|
||||||
|
#include "hardware/hardware.hpp"
|
||||||
|
#include "registers.hpp"
|
||||||
|
#include "uv_k5_display.hpp"
|
||||||
|
#include "rssi_printer.hpp"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
Hardware::THardware Hw;
|
||||||
|
const System::TOrgFunctions& Fw = System::OrgFunc_01_26;
|
||||||
|
const System::TOrgData& FwData = System::OrgData_01_26;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
System::JumpToOrginalFw();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultiIrq_Handler(unsigned int u32IrqSource)
|
||||||
|
{
|
||||||
|
static unsigned int u32StupidCounter = 1;
|
||||||
|
//GPIOA->DATA & GPIO_PIN_3
|
||||||
|
if((!(u32StupidCounter++ % 15) && u32StupidCounter > 200)) // exit key
|
||||||
|
{
|
||||||
|
CRssiPrinter::Handle(Fw, FwData);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ ENTRY(Reset_Handler)
|
||||||
|
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 4K
|
RAM (rwx) : ORIGIN = 0x2000138B, LENGTH = 4K
|
||||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 60K
|
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 60K
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
#pragma once
|
||||||
|
#include "system.hpp"
|
||||||
|
#include "uv_k5_display.hpp"
|
||||||
|
|
||||||
|
class CRssiPrinter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr auto ChartStartX = 4*7 + 4;
|
||||||
|
static void Handle(const System::TOrgFunctions& Fw, const System::TOrgData& FwData)
|
||||||
|
{
|
||||||
|
static bool bIsCleared = false;
|
||||||
|
static unsigned char u8ChartPosition = 0;
|
||||||
|
TUV_K5Display DisplayBuff(FwData.pDisplayBuffer);
|
||||||
|
const TUV_K5SmallNumbers FontSmallNr(FwData.pSmallDigs);
|
||||||
|
CDisplay Display(DisplayBuff);
|
||||||
|
|
||||||
|
auto* pMenuCheckData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, ChartStartX));
|
||||||
|
bool bIsSqlOpen = (Fw.BK4819Read(0x0C) & 0b10);
|
||||||
|
if(!bIsSqlOpen || *pMenuCheckData == 0xFF)
|
||||||
|
{
|
||||||
|
if(!bIsCleared)
|
||||||
|
{
|
||||||
|
bIsCleared = true;
|
||||||
|
u8ChartPosition = ChartStartX;
|
||||||
|
auto* pDData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, 0));
|
||||||
|
memset(pDData, 0, DisplayBuff.SizeX);
|
||||||
|
Fw.FlushFramebufferToScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Display.SetCoursor(3, 0);
|
||||||
|
Display.SetFont(&FontSmallNr);
|
||||||
|
|
||||||
|
char C8RssiString[] = "g000";
|
||||||
|
unsigned char u8Rssi = ((Fw.BK4819Read(0x67) >> 1) & 0xFF);
|
||||||
|
if(!u8Rssi)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(u8Rssi > 160)
|
||||||
|
{
|
||||||
|
u8Rssi -= 160;
|
||||||
|
C8RssiString[0] = ' ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
u8Rssi = 160 - u8Rssi;
|
||||||
|
C8RssiString[0] = '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
C8RssiString[1] = '0' + u8Rssi / 100;
|
||||||
|
C8RssiString[2] = '0' + (u8Rssi / 10) % 10;
|
||||||
|
C8RssiString[3] = '0' + u8Rssi % 10;
|
||||||
|
|
||||||
|
Display.Print(C8RssiString);
|
||||||
|
|
||||||
|
if(u8ChartPosition < ChartStartX || u8ChartPosition >= TUV_K5Display::SizeX)
|
||||||
|
u8ChartPosition = ChartStartX;
|
||||||
|
|
||||||
|
unsigned char u8Sub = (u8Rssi * 7) >> 7;
|
||||||
|
unsigned char u8PrintShift = (u8Sub > 7 ? 7 : u8Sub);
|
||||||
|
auto* pDData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, 0) + u8ChartPosition);
|
||||||
|
*pDData = (1 << u8PrintShift) & 0xFF;
|
||||||
|
if(u8ChartPosition + 4 < DisplayBuff.SizeX)
|
||||||
|
{
|
||||||
|
for(unsigned char i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
*(++pDData) = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
u8ChartPosition++;
|
||||||
|
Fw.FlushFramebufferToScreen();
|
||||||
|
}
|
||||||
|
};
|
Ładowanie…
Reference in New Issue