cleanup and little endian status format
This commit is contained in:
parent
a41be6d7ca
commit
19c4f112a9
13
blmc.c
13
blmc.c
@ -183,19 +183,18 @@ void setpwm(uint8_t pwm)
|
||||
if (blmc.flags & FLAG_PWM_SPINUP)
|
||||
pwm = params.spinup_pwm;
|
||||
|
||||
/* raise current-limit */
|
||||
if (blmc.current > params.current_limit)
|
||||
/* raise current-limit, set flag */
|
||||
if (blmc.current > params.current_limit) {
|
||||
blmc.flags |= FLAG_CURRENT_LIMIT;
|
||||
blmc.pwm_limit++;
|
||||
|
||||
/* lower current-limit */
|
||||
else if (blmc.pwm_limit > 0)
|
||||
} else if (blmc.pwm_limit > 0) {
|
||||
blmc.pwm_limit--;
|
||||
|
||||
/* set current-limit flag */
|
||||
if (blmc.pwm_limit)
|
||||
blmc.flags |= FLAG_CURRENT_LIMIT;
|
||||
else
|
||||
} else if (blmc.pwm_limit == 0) {
|
||||
blmc.flags &= ~FLAG_CURRENT_LIMIT;
|
||||
}
|
||||
|
||||
/* prevent overflow */
|
||||
if (blmc.pwm_limit > pwm)
|
||||
|
12
i2c-slave.c
12
i2c-slave.c
@ -109,22 +109,22 @@ ISR(TWI_vect)
|
||||
case 1: TWDR = blmc.pwm;
|
||||
break;
|
||||
|
||||
case 2: TWDR = (blmc.rpm >> 8);
|
||||
case 2: TWDR = (blmc.rpm & 0xFF);
|
||||
break;
|
||||
|
||||
case 3: TWDR = (blmc.rpm & 0xFF);
|
||||
case 3: TWDR = (blmc.rpm >> 8);
|
||||
break;
|
||||
|
||||
case 4: TWDR = (blmc.current >> 8);
|
||||
case 4: TWDR = (blmc.current & 0xFF);
|
||||
break;
|
||||
|
||||
case 5: TWDR = (blmc.current & 0xFF);
|
||||
case 5: TWDR = (blmc.current >> 8);
|
||||
break;
|
||||
|
||||
case 6: TWDR = (blmc.voltage >> 8);
|
||||
case 6: TWDR = (blmc.voltage & 0xFF);
|
||||
break;
|
||||
|
||||
case 7: TWDR = (blmc.voltage & 0xFF);
|
||||
case 7: TWDR = (blmc.voltage >> 8);
|
||||
bcnt = 0;
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user