mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_HAL_Empty: implement SPIDevice
This commit is contained in:
parent
66f644c50d
commit
cb40444bf8
@ -14,6 +14,7 @@ namespace Empty {
|
||||
class RCOutput;
|
||||
class Scheduler;
|
||||
class Semaphore;
|
||||
class SPIDevice;
|
||||
class SPIDeviceDriver;
|
||||
class SPIDeviceManager;
|
||||
class Storage;
|
||||
|
72
libraries/AP_HAL_Empty/SPIDevice.h
Normal file
72
libraries/AP_HAL_Empty/SPIDevice.h
Normal file
@ -0,0 +1,72 @@
|
||||
/// -*- 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/HAL.h>
|
||||
#include <AP_HAL/SPIDevice.h>
|
||||
|
||||
#include "Semaphores.h"
|
||||
|
||||
namespace Empty {
|
||||
|
||||
class SPIDevice : public AP_HAL::SPIDevice {
|
||||
public:
|
||||
SPIDevice()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~SPIDevice() { }
|
||||
|
||||
/* AP_HAL::Device implementation */
|
||||
|
||||
/* See AP_HAL::Device::set_speed() */
|
||||
bool set_speed(AP_HAL::Device::Speed speed) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* See AP_HAL::Device::transfer() */
|
||||
bool transfer(const uint8_t *send, uint32_t send_len,
|
||||
uint8_t *recv, uint32_t recv_len) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* See AP_HAL::Device::get_semaphore() */
|
||||
AP_HAL::Semaphore *get_semaphore()
|
||||
{
|
||||
return &_semaphore;
|
||||
}
|
||||
|
||||
/* See AP_HAL::Device::register_periodic_callback() */
|
||||
AP_HAL::Device::PeriodicHandle *register_periodic_callback(
|
||||
uint32_t period_usec, AP_HAL::MemberProc) override
|
||||
{
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
/* See AP_HAL::Device::get_fd() */
|
||||
int get_fd() override { return -1; }
|
||||
|
||||
private:
|
||||
Semaphore _semaphore;
|
||||
};
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
|
||||
#include "SPIDevice.h"
|
||||
#include "SPIDriver.h"
|
||||
|
||||
using namespace Empty;
|
||||
@ -46,3 +46,8 @@ AP_HAL::SPIDeviceDriver* SPIDeviceManager::device(enum AP_HAL::SPIDeviceType, ui
|
||||
return &_device;
|
||||
}
|
||||
|
||||
AP_HAL::OwnPtr<AP_HAL::SPIDevice>
|
||||
SPIDeviceManager::get_device(const char *name)
|
||||
{
|
||||
return AP_HAL::OwnPtr<AP_HAL::SPIDevice>(new SPIDevice());
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __AP_HAL_EMPTY_SPIDRIVER_H__
|
||||
#define __AP_HAL_EMPTY_SPIDRIVER_H__
|
||||
#include <AP_HAL/SPIDevice.h>
|
||||
#include <AP_HAL/utility/OwnPtr.h>
|
||||
|
||||
#include "AP_HAL_Empty.h"
|
||||
#include "Semaphores.h"
|
||||
@ -23,10 +24,11 @@ private:
|
||||
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;
|
||||
};
|
||||
|
||||
#endif // __AP_HAL_EMPTY_SPIDRIVER_H__
|
||||
|
Loading…
Reference in New Issue
Block a user