added kvm mode for ps2 mouse

This commit is contained in:
dekunukem
2022-05-02 22:44:47 +01:00
parent 4834e32b62
commit 779143b8bd
15 changed files with 2328 additions and 2263 deletions

View File

@@ -23,6 +23,8 @@ uint8_t ps2mouse_send_update(ps2_outgoing_buf* pbuf, uint8_t inhibit_timeout_ms)
uint8_t ps2mouse_write_nowait(uint8_t data);
void ps2mouse_reset(void);
void ps2mouse_restore_defaults(void);
void ps2mouse_send_bat(uint8_t timeout_ms);
uint8_t ps2mouse_wait_for_idle(uint8_t timeout_ms);
#define PS2_OK 0
#define PS2_ERROR_REPORTING_DISABLED 1

View File

File diff suppressed because one or more lines are too long

View File

Binary file not shown.

View File

@@ -29,21 +29,19 @@ Project File Date: 03/28/2022
Build target 'ibmpc'
compiling ps2mouse.c...
compiling main.c...
../Src/main.c(481): warning: #188-D: enumerated type mixed with another type
HAL_GPIO_WritePin(GAMEPAD_B1_GPIO_Port, GAMEPAD_B1_Pin, !(this_gamepad_event->button_1));
../Src/main.c(482): warning: #188-D: enumerated type mixed with another type
HAL_GPIO_WritePin(GAMEPAD_B2_GPIO_Port, GAMEPAD_B2_Pin, !(this_gamepad_event->button_2));
HAL_GPIO_WritePin(GAMEPAD_B1_GPIO_Port, GAMEPAD_B1_Pin, !(this_gamepad_event->button_1));
../Src/main.c(483): warning: #188-D: enumerated type mixed with another type
HAL_GPIO_WritePin(GAMEPAD_B3_GPIO_Port, GAMEPAD_B3_Pin, !(this_gamepad_event->button_3));
HAL_GPIO_WritePin(GAMEPAD_B2_GPIO_Port, GAMEPAD_B2_Pin, !(this_gamepad_event->button_2));
../Src/main.c(484): warning: #188-D: enumerated type mixed with another type
HAL_GPIO_WritePin(GAMEPAD_B3_GPIO_Port, GAMEPAD_B3_Pin, !(this_gamepad_event->button_3));
../Src/main.c(485): warning: #188-D: enumerated type mixed with another type
HAL_GPIO_WritePin(GAMEPAD_B4_GPIO_Port, GAMEPAD_B4_Pin, !(this_gamepad_event->button_4));
../Src/main.c(715): warning: #177-D: function "MX_IWDG_Init" was declared but never referenced
static void MX_IWDG_Init(void)
../Src/main.c: 5 warnings, 0 errors
../Src/main.c: 4 warnings, 0 errors
linking...
Program Size: Code=16444 RO-data=428 RW-data=128 ZI-data=2160
Program Size: Code=16628 RO-data=428 RW-data=128 ZI-data=2176
FromELF: creating hex file...
"ibmpc\ibmpc.axf" - 0 Error(s), 5 Warning(s).
"ibmpc\ibmpc.axf" - 0 Error(s), 4 Warning(s).
<h2>Software Packages used:</h2>

View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because it is too large Load Diff

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)
@@ -152,12 +152,12 @@ I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h)(0x5DFA0893)
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_uart.h)(0x5DFA0893)
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_uart_ex.h)(0x5DFA0893)
I (../Inc/shared.h)(0x61B61A00)
I (../Inc/ps2kb.h)(0x626EE78C)
I (../Inc/ps2kb.h)(0x626EE78C)
I (../Inc/delay_us.h)(0x617487C7)
F (..\Src\ps2mouse.c)(0x62705063)(--c99 -c --cpu Cortex-M0 -D__MICROLIB -g -O3 --apcs=interwork --split_sections -I ../Inc -I ../Drivers/STM32F0xx_HAL_Driver/Inc -I ../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F0xx/Include -I ../Drivers/CMSIS/Include
-I.\RTE\_ibmpc
-IC:\Users\allen\AppData\Local\Arm\Packs\ARM\CMSIS\5.6.0\CMSIS\Core\Include
-IC:\Users\allen\AppData\Local\Arm\Packs\Keil\STM32F0xx_DFP\2.0.0\Drivers\CMSIS\Device\ST\STM32F0xx\Include
@@ -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)
@@ -278,7 +278,7 @@ I (../Inc/shared.h)(0x61B61A00)
I (../Inc/main.h)(0x62423606)
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_rcc.h)(0x5DFA0893)
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_def.h)(0x5DFA0893)
I (../Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f0xx.h)(0x5DFA0880)
I (../Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f0xx.h)(0x5DFA0880)
I (../Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f072xb.h)(0x5DFA0880)
I (../Drivers/CMSIS/Include/core_cm0.h)(0x5DFA0892)
I (C:\Keil_v5\ARM\ARMCC\include\stdint.h)(0x5D9B4298)

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

@@ -199,6 +199,7 @@ void handle_protocol_switch(uint8_t spi_byte)
break;
case PROTOCOL_PS2_MOUSE:
case PROTOCOL_PS2_MOUSE_KVM:
ps2mouse_reset();
ps2mouse_release_lines();
break;
@@ -327,7 +328,7 @@ void ps2mouse_update(void)
uint8_t inhibit_timeout_ms = 200;
if(is_protocol_enabled(PROTOCOL_PS2_MOUSE_KVM))
inhibit_timeout_ms = 3;
inhibit_timeout_ms = 2;
if(ps2mouse_send_update(&my_ps2_outbuf, inhibit_timeout_ms) != PS2_OK)
{
HAL_GPIO_WritePin(ERR_LED_GPIO_Port, ERR_LED_Pin, GPIO_PIN_SET);
@@ -555,9 +556,9 @@ int main(void)
MX_TIM2_Init();
MX_USART1_UART_Init();
MX_USART3_UART_Init();
// MX_IWDG_Init();
MX_IWDG_Init();
/* USER CODE BEGIN 2 */
// HAL_IWDG_Refresh(&hiwdg);
HAL_IWDG_Refresh(&hiwdg);
printf("%s\nrev%d v%d.%d.%d\n", boot_message, hw_revision, version_major, version_minor, version_patch);
delay_us_init(&htim2);
protocol_status_lookup_init();
@@ -593,11 +594,11 @@ int main(void)
}
HAL_GPIO_WritePin(ERR_LED_GPIO_Port, ERR_LED_Pin, GPIO_PIN_SET);
}
ps2mouse_write(0xaa, 100);
ps2mouse_write(0, 100);
ps2mouse_send_bat(25);
while (1)
{
// HAL_IWDG_Refresh(&hiwdg);
HAL_IWDG_Refresh(&hiwdg);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */

View File

@@ -73,6 +73,14 @@ void ps2mouse_reset(void)
mouse_device_id = 0;
}
void ps2mouse_send_bat(uint8_t timeout_ms)
{
if(ps2mouse_wait_for_idle(timeout_ms))
return;
ps2mouse_write(0xaa, 100);
ps2mouse_write(0, 100);
}
void ps2mouse_init(GPIO_TypeDef* clk_port, uint16_t clk_pin, GPIO_TypeDef* data_port, uint16_t data_pin)
{
ps2mouse_clk_port = clk_port;