SPI.h
1 /*
2  * EEZ PSU Firmware
3  * Copyright (C) 2015-present, Envox d.o.o.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include "Arduino.h"
22 
23 #define SPI_CLOCK_DIV4 0x00
24 #define SPI_CLOCK_DIV16 0x01
25 #define SPI_CLOCK_DIV64 0x02
26 #define SPI_CLOCK_DIV128 0x03
27 #define SPI_CLOCK_DIV2 0x04
28 #define SPI_CLOCK_DIV8 0x05
29 #define SPI_CLOCK_DIV32 0x06
30 
31 #define SPI_MODE0 0x00
32 #define SPI_MODE1 0x04
33 #define SPI_MODE2 0x08
34 #define SPI_MODE3 0x0C
35 
36 namespace eez {
37 namespace psu {
38 namespace simulator {
39 namespace arduino {
40 
42 class SPISettings {
43 public:
44  SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode);
45 };
46 
48 class SimulatorSPI {
49 public:
50  void begin();
51 
52  void usingInterrupt(uint8_t interruptNumber);
53  void beginTransaction(SPISettings settings);
54  uint8_t transfer(uint8_t data);
55  void endTransaction(void);
56  void attachInterrupt();
57 
58  void setBitOrder(int _order);
59  void setDataMode(uint8_t _mode);
60  void setClockDivider(uint8_t _div);
61 };
62 
63 extern SimulatorSPI SPI;
64 
65 }
66 }
67 }
68 } // namespace eez::psu::simulator::arduino;
Bare minimum implementation of the Arduino SPISettings class.
Definition: SPI.h:42
Namespace for the everything from the EEZ.
Definition: actions.cpp:41
Bare minimum implementation of the Arduino SPI object.
Definition: SPI.h:48