mirror of
https://github.com/dekuNukem/USB4VC.git
synced 2025-10-31 11:26:46 -07:00
keyboard LED request working, clearing buf when swithcing on protocols
This commit is contained in:
@@ -3606,7 +3606,7 @@
|
||||
<ActiveTab>0</ActiveTab>
|
||||
<Doc>
|
||||
<Name>../Src/main.c</Name>
|
||||
<ColumnNumber>33</ColumnNumber>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<TopLine>323</TopLine>
|
||||
<CurrentLine>338</CurrentLine>
|
||||
<Folding>1</Folding>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -27,14 +27,17 @@ Project File Date: 01/01/2022
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
|
||||
Build target 'my_adb'
|
||||
compiling helpers.c...
|
||||
compiling main.c...
|
||||
../Src/main.c(491): warning: #188-D: enumerated type mixed with another type
|
||||
../Src/main.c(132): warning: #223-D: function "kb_buf_reset" declared implicitly
|
||||
kb_buf_reset(&my_kb_buf);
|
||||
../Src/main.c(504): warning: #188-D: enumerated type mixed with another type
|
||||
HAL_GPIO_WritePin(DEBUG1_GPIO_Port, DEBUG1_Pin, kb_srq || mouse_srq);
|
||||
../Src/main.c: 1 warning, 0 errors
|
||||
../Src/main.c: 2 warnings, 0 errors
|
||||
linking...
|
||||
Program Size: Code=10676 RO-data=496 RW-data=76 ZI-data=1948
|
||||
Program Size: Code=10344 RO-data=496 RW-data=76 ZI-data=1948
|
||||
FromELF: creating hex file...
|
||||
"my_adb\my_adb.axf" - 0 Error(s), 1 Warning(s).
|
||||
"my_adb\my_adb.axf" - 0 Error(s), 2 Warning(s).
|
||||
|
||||
<h2>Software Packages used:</h2>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
Dependencies for Project 'my_adb', Target 'my_adb': (DO NOT MODIFY !)
|
||||
CompilerVersion: 5060750::V5.06 update 6 (build 750)::ARMCC
|
||||
F (startup_stm32f042x6.s)(0x61D0CD73)(--cpu Cortex-M0 -g --apcs=interwork --pd "__MICROLIB SETA 1"
|
||||
|
||||
|
||||
-I.\RTE\_my_adb
|
||||
|
||||
-IC:\Users\allen\AppData\Local\Arm\Packs\ARM\CMSIS\5.6.0\CMSIS\Core\Include
|
||||
@@ -74,7 +74,7 @@ I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h)(0x5DFA0893)
|
||||
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal.h)(0x5DFA0893)
|
||||
I (../Inc/stm32f0xx_hal_conf.h)(0x61D0CD72)
|
||||
I (../Inc/main.h)(0x61D0CD72)
|
||||
I (../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_rcc.h)(0x5DFA0893)
|
||||
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/stm32f042x6.h)(0x5DFA0880)
|
||||
@@ -114,7 +114,7 @@ I (../Inc/shared.h)(0x617487BD)
|
||||
|
||||
-D__UVISION_VERSION="529" -D_RTE_ -DSTM32F042x6 -DUSE_HAL_DRIVER -DSTM32F042x6
|
||||
|
||||
-o my_adb\helpers.o --omf_browse my_adb\helpers.crf --depend my_adb\helpers.d)
|
||||
-o my_adb\helpers.o --omf_browse my_adb\helpers.crf --depend my_adb\helpers.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)
|
||||
|
||||
@@ -10,7 +10,7 @@ GPIO_TypeDef* adb_psw_port;
|
||||
uint16_t adb_psw_pin;
|
||||
GPIO_TypeDef* adb_data_port;
|
||||
uint16_t adb_data_pin;
|
||||
uint16_t adb_kb_reg2 = 0xfff8; // all key released, all LED off
|
||||
uint16_t adb_kb_reg2 = 0xffff; // all key released, all LED off
|
||||
uint8_t adb_mouse_current_addr, adb_kb_current_addr, adb_rw_in_progress;
|
||||
uint8_t kb_enabled, mouse_enabled;
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ const uint8_t board_id = 2;
|
||||
const uint8_t version_major = 0;
|
||||
const uint8_t version_minor = 1;
|
||||
const uint8_t version_patch = 0;
|
||||
uint8_t hw_revision;
|
||||
uint8_t hw_revision = 0;
|
||||
|
||||
uint8_t spi_transmit_buf[SPI_BUF_SIZE];
|
||||
uint8_t spi_recv_buf[SPI_BUF_SIZE];
|
||||
@@ -125,13 +125,23 @@ void handle_protocol_switch(uint8_t spi_byte)
|
||||
return;
|
||||
// switching protocol ON
|
||||
if(onoff && protocol_status_lookup[index] == PROTOCOL_STATUS_DISABLED)
|
||||
{
|
||||
switch(index)
|
||||
{
|
||||
case PROTOCOL_ADB_KB:
|
||||
kb_buf_reset(&my_kb_buf);
|
||||
break;
|
||||
case PROTOCOL_ADB_MOUSE:
|
||||
mouse_buf_reset(&my_mouse_buf);
|
||||
break;
|
||||
}
|
||||
protocol_status_lookup[index] = PROTOCOL_STATUS_ENABLED;
|
||||
}
|
||||
// switching protocol OFF
|
||||
else if((onoff == 0) && protocol_status_lookup[index] == PROTOCOL_STATUS_ENABLED)
|
||||
protocol_status_lookup[index] = PROTOCOL_STATUS_DISABLED;
|
||||
}
|
||||
|
||||
|
||||
void parse_spi_buf(uint8_t* spibuf)
|
||||
{
|
||||
if(spibuf[SPI_BUF_INDEX_MSG_TYPE] == SPI_MOSI_MSG_TYPE_MOUSE_EVENT)
|
||||
@@ -150,10 +160,6 @@ void parse_spi_buf(uint8_t* spibuf)
|
||||
{
|
||||
kb_buf_add(&my_kb_buf, spibuf[4], spibuf[6]);
|
||||
}
|
||||
else if(spibuf[SPI_BUF_INDEX_MSG_TYPE] == SPI_MOSI_MSG_TYPE_REQ_ACK)
|
||||
{
|
||||
HAL_GPIO_WritePin(SLAVE_REQ_GPIO_Port, SLAVE_REQ_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
else if(spibuf[SPI_BUF_INDEX_MSG_TYPE] == SPI_MOSI_MSG_TYPE_INFO_REQUEST)
|
||||
{
|
||||
memset(spi_transmit_buf, 0, SPI_BUF_SIZE);
|
||||
@@ -227,6 +233,8 @@ void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
|
||||
}
|
||||
parse_spi_buf(spi_recv_buf);
|
||||
spi_isr_end:
|
||||
if(spi_recv_buf[SPI_BUF_INDEX_MSG_TYPE] == SPI_MOSI_MSG_TYPE_REQ_ACK)
|
||||
HAL_GPIO_WritePin(SLAVE_REQ_GPIO_Port, SLAVE_REQ_Pin, GPIO_PIN_RESET);
|
||||
HAL_SPI_TransmitReceive_IT(&hspi1, spi_transmit_buf, spi_recv_buf, SPI_BUF_SIZE);
|
||||
HAL_GPIO_WritePin(USER_LED_GPIO_Port, USER_LED_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
@@ -509,8 +517,17 @@ int main(void)
|
||||
else if(adb_status == ADB_KB_CHANGE_LED)
|
||||
{
|
||||
// kb reg2 top 13 bits is button status, 1 = released 0 = pressed
|
||||
// first 3 bits is LED, 1 = on, 0 = off
|
||||
printf("%x\n", adb_kb_reg2);
|
||||
// bottom 3 bits is LED, 1 = off, 0 = on
|
||||
memset(spi_transmit_buf, 0, SPI_BUF_SIZE);
|
||||
spi_transmit_buf[SPI_BUF_INDEX_MAGIC] = SPI_MISO_MAGIC;
|
||||
spi_transmit_buf[SPI_BUF_INDEX_MSG_TYPE] = SPI_MISO_MSG_TYPE_KB_LED_REQUEST;
|
||||
if(!(adb_kb_reg2 & 0x4)) // scroll lock LED
|
||||
spi_transmit_buf[3] = 1;
|
||||
if(!(adb_kb_reg2 & 0x1)) // num lock LED
|
||||
spi_transmit_buf[4] = 1;
|
||||
if(!(adb_kb_reg2 & 0x2)) // caps lock LED
|
||||
spi_transmit_buf[5] = 1;
|
||||
HAL_GPIO_WritePin(SLAVE_REQ_GPIO_Port, SLAVE_REQ_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
|
||||
Reference in New Issue
Block a user