mirror of
https://github.com/dekuNukem/USB4VC.git
synced 2025-10-31 11:26:46 -07:00
updated p-card interrupt information and other technical docs
This commit is contained in:
BIN
captures/diy_samples/pcard_interrupt_numlock.sal
Normal file
BIN
captures/diy_samples/pcard_interrupt_numlock.sal
Normal file
Binary file not shown.
BIN
photos/interrupt.png
Normal file
BIN
photos/interrupt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
@@ -52,8 +52,6 @@ Most pins are already in use:
|
||||
|
||||

|
||||
|
||||
A few comments:
|
||||
|
||||
* Protocol Card and OLED screen shares the same SPI bus, with different CS of course.
|
||||
|
||||
* Pin 22 is used to reset the P-Card, pin 32 for putting the microcontroller in bootloader mode for firmware updates.
|
||||
@@ -72,7 +70,9 @@ A few comments:
|
||||
|
||||
Raspberri Pi communicates with Protocol Card through SPI. [Here's a quick introduction](https://www.circuitbasics.com/basics-of-the-spi-communication-protocol/) if you're unfamiliar.
|
||||
|
||||
RPi is master, P-card is slave. **Mode 0** is used (CPOL and CPHA both 0), **SCLK is 2MHz**.
|
||||
RPi is master, P-card is slave. **SCLK is 2MHz**.
|
||||
|
||||
**Mode 0** is used. CPOL=0 (CLK idle low), CPHA=0 (data valid on CLK rising edge).
|
||||
|
||||
RPi and P-Card communicates via **fixed-length 32-byte packets**.
|
||||
|
||||
@@ -94,6 +94,20 @@ Compare to the [keyboard tab in the document](https://docs.google.com/spreadshee
|
||||
|
||||

|
||||
|
||||
## P-Card Interrupt Handling
|
||||
|
||||
When Protocol Card has data for RPi, it should prepare the SPI buffer, and switch its interrupt pin to HIGH ([Pin 36](#hardware-pinout)).
|
||||
|
||||
Upon detecting this change, RPi will send out an ACK message. Upon receiving, the P-Card switches the interrupt pin to LOW.
|
||||
|
||||
RPi will then send out another ACK (or NOP) message to shift the data from P-Card to itself.
|
||||
|
||||
Here is a sample capture:
|
||||
|
||||

|
||||
|
||||
Currently this feature is only used for changing keyboard LEDs.
|
||||
|
||||
## Sample SPI Message Captures
|
||||
|
||||
More **sample captures** [can be found here](https://github.com/dekuNukem/USB4VC/tree/master/captures/diy_samples).
|
||||
|
||||
@@ -910,8 +910,10 @@ def raw_input_event_worker():
|
||||
|
||||
# ----------------- PBOARD INTERRUPT -----------------
|
||||
if GPIO.event_detected(SLAVE_REQ_PIN):
|
||||
slave_result = None
|
||||
for x in range(2):
|
||||
# send out ACK to turn off P-Card interrupt
|
||||
slave_result = pcard_spi.xfer(make_spi_msg_ack())
|
||||
time.sleep(0.001)
|
||||
# send another to shift response into RPi
|
||||
slave_result = pcard_spi.xfer(make_spi_msg_ack())
|
||||
print(int(time.time()), slave_result)
|
||||
if slave_result[SPI_BUF_INDEX_MAGIC] == SPI_MISO_MAGIC and slave_result[SPI_BUF_INDEX_MSG_TYPE] == SPI_MISO_MSG_TYPE_KB_LED_REQUEST:
|
||||
|
||||
Reference in New Issue
Block a user