git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4174 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2012-05-07 19:34:10 +00:00
parent 428eab74e0
commit ba6519a2ea
4 changed files with 42 additions and 39 deletions

View File

@ -34,6 +34,9 @@
#include "hal_lld.h" #include "hal_lld.h"
#include "io_channel.h"
#include "io_block.h"
#include "tm.h" #include "tm.h"
#include "pal.h" #include "pal.h"
#include "adc.h" #include "adc.h"

View File

@ -51,9 +51,9 @@ typedef struct {
*/ */
#define _base_block_device_methods \ #define _base_block_device_methods \
/* Removable media detection.*/ \ /* Removable media detection.*/ \
bool_t is_inserted(void *instance); \ bool_t (*is_inserted)(void *instance); \
/* Removable write protection detection.*/ \ /* Removable write protection detection.*/ \
bool_t is_protected(void *instance); \ bool_t (*is_protected)(void *instance); \
/* Connection to the block device.*/ \ /* Connection to the block device.*/ \
bool_t (*connect)(void *instance); \ bool_t (*connect)(void *instance); \
/* Disconnection from the block device.*/ \ /* Disconnection from the block device.*/ \

View File

@ -19,12 +19,12 @@
*/ */
/** /**
* @file io_serial.h * @file io_channel.h
* @brief I/O serial devices access. * @brief I/O channels access.
* @details This header defines abstract interfaces useful to access generic * @details This header defines abstract interfaces useful to access generic
* I/O serial devices in a standardized way. * I/O serial devices in a standardized way.
* *
* @addtogroup IO_SERIAL * @addtogroup IO_CHANNEL
* @details This module defines an abstract interface for I/O channels by * @details This module defines an abstract interface for I/O channels by
* extending the @p BaseSequentialStream interface. Note that no code * extending the @p BaseSequentialStream interface. Note that no code
* is present, I/O channels are just abstract interface like * is present, I/O channels are just abstract interface like
@ -36,8 +36,8 @@
* @{ * @{
*/ */
#ifndef _IO_SERIAL_H_ #ifndef _IO_CHANNEL_H_
#define _IO_SERIAL_H_ #define _IO_CHANNEL_H_
/** /**
* @brief @p BaseChannel specific methods. * @brief @p BaseChannel specific methods.
@ -71,7 +71,7 @@
* *
* @brief @p BaseChannel virtual methods table. * @brief @p BaseChannel virtual methods table.
*/ */
struct BaseChannelVMT { struct tmp_BaseChannelVMT {
_base_channel_methods _base_channel_methods
}; };
@ -86,7 +86,7 @@ typedef struct {
/** @brief Virtual Methods Table.*/ /** @brief Virtual Methods Table.*/
const struct BaseChannelVMT *vmt; const struct BaseChannelVMT *vmt;
_base_channel_data _base_channel_data
} BaseChannel; } tmp_BaseChannel;
/** /**
* @name Macro Functions (BaseChannel) * @name Macro Functions (BaseChannel)
@ -106,7 +106,7 @@ typedef struct {
* *
* @api * @api
*/ */
#define srlPutWouldBlock(ip) ((ip)->vmt->putwouldblock(ip)) #define chnPutWouldBlock(ip) ((ip)->vmt->putwouldblock(ip))
/** /**
* @brief Channel input check. * @brief Channel input check.
@ -122,7 +122,7 @@ typedef struct {
* *
* @api * @api
*/ */
#define srlGetWouldBlock(ip) ((ip)->vmt->getwouldblock(ip)) #define chnGetWouldBlock(ip) ((ip)->vmt->getwouldblock(ip))
/** /**
* @brief Channel blocking byte write. * @brief Channel blocking byte write.
@ -137,7 +137,7 @@ typedef struct {
* *
* @api * @api
*/ */
#define srlPut(ip, b) ((ip)->vmt->put(ip, b, TIME_INFINITE)) #define chnPut(ip, b) ((ip)->vmt->put(ip, b, TIME_INFINITE))
/** /**
* @brief Channel blocking byte write with timeout. * @brief Channel blocking byte write with timeout.
@ -158,7 +158,7 @@ typedef struct {
* *
* @api * @api
*/ */
#define srlPutTimeout(ip, b, time) ((ip)->vmt->put(ip, b, time)) #define chnPutTimeout(ip, b, time) ((ip)->vmt->put(ip, b, time))
/** /**
* @brief Channel blocking byte read. * @brief Channel blocking byte read.
@ -172,7 +172,7 @@ typedef struct {
* *
* @api * @api
*/ */
#define srlGet(ip) ((ip)->vmt->get(ip, TIME_INFINITE)) #define chnGet(ip) ((ip)->vmt->get(ip, TIME_INFINITE))
/** /**
* @brief Channel blocking byte read with timeout. * @brief Channel blocking byte read with timeout.
@ -192,7 +192,7 @@ typedef struct {
* *
* @api * @api
*/ */
#define srlGetTimeout(ip, time) ((ip)->vmt->get(ip, time)) #define chnGetTimeout(ip, time) ((ip)->vmt->get(ip, time))
/** /**
* @brief Channel blocking write with timeout. * @brief Channel blocking write with timeout.
@ -211,7 +211,7 @@ typedef struct {
* *
* @api * @api
*/ */
#define srlWriteTimeout(ip, bp, n, time) ((ip)->vmt->writet(ip, bp, n, time)) #define chnWriteTimeout(ip, bp, n, time) ((ip)->vmt->writet(ip, bp, n, time))
/** /**
* @brief Channel blocking read with timeout. * @brief Channel blocking read with timeout.
@ -230,7 +230,7 @@ typedef struct {
* *
* @api * @api
*/ */
#define srlReadTimeout(ip, bp, n, time) ((ip)->vmt->readt(ip, bp, n, time)) #define chnReadTimeout(ip, bp, n, time) ((ip)->vmt->readt(ip, bp, n, time))
/** @} */ /** @} */
#if CH_USE_EVENTS || defined(__DOXYGEN__) #if CH_USE_EVENTS || defined(__DOXYGEN__)
@ -239,48 +239,48 @@ typedef struct {
* @{ * @{
*/ */
/** @brief No pending conditions.*/ /** @brief No pending conditions.*/
#define IO_NO_ERROR 0 #define CHN_NO_ERROR 0
/** @brief Connection happened.*/ /** @brief Connection happened.*/
#define IO_CONNECTED 1 #define ICHN_CONNECTED 1
/** @brief Disconnection happened.*/ /** @brief Disconnection happened.*/
#define IO_DISCONNECTED 2 #define CHN_DISCONNECTED 2
/** @brief Data available in the input queue.*/ /** @brief Data available in the input queue.*/
#define IO_INPUT_AVAILABLE 4 #define CHN_INPUT_AVAILABLE 4
/** @brief Output queue empty.*/ /** @brief Output queue empty.*/
#define IO_OUTPUT_EMPTY 8 #define CHN_OUTPUT_EMPTY 8
/** @brief Transmission end.*/ /** @brief Transmission end.*/
#define IO_TRANSMISSION_END 16 #define CHN_TRANSMISSION_END 16
/** @} */ /** @} */
/** /**
* @brief Type of an I/O condition flags mask. * @brief Type of an I/O condition flags mask.
*/ */
typedef uint_fast16_t ioflags_t; typedef uint_fast16_t chnflags_t;
/** /**
* @brief @p BaseAsynchronousChannel specific methods. * @brief @p BaseAsynchronousChannel specific methods.
*/ */
#define _base_asynchronous_channel_methods \ #define tmp__base_asynchronous_channel_methods \
_base_channel_methods \ _base_channel_methods \
/* Channel read method with timeout specification.*/ \ /* Channel read method with timeout specification.*/ \
ioflags_t (*getflags)(void *instance); chnflags_t (*getflags)(void *instance);
/** /**
* @brief @p BaseAsynchronousChannel specific data. * @brief @p BaseAsynchronousChannel specific data.
*/ */
#define _base_asynchronous_channel_data \ #define tmp__base_asynchronous_channel_data \
_base_channel_data \ _base_channel_data \
/* I/O condition event source.*/ \ /* I/O condition event source.*/ \
EventSource event; \ EventSource event; \
/* I/O condition flags.*/ \ /* I/O condition flags.*/ \
ioflags_t flags; chnflags_t flags;
/** /**
* @extends BaseChannelVMT * @extends BaseChannelVMT
* *
* @brief @p BaseAsynchronousChannel virtual methods table. * @brief @p BaseAsynchronousChannel virtual methods table.
*/ */
struct BaseAsynchronousChannelVMT { struct tmp_BaseAsynchronousChannelVMT {
_base_asynchronous_channel_methods _base_asynchronous_channel_methods
}; };
@ -295,7 +295,7 @@ typedef struct {
/** @brief Virtual Methods Table.*/ /** @brief Virtual Methods Table.*/
const struct BaseAsynchronousChannelVMT *vmt; const struct BaseAsynchronousChannelVMT *vmt;
_base_asynchronous_channel_data _base_asynchronous_channel_data
} BaseAsynchronousChannel; } tmp_BaseAsynchronousChannel;
/** /**
* @name Macro Functions (BaseAsynchronousChannel) * @name Macro Functions (BaseAsynchronousChannel)
@ -311,7 +311,7 @@ typedef struct {
* *
* @api * @api
*/ */
#define srlGetEventSource(ip) (&((ip)->event)) #define chnGetEventSource(ip) (&((ip)->event))
/** /**
* @brief Adds status flags to the channel's mask. * @brief Adds status flags to the channel's mask.
@ -325,7 +325,7 @@ typedef struct {
* *
* @iclass * @iclass
*/ */
#define srlAddFlagsI(ip, mask) { \ #define chnAddFlagsI(ip, mask) { \
(ip)->flags |= (mask); \ (ip)->flags |= (mask); \
chEvtBroadcastI(&(ip)->event); \ chEvtBroadcastI(&(ip)->event); \
} }
@ -340,7 +340,7 @@ typedef struct {
* *
* @api * @api
*/ */
#define srlGetAndClearFlags(ip) ((ip)->vmt->getflags(ip)) #define chnGetAndClearFlags(ip) ((ip)->vmt->getflags(ip))
/** @} */ /** @} */
/** /**
@ -353,16 +353,16 @@ typedef struct {
* *
* @notapi * @notapi
*/ */
#define _ser_get_and_clear_flags_impl(ip) \ #define _chn_get_and_clear_flags_impl(ip) \
ioflags_t mask; \ chnflags_t mask; \
chSysLock(); \ chSysLock(); \
mask = ((BaseAsynchronousChannel *)(ip))->flags; \ mask = ((BaseAsynchronousChannel *)(ip))->flags; \
((BaseAsynchronousChannel *)(ip))->flags = IO_NO_ERROR; \ ((BaseAsynchronousChannel *)(ip))->flags = CHN_NO_ERROR; \
chSysUnlock(); \ chSysUnlock(); \
return mask return mask
#endif /* CH_USE_EVENTS */ #endif /* CH_USE_EVENTS */
#endif /* _IO_SERIAL_H_ */ #endif /* _IO_CHANNEL_H_ */
/** @} */ /** @} */

View File

@ -124,8 +124,8 @@
- FIX: Fixed various minor documentation errors (bug 3484942)(backported - FIX: Fixed various minor documentation errors (bug 3484942)(backported
to 2.4.1). to 2.4.1).
- NEW: Added an abstract interface for serial devices in the HAL. This - NEW: Added an abstract interface for serial devices in the HAL. This
interface is meant to replace the equivalent class present in the interface is meant to replace the equivalent class already present in the
kernel. access macros are similar except for the prefix, "ser" instead kernel. access macros are similar except for the prefix, "chn" instead
of "chIO". of "chIO".
- NEW: Added an abstract interface for block devices in the HAL. This - NEW: Added an abstract interface for block devices in the HAL. This
abstraction layer is meant to unify the access protocol to the SDC and abstraction layer is meant to unify the access protocol to the SDC and