pull/1/head
Piotr Lewandowski 2023-06-30 12:54:03 +02:00
rodzic 03d5c68784
commit dbe5d084df
13 zmienionych plików z 147 dodań i 6 usunięć

Wyświetl plik

@ -1,5 +1,5 @@
transport select swd
adapter speed 8000
adapter speed 16000
reset_config srst_only srst_nogate connect_assert_srst
set _CHIP_NAME DP32G0xx

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -0,0 +1,17 @@
#include "registers.hpp"
class CExec final
{
public:
CExec(){};
void InterruptCallback()
{
CheckButtons();
}
private:
void CheckButtons() const
{
}
};

Wyświetl plik

@ -5,6 +5,7 @@ using namespace Hardware;
void TPower::EnableDbg()
{
GPIOB->DIR &= ~(GPIO_PIN_11|GPIO_PIN_14);
// PB11 alternate fx to SWDIO
GPIO->PORTB_SEL1 &= ~(0b1111 << 12);
GPIO->PORTB_SEL1 |= (0b1 << 12);
@ -12,4 +13,38 @@ void TPower::EnableDbg()
// PB14 alternate fx to SWDIO
GPIO->PORTB_SEL1 &= ~(0b1111 << 24);
GPIO->PORTB_SEL1 |= (0b1 << 24);
}
void TSystem::Delay(unsigned int u32Ticks)
{
for(volatile unsigned int i = 0; i < u32Ticks; i++)
{
__asm volatile ("dsb sy" : : : "memory");
}
}
void TFlashLight::On()
{
GPIOC->DATA |= 1 << 3;
}
void TFlashLight::Off()
{
GPIOC->DATA &= ~(1 << 3);
}
void TFlashLight::Toggle()
{
GPIOC->DATA ^= 1 << 3;
}
void TFlashLight::BlinkSync(unsigned char u8BlinksCnt)
{
for(unsigned char i = 0; i < u8BlinksCnt*2; i++)
{
Toggle();
System.Delay(100000);
}
Off();
}

Wyświetl plik

@ -5,8 +5,25 @@ namespace Hardware
void EnableDbg();
};
struct TSystem
{
static void Delay(unsigned int u32Ticks);
};
struct TFlashLight
{
TFlashLight(TSystem& Sys) :System(Sys){};
void On();
void Off();
void Toggle();
void BlinkSync(unsigned char u8BlinksCnt);
TSystem& System;
};
struct THardware
{
TPower Power;
TSystem System;
TFlashLight FlashLight = {System};
};
}

Wyświetl plik

@ -3,16 +3,36 @@
#include "registers.hpp"
Hardware::THardware Hw;
extern "C" void Reset_Handler();
const System::TOrgFunctions Fw = System::OrgFunc_01_26;
int main()
{
Hw.Power.EnableDbg();
System::JumpToOrginalFw();
return 0;
}
}
void MultiIrq_Handler(unsigned int u32IrqSource)
{
GPIOC->DATA ^= 1 << 3;
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);
}
}

Wyświetl plik

@ -3,7 +3,7 @@ ENTRY(Reset_Handler)
MEMORY
{
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 4K
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 60K
}
_estack = 0x20001388;

Wyświetl plik

@ -46,11 +46,36 @@ struct TPort
struct TGpio
{
unsigned int DATA;
unsigned int DIR;
};
#define GPIO_BASE 0x400B0000
#define GPIO ((TPort*)GPIO_BASE)
#define __BKPT(value) __asm volatile ("bkpt "#value)
#define GPIOA_BASE 0x40060000
#define GPIOA ((TGpio*)GPIOC_BASE)
#define GPIOB_BASE 0x40060800
#define GPIOB ((TGpio*)GPIOC_BASE)
#define GPIOC_BASE 0x40061000
#define GPIOC ((TGpio*)GPIOC_BASE)
#define GPIO_PIN_0 (1 << 0 )
#define GPIO_PIN_1 (1 << 1 )
#define GPIO_PIN_2 (1 << 2 )
#define GPIO_PIN_3 (1 << 3 )
#define GPIO_PIN_4 (1 << 4 )
#define GPIO_PIN_5 (1 << 5 )
#define GPIO_PIN_6 (1 << 6 )
#define GPIO_PIN_7 (1 << 7 )
#define GPIO_PIN_8 (1 << 8 )
#define GPIO_PIN_9 (1 << 9 )
#define GPIO_PIN_10 (1 << 10)
#define GPIO_PIN_11 (1 << 11)
#define GPIO_PIN_12 (1 << 12)
#define GPIO_PIN_13 (1 << 13)
#define GPIO_PIN_14 (1 << 14)
#define GPIO_PIN_15 (1 << 15)

Wyświetl plik

@ -9,4 +9,31 @@ namespace System
};
void JumpToOrginalFw();
struct TOrgFunctions
{
void(*PrintTextOnScreen)(const char* U8Text,
unsigned int u32StartPixel,
unsigned int u32StopPixel,
unsigned int u32LineNumber,
unsigned int u32Centered);
void(*FillScreenMemory)(unsigned int u32Param1);
void(*DelayMs)(unsigned int u32Ms);
void(*DelayUs)(unsigned int u32Us);
int(*WriteSerialData)(unsigned char* p8Data, unsigned char u8Len);
void(*BK4819Write)(unsigned int u32Address, unsigned int u32Data);
unsigned int(*BK4819Read)(unsigned int u32Address);
};
inline const TOrgFunctions OrgFunc_01_26 =
{
.PrintTextOnScreen = (decltype(TOrgFunctions::PrintTextOnScreen))(0x874C + 1),
.FillScreenMemory = (decltype(TOrgFunctions::FillScreenMemory))(0xb70c + 1),
.DelayMs = (decltype(TOrgFunctions::DelayMs)) (0xD0EE + 1),
.DelayUs = (decltype(TOrgFunctions::DelayUs)) (0xD100 + 1),
.WriteSerialData = (int(*)(unsigned char*, unsigned char))(0xBE44 + 1),
.BK4819Write = (decltype(TOrgFunctions::BK4819Write) (0xAF00 + 1)),
.BK4819Read = (decltype(TOrgFunctions::BK4819Read) (0xA960 + 1)),
};
}

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.