// // Created by DELL on 2024/10/16. // #include #include "mini_gateway_master.h" #include "usart.h" static int32_t uart_read(uint8_t *buf, uint16_t count, int32_t byte_timeout_ms, void *arg) { HAL_StatusTypeDef status = HAL_UART_Receive(&huart2, buf, count, byte_timeout_ms); if (status == HAL_OK) { return count; } else { return 0; } } static int32_t uart_write(const uint8_t *buf, uint16_t count, int32_t byte_timeout_ms, void *arg) { HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_SET); HAL_UART_Transmit(&huart2, buf, count, byte_timeout_ms); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET); return count; }