/* * stm32_uart.h * * Created on: Jul 24, 2016 * Author: tkl */ #ifndef SOURCE_FIRMWARE_ARCH_STM32F4XX_DRIVER_UART_STM32_UART_H_ #define SOURCE_FIRMWARE_ARCH_STM32F4XX_DRIVER_UART_STM32_UART_H_ #include "uart.h" //! \brief Stm32f4 uart device. struct stm32f4_uart { const GPIO_InitTypeDef *gpio_init; GPIO_TypeDef *gpio_port; uint8_t pin_src_rx; uint8_t pin_src_tx; const USART_InitTypeDef *usart_init; USART_TypeDef *usart_port; uint16_t usart_it_select; const NVIC_InitTypeDef *nvic_init; }; //! \brief Open an uart device. //! \param this The uart to open. //! \retval -1 in error case. int stm32f4_uart_open(const void *this); //! \brief Close an uart device. //! \param this The uart to close. //! \retval -1 in error case. int stm32f4_uart_close(const void *this); //! \brief Read from an uart device. //! \param this The uart to read from. //! \param buffer The buffer to read to. //! \param len The length of the buffer. //! \retval -1 in error case, otherwise number of read characters. int stm32f4_uart_read(const void *this, char *buffer, int len); //! \brief Write to an uart device. //! \param this The uart to write to. //! \param buffer The buffer to write. //! \param len The number of characters to write. //! \retval -1 in error case, otherwise number of written characters. int stm32f4_uart_write(const void *this, const char *buffer, int len); //! \brief Set a callback for interrupt handling of the uart. //! \param this The uart. //! \param callback The callback to execute in interrupt case. //! \param param The argument for the callback. //! \retval -1 in error case. int stm32f4_uart_set_cb(const void *this, const void *callback, const void *param); static const struct uart_fp stm32f4_uart_fp = { stm32f4_uart_open, stm32f4_uart_close, stm32f4_uart_read, stm32f4_uart_write, stm32f4_uart_set_cb }; #endif /* SOURCE_FIRMWARE_ARCH_STM32F4XX_DRIVER_UART_STM32_UART_H_ */