remove crappy code, hw is fixed :)

This commit is contained in:
Gautier Hattenberger
2012-02-24 14:43:23 +01:00
parent 7b8b90442a
commit 95e6f124f0
+4 -16
View File
@@ -27,6 +27,7 @@
#include "subsystems/sensors/baro.h" #include "subsystems/sensors/baro.h"
#include "led.h" #include "led.h"
#include "mcu_periph/spi.h"
/* Common Baro struct */ /* Common Baro struct */
struct Baro baro; struct Baro baro;
@@ -37,6 +38,7 @@ uint16_t startup_cnt;
void baro_init( void ) { void baro_init( void ) {
mcp355x_init(); mcp355x_init();
SpiSelectSlave0(); // never unselect this slave (continious conversion mode)
baro.status = BS_UNINITIALIZED; baro.status = BS_UNINITIALIZED;
baro.absolute = 0; baro.absolute = 0;
baro.differential = 0; /* not handled on this board */ baro.differential = 0; /* not handled on this board */
@@ -46,24 +48,10 @@ void baro_init( void ) {
startup_cnt = STARTUP_COUNTER; startup_cnt = STARTUP_COUNTER;
} }
// Need to play with slave select
#include "mcu_periph/spi.h"
void baro_periodic( void ) { void baro_periodic( void ) {
if (baro.status == BS_UNINITIALIZED) { if (baro.status == BS_UNINITIALIZED) {
/** // Run some loops to get correct readings from the adc
* Crappy code to empty the buffer
* then unselect the device (goes to shutdown ?)
* reselect to go to continious conversion mode
* make some readings before setting BS_RUNNING
* don't unselect the slave !
*/
if (startup_cnt == 150) { SpiSelectSlave0(); mcp355x_read(); }
else if (startup_cnt == 149) { SpiUnselectSlave0(); }
else if (startup_cnt == 100) { SpiSelectSlave0(); }
else if (startup_cnt < 90) { RunOnceEvery(4, mcp355x_read()); }
// decrease init counter
--startup_cnt; --startup_cnt;
#ifdef ROTORCRAFT_BARO_LED #ifdef ROTORCRAFT_BARO_LED
LED_TOGGLE(ROTORCRAFT_BARO_LED); LED_TOGGLE(ROTORCRAFT_BARO_LED);
@@ -76,6 +64,6 @@ void baro_periodic( void ) {
} }
} }
// Read the ADC (at 50/4 Hz, conversion time is 68 ms) // Read the ADC (at 50/4 Hz, conversion time is 68 ms)
else { RunOnceEvery(4,mcp355x_read()); } RunOnceEvery(4,mcp355x_read());
} }