Browse Source

Improved drivers, allowed parallel use of multiple gyros

sbg
Lorenz Meier 12 years ago
parent
commit
b1bc5e0e46
  1. 11
      apps/drivers/device/spi.cpp
  2. 8
      apps/drivers/l3gd20/l3gd20.cpp
  3. 2
      apps/systemcmds/preflight_check/preflight_check.c

11
apps/drivers/device/spi.cpp

@ -86,7 +86,7 @@ SPI::init()
{ {
int ret = OK; int ret = OK;
// attach to the spi bus /* attach to the spi bus */
if (_dev == nullptr) if (_dev == nullptr)
_dev = up_spiinitialize(_bus); _dev = up_spiinitialize(_bus);
@ -96,7 +96,10 @@ SPI::init()
goto out; goto out;
} }
// call the probe function to check whether the device is present /* deselect device to ensure high to low transition of pin select */
SPI_SELECT(_dev, _device, false);
/* call the probe function to check whether the device is present */
ret = probe(); ret = probe();
if (ret != OK) { if (ret != OK) {
@ -104,7 +107,7 @@ SPI::init()
goto out; goto out;
} }
// do base class init, which will create the device node, etc. /* do base class init, which will create the device node, etc. */
ret = CDev::init(); ret = CDev::init();
if (ret != OK) { if (ret != OK) {
@ -112,7 +115,7 @@ SPI::init()
goto out; goto out;
} }
// tell the workd where we are /* tell the workd where we are */
log("on SPI bus %d at %d", _bus, _device); log("on SPI bus %d at %d", _bus, _device);
out: out:

8
apps/drivers/l3gd20/l3gd20.cpp

@ -151,7 +151,7 @@ extern "C" { __EXPORT int l3gd20_main(int argc, char *argv[]); }
class L3GD20 : public device::SPI class L3GD20 : public device::SPI
{ {
public: public:
L3GD20(int bus, spi_dev_e device); L3GD20(int bus, const char* path, spi_dev_e device);
~L3GD20(); ~L3GD20();
virtual int init(); virtual int init();
@ -265,8 +265,8 @@ private:
#define INCREMENT(_x, _lim) do { _x++; if (_x >= _lim) _x = 0; } while(0) #define INCREMENT(_x, _lim) do { _x++; if (_x >= _lim) _x = 0; } while(0)
L3GD20::L3GD20(int bus, spi_dev_e device) : L3GD20::L3GD20(int bus, const char* path, spi_dev_e device) :
SPI("L3GD20", GYRO_DEVICE_PATH, bus, device, SPIDEV_MODE3, 8000000), SPI("L3GD20", path, bus, device, SPIDEV_MODE3, 8000000),
_call_interval(0), _call_interval(0),
_num_reports(0), _num_reports(0),
_next_report(0), _next_report(0),
@ -745,7 +745,7 @@ start()
errx(1, "already started"); errx(1, "already started");
/* create the driver */ /* create the driver */
g_dev = new L3GD20(1 /* XXX magic number */, (spi_dev_e)PX4_SPIDEV_GYRO); g_dev = new L3GD20(1 /* XXX magic number */, GYRO_DEVICE_PATH, (spi_dev_e)PX4_SPIDEV_GYRO);
if (g_dev == nullptr) if (g_dev == nullptr)
goto fail; goto fail;

2
apps/systemcmds/preflight_check/preflight_check.c

@ -145,7 +145,7 @@ system_eval:
led_toggle(leds, LED_BLUE); led_toggle(leds, LED_BLUE);
/* display and sound error */ /* display and sound error */
for (int i = 0; i < 200; i++) for (int i = 0; i < 150; i++)
{ {
led_toggle(leds, LED_BLUE); led_toggle(leds, LED_BLUE);
led_toggle(leds, LED_AMBER); led_toggle(leds, LED_AMBER);

Loading…
Cancel
Save