Skip to content

Commit

Permalink
Bugfix SPI_TC_Init numspidevices handling
Browse files Browse the repository at this point in the history
An incorrect assumption was made that SPI_TC_Work could be used during
init (before numspidevices was properly initialized). numspidevices
variable is now properly initialized before attemting to probe (and
still kept at zero until init is run).
Thanks to patrickwtlaw for tracking this thing down!
  • Loading branch information
xnk committed Dec 21, 2014
1 parent c5da481 commit a1822c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/max31855.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ static int32_t SPI_TC_Work( void ) {
}

uint32_t SPI_TC_Init( void ) {
uint32_t numspidevices = 0;
printf("\n%s called",__FUNCTION__);
Sched_SetWorkfunc( SPI_TC_WORK, SPI_TC_Work );

Expand All @@ -60,7 +59,9 @@ uint32_t SPI_TC_Init( void ) {
if( SC18IS602B_Init( SPICLK_1843KHZ, SPIMODE_0, SPIORDER_MSBFIRST ) >= 0 ) { // Only continue of we find the I2C to SPI bridge chip
printf("\nProbing for MAX31855 devices...");

numspidevices = MAX_SPI_DEVICES; // Assume all devices are present for SPI_TC_Work
SPI_TC_Work(); // Run one iteration to update all data
numspidevices = 0; // And reset it afterwards

for( int i = 0; i < MAX_SPI_DEVICES; i++ ) {
if( (spidevreadout[i] == -1 && spiextrareadout[i] == -1) ||
Expand Down

0 comments on commit a1822c5

Please sign in to comment.