From e117ef5c3c14609876e619cdbb8edc8f94e62df6 Mon Sep 17 00:00:00 2001 From: talorion Date: Tue, 8 Sep 2020 10:54:09 +0200 Subject: [PATCH] use descriptive variable names --- targets/TARGET_Freescale/TARGET_K20XX/pwmout_api.c | 12 ++++++------ targets/TARGET_Freescale/TARGET_KLXX/pwmout_api.c | 12 ++++++------ .../TARGET_MCUXpresso_MCUS/TARGET_K66F/pwmout_api.c | 12 ++++++------ .../TARGET_MCUXpresso_MCUS/TARGET_K82F/pwmout_api.c | 12 ++++++------ .../TARGET_MCUXpresso_MCUS/TARGET_KL27Z/pwmout_api.c | 12 ++++++------ .../TARGET_MCUXpresso_MCUS/TARGET_KL43Z/pwmout_api.c | 12 ++++++------ .../TARGET_MCUXpresso_MCUS/TARGET_KW41Z/pwmout_api.c | 12 ++++++------ .../TARGET_MCU_K22F/pwmout_api.c | 12 ++++++------ .../TARGET_MCU_K64F/pwmout_api.c | 12 ++++++------ targets/TARGET_STM/pwmout_api.c | 4 ++-- 10 files changed, 56 insertions(+), 56 deletions(-) diff --git a/targets/TARGET_Freescale/TARGET_K20XX/pwmout_api.c b/targets/TARGET_Freescale/TARGET_K20XX/pwmout_api.c index 121518df8a..3c7e25d712 100644 --- a/targets/TARGET_Freescale/TARGET_K20XX/pwmout_api.c +++ b/targets/TARGET_Freescale/TARGET_K20XX/pwmout_api.c @@ -114,11 +114,11 @@ void pwmout_period_us(pwmout_t *obj, int us) int pwmout_read_period_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_period = 0; if (pwm_clock > 0) { - tmp = ((*obj->MOD) + 1) / pwm_clock; + pwm_period = ((*obj->MOD) + 1) / pwm_clock; } - return tmp; + return pwm_period; } void pwmout_pulsewidth(pwmout_t *obj, float seconds) @@ -139,11 +139,11 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us) int pwmout_read_pulsewidth_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_pulsewidth = 0; if (pwm_clock > 0) { - tmp = (*obj->CnV) / pwm_clock; + pwm_pulsewidth = (*obj->CnV) / pwm_clock; } - return tmp; + return pwm_pulsewidth; } const PinMap *pwmout_pinmap() diff --git a/targets/TARGET_Freescale/TARGET_KLXX/pwmout_api.c b/targets/TARGET_Freescale/TARGET_KLXX/pwmout_api.c index 821ff483a4..35bb782cce 100644 --- a/targets/TARGET_Freescale/TARGET_KLXX/pwmout_api.c +++ b/targets/TARGET_Freescale/TARGET_KLXX/pwmout_api.c @@ -121,11 +121,11 @@ void pwmout_period_us(pwmout_t *obj, int us) int pwmout_read_period_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_period = 0; if (pwm_clock > 0) { - tmp = ((*obj->MOD) + 1) / pwm_clock; + pwm_period = ((*obj->MOD) + 1) / pwm_clock; } - return tmp; + return pwm_period; } void pwmout_pulsewidth(pwmout_t *obj, float seconds) @@ -145,11 +145,11 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us) int pwmout_read_pulsewidth_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_pulsewidth = 0; if (pwm_clock > 0) { - tmp = (*obj->CnV) / pwm_clock; + pwm_pulsewidth = (*obj->CnV) / pwm_clock; } - return tmp; + return pwm_pulsewidth; } const PinMap *pwmout_pinmap() diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/pwmout_api.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/pwmout_api.c index 3047605125..346b2d4900 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/pwmout_api.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/pwmout_api.c @@ -132,12 +132,12 @@ void pwmout_period_us(pwmout_t *obj, int us) int pwmout_read_period_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_period = 0; if (pwm_clock_mhz > 0) { FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = ((base->MOD) + 1) / pwm_clock_mhz; + pwm_period = ((base->MOD) + 1) / pwm_clock_mhz; } - return tmp; + return pwm_period; } void pwmout_pulsewidth(pwmout_t *obj, float seconds) @@ -163,12 +163,12 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us) int pwmout_read_pulsewidth_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_pulsewidth = 0; if (pwm_clock_mhz > 0) { FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; + pwm_pulsewidth = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; } - return tmp; + return pwm_pulsewidth; } const PinMap *pwmout_pinmap() diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/pwmout_api.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/pwmout_api.c index 3047605125..346b2d4900 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/pwmout_api.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/pwmout_api.c @@ -132,12 +132,12 @@ void pwmout_period_us(pwmout_t *obj, int us) int pwmout_read_period_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_period = 0; if (pwm_clock_mhz > 0) { FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = ((base->MOD) + 1) / pwm_clock_mhz; + pwm_period = ((base->MOD) + 1) / pwm_clock_mhz; } - return tmp; + return pwm_period; } void pwmout_pulsewidth(pwmout_t *obj, float seconds) @@ -163,12 +163,12 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us) int pwmout_read_pulsewidth_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_pulsewidth = 0; if (pwm_clock_mhz > 0) { FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; + pwm_pulsewidth = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; } - return tmp; + return pwm_pulsewidth; } const PinMap *pwmout_pinmap() diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/pwmout_api.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/pwmout_api.c index 687fd8962e..87b9c6d972 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/pwmout_api.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/pwmout_api.c @@ -129,12 +129,12 @@ void pwmout_period_us(pwmout_t *obj, int us) int pwmout_read_period_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_period = 0; if (pwm_clock_mhz > 0) { TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = ((base->MOD) + 1) / pwm_clock_mhz; + pwm_period = ((base->MOD) + 1) / pwm_clock_mhz; } - return tmp; + return pwm_period; } void pwmout_pulsewidth(pwmout_t *obj, float seconds) @@ -158,12 +158,12 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us) int pwmout_read_pulsewidth_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_pulsewidth = 0; if (pwm_clock_mhz > 0) { TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; + pwm_pulsewidth = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; } - return tmp; + return pwm_pulsewidth; } const PinMap *pwmout_pinmap() diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/pwmout_api.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/pwmout_api.c index 687fd8962e..87b9c6d972 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/pwmout_api.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/pwmout_api.c @@ -129,12 +129,12 @@ void pwmout_period_us(pwmout_t *obj, int us) int pwmout_read_period_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_period = 0; if (pwm_clock_mhz > 0) { TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = ((base->MOD) + 1) / pwm_clock_mhz; + pwm_period = ((base->MOD) + 1) / pwm_clock_mhz; } - return tmp; + return pwm_period; } void pwmout_pulsewidth(pwmout_t *obj, float seconds) @@ -158,12 +158,12 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us) int pwmout_read_pulsewidth_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_pulsewidth = 0; if (pwm_clock_mhz > 0) { TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; + pwm_pulsewidth = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; } - return tmp; + return pwm_pulsewidth; } const PinMap *pwmout_pinmap() diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/pwmout_api.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/pwmout_api.c index 41f82a7458..31b953c041 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/pwmout_api.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/pwmout_api.c @@ -129,12 +129,12 @@ void pwmout_period_us(pwmout_t *obj, int us) int pwmout_read_period_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_period = 0; if (pwm_clock_mhz > 0) { TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = ((base->MOD) + 1) / pwm_clock_mhz; + pwm_period = ((base->MOD) + 1) / pwm_clock_mhz; } - return tmp; + return pwm_period; } void pwmout_pulsewidth(pwmout_t *obj, float seconds) @@ -158,12 +158,12 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us) int pwmout_read_pulsewidth_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_pulsewidth = 0; if (pwm_clock_mhz > 0) { TPM_Type *base = tpm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; + pwm_pulsewidth = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; } - return tmp; + return pwm_pulsewidth; } const PinMap *pwmout_pinmap() diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K22F/pwmout_api.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K22F/pwmout_api.c index ec7a046b34..6efe704b14 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K22F/pwmout_api.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K22F/pwmout_api.c @@ -132,12 +132,12 @@ void pwmout_period_us(pwmout_t *obj, int us) int pwmout_read_period_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_period = 0; if (pwm_clock_mhz > 0) { FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];; - tmp = ((base->MOD) + 1) / pwm_clock_mhz; + pwm_period = ((base->MOD) + 1) / pwm_clock_mhz; } - return tmp; + return pwm_period; } void pwmout_pulsewidth(pwmout_t *obj, float seconds) @@ -163,12 +163,12 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us) int pwmout_read_pulsewidth_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_pulsewidth = 0; if (pwm_clock_mhz > 0) { FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; + pwm_pulsewidth = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; } - return tmp; + return pwm_pulsewidth; } const PinMap *pwmout_pinmap() diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/pwmout_api.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/pwmout_api.c index bff513e4cd..805020c862 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/pwmout_api.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/pwmout_api.c @@ -160,13 +160,13 @@ void pwmout_period_us(pwmout_t *obj, int us) int pwmout_read_period_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_period = 0; if (pwm_clock_mhz > 0) { FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT]; uint16_t mod = base->MOD & FTM_MOD_MOD_MASK; - tmp = ((mod) + 1) / pwm_clock_mhz; + pwm_period = ((mod) + 1) / pwm_clock_mhz; } - return tmp; + return pwm_period; } void pwmout_pulsewidth(pwmout_t *obj, float seconds) @@ -192,12 +192,12 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us) int pwmout_read_pulsewidth_us(pwmout_t *obj) { - uint32_t tmp = 0; + uint32_t pwm_pulsewidth = 0; if (pwm_clock_mhz > 0) { FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT]; - tmp = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; + pwm_pulsewidth = (base->CONTROLS[obj->pwm_name & 0xF].CnV) / pwm_clock_mhz; } - return tmp; + return pwm_pulsewidth; } const PinMap *pwmout_pinmap() diff --git a/targets/TARGET_STM/pwmout_api.c b/targets/TARGET_STM/pwmout_api.c index fcf846143f..27f140a530 100644 --- a/targets/TARGET_STM/pwmout_api.c +++ b/targets/TARGET_STM/pwmout_api.c @@ -409,8 +409,8 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int us) int pwmout_read_pulsewidth_us(pwmout_t *obj) { - float tmp = pwmout_read(obj); - return (int)(tmp * (float)obj->period); + float pwm_duty_cycle = pwmout_read(obj); + return (int)(pwm_duty_cycle * (float)obj->period); } const PinMap *pwmout_pinmap()