2013-01-03 13:56:23 -04:00
|
|
|
/*
|
|
|
|
* SPIDriver.h --- AP_HAL_SMACCM SPI driver.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012, Galois, Inc.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This software is released under the "BSD3" license. Read the file
|
|
|
|
* "LICENSE" for more information.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __AP_HAL_SMACCM_SPIDRIVER_H__
|
|
|
|
#define __AP_HAL_SMACCM_SPIDRIVER_H__
|
|
|
|
|
2013-01-09 17:32:34 -04:00
|
|
|
#include <AP_HAL_Boards.h>
|
|
|
|
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SMACCM
|
|
|
|
|
2013-01-03 13:56:23 -04:00
|
|
|
#include <AP_HAL_SMACCM.h>
|
2013-01-03 19:41:36 -04:00
|
|
|
#include "Semaphores.h"
|
2013-01-03 13:56:23 -04:00
|
|
|
|
|
|
|
#include <hwf4/spi.h>
|
|
|
|
|
|
|
|
class SMACCM::SMACCMSPIDeviceDriver : public AP_HAL::SPIDeviceDriver {
|
|
|
|
public:
|
|
|
|
SMACCMSPIDeviceDriver(spi_bus *bus, spi_device *device);
|
|
|
|
void init();
|
|
|
|
AP_HAL::Semaphore* get_semaphore();
|
|
|
|
void transaction(const uint8_t *tx, uint8_t *rx, uint16_t len);
|
|
|
|
|
|
|
|
void cs_assert();
|
|
|
|
void cs_release();
|
|
|
|
uint8_t transfer (uint8_t data);
|
2013-01-12 07:13:38 -04:00
|
|
|
void transfer (const uint8_t *data, uint16_t len);
|
2013-01-03 13:56:23 -04:00
|
|
|
private:
|
|
|
|
SMACCMSemaphore _semaphore;
|
|
|
|
struct spi_bus *_bus;
|
|
|
|
struct spi_device *_device;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SMACCM::SMACCMSPIDeviceManager : public AP_HAL::SPIDeviceManager {
|
|
|
|
public:
|
|
|
|
SMACCMSPIDeviceManager();
|
|
|
|
void init(void *);
|
|
|
|
AP_HAL::SPIDeviceDriver* device(AP_HAL::SPIDevice);
|
|
|
|
};
|
|
|
|
|
2013-01-09 17:32:34 -04:00
|
|
|
#endif // CONFIG_HAL_BOARD == HAL_BOARD_SMACCM
|
2013-01-03 13:56:23 -04:00
|
|
|
#endif // __AP_HAL_SMACCM_SPIDRIVER_H__
|