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

master
gdisirio 2009-06-07 16:11:41 +00:00
parent a5df28e309
commit f9ecd9f46e
5 changed files with 62 additions and 50 deletions

View File

@ -18,14 +18,14 @@
*/ */
/** /**
* @file ports/ARM-LPC214x/ioports_lld.h * @file ports/ARM7-LPC214x/ioports_lld.h
* @brief LPC214x FIO low level driver * @brief LPC214x FIO low level driver
* @addtogroup LPC214x_IOPORTS * @addtogroup LPC214x_PAL
* @{ * @{
*/ */
#ifndef _IOPORTS_LLD_H_ #ifndef _PAL_LLD_H_
#define _IOPORTS_LLD_H_ #define _PAL_LLD_H_
#ifndef _LPC214X_H_ #ifndef _LPC214X_H_
#include "lpc214x.h" #include "lpc214x.h"
@ -38,7 +38,7 @@
/** /**
* @brief Width, in bits, of an I/O port. * @brief Width, in bits, of an I/O port.
*/ */
#define IOPORTS_WIDTH 32 #define PAL_IOPORTS_WIDTH 32
/** /**
* @brief Digital I/O port sized unsigned type. * @brief Digital I/O port sized unsigned type.
@ -73,23 +73,14 @@ typedef FIO * ioportid_t;
* @brief FIO subsystem initialization. * @brief FIO subsystem initialization.
* @details Enables the access through the fast registers. * @details Enables the access through the fast registers.
*/ */
#define ioport_init_lld() { \ #define pal_lld_init() { \
SCS = 3; \ SCS = 3; \
} }
/**
* @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) ((port)->FIO_PIN = (bits))
/** /**
* @brief Reads an I/O port. * @brief Reads an I/O port.
* @details This function is implemented by reading the FIO PIN register, the
* implementation has no side effects.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
* @return the port bits * @return the port bits
@ -97,10 +88,38 @@ typedef FIO * ioportid_t;
* @note This function is not meant to be invoked directly by the application * @note This function is not meant to be invoked directly by the application
* code. * code.
*/ */
#define ioport_read_lld(port) ((port)->FIO_PIN) #define pal_lld_readport(port) ((port)->FIO_PIN)
/**
* @brief Reads the output latch.
* @details This function is implemented by reading the FIO SET register, the
* implementation has no side effects.
*
* @param[in] port the port identifier
* @return The latched logical states.
*
* @note This function is not meant to be invoked directly by the application
* code.
*/
#define pal_lld_readlatch(port) ((port)->FIO_SET)
/**
* @brief Writes a bits mask on a I/O port.
* @details This function is implemented by writing the FIO PIN register, the
* implementation has no side effects.
*
* @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 pal_lld_writeport(port, bits) ((port)->FIO_PIN = (bits))
/** /**
* @brief Sets a bits mask on a I/O port. * @brief Sets a bits mask on a I/O port.
* @details This function is implemented by writing the FIO SET register, the
* implementation has no side effects.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
* @param[in] bits the bits to be ORed on the specified port * @param[in] bits the bits to be ORed on the specified port
@ -108,10 +127,12 @@ typedef FIO * ioportid_t;
* @note This function is not meant to be invoked directly by the application * @note This function is not meant to be invoked directly by the application
* code. * code.
*/ */
#define ioport_set_lld(port, bits) ((port)->FIO_SET = (bits)) #define pal_lld_setport(port, bits) ((port)->FIO_SET = (bits))
/** /**
* @brief Clears a bits mask on a I/O port. * @brief Clears a bits mask on a I/O port.
* @details This function is implemented by writing the FIO CLR register, the
* implementation has no side effects.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
* @param[in] bits the bits to be cleared on the specified port * @param[in] bits the bits to be cleared on the specified port
@ -119,56 +140,50 @@ typedef FIO * ioportid_t;
* @note This function is not meant to be invoked directly by the application * @note This function is not meant to be invoked directly by the application
* code. * code.
*/ */
#define ioport_clear_lld(port, bits) ((port)->FIO_CLR = (bits)) #define pal_lld_clearport(port, bits) ((port)->FIO_CLR = (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_toggle_lld(port, bits) ((port)->FIO_PIN ^= (bits))
/** /**
* @brief Writes a value on an I/O bus. * @brief Writes a value on an I/O bus.
* @details This function is implemented by writing the FIO PIN and MASK
* registers, the implementation is not atomic because the multiple
* accesses.
* *
* @param[in] bus the I/O bus, pointer to a @p IOBus structure * @param[in] port the port identifier
* @param[in] bits the bits to be written on the I/O bus. Values exceeding * @param[in] mask the group mask
* the bus width are masked so most significant bits are lost. * @param[in] offset the group bit offset within the port
* @param[in] bits the bits to be written. Values exceeding the group width
* are masked.
* *
* @note This function is not meant to be invoked directly by the application * @note This function is not meant to be invoked directly by the application
* code. * code.
*/ */
#define ioport_writebus_lld(bus, bits) { \ #define pal_lld_writegroup(port, mask, offset, bits) { \
(port)->FIO_MASK = (bus)->bus_mask; \ (port)->FIO_MASK = (mask) << (offset); \
(port)->FIO_PIN = (bits) << (bus)->bus_offset; \ (port)->FIO_PIN = (bits) << (offset); \
(port)->FIO_MASK = 0; \ (port)->FIO_MASK = 0; \
} }
/** /**
* @brief Reads a value from an I/O bus. * @brief Writes a logical state on an output pad.
* *
* @param[in] bus the I/O bus, pointer to a @p IOBus structure * @param[in] port the port identifier
* @return the bus bits * @param[in] pad the pad number within the port
* @param[out] bit the logical value, the value must be @p 0 or @p 1
* *
* @note This function is not meant to be invoked directly by the application * @note This function is not meant to be invoked directly by the application
* code. * code.
*/ */
#define ioport_readbus_lld(bus) \ #define pal_lld_writepad(port, pad, bit) pal_lld_writegroup(port, 1, pad, bit)
(((bus)->bus_portid->FIO_PIN & (bus)->bus_mask) >> (bus)->bus_offset)
/** /**
* @brief FIO port setup. * @brief FIO port setup.
* @details This function initializes a FIO port, note that this functionality * @details This function initializes a FIO port, note that this functionality
* is LPC214x specific and non portable. * is LPC214x specific and non portable.
*/ */
#define ioport_lpc214x_set_direction_lld(port, dir) { \ #define pal_lld_lpc214x_set_direction(port, dir) { \
(port)->FIO_DIR = (dir); \ (port)->FIO_DIR = (dir); \
} }
#endif /* _IOPORTS_LLD_H_ */ #endif /* _PAL_LLD_H_ */
/** @} */ /** @} */

View File

@ -49,14 +49,14 @@
* @defgroup LPC214x_IOPORTS I/O Ports Support * @defgroup LPC214x_IOPORTS I/O Ports Support
* @brief I/O Ports peripherals support. * @brief I/O Ports peripherals support.
* @details This module supports the LPC214x FIO controller. The controller * @details This module supports the LPC214x FIO controller. The controller
* supports the following features (see @ref IOPorts): * supports the following features (see @ref PAL):
* - 32 bits wide ports. * - 32 bits wide ports.
* - Atomic set/reset functions. * - Atomic set/reset functions.
* - Atomic set+reset function (atomic bus operations). * - Atomic set+reset function (atomic bus operations).
* - Output latched regardless of the pad setting. * - Output latched regardless of the pad setting.
* - Direct read of input pads regardless of the pad setting. * - Direct read of input pads regardless of the pad setting.
* . * .
* The only non atomic operations are bit toggling and bus writing. * The only non atomic operations are bit toggling and bus/group writing.
* *
* @ingroup LPC214x * @ingroup LPC214x
*/ */

View File

@ -132,7 +132,7 @@ typedef GPIO_TypeDef * ioportid_t;
/** /**
* @brief Reads the output latch. * @brief Reads the output latch.
* @details This function is implemented by reading the GPIO oDR register, the * @details This function is implemented by reading the GPIO ODR register, the
* implementation has no side effects. * implementation has no side effects.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
@ -192,7 +192,6 @@ typedef GPIO_TypeDef * ioportid_t;
* @param[in] offset the group bit offset within the port * @param[in] offset the group bit offset within the port
* @param[in] bits the bits to be written. Values exceeding the group width * @param[in] bits the bits to be written. Values exceeding the group width
* are masked. * are masked.
* @return The group logical states.
* *
* @note This function is not meant to be invoked directly by the application * @note This function is not meant to be invoked directly by the application
* code. * code.

View File

@ -239,7 +239,6 @@ typedef struct {
* @param[in] offset the group bit offset within the port * @param[in] offset the group bit offset within the port
* @param[in] bits the bits to be written. Values exceeding the group width * @param[in] bits the bits to be written. Values exceeding the group width
* are masked. * are masked.
* @return The group logical states.
*/ */
#if !defined(pal_lld_writegroup) || defined(__DOXYGEN__) #if !defined(pal_lld_writegroup) || defined(__DOXYGEN__)
#define palWriteGroup(port, mask, offset, bits) { \ #define palWriteGroup(port, mask, offset, bits) { \

View File

@ -171,7 +171,6 @@ typedef uint32_t ioportid_t;
* @param[in] offset the group bit offset within the port * @param[in] offset the group bit offset within the port
* @param[in] bits the bits to be written. Values exceeding the group width * @param[in] bits the bits to be written. Values exceeding the group width
* are masked. * are masked.
* @return The group logical states.
* *
* @note This function is not meant to be invoked directly by the application * @note This function is not meant to be invoked directly by the application
* code. * code.