- folder structure reordered
- unnecessary drivers removed
This commit is contained in:
38
source/firmware/kernel/driver/include/adc.h
Executable file
38
source/firmware/kernel/driver/include/adc.h
Executable file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* adc.h
|
||||
*
|
||||
* Created on: Dec 23, 2012
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#ifndef ADC_H_
|
||||
#define ADC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
typedef int (*adc_fp_open)(const void *);
|
||||
typedef int (*adc_fp_close)(const void *);
|
||||
typedef uint16_t (*adc_fp_read)(const void *, int);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//! \brief Contains the function pointer to access the adc driver.
|
||||
struct adc_fp {
|
||||
const adc_fp_open open; //!< Function pointer to the open function.
|
||||
const adc_fp_close close; //!< Function pointer to the close function.
|
||||
const adc_fp_read read; //!< Function pointer to the read function.
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//! \brief Contains the architecture depended device and the access functions to the adc driver.
|
||||
struct adc {
|
||||
const void *arch_dep_device; //!< Architecture depended adc device (i.e. msp430_adc_t).
|
||||
const struct adc_fp *fp; //!< Function pointer for the adc driver access.
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
int adc_open(const struct adc *device);
|
||||
int adc_close(const struct adc *device);
|
||||
uint16_t adc_read(const struct adc *device, int timeout);
|
||||
|
||||
#endif /* ADC_H_ */
|
78
source/firmware/kernel/driver/include/gpio.h
Executable file
78
source/firmware/kernel/driver/include/gpio.h
Executable file
@@ -0,0 +1,78 @@
|
||||
/*! \file gpio.h
|
||||
* \author tkl
|
||||
* \date Feb 13, 2012
|
||||
* \brief Header file of the architecture independent gpio driver.
|
||||
*/
|
||||
#ifndef GPIO_H_
|
||||
#define GPIO_H_
|
||||
|
||||
//! \brief Function pointer to the open function.
|
||||
typedef int (*gpio_fp_open_t)(const void*);
|
||||
|
||||
//! \brief Function pointer to the close function.
|
||||
typedef int (*gpio_fp_close_t)(const void*);
|
||||
|
||||
//! \brief Function pointer to the read function.
|
||||
typedef char (*gpio_fp_read_t)(const void*);
|
||||
|
||||
//! \brief Function pointer to the write function.
|
||||
typedef void (*gpio_fp_write_t)(const void*, char);
|
||||
|
||||
//! \brief Function pointer to the toggle function.
|
||||
typedef void (*gpio_fp_toggle_t)(const void*);
|
||||
|
||||
//! \brief Function pointer to the set_callback function.
|
||||
typedef int (*gpio_fp_set_cb_t)(const void*, const void*, const void*);
|
||||
|
||||
//! \brief Contains the function pointer to access the gpio driver.
|
||||
struct gpio_fp {
|
||||
const gpio_fp_open_t open; //!< Function pointer to the open function.
|
||||
const gpio_fp_close_t close; //!< Function pointer to the close function.
|
||||
const gpio_fp_read_t read; //!< Function pointer to the read function.
|
||||
const gpio_fp_write_t write; //!< Function pointer to the write function.
|
||||
const gpio_fp_toggle_t toggle; //!< Function pointer to the toggle function.
|
||||
const gpio_fp_set_cb_t set_cb; //!< Function pointer to the set_callback function.
|
||||
};
|
||||
|
||||
//! \brief Contains the architecture depended device and the access functions to the gpio driver.
|
||||
struct gpio {
|
||||
const void *arch_dep_device; //!< Architecture depended gpio device (i.e. stm32f10x_gpio_t).
|
||||
const struct gpio_fp *fp; //!< Function pointer for the gpio driver access.
|
||||
};
|
||||
|
||||
/*! \brief Open a gpio pin.
|
||||
* \param device The gpio to open.
|
||||
* \retval -1 in error case.
|
||||
*/
|
||||
int gpio_open(const struct gpio *device);
|
||||
|
||||
/*! \brief Close a gpio pin
|
||||
* \param device The gpio to close.
|
||||
* \retval -1 in error case.
|
||||
*/
|
||||
int gpio_close(const struct gpio *device);
|
||||
|
||||
/*! \brief read from a gpio pin
|
||||
* \param device The gpio to read from
|
||||
* \return Read out value.
|
||||
*/
|
||||
char gpio_read(const struct gpio *device);
|
||||
|
||||
/*! \brief write to a gpio pin
|
||||
* \param device The gpio to write to.
|
||||
* \param byte The value to write.
|
||||
*/
|
||||
void gpio_write(const struct gpio *device, char byte);
|
||||
|
||||
//! \brief toggle a gpio pin
|
||||
//! \param device the gpio to toggle.
|
||||
void gpio_toggle(const struct gpio *device);
|
||||
|
||||
//! \brief set the callback for a gpio pin external interrupt
|
||||
//! \param device The gpio to set a callback for.
|
||||
//! \param callback The function pointer to be called back.
|
||||
//! \param param The parameter for the call back.
|
||||
int gpio_set_exti_callback(const struct gpio *device, const void *callback,
|
||||
const void *param);
|
||||
|
||||
#endif /* GPIO_H_ */
|
75
source/firmware/kernel/driver/include/i2c.h
Executable file
75
source/firmware/kernel/driver/include/i2c.h
Executable file
@@ -0,0 +1,75 @@
|
||||
//! \file spi.h
|
||||
//! \author tkl
|
||||
//! \date Apr 26, 2012
|
||||
//! \brief Header file of the architecture independent i2c driver.
|
||||
#ifndef I2C_H_
|
||||
#define I2C_H_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Function pointer to the open function.
|
||||
typedef int (*i2c_fp_open_t)(const void *);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Function pointer to the close function.
|
||||
typedef int (*i2c_fp_close_t)(const void *);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Function pointer to the write function.
|
||||
typedef int (*i2c_fp_write_t)(const void *, char addr, const char *buffer,
|
||||
unsigned int len);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Function pointer to the read function.
|
||||
typedef int (*i2c_fp_read_t)(const void *, char addr, char *buffer,
|
||||
unsigned int len);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Contains the function pointer to access the i2c driver.
|
||||
struct i2c_fp {
|
||||
const i2c_fp_open_t open; //!< Function pointer to the open function.
|
||||
const i2c_fp_close_t close; //!< Function pointer to the close function.
|
||||
const i2c_fp_write_t write; //!< Function pointer to the write function.
|
||||
const i2c_fp_read_t read; //!< Function pointer to the read function.
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Contains the architecture depended device and the access functions to the i2c driver.
|
||||
struct i2c {
|
||||
const void *arch_dep_device; //!< Architecture depended i2c device (i.e. stm32f10x_i2c_t).
|
||||
const struct i2c_fp *fp; //!< Function pointer for the i2c driver access.
|
||||
int cnt_subscriber; //!< Number of opened slaves
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Open i2c device.
|
||||
//! \param device The device to open.
|
||||
//! \retval -1 in error case.
|
||||
int i2c_open(struct i2c *device);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Close i2c device.
|
||||
//! \param device The device to close.
|
||||
//! \retval -1 in error case.
|
||||
int i2c_close(struct i2c *device);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Write to an i2c device.
|
||||
//! \param device The device to write to.
|
||||
//! \param addr The i2c address of the i2c sink.
|
||||
//! \param buffer The buffer to write.
|
||||
//! \param len The length of the buffer.
|
||||
//! \retval -1 in error case, otherwise the number of written bytes.
|
||||
int i2c_write(const struct i2c *device, char addr, const char *buffer,
|
||||
unsigned int len);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Read from an i2c device.
|
||||
//! \param device The device to read from.
|
||||
//! \param addr The i2c address of the i2c source
|
||||
//! \param buffer The buffer to read to.
|
||||
//! \param len The maximum length of the buffer.
|
||||
//! \retval -1 in error case, otherwise the number of read bytes.
|
||||
int i2c_read(const struct i2c *device, char addr, char *buffer,
|
||||
unsigned int len);
|
||||
|
||||
#endif /* I2C_H_ */
|
161
source/firmware/kernel/driver/include/rtc.h
Executable file
161
source/firmware/kernel/driver/include/rtc.h
Executable file
@@ -0,0 +1,161 @@
|
||||
//! \file rtc.h
|
||||
//! \author tkl
|
||||
//! \date Jul 8, 2012
|
||||
//! \brief Header file of the architecture independent rtc implementation.
|
||||
#ifndef RTC_H_
|
||||
#define RTC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Loki time container.
|
||||
struct loki_time {
|
||||
uint32_t sec; //!< Seconds. [0-60]
|
||||
uint32_t min; //!< Minutes. [0-59]
|
||||
uint32_t hour; //!< Hours. [0-23]
|
||||
uint32_t day; //!< Day. [1-31]
|
||||
uint32_t mon; //!< Month. [0-11]
|
||||
uint32_t year; //!< Year.
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Rtc interrupt interval.
|
||||
enum rtc_interval {
|
||||
RTC_INTERVAL_MINUTE = 0, //!< rtc interrupt every minute.
|
||||
RTC_INTERVAL_HOUR, //!< rtc interrupt every hour.
|
||||
RTC_INTERVAL_MIDNIGHT, //!< rtc interrupt every day at 00:00.
|
||||
RTC_INTERVAL_NOON //!< rtc interrupt every day at 12:00.
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Rtc alarm mask.
|
||||
enum rtc_alarm_mask {
|
||||
RTC_ALARM_DISABLED = 0x00, //!< Alarm mask disabled.
|
||||
RTC_ALARM_MINUTE = 0x01, //!< Alarm mask minute.
|
||||
RTC_ALARM_HOUR = 0x02, //!< Alarm mask hour.
|
||||
RTC_ALARM_DAY_OF_WEEK = 0x04, //!< Alarm mask day of week.
|
||||
RTC_ALARM_DAY_OF_MONTH = 0x08 //!< Alarm mask day of month.
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! Callback for the open function of the arch depended rtc driver.
|
||||
typedef int (*rtc_fp_open_t)(const void*);
|
||||
|
||||
//! Callback for the close function of the arch depended rtc driver.
|
||||
typedef int (*rtc_fp_close_t)(const void*);
|
||||
|
||||
//! Callback for the time set function of the arch depended rtc driver.
|
||||
typedef void (*rtc_fp_set_time_t)(const void*, const struct loki_time*);
|
||||
|
||||
//! Callback for the time get function of the arch depended rtc driver.
|
||||
typedef struct loki_time *(*rtc_fp_get_time_t)(const void*, struct loki_time*);
|
||||
|
||||
//! Callback for the start interval event function.
|
||||
typedef int (*rtc_fp_start_interval_event)
|
||||
(const void *, enum rtc_interval, const void *, const void *);
|
||||
|
||||
//! Callback for the stop interval event.
|
||||
typedef int (*rtc_fp_stop_interval_event)(const void *);
|
||||
|
||||
//! Callback for the start alarm event.
|
||||
typedef int (*rtc_fp_start_alarm_event)
|
||||
(const void *, const struct loki_time*, enum rtc_alarm_mask, const void *, const void *);
|
||||
|
||||
//! Callback for the stop alarm event.
|
||||
typedef int (*rtc_fp_stop_alarm_event)(const void *);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Function pointer to access the rct driver.
|
||||
struct rtc_fp {
|
||||
const rtc_fp_open_t open; //!< Function pointer to the open function.
|
||||
const rtc_fp_close_t close; //!< Function pointer to the close function.
|
||||
const rtc_fp_set_time_t set_time; //!< Function pointer to the set_time function.
|
||||
const rtc_fp_get_time_t get_time; //!< Function pointer to the get_time function.
|
||||
const rtc_fp_start_interval_event start_interval; //!< Function pointer to the start_interval function.
|
||||
const rtc_fp_stop_interval_event stop_interval; //!< Function pointer to the stop_interval function.
|
||||
const rtc_fp_start_alarm_event start_alarm; //!< Function pointer to the start_alarm function.
|
||||
const rtc_fp_stop_alarm_event stop_alarm; //!< Function pointer to the stop_alarm function.
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Contains the architecture depended device and the access functions to the rtc driver.
|
||||
struct rtc {
|
||||
const void *arch_dep_device; //!< Architecture depended rtc device (i.e. msp430_rtc_t).
|
||||
const struct rtc_fp *fp; //!< Function pointer for the rtc driver access.
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Open a rtc device.
|
||||
//! \param device The rtc device to open.
|
||||
//! \retval -1 in error case.
|
||||
int rtc_open(const struct rtc *device);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Close a rtc device.
|
||||
//! \param device The rtc device to close.
|
||||
//! \retval -1 in error case.
|
||||
int rtc_close(const struct rtc *device);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Set rtc time.
|
||||
//! \param device The rtc device.
|
||||
//! \param time The time to set.
|
||||
void rtc_set_time(const struct rtc *device, const struct loki_time *time);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Get rtc time.
|
||||
//! \param device The rtc device.
|
||||
//! \param time The time to get.
|
||||
//! \retval NULL in error case, otherwise points to time.
|
||||
struct loki_time *rtc_get_time(const struct rtc *device,
|
||||
struct loki_time *time);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Converts a Unix timestamp to a loki_time.
|
||||
//! \param tick The Unix timestamp.
|
||||
//! \return the converted time.
|
||||
struct loki_time tick_to_time(uint32_t tick);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Converts a loki_time to aunix timestamp.
|
||||
//! \param time The time to convert.
|
||||
//! \return The converted unix timestamp.
|
||||
uint32_t time_to_tick(const struct loki_time *time);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Starts a rtc interval event.
|
||||
//! On every occurance of interval the rtc event gets fired.
|
||||
//! \param device The rtc device.
|
||||
//! \param interval The interval of rtc event occurance.
|
||||
//! \param callback The callback is executed in case of interval event.
|
||||
//! \param argument The argument for the callback.
|
||||
//! \retval -1 in error case.
|
||||
int rtc_start_interval_event(const struct rtc *device, enum rtc_interval interval,
|
||||
const void * callback, const void *argument);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Stops a rtc interval event.
|
||||
//! \param device The rtc device.
|
||||
//! \retval -1 in error case.
|
||||
int rtc_stop_interval_event(const struct rtc *device);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Starts a rtc alarm event.
|
||||
//! \param device The rtc device.
|
||||
//! \param alarm_time The time to fire the alarm.
|
||||
//! \param alarm_mask The mask to filter the alarm time.
|
||||
//! \param callback The callback is executed in case of alarm.
|
||||
//! \param argument The argument for the callback.
|
||||
//! \retval -1 in error case.
|
||||
int rtc_start_alarm_event(const struct rtc *device,
|
||||
const struct loki_time *alarm_time, enum rtc_alarm_mask alarm_mask,
|
||||
const void * callback, const void *argument);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Stops a rtc alarm.
|
||||
//! \param device The rtc device.
|
||||
//! \retval -1 in error case.
|
||||
int rtc_stop_alarm_event(const struct rtc *device);
|
||||
|
||||
#endif /* RTC_H_ */
|
75
source/firmware/kernel/driver/include/spi.h
Executable file
75
source/firmware/kernel/driver/include/spi.h
Executable file
@@ -0,0 +1,75 @@
|
||||
//! \file spi.h
|
||||
//! \author tkl
|
||||
//! \date Feb 11, 2012
|
||||
//! \brief Header file of the architecture independent spi driver.
|
||||
#ifndef SPI_H_
|
||||
#define SPI_H_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Function pointer to the open function.
|
||||
typedef int (*spi_fp_open_t)(const void *);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Function pointer to the close function.
|
||||
typedef int (*spi_fp_close_t)(const void *);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Function pointer to the assert chip select function.
|
||||
typedef void (*spi_fp_assert_cs_t)(const void *);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Function pointer to the deassert chip select function.
|
||||
typedef void (*spi_fp_deassert_cs_t)(const void *);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Function pointer to the receive / transmit function.
|
||||
typedef char (*spi_fp_rxtx_byte_t)(const void *, char);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Contains the function pointer to access the spi driver.
|
||||
struct spi_fp {
|
||||
const spi_fp_open_t open; //!< Function pointer to the open function.
|
||||
const spi_fp_close_t close; //!< Function pointer to the close function.
|
||||
const spi_fp_assert_cs_t assert_cs; //!< Function pointer to the assert chip select function.
|
||||
const spi_fp_deassert_cs_t deassert_cs; //!< Function pointer to the deassert chip select function.
|
||||
const spi_fp_rxtx_byte_t rxtx_byte; //!< Function pointer to the receive / transmit function.
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Contains the architecture depended device and the access functions to the spi driver.
|
||||
struct spi {
|
||||
const void *arch_dep_device; //!< Architecture depended spi device (i.e. stm32f10x_spi_t).
|
||||
const struct spi_fp *fp; //!< Function pointer for the spi driver access.
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Open spi device.
|
||||
//! \param device The spi to open.
|
||||
int spi_open(const struct spi *device);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Close spi device.
|
||||
//! \param device The spi to close.
|
||||
//! \retval -1 in error case.
|
||||
int spi_close(const struct spi *device);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Assert the spi's chip select.
|
||||
//! \param device The spi to assert.
|
||||
//! \retval -1 in error case.
|
||||
void spi_assert_cs(const struct spi * device);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief Deassert the spi'schip select.
|
||||
//! \param device The spi to deassert.
|
||||
//! \retval -1 in error case.
|
||||
void spi_deassert_cs(const struct spi * device);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! \brief rx/tx byte over spi.
|
||||
//! \param device The spi to act on.
|
||||
//! \param byte The data to transmit.
|
||||
//! \return The received data
|
||||
char spi_rxtx_byte(const struct spi * device, char byte);
|
||||
|
||||
#endif /* SPI_H_ */
|
43
source/firmware/kernel/driver/include/timer.h
Executable file
43
source/firmware/kernel/driver/include/timer.h
Executable file
@@ -0,0 +1,43 @@
|
||||
//! \file timer.h
|
||||
//! \author tkl
|
||||
//! \date Jul 4, 2012
|
||||
//! \brief Header file of the architecture independent timer implementation.
|
||||
#ifndef TIMER_H_
|
||||
#define TIMER_H_
|
||||
|
||||
typedef int (*timer_fp_open_t)(const void*); //!< callback for the open function of the arch depended timer driver.
|
||||
typedef int (*timer_fp_close_t)(const void*); //!< callback for the close function of the arch depended timer driver.
|
||||
typedef int (*timer_fp_set_cb_t)(const void*, const void *, const void *); //!< callback for set_callback function of the arch depended timer driver.
|
||||
|
||||
//! \brief The access function pointer for the timer.
|
||||
struct timer_fp {
|
||||
const timer_fp_open_t open; //!< Function pointer to the open function.
|
||||
const timer_fp_close_t close; //!< Function pointer to the close function.
|
||||
const timer_fp_set_cb_t set_cb; //!< Function pointer to the set_callback function.
|
||||
};
|
||||
|
||||
//! \brief Contains the architecture depended device informations.
|
||||
struct loki_timer {
|
||||
const void *arch_dep_device; //!< Architecture depended timer device (i.e. msp430_timer).
|
||||
const struct timer_fp *fp; //!< Function pointer to the architectur depended timer driver access.
|
||||
};
|
||||
|
||||
//! \brief Open a timer timer
|
||||
//! \param device The timer device to open.
|
||||
//! \retval -1 in error case.
|
||||
int timer_open(const struct loki_timer *device);
|
||||
|
||||
//! \brief Close a timer timer
|
||||
//! \param device The timer device to close.
|
||||
//! \retval -1 in error case.
|
||||
int timer_close(const struct loki_timer *device);
|
||||
|
||||
//! \brief Set the callback for a sys tick timer
|
||||
//! \param device The timer device to set the callback for.
|
||||
//! \param callback The function pointer to call back.
|
||||
//! \param param The parameter for the call back.
|
||||
//! \retval -1 in error case.
|
||||
int timer_set_it_callback(const struct loki_timer *device, const void *callback,
|
||||
const void *param);
|
||||
|
||||
#endif /* TIMER_H_ */
|
63
source/firmware/kernel/driver/include/uart.h
Executable file
63
source/firmware/kernel/driver/include/uart.h
Executable file
@@ -0,0 +1,63 @@
|
||||
//! \file uart.h
|
||||
//! \author tkl
|
||||
//! \date Jul 15, 2012
|
||||
//! \brief Header file of the architecture independent uart implementation.
|
||||
#ifndef UART_H_
|
||||
#define UART_H_
|
||||
|
||||
//! Function pointer for the uart open function.
|
||||
typedef int (*uart_fp_open_t)(const void*);
|
||||
|
||||
//! Function pointer for the uart close function.
|
||||
typedef int (*uart_fp_close_t)(const void*);
|
||||
|
||||
//! Function pointer for the uart read function.
|
||||
typedef int (*uart_fp_read_t)(const void*, char*, int);
|
||||
|
||||
//! Function pointer for the uart write function.
|
||||
typedef int (*uart_fp_write_t)(const void*, const char*, int);
|
||||
|
||||
//! Function pointer for the uart set callback function.
|
||||
typedef int (*uart_fp_set_cb_t)(const void*, const void *, const void*);
|
||||
|
||||
//! \brief Uart access.
|
||||
struct uart_fp {
|
||||
const uart_fp_open_t open; //!< Open.
|
||||
const uart_fp_close_t close; //!< Close.
|
||||
const uart_fp_read_t read; //!< Read.
|
||||
const uart_fp_write_t write; //!< Write.
|
||||
const uart_fp_set_cb_t set_cb; //!< Set callback.
|
||||
};
|
||||
|
||||
//! \brief Uart driver object.
|
||||
struct uart {
|
||||
const void *arch_dep_device; //!< Architecture depended uart device.
|
||||
const struct uart_fp *fp; //!< Uart access.
|
||||
struct ringbuffer *buffer; //!< Intermediate buffer.
|
||||
};
|
||||
|
||||
//! \brief Open an uart device.
|
||||
//! \param this The uart device to open.
|
||||
//! \retval -1 in error case.
|
||||
int uart_open(const struct uart *this);
|
||||
|
||||
//! \brief Close an uart device.
|
||||
//! \param this The uart device to close.
|
||||
//! \retval -1 in error case.
|
||||
int uart_close(const struct uart *this);
|
||||
|
||||
//! \brief Read from an uart device.
|
||||
//! \param this The uart device to read from.
|
||||
//! \param buffer The buffer to read to.
|
||||
//! \param len The size of the buffer.
|
||||
//! \retval -1 in error case, otherwise the number of read characters.
|
||||
int uart_read(const struct uart *this, char *buffer, int len);
|
||||
|
||||
//! \brief Write to an uart device.
|
||||
//! \param this The uart device to write to.
|
||||
//! \param buffer The buffer to write.
|
||||
//! \param len The number of characters to write.
|
||||
//! \retval -1 in error case, otherwise the number of written characters.
|
||||
int uart_write(const struct uart *this, const char *buffer, int len);
|
||||
|
||||
#endif /* UART_H_ */
|
Reference in New Issue
Block a user