AP_HAL_Empty: remove SPIDriver

SPIDevice now controls all accesses to SPI bus.
This commit is contained in:
Lucas De Marchi 2016-07-22 11:19:36 -03:00
parent 7b140da6d1
commit dc91dfb446
4 changed files with 10 additions and 88 deletions

View File

@ -13,7 +13,7 @@
#include "RCOutput.h"
#include "Scheduler.h"
#include "Semaphores.h"
#include "SPIDriver.h"
#include "SPIDevice.h"
#include "Storage.h"
#include "UARTDriver.h"
#include "Util.h"

View File

@ -76,4 +76,13 @@ private:
Semaphore _semaphore;
};
class SPIDeviceManager : public AP_HAL::SPIDeviceManager {
public:
SPIDeviceManager() { }
AP_HAL::OwnPtr<AP_HAL::SPIDevice> get_device(const char *name) override
{
return AP_HAL::OwnPtr<AP_HAL::SPIDevice>(new SPIDevice());
}
};
}

View File

@ -1,53 +0,0 @@
#include "SPIDevice.h"
#include "SPIDriver.h"
using namespace Empty;
SPIDeviceDriver::SPIDeviceDriver()
{}
void SPIDeviceDriver::init()
{}
AP_HAL::Semaphore* SPIDeviceDriver::get_semaphore()
{
return &_semaphore;
}
bool SPIDeviceDriver::transaction(const uint8_t *tx, uint8_t *rx, uint16_t len)
{
return true;
}
void SPIDeviceDriver::cs_assert()
{}
void SPIDeviceDriver::cs_release()
{}
uint8_t SPIDeviceDriver::transfer (uint8_t data)
{
return 0;
}
void SPIDeviceDriver::transfer (const uint8_t *data, uint16_t len)
{
}
SPIDeviceManager::SPIDeviceManager()
{}
void SPIDeviceManager::init()
{}
AP_HAL::SPIDeviceDriver* SPIDeviceManager::device(enum AP_HAL::SPIDeviceType, uint8_t index)
{
return &_device;
}
AP_HAL::OwnPtr<AP_HAL::SPIDevice>
SPIDeviceManager::get_device(const char *name)
{
return AP_HAL::OwnPtr<AP_HAL::SPIDevice>(new SPIDevice());
}

View File

@ -1,34 +0,0 @@
#pragma once
#include <AP_HAL/SPIDevice.h>
#include <AP_HAL/utility/OwnPtr.h>
#include "AP_HAL_Empty.h"
#include "Semaphores.h"
class Empty::SPIDeviceDriver : public AP_HAL::SPIDeviceDriver {
public:
SPIDeviceDriver();
void init();
AP_HAL::Semaphore* get_semaphore();
bool transaction(const uint8_t *tx, uint8_t *rx, uint16_t len);
void cs_assert();
void cs_release();
uint8_t transfer (uint8_t data);
void transfer (const uint8_t *data, uint16_t len);
private:
Semaphore _semaphore;
};
class Empty::SPIDeviceManager : public AP_HAL::SPIDeviceManager {
public:
SPIDeviceManager();
void init();
AP_HAL::SPIDeviceDriver* device(enum AP_HAL::SPIDeviceType, uint8_t index);
AP_HAL::OwnPtr<AP_HAL::SPIDevice> get_device(const char *name) override;
private:
SPIDeviceDriver _device;
};