Skip to content

Commit be492fe

Browse files
committed
Add HAL API for pwmout pinmap
Add the function pwm_pinmap to all targets.
1 parent 22a8977 commit be492fe

File tree

59 files changed

+300
-0
lines changed

Some content is hidden

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

59 files changed

+300
-0
lines changed

hal/pwmout_api.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define MBED_PWMOUT_API_H
2222

2323
#include "device.h"
24+
#include "pinmap.h"
2425

2526
#if DEVICE_PWMOUT
2627

@@ -108,6 +109,15 @@ void pwmout_pulsewidth_ms(pwmout_t *obj, int ms);
108109
*/
109110
void pwmout_pulsewidth_us(pwmout_t *obj, int us);
110111

112+
/** Get the pins that support PWM
113+
*
114+
* Return a PinMap array of pins that support PWM.
115+
* The array is terminated with {NC, NC, 0}.
116+
*
117+
* @return PinMap array
118+
*/
119+
const PinMap *pwmout_pinmap(void);
120+
111121
/**@}*/
112122

113123
#ifdef __cplusplus

targets/TARGET_Atmel/TARGET_SAM_CortexM0P/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
300300
/* This call updates pulse width as well as period */
301301
pwmout_write(obj, duty_cycle);
302302
}
303+
304+
const PinMap *pwmout_pinmap()
305+
{
306+
return PinMap_PWM;
307+
}

targets/TARGET_Atmel/TARGET_SAM_CortexM4/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
305305
float new_duty = (us / 1000000.0) * (float)obj->waveconfig.us_frequency;
306306
pwmout_write(obj, new_duty);
307307
}
308+
309+
const PinMap *pwmout_pinmap()
310+
{
311+
return PinMap_PWM;
312+
}

targets/TARGET_Cypress/TARGET_PSOC6/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
339339
}
340340
pwm_start(obj, obj->period, us);
341341
}
342+
343+
const PinMap *pwmout_pinmap()
344+
{
345+
return PinMap_PWM_OUT;
346+
}

targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
319319
}
320320
pwm_start(obj, obj->period, us);
321321
}
322+
323+
const PinMap *pwmout_pinmap()
324+
{
325+
return PinMap_PWM_OUT;
326+
}

targets/TARGET_Freescale/TARGET_K20XX/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
117117
*obj->CnV = (uint32_t)(pwm_clock * (float)us);
118118
*obj->SYNC |= FTM_SYNC_SWSYNC_MASK;
119119
}
120+
121+
const PinMap *pwmout_pinmap()
122+
{
123+
return PinMap_PWM;
124+
}

targets/TARGET_Freescale/TARGET_KLXX/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,8 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) {
123123
void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
124124
*obj->CnV = (uint32_t)(pwm_clock * (float)us);
125125
}
126+
127+
const PinMap *pwmout_pinmap()
128+
{
129+
return PinMap_PWM;
130+
}

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
150150
FTM_SetSoftwareTrigger(base, true);
151151
}
152152

153+
const PinMap *pwmout_pinmap()
154+
{
155+
return PinMap_PWM;
156+
}
157+
153158
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
150150
FTM_SetSoftwareTrigger(base, true);
151151
}
152152

153+
const PinMap *pwmout_pinmap()
154+
{
155+
return PinMap_PWM;
156+
}
157+
153158
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
145145
base->CONTROLS[obj->pwm_name & 0xF].CnV = value;
146146
}
147147

148+
const PinMap *pwmout_pinmap()
149+
{
150+
return PinMap_PWM;
151+
}
152+
148153
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
145145
base->CONTROLS[obj->pwm_name & 0xF].CnV = value;
146146
}
147147

148+
const PinMap *pwmout_pinmap()
149+
{
150+
return PinMap_PWM;
151+
}
152+
148153
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
146146
base->CONTROLS[obj->pwm_name & 0xF].CnV = value;
147147
}
148148

149+
const PinMap *pwmout_pinmap()
150+
{
151+
return PinMap_PWM;
152+
}
153+
149154
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
150150
FTM_SetSoftwareTrigger(base, true);
151151
}
152152

153+
const PinMap *pwmout_pinmap()
154+
{
155+
return PinMap_PWM;
156+
}
157+
153158
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
145145
base->CONTROLS[obj->pwm_name & 0xF].CnV = value;
146146
}
147147

148+
const PinMap *pwmout_pinmap()
149+
{
150+
return PinMap_PWM;
151+
}
152+
148153
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K22F/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
150150
FTM_SetSoftwareTrigger(base, true);
151151
}
152152

153+
const PinMap *pwmout_pinmap()
154+
{
155+
return PinMap_PWM;
156+
}
157+
153158
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K24F/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
150150
FTM_SetSoftwareTrigger(base, true);
151151
}
152152

153+
const PinMap *pwmout_pinmap()
154+
{
155+
return PinMap_PWM;
156+
}
157+
153158
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
167167
FTM_SetSoftwareTrigger(base, true);
168168
}
169169

170+
const PinMap *pwmout_pinmap()
171+
{
172+
return PinMap_PWM;
173+
}
174+
170175
#endif

targets/TARGET_GigaDevice/TARGET_GD32E10X/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,8 @@ static uint32_t timer_get_clock(uint32_t timer_periph)
297297

298298
return timerclk;
299299
}
300+
301+
const PinMap *pwmout_pinmap()
302+
{
303+
return PinMap_PWM;
304+
}

targets/TARGET_GigaDevice/TARGET_GD32F30X/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,8 @@ static uint32_t timer_get_clock(uint32_t timer_periph)
297297

298298
return timerclk;
299299
}
300+
301+
const PinMap *pwmout_pinmap()
302+
{
303+
return PinMap_PWM;
304+
}

targets/TARGET_GigaDevice/TARGET_GD32F4XX/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,8 @@ static void dev_pwmout_init(pwmout_t *obj)
344344

345345
timer_primary_output_config(obj->pwm, ENABLE);
346346
}
347+
348+
const PinMap *pwmout_pinmap()
349+
{
350+
return PinMap_PWM;
351+
}

targets/TARGET_Maxim/TARGET_MAX32600/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
211211
// Update the register
212212
pwmout_update(obj);
213213
}
214+
215+
const PinMap *pwmout_pinmap()
216+
{
217+
return PinMap_PWM;
218+
}

targets/TARGET_Maxim/TARGET_MAX32610/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
211211
// Update the register
212212
pwmout_update(obj);
213213
}
214+
215+
const PinMap *pwmout_pinmap()
216+
{
217+
return PinMap_PWM;
218+
}

targets/TARGET_Maxim/TARGET_MAX32620/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
209209
// Update the register
210210
pwmout_update(obj);
211211
}
212+
213+
const PinMap *pwmout_pinmap()
214+
{
215+
return PinMap_PWM;
216+
}

targets/TARGET_Maxim/TARGET_MAX32620C/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
219219
pwmout_update(obj);
220220
}
221221

222+
const PinMap *pwmout_pinmap()
223+
{
224+
return PinMap_PWM;
225+
}
226+

targets/TARGET_Maxim/TARGET_MAX32625/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
219219
pwmout_update(obj);
220220
}
221221

222+
const PinMap *pwmout_pinmap()
223+
{
224+
return PinMap_PWM;
225+
}
226+

targets/TARGET_Maxim/TARGET_MAX32630/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
219219
pwmout_update(obj);
220220
}
221221

222+
const PinMap *pwmout_pinmap()
223+
{
224+
return PinMap_PWM;
225+
}
226+

targets/TARGET_NORDIC/TARGET_MCU_NRF51822/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
378378
NRF_TIMER2->SHORTS = TIMER_SHORTS_COMPARE3_CLEAR_Msk | TIMER_SHORTS_COMPARE3_STOP_Msk;
379379
NRF_TIMER2->TASKS_START = 1;
380380
}
381+
382+
const PinMap *pwmout_pinmap()
383+
{
384+
return PinMap_PWM;
385+
}

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,9 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
256256
pwm_ticks_set(pwm, obj->pwm_channel, ticks);
257257
}
258258

259+
const PinMap *pwmout_pinmap()
260+
{
261+
return PinMap_PWM;
262+
}
263+
259264
#endif // DEVICE_PWMOUT

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,9 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int pulse)
348348
nordic_pwm_restart(obj);
349349
}
350350

351+
const PinMap *pwmout_pinmap()
352+
{
353+
return PinMap_PWM;
354+
}
355+
351356
#endif // DEVICE_PWMOUT

targets/TARGET_NUVOTON/TARGET_M2351/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,9 @@ static void pwmout_config(pwmout_t* obj, int start)
205205
}
206206
}
207207

208+
const PinMap *pwmout_pinmap()
209+
{
210+
return PinMap_PWM;
211+
}
212+
208213
#endif

targets/TARGET_NUVOTON/TARGET_M451/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,9 @@ static void pwmout_config(pwmout_t* obj)
181181
PWM_ConfigOutputChannel2(pwm_base, chn, 1000 * 1000, obj->pulsewidth_us * 100 / obj->period_us, obj->period_us);
182182
}
183183

184+
const PinMap *pwmout_pinmap()
185+
{
186+
return PinMap_PWM;
187+
}
188+
184189
#endif

targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,9 @@ static void pwmout_config(pwmout_t* obj, int start)
191191
}
192192
}
193193

194+
const PinMap *pwmout_pinmap()
195+
{
196+
return PinMap_PWM;
197+
}
198+
194199
#endif

targets/TARGET_NUVOTON/TARGET_NANO100/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,9 @@ static void pwmout_config(pwmout_t* obj)
188188
PWM_ConfigOutputChannel2(pwm_base, chn, 1000 * 1000, 100 - (obj->pulsewidth_us * 100 / obj->period_us), obj->period_us);
189189
}
190190

191+
const PinMap *pwmout_pinmap()
192+
{
193+
return PinMap_PWM;
194+
}
195+
191196
#endif

targets/TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,9 @@ static void pwmout_config(pwmout_t* obj)
204204
PWM_ConfigOutputChannel2(pwm_base, chn, 1000 * 1000, obj->pulsewidth_us * 100 / obj->period_us, obj->period_us);
205205
}
206206

207+
const PinMap *pwmout_pinmap()
208+
{
209+
return PinMap_PWM;
210+
}
211+
207212
#endif

targets/TARGET_NXP/TARGET_LPC11U6X/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,9 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
219219
}
220220
}
221221

222+
const PinMap *pwmout_pinmap()
223+
{
224+
return PinMap_PWM;
225+
}
226+
222227
#endif

targets/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
155155
timer->MR[tid.mr] = t_off;
156156
timer->TCR = TCR_CNT_EN;
157157
}
158+
159+
const PinMap *pwmout_pinmap()
160+
{
161+
return PinMap_PWM;
162+
}

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
186186
timer->MR[tid.mr] = t_off;
187187
timer->TCR = TCR_CNT_EN;
188188
}
189+
190+
const PinMap *pwmout_pinmap()
191+
{
192+
return PinMap_PWM;
193+
}

targets/TARGET_NXP/TARGET_LPC13XX/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
191191
timer->MR[tid.mr] = t_off;
192192
timer->TCR = TCR_CNT_EN;
193193
}
194+
195+
const PinMap *pwmout_pinmap()
196+
{
197+
return PinMap_PWM;
198+
}

targets/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
203203
}
204204
}
205205

206+
const PinMap *pwmout_pinmap()
207+
{
208+
return PinMap_PWM;
209+
}
210+

targets/TARGET_NXP/TARGET_LPC176X/pwmout_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,8 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
169169
// set the channel latch to update value at next period start
170170
LPC_PWM1->LER |= 1 << obj->pwm;
171171
}
172+
173+
const PinMap *pwmout_pinmap()
174+
{
175+
return PinMap_PWM;
176+
}

0 commit comments

Comments
 (0)