Fixed bug bug #427.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/stable_2.4.x@6155 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
gdisirio 2013-08-15 08:44:15 +00:00
parent 236e9ee11e
commit 268462fc70
3 changed files with 62 additions and 43 deletions

View File

@ -1,6 +1,6 @@
/* /*
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 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. This file is part of ChibiOS/RT.
@ -58,7 +58,7 @@
* @brief Safe state for <b>unconnected</b> pads. * @brief Safe state for <b>unconnected</b> pads.
* @details The state itself is not specified and is architecture dependent, * @details The state itself is not specified and is architecture dependent,
* it may be mapped on @p PAL_MODE_INPUT_PULLUP, * 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. * example.
*/ */
#define PAL_MODE_UNCONNECTED 1 #define PAL_MODE_UNCONNECTED 1
@ -101,12 +101,12 @@
/** /**
* @brief Logical low state. * @brief Logical low state.
*/ */
#define PAL_LOW 0 #define PAL_LOW 0
/** /**
* @brief Logical high state. * @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 * @param[in] n bit position within the port
* @return The bit mask. * @return The bit mask.
*/ */
#if !defined(PAL_PORT_BIT) || defined(__DOXYGEN__)
#define PAL_PORT_BIT(n) ((ioportmask_t)(1 << (n))) #define PAL_PORT_BIT(n) ((ioportmask_t)(1 << (n)))
#endif
/** /**
* @brief Bits group mask helper. * @brief Bits group mask helper.
@ -167,7 +169,9 @@ typedef struct {
* @param[in] width group width * @param[in] width group width
* @return The group mask. * @return The group mask.
*/ */
#if !defined(PAL_GROUP_MASK) || defined(__DOXYGEN__)
#define PAL_GROUP_MASK(width) ((ioportmask_t)(1 << (width)) - 1) #define PAL_GROUP_MASK(width) ((ioportmask_t)(1 << (width)) - 1)
#endif
/** /**
* @brief Data part of a static I/O bus initializer. * @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] width bus width in bits
* @param[in] offset bus bit offset within the port * @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} {port, PAL_GROUP_MASK(width), offset}
/** /**
@ -190,7 +194,7 @@ typedef struct {
* @param[in] width bus width in bits * @param[in] width bus width in bits
* @param[in] offset bus bit offset within the port * @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) IOBus name = _IOBUS_DATA(name, port, width, offset)
/** /**
@ -214,11 +218,12 @@ typedef struct {
* @brief Reads the physical I/O port states. * @brief Reads the physical I/O port states.
* @note The default implementation always return zero and computes the * @note The default implementation always return zero and computes the
* parameter eventual side effects. * parameter eventual side effects.
* @note The function can be called from any context.
* *
* @param[in] port port identifier * @param[in] port port identifier
* @return The port logical states. * @return The port logical states.
* *
* @api * @special
*/ */
#if !defined(pal_lld_readport) || defined(__DOXYGEN__) #if !defined(pal_lld_readport) || defined(__DOXYGEN__)
#define palReadPort(port) ((void)(port), 0) #define palReadPort(port) ((void)(port), 0)
@ -232,11 +237,12 @@ typedef struct {
* value. * value.
* @note The default implementation always return zero and computes the * @note The default implementation always return zero and computes the
* parameter eventual side effects. * parameter eventual side effects.
* @note The function can be called from any context.
* *
* @param[in] port port identifier * @param[in] port port identifier
* @return The latched logical states. * @return The latched logical states.
* *
* @api * @special
*/ */
#if !defined(pal_lld_readlatch) || defined(__DOXYGEN__) #if !defined(pal_lld_readlatch) || defined(__DOXYGEN__)
#define palReadLatch(port) ((void)(port), 0) #define palReadLatch(port) ((void)(port), 0)
@ -248,11 +254,12 @@ typedef struct {
* @brief Writes a bits mask on a I/O port. * @brief Writes a bits mask on a I/O port.
* @note The default implementation does nothing except computing the * @note The default implementation does nothing except computing the
* parameters eventual side effects. * parameters eventual side effects.
* @note The function can be called from any context.
* *
* @param[in] port port identifier * @param[in] port port identifier
* @param[in] bits bits to be written on the specified port * @param[in] bits bits to be written on the specified port
* *
* @api * @special
*/ */
#if !defined(pal_lld_writeport) || defined(__DOXYGEN__) #if !defined(pal_lld_writeport) || defined(__DOXYGEN__)
#define palWritePort(port, bits) ((void)(port), (void)(bits)) #define palWritePort(port, bits) ((void)(port), (void)(bits))
@ -269,14 +276,15 @@ typedef struct {
* @note The default implementation is non atomic and not necessarily * @note The default implementation is non atomic and not necessarily
* optimal. Low level drivers may optimize the function by using * optimal. Low level drivers may optimize the function by using
* specific hardware or coding. * specific hardware or coding.
* @note The function can be called from any context.
* *
* @param[in] port port identifier * @param[in] port port identifier
* @param[in] bits bits to be ORed on the specified port * @param[in] bits bits to be ORed on the specified port
* *
* @api * @special
*/ */
#if !defined(pal_lld_setport) || defined(__DOXYGEN__) #if !defined(pal_lld_setport) || defined(__DOXYGEN__)
#define palSetPort(port, bits) \ #define palSetPort(port, bits) \
palWritePort(port, palReadLatch(port) | (bits)) palWritePort(port, palReadLatch(port) | (bits))
#else #else
#define palSetPort(port, bits) pal_lld_setport(port, bits) #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 * @note The default implementation is non atomic and not necessarily
* optimal. Low level drivers may optimize the function by using * optimal. Low level drivers may optimize the function by using
* specific hardware or coding. * specific hardware or coding.
* @note The function can be called from any context.
* *
* @param[in] port port identifier * @param[in] port port identifier
* @param[in] bits bits to be cleared on the specified port * @param[in] bits bits to be cleared on the specified port
* *
* @api * @special
*/ */
#if !defined(pal_lld_clearport) || defined(__DOXYGEN__) #if !defined(pal_lld_clearport) || defined(__DOXYGEN__)
#define palClearPort(port, bits) \ #define palClearPort(port, bits) \
palWritePort(port, palReadLatch(port) & ~(bits)) palWritePort(port, palReadLatch(port) & ~(bits))
#else #else
#define palClearPort(port, bits) pal_lld_clearport(port, bits) #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 * @note The default implementation is non atomic and not necessarily
* optimal. Low level drivers may optimize the function by using * optimal. Low level drivers may optimize the function by using
* specific hardware or coding. * specific hardware or coding.
* @note The function can be called from any context.
* *
* @param[in] port port identifier * @param[in] port port identifier
* @param[in] bits bits to be XORed on the specified port * @param[in] bits bits to be XORed on the specified port
* *
* @api * @special
*/ */
#if !defined(pal_lld_toggleport) || defined(__DOXYGEN__) #if !defined(pal_lld_toggleport) || defined(__DOXYGEN__)
#define palTogglePort(port, bits) \ #define palTogglePort(port, bits) \
palWritePort(port, palReadLatch(port) ^ (bits)) palWritePort(port, palReadLatch(port) ^ (bits))
#else #else
#define palTogglePort(port, bits) pal_lld_toggleport(port, bits) #define palTogglePort(port, bits) pal_lld_toggleport(port, bits)
@ -328,6 +338,7 @@ typedef struct {
/** /**
* @brief Reads a group of bits. * @brief Reads a group of bits.
* @note The function can be called from any context.
* *
* @param[in] port port identifier * @param[in] port port identifier
* @param[in] mask group mask, a logical AND is performed on the input * @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 * @param[in] offset group bit offset within the port
* @return The group logical states. * @return The group logical states.
* *
* @api * @special
*/ */
#if !defined(pal_lld_readgroup) || defined(__DOXYGEN__) #if !defined(pal_lld_readgroup) || defined(__DOXYGEN__)
#define palReadGroup(port, mask, offset) \ #define palReadGroup(port, mask, offset) \
((palReadPort(port) >> (offset)) & (mask)) ((palReadPort(port) >> (offset)) & (mask))
#else #else
#define palReadGroup(port, mask, offset) pal_lld_readgroup(port, mask, offset) #define palReadGroup(port, mask, offset) pal_lld_readgroup(port, mask, offset)
@ -346,6 +357,7 @@ typedef struct {
/** /**
* @brief Writes a group of bits. * @brief Writes a group of bits.
* @note The function can be called from any context.
* *
* @param[in] port port identifier * @param[in] port port identifier
* @param[in] mask group mask, a logical AND is performed on the * @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 * @param[in] bits bits to be written. Values exceeding the group
* width are masked. * width are masked.
* *
* @api * @special
*/ */
#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) \
palWritePort(port, (palReadLatch(port) & ~((mask) << (offset))) | \ palWritePort(port, (palReadLatch(port) & ~((mask) << (offset))) | \
(((bits) & (mask)) << (offset))) (((bits) & (mask)) << (offset)))
#else #else
#define palWriteGroup(port, mask, offset, bits) \ #define palWriteGroup(port, mask, offset, bits) \
pal_lld_writegroup(port, mask, offset, bits) pal_lld_writegroup(port, mask, offset, bits)
#endif #endif
@ -371,13 +383,14 @@ typedef struct {
* @details This function programs a pads group belonging to the same port * @details This function programs a pads group belonging to the same port
* with the specified mode. * with the specified mode.
* @note Programming an unknown or unsupported mode is silently ignored. * @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] port port identifier
* @param[in] mask group mask * @param[in] mask group mask
* @param[in] offset group bit offset within the port * @param[in] offset group bit offset within the port
* @param[in] mode group mode * @param[in] mode group mode
* *
* @api * @special
*/ */
#if !defined(pal_lld_setgroupmode) || defined(__DOXYGEN__) #if !defined(pal_lld_setgroupmode) || defined(__DOXYGEN__)
#define palSetGroupMode(port, mask, offset, mode) #define palSetGroupMode(port, mask, offset, mode)
@ -392,6 +405,7 @@ typedef struct {
* drivers may optimize the function by using specific hardware * drivers may optimize the function by using specific hardware
* or coding. * or coding.
* @note The default implementation internally uses the @p palReadPort(). * @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] port port identifier
* @param[in] pad pad number within the port * @param[in] pad pad number within the port
@ -399,7 +413,7 @@ typedef struct {
* @retval PAL_LOW low logical state. * @retval PAL_LOW low logical state.
* @retval PAL_HIGH high logical state. * @retval PAL_HIGH high logical state.
* *
* @api * @special
*/ */
#if !defined(pal_lld_readpad) || defined(__DOXYGEN__) #if !defined(pal_lld_readpad) || defined(__DOXYGEN__)
#define palReadPad(port, pad) ((palReadPort(port) >> (pad)) & 1) #define palReadPad(port, pad) ((palReadPort(port) >> (pad)) & 1)
@ -418,17 +432,18 @@ typedef struct {
* specific hardware or coding. * specific hardware or coding.
* @note The default implementation internally uses the @p palReadLatch() * @note The default implementation internally uses the @p palReadLatch()
* and @p palWritePort(). * and @p palWritePort().
* @note The function can be called from any context.
* *
* @param[in] port port identifier * @param[in] port port identifier
* @param[in] pad pad number within the port * @param[in] pad pad number within the port
* @param[in] bit logical value, the value must be @p PAL_LOW or * @param[in] bit logical value, the value must be @p PAL_LOW or
* @p PAL_HIGH * @p PAL_HIGH
* *
* @api * @special
*/ */
#if !defined(pal_lld_writepad) || defined(__DOXYGEN__) #if !defined(pal_lld_writepad) || defined(__DOXYGEN__)
#define palWritePad(port, pad, bit) \ #define palWritePad(port, pad, bit) \
palWritePort(port, (palReadLatch(port) & ~PAL_PORT_BIT(pad)) | \ palWritePort(port, (palReadLatch(port) & ~PAL_PORT_BIT(pad)) | \
(((bit) & 1) << pad)) (((bit) & 1) << pad))
#else #else
#define palWritePad(port, pad, bit) pal_lld_writepad(port, pad, bit) #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 * optimal. Low level drivers may optimize the function by using
* specific hardware or coding. * specific hardware or coding.
* @note The default implementation internally uses the @p palSetPort(). * @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] port port identifier
* @param[in] pad pad number within the port * @param[in] pad pad number within the port
* *
* @api * @special
*/ */
#if !defined(pal_lld_setpad) || defined(__DOXYGEN__) #if !defined(pal_lld_setpad) || defined(__DOXYGEN__)
#define palSetPad(port, pad) palSetPort(port, PAL_PORT_BIT(pad)) #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 * optimal. Low level drivers may optimize the function by using
* specific hardware or coding. * specific hardware or coding.
* @note The default implementation internally uses the @p palClearPort(). * @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] port port identifier
* @param[in] pad pad number within the port * @param[in] pad pad number within the port
* *
* @api * @special
*/ */
#if !defined(pal_lld_clearpad) || defined(__DOXYGEN__) #if !defined(pal_lld_clearpad) || defined(__DOXYGEN__)
#define palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad)) #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 * optimal. Low level drivers may optimize the function by using
* specific hardware or coding. * specific hardware or coding.
* @note The default implementation internally uses the @p palTogglePort(). * @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] port port identifier
* @param[in] pad pad number within the port * @param[in] pad pad number within the port
* *
* @api * @special
*/ */
#if !defined(pal_lld_togglepad) || defined(__DOXYGEN__) #if !defined(pal_lld_togglepad) || defined(__DOXYGEN__)
#define palTogglePad(port, pad) palTogglePort(port, PAL_PORT_BIT(pad)) #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) #define palTogglePad(port, pad) pal_lld_togglepad(port, pad)
#endif #endif
/** /**
* @brief Pad mode setup. * @brief Pad mode setup.
* @details This function programs a pad with the specified mode. * @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 * drivers may optimize the function by using specific hardware
* or coding. * or coding.
* @note Programming an unknown or unsupported mode is silently ignored. * @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] port port identifier
* @param[in] pad pad number within the port * @param[in] pad pad number within the port
* @param[in] mode pad mode * @param[in] mode pad mode
* *
* @api * @special
*/ */
#if !defined(pal_lld_setpadmode) || defined(__DOXYGEN__) #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) palSetGroupMode(port, PAL_PORT_BIT(pad), 0, mode)
#else #else
#define palSetPadMode(port, pad, mode) pal_lld_setpadmode(port, pad, mode) #define palSetPadMode(port, pad, mode) pal_lld_setpadmode(port, pad, mode)

View File

@ -1,6 +1,6 @@
/* /*
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 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. 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 * @note The function internally uses the @p palReadGroup() macro. The use
* of this function is preferred when you value code size, readability * of this function is preferred when you value code size, readability
* and error checking over speed. * 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 * @param[in] bus the I/O bus, pointer to a @p IOBus structure
* @return The bus logical states. * @return The bus logical states.
* *
* @api * @special
*/ */
ioportmask_t palReadBus(IOBus *bus) { ioportmask_t palReadBus(IOBus *bus) {
chDbgCheck((bus != NULL) && osalDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH));
(bus->offset < PAL_IOPORTS_WIDTH), "palReadBus");
return palReadGroup(bus->portid, bus->mask, bus->offset); 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 * @note The default implementation is non atomic and not necessarily
* optimal. Low level drivers may optimize the function by using * optimal. Low level drivers may optimize the function by using
* specific hardware or coding. * 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] 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 * @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 * the bus width are masked so most significant bits are
* lost. * lost.
* *
* @api * @special
*/ */
void palWriteBus(IOBus *bus, ioportmask_t bits) { void palWriteBus(IOBus *bus, ioportmask_t bits) {
chDbgCheck((bus != NULL) && osalDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH));
(bus->offset < PAL_IOPORTS_WIDTH), "palWriteBus");
palWriteGroup(bus->portid, bus->mask, bus->offset, bits); 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 * @note The default implementation is non atomic and not necessarily
* optimal. Low level drivers may optimize the function by using * optimal. Low level drivers may optimize the function by using
* specific hardware or coding. * 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] bus the I/O bus, pointer to a @p IOBus structure
* @param[in] mode the mode * @param[in] mode the mode
* *
* @api * @special
*/ */
void palSetBusMode(IOBus *bus, iomode_t mode) { void palSetBusMode(IOBus *bus, iomode_t mode) {
chDbgCheck((bus != NULL) && osalDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH));
(bus->offset < PAL_IOPORTS_WIDTH), "palSetBusMode");
palSetGroupMode(bus->portid, bus->mask, bus->offset, mode); palSetGroupMode(bus->portid, bus->mask, bus->offset, mode);
} }

View File

@ -79,6 +79,7 @@
***************************************************************************** *****************************************************************************
*** 2.4.5 *** *** 2.4.5 ***
- FIX: Fixed PAL driver documentation error (bug #427).
- FIX: Fixed wrong RTC macro names in STM32L1xx HAL (bug #422). - FIX: Fixed wrong RTC macro names in STM32L1xx HAL (bug #422).
*** 2.4.4 *** *** 2.4.4 ***