Skip to content

Commit 435d5d3

Browse files
LMESTMbulislaw
authored andcommitted
STM32: move pwmout device tables to C file
In order to avoid possible multiple definitions errors, move the table initialization to the C file instead of header file
1 parent 6599039 commit 435d5d3

File tree

18 files changed

+606
-264
lines changed

18 files changed

+606
-264
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/* mbed Microcontroller Library
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 "cmsis.h"
31+
#include "pwmout_api.h"
32+
#include "pwmout_device.h"
33+
34+
#ifdef DEVICE_PWMOUT
35+
36+
const pwm_apb_map_t pwm_apb_map_table[] =
37+
{
38+
#if defined(TIM2_BASE)
39+
{PWM_2, PWMOUT_ON_APB1},
40+
#endif
41+
#if defined(TIM3_BASE)
42+
{PWM_3, PWMOUT_ON_APB1},
43+
#endif
44+
#if defined(TIM14_BASE)
45+
{PWM_14, PWMOUT_ON_APB1},
46+
#endif
47+
#if defined(TIM1_BASE)
48+
{PWM_1, PWMOUT_ON_APB1},
49+
#endif
50+
#if defined(TIM15_BASE)
51+
{PWM_15, PWMOUT_ON_APB1},
52+
#endif
53+
#if defined(TIM16_BASE)
54+
{PWM_16, PWMOUT_ON_APB1},
55+
#endif
56+
#if defined(TIM17_BASE)
57+
{PWM_17, PWMOUT_ON_APB1},
58+
#endif
59+
{(PWMName) 0, PWMOUT_UNKNOWN}
60+
};
61+
62+
#endif // DEVICE_PWMOUT

targets/TARGET_STM/TARGET_STM32F0/pwmout_device.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,7 @@ typedef struct pwm_apb_map {
5252
/* there is only 1 APB clock in F0 family */
5353
#define PWMOUT_APB2_NOT_SUPPORTED
5454

55-
static const pwm_apb_map_t pwm_apb_map_table[] =
56-
{
57-
#if defined(TIM2_BASE)
58-
{PWM_2, PWMOUT_ON_APB1},
59-
#endif
60-
#if defined(TIM3_BASE)
61-
{PWM_3, PWMOUT_ON_APB1},
62-
#endif
63-
#if defined(TIM14_BASE)
64-
{PWM_14, PWMOUT_ON_APB1},
65-
#endif
66-
#if defined(TIM1_BASE)
67-
{PWM_1, PWMOUT_ON_APB1},
68-
#endif
69-
#if defined(TIM15_BASE)
70-
{PWM_15, PWMOUT_ON_APB1},
71-
#endif
72-
#if defined(TIM16_BASE)
73-
{PWM_16, PWMOUT_ON_APB1},
74-
#endif
75-
#if defined(TIM17_BASE)
76-
{PWM_17, PWMOUT_ON_APB1},
77-
#endif
78-
{(PWMName) 0, PWMOUT_UNKNOWN}
79-
};
55+
extern const pwm_apb_map_t pwm_apb_map_table[];
8056

8157
#endif // DEVICE_PWMOUT
8258

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* mbed Microcontroller Library
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 "cmsis.h"
31+
#include "pwmout_api.h"
32+
#include "pwmout_device.h"
33+
34+
#ifdef DEVICE_PWMOUT
35+
36+
const pwm_apb_map_t pwm_apb_map_table[] =
37+
{
38+
#if defined(TIM1_BASE)
39+
{PWM_1, PWMOUT_ON_APB2},
40+
#endif
41+
#if defined(TIM2_BASE)
42+
{PWM_2, PWMOUT_ON_APB1},
43+
#endif
44+
#if defined(TIM3_BASE)
45+
{PWM_3, PWMOUT_ON_APB1},
46+
#endif
47+
#if defined(TIM4_BASE)
48+
{PWM_4, PWMOUT_ON_APB1},
49+
#endif
50+
{(PWMName) 0, PWMOUT_UNKNOWN}
51+
};
52+
53+
#endif // DEVICE_PWMOUT

targets/TARGET_STM/TARGET_STM32F1/pwmout_device.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,7 @@ typedef struct pwm_apb_map {
5050
PwmoutApb pwmoutApb;
5151
} pwm_apb_map_t;
5252

53-
static const pwm_apb_map_t pwm_apb_map_table[] =
54-
{
55-
#if defined(TIM1_BASE)
56-
{PWM_1, PWMOUT_ON_APB2},
57-
#endif
58-
#if defined(TIM2_BASE)
59-
{PWM_2, PWMOUT_ON_APB1},
60-
#endif
61-
#if defined(TIM3_BASE)
62-
{PWM_3, PWMOUT_ON_APB1},
63-
#endif
64-
#if defined(TIM4_BASE)
65-
{PWM_4, PWMOUT_ON_APB1},
66-
#endif
67-
{(PWMName) 0, PWMOUT_UNKNOWN}
68-
};
53+
extern const pwm_apb_map_t pwm_apb_map_table[];
6954

7055
#endif // DEVICE_PWMOUT
7156

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/* mbed Microcontroller Library
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 "cmsis.h"
31+
#include "pwmout_api.h"
32+
#include "pwmout_device.h"
33+
34+
#ifdef DEVICE_PWMOUT
35+
36+
const pwm_apb_map_t pwm_apb_map_table[] =
37+
{
38+
#if defined(TIM2_BASE)
39+
{PWM_2, PWMOUT_ON_APB1},
40+
#endif
41+
#if defined(TIM3_BASE)
42+
{PWM_3, PWMOUT_ON_APB1},
43+
#endif
44+
#if defined(TIM4_BASE)
45+
{PWM_4, PWMOUT_ON_APB1},
46+
#endif
47+
#if defined(TIM5_BASE)
48+
{PWM_5, PWMOUT_ON_APB1},
49+
#endif
50+
#if defined(TIM12_BASE)
51+
{PWM_12, PWMOUT_ON_APB1},
52+
#endif
53+
#if defined(TIM13_BASE)
54+
{PWM_13, PWMOUT_ON_APB1},
55+
#endif
56+
#if defined(TIM14_BASE)
57+
{PWM_14, PWMOUT_ON_APB1},
58+
#endif
59+
#if defined(TIM1_BASE)
60+
{PWM_1, PWMOUT_ON_APB2},
61+
#endif
62+
#if defined(TIM8_BASE)
63+
{PWM_8, PWMOUT_ON_APB2},
64+
#endif
65+
#if defined(TIM9_BASE)
66+
{PWM_9, PWMOUT_ON_APB2},
67+
#endif
68+
#if defined(TIM10_BASE)
69+
{PWM_10, PWMOUT_ON_APB2},
70+
#endif
71+
#if defined(TIM11_BASE)
72+
{PWM_11, PWMOUT_ON_APB2},
73+
#endif
74+
{(PWMName) 0, PWMOUT_UNKNOWN}
75+
};
76+
77+
#endif // DEVICE_PWMOUT

targets/TARGET_STM/TARGET_STM32F2/pwmout_device.h

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -50,46 +50,7 @@ typedef struct pwm_apb_map {
5050
PwmoutApb pwmoutApb;
5151
} pwm_apb_map_t;
5252

53-
static const pwm_apb_map_t pwm_apb_map_table[] =
54-
{
55-
#if defined(TIM2_BASE)
56-
{PWM_2, PWMOUT_ON_APB1},
57-
#endif
58-
#if defined(TIM3_BASE)
59-
{PWM_3, PWMOUT_ON_APB1},
60-
#endif
61-
#if defined(TIM4_BASE)
62-
{PWM_4, PWMOUT_ON_APB1},
63-
#endif
64-
#if defined(TIM5_BASE)
65-
{PWM_5, PWMOUT_ON_APB1},
66-
#endif
67-
#if defined(TIM12_BASE)
68-
{PWM_12, PWMOUT_ON_APB1},
69-
#endif
70-
#if defined(TIM13_BASE)
71-
{PWM_13, PWMOUT_ON_APB1},
72-
#endif
73-
#if defined(TIM14_BASE)
74-
{PWM_14, PWMOUT_ON_APB1},
75-
#endif
76-
#if defined(TIM1_BASE)
77-
{PWM_1, PWMOUT_ON_APB2},
78-
#endif
79-
#if defined(TIM8_BASE)
80-
{PWM_8, PWMOUT_ON_APB2},
81-
#endif
82-
#if defined(TIM9_BASE)
83-
{PWM_9, PWMOUT_ON_APB2},
84-
#endif
85-
#if defined(TIM10_BASE)
86-
{PWM_10, PWMOUT_ON_APB2},
87-
#endif
88-
#if defined(TIM11_BASE)
89-
{PWM_11, PWMOUT_ON_APB2},
90-
#endif
91-
{(PWMName) 0, PWMOUT_UNKNOWN}
92-
};
53+
extern const pwm_apb_map_t pwm_apb_map_table[];
9354

9455
#endif // DEVICE_PWMOUT
9556

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* mbed Microcontroller Library
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 "cmsis.h"
31+
#include "pwmout_api.h"
32+
#include "pwmout_device.h"
33+
34+
#ifdef DEVICE_PWMOUT
35+
36+
const pwm_apb_map_t pwm_apb_map_table[] =
37+
{
38+
#if defined(TIM2_BASE)
39+
{PWM_2, PWMOUT_ON_APB1},
40+
#endif
41+
#if defined(TIM3_BASE)
42+
{PWM_3, PWMOUT_ON_APB1},
43+
#endif
44+
#if defined(TIM4_BASE)
45+
{PWM_4, PWMOUT_ON_APB1},
46+
#endif
47+
#if defined(TIM1_BASE)
48+
{PWM_1, PWMOUT_ON_APB2},
49+
#endif
50+
#if defined(TIM8_BASE)
51+
{PWM_8, PWMOUT_ON_APB2},
52+
#endif
53+
#if defined(TIM15_BASE)
54+
{PWM_15, PWMOUT_ON_APB2},
55+
#endif
56+
#if defined(TIM16_BASE)
57+
{PWM_16, PWMOUT_ON_APB2},
58+
#endif
59+
#if defined(TIM17_BASE)
60+
{PWM_17, PWMOUT_ON_APB2},
61+
#endif
62+
#if defined(TIM20_BASE)
63+
{PWM_20, PWMOUT_ON_APB2},
64+
#endif
65+
{(PWMName) 0, PWMOUT_UNKNOWN}
66+
};
67+
68+
#endif // DEVICE_PWMOUT

0 commit comments

Comments
 (0)