most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown
Dependencies: mbed MODSERIAL FATFileSystem
Diff: LTC1298/ltc1298.cpp
- Revision:
- 10:085ab7328054
- Parent:
- 9:d5fcdcb3c89d
- Child:
- 51:c5c40272ecc3
--- a/LTC1298/ltc1298.cpp Fri Oct 20 11:41:22 2017 +0000 +++ b/LTC1298/ltc1298.cpp Mon Oct 23 12:50:53 2017 +0000 @@ -1,43 +1,45 @@ #include "ltc1298.hpp" -SpiADC::SpiADC(): _spi(p5,p6,p7),adcLed(LED2),cs(p8) //maybe this should configurable on construction +SpiADC::SpiADC(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName led) : + _spi(mosi, miso, sclk), // mosi, miso, sclk + adcLed(led), // status led + cs(csel) // chip select { - } -void SpiADC::initialize() -{ +void SpiADC::initialize() { //set up the spi bus and frequency _spi.format(13,0); _spi.frequency(1000000); + //chip select high puts ltc1298 in standby - adcLed = 1; + cs = 1; + + //zero the initial ch0 and ch1 oversampled readings ch0_filt = 0; ch1_filt = 0; - cs = 1; + //led on to say hello + adcLed = 1; } -//This starts an interupt driven trigger of the external ADC -void SpiADC::start() -{ +// start an interupt driven trigger of the external ADC +void SpiADC::start() { interval.attach_us(this, &SpiADC::update, 100); //this should be a 10 kHz sample rate } -//This stops it -void SpiADC::stop() -{ +// stop the interupt driven trigger +void SpiADC::stop() { interval.detach(); } - -void SpiADC::update() -{ +void SpiADC::update() { //flash the LED adcLed = !adcLed; //chip select low starts data conversion cs = 0; + //the next thing is the input data word //it is 4 bits and looks like this // | start | single/diff | odd/sign | MSB first/LSB first | @@ -65,12 +67,10 @@ return ; } -int SpiADC::readCh0() -{ +int SpiADC::readCh0() { return ch0_filt; } -int SpiADC::readCh1() -{ +int SpiADC::readCh1() { return ch1_filt; } \ No newline at end of file