diff --git a/BMLite_sdk/inc/platform.h b/BMLite_sdk/inc/platform.h index e9babe2..78d1204 100644 --- a/BMLite_sdk/inc/platform.h +++ b/BMLite_sdk/inc/platform.h @@ -46,7 +46,7 @@ fpc_bep_result_t platform_init(void *params); void platform_bmlite_reset(void); /** - * @brief Sends data over communication port in blocking mode. + * @brief Sends data over SPI port in blocking mode. * * @param[in] size Number of bytes to send. * @param[in] data Data buffer to send. @@ -58,7 +58,19 @@ fpc_bep_result_t platform_bmlite_spi_send(uint16_t size, const uint8_t *data, ui void *session); /** - * @brief Receives data from communication port in blocking mode. + * @brief Sends data over UART port in blocking mode. + * + * @param[in] size Number of bytes to send. + * @param[in] data Data buffer to send. + * @param[in] timeout Timeout in ms. Use 0 for infinity. + * + * @return ::fpc_com_result_t + */ +fpc_bep_result_t platform_bmlite_uart_send(uint16_t size, const uint8_t *data, uint32_t timeout, + void *session); + +/** + * @brief Receives data from SPI port in blocking mode. * * @param[in] size Number of bytes to receive. * @param[in, out] data Data buffer to fill. @@ -69,6 +81,18 @@ fpc_bep_result_t platform_bmlite_spi_send(uint16_t size, const uint8_t *data, ui fpc_bep_result_t platform_bmlite_spi_receive(uint16_t size, uint8_t *data, uint32_t timeout, void *session); +/** + * @brief Receives data from UART port in blocking mode. + * + * @param[in] size Number of bytes to receive. + * @param[in, out] data Data buffer to fill. + * @param[in] timeout Timeout in ms. Use 0 for infinity. + * + * @return ::fpc_com_result_t + */ +fpc_bep_result_t platform_bmlite_uart_receive(uint16_t size, uint8_t *data, uint32_t timeout, + void *session); + /** * @brief Stops execution if a debug interface is attached. */ diff --git a/README.md b/README.md index 044db9e..32e7430 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Platform-independent interface implemented in [platform.c](BMLite_sdk/src/platfo | fpc_bep_result_t **platform_bmlite_spi_send**(uint16_t size, const uint8_t *data, uint32_t timeout, void *session) | Send data packet to FPC BM-Lite | | fpc_bep_result_t **platform_bmlite_spi_receive**(uint16_t size, uint8_t *data, uint32_t timeout, void *session) | Receive data packet from FPC BM-Lite. If timeout = **0**, the function will wait for data from BM-Lite indefinitely. The waiting loop will be breaked if **hal_check_button_pressed()** returns non-zero value. It is recommended to do HW or SW reset of BM-Lite if **platform_bmlite_spi_receive()** returns **FPC_BEP_RESULT_TIMEOUT** in order to return is into known state. | -Currently **platform_bmlite_spi_send()** and **platform_bmlite_spi_receive()** are implemented for SPI interface. For UART interface there is no need to wait for **IRQ** pin ready. However because in UART mode there is no signal from FPC-BM-LIte that it will send data, I would recommend to use UART interrupt or DMA to receive data from UART and store it to a separate buffer and read data in **platform_bmlite_spi_receive()** from that buffer. Activation UART data reading only inside **platform_bmlite_spi_receive()** could lead to loosing some incoming data and causing HCP protocol errors. +Currently **platform_bmlite_uart_send()** and **platform_bmlite_uart_receive()** are not implemented. For UART interface there is no need to wait for **IRQ** pin ready. However because in UART mode there is no signal from FPC-BM-LIte that it will send data, I would recommend to use UART interrupt or DMA to receive data from UART and store it to a separate buffer and read data in **platform_bmlite_uart_receive()** from that buffer. Activation UART data reading only inside **platform_bmlite_uart_receive()** could lead to loosing some incoming data and causing HCP protocol errors. ------------