use descriptive variable names

pull/13492/head
talorion 2020-09-08 10:54:09 +02:00
parent b03d80fd08
commit e117ef5c3c
10 changed files with 56 additions and 56 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()