63 lines
1.8 KiB
C
63 lines
1.8 KiB
C
/*
|
|
* stm32f4_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 "driver.h"
|
|
#include "uart.h"
|
|
|
|
//! \brief Stm32f4 uart device.
|
|
#pragma pack(push)
|
|
#pragma pack(1)
|
|
struct stm32f4_uart {
|
|
const struct stm32f4_gpio *uart_gpio;
|
|
UART_HandleTypeDef *uart_handle;
|
|
};
|
|
#pragma pack(pop)
|
|
|
|
//! \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_ */
|