src/def_hp34970_fp.h

Mon, 09 Nov 2020 23:05:24 +0100

author
David Douard <david.douard@sdf3.org>
date
Mon, 09 Nov 2020 23:05:24 +0100
changeset 49
c146d19101a3
parent 44
b3c3d54d2c7c
child 64
897330ee6e9d
permissions
-rw-r--r--

Refactor HPSerial to get rid of packet collision misbehavior

completely split the key sending code from the irq-based receiveing logic.
When sending keycodes, disable the RxIrq callback and handle send and recv
of bytes synchronously.

The keycode sending routine rus in a dedicated thread.

32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
1 // STM32F303xE based HP34970 replacement PCB
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
2
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
3 #if !defined(DEF_HP34970_FP_H)
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
4
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
5 #define DEF_HP34970_FP_H
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
6
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
7 #define DSP_MOSI PA_7
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
8 #define DSP_MISO PA_6 // NC
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
9 #define DSP_SCLK PA_5
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
10 #define DSP_CS PA_2
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
11 #define DSP_RST PA_3
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
12 #define DSP_DC PA_4
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
13
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
14 // UART for RX (CPU->DP)
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
15 #define HP_RX PC_5
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
16 #define HP_TX PC_4
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
17
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
18 // RST pin (handle this by hand)
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
19 #define HP_RST PA_15
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
20
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
21 // encoder
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
22 #define KP_ENC1 PA_0
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
23 #define KP_ENC2 PA_1
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
24
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
25 // keypad
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
26 #define KP_R0 PB_5
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
27 #define KP_R1 PB_6
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
28 #define KP_R2 PB_7
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
29 #define KP_R3 PB_8
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
30
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
31 #define KP_C0 PC_2
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
32 #define KP_C1 PC_1
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
33 #define KP_C2 PC_0
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
34 #define KP_C3 PB_4
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
35 #define KP_C4 PB_0
44
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
36
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
37 #if defined(HAVE_PC)
44
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
38 //#include <USBSerial.h>
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
39 //USBSerial pc;
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
40 BufferedSerial pc(PC_10_ALT0, PC_11_ALT0, 115200); // UART_4
b3c3d54d2c7c Many improvements
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
41 //BufferedSerial pc(PC_10, PC_11, 115200); // UART_4
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
42 #endif
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
43
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents:
diff changeset
44 #endif

mercurial