Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 0c97f2c

Browse files
committed
Add STM32 core
Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent a86b4f4 commit 0c97f2c

Some content is hidden

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

47 files changed

+10626
-0
lines changed

cores/arduino/stm32/PeripheralPins.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2014, 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+
31+
#ifndef _PERIPHERALPINS_H
32+
#define _PERIPHERALPINS_H
33+
34+
#include "pinmap.h"
35+
36+
//*** ADC ***
37+
extern const PinMap PinMap_ADC[];
38+
39+
//*** DAC ***
40+
extern const PinMap PinMap_DAC[];
41+
42+
//*** I2C ***
43+
extern const PinMap PinMap_I2C_SDA[];
44+
extern const PinMap PinMap_I2C_SCL[];
45+
46+
//*** PWM ***
47+
extern const PinMap PinMap_PWM[];
48+
49+
//*** SERIAL ***
50+
extern const PinMap PinMap_UART_TX[];
51+
extern const PinMap PinMap_UART_RX[];
52+
extern const PinMap PinMap_UART_RTS[];
53+
extern const PinMap PinMap_UART_CTS[];
54+
55+
//*** SPI ***
56+
extern const PinMap PinMap_SPI_MOSI[];
57+
extern const PinMap PinMap_SPI_MISO[];
58+
extern const PinMap PinMap_SPI_SCLK[];
59+
extern const PinMap PinMap_SPI_SSEL[];
60+
61+
//*** CAN ***
62+
extern const PinMap PinMap_CAN_RD[];
63+
extern const PinMap PinMap_CAN_TD[];
64+
65+
//*** TIMER ***
66+
extern const TimerMap TimerMap_CONFIG[];
67+
68+
#endif
69+

cores/arduino/stm32/PinConfigured.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2017, 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+
#include "PinConfigured.h"
31+
32+
bool is_pin_configured(PinName pin, uint32_t* map) {
33+
uint32_t index = PINCONF_INDEX(pin);
34+
return PINCONF_VAL(pin, map[index]);
35+
}
36+
37+
void set_pin_configured(PinName pin, uint32_t* map) {
38+
uint32_t index = PINCONF_INDEX(pin);
39+
map[index] = map[index] | PINCONF_BIT(pin);
40+
}
41+
42+
void reset_pin_configured(PinName pin, uint32_t* map) {
43+
uint32_t index = PINCONF_INDEX(pin);
44+
map[index] = map[index] & (~PINCONF_BIT(pin));
45+
}
46+

cores/arduino/stm32/PinConfigured.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2017, 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 _PINCONFIGURED_H
31+
#define _PINCONFIGURED_H
32+
33+
#include "Arduino.h"
34+
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif
38+
39+
#define PINCONF_INDEX(X) (STM_PORT(X)-FirstPort)
40+
41+
#define PINCONF_MASK 0x01
42+
#define PINCONF_SHIFT(X) (STM_PIN(X))
43+
#define PINCONF_BIT(X) (PINCONF_MASK << PINCONF_SHIFT(X))
44+
45+
#define PINCONF_VAL(X, Y) ((Y >> PINCONF_SHIFT(X)) & PINCONF_MASK)
46+
47+
48+
bool is_pin_configured(PinName pin, uint32_t* map);
49+
void set_pin_configured(PinName pin, uint32_t* map);
50+
void reset_pin_configured(PinName pin, uint32_t* map);
51+
52+
#ifdef __cplusplus
53+
}
54+
#endif
55+
56+
#endif

0 commit comments

Comments
 (0)