-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSpiBusDevice.h
56 lines (40 loc) · 1.83 KB
/
SpiBusDevice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* This file is part of the Arduino_ThreadsafeIO library.
* Copyright (c) 2021 Arduino SA.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SPI_BUS_DEVICE_H_
#define SPI_BUS_DEVICE_H_
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include "../BusDevice.h"
#include "SpiBusDeviceConfig.h"
/**************************************************************************************
* CLASS DECLARATION
**************************************************************************************/
class SpiBusDevice : public BusDeviceBase
{
public:
SpiBusDevice(SpiBusDeviceConfig const & config);
virtual ~SpiBusDevice() { }
virtual IoResponse transfer(IoRequest & req) override;
bool read(uint8_t * buffer, size_t len, uint8_t sendvalue = 0xFF);
bool write(uint8_t * buffer, size_t len);
bool write_then_read(uint8_t * write_buffer, size_t write_len, uint8_t * read_buffer, size_t read_len, uint8_t sendvalue = 0xFF);
private:
SpiBusDeviceConfig _config;
};
#endif /* SPI_BUS_DEVICE_H_ */