PAL_LINE on STM32F1xx

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
greb
Posts: 10
Joined: Tue Apr 05, 2016 12:50 pm
Has thanked: 2 times
Been thanked: 3 times

PAL_LINE on STM32F1xx

Post by greb »

I've tried to use PAL_LINE and associated macros on a STM32F103. Compiling fails due to stm32_gpio_t's definition is missing from GPIOv1's pal_lld.h
On devices which use GPIOv2 (e.g. STM32L152) it works without problems.
I'm using git branch stable_16.1.x

What are some possible solutions to enable PAL_LINE support on STM32F1xx? Switching over to GPIOv2 wouldn't work because of reported HW incompatibilities. Or is it necessary to patch ./os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h ?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: PAL_LINE on STM32F1xx

Post by Giovanni »

Hi,

The PAL driver for GPIOv1 already includes the required macros, it is just that board files for F1 devices do not include the LINE_ definitions. You could try to define them and verify the functionality of the driver.

A note, board files for STM32 non-F1 devices are generated automatically, it is easier to keep them up to date. F1 board files have to be edited manually.

Giovanni
greb
Posts: 10
Joined: Tue Apr 05, 2016 12:50 pm
Has thanked: 2 times
Been thanked: 3 times

Re: PAL_LINE on STM32F1xx

Post by greb »

Thank you for your answer. But I think there's a misunderstanding. The problem isn't that the macros are missing, because they're clearly there. And I'm using them already for other boards.

It is the missing definition for the type stm32_gpio_t in os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h which is used by some of those macros which in turn causes those macros to fail.

I've wrote a patch that seem to fix the problem. I've haven't tested it yet thoroughly though.

Greb

Code: Select all

From ddcce2d168cf8b6e2be56527f21cf5a5a4823e0e Mon Sep 17 00:00:00 2001
From: Grischa Ebinger <[email protected]>
Date: Tue, 5 Apr 2016 14:41:24 +0200
Subject: [PATCH] Fix missing stm32_gpio_t for older boards

---
 os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h b/os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h
index f2eb590..2cb4925 100644
--- a/os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h
+++ b/os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h
@@ -99,6 +99,19 @@
 /** @} */
 
 /**
+ * @brief   STM32 GPIO register block.
+ */
+typedef struct {
+    volatile uint32_t   CRL;
+    volatile uint32_t   CRH;
+    volatile uint32_t   IDR;
+    volatile uint32_t   ODR;
+    volatile uint32_t   BSRR;
+    volatile uint32_t   BRR;
+    volatile uint32_t   LCKR;
+} stm32_gpio_t;
+
+/**
  * @brief   GPIO port setup info.
  */
 typedef struct {
--
2.6.2

User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: PAL_LINE on STM32F1xx

Post by Giovanni »

Hi,

It should work also by replacing stm32_gpio_t with GPIO_TypeDef, there is no need to redefine the structure.

I committed this change on trunk (bug #730).

Giovanni
Post Reply