The primary communication channel for the Raspberry Pi is UART using the KE protocol to request and recieve data from the Digital Dash Motherboard.
Parameter | Value |
---|---|
Buad Rate | 57600 |
Data | 8-bit |
Parity | none |
Stop | 1-bit |
On the Raspberry Pi ttyAMA0
is connected to the primary UART channel Any serial library can be used to interface with that port. We chose to use PySerial with the following configuration:
self.ser = serial.Serial(
port='/dev/ttyAMA0',
baudrate=57600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
On the STM32 microcontroller we configured the UART similarly using PA9 as USART1_TX and PA10 as USART1_RX. To reduce CPU load, the USART1 global interrupts are enabled.
void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 57600;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
}
Further Information coming soon!
GPIO configuration of STM32446 and Raspberry Pi Compute 3+ module outlining the pull-up/pull-down configuration.
Pi GPIO | STM32 GPIO | Pi Function | STM32 Function | Pi Default Pull | Hardware Pull | Note |
---|---|---|---|---|---|---|
28 | PC9 | SDA0 (ALT0) | I2C3_SDA | — | PU (10k) | |
29 | PA8 | SCL0 (ALT0) | I2C3_SCL | — | PU (10k) | |
30 | PA0 | CTS0 (ALT3) | UART2_CTS | PD (50k) | — | |
31 | PA1 | RTS0 (ALT3) | UART2_RTS | PD (50k) | — | |
32 | PA2 | TXD0 (ALT3) | UART2_RX | PD (50k) | — | |
33 | PA3 | RXD0 (ALT3) | UART2_TX | PD (50k) | — | |
34 | PA15 | GPIO34 | GPIO | PU (50k) | — | |
35 | PB5 | GPIO35 | GPIO | PU (50k) | — | |
36 | PA9 | TXD0 | UART1_TX | PU (50k) | PU (10k) | |
37 | PA10 | RXD0 | UART1_RX | PD (50k) | PU (10k) | Pi pull-down should be disabled on boot |
38 | PA12 | RTS0 | UART1_CTS | PD (50k) | — | |
39 | PA11 | CTS0 | UART1_RTS | PD (50k) | — | |
40 | PB6 | GPIO40 | GPIO | PD (50k) | — | |
41 | PB2 | STM32 BOOT1 | BOOT1 | PD (50k) | — | |
42 | BOOT0 | STM32 BOOT0 | BOOT0 | PD (50k) | — | |
43 | NRST | STM32 NRST | NRST | PD (50k) | — |