Skip to content

Commit 4cc2d53

Browse files
committed
Added support for PWMOUT
1 parent 1c1458b commit 4cc2d53

File tree

4 files changed

+138
-1
lines changed

4 files changed

+138
-1
lines changed

targets/TARGET_STM/TARGET_STM32G4/objects.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ struct port_s {
4444
__IO uint32_t *reg_out;
4545
};
4646

47+
struct pwmout_s {
48+
PWMName pwm;
49+
PinName pin;
50+
uint32_t prescaler;
51+
uint32_t period;
52+
uint32_t pulse;
53+
uint8_t channel;
54+
uint8_t inverted;
55+
};
56+
4757
struct serial_s {
4858
UARTName uart;
4959
int index; // Used by irq
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
#if DEVICE_PWMOUT
35+
36+
const pwm_apb_map_t pwm_apb_map_table[] = {
37+
#if defined(TIM2_BASE)
38+
{PWM_2, PWMOUT_ON_APB1},
39+
#endif
40+
#if defined(TIM3_BASE)
41+
{PWM_3, PWMOUT_ON_APB1},
42+
#endif
43+
#if defined(TIM4_BASE)
44+
{PWM_4, PWMOUT_ON_APB1},
45+
#endif
46+
#if defined(TIM1_BASE)
47+
{PWM_1, PWMOUT_ON_APB2},
48+
#endif
49+
#if defined(TIM8_BASE)
50+
{PWM_8, PWMOUT_ON_APB2},
51+
#endif
52+
#if defined(TIM15_BASE)
53+
{PWM_15, PWMOUT_ON_APB2},
54+
#endif
55+
#if defined(TIM16_BASE)
56+
{PWM_16, PWMOUT_ON_APB2},
57+
#endif
58+
#if defined(TIM17_BASE)
59+
{PWM_17, PWMOUT_ON_APB2},
60+
#endif
61+
#if defined(TIM20_BASE)
62+
{PWM_20, PWMOUT_ON_APB2},
63+
#endif
64+
{(PWMName) 0, PWMOUT_UNKNOWN}
65+
};
66+
67+
#endif // DEVICE_PWMOUT
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
#ifndef MBED_PWMOUT_DEVICE_H
31+
#define MBED_PWMOUT_DEVICE_H
32+
33+
#include "cmsis.h"
34+
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif
38+
39+
#if DEVICE_PWMOUT
40+
41+
typedef enum {
42+
PWMOUT_ON_APB1 = 0,
43+
PWMOUT_ON_APB2 = 1,
44+
PWMOUT_UNKNOWN = 2
45+
} PwmoutApb;
46+
47+
/* Structure to describe Timers to APB */
48+
typedef struct pwm_apb_map {
49+
PWMName pwm; // an index entry for each EXIT line
50+
PwmoutApb pwmoutApb;
51+
} pwm_apb_map_t;
52+
53+
extern const pwm_apb_map_t pwm_apb_map_table[];
54+
55+
#endif // DEVICE_PWMOUT
56+
57+
#ifdef __cplusplus
58+
}
59+
#endif
60+
61+
#endif

targets/targets.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15051,7 +15051,6 @@
1505115051
"MPU"
1505215052
],
1505315053
"device_has_remove": [
15054-
"PWMOUT",
1505515054
"SPI",
1505615055
"SPISLAVE",
1505715056
"SPI_ASYNCH"

0 commit comments

Comments
 (0)