diff --git a/demos/STM8S-STM8S208-RC/ch.rapp b/demos/STM8S-STM8S208-RC/ch.rapp index 0dd5a4435..8378004bc 100644 --- a/demos/STM8S-STM8S208-RC/ch.rapp +++ b/demos/STM8S-STM8S208-RC/ch.rapp @@ -10,15 +10,15 @@
- +
- +
- + - + - + @@ -34,15 +34,15 @@
- +
- +
- + - + - +
@@ -53,17 +53,17 @@
- +
- +
- + - + - +
- + @@ -78,13 +78,13 @@ - + - + - + @@ -97,11 +97,11 @@ - + - + @@ -109,21 +109,21 @@
- +
- +
- +
- +
@@ -134,33 +134,33 @@
- +
- +
- +
- +
- +
- +
- +
diff --git a/os/hal/include/pal.h b/os/hal/include/pal.h index 1ba3ee04d..6a5c18f16 100644 --- a/os/hal/include/pal.h +++ b/os/hal/include/pal.h @@ -388,7 +388,7 @@ typedef struct { * * @param[in] port port identifier * @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 */ #if !defined(pal_lld_writepad) || defined(__DOXYGEN__) diff --git a/os/hal/platforms/STM32/pal_lld.c b/os/hal/platforms/STM32/pal_lld.c index ae250f85d..69bd3ecab 100644 --- a/os/hal/platforms/STM32/pal_lld.c +++ b/os/hal/platforms/STM32/pal_lld.c @@ -18,8 +18,9 @@ */ /** - * @file STM32/pal_lld.c - * @brief STM32 GPIO low level driver code. + * @file STM32/pal_lld.c + * @brief STM32 GPIO low level driver code. + * * @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. * - * @param[in] config the STM32 ports configuration + * @param[in] config the STM32 ports configuration */ 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 * 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] mask the group mask - * @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. + * @param[in] port the port identifier + * @param[in] mask the group mask + * @param[in] mode the mode */ void _pal_lld_setgroupmode(ioportid_t port, ioportmask_t mask, diff --git a/os/hal/platforms/STM32/pal_lld.h b/os/hal/platforms/STM32/pal_lld.h index 6b526916c..3564d3cb9 100644 --- a/os/hal/platforms/STM32/pal_lld.h +++ b/os/hal/platforms/STM32/pal_lld.h @@ -18,8 +18,9 @@ */ /** - * @file STM32/pal_lld.h - * @brief STM32 GPIO low level driver header. + * @file STM32/pal_lld.h + * @brief STM32 GPIO low level driver header. + * * @addtogroup STM32_PAL * @{ */ @@ -30,21 +31,25 @@ #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 /** - * @brief STM32 specific alternate open-drain output mode. + * @brief STM32 specific alternate open-drain output mode. */ #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 { /** Initial value for ODR register.*/ @@ -56,7 +61,7 @@ typedef struct { } 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 * system startup time in order to initialize the digital I/O * subsystem. This represents only the initial setup, specific pads @@ -84,13 +89,13 @@ typedef struct { } STM32GPIOConfig; /** - * @brief Width, in bits, of an I/O port. + * @brief Width, in bits, of an I/O port. */ #define PAL_IOPORTS_WIDTH 16 /** - * @brief Whole port mask. - * @brief This macro specifies all the valid bits into a port. + * @brief Whole port mask. + * @brief This macro specifies all the valid bits into a port. */ #define PAL_WHOLE_PORT ((ioportmask_t)0xFFFF) @@ -100,7 +105,7 @@ typedef struct { 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 * any assumption about it, use the provided macros when populating * 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 /** - * @brief GPIO port B identifier. + * @brief GPIO port B identifier. */ #define IOPORT2 GPIOB /** - * @brief GPIO port C identifier. + * @brief GPIO port C identifier. */ #define IOPORT3 GPIOC /** - * @brief GPIO port D identifier. + * @brief GPIO port D identifier. */ #define IOPORT4 GPIOD /** - * @brief GPIO port E identifier. + * @brief GPIO port E identifier. */ #if !defined(STM32F10X_LD) || defined(__DOXYGEN__) #define IOPORT5 GPIOE #endif /** - * @brief GPIO port F identifier. + * @brief GPIO port F identifier. */ #if defined(STM32F10X_HD) || defined(__DOXYGEN__) #define IOPORT6 GPIOF /** - * @brief GPIO port G identifier. + * @brief GPIO port G identifier. */ #define IOPORT7 GPIOG #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) /** - * @brief Reads an I/O port. + * @brief Reads an I/O port. * @details This function is implemented by reading the GPIO IDR register, the * 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 - * @return the port bits - * - * @note This function is not meant to be invoked directly by the application - * code. + * @param[in] port the port identifier + * @return The port bits. */ #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 * 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 - * @return The latched logical states. - * - * @note This function is not meant to be invoked directly by the application - * code. + * @param[in] port the port identifier + * @return The latched logical states. */ #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 * 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] 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. + * @param[in] port the port identifier + * @param[in] bits the bits to be written on the specified port */ #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 * 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] 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. + * @param[in] port the port identifier + * @param[in] bits the bits to be ORed on the specified port */ #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 * 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] 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. + * @param[in] port the port identifier + * @param[in] bits the bits to be cleared on the specified port */ #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 * 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] 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. - * @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] 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. */ #define pal_lld_writegroup(port, mask, offset, bits) { \ (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 * 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] mask the group mask - * @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. + * @param[in] port the port identifier + * @param[in] mask the group mask + * @param[in] mode the mode */ #define 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] 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. - * @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] pad the pad number within the port + * @param[in] bit logical value, the value must be @p PAL_LOW or + * @p PAL_HIGH */ #define pal_lld_writepad(port, pad, bit) pal_lld_writegroup(port, 1, pad, bit) diff --git a/os/hal/platforms/STM8/hal_lld.c b/os/hal/platforms/STM8/hal_lld.c index 7a2d1bc1f..b0d3883d6 100644 --- a/os/hal/platforms/STM8/hal_lld.c +++ b/os/hal/platforms/STM8/hal_lld.c @@ -40,7 +40,7 @@ * @brief PAL setup. * @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}, diff --git a/os/hal/platforms/STM8/pal_lld.h b/os/hal/platforms/STM8/pal_lld.h index 65ddeedea..0545986d9 100644 --- a/os/hal/platforms/STM8/pal_lld.h +++ b/os/hal/platforms/STM8/pal_lld.h @@ -34,6 +34,18 @@ /* 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. */ /*===========================================================================*/ @@ -58,23 +70,23 @@ typedef struct { */ typedef struct { gpio_t P[9]; -} STM8GPIOConfig; +} PALConfig; /** * @brief Width, in bits, of an I/O port. */ -#define PAL_IOPORTS_WIDTH 32 +#define PAL_IOPORTS_WIDTH 8 /** * @brief Whole port mask. * @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. */ -typedef uint32_t ioportmask_t; +typedef uint8_t ioportmask_t; /** * @brief Port Identifier. @@ -88,7 +100,7 @@ typedef gpio_t *ioportid_t; /** * @brief GPIO ports as a whole. */ -#define IOPORTS ((STM8GPIOConfig *)0x5000) +#define IOPORTS ((PALConfig *)0x5000) /** * @brief GPIO port A identifier. @@ -194,7 +206,7 @@ typedef gpio_t *ioportid_t; */ #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 */ diff --git a/readme.txt b/readme.txt index bdbdc3bdb..5baab4cff 100644 --- a/readme.txt +++ b/readme.txt @@ -59,6 +59,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 configure the clock using any clock source and any HSE frequency. - NEW: The STM32 clock tree parameters and checks are now calculated into