| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |  #ifndef STM32SPROG_SERIAL_H#define STM32SPROG_SERIAL_H/** \file serial.h * * Provides a serial communication interface. */#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "usart.h"#define USARTn  USER_USART#define MAX_READ_RETRIES 50000000/** Serial device handle. */typedef struct SSerialDev SerialDev;/** \brief Read data from a serial device. * * Blocks until all data has been read or an error has occurred. * * \param dev An open serial device. * \param buffer The data buffer to fill. * \param n The number of bytes to read. * * \return \c true on success, \c false if any error occurred. */bool serialRead(SerialDev *dev, uint8_t *buffer, size_t n);/** \brief Write data to a serial device. * * Blocks until all data has been written or an error has occurred. * * \param dev An open serial device. * \param buffer The data to write. * \param n The number of bytes to write. * * \return \c true on success, \c false if any error occurred. */bool serialWrite(SerialDev *dev, const uint8_t *buffer, size_t n);#endif /* STM32SPROG_SERIAL_H */
 |