Skip to content

Commit cfbc0f4

Browse files
committed
stm32f103xb_hic: Fix names and collisions in CMSIS drivers
1 parent 6074641 commit cfbc0f4

File tree

5 files changed

+45
-27
lines changed

5 files changed

+45
-27
lines changed

source/hic_hal/stm32/stm32f103xb/cmsis/DMA_STM32F10x.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include <stdint.h>
3030
#include <stdbool.h>
31-
#include "stm32f10x.h"
31+
#include "stm32f1xx.h"
3232

3333

3434
#if defined (__CC_ARM)
@@ -61,7 +61,9 @@
6161
#define DMA_TRANSFER_COMPLETE_INTERRUPT DMA_CCR1_TCIE
6262
#define DMA_PERIPHERAL_TO_MEMORY 0
6363
#define DMA_READ_MEMORY DMA_CCR1_DIR
64+
#ifndef DMA_MEMORY_TO_MEMORY
6465
#define DMA_MEMORY_TO_MEMORY DMA_CCR1_MEM2MEM
66+
#endif
6567
#define DMA_CIRCULAR_MODE DMA_CCR1_CIRC
6668
#define DMA_PERIPHERAL_INCREMENT DMA_CCR1_PINC
6769
#define DMA_MEMORY_INCREMENT DMA_CCR1_MINC
@@ -73,7 +75,11 @@
7375
#define DMA_MEMORY_DATA_32BIT DMA_CCR1_MSIZE_1
7476
#define DMA_PRIORITY_POS 12
7577
#define DMA_PRIORITY_MASK DMA_CCR1_PL
78+
#ifdef DMA_CCR_EN
79+
#define DMA_CHANNEL_EN DMA_CCR_EN
80+
#else
7681
#define DMA_CHANNEL_EN DMA_CCR1_EN
82+
#endif
7783

7884

7985
// DMA Information definitions

source/hic_hal/stm32/stm32f103xb/cmsis/GPIO_STM32F10x.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* -----------------------------------------------------------------------------
2-
* Copyright (c) 2016 Arm Limited (or its affiliates). All
2+
* Copyright (c) 2016 Arm Limited (or its affiliates). All
33
* rights reserved.
44
*
55
* SPDX-License-Identifier: Apache-2.0
@@ -61,16 +61,24 @@ void GPIO_PortClock (GPIO_TypeDef *GPIOx, bool enable) {
6161
else if (GPIOx == GPIOC) RCC->APB2ENR |= (1U << 4);
6262
else if (GPIOx == GPIOD) RCC->APB2ENR |= (1U << 5);
6363
else if (GPIOx == GPIOE) RCC->APB2ENR |= (1U << 6);
64+
#ifdef GPIOF
6465
else if (GPIOx == GPIOF) RCC->APB2ENR |= (1U << 7);
66+
#endif
67+
#ifdef GPIOG
6568
else if (GPIOx == GPIOG) RCC->APB2ENR |= (1U << 8);
69+
#endif
6670
} else {
6771
if (GPIOx == GPIOA) RCC->APB2ENR &= ~(1U << 2);
6872
else if (GPIOx == GPIOB) RCC->APB2ENR &= ~(1U << 3);
6973
else if (GPIOx == GPIOC) RCC->APB2ENR &= ~(1U << 4);
7074
else if (GPIOx == GPIOD) RCC->APB2ENR &= ~(1U << 5);
7175
else if (GPIOx == GPIOE) RCC->APB2ENR &= ~(1U << 6);
76+
#ifdef GPIOF
7277
else if (GPIOx == GPIOF) RCC->APB2ENR &= ~(1U << 7);
78+
#endif
79+
#ifdef GPIOG
7380
else if (GPIOx == GPIOG) RCC->APB2ENR &= ~(1U << 8);
81+
#endif
7482
}
7583
}
7684

@@ -88,10 +96,14 @@ bool GPIO_GetPortClockState (GPIO_TypeDef *GPIOx) {
8896
else if (GPIOx == GPIOC) { return ((RCC->APB2ENR & (1U << 4)) != 0U); }
8997
else if (GPIOx == GPIOD) { return ((RCC->APB2ENR & (1U << 5)) != 0U); }
9098
else if (GPIOx == GPIOE) { return ((RCC->APB2ENR & (1U << 6)) != 0U); }
99+
#ifdef GPIOF
91100
else if (GPIOx == GPIOF) { return ((RCC->APB2ENR & (1U << 7)) != 0U); }
101+
#endif
102+
#ifdef GPIOG
92103
else if (GPIOx == GPIOG) { return ((RCC->APB2ENR & (1U << 8)) != 0U); }
104+
#endif
93105

94-
return false;
106+
return false;
95107
}
96108

97109

@@ -116,9 +128,9 @@ bool GPIO_PinConfigure(GPIO_TypeDef *GPIOx, uint32_t num, GPIO_CONF conf,
116128
if (GPIO_GetPortClockState(GPIOx) == false) {
117129
/* Enable GPIOx peripheral clock */
118130
GPIO_PortClock (GPIOx, true);
119-
}
131+
}
120132

121-
if (mode == GPIO_MODE_INPUT) {
133+
if (mode == GPIO_MODE_IN) {
122134
if (conf == GPIO_IN_PULL_DOWN) {
123135
/* Enable pull down on selected input */
124136
GPIOx->ODR &= ~(1 << num);

source/hic_hal/stm32/stm32f103xb/cmsis/GPIO_STM32F10x.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* -----------------------------------------------------------------------------
2-
* Copyright (c) 2013 Arm Limited (or its affiliates). All
2+
* Copyright (c) 2013 Arm Limited (or its affiliates). All
33
* rights reserved.
44
*
55
* SPDX-License-Identifier: Apache-2.0
@@ -27,7 +27,7 @@
2727
#define __GPIO_STM32F10X_H
2828

2929
#include <stdbool.h>
30-
#include "stm32f10x.h"
30+
#include "stm32f1xx.h"
3131

3232

3333
#if defined (__CC_ARM)
@@ -44,7 +44,7 @@ typedef struct _GPIO_PIN_ID {
4444

4545
/// Port Mode
4646
typedef enum {
47-
GPIO_MODE_INPUT = 0x00, /// GPIO is input
47+
GPIO_MODE_IN = 0x00, /// GPIO is input
4848
GPIO_MODE_OUT10MHZ = 0x01, /// Max output Speed 10MHz
4949
GPIO_MODE_OUT2MHZ = 0x02, /// Max output Speed 2MHz
5050
GPIO_MODE_OUT50MHZ = 0x03 /// Max output Speed 50MHz
@@ -126,7 +126,7 @@ typedef enum {
126126
AFIO_PTP_PPS_NO_REMAP = AFIO_FUNC_DEF (30, 1, 0, 0),
127127
AFIO_PTP_PPS_REMAP = AFIO_FUNC_DEF (30, 1, 1, 0),
128128
#endif
129-
129+
130130
/* AF remap and debug I/O config register 2 */
131131
AFIO_TIM15_NO_REMAP = AFIO_FUNC_DEF (0, 1, 0, 1),
132132
AFIO_TIM15_REMAP = AFIO_FUNC_DEF (0, 1, 1, 1),
@@ -138,7 +138,7 @@ typedef enum {
138138
AFIO_CEC_REMAP = AFIO_FUNC_DEF (3, 1, 1, 1),
139139
AFIO_TIM1_DMA_NO_REMAP = AFIO_FUNC_DEF (4, 1, 0, 1),
140140
AFIO_TIM1_DMA_REMAP = AFIO_FUNC_DEF (4, 1, 1, 1),
141-
141+
142142
AFIO_TIM9_NO_REMAP = AFIO_FUNC_DEF (5, 1, 0, 1),
143143
AFIO_TIM9_REMAP = AFIO_FUNC_DEF (5, 1, 1, 1),
144144
AFIO_TIM10_NO_REMAP = AFIO_FUNC_DEF (6, 1, 0, 1),

source/hic_hal/stm32/stm32f103xb/cmsis/USART_STM32F10x.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -818,11 +818,11 @@ static int32_t USART_Initialize ( ARM_USART_SignalEvent_t cb_event,
818818
static int32_t USART_Uninitialize (const USART_RESOURCES *usart) {
819819

820820
// Unconfigure USART pins
821-
if (usart->io.tx) GPIO_PinConfigure(usart->io.tx->port, usart->io.tx->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
822-
if (usart->io.rx) GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
823-
if (usart->io.ck) GPIO_PinConfigure(usart->io.ck->port, usart->io.ck->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
824-
if (usart->io.rts) GPIO_PinConfigure(usart->io.rts->port, usart->io.rts->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
825-
if (usart->io.cts) GPIO_PinConfigure(usart->io.cts->port, usart->io.cts->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
821+
if (usart->io.tx) GPIO_PinConfigure(usart->io.tx->port, usart->io.tx->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
822+
if (usart->io.rx) GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
823+
if (usart->io.ck) GPIO_PinConfigure(usart->io.ck->port, usart->io.ck->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
824+
if (usart->io.rts) GPIO_PinConfigure(usart->io.rts->port, usart->io.rts->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
825+
if (usart->io.cts) GPIO_PinConfigure(usart->io.cts->port, usart->io.cts->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
826826

827827
// Unconfigure pin remap
828828
GPIO_AFConfigure(usart->io.afio_def);
@@ -1386,7 +1386,7 @@ static int32_t USART_Control ( uint32_t control,
13861386
if (usart->info->mode != ARM_USART_MODE_SMART_CARD) {
13871387
// GPIO pin function selected
13881388
if (usart->io.tx) {
1389-
GPIO_PinConfigure(usart->io.tx->port, usart->io.tx->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
1389+
GPIO_PinConfigure(usart->io.tx->port, usart->io.tx->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
13901390
}
13911391
}
13921392
}
@@ -1400,7 +1400,7 @@ static int32_t USART_Control ( uint32_t control,
14001400
if ((usart->info->mode != ARM_USART_MODE_SMART_CARD) &&
14011401
(usart->info->mode != ARM_USART_MODE_SINGLE_WIRE )) {
14021402
// USART RX pin function selected
1403-
GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_FLOATING, GPIO_MODE_INPUT);
1403+
GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_FLOATING, GPIO_MODE_IN);
14041404
}
14051405
usart->info->flags |= USART_FLAG_RX_ENABLED;
14061406

@@ -1430,7 +1430,7 @@ static int32_t USART_Control ( uint32_t control,
14301430
(usart->info->mode != ARM_USART_MODE_SINGLE_WIRE )) {
14311431
// GPIO pin function selected
14321432
if (usart->io.rx) {
1433-
GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
1433+
GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
14341434
}
14351435
}
14361436
}
@@ -1696,7 +1696,7 @@ static int32_t USART_Control ( uint32_t control,
16961696
} else {
16971697
// GPIO pin function selected
16981698
if (usart->io.tx) {
1699-
GPIO_PinConfigure(usart->io.tx->port, usart->io.tx->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
1699+
GPIO_PinConfigure(usart->io.tx->port, usart->io.tx->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
17001700
}
17011701
}
17021702
}
@@ -1707,20 +1707,20 @@ static int32_t USART_Control ( uint32_t control,
17071707
case ARM_USART_MODE_SMART_CARD:
17081708
// GPIO pin function selected
17091709
if (usart->io.rx) {
1710-
GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
1710+
GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
17111711
}
17121712
break;
17131713
default:
17141714
// Synchronous master/slave, asynchronous and IrDA mode
17151715
if (usart->info->flags & USART_FLAG_RX_ENABLED) {
17161716
// USART RX pin function selected
17171717
if (usart->io.rx) {
1718-
GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_FLOATING, GPIO_MODE_INPUT);
1718+
GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_FLOATING, GPIO_MODE_IN);
17191719
}
17201720
} else {
17211721
// GPIO pin function selected
17221722
if (usart->io.rx) {
1723-
GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
1723+
GPIO_PinConfigure(usart->io.rx->port, usart->io.rx->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
17241724
}
17251725
}
17261726
break;
@@ -1737,7 +1737,7 @@ static int32_t USART_Control ( uint32_t control,
17371737
default:
17381738
// Asynchronous, Single-wire and IrDA mode
17391739
// GPIO pin function selected
1740-
GPIO_PinConfigure(usart->io.ck->port, usart->io.ck->pin, GPIO_IN_ANALOG, GPIO_MODE_INPUT);
1740+
GPIO_PinConfigure(usart->io.ck->port, usart->io.ck->pin, GPIO_IN_ANALOG, GPIO_MODE_IN);
17411741
}
17421742
}
17431743

@@ -1749,7 +1749,7 @@ static int32_t USART_Control ( uint32_t control,
17491749
GPIO_PinConfigure(usart->io.rts->port, usart->io.rts->pin, GPIO_AF_PUSHPULL, GPIO_MODE_OUT50MHZ);
17501750
} else {
17511751
// GPIO output
1752-
GPIO_PinConfigure(usart->io.rts->port, usart->io.rts->pin, GPIO_OUT_PUSH_PULL, GPIO_MODE_INPUT);
1752+
GPIO_PinConfigure(usart->io.rts->port, usart->io.rts->pin, GPIO_OUT_PUSH_PULL, GPIO_MODE_IN);
17531753
}
17541754
}
17551755

@@ -1758,10 +1758,10 @@ static int32_t USART_Control ( uint32_t control,
17581758
if ((flow_control == ARM_USART_FLOW_CONTROL_CTS) ||
17591759
(flow_control == ARM_USART_FLOW_CONTROL_RTS_CTS)) {
17601760
// USART CTS Alternate function
1761-
GPIO_PinConfigure(usart->io.cts->port, usart->io.cts->pin, GPIO_IN_FLOATING, GPIO_MODE_INPUT);
1761+
GPIO_PinConfigure(usart->io.cts->port, usart->io.cts->pin, GPIO_IN_FLOATING, GPIO_MODE_IN);
17621762
} else {
17631763
// GPIO input
1764-
GPIO_PinConfigure(usart->io.cts->port, usart->io.cts->pin, GPIO_IN_FLOATING, GPIO_MODE_INPUT);
1764+
GPIO_PinConfigure(usart->io.cts->port, usart->io.cts->pin, GPIO_IN_FLOATING, GPIO_MODE_IN);
17651765
}
17661766
}
17671767

source/hic_hal/stm32/stm32f103xb/cmsis/USART_STM32F10x.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <stdbool.h>
3131
#include <string.h>
3232

33-
#include "stm32f10x.h"
33+
#include "stm32f1xx.h"
3434
#include "GPIO_STM32F10x.h"
3535
#include "DMA_STM32F10x.h"
3636

0 commit comments

Comments
 (0)