Skip to content

Commit 8853453

Browse files
Andreas TersteggeAndreas Terstegge
authored andcommitted
First version of MSP432 support for mbed OS
Removed private TODO file. Fixed cmsis.h so that renaming of CS and DIR_H is not necessary any more. Leave pinmap.h unchanged although it should include stdint.h Moved stdint.h to PinNames.h instead, where it is also used. Reworked system startup (clock configuration) to be more flexible (different clock sources for MCLK and SMCLK, configurable clock dividers). Fixed Copyright headers Changed default clock settings for MSP432 Launchpad to MCLK 48 MHz (HFXT) and SMCLK 24 MHz (HFXT) Remove mbed_rtx.h Added common mbed_rtx.h file (merge with lastest master) Added support for IAR toolchain Fixed some astyle problems. Added support for ARM C5/C6 toolchains Small changes to us_ticker implementation after port testing. Changed default clock configuration to DCO (MCLK 48MHz, SMCLK 24MHz). De-configured the LFXT crysal, because this made the system_reset() test to time out. Removed MPU from device_has list. Changed clock source to HFXT. Reworked startup_msp432p401r.c -> now only one startup file for all compilers. Changed all linker scripts to delete VECTORS stuff (not needed). Moved position of MSP432 in targets.json so TI stuff is in one block.
1 parent e001216 commit 8853453

34 files changed

+15760
-5
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef MBED_PERIPHERALNAMES_H
19+
#define MBED_PERIPHERALNAMES_H
20+
21+
/* mbed-os internally uses integer values
22+
* for peripheral names. Instead of defining
23+
* enums with new names, we simply reuse the
24+
* macros for the base addresses of the
25+
* peripheral units, which are defined in
26+
* msp.h and are self-explanatory (see
27+
* PeripheralPins.c).
28+
* So the name types are simply typedefs
29+
* to integers...
30+
*/
31+
32+
#define DEVICE_SPI_COUNT 4
33+
34+
typedef uint32_t ADCName;
35+
typedef uint32_t UARTName;
36+
typedef uint32_t I2CName;
37+
typedef uint32_t SPIName;
38+
typedef uint32_t PWMName;
39+
40+
#endif
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "PeripheralPins.h"
19+
#include "PeripheralNames.h"
20+
#include "cmsis.h"
21+
22+
const PinMap PinMap_empty[] = {
23+
{ NC, NC, 0 }
24+
};
25+
26+
/*** ADC ***/
27+
const PinMap PinMap_ADC[] = {
28+
{ P5_5, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 0) },
29+
{ P5_4, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 1) },
30+
{ P5_3, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 2) },
31+
{ P5_2, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 3) },
32+
{ P5_1, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 4) },
33+
{ P5_0, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 5) },
34+
{ P4_7, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 6) },
35+
{ P4_6, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 7) },
36+
{ P4_5, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 8) },
37+
{ P4_4, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 9) },
38+
{ P4_3, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 10) },
39+
{ P4_2, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 11) },
40+
{ P4_1, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 12) },
41+
{ P4_0, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 13) },
42+
{ P6_1, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 14) },
43+
{ P6_0, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 15) },
44+
{ P9_1, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 16) },
45+
{ P9_0, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 17) },
46+
{ P8_7, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 18) },
47+
{ P8_6, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 19) },
48+
{ P8_5, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 20) },
49+
{ P8_4, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 21) },
50+
{ P8_3, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 22) },
51+
{ P8_2, ADC14_BASE, MSP432_PIN_DATA(SEL3, PIN_INPUT, PullNone, 23) },
52+
{ NC, NC, 0 }
53+
};
54+
55+
const PinMap PinMap_ADC_Internal[] = {
56+
{ NC, NC, 0 }
57+
};
58+
59+
//*** I2C ***
60+
const PinMap PinMap_I2C_SDA[] = {
61+
{ P1_6, EUSCI_B0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, OpenDrainPullUp, 0) },
62+
{ P6_4, EUSCI_B1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, OpenDrainPullUp, 0) },
63+
{ P3_6, EUSCI_B2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, OpenDrainPullUp, 0) },
64+
{ P6_6, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL2, PIN_OUTPUT, OpenDrainPullUp, 0) },
65+
{ P10_2, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, OpenDrainPullUp, 0) },
66+
{ NC, NC, 0 }
67+
};
68+
69+
const PinMap PinMap_I2C_SCL[] = {
70+
{ P1_7, EUSCI_B0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, OpenDrainPullUp, 0) },
71+
{ P6_5, EUSCI_B1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, OpenDrainPullUp, 0) },
72+
{ P3_7, EUSCI_B2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, OpenDrainPullUp, 0) },
73+
{ P6_7, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL2, PIN_OUTPUT, OpenDrainPullUp, 0) },
74+
{ P10_3, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, OpenDrainPullUp, 0) },
75+
{ NC, NC, 0 }
76+
};
77+
78+
//*** SERIAL ***
79+
const PinMap PinMap_UART_TX[] = {
80+
{ P1_3, EUSCI_A0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 0) },
81+
{ P2_3, EUSCI_A1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 0) },
82+
{ P3_3, EUSCI_A2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 0) },
83+
{ P9_7, EUSCI_A3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 0) },
84+
{ NC, NC, 0 }
85+
};
86+
87+
const PinMap PinMap_UART_RX[] = {
88+
{ P1_2, EUSCI_A0_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 0) },
89+
{ P2_2, EUSCI_A1_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 0) },
90+
{ P3_2, EUSCI_A2_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 0) },
91+
{ P9_6, EUSCI_A3_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 0) },
92+
{ NC, NC, 0 }
93+
};
94+
95+
//*** SPI ***
96+
const PinMap PinMap_SPI_MOSI[] = {
97+
{ P1_3, EUSCI_A0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 0) },
98+
{ P2_3, EUSCI_A1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 1) },
99+
{ P3_3, EUSCI_A2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 2) },
100+
{ P9_7, EUSCI_A3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 3) },
101+
{ P1_6, EUSCI_B0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 4) },
102+
{ P6_4, EUSCI_B1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 5) },
103+
{ P3_6, EUSCI_B2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 6) },
104+
{ P6_6, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL2, PIN_OUTPUT, PullNone, 7) },
105+
{ P10_2, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 7) },
106+
{ NC, NC, 0 }
107+
};
108+
109+
const PinMap PinMap_SPI_MISO[] = {
110+
{ P1_2, EUSCI_A0_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 0) },
111+
{ P2_2, EUSCI_A1_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 1) },
112+
{ P3_2, EUSCI_A2_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 2) },
113+
{ P9_6, EUSCI_A3_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 3) },
114+
{ P1_7, EUSCI_B0_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 4) },
115+
{ P6_5, EUSCI_B1_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 5) },
116+
{ P3_7, EUSCI_B2_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 6) },
117+
{ P6_7, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL2, PIN_INPUT, PullNone, 7) },
118+
{ P10_3, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL1, PIN_INPUT, PullNone, 7) },
119+
{ NC, NC, 0 }
120+
};
121+
122+
const PinMap PinMap_SPI_SCLK[] = {
123+
{ P1_1, EUSCI_A0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 0) },
124+
{ P2_1, EUSCI_A1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 1) },
125+
{ P3_1, EUSCI_A2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 2) },
126+
{ P9_5, EUSCI_A3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 3) },
127+
{ P1_5, EUSCI_B0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 4) },
128+
{ P6_3, EUSCI_B1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 5) },
129+
{ P3_5, EUSCI_B2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 6) },
130+
{ P8_1, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 7) },
131+
{ P10_1, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 7) },
132+
{ NC, NC, 0 }
133+
};
134+
135+
const PinMap PinMap_SPI_SSEL[] = {
136+
{ P1_0, EUSCI_A0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 0) },
137+
{ P2_0, EUSCI_A1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 1) },
138+
{ P3_0, EUSCI_A2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 2) },
139+
{ P9_4, EUSCI_A3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 3) },
140+
{ P1_4, EUSCI_B0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 4) },
141+
{ P6_2, EUSCI_B1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 5) },
142+
{ P3_4, EUSCI_B2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 6) },
143+
{ P8_0, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 7) },
144+
{ P10_0, EUSCI_B3_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 7) },
145+
{ NC, NC, 0 }
146+
};
147+
148+
const PinMap PinMap_PWM[] = {
149+
{ P2_4, TIMER_A0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 1) },
150+
{ P2_5, TIMER_A0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 2) },
151+
{ P2_6, TIMER_A0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 3) },
152+
{ P2_7, TIMER_A0_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 4) },
153+
{ P7_7, TIMER_A1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 1) },
154+
{ P7_6, TIMER_A1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 2) },
155+
{ P7_5, TIMER_A1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 3) },
156+
{ P7_4, TIMER_A1_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 4) },
157+
{ P5_6, TIMER_A2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 1) },
158+
{ P5_7, TIMER_A2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 2) },
159+
{ P6_6, TIMER_A2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 3) },
160+
{ P6_7, TIMER_A2_BASE, MSP432_PIN_DATA(SEL1, PIN_OUTPUT, PullNone, 4) },
161+
{ NC, NC, 0 }
162+
};
163+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef MBED_PERIPHERALPINS_H
19+
#define MBED_PERIPHERALPINS_H
20+
21+
#include "pinmap.h"
22+
23+
typedef enum {
24+
SEL0 = 0,
25+
SEL1 = 1,
26+
SEL2 = 2,
27+
SEL3 = 3
28+
} pin_sel_t;
29+
30+
#define MSP432_PIN_DATA(sel, dir, mode, channel) (sel | (dir << 8) | (mode << 16) | (channel << 24))
31+
32+
#define GET_DATA_SEL(data) ( data & 0xff)
33+
#define GET_DATA_DIR(data) ((data >> 8) & 0xff)
34+
#define GET_DATA_MODE(data) ((data >> 16) & 0xff)
35+
#define GET_DATA_CHAN(data) ((data >> 24) & 0xff)
36+
37+
extern const PinMap PinMap_empty[];
38+
39+
//*** ADC ***
40+
#if DEVICE_ANALOGIN
41+
extern const PinMap PinMap_ADC[];
42+
extern const PinMap PinMap_ADC_Internal[];
43+
#endif
44+
45+
//*** I2C ***
46+
#if DEVICE_I2C
47+
extern const PinMap PinMap_I2C_SDA[];
48+
extern const PinMap PinMap_I2C_SCL[];
49+
#endif
50+
51+
//*** PWM ***
52+
#if DEVICE_PWMOUT
53+
extern const PinMap PinMap_PWM[];
54+
#endif
55+
56+
//*** SERIAL ***
57+
#if DEVICE_SERIAL
58+
extern const PinMap PinMap_UART_TX[];
59+
extern const PinMap PinMap_UART_RX[];
60+
#endif
61+
62+
//*** SPI ***
63+
#if DEVICE_SPI
64+
extern const PinMap PinMap_SPI_MOSI[];
65+
extern const PinMap PinMap_SPI_MISO[];
66+
extern const PinMap PinMap_SPI_SCLK[];
67+
extern const PinMap PinMap_SPI_SSEL[];
68+
#endif
69+
70+
#endif

0 commit comments

Comments
 (0)