6 #include "stm32f7xx_hal.h"
11 #define SET_LED_RED GPIOB->BSRR = GPIO_PIN_14
12 #define RESET_LED_RED GPIOB->BSRR = GPIO_PIN_14 << 16
14 #define SET_LED_BLUE GPIOB->BSRR = GPIO_PIN_7
15 #define RESET_LED_BLUE GPIOB->BSRR = GPIO_PIN_7 << 16
17 #define SET_LED_GREEN GPIOB->BSRR = GPIO_PIN_0
18 #define RESET_LED_GREEN GPIOB->BSRR = GPIO_PIN_0 << 16
25 volatile bool sending
= false;
26 uint8_t circbuf
[BUFSIZE
];
27 uint16_t readpos
, writepos
;
35 void HAL_UART_TxCpltCallback(UART_HandleTypeDef
*UartHandle
)
41 void HAL_UART_RxCpltCallback(UART_HandleTypeDef
*UartHandle
)
43 if(writepos
== BUFSIZE
){
46 circbuf
[writepos
++] = readb
;
47 HAL_UART_Receive_DMA(&huart3
, &readb
, 1);
50 bool input_available()
52 return readpos
!= writepos
;
60 if(readpos
== BUFSIZE
){
63 return circbuf
[readpos
++];
66 void write_byte(uint8_t b
)
72 HAL_UART_Transmit_IT(&huart3
, &b
, 1);
75 void write_dpin(uint8_t i
, bool b
)
81 bool read_dpin(uint8_t i
)
87 void write_apin(uint8_t i
, uint8_t a
)
104 uint8_t read_apin(uint8_t i
)
111 return HAL_GetTick();
123 HAL_UART_Receive_DMA(&huart3
, &readb
, 1);