Fixed bug 3001528.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1920 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
gdisirio 2010-05-14 09:23:32 +00:00
parent f0f02c897c
commit d6e56d6e7f
7 changed files with 156 additions and 145 deletions

View File

@ -84,7 +84,7 @@
<NodeC Path="..\..\os\ports\RC\STM8\chcore.c" Header="chcore.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chcore.obj" sate="0" /> <NodeC Path="..\..\os\ports\RC\STM8\chcore.c" Header="chcore.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chcore.obj" sate="0" />
</Group> </Group>
<Group Header="hal" Marker="-1" OutputFile="" sate="0" > <Group Header="hal" Marker="-1" OutputFile="" sate="96" >
<NodeC Path="..\..\os\hal\src\adc.c" Header="adc.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\adc.obj" sate="0" /> <NodeC Path="..\..\os\hal\src\adc.c" Header="adc.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\adc.obj" sate="0" />
<NodeC Path="..\..\os\hal\src\can.c" Header="can.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\can.obj" sate="0" /> <NodeC Path="..\..\os\hal\src\can.c" Header="can.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\can.obj" sate="0" />
<NodeC Path="..\..\os\hal\src\hal.c" Header="hal.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\hal.obj" sate="0" /> <NodeC Path="..\..\os\hal\src\hal.c" Header="hal.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\hal.obj" sate="0" />

View File

@ -388,7 +388,7 @@ typedef struct {
* *
* @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[out] 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
*/ */
#if !defined(pal_lld_writepad) || defined(__DOXYGEN__) #if !defined(pal_lld_writepad) || defined(__DOXYGEN__)

View File

@ -18,8 +18,9 @@
*/ */
/** /**
* @file STM32/pal_lld.c * @file STM32/pal_lld.c
* @brief STM32 GPIO low level driver code. * @brief STM32 GPIO low level driver code.
*
* @addtogroup STM32_PAL * @addtogroup STM32_PAL
* @{ * @{
*/ */
@ -76,10 +77,10 @@
/*===========================================================================*/ /*===========================================================================*/
/** /**
* @brief STM32 I/O ports configuration. * @brief STM32 I/O ports configuration.
* @details Ports A-D(E, F, G) clocks enabled, AFIO clock enabled. * @details Ports A-D(E, F, G) clocks enabled, AFIO clock enabled.
* *
* @param[in] config the STM32 ports configuration * @param[in] config the STM32 ports configuration
*/ */
void _pal_lld_init(const STM32GPIOConfig *config) { void _pal_lld_init(const STM32GPIOConfig *config) {
@ -122,20 +123,19 @@ void _pal_lld_init(const STM32GPIOConfig *config) {
} }
/** /**
* @brief Pads mode setup. * @brief Pads mode setup.
* @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 This function is not meant to be invoked directly by the
* application code.
* @note @p PAL_MODE_UNCONNECTED is implemented as push pull output at 2MHz.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched
* data is used for the resistor selection.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
* @param[in] mask the group mask * @param[in] mask the group mask
* @param[in] mode the mode * @param[in] mode the mode
*
* @note This function is not meant to be invoked directly by the application
* code.
* @note @p PAL_MODE_UNCONNECTED is implemented as push pull output at 2MHz.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched data
* is used for the resistor selection.
*/ */
void _pal_lld_setgroupmode(ioportid_t port, void _pal_lld_setgroupmode(ioportid_t port,
ioportmask_t mask, ioportmask_t mask,

View File

@ -18,8 +18,9 @@
*/ */
/** /**
* @file STM32/pal_lld.h * @file STM32/pal_lld.h
* @brief STM32 GPIO low level driver header. * @brief STM32 GPIO low level driver header.
*
* @addtogroup STM32_PAL * @addtogroup STM32_PAL
* @{ * @{
*/ */
@ -30,21 +31,25 @@
#if CH_HAL_USE_PAL || defined(__DOXYGEN__) #if CH_HAL_USE_PAL || defined(__DOXYGEN__)
/*===========================================================================*/ /*===========================================================================*/
/* I/O Ports Types and constants. */ /* Unsupported modes and specific modes */
/*===========================================================================*/ /*===========================================================================*/
/** /**
* @brief STM32 specific alternate push-pull output mode. * @brief STM32 specific alternate push-pull output mode.
*/ */
#define PAL_MODE_STM32_ALTERNATE_PUSHPULL 16 #define PAL_MODE_STM32_ALTERNATE_PUSHPULL 16
/** /**
* @brief STM32 specific alternate open-drain output mode. * @brief STM32 specific alternate open-drain output mode.
*/ */
#define PAL_MODE_STM32_ALTERNATE_OPENDRAIN 17 #define PAL_MODE_STM32_ALTERNATE_OPENDRAIN 17
/*===========================================================================*/
/* I/O Ports Types and constants. */
/*===========================================================================*/
/** /**
* @brief GPIO port setup info. * @brief GPIO port setup info.
*/ */
typedef struct { typedef struct {
/** Initial value for ODR register.*/ /** Initial value for ODR register.*/
@ -56,7 +61,7 @@ typedef struct {
} stm32_gpio_setup_t; } stm32_gpio_setup_t;
/** /**
* @brief STM32 GPIO static initializer. * @brief STM32 GPIO static initializer.
* @details An instance of this structure must be passed to @p palInit() at * @details An instance of this structure must be passed to @p palInit() at
* system startup time in order to initialize the digital I/O * system startup time in order to initialize the digital I/O
* subsystem. This represents only the initial setup, specific pads * subsystem. This represents only the initial setup, specific pads
@ -84,13 +89,13 @@ typedef struct {
} STM32GPIOConfig; } STM32GPIOConfig;
/** /**
* @brief Width, in bits, of an I/O port. * @brief Width, in bits, of an I/O port.
*/ */
#define PAL_IOPORTS_WIDTH 16 #define PAL_IOPORTS_WIDTH 16
/** /**
* @brief Whole port mask. * @brief Whole port mask.
* @brief This macro specifies all the valid bits into a port. * @brief This macro specifies all the valid bits into a port.
*/ */
#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFF) #define PAL_WHOLE_PORT ((ioportmask_t)0xFFFF)
@ -100,7 +105,7 @@ typedef struct {
typedef uint32_t ioportmask_t; typedef uint32_t ioportmask_t;
/** /**
* @brief Port Identifier. * @brief Port Identifier.
* @details This type can be a scalar or some kind of pointer, do not make * @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 * any assumption about it, use the provided macros when populating
* variables of this type. * variables of this type.
@ -114,40 +119,40 @@ typedef GPIO_TypeDef * ioportid_t;
/*===========================================================================*/ /*===========================================================================*/
/** /**
* @brief GPIO port A identifier. * @brief GPIO port A identifier.
*/ */
#define IOPORT1 GPIOA #define IOPORT1 GPIOA
/** /**
* @brief GPIO port B identifier. * @brief GPIO port B identifier.
*/ */
#define IOPORT2 GPIOB #define IOPORT2 GPIOB
/** /**
* @brief GPIO port C identifier. * @brief GPIO port C identifier.
*/ */
#define IOPORT3 GPIOC #define IOPORT3 GPIOC
/** /**
* @brief GPIO port D identifier. * @brief GPIO port D identifier.
*/ */
#define IOPORT4 GPIOD #define IOPORT4 GPIOD
/** /**
* @brief GPIO port E identifier. * @brief GPIO port E identifier.
*/ */
#if !defined(STM32F10X_LD) || defined(__DOXYGEN__) #if !defined(STM32F10X_LD) || defined(__DOXYGEN__)
#define IOPORT5 GPIOE #define IOPORT5 GPIOE
#endif #endif
/** /**
* @brief GPIO port F identifier. * @brief GPIO port F identifier.
*/ */
#if defined(STM32F10X_HD) || defined(__DOXYGEN__) #if defined(STM32F10X_HD) || defined(__DOXYGEN__)
#define IOPORT6 GPIOF #define IOPORT6 GPIOF
/** /**
* @brief GPIO port G identifier. * @brief GPIO port G identifier.
*/ */
#define IOPORT7 GPIOG #define IOPORT7 GPIOG
#endif #endif
@ -158,100 +163,94 @@ typedef GPIO_TypeDef * ioportid_t;
/*===========================================================================*/ /*===========================================================================*/
/** /**
* @brief GPIO ports subsystem initialization. * @brief GPIO ports subsystem initialization.
*/ */
#define pal_lld_init(config) _pal_lld_init(config) #define pal_lld_init(config) _pal_lld_init(config)
/** /**
* @brief Reads an I/O port. * @brief Reads an I/O port.
* @details This function is implemented by reading the GPIO IDR register, the * @details This function is implemented by reading the GPIO IDR register, the
* implementation has no side effects. * implementation has no side effects.
* @note This function is not meant to be invoked directly by the application
* code.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
* @return the port bits * @return The port bits.
*
* @note This function is not meant to be invoked directly by the application
* code.
*/ */
#define pal_lld_readport(port) ((port)->IDR) #define pal_lld_readport(port) ((port)->IDR)
/** /**
* @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.
* @note This function is not meant to be invoked directly by the application
* code.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
* @return The latched logical states. * @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)->ODR) #define pal_lld_readlatch(port) ((port)->ODR)
/** /**
* @brief Writes on a I/O port. * @brief Writes on a I/O port.
* @details This function is implemented by writing the GPIO ODR register, the * @details This function is implemented by writing the GPIO ODR register, the
* implementation has no side effects. * implementation has no side effects.
* @note This function is not meant to be invoked directly by the
* application code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched
* data is used for the resistor selection.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
* @param[in] bits the bits to be written on the specified port * @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.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched data
* is used for the resistor selection.
*/ */
#define pal_lld_writeport(port, bits) ((port)->ODR = (bits)) #define pal_lld_writeport(port, bits) ((port)->ODR = (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 GPIO BSRR register, the * @details This function is implemented by writing the GPIO BSRR register, the
* implementation has no side effects. * implementation has no side effects.
* @note This function is not meant to be invoked directly by the
* application code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched
* data is used for the resistor selection.
* *
* @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
*
* @note This function is not meant to be invoked directly by the application
* code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched data
* is used for the resistor selection.
*/ */
#define pal_lld_setport(port, bits) ((port)->BSRR = (bits)) #define pal_lld_setport(port, bits) ((port)->BSRR = (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 GPIO BRR register, the * @details This function is implemented by writing the GPIO BRR register, the
* implementation has no side effects. * implementation has no side effects.
* @note This function is not meant to be invoked directly by the
* application code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched
* data is used for the resistor selection.
* *
* @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
*
* @note This function is not meant to be invoked directly by the application
* code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched data
* is used for the resistor selection.
*/ */
#define pal_lld_clearport(port, bits) ((port)->BRR = (bits)) #define pal_lld_clearport(port, bits) ((port)->BRR = (bits))
/** /**
* @brief Writes a group of bits. * @brief Writes a group of bits.
* @details This function is implemented by writing the GPIO BSRR register, the * @details This function is implemented by writing the GPIO BSRR register, the
* implementation has no side effects. * implementation has no side effects.
* @note This function is not meant to be invoked directly by the
* application code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched
* data is used for the resistor selection.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
* @param[in] mask the group mask * @param[in] mask the group mask
* @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
* are masked. * width are masked.
*
* @note This function is not meant to be invoked directly by the application
* code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched data
* is used for the resistor selection.
*/ */
#define pal_lld_writegroup(port, mask, offset, bits) { \ #define pal_lld_writegroup(port, mask, offset, bits) { \
(port)->BSRR = ((~(bits) & (mask)) << (16 + (offset))) | \ (port)->BSRR = ((~(bits) & (mask)) << (16 + (offset))) | \
@ -259,35 +258,34 @@ typedef GPIO_TypeDef * ioportid_t;
} }
/** /**
* @brief Pads group mode setup. * @brief Pads group mode setup.
* @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 This function is not meant to be invoked directly by the
* application code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched
* data is used for the resistor selection.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
* @param[in] mask the group mask * @param[in] mask the group mask
* @param[in] mode the mode * @param[in] mode the mode
*
* @note This function is not meant to be invoked directly by the application
* code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched data
* is used for the resistor selection.
*/ */
#define pal_lld_setgroupmode(port, mask, mode) \ #define pal_lld_setgroupmode(port, mask, mode) \
_pal_lld_setgroupmode(port, mask, mode) _pal_lld_setgroupmode(port, mask, mode)
/** /**
* @brief Writes a logical state on an output pad. * @brief Writes a logical state on an output pad.
* @note This function is not meant to be invoked directly by the
* application code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched
* data is used for the resistor selection.
* *
* @param[in] port the port identifier * @param[in] port the port identifier
* @param[in] pad the pad number within the port * @param[in] pad the pad number within the port
* @param[out] bit the logical value, the value must be @p 0 or @p 1 * @param[in] bit logical value, the value must be @p PAL_LOW or
* * @p PAL_HIGH
* @note This function is not meant to be invoked directly by the application
* code.
* @note Writing on pads programmed as pull-up or pull-down has the side
* effect to modify the resistor setting because the output latched data
* is used for the resistor selection.
*/ */
#define pal_lld_writepad(port, pad, bit) pal_lld_writegroup(port, 1, pad, bit) #define pal_lld_writepad(port, pad, bit) pal_lld_writegroup(port, 1, pad, bit)

View File

@ -40,7 +40,7 @@
* @brief PAL setup. * @brief PAL setup.
* @details Digital I/O ports static configuration as defined in @p board.h. * @details Digital I/O ports static configuration as defined in @p board.h.
*/ */
ROMCONST STM8GPIOConfig pal_default_config = ROMCONST PALConfig pal_default_config =
{ {
{ {
{VAL_GPIOAODR, 0, VAL_GPIOADDR, VAL_GPIOACR1, VAL_GPIOACR2}, {VAL_GPIOAODR, 0, VAL_GPIOADDR, VAL_GPIOACR1, VAL_GPIOACR2},

View File

@ -34,6 +34,18 @@
/* Unsupported modes and specific modes */ /* Unsupported modes and specific modes */
/*===========================================================================*/ /*===========================================================================*/
#undef PAL_MODE_INPUT_PULLDOWN
/**
* @brief STM8 specific alternate push-pull slow output mode.
*/
#define PAL_MODE_OUTPUT_PUSHPULL_SLOW 16
/**
* @brief STM8 specific alternate open-drain slow output mode.
*/
#define PAL_MODE_OUTPUT_OPENDRAIN_SLOW 17
/*===========================================================================*/ /*===========================================================================*/
/* I/O Ports Types and constants. */ /* I/O Ports Types and constants. */
/*===========================================================================*/ /*===========================================================================*/
@ -58,23 +70,23 @@ typedef struct {
*/ */
typedef struct { typedef struct {
gpio_t P[9]; gpio_t P[9];
} STM8GPIOConfig; } PALConfig;
/** /**
* @brief Width, in bits, of an I/O port. * @brief Width, in bits, of an I/O port.
*/ */
#define PAL_IOPORTS_WIDTH 32 #define PAL_IOPORTS_WIDTH 8
/** /**
* @brief Whole port mask. * @brief Whole port mask.
* @brief This macro specifies all the valid bits into a port. * @brief This macro specifies all the valid bits into a port.
*/ */
#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFFFFFF) #define PAL_WHOLE_PORT ((ioportmask_t)0xFF)
/** /**
* @brief Digital I/O port sized unsigned type. * @brief Digital I/O port sized unsigned type.
*/ */
typedef uint32_t ioportmask_t; typedef uint8_t ioportmask_t;
/** /**
* @brief Port Identifier. * @brief Port Identifier.
@ -88,7 +100,7 @@ typedef gpio_t *ioportid_t;
/** /**
* @brief GPIO ports as a whole. * @brief GPIO ports as a whole.
*/ */
#define IOPORTS ((STM8GPIOConfig *)0x5000) #define IOPORTS ((PALConfig *)0x5000)
/** /**
* @brief GPIO port A identifier. * @brief GPIO port A identifier.
@ -194,7 +206,7 @@ typedef gpio_t *ioportid_t;
*/ */
#define pal_lld_setgroupmode(port, mask, mode) ((void)(mode)) #define pal_lld_setgroupmode(port, mask, mode) ((void)(mode))
extern ROMCONST STM8GPIOConfig pal_default_config; extern ROMCONST PALConfig pal_default_config;
#endif /* CH_HAL_USE_PAL */ #endif /* CH_HAL_USE_PAL */

View File

@ -59,6 +59,7 @@
***************************************************************************** *****************************************************************************
*** 1.5.7 *** *** 1.5.7 ***
- FIX: Fixed wrong GPIO ports size in the STM8 PAL driver (bug 3001528).
- NEW: Improved clock initialization for the STM32, now it is possible to - NEW: Improved clock initialization for the STM32, now it is possible to
configure the clock using any clock source and any HSE frequency. configure the clock using any clock source and any HSE frequency.
- NEW: The STM32 clock tree parameters and checks are now calculated into - NEW: The STM32 clock tree parameters and checks are now calculated into