added improved idle detection to ps/2 mouse too

This commit is contained in:
dekunukem
2022-05-13 10:36:34 +01:00
parent 32ecf689ff
commit eedfba9a6b
15 changed files with 2573 additions and 1411 deletions

View File

File diff suppressed because one or more lines are too long

View File

Binary file not shown.

View File

@@ -27,6 +27,10 @@ Project File Date: 03/28/2022
<h2>Output:</h2>
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'ibmpc'
compiling ps2mouse.c...
..\Src\ps2mouse.c(157): warning: #1182-D: a declaration cannot have a label
uint32_t ps2mouse_wait_start = HAL_GetTick();
..\Src\ps2mouse.c: 1 warning, 0 errors
compiling main.c...
../Src/main.c(517): warning: #188-D: enumerated type mixed with another type
HAL_GPIO_WritePin(GAMEPAD_B1_GPIO_Port, GAMEPAD_B1_Pin, !(this_gamepad_event->button_1));
@@ -38,9 +42,9 @@ compiling main.c...
HAL_GPIO_WritePin(GAMEPAD_B4_GPIO_Port, GAMEPAD_B4_Pin, !(this_gamepad_event->button_4));
../Src/main.c: 4 warnings, 0 errors
linking...
Program Size: Code=17224 RO-data=768 RW-data=136 ZI-data=2320
Program Size: Code=17252 RO-data=768 RW-data=136 ZI-data=2320
FromELF: creating hex file...
"ibmpc\ibmpc.axf" - 0 Error(s), 4 Warning(s).
"ibmpc\ibmpc.axf" - 0 Error(s), 5 Warning(s).
<h2>Software Packages used:</h2>

View File

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
<title>Static Call Graph - [ibmpc\ibmpc.axf]</title></head>
<body><HR>
<H1>Static Call Graph for image ibmpc\ibmpc.axf</H1><HR>
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060750: Last Updated: Thu May 12 22:57:32 2022
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060750: Last Updated: Fri May 13 10:27:47 2022
<BR><P>
<H3>Maximum Stack Usage = 212 bytes + Unknown(Cycles, Untraceable Function Pointers)</H3><H3>
Call chain for Maximum Stack Depth:</H3>
@@ -592,7 +592,7 @@ Global Symbols
<LI><a href="#[58]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;HAL_SPI_TxRxCpltCallback
</UL>
<P><STRONG><a name="[58]"></a>HAL_SPI_TxRxCpltCallback</STRONG> (Thumb, 400 bytes, Stack size 24 bytes, main.o(i.HAL_SPI_TxRxCpltCallback))
<P><STRONG><a name="[58]"></a>HAL_SPI_TxRxCpltCallback</STRONG> (Thumb, 402 bytes, Stack size 24 bytes, main.o(i.HAL_SPI_TxRxCpltCallback))
<BR><BR>[Stack]<UL><LI>Max Depth = 148<LI>Call Chain = HAL_SPI_TxRxCpltCallback &rArr; handle_protocol_switch &rArr; mouse_uart_switch_to_8bit &rArr; HAL_UART_Init &rArr; UART_SetConfig &rArr; HAL_RCC_GetSysClockFreq &rArr; __aeabi_uidivmod
</UL>
<BR>[Calls]<UL><LI><a href="#[59]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;HAL_GPIO_WritePin
@@ -1160,7 +1160,8 @@ Global Symbols
</UL>
<P><STRONG><a name="[95]"></a>micros</STRONG> (Thumb, 10 bytes, Stack size 0 bytes, delay_us.o(i.micros))
<BR><BR>[Called By]<UL><LI><a href="#[b3]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ps2kb_write
<BR><BR>[Called By]<UL><LI><a href="#[d7]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ps2mouse_wait_for_idle
<LI><a href="#[b3]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ps2kb_write
<LI><a href="#[94]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;delay_us
</UL>
@@ -1500,11 +1501,12 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[26]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;main
</UL>
<P><STRONG><a name="[d7]"></a>ps2mouse_wait_for_idle</STRONG> (Thumb, 38 bytes, Stack size 16 bytes, ps2mouse.o(i.ps2mouse_wait_for_idle))
<P><STRONG><a name="[d7]"></a>ps2mouse_wait_for_idle</STRONG> (Thumb, 64 bytes, Stack size 16 bytes, ps2mouse.o(i.ps2mouse_wait_for_idle))
<BR><BR>[Stack]<UL><LI>Max Depth = 24<LI>Call Chain = ps2mouse_wait_for_idle &rArr; ps2mouse_get_bus_status
</UL>
<BR>[Calls]<UL><LI><a href="#[cf]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ps2mouse_get_bus_status
<LI><a href="#[38]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;HAL_GetTick
<LI><a href="#[95]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;micros
</UL>
<BR>[Called By]<UL><LI><a href="#[d2]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ps2mouse_write_delay_start
<LI><a href="#[d3]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ps2mouse_write

View File

File diff suppressed because it is too large Load Diff

View File

@@ -114,7 +114,7 @@ I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_uart_ex.h)(0x5DFA0893)
-D__UVISION_VERSION="529" -D_RTE_ -DSTM32F072xB -DUSE_HAL_DRIVER -DSTM32F072xB
-o ibmpc\ps2kb.o --omf_browse ibmpc\ps2kb.crf --depend ibmpc\ps2kb.d)
-o ibmpc\ps2kb.o --omf_browse ibmpc\ps2kb.crf --depend ibmpc\ps2kb.d)
I (C:\Keil_v5\ARM\ARMCC\include\stdio.h)(0x5D9B429A)
I (C:\Keil_v5\ARM\ARMCC\include\string.h)(0x5D9B4298)
I (C:\Keil_v5\ARM\ARMCC\include\stdlib.h)(0x5D9B429A)
@@ -239,7 +239,7 @@ I (../Inc/shared.h)(0x61B61A00)
I (../Drivers/CMSIS/Include/core_cmFunc.h)(0x5DFA0892)
I (../Drivers/CMSIS/Device/ST/STM32F0xx/Include/system_stm32f0xx.h)(0x5DFA0880)
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_rcc_ex.h)(0x5DFA0893)
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_gpio.h)(0x5DFA0893)
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_gpio.h)(0x5DFA0893)
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_gpio_ex.h)(0x5DFA0893)
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_dma.h)(0x5DFA0893)
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_dma_ex.h)(0x5DFA0893)

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

@@ -69,7 +69,7 @@ UART_HandleTypeDef huart3;
const uint8_t board_id = 1;
const uint8_t version_major = 0;
const uint8_t version_minor = 5;
const uint8_t version_patch = 1;
const uint8_t version_patch = 2;
uint8_t hw_revision;
uint8_t spi_transmit_buf[SPI_BUF_SIZE];

View File

@@ -153,12 +153,22 @@ uint8_t ps2mouse_read(uint8_t* result, uint8_t timeout_ms)
uint8_t ps2mouse_wait_for_idle(uint8_t timeout_ms)
{
ps2mouse_idle_check:
uint32_t ps2mouse_wait_start = HAL_GetTick();
while(ps2mouse_get_bus_status() != PS2_BUS_IDLE)
{
if(HAL_GetTick() - ps2mouse_wait_start >= timeout_ms)
return PS2_ERROR_TIMEOUT;
}
ps2mouse_wait_start = micros();
// make sure idle is more than 50us
while(micros() - ps2mouse_wait_start < 60)
{
if(ps2mouse_get_bus_status() != PS2_BUS_IDLE)
goto ps2mouse_idle_check;
}
return PS2_OK;
}