ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
DummyIoProvider.hpp
1 /*
2  * Copyright 2021 Marcus Behel
3  *
4  * This file is part of ArPiRobot-CoreLib.
5  *
6  * ArPiRobot-CoreLib is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * ArPiRobot-CoreLib is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with ArPiRobot-CoreLib. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #pragma once
21 
22 #include <arpirobot/core/io/IoProvider.hpp>
23 
24 namespace arpirobot{
25 
35  class DummyIoProvider : public IoProvider{
36  protected:
37 
39 
40  ~DummyIoProvider();
41 
45  void gpioMode(unsigned int pin, unsigned int mode) override;
46 
47  void gpioWrite(unsigned int pin, unsigned int state) override;
48 
49  unsigned int gpioRead(unsigned int pin) override;
50 
51  void gpioSetPwmFrequency(unsigned int pin, unsigned int frequency) override;
52 
53  unsigned int gpioGetPwmFrequency(unsigned int pin) override;
54 
55  void gpioPwm(unsigned int pin, unsigned int value) override;
56 
57 
61  unsigned int i2cOpen(unsigned int bus, unsigned int address) override;
62 
63  void i2cClose(unsigned int handle) override;
64 
65  void i2cWriteByte(unsigned int handle, uint8_t data) override;
66 
67  uint8_t i2cReadByte(unsigned int handle) override;
68 
69  void i2cWriteBytes(unsigned int handle, char *buf, unsigned int count) override;
70 
71  unsigned int i2cReadBytes(unsigned int handle, char *buf, unsigned int count) override;
72 
73  void i2cWriteReg8(unsigned int handle, uint8_t reg, uint8_t value) override;
74 
75  uint8_t i2cReadReg8(unsigned int handle, uint8_t reg) override;
76 
77  void i2cWriteReg16(unsigned int handle, uint8_t reg, uint16_t value) override;
78 
79  uint16_t i2cReadReg16(unsigned int handle, uint8_t reg) override;
80 
81 
85 
86  // Bus = spi bus
87  // Channel = which builtin CS pin
88  // Mode = SPI Mode (0, 1, 2, 3)
89  unsigned int spiOpen(unsigned int bus, unsigned int channel, unsigned int baud, unsigned int mode) override;
90 
91  void spiClose(unsigned int handle) override;
92 
93  void spiWrite(unsigned int handle, char *buf, unsigned int count) override;
94 
95  unsigned int spiRead(unsigned int handle, char *buf, unsigned int count) override;
96 
97 
101 
102  unsigned int uartOpen(char *port, unsigned int baud) override;
103 
104  void uartClose(unsigned int handle) override;
105 
106  unsigned int uartAvailable(unsigned int handle) override;
107 
108  void uartWrite(unsigned int handle, char* buf, unsigned int count) override;
109 
110  unsigned int uartRead(unsigned int handle, char *buf, unsigned int count) override;
111 
112  void uartWriteByte(unsigned int handle, uint8_t b) override;
113 
114  uint8_t uartReadByte(unsigned int handle) override;
115 
116  friend class Io;
117  };
118 }
Definition: DummyIoProvider.hpp:35
void gpioMode(unsigned int pin, unsigned int mode) override
GPIO & PWM.
unsigned int uartOpen(char *port, unsigned int baud) override
UART.
unsigned int i2cOpen(unsigned int bus, unsigned int address) override
I2C.
unsigned int spiOpen(unsigned int bus, unsigned int channel, unsigned int baud, unsigned int mode) override
SPI.
Definition: IoProvider.hpp:30
Definition: Io.hpp:32
Definition: ArduinoDevice.hpp:27