APM:Libraries
SPIDevice.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2016 Intel Corporation. All rights reserved.
3  *
4  * This file is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This file is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #pragma once
18 
19 #include <inttypes.h>
20 
21 #include <AP_HAL/HAL.h>
22 #include <AP_HAL/SPIDevice.h>
23 
24 #include "Semaphores.h"
25 
26 namespace Empty {
27 
28 class SPIDevice : public AP_HAL::SPIDevice {
29 public:
31  {
32  }
33 
34  virtual ~SPIDevice() { }
35 
36  /* AP_HAL::Device implementation */
37 
38  /* See AP_HAL::Device::set_speed() */
39  bool set_speed(AP_HAL::Device::Speed speed) override
40  {
41  return true;
42  }
43 
44  /* See AP_HAL::Device::transfer() */
45  bool transfer(const uint8_t *send, uint32_t send_len,
46  uint8_t *recv, uint32_t recv_len) override
47  {
48  return true;
49  }
50 
51  /* See AP_HAL::SPIDevice::transfer_fullduplex() */
52  bool transfer_fullduplex(const uint8_t *send, uint8_t *recv,
53  uint32_t len) override
54  {
55  return true;
56  }
57 
58  /* See AP_HAL::Device::get_semaphore() */
60  {
61  return &_semaphore;
62  }
63 
64  /* See AP_HAL::Device::register_periodic_callback() */
66  uint32_t period_usec, AP_HAL::Device::PeriodicCb) override
67  {
68  return nullptr;
69  }
70 
71 private:
73 };
74 
76 public:
79  {
81  }
82 };
83 
84 }
virtual ~SPIDevice()
Definition: SPIDevice.h:34
bool set_speed(AP_HAL::Device::Speed speed) override
Definition: SPIDevice.h:39
bool transfer_fullduplex(const uint8_t *send, uint8_t *recv, uint32_t len) override
Definition: SPIDevice.h:52
const char * name
Definition: BusTest.cpp:11
bool transfer(const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len) override
Definition: SPIDevice.h:45
AP_HAL::OwnPtr< AP_HAL::SPIDevice > get_device(const char *name) override
Definition: SPIDevice.h:78
void * PeriodicHandle
Definition: Device.h:42
Semaphore _semaphore
Definition: SPIDevice.h:72
AP_HAL::Semaphore * get_semaphore()
Definition: SPIDevice.h:59
AP_HAL::Device::PeriodicHandle register_periodic_callback(uint32_t period_usec, AP_HAL::Device::PeriodicCb) override
Definition: SPIDevice.h:65