Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.

Commit 153fa2f

Browse files
fprVVESTM
fpr
authored andcommitted
Add STM8 core folder
Link STM8 standard peripheral library with Arduino project. Signed-off-by: Ridha Noomane <ridha.noomane@wi6labs.com> Signed-off-by: Frederic Pillon <frederic.pillon@st.com> Signed-off-by: Vincent Veron <vincent.veron@st.com>
1 parent d97b970 commit 153fa2f

Some content is hidden

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

70 files changed

+6338
-0
lines changed

LICENSE.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) (Year), (Name of copyright holder)
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
*
14+
* 3. Neither the name of the copyright holder nor the names of its
15+
* contributors may be used to endorse or promote products derived
16+
* from this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22+
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29+
* OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/

cores/arduino/stm8/PeripheralPins.h

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
#if defined(STM8Lxx)
36+
#include "PinAF_STM8Lxx.h"
37+
#endif
38+
39+
//*** ADC ***
40+
extern const PinMap PinMap_ADC[];
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+
extern const PinMap PinMap_UART_TX[];
49+
extern const PinMap PinMap_UART_RX[];
50+
51+
//*** SPI ***
52+
extern const PinMap PinMap_SPI_MOSI[];
53+
extern const PinMap PinMap_SPI_MISO[];
54+
extern const PinMap PinMap_SPI_SCLK[];
55+
extern const PinMap PinMap_SPI_SSEL[];
56+
57+
#endif

cores/arduino/stm8/PinAF_STM8Lxx.h

+217
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2018, 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 _PINAF_STM8LXX_H
32+
#define _PINAF_STM8LXX_H
33+
#ifdef STM8Lxx
34+
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif
38+
39+
enum {
40+
AFIO_NONE,
41+
AFIO_SPI1_FULL_ENABLE,
42+
AFIO_SPI1_FULL_DISABLE,
43+
AFIO_SPI1_PORTF_ENABLE,
44+
AFIO_SPI1_PORTF_DISABLE,
45+
AFIO_SPI2_ENABLE,
46+
AFIO_SPI2_DISABLE,
47+
AFIO_USART1_PORTA_ENABLE,
48+
AFIO_USART1_PORTA_DISABLE,
49+
AFIO_USART1_PORTC_ENABLE,
50+
AFIO_USART1_PORTC_DISABLE,
51+
AFIO_USART1_CLK_ENABLE,
52+
AFIO_USART1_CLK_DISABLE,
53+
AFIO_USART3_PORTF_ENABLE,
54+
AFIO_USART3_PORTF_DISABLE,
55+
AFIO_USART3_Clk_ENABLE,
56+
AFIO_USART3_Clk_DISABLE,
57+
AFIO_TIM2_CH1_ENABLE,
58+
AFIO_TIM2_CH1_DISABLE,
59+
AFIO_TIM2_CH2_ENABLE,
60+
AFIO_TIM2_CH2_DISABLE,
61+
AFIO_TIM2_TRIGPortA_ENABLE,
62+
AFIO_TIM2_TRIGPortA_DISABLE,
63+
AFIO_TIM2_TRIGLSE_ENABLE,
64+
AFIO_TIM2_TRIGLSE_DISABLE,
65+
AFIO_TIM2_TIM3_BKIN_ENABLE,
66+
AFIO_TIM2_TIM3_BKIN_DISABLE,
67+
AFIO_TIM3_CH1_ENABLE,
68+
AFIO_TIM3_CH1_DISABLE,
69+
AFIO_TIM3_CH2_ENABLE,
70+
AFIO_TIM3_CH2_DISABLE,
71+
AFIO_TIM3_TRIGPortA_ENABLE,
72+
AFIO_TIM3_TRIGPortA_DISABLE,
73+
AFIO_TIM3_TRIGPortG_ENABLE,
74+
AFIO_TIM3_TRIGPortG_DISABLE,
75+
AFIO_TIM3_TRIGLSE_ENABLE,
76+
AFIO_TIM3_TRIGLSE_DISABLE,
77+
AFIO_ADC1_EXTRIG_ENABLE,
78+
AFIO_ADC1_EXTRIG_DISABLE,
79+
AFIO_CCO_ENABLE,
80+
AFIO_CCO_DISABLE
81+
};
82+
83+
static inline void pin_Set8LAFPin(uint16_t afnum)
84+
{
85+
switch (afnum)
86+
{
87+
case AFIO_SPI1_FULL_ENABLE:
88+
SYSCFG_REMAPPinConfig(REMAP_Pin_SPI1Full, ENABLE);
89+
break;
90+
case AFIO_SPI1_FULL_DISABLE:
91+
SYSCFG_REMAPPinConfig(REMAP_Pin_SPI1Full, DISABLE);
92+
break;
93+
case AFIO_SPI1_PORTF_ENABLE:
94+
SYSCFG_REMAPPinConfig(REMAP_Pin_SPI1PortF, ENABLE);
95+
break;
96+
case AFIO_SPI1_PORTF_DISABLE:
97+
SYSCFG_REMAPPinConfig(REMAP_Pin_SPI1PortF, DISABLE);
98+
break;
99+
case AFIO_SPI2_ENABLE:
100+
SYSCFG_REMAPPinConfig(REMAP_Pin_SPI2Full, ENABLE);
101+
break;
102+
case AFIO_SPI2_DISABLE:
103+
SYSCFG_REMAPPinConfig(REMAP_Pin_SPI2Full, DISABLE);
104+
break;
105+
case AFIO_USART1_PORTA_ENABLE:
106+
SYSCFG_REMAPPinConfig(REMAP_Pin_USART1TxRxPortA, ENABLE);
107+
break;
108+
case AFIO_USART1_PORTA_DISABLE:
109+
SYSCFG_REMAPPinConfig(REMAP_Pin_USART1TxRxPortA, DISABLE);
110+
break;
111+
case AFIO_USART1_PORTC_ENABLE:
112+
SYSCFG_REMAPPinConfig(REMAP_Pin_USART1TxRxPortC, ENABLE);
113+
break;
114+
case AFIO_USART1_PORTC_DISABLE:
115+
SYSCFG_REMAPPinConfig(REMAP_Pin_USART1TxRxPortC, DISABLE);
116+
break;
117+
case AFIO_USART1_CLK_ENABLE:
118+
SYSCFG_REMAPPinConfig(REMAP_Pin_USART1Clk, ENABLE);
119+
break;
120+
case AFIO_USART1_CLK_DISABLE:
121+
SYSCFG_REMAPPinConfig(REMAP_Pin_USART1Clk, DISABLE);
122+
break;
123+
case AFIO_USART3_PORTF_ENABLE:
124+
SYSCFG_REMAPPinConfig(REMAP_Pin_USART3TxRxPortF, ENABLE);
125+
break;
126+
case AFIO_USART3_PORTF_DISABLE:
127+
SYSCFG_REMAPPinConfig(REMAP_Pin_USART3TxRxPortF, DISABLE);
128+
break;
129+
case AFIO_USART3_Clk_ENABLE:
130+
SYSCFG_REMAPPinConfig(REMAP_Pin_USART3Clk, ENABLE);
131+
break;
132+
case AFIO_USART3_Clk_DISABLE:
133+
SYSCFG_REMAPPinConfig(REMAP_Pin_USART3Clk, DISABLE);
134+
break;
135+
case AFIO_TIM2_CH1_ENABLE:
136+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM2Channel1, ENABLE);
137+
break;
138+
case AFIO_TIM2_CH1_DISABLE:
139+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM2Channel1, DISABLE);
140+
break;
141+
case AFIO_TIM2_CH2_ENABLE:
142+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM2Channel2, ENABLE);
143+
break;
144+
case AFIO_TIM2_CH2_DISABLE:
145+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM2Channel2, DISABLE);
146+
break;
147+
case AFIO_TIM2_TRIGPortA_ENABLE:
148+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM2TRIGPortA, ENABLE);
149+
break;
150+
case AFIO_TIM2_TRIGPortA_DISABLE:
151+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM2TRIGPortA, DISABLE);
152+
break;
153+
case AFIO_TIM2_TRIGLSE_ENABLE:
154+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM2TRIGLSE, ENABLE);
155+
break;
156+
case AFIO_TIM2_TRIGLSE_DISABLE:
157+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM2TRIGLSE, DISABLE);
158+
break;
159+
case AFIO_TIM2_TIM3_BKIN_ENABLE:
160+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM23BKIN, ENABLE);
161+
break;
162+
case AFIO_TIM2_TIM3_BKIN_DISABLE:
163+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM23BKIN, DISABLE);
164+
break;
165+
case AFIO_TIM3_CH1_ENABLE:
166+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM3Channel1, ENABLE);
167+
break;
168+
case AFIO_TIM3_CH1_DISABLE:
169+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM3Channel1, DISABLE);
170+
break;
171+
case AFIO_TIM3_CH2_ENABLE:
172+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM3Channel2, ENABLE);
173+
break;
174+
case AFIO_TIM3_CH2_DISABLE:
175+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM3Channel2, DISABLE);
176+
break;
177+
case AFIO_TIM3_TRIGPortA_ENABLE:
178+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM3TRIGPortA, ENABLE);
179+
break;
180+
case AFIO_TIM3_TRIGPortA_DISABLE:
181+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM3TRIGPortA, DISABLE);
182+
break;
183+
case AFIO_TIM3_TRIGPortG_ENABLE:
184+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM3TRIGPortG, ENABLE);
185+
break;
186+
case AFIO_TIM3_TRIGPortG_DISABLE:
187+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM3TRIGPortG, DISABLE);
188+
break;
189+
case AFIO_TIM3_TRIGLSE_ENABLE:
190+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM3TRIGLSE, ENABLE);
191+
break;
192+
case AFIO_TIM3_TRIGLSE_DISABLE:
193+
SYSCFG_REMAPPinConfig(REMAP_Pin_TIM3TRIGLSE, DISABLE);
194+
break;
195+
case AFIO_ADC1_EXTRIG_ENABLE:
196+
SYSCFG_REMAPPinConfig(REMAP_Pin_ADC1ExtTRIG1, ENABLE);
197+
break;
198+
case AFIO_ADC1_EXTRIG_DISABLE:
199+
SYSCFG_REMAPPinConfig(REMAP_Pin_ADC1ExtTRIG1, DISABLE);
200+
break;
201+
case AFIO_CCO_ENABLE:
202+
SYSCFG_REMAPPinConfig(REMAP_Pin_CCO, ENABLE);
203+
break;
204+
case AFIO_CCO_DISABLE:
205+
SYSCFG_REMAPPinConfig(REMAP_Pin_CCO, DISABLE);
206+
break;
207+
default:
208+
case AFIO_NONE:
209+
break;
210+
}
211+
}
212+
213+
#ifdef __cplusplus
214+
} // extern "C"
215+
#endif // __cplusplus
216+
#endif //STM8Lxx
217+
#endif //_PINAF_STM8LXX_H

cores/arduino/stm8/PinConfigured.c

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
{
34+
uint32_t index = PINCONF_INDEX(pin);
35+
return PINCONF_VAL(pin, map[index]);
36+
}
37+
38+
void set_pin_configured(PinName pin, uint32_t *map)
39+
{
40+
uint32_t index = PINCONF_INDEX(pin);
41+
map[index] = map[index] | PINCONF_BIT(pin);
42+
}
43+
44+
void reset_pin_configured(PinName pin, uint32_t *map)
45+
{
46+
uint32_t index = PINCONF_INDEX(pin);
47+
map[index] = map[index] & (~PINCONF_BIT(pin));
48+
}

0 commit comments

Comments
 (0)