cleanup and little endian status format

This commit is contained in:
Olaf Rempel 2008-06-22 21:21:23 +02:00
parent a41be6d7ca
commit 19c4f112a9
2 changed files with 12 additions and 13 deletions

13
blmc.c
View File

@ -183,19 +183,18 @@ void setpwm(uint8_t pwm)
if (blmc.flags & FLAG_PWM_SPINUP) if (blmc.flags & FLAG_PWM_SPINUP)
pwm = params.spinup_pwm; pwm = params.spinup_pwm;
/* raise current-limit */ /* raise current-limit, set flag */
if (blmc.current > params.current_limit) if (blmc.current > params.current_limit) {
blmc.flags |= FLAG_CURRENT_LIMIT;
blmc.pwm_limit++; blmc.pwm_limit++;
/* lower current-limit */ /* lower current-limit */
else if (blmc.pwm_limit > 0) } else if (blmc.pwm_limit > 0) {
blmc.pwm_limit--; blmc.pwm_limit--;
/* set current-limit flag */ } else if (blmc.pwm_limit == 0) {
if (blmc.pwm_limit)
blmc.flags |= FLAG_CURRENT_LIMIT;
else
blmc.flags &= ~FLAG_CURRENT_LIMIT; blmc.flags &= ~FLAG_CURRENT_LIMIT;
}
/* prevent overflow */ /* prevent overflow */
if (blmc.pwm_limit > pwm) if (blmc.pwm_limit > pwm)

View File

@ -109,22 +109,22 @@ ISR(TWI_vect)
case 1: TWDR = blmc.pwm; case 1: TWDR = blmc.pwm;
break; break;
case 2: TWDR = (blmc.rpm >> 8); case 2: TWDR = (blmc.rpm & 0xFF);
break; break;
case 3: TWDR = (blmc.rpm & 0xFF); case 3: TWDR = (blmc.rpm >> 8);
break; break;
case 4: TWDR = (blmc.current >> 8); case 4: TWDR = (blmc.current & 0xFF);
break; break;
case 5: TWDR = (blmc.current & 0xFF); case 5: TWDR = (blmc.current >> 8);
break; break;
case 6: TWDR = (blmc.voltage >> 8); case 6: TWDR = (blmc.voltage & 0xFF);
break; break;
case 7: TWDR = (blmc.voltage & 0xFF); case 7: TWDR = (blmc.voltage >> 8);
bcnt = 0; bcnt = 0;
break; break;