Fix bug with premature step end. Refactored _delay_ms() and square() for better portability.

- Fixed a premature step end bug dating back to Simen's 0.7b edge
version is fixed, from which this code is forked from. Caused by Timer2
constantly overflowing calling the Step Reset Interrupt every 128usec.
Now Timer2 is always disabled after a step end and should free up some
cycles for the main program. Could be more than one way to fix this
problem. I'm open to suggestions.

- _delay_ms() refactored to accept only constants to comply with
current compilers. square() removed since not available with some
compilers.
This commit is contained in:
Sonny Jeon
2012-01-15 18:25:12 -07:00
parent 89a3b37e02
commit d27dd13a54
8 changed files with 39 additions and 28 deletions

View File

@ -21,6 +21,7 @@
#include "nuts_bolts.h"
#include <stdint.h>
#include <stdlib.h>
#include <util/delay.h>
int read_double(char *line, uint8_t *char_counter, double *double_ptr)
{
@ -36,3 +37,10 @@ int read_double(char *line, uint8_t *char_counter, double *double_ptr)
return(true);
}
// Delays variable defined milliseconds. Compiler compatibility fix for _delay_ms(),
// which only accepts constants in future compiler releases.
void delay_ms(uint16_t ms)
{
while ( ms-- ) { _delay_ms(1); }
}