Added I/O ports low level driver template.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1006 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
d9d8d0bc90
commit
080e6abe80
|
@ -401,6 +401,15 @@
|
|||
* @ingroup IO
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup IOPortsLLD I/O Ports Low Level Driver
|
||||
* @brief Digital I/O ports low level driver template.
|
||||
* @details This file is a template for an I/O port low level driver. This
|
||||
* file implements the prysical layer of an I/O port driver.
|
||||
*
|
||||
* @ingroup IOPorts
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Channels Abstract I/O Channels
|
||||
* @brief Abstract I/O Channels.
|
||||
|
|
|
@ -70,9 +70,9 @@ typedef struct {
|
|||
* @brief Writes a bits mask on a I/O port.
|
||||
*
|
||||
* @param[in] port the port identifier
|
||||
* @param[in] value the value to be written on the specified port
|
||||
* @param[in] bits the bits to be written on the specified port
|
||||
*/
|
||||
#define chPortWrite(port, value) ioport_write_lld(port, value)
|
||||
#define chPortWrite(port, bits) ioport_write_lld(port, bits)
|
||||
|
||||
/**
|
||||
* @brief Reads an I/O port.
|
||||
|
@ -86,50 +86,50 @@ typedef struct {
|
|||
* @brief Sets a bits mask on a I/O port.
|
||||
*
|
||||
* @param[in] port the port identifier
|
||||
* @param[in] mask the mask to be ORed on the specified port
|
||||
* @param[in] bits the bits to be ORed on the specified port
|
||||
*
|
||||
* @note The operation is not guaranteed to be atomic on all the architectures,
|
||||
* for atomicity and/or portability reasons you may need to enclose port
|
||||
* I/O operations between @p chSysLock() and @p chSysUnlock().
|
||||
*/
|
||||
#define chPortSet(port, mask) ioport_set_lld(port, mask)
|
||||
#define chPortSet(port, bits) ioport_set_lld(port, bits)
|
||||
|
||||
/**
|
||||
* @brief Clears a bits mask on a I/O port.
|
||||
*
|
||||
* @param[in] port the port identifier
|
||||
* @param[in] mask the mask to be cleared on the specified port
|
||||
* @param[in] bits the bits to be cleared on the specified port
|
||||
*
|
||||
* @note The operation is not guaranteed to be atomic on all the architectures,
|
||||
* for atomicity and/or portability reasons you may need to enclose port
|
||||
* I/O operations between @p chSysLock() and @p chSysUnlock().
|
||||
*/
|
||||
#define chPortClear(port, mask) ioport_clear_lld(port mask)
|
||||
#define chPortClear(port, bits) ioport_clear_lld(port, bits)
|
||||
|
||||
/**
|
||||
* @brief Toggles a bits mask on a I/O port.
|
||||
*
|
||||
* @param[in] port the port identifier
|
||||
* @param[in] mask the mask to be XORed on the specified port
|
||||
* @param[in] bits the bits to be XORed on the specified port
|
||||
*
|
||||
* @note The operation is not guaranteed to be atomic on all the architectures,
|
||||
* for atomicity and/or portability reasons you may need to enclose port
|
||||
* I/O operations between @p chSysLock() and @p chSysUnlock().
|
||||
*/
|
||||
#define chPortToggle(port, mask) ioport_clear_lld(port mask)
|
||||
#define chPortToggle(port, bits) ioport_clear_lld(port, bits)
|
||||
|
||||
/**
|
||||
* @brief Writes a value on an I/O bus.
|
||||
*
|
||||
* @param[in] bus the I/O bus
|
||||
* @param[in] value the value to be written on the I/O bus. Values exceeding
|
||||
* the bus width are masked so most significant bits may be lost.
|
||||
* @param[in] bits the bits to be written on the I/O bus. Values exceeding
|
||||
* the bus width are masked so most significant bits are lost.
|
||||
*
|
||||
* @note The operation is not guaranteed to be atomic on all the architectures,
|
||||
* for atomicity and/or portability reasons you may need to enclose port
|
||||
* I/O operations between @p chSysLock() and @p chSysUnlock().
|
||||
*/
|
||||
#define chPortWriteBus(bus, value) ioport_writebus_lld(bus, value)
|
||||
#define chPortWriteBus(bus, bits) ioport_writebus_lld(bus, bits)
|
||||
|
||||
/**
|
||||
* @brief Reads a value from an I/O bus.
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ioports_lld.h
|
||||
* @brief I/O ports low level driver
|
||||
* @addtogroup IOPortsLLD
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _IOPORTS_LLD_H_
|
||||
#define _IOPORTS_LLD_H_
|
||||
|
||||
/*===========================================================================*/
|
||||
/* I/O Ports Types and constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Width, in bits, of an I/O port.
|
||||
*/
|
||||
#define IOPORTS_WIDTH 32
|
||||
|
||||
/**
|
||||
* @brief Digital I/O port sized unsigned type.
|
||||
*/
|
||||
typedef uint32_t ioportmask_t;
|
||||
|
||||
/**
|
||||
* @brief Port Identifier.
|
||||
* @details This type can be a scalar or some kind of pointer, do not make
|
||||
* any assumption about it, use the provided macros when populating
|
||||
* variables of this type.
|
||||
*/
|
||||
typedef uint32_t ioportid_t;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* I/O Ports Identifiers. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief First I/O port identifier.
|
||||
* @details Low level drivers can define multiple ports, please use this
|
||||
* naming convention.
|
||||
*/
|
||||
#define IOPORT_A 0
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Implementation, some of the following macros could be implemented as */
|
||||
/* functions, please put them in a file named ioports_lld.c if so. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Writes a bits mask on a I/O port.
|
||||
*
|
||||
* @param[in] port the port identifier
|
||||
* @param[in] bits the bits to be written on the specified port
|
||||
*
|
||||
* @note This function is not meant to be invoked directly by the application
|
||||
* code.
|
||||
*/
|
||||
#define ioport_write_lld(port, bits)
|
||||
|
||||
/**
|
||||
* @brief Reads an I/O port.
|
||||
*
|
||||
* @param[in] port the port identifier
|
||||
* @return the port bits
|
||||
*
|
||||
* @note This function is not meant to be invoked directly by the application
|
||||
* code.
|
||||
*/
|
||||
#define ioport_read_lld(port)
|
||||
|
||||
/**
|
||||
* @brief Sets a bits mask on a I/O port.
|
||||
*
|
||||
* @param[in] port the port identifier
|
||||
* @param[in] bits the bits to be ORed on the specified port
|
||||
*
|
||||
* @note This function is not meant to be invoked directly by the application
|
||||
* code.
|
||||
*/
|
||||
#define ioport_set_lld(port, bits)
|
||||
|
||||
/**
|
||||
* @brief Clears a bits mask on a I/O port.
|
||||
*
|
||||
* @param[in] port the port identifier
|
||||
* @param[in] bits the bits to be cleared on the specified port
|
||||
*
|
||||
* @note This function is not meant to be invoked directly by the application
|
||||
* code.
|
||||
*/
|
||||
#define ioport_clear_lld(port, bits)
|
||||
|
||||
/**
|
||||
* @brief Toggles a bits mask on a I/O port.
|
||||
*
|
||||
* @param[in] port the port identifier
|
||||
* @param[in] bits the bits to be XORed on the specified port
|
||||
*
|
||||
* @note This function is not meant to be invoked directly by the application
|
||||
* code.
|
||||
*/
|
||||
#define ioport_clear_lld(port, bits)
|
||||
|
||||
/**
|
||||
* @brief Writes a value on an I/O bus.
|
||||
*
|
||||
* @param[in] bus the I/O bus
|
||||
* @param[in] bits the bits to be written on the I/O bus. Values exceeding
|
||||
* the bus width are masked so most significant bits are lost.
|
||||
*
|
||||
* @note This function is not meant to be invoked directly by the application
|
||||
* code.
|
||||
*/
|
||||
#define ioport_writebus_lld(bus, bits)
|
||||
|
||||
/**
|
||||
* @brief Reads a value from an I/O bus.
|
||||
*
|
||||
* @param[in] bus the I/O bus
|
||||
* @return the bus bits
|
||||
*
|
||||
* @note This function is not meant to be invoked directly by the application
|
||||
* code.
|
||||
*/
|
||||
#define ioport_readbus_lld(bus)
|
||||
|
||||
#endif /* _IOPORTS_LLD_H_ */
|
||||
|
||||
/** @} */
|
Loading…
Reference in New Issue