From f9ecd9f46e829010b0457a04993d2a89a37c104a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 7 Jun 2009 16:11:41 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1024 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- .../ARM7-LPC214x/{ioports_lld.h => pal_lld.h} | 103 ++++++++++-------- ports/ARM7-LPC214x/port.dox | 4 +- ports/ARMCM3-STM32F103/pal_lld.h | 3 +- src/lib/pal.h | 1 - src/templates/pal_lld.h | 1 - 5 files changed, 62 insertions(+), 50 deletions(-) rename ports/ARM7-LPC214x/{ioports_lld.h => pal_lld.h} (62%) diff --git a/ports/ARM7-LPC214x/ioports_lld.h b/ports/ARM7-LPC214x/pal_lld.h similarity index 62% rename from ports/ARM7-LPC214x/ioports_lld.h rename to ports/ARM7-LPC214x/pal_lld.h index cedc9e361..ce56f9562 100644 --- a/ports/ARM7-LPC214x/ioports_lld.h +++ b/ports/ARM7-LPC214x/pal_lld.h @@ -18,14 +18,14 @@ */ /** - * @file ports/ARM-LPC214x/ioports_lld.h + * @file ports/ARM7-LPC214x/ioports_lld.h * @brief LPC214x FIO low level driver - * @addtogroup LPC214x_IOPORTS + * @addtogroup LPC214x_PAL * @{ */ -#ifndef _IOPORTS_LLD_H_ -#define _IOPORTS_LLD_H_ +#ifndef _PAL_LLD_H_ +#define _PAL_LLD_H_ #ifndef _LPC214X_H_ #include "lpc214x.h" @@ -38,7 +38,7 @@ /** * @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. @@ -73,23 +73,14 @@ typedef FIO * ioportid_t; * @brief FIO subsystem initialization. * @details Enables the access through the fast registers. */ -#define ioport_init_lld() { \ +#define pal_lld_init() { \ 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. + * @details This function is implemented by reading the FIO PIN register, the + * implementation has no side effects. * * @param[in] port the port identifier * @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 * 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. + * @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] 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 * 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. + * @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] 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 * code. */ -#define ioport_clear_lld(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)) +#define pal_lld_clearport(port, bits) ((port)->FIO_CLR = (bits)) /** * @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] bits the bits to be written on the I/O bus. Values exceeding - * the bus width are masked so most significant bits are lost. + * @param[in] port the port identifier + * @param[in] mask the group mask + * @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 * code. */ -#define ioport_writebus_lld(bus, bits) { \ - (port)->FIO_MASK = (bus)->bus_mask; \ - (port)->FIO_PIN = (bits) << (bus)->bus_offset; \ +#define pal_lld_writegroup(port, mask, offset, bits) { \ + (port)->FIO_MASK = (mask) << (offset); \ + (port)->FIO_PIN = (bits) << (offset); \ (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 - * @return the bus bits + * @param[in] port the port identifier + * @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 * code. */ -#define ioport_readbus_lld(bus) \ - (((bus)->bus_portid->FIO_PIN & (bus)->bus_mask) >> (bus)->bus_offset) +#define pal_lld_writepad(port, pad, bit) pal_lld_writegroup(port, 1, pad, bit) /** * @brief FIO port setup. * @details This function initializes a FIO port, note that this functionality * 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); \ } -#endif /* _IOPORTS_LLD_H_ */ +#endif /* _PAL_LLD_H_ */ /** @} */ diff --git a/ports/ARM7-LPC214x/port.dox b/ports/ARM7-LPC214x/port.dox index 7db0867b2..69d8d6198 100644 --- a/ports/ARM7-LPC214x/port.dox +++ b/ports/ARM7-LPC214x/port.dox @@ -49,14 +49,14 @@ * @defgroup LPC214x_IOPORTS I/O Ports Support * @brief I/O Ports peripherals support. * @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. * - Atomic set/reset functions. * - Atomic set+reset function (atomic bus operations). * - Output latched 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 */ diff --git a/ports/ARMCM3-STM32F103/pal_lld.h b/ports/ARMCM3-STM32F103/pal_lld.h index 33e6f959a..ec4896add 100644 --- a/ports/ARMCM3-STM32F103/pal_lld.h +++ b/ports/ARMCM3-STM32F103/pal_lld.h @@ -132,7 +132,7 @@ typedef GPIO_TypeDef * ioportid_t; /** * @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. * * @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] bits the bits to be written. Values exceeding the group width * are masked. - * @return The group logical states. * * @note This function is not meant to be invoked directly by the application * code. diff --git a/src/lib/pal.h b/src/lib/pal.h index 76bf111b6..662df87ee 100644 --- a/src/lib/pal.h +++ b/src/lib/pal.h @@ -239,7 +239,6 @@ typedef struct { * @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. - * @return The group logical states. */ #if !defined(pal_lld_writegroup) || defined(__DOXYGEN__) #define palWriteGroup(port, mask, offset, bits) { \ diff --git a/src/templates/pal_lld.h b/src/templates/pal_lld.h index 246ab8d9f..38d0253e2 100644 --- a/src/templates/pal_lld.h +++ b/src/templates/pal_lld.h @@ -171,7 +171,6 @@ typedef uint32_t ioportid_t; * @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. - * @return The group logical states. * * @note This function is not meant to be invoked directly by the application * code.