Browse Source

AP_ADC: use new scheduler API

mission-4.1.18
Andrew Tridgell 12 years ago
parent
commit
6134d9d0d7
  1. 8
      libraries/AP_ADC/AP_ADC_ADS7844.cpp
  2. 7
      libraries/AP_ADC/AP_ADC_ADS7844.h
  3. 4
      libraries/AP_ADC/AP_ADC_HIL.cpp
  4. 6
      libraries/AP_ADC/AP_ADC_HIL.h

8
libraries/AP_ADC/AP_ADC_ADS7844.cpp

@ -81,11 +81,7 @@ static volatile uint32_t _ch6_delta_time_start_micros = 0; @@ -81,11 +81,7 @@ static volatile uint32_t _ch6_delta_time_start_micros = 0;
// time latest sample was collected
static volatile uint32_t _ch6_last_sample_time_micros = 0;
AP_HAL::SPIDeviceDriver* AP_ADC_ADS7844::_spi = NULL;
AP_HAL::Semaphore* AP_ADC_ADS7844::_spi_sem = NULL;
void AP_ADC_ADS7844::read(uint32_t tnow)
void AP_ADC_ADS7844::read(void)
{
static int semfail_ctr = 0;
uint8_t ch;
@ -175,7 +171,7 @@ void AP_ADC_ADS7844::Init() @@ -175,7 +171,7 @@ void AP_ADC_ADS7844::Init()
_ch6_last_sample_time_micros = hal.scheduler->micros();
hal.scheduler->register_timer_process( AP_ADC_ADS7844::read );
hal.scheduler->register_timer_process( reinterpret_cast<AP_HAL::TimedProc>(&AP_ADC_ADS7844::read), this );
hal.scheduler->resume_timer_procs();
}

7
libraries/AP_ADC/AP_ADC_ADS7844.h

@ -26,10 +26,9 @@ public: @@ -26,10 +26,9 @@ public:
uint16_t num_samples_available(const uint8_t *channel_numbers);
private:
static void read(uint32_t);
static AP_HAL::SPIDeviceDriver *_spi;
static AP_HAL::Semaphore *_spi_sem;
void read(void);
AP_HAL::SPIDeviceDriver *_spi;
AP_HAL::Semaphore *_spi_sem;
};
#endif

4
libraries/AP_ADC/AP_ADC_HIL.cpp

@ -30,8 +30,6 @@ const float AP_ADC_HIL::accelBias[3] = {2025,2025,2025}; @@ -30,8 +30,6 @@ const float AP_ADC_HIL::accelBias[3] = {2025,2025,2025};
const float AP_ADC_HIL::gyroScale[3] = {143.239, 139.746, 139.746};
const float AP_ADC_HIL::accelScale[3] = {418,418,418}; // adcPerG
uint16_t AP_ADC_HIL::_count; // number of samples captured
AP_ADC_HIL::AP_ADC_HIL()
{
// gyros set to zero for calibration
@ -51,7 +49,7 @@ AP_ADC_HIL::AP_ADC_HIL() @@ -51,7 +49,7 @@ AP_ADC_HIL::AP_ADC_HIL()
void AP_ADC_HIL::Init()
{
hal.scheduler->register_timer_process( AP_ADC_HIL::read );
hal.scheduler->register_timer_process( reinterpret_cast<AP_HAL::TimedProc>(&AP_ADC_HIL::read), this);
}
// Read one channel value

6
libraries/AP_ADC/AP_ADC_HIL.h

@ -103,12 +103,12 @@ private: @@ -103,12 +103,12 @@ private:
void setGyroTemp(int16_t val) {
}
// read function that pretends to capture new data
static void read(uint32_t tnow) {
// read function that pretends to capture new data
void read(void) {
_count++;
}
static uint16_t _count; // number of samples captured
uint16_t _count; // number of samples captured
};
#endif

Loading…
Cancel
Save