diff --git a/os/hal/include/pal.h b/os/hal/include/pal.h index 7ffa5fc69..dc96f6e60 100644 --- a/os/hal/include/pal.h +++ b/os/hal/include/pal.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -58,7 +58,7 @@ * @brief Safe state for unconnected pads. * @details The state itself is not specified and is architecture dependent, * it may be mapped on @p PAL_MODE_INPUT_PULLUP, - * @p PAL_MODE_INPUT_PULLDOWN or @p PAL_MODE_OUTPUT_PUSHPULL as + * @p PAL_MODE_INPUT_PULLDOWN or @p PAL_MODE_OUTPUT_PUSHPULL for * example. */ #define PAL_MODE_UNCONNECTED 1 @@ -101,12 +101,12 @@ /** * @brief Logical low state. */ -#define PAL_LOW 0 +#define PAL_LOW 0 /** * @brief Logical high state. */ -#define PAL_HIGH 1 +#define PAL_HIGH 1 /** @} */ /*===========================================================================*/ @@ -158,7 +158,9 @@ typedef struct { * @param[in] n bit position within the port * @return The bit mask. */ +#if !defined(PAL_PORT_BIT) || defined(__DOXYGEN__) #define PAL_PORT_BIT(n) ((ioportmask_t)(1 << (n))) +#endif /** * @brief Bits group mask helper. @@ -167,7 +169,9 @@ typedef struct { * @param[in] width group width * @return The group mask. */ +#if !defined(PAL_GROUP_MASK) || defined(__DOXYGEN__) #define PAL_GROUP_MASK(width) ((ioportmask_t)(1 << (width)) - 1) +#endif /** * @brief Data part of a static I/O bus initializer. @@ -179,7 +183,7 @@ typedef struct { * @param[in] width bus width in bits * @param[in] offset bus bit offset within the port */ -#define _IOBUS_DATA(name, port, width, offset) \ +#define _IOBUS_DATA(name, port, width, offset) \ {port, PAL_GROUP_MASK(width), offset} /** @@ -190,7 +194,7 @@ typedef struct { * @param[in] width bus width in bits * @param[in] offset bus bit offset within the port */ -#define IOBUS_DECL(name, port, width, offset) \ +#define IOBUS_DECL(name, port, width, offset) \ IOBus name = _IOBUS_DATA(name, port, width, offset) /** @@ -214,11 +218,12 @@ typedef struct { * @brief Reads the physical I/O port states. * @note The default implementation always return zero and computes the * parameter eventual side effects. + * @note The function can be called from any context. * * @param[in] port port identifier * @return The port logical states. * - * @api + * @special */ #if !defined(pal_lld_readport) || defined(__DOXYGEN__) #define palReadPort(port) ((void)(port), 0) @@ -232,11 +237,12 @@ typedef struct { * value. * @note The default implementation always return zero and computes the * parameter eventual side effects. + * @note The function can be called from any context. * * @param[in] port port identifier * @return The latched logical states. * - * @api + * @special */ #if !defined(pal_lld_readlatch) || defined(__DOXYGEN__) #define palReadLatch(port) ((void)(port), 0) @@ -248,11 +254,12 @@ typedef struct { * @brief Writes a bits mask on a I/O port. * @note The default implementation does nothing except computing the * parameters eventual side effects. + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] bits bits to be written on the specified port * - * @api + * @special */ #if !defined(pal_lld_writeport) || defined(__DOXYGEN__) #define palWritePort(port, bits) ((void)(port), (void)(bits)) @@ -269,14 +276,15 @@ typedef struct { * @note The default implementation is non atomic and not necessarily * optimal. Low level drivers may optimize the function by using * specific hardware or coding. + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] bits bits to be ORed on the specified port * - * @api + * @special */ #if !defined(pal_lld_setport) || defined(__DOXYGEN__) -#define palSetPort(port, bits) \ +#define palSetPort(port, bits) \ palWritePort(port, palReadLatch(port) | (bits)) #else #define palSetPort(port, bits) pal_lld_setport(port, bits) @@ -291,14 +299,15 @@ typedef struct { * @note The default implementation is non atomic and not necessarily * optimal. Low level drivers may optimize the function by using * specific hardware or coding. + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] bits bits to be cleared on the specified port * - * @api + * @special */ #if !defined(pal_lld_clearport) || defined(__DOXYGEN__) -#define palClearPort(port, bits) \ +#define palClearPort(port, bits) \ palWritePort(port, palReadLatch(port) & ~(bits)) #else #define palClearPort(port, bits) pal_lld_clearport(port, bits) @@ -313,14 +322,15 @@ typedef struct { * @note The default implementation is non atomic and not necessarily * optimal. Low level drivers may optimize the function by using * specific hardware or coding. + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] bits bits to be XORed on the specified port * - * @api + * @special */ #if !defined(pal_lld_toggleport) || defined(__DOXYGEN__) -#define palTogglePort(port, bits) \ +#define palTogglePort(port, bits) \ palWritePort(port, palReadLatch(port) ^ (bits)) #else #define palTogglePort(port, bits) pal_lld_toggleport(port, bits) @@ -328,6 +338,7 @@ typedef struct { /** * @brief Reads a group of bits. + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] mask group mask, a logical AND is performed on the input @@ -335,10 +346,10 @@ typedef struct { * @param[in] offset group bit offset within the port * @return The group logical states. * - * @api + * @special */ #if !defined(pal_lld_readgroup) || defined(__DOXYGEN__) -#define palReadGroup(port, mask, offset) \ +#define palReadGroup(port, mask, offset) \ ((palReadPort(port) >> (offset)) & (mask)) #else #define palReadGroup(port, mask, offset) pal_lld_readgroup(port, mask, offset) @@ -346,6 +357,7 @@ typedef struct { /** * @brief Writes a group of bits. + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] mask group mask, a logical AND is performed on the @@ -354,14 +366,14 @@ typedef struct { * @param[in] bits bits to be written. Values exceeding the group * width are masked. * - * @api + * @special */ #if !defined(pal_lld_writegroup) || defined(__DOXYGEN__) -#define palWriteGroup(port, mask, offset, bits) \ - palWritePort(port, (palReadLatch(port) & ~((mask) << (offset))) | \ +#define palWriteGroup(port, mask, offset, bits) \ + palWritePort(port, (palReadLatch(port) & ~((mask) << (offset))) | \ (((bits) & (mask)) << (offset))) #else -#define palWriteGroup(port, mask, offset, bits) \ +#define palWriteGroup(port, mask, offset, bits) \ pal_lld_writegroup(port, mask, offset, bits) #endif @@ -371,13 +383,14 @@ typedef struct { * @details This function programs a pads group belonging to the same port * with the specified mode. * @note Programming an unknown or unsupported mode is silently ignored. + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] mask group mask * @param[in] offset group bit offset within the port * @param[in] mode group mode * - * @api + * @special */ #if !defined(pal_lld_setgroupmode) || defined(__DOXYGEN__) #define palSetGroupMode(port, mask, offset, mode) @@ -392,6 +405,7 @@ typedef struct { * drivers may optimize the function by using specific hardware * or coding. * @note The default implementation internally uses the @p palReadPort(). + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] pad pad number within the port @@ -399,7 +413,7 @@ typedef struct { * @retval PAL_LOW low logical state. * @retval PAL_HIGH high logical state. * - * @api + * @special */ #if !defined(pal_lld_readpad) || defined(__DOXYGEN__) #define palReadPad(port, pad) ((palReadPort(port) >> (pad)) & 1) @@ -418,17 +432,18 @@ typedef struct { * specific hardware or coding. * @note The default implementation internally uses the @p palReadLatch() * and @p palWritePort(). + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] pad pad number within the port * @param[in] bit logical value, the value must be @p PAL_LOW or * @p PAL_HIGH * - * @api + * @special */ #if !defined(pal_lld_writepad) || defined(__DOXYGEN__) -#define palWritePad(port, pad, bit) \ - palWritePort(port, (palReadLatch(port) & ~PAL_PORT_BIT(pad)) | \ +#define palWritePad(port, pad, bit) \ + palWritePort(port, (palReadLatch(port) & ~PAL_PORT_BIT(pad)) | \ (((bit) & 1) << pad)) #else #define palWritePad(port, pad, bit) pal_lld_writepad(port, pad, bit) @@ -444,11 +459,12 @@ typedef struct { * optimal. Low level drivers may optimize the function by using * specific hardware or coding. * @note The default implementation internally uses the @p palSetPort(). + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] pad pad number within the port * - * @api + * @special */ #if !defined(pal_lld_setpad) || defined(__DOXYGEN__) #define palSetPad(port, pad) palSetPort(port, PAL_PORT_BIT(pad)) @@ -466,11 +482,12 @@ typedef struct { * optimal. Low level drivers may optimize the function by using * specific hardware or coding. * @note The default implementation internally uses the @p palClearPort(). + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] pad pad number within the port * - * @api + * @special */ #if !defined(pal_lld_clearpad) || defined(__DOXYGEN__) #define palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad)) @@ -488,11 +505,12 @@ typedef struct { * optimal. Low level drivers may optimize the function by using * specific hardware or coding. * @note The default implementation internally uses the @p palTogglePort(). + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] pad pad number within the port * - * @api + * @special */ #if !defined(pal_lld_togglepad) || defined(__DOXYGEN__) #define palTogglePad(port, pad) palTogglePort(port, PAL_PORT_BIT(pad)) @@ -500,7 +518,6 @@ typedef struct { #define palTogglePad(port, pad) pal_lld_togglepad(port, pad) #endif - /** * @brief Pad mode setup. * @details This function programs a pad with the specified mode. @@ -508,15 +525,16 @@ typedef struct { * drivers may optimize the function by using specific hardware * or coding. * @note Programming an unknown or unsupported mode is silently ignored. + * @note The function can be called from any context. * * @param[in] port port identifier * @param[in] pad pad number within the port * @param[in] mode pad mode * - * @api + * @special */ #if !defined(pal_lld_setpadmode) || defined(__DOXYGEN__) -#define palSetPadMode(port, pad, mode) \ +#define palSetPadMode(port, pad, mode) \ palSetGroupMode(port, PAL_PORT_BIT(pad), 0, mode) #else #define palSetPadMode(port, pad, mode) pal_lld_setpadmode(port, pad, mode) diff --git a/os/hal/src/pal.c b/os/hal/src/pal.c index 3f8c91f60..3481ba6f0 100644 --- a/os/hal/src/pal.c +++ b/os/hal/src/pal.c @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -47,7 +47,7 @@ /*===========================================================================*/ /*===========================================================================*/ -/* Driver local variables. */ +/* Driver local variables and types. */ /*===========================================================================*/ /*===========================================================================*/ @@ -67,16 +67,16 @@ * @note The function internally uses the @p palReadGroup() macro. The use * of this function is preferred when you value code size, readability * and error checking over speed. + * @note The function can be called from any context. * * @param[in] bus the I/O bus, pointer to a @p IOBus structure * @return The bus logical states. * - * @api + * @special */ ioportmask_t palReadBus(IOBus *bus) { - chDbgCheck((bus != NULL) && - (bus->offset < PAL_IOPORTS_WIDTH), "palReadBus"); + osalDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH)); return palReadGroup(bus->portid, bus->mask, bus->offset); } @@ -90,18 +90,18 @@ ioportmask_t palReadBus(IOBus *bus) { * @note The default implementation is non atomic and not necessarily * optimal. Low level drivers may optimize the function by using * specific hardware or coding. + * @note The function can be called from any context. * * @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. * - * @api + * @special */ void palWriteBus(IOBus *bus, ioportmask_t bits) { - chDbgCheck((bus != NULL) && - (bus->offset < PAL_IOPORTS_WIDTH), "palWriteBus"); + osalDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH)); palWriteGroup(bus->portid, bus->mask, bus->offset, bits); } @@ -115,16 +115,16 @@ void palWriteBus(IOBus *bus, ioportmask_t bits) { * @note The default implementation is non atomic and not necessarily * optimal. Low level drivers may optimize the function by using * specific hardware or coding. + * @note The function can be called from any context. * * @param[in] bus the I/O bus, pointer to a @p IOBus structure * @param[in] mode the mode * - * @api + * @special */ void palSetBusMode(IOBus *bus, iomode_t mode) { - chDbgCheck((bus != NULL) && - (bus->offset < PAL_IOPORTS_WIDTH), "palSetBusMode"); + osalDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH)); palSetGroupMode(bus->portid, bus->mask, bus->offset, mode); } diff --git a/readme.txt b/readme.txt index 3d03eef72..368fe2261 100644 --- a/readme.txt +++ b/readme.txt @@ -79,6 +79,7 @@ ***************************************************************************** *** 2.4.5 *** +- FIX: Fixed PAL driver documentation error (bug #427). - FIX: Fixed wrong RTC macro names in STM32L1xx HAL (bug #422). *** 2.4.4 ***