Browse Source

cleanup and little endian status format

remotes/origin/master
Olaf Rempel 12 years ago
parent
commit
19c4f112a9
2 changed files with 12 additions and 13 deletions
  1. +6
    -7
      blmc.c
  2. +6
    -6
      i2c-slave.c

+ 6
- 7
blmc.c View File

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


+ 6
- 6
i2c-slave.c View File

@@ -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…
Cancel
Save