Skip to content

Commit b03d80f

Browse files
committed
pwmout - fixed compile errors
1 parent 6625bdb commit b03d80f

File tree

20 files changed

+49
-18
lines changed

20 files changed

+49
-18
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/pwmout_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ int pwmout_read_period_us(pwmout_t *obj)
134134
{
135135
uint32_t tmp = 0;
136136
if (pwm_clock_mhz > 0) {
137+
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
137138
tmp = ((base->MOD) + 1) / pwm_clock_mhz;
138139
}
139140
return tmp;
@@ -164,6 +165,7 @@ int pwmout_read_pulsewidth_us(pwmout_t *obj)
164165
{
165166
uint32_t tmp = 0;
166167
if (pwm_clock_mhz > 0) {
168+
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
167169
tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz;
168170
}
169171
return tmp;

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/pwmout_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ int pwmout_read_period_us(pwmout_t *obj)
134134
{
135135
uint32_t tmp = 0;
136136
if (pwm_clock_mhz > 0) {
137+
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
137138
tmp = ((base->MOD) + 1) / pwm_clock_mhz;
138139
}
139140
return tmp;
@@ -164,6 +165,7 @@ int pwmout_read_pulsewidth_us(pwmout_t *obj)
164165
{
165166
uint32_t tmp = 0;
166167
if (pwm_clock_mhz > 0) {
168+
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
167169
tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz;
168170
}
169171
return tmp;

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/pwmout_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ int pwmout_read_period_us(pwmout_t *obj)
131131
{
132132
uint32_t tmp = 0;
133133
if (pwm_clock_mhz > 0) {
134+
TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT];
134135
tmp = ((base->MOD) + 1) / pwm_clock_mhz;
135136
}
136137
return tmp;
@@ -159,6 +160,7 @@ int pwmout_read_pulsewidth_us(pwmout_t *obj)
159160
{
160161
uint32_t tmp = 0;
161162
if (pwm_clock_mhz > 0) {
163+
TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT];
162164
tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz;
163165
}
164166
return tmp;

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/pwmout_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ int pwmout_read_period_us(pwmout_t *obj)
131131
{
132132
uint32_t tmp = 0;
133133
if (pwm_clock_mhz > 0) {
134+
TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT];
134135
tmp = ((base->MOD) + 1) / pwm_clock_mhz;
135136
}
136137
return tmp;
@@ -159,6 +160,7 @@ int pwmout_read_pulsewidth_us(pwmout_t *obj)
159160
{
160161
uint32_t tmp = 0;
161162
if (pwm_clock_mhz > 0) {
163+
TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT];
162164
tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz;
163165
}
164166
return tmp;

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/pwmout_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ int pwmout_read_period_us(pwmout_t *obj)
131131
{
132132
uint32_t tmp = 0;
133133
if (pwm_clock_mhz > 0) {
134+
TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT];
134135
tmp = ((base->MOD) + 1) / pwm_clock_mhz;
135136
}
136137
return tmp;
@@ -159,6 +160,7 @@ int pwmout_read_pulsewidth_us(pwmout_t *obj)
159160
{
160161
uint32_t tmp = 0;
161162
if (pwm_clock_mhz > 0) {
163+
TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT];
162164
tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz;
163165
}
164166
return tmp;

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K22F/pwmout_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ int pwmout_read_period_us(pwmout_t *obj)
134134
{
135135
uint32_t tmp = 0;
136136
if (pwm_clock_mhz > 0) {
137+
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];;
137138
tmp = ((base->MOD) + 1) / pwm_clock_mhz;
138139
}
139140
return tmp;
@@ -164,6 +165,7 @@ int pwmout_read_pulsewidth_us(pwmout_t *obj)
164165
{
165166
uint32_t tmp = 0;
166167
if (pwm_clock_mhz > 0) {
168+
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
167169
tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz;
168170
}
169171
return tmp;

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/pwmout_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ int pwmout_read_period_us(pwmout_t *obj)
162162
{
163163
uint32_t tmp = 0;
164164
if (pwm_clock_mhz > 0) {
165+
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
165166
uint16_t mod = base->MOD & FTM_MOD_MOD_MASK;
166167
tmp = ((mod) + 1) / pwm_clock_mhz;
167168
}
@@ -193,6 +194,7 @@ int pwmout_read_pulsewidth_us(pwmout_t *obj)
193194
{
194195
uint32_t tmp = 0;
195196
if (pwm_clock_mhz > 0) {
197+
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
196198
tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz;
197199
}
198200
return tmp;

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/pwmout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int pulse)
353353
nordic_pwm_restart(obj);
354354
}
355355

356-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
356+
int pwmout_read_pulsewidth_us(pwmout_t *obj) {
357357
return (obj->period) * (obj->percent);
358358
}
359359

targets/TARGET_NUVOTON/TARGET_M2351/pwmout_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
194194
pwmout_config(obj, 1);
195195
}
196196

197-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
197+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
198+
{
198199
return obj->pulsewidth_us;
199200
}
200201

targets/TARGET_NUVOTON/TARGET_M251/pwmout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
180180
pwmout_config(obj, 1);
181181
}
182182

183-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
183+
int pwmout_read_pulsewidth_us(pwmout_t *obj) {
184184
return obj->pulsewidth_us;
185185
}
186186

targets/TARGET_NUVOTON/TARGET_M261/pwmout_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
179179
pwmout_config(obj, 1);
180180
}
181181

182-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
182+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
183+
{
183184
return obj->pulsewidth_us;
184185
}
185186

targets/TARGET_NUVOTON/TARGET_M451/pwmout_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
184184
pwmout_config(obj);
185185
}
186186

187-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
187+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
188+
{
188189
return obj->pulsewidth_us;
189190
}
190191

targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
182182
pwmout_config(obj, 1);
183183
}
184184

185-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
185+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
186+
{
186187
return obj->pulsewidth_us;
187188
}
188189

targets/TARGET_NUVOTON/TARGET_NANO100/pwmout_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
187187
pwmout_config(obj);
188188
}
189189

190-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
190+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
191+
{
191192
return obj->pulsewidth_us;
192193
}
193194

targets/TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
208208
pwmout_config(obj);
209209
}
210210

211-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
211+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
212+
{
212213
return obj->pulsewidth_us;
213214
}
214215

targets/TARGET_NXP/TARGET_LPC11U6X/pwmout_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
236236
}
237237
}
238238

239-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
239+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
240+
{
240241
return (!(pwm->CTRL & (1 << 2))) ? pwm->MATCHREL1 + 1 : 0;
241242
}
242243

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/pwmout_api.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ void pwmout_period_us(pwmout_t *obj, int us)
174174

175175
int pwmout_read_period_us(pwmout_t *obj)
176176
{
177+
timer_mr tid = pwm_timer_map[obj->pwm];
178+
LPC_TMR_TypeDef *timer = Timers[tid.timer];
177179
return (timer->MR3);
178180
}
179181

@@ -202,7 +204,10 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
202204
timer->TCR = TCR_CNT_EN;
203205
}
204206

205-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
207+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
208+
{
209+
timer_mr tid = pwm_timer_map[obj->pwm];
210+
LPC_TMR_TypeDef *timer = Timers[tid.timer];
206211
return (timer->MR3 - timer->MR[tid.mr]);
207212
}
208213

targets/TARGET_NXP/TARGET_LPC176X/pwmout_api.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void pwmout_period_us(pwmout_t *obj, int us)
155155

156156
int pwmout_read_period_us(pwmout_t *obj)
157157
{
158-
return (float)(LPC_PWM1->MR0);
158+
return (LPC_PWM1->MR0);
159159
}
160160

161161
void pwmout_pulsewidth(pwmout_t *obj, float seconds)
@@ -185,8 +185,9 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
185185
LPC_PWM1->LER |= 1 << obj->pwm;
186186
}
187187

188-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
189-
return (timer->MR3 - timer->MR[tid.mr]);
188+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
189+
{
190+
return (*obj->MR);
190191
}
191192

192193
const PinMap *pwmout_pinmap()

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_IMX/pwmout_api.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ void pwmout_period_us(pwmout_t *obj, int us)
196196

197197
int pwmout_read_period_us(pwmout_t *obj)
198198
{
199+
PWM_Type *base = pwm_addrs[(obj->pwm_name >> PWM_SHIFT) & 0x7];
200+
uint32_t module = (obj->pwm_name >> PWM_MODULE_SHIFT) & 0x3;
199201
return (base->SM[module].VAL1) & PWM_VAL1_VAL1_MASK;
200202
}
201203

@@ -228,9 +230,11 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
228230
PWM_SetPwmLdok(base, (1 << module), true);
229231
}
230232

231-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
233+
int pwmout_read_pulsewidth_us(pwmout_t *obj) {
232234
uint16_t count;
233-
235+
PWM_Type *base = pwm_addrs[(obj->pwm_name >> PWM_SHIFT) & 0x7];
236+
uint32_t module = (obj->pwm_name >> PWM_MODULE_SHIFT) & 0x3;
237+
uint32_t pwmchannel = obj->pwm_name & 0x1;
234238
if (pwmchannel == 0)
235239
{
236240
count = (base->SM[module].VAL3) & PWM_VAL3_VAL3_MASK;

targets/TARGET_RENESAS/TARGET_RZ_A1XX/pwmout_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,11 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us)
567567
pwmout_write(obj, value);
568568
}
569569

570-
int pwmout_read_pulsewidth_us(pwmout_t *obj {
570+
int pwmout_read_pulsewidth_us(pwmout_t *obj)
571+
{
571572
uint32_t wk_pulse = 0;
572573

573-
if (obj->pwm >= MTU2_PWM_OFFSET)
574-
{
574+
if (obj->pwm >= MTU2_PWM_OFFSET) {
575575
#ifdef FUMC_MTU2_PWM
576576
/* PWM by MTU2 */
577577

0 commit comments

Comments
 (0)