LCDGFX LCD display driver  1.1.5
This library is developed to control SSD1306/SSD1325/SSD1327/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
esp32_spi.h
1 /*
2  MIT License
3 
4  Copyright (c) 2018-2020, Alexey Dynda
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23 */
24 
25 /*
26  * @file lcd_hal/esp/esp32_spi.h This is SPI implementation for ESP32
27  */
28 
29 #ifndef _SSD1306V2_ESP_ESP32_SPI_H_
30 #define _SSD1306V2_ESP_ESP32_SPI_H_
31 
32 #if defined(CONFIG_ESP32_SPI_AVAILABLE) && defined(CONFIG_ESP32_SPI_ENABLE)
33 
34 #include "driver/spi_master.h"
35 
39 class EspSpi
40 {
41 public:
51  explicit EspSpi(int8_t busId = -1, int8_t csPin = -1, int8_t dcPin = -1, int8_t clk = -1, int8_t mosi = -1,
52  uint32_t frequency = 8000000);
53  ~EspSpi();
54 
58  void begin();
59 
63  void end();
64 
68  void start();
69 
73  void stop();
74 
79  void send(uint8_t data);
89  void sendBuffer(const uint8_t *buffer, uint16_t size);
90 
91 private:
92  int8_t m_busId;
93  int8_t m_cs;
94  int8_t m_dc;
95  int8_t m_clk;
96  int8_t m_mosi;
97  bool m_first_spi_session;
98  uint32_t m_frequency;
99  spi_device_handle_t m_spi;
100  uint8_t m_buffer[64]{};
101  uint16_t m_data_size = 0;
102 
103  void forceSpiTransfer();
104  static void OnDcChange(void *arg);
105 };
106 
107 #endif
108 
109 #endif
void end()
void start()
void stop()
EspSpi(int8_t busId=-1, int8_t csPin=-1, int8_t dcPin=-1, int8_t clk=-1, int8_t mosi=-1, uint32_t frequency=8000000)
void send(uint8_t data)
void begin()
void sendBuffer(const uint8_t *buffer, uint16_t size)
Sends bytes to SSD1306 device.