Fixed pin names and some missing defines

- FLASHLIGHT_Init() used pins PC10-13 those don't exist on MCU
- Renamed ST7565 0 and 1 pins to A0 and RES as named in datasheet
- Set pin defined names instead literal numbers on set/clear bit function
This commit is contained in:
Rafa Couto 2023-08-26 18:27:25 +02:00 committed by DualTachyon
parent a2fd4c7a8b
commit 445e82f6a0
5 changed files with 15 additions and 20 deletions

View File

@ -128,7 +128,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
SYSTEM_DelayMs(Duration);
BK4819_EnterTxMute();
SYSTEM_DelayMs(20);
GPIO_ClearBit(&GPIOC->DATA,4);
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
g_200003B6 = 80;

View File

@ -79,7 +79,7 @@ void BOARD_GPIO_Init(void)
| GPIO_DIR_5_MASK
);
GPIO_SetBit(&GPIOB->DATA, 15);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
}
void BOARD_PORTCON_Init(void)

View File

@ -39,8 +39,8 @@ enum GPIOA_PINS {
enum GPIOB_PINS {
GPIOB_PIN_BACKLIGHT = 6,
GPIOB_PIN_ST7565_0 = 9,
GPIOB_PIN_ST7565_1 = 11, // Shared with SWD!
GPIOB_PIN_ST7565_A0 = 9,
GPIOB_PIN_ST7565_RES = 11, // Shared with SWD!
GPIOB_PIN_SWD_IO = 11, // Shared with ST7565!
GPIOB_PIN_SWD_CLK = 14,
@ -52,7 +52,7 @@ enum GPIOC_PINS {
GPIOC_PIN_BK4819_SCN = 0,
GPIOC_PIN_BK4819_SCL = 1,
GPIOC_PIN_BK4819_SDA = 2,
GPIOC_PIN_FLASHLIGHT = 3,
GPIOC_PIN_AUDIO_PATH = 4,

View File

@ -31,7 +31,7 @@ void ST7565_DrawLine(uint8_t Column, uint8_t Line, uint16_t Size, const uint8_t
SPI_ToggleMasterMode(&SPI0->CR, false);
ST7565_SelectColumnAndLine(Column + 4U, Line);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_0);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
if (bIsClearMode == false) {
for (i = 0; i < Size; i++) {
@ -61,7 +61,7 @@ void ST7565_BlitFullScreen(void)
for (Line = 0; Line < 7; Line++) {
ST7565_SelectColumnAndLine(4U, Line + 1U);
GPIO_SetBit(&GPIOB->DATA, 9U);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
for (Column = 0; Column < 128; Column++) {
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {
}
@ -81,7 +81,7 @@ void ST7565_BlitStatusLine(void)
SPI_ToggleMasterMode(&SPI0->CR, false);
ST7565_WriteByte(0x40);
ST7565_SelectColumnAndLine(4, 0);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_0);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
for (i = 0; i < 0x80; i++) {
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {
@ -99,7 +99,7 @@ void ST7565_FillScreen(uint8_t Value)
SPI_ToggleMasterMode(&SPI0->CR, false);
for (i = 0; i < 8; i++) {
ST7565_SelectColumnAndLine(0, i);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_0);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
for (j = 0; j < 132; j++) {
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {
}
@ -143,17 +143,17 @@ void ST7565_Init(void)
void ST7565_Configure_GPIO_B11(void)
{
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_1);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_RES);
SYSTEM_DelayMs(1);
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_1);
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_RES);
SYSTEM_DelayMs(20);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_1);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_RES);
SYSTEM_DelayMs(120);
}
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line)
{
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_0);
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {
}
SPI0->WDR = Line + 0xB0;
@ -168,7 +168,7 @@ void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line)
void ST7565_WriteByte(uint8_t Value)
{
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_0);
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {
}
SPI0->WDR = Value;

7
main.c
View File

@ -56,11 +56,6 @@ static void FLASHLIGHT_Init(void)
PORTCON_PORTC_IE = PORTCON_PORTC_IE_C5_BITS_ENABLE;
PORTCON_PORTC_PU = PORTCON_PORTC_PU_C5_BITS_ENABLE;
GPIOC->DIR |= GPIO_DIR_3_BITS_OUTPUT;
GPIO_SetBit(&GPIOC->DATA, 10);
GPIO_SetBit(&GPIOC->DATA, 11);
GPIO_SetBit(&GPIOC->DATA, 12);
GPIO_SetBit(&GPIOC->DATA, 13);
}
static void FLASHLIGHT_TurnOff(void)
@ -145,7 +140,7 @@ void Main(void)
HELPER_CheckBootKey(KeyType);
GPIO_ClearBit(&GPIOA->DATA, 12);
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
g_2000036F = 1;
AUDIO_SetVoiceID(0, VOICE_ID_WELCOME);
Channel = gEeprom.VfoChannel[gEeprom.TX_CHANNEL] + 1;