Ardupilot2/libraries/AP_HAL/SPIDevice.h
Lucas De Marchi 01452bf922 AP_HAL: SPIDevice: add fullduplex method
This method is needed when we want to transfer both tx and rx at the
same time, as opposed to common cases for sensors in which they are like
in the I2C interface: half-duplex.
2016-07-29 15:01:14 -03:00

62 lines
2.0 KiB
C++

/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
/*
* Copyright (C) 2015-2016 Intel Corporation. All rights reserved.
*
* This file is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <inttypes.h>
#include "AP_HAL_Namespace.h"
#include "Device.h"
#include "utility/OwnPtr.h"
namespace AP_HAL {
class SPIDevice : public Device {
public:
SPIDevice() : Device(BUS_TYPE_SPI) { }
virtual ~SPIDevice() { }
/* Device implementation */
/* See Device::set_speed() */
virtual bool set_speed(Device::Speed speed) override = 0;
/* See Device::transfer() */
virtual bool transfer(const uint8_t *send, uint32_t send_len,
uint8_t *recv, uint32_t recv_len) override = 0;
/*
* Like #transfer(), but both @send and @recv buffers are transmitted at
* the same time: because of this they need to be of the same size.
*/
virtual bool transfer_fullduplex(const uint8_t *send, uint8_t *recv,
uint32_t len) = 0;
/* See Device::get_semaphore() */
virtual Semaphore *get_semaphore() override = 0;
/* See Device::register_periodic_callback() */
virtual Device::PeriodicHandle *register_periodic_callback(
uint32_t period_usec, MemberProc) override = 0;
virtual int get_fd() override = 0;
};
/* SPIDeviceManager is temporarily provided by SPIDriver.h */
}