Skip to content

Commit 42f6622

Browse files
committed
STM32: Move types definitions to a common file
Only one point of attention: STM_MODE_ANALOG_ADC_CONTROL is a specific mode that is only supported on L4. So STM_MODE_ANALOG_ADC_CONTROL was moved to index 13 (last entry) of gpio_mode table so that all the other modes are common and only the last one is specific.
1 parent 04a31f3 commit 42f6622

File tree

54 files changed

+153
-2371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+153
-2371
lines changed

targets/TARGET_STM/PinNamesTypes.h

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/* mbed Microcontroller Library
2+
*******************************************************************************
3+
* Copyright (c) 2016, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software
16+
* without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*******************************************************************************
29+
*/
30+
#ifndef MBED_PINNAMESTYPES_H
31+
#define MBED_PINNAMESTYPES_H
32+
33+
#include "cmsis.h"
34+
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif
38+
39+
#define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((MODE & 0x0F) << 0) |\
40+
((PUPD & 0x07) << 4) |\
41+
((AFNUM & 0x0F) << 7)))
42+
43+
#define STM_PIN_DATA_EXT(MODE, PUPD, AFNUM, CHANNEL, INVERTED) ((int)(((MODE & 0x0F) << 0) |\
44+
((PUPD & 0x07) << 4) |\
45+
((AFNUM & 0x0F) << 7) |\
46+
((CHANNEL & 0x1F) << 11) |\
47+
((INVERTED & 0x01) << 16)))
48+
49+
#define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
50+
#define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
51+
#define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
52+
#define STM_PIN_CHANNEL(X) (((X) >> 11) & 0x1F)
53+
#define STM_PIN_INVERTED(X) (((X) >> 16) & 0x01)
54+
55+
#define STM_MODE_INPUT (0)
56+
#define STM_MODE_OUTPUT_PP (1)
57+
#define STM_MODE_OUTPUT_OD (2)
58+
#define STM_MODE_AF_PP (3)
59+
#define STM_MODE_AF_OD (4)
60+
#define STM_MODE_ANALOG (5)
61+
#define STM_MODE_IT_RISING (6)
62+
#define STM_MODE_IT_FALLING (7)
63+
#define STM_MODE_IT_RISING_FALLING (8)
64+
#define STM_MODE_EVT_RISING (9)
65+
#define STM_MODE_EVT_FALLING (10)
66+
#define STM_MODE_EVT_RISING_FALLING (11)
67+
#define STM_MODE_IT_EVT_RESET (12)
68+
// The last mode is only valid for specific families, so we put it in the end
69+
#define STM_MODE_ANALOG_ADC_CONTROL (13)
70+
71+
// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
72+
// Low nibble = pin number
73+
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
74+
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
75+
76+
typedef enum {
77+
PIN_INPUT,
78+
PIN_OUTPUT
79+
} PinDirection;
80+
81+
typedef enum {
82+
PullNone = 0,
83+
PullUp = 1,
84+
PullDown = 2,
85+
OpenDrain = 3,
86+
PullDefault = PullNone
87+
} PinMode;
88+
89+
#ifdef __cplusplus
90+
}
91+
#endif
92+
93+
#endif

targets/TARGET_STM/TARGET_STM32F0/TARGET_DISCO_F051R8/PinNames.h

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,51 +31,12 @@
3131
#define MBED_PINNAMES_H
3232

3333
#include "cmsis.h"
34+
#include "PinNamesTypes.h"
3435

3536
#ifdef __cplusplus
3637
extern "C" {
3738
#endif
3839

39-
#define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((MODE & 0x0F) << 0) |\
40-
((PUPD & 0x07) << 4) |\
41-
((AFNUM & 0x0F) << 7)))
42-
43-
#define STM_PIN_DATA_EXT(MODE, PUPD, AFNUM, CHANNEL, INVERTED) ((int)(((MODE & 0x0F) << 0) |\
44-
((PUPD & 0x07) << 4) |\
45-
((AFNUM & 0x0F) << 7) |\
46-
((CHANNEL & 0x1F) << 11) |\
47-
((INVERTED & 0x01) << 16)))
48-
49-
#define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
50-
#define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
51-
#define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
52-
#define STM_PIN_CHANNEL(X) (((X) >> 11) & 0x1F)
53-
#define STM_PIN_INVERTED(X) (((X) >> 16) & 0x01)
54-
55-
#define STM_MODE_INPUT (0)
56-
#define STM_MODE_OUTPUT_PP (1)
57-
#define STM_MODE_OUTPUT_OD (2)
58-
#define STM_MODE_AF_PP (3)
59-
#define STM_MODE_AF_OD (4)
60-
#define STM_MODE_ANALOG (5)
61-
#define STM_MODE_IT_RISING (6)
62-
#define STM_MODE_IT_FALLING (7)
63-
#define STM_MODE_IT_RISING_FALLING (8)
64-
#define STM_MODE_EVT_RISING (9)
65-
#define STM_MODE_EVT_FALLING (10)
66-
#define STM_MODE_EVT_RISING_FALLING (11)
67-
#define STM_MODE_IT_EVT_RESET (12)
68-
69-
// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
70-
// Low nibble = pin number
71-
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
72-
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
73-
74-
typedef enum {
75-
PIN_INPUT,
76-
PIN_OUTPUT
77-
} PinDirection;
78-
7940
typedef enum {
8041
PA_0 = 0x00,
8142
PA_1 = 0x01,
@@ -241,14 +202,6 @@ typedef enum {
241202
NC = (int)0xFFFFFFFF
242203
} PinName;
243204

244-
typedef enum {
245-
PullNone = 0,
246-
PullUp = 1,
247-
PullDown = 2,
248-
OpenDrain = 3,
249-
PullDefault = PullNone
250-
} PinMode;
251-
252205
#ifdef __cplusplus
253206
}
254207
#endif

targets/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F030R8/PinNames.h

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,51 +31,12 @@
3131
#define MBED_PINNAMES_H
3232

3333
#include "cmsis.h"
34+
#include "PinNamesTypes.h"
3435

3536
#ifdef __cplusplus
3637
extern "C" {
3738
#endif
3839

39-
#define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((MODE & 0x0F) << 0) |\
40-
((PUPD & 0x07) << 4) |\
41-
((AFNUM & 0x0F) << 7)))
42-
43-
#define STM_PIN_DATA_EXT(MODE, PUPD, AFNUM, CHANNEL, INVERTED) ((int)(((MODE & 0x0F) << 0) |\
44-
((PUPD & 0x07) << 4) |\
45-
((AFNUM & 0x0F) << 7) |\
46-
((CHANNEL & 0x1F) << 11) |\
47-
((INVERTED & 0x01) << 16)))
48-
49-
#define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
50-
#define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
51-
#define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
52-
#define STM_PIN_CHANNEL(X) (((X) >> 11) & 0x1F)
53-
#define STM_PIN_INVERTED(X) (((X) >> 16) & 0x01)
54-
55-
#define STM_MODE_INPUT (0)
56-
#define STM_MODE_OUTPUT_PP (1)
57-
#define STM_MODE_OUTPUT_OD (2)
58-
#define STM_MODE_AF_PP (3)
59-
#define STM_MODE_AF_OD (4)
60-
#define STM_MODE_ANALOG (5)
61-
#define STM_MODE_IT_RISING (6)
62-
#define STM_MODE_IT_FALLING (7)
63-
#define STM_MODE_IT_RISING_FALLING (8)
64-
#define STM_MODE_EVT_RISING (9)
65-
#define STM_MODE_EVT_FALLING (10)
66-
#define STM_MODE_EVT_RISING_FALLING (11)
67-
#define STM_MODE_IT_EVT_RESET (12)
68-
69-
// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
70-
// Low nibble = pin number
71-
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
72-
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
73-
74-
typedef enum {
75-
PIN_INPUT,
76-
PIN_OUTPUT
77-
} PinDirection;
78-
7940
typedef enum {
8041
PA_0 = 0x00,
8142
PA_1 = 0x01,
@@ -188,14 +149,6 @@ typedef enum {
188149
NC = (int)0xFFFFFFFF
189150
} PinName;
190151

191-
typedef enum {
192-
PullNone = 0,
193-
PullUp = 1,
194-
PullDown = 2,
195-
OpenDrain = 3,
196-
PullDefault = PullNone
197-
} PinMode;
198-
199152
#ifdef __cplusplus
200153
}
201154
#endif

targets/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F031K6/PinNames.h

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,51 +31,12 @@
3131
#define MBED_PINNAMES_H
3232

3333
#include "cmsis.h"
34+
#include "PinNamesTypes.h"
3435

3536
#ifdef __cplusplus
3637
extern "C" {
3738
#endif
3839

39-
#define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((MODE & 0x0F) << 0) |\
40-
((PUPD & 0x07) << 4) |\
41-
((AFNUM & 0x0F) << 7)))
42-
43-
#define STM_PIN_DATA_EXT(MODE, PUPD, AFNUM, CHANNEL, INVERTED) ((int)(((MODE & 0x0F) << 0) |\
44-
((PUPD & 0x07) << 4) |\
45-
((AFNUM & 0x0F) << 7) |\
46-
((CHANNEL & 0x1F) << 11) |\
47-
((INVERTED & 0x01) << 16)))
48-
49-
#define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
50-
#define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
51-
#define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
52-
#define STM_PIN_CHANNEL(X) (((X) >> 11) & 0x1F)
53-
#define STM_PIN_INVERTED(X) (((X) >> 16) & 0x01)
54-
55-
#define STM_MODE_INPUT (0)
56-
#define STM_MODE_OUTPUT_PP (1)
57-
#define STM_MODE_OUTPUT_OD (2)
58-
#define STM_MODE_AF_PP (3)
59-
#define STM_MODE_AF_OD (4)
60-
#define STM_MODE_ANALOG (5)
61-
#define STM_MODE_IT_RISING (6)
62-
#define STM_MODE_IT_FALLING (7)
63-
#define STM_MODE_IT_RISING_FALLING (8)
64-
#define STM_MODE_EVT_RISING (9)
65-
#define STM_MODE_EVT_FALLING (10)
66-
#define STM_MODE_EVT_RISING_FALLING (11)
67-
#define STM_MODE_IT_EVT_RESET (12)
68-
69-
// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
70-
// Low nibble = pin number
71-
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
72-
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
73-
74-
typedef enum {
75-
PIN_INPUT,
76-
PIN_OUTPUT
77-
} PinDirection;
78-
7940
typedef enum {
8041
PA_0 = 0x00,
8142
PA_1 = 0x01,
@@ -157,14 +118,6 @@ typedef enum {
157118
NC = (int)0xFFFFFFFF
158119
} PinName;
159120

160-
typedef enum {
161-
PullNone = 0,
162-
PullUp = 1,
163-
PullDown = 2,
164-
OpenDrain = 3,
165-
PullDefault = PullNone
166-
} PinMode;
167-
168121
#ifdef __cplusplus
169122
}
170123
#endif

targets/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F042K6/PinNames.h

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,51 +31,12 @@
3131
#define MBED_PINNAMES_H
3232

3333
#include "cmsis.h"
34+
#include "PinNamesTypes.h"
3435

3536
#ifdef __cplusplus
3637
extern "C" {
3738
#endif
3839

39-
#define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((MODE & 0x0F) << 0) |\
40-
((PUPD & 0x07) << 4) |\
41-
((AFNUM & 0x0F) << 7)))
42-
43-
#define STM_PIN_DATA_EXT(MODE, PUPD, AFNUM, CHANNEL, INVERTED) ((int)(((MODE & 0x0F) << 0) |\
44-
((PUPD & 0x07) << 4) |\
45-
((AFNUM & 0x0F) << 7) |\
46-
((CHANNEL & 0x1F) << 11) |\
47-
((INVERTED & 0x01) << 16)))
48-
49-
#define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
50-
#define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
51-
#define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
52-
#define STM_PIN_CHANNEL(X) (((X) >> 11) & 0x1F)
53-
#define STM_PIN_INVERTED(X) (((X) >> 16) & 0x01)
54-
55-
#define STM_MODE_INPUT (0)
56-
#define STM_MODE_OUTPUT_PP (1)
57-
#define STM_MODE_OUTPUT_OD (2)
58-
#define STM_MODE_AF_PP (3)
59-
#define STM_MODE_AF_OD (4)
60-
#define STM_MODE_ANALOG (5)
61-
#define STM_MODE_IT_RISING (6)
62-
#define STM_MODE_IT_FALLING (7)
63-
#define STM_MODE_IT_RISING_FALLING (8)
64-
#define STM_MODE_EVT_RISING (9)
65-
#define STM_MODE_EVT_FALLING (10)
66-
#define STM_MODE_EVT_RISING_FALLING (11)
67-
#define STM_MODE_IT_EVT_RESET (12)
68-
69-
// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
70-
// Low nibble = pin number
71-
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
72-
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
73-
74-
typedef enum {
75-
PIN_INPUT,
76-
PIN_OUTPUT
77-
} PinDirection;
78-
7940
typedef enum {
8041
PA_0 = 0x00,
8142
PA_1 = 0x01,
@@ -156,14 +117,6 @@ typedef enum {
156117
NC = (int)0xFFFFFFFF
157118
} PinName;
158119

159-
typedef enum {
160-
PullNone = 0,
161-
PullUp = 1,
162-
PullDown = 2,
163-
OpenDrain = 3,
164-
PullDefault = PullNone
165-
} PinMode;
166-
167120
#ifdef __cplusplus
168121
}
169122
#endif

0 commit comments

Comments
 (0)