diff --git a/libs/k5_uv_system/system.hpp b/libs/k5_uv_system/system.hpp index 55be305..d2527ae 100644 --- a/libs/k5_uv_system/system.hpp +++ b/libs/k5_uv_system/system.hpp @@ -32,8 +32,8 @@ namespace System }; void JumpToOrginalFw(); - void JumpToOrginalVector(unsigned int u32IrqSource); - void CopyDataSection(); + void JumpToOrginalVector(unsigned int u32IrqSource); + void CopyDataSection(); struct TOrgFunctions { diff --git a/src/rssi_printer/main.cpp b/src/rssi_printer/main.cpp index 01cd441..c5b1219 100644 --- a/src/rssi_printer/main.cpp +++ b/src/rssi_printer/main.cpp @@ -30,4 +30,5 @@ extern "C" void MultiIrq_Handler(unsigned int u32IrqSource) { CRssiPrinter::Handle(Fw, FwData); } + System::JumpToOrginalVector(u32IrqSource); } \ No newline at end of file diff --git a/src/rssi_sbar/main.cpp b/src/rssi_sbar/main.cpp index 3aa6303..8648292 100644 --- a/src/rssi_sbar/main.cpp +++ b/src/rssi_sbar/main.cpp @@ -15,7 +15,7 @@ int main() return 0; } -extern "C" __attribute__((interrupt)) void MultiIrq_Handler(unsigned int u32IrqSource) +extern "C" void MultiIrq_Handler(unsigned int u32IrqSource) { static bool bFirstInit = false; if(!bFirstInit) diff --git a/src/spectrum/CMakeLists.txt b/src/spectrum/CMakeLists.txt index 9d3f0c3..02ebe9d 100644 --- a/src/spectrum/CMakeLists.txt +++ b/src/spectrum/CMakeLists.txt @@ -2,10 +2,10 @@ set(NAME spectrum) set(MCU_TARGET_FILES_DIR ../mcu_target_common) add_executable(${NAME} - main.cpp - hardware/hardware.cpp - dp32g030.s - ) + main.cpp + hardware/hardware.cpp + dp32g030.s +) target_link_libraries(${NAME} orginal_fw @@ -33,6 +33,7 @@ target_compile_options(${NAME} PRIVATE target_link_options(${NAME} PRIVATE #-print-multi-lib -T ${CMAKE_CURRENT_SOURCE_DIR}/memory.ld + -flto -mcpu=cortex-m0 -mthumb -mfpu=auto @@ -68,7 +69,7 @@ add_custom_command(TARGET ${NAME} ) 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}/cmake-build-debug/src/spectrum/spectrum.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} ) diff --git a/src/spectrum/main.cpp b/src/spectrum/main.cpp index a4b10e9..baf5b2c 100644 --- a/src/spectrum/main.cpp +++ b/src/spectrum/main.cpp @@ -6,38 +6,38 @@ #include Hardware::THardware Hw; -const System::TOrgFunctions &Fw = System::OrgFunc_01_26; -const System::TOrgData &FwData = System::OrgData_01_26; +const System::TOrgFunctions& Fw = System::OrgFunc_01_26; +const System::TOrgData& FwData = System::OrgData_01_26; CSpectrum Spectrum; - -int main() { - System::JumpToOrginalFw(); - return 0; +int main() +{ + System::JumpToOrginalFw(); + return 0; } extern "C" void MultiIrq_Handler(unsigned int u32IrqSource) { + unsigned int u32Dummy; + System::TCortexM0Stacking* pStackedRegs = + (System::TCortexM0Stacking*)(((unsigned int*)&u32Dummy) + 1); - static bool bFirstInit = false; - if (!bFirstInit) { - System::CopyDataSection(); - __libc_init_array(); - bFirstInit = true; - } + static bool bFirstInit = false; + if(!bFirstInit) + { + System::CopyDataSection(); + __libc_init_array(); + bFirstInit = true; + } - unsigned int u32Dummy; - System::TCortexM0Stacking *pStackedRegs = - (System::TCortexM0Stacking *) (((unsigned int *) &u32Dummy) + 1); + bool bPreventWhileKeypadPolling = pStackedRegs->LR > (unsigned int)Fw.PollKeyboard && + pStackedRegs->PC < (unsigned int)Fw.PollKeyboard + 0x100; // i made a mistake and compared PC and LR, but this works fine xD - bool bPreventWhileKeypadPolling = pStackedRegs->LR > (unsigned int) Fw.PollKeyboard && - pStackedRegs->PC < (unsigned int) Fw.PollKeyboard + - 0x100; // i made a mistake and compared PC and LR, but this works fine xD - - static unsigned int u32StupidCounter = 1; - if (u32StupidCounter++ > 200 && !bPreventWhileKeypadPolling) { - Spectrum.Handle(); - } + static unsigned int u32StupidCounter = 1; + if(u32StupidCounter++ > 200 && !bPreventWhileKeypadPolling) + { + Spectrum.Handle(); + } System::JumpToOrginalVector(u32IrqSource); } \ No newline at end of file diff --git a/src/t9_texting/main.cpp b/src/t9_texting/main.cpp index 5604f84..2a3f677 100644 --- a/src/t9_texting/main.cpp +++ b/src/t9_texting/main.cpp @@ -39,6 +39,5 @@ extern "C" void MultiIrq_Handler(unsigned int u32IrqSource) { T9Texting.Handle(); } - System::JumpToOrginalVector(u32IrqSource); } \ No newline at end of file