SSD1306 OLED display driver 1.8.2 This library is developed to control SSD1306/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays

io.h
1 /*
2 MIT License
3
4 Copyright (c) 2018-2019, 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 ssd1306_hal/avr/io.h SSD1306 AVR IO communication functions
27 */
28
29 #ifndef _SSD1306_AVR_IO_H_
30 #define _SSD1306_AVR_IO_H_
31
32 #include <avr/io.h>
33 #include <avr/interrupt.h>
34 #include <avr/pgmspace.h>
35 #include <avr/sleep.h>
36 #include <avr/eeprom.h>
37 #include <util/delay.h>
38 #include <stdint.h>
39 #include <stdlib.h>
40 #include <string.h>
41
42 #define LOW 0
43 #define HIGH 1
44 #define INPUT 0
45 #define OUTPUT 1
46
47 #if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || \
48 defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
49
50 #define CONFIG_SOFTWARE_I2C_AVAILABLE
51
52 #define CONFIG_USI_SPI_AVAILABLE
53 /* Define lcdint as smallest types to reduce memo usage on tiny controllers. *
54 * Remember, that this can cause issues with large lcd displays, i.e. 320x240*/
55 #define LCDINT_TYPES_DEFINED
56 typedef int8_t lcdint_t;
57 typedef uint8_t lcduint_t;
59 #define CONFIG_MULTIPLICATION_NOT_SUPPORTED
60 #elif defined(__AVR_ATmega328P__)
61
62 #define CONFIG_SOFTWARE_I2C_AVAILABLE
63
64 #define CONFIG_TWI_I2C_AVAILABLE
65
66 #define CONFIG_AVR_SPI_AVAILABLE
67
68 #define CONFIG_AVR_UART_AVAILABLE
69
70 #define CONFIG_VGA_AVAILABLE
71
72 #elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
73
74 #define CONFIG_SOFTWARE_I2C_AVAILABLE
75
76 #define CONFIG_TWI_I2C_AVAILABLE
77
78 #define CONFIG_AVR_SPI_AVAILABLE
79
80 #else
81
82 #define CONFIG_SOFTWARE_I2C_AVAILABLE
83
84 #define CONFIG_TWI_I2C_AVAILABLE
85
86 #define CONFIG_AVR_SPI_AVAILABLE
87 #endif
88
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
92
93 // not implemented functions for plain AVR
94 static inline int digitalRead(int pin) { return LOW; };
95 static inline int analogRead(int pin) { return 0; };
96 static inline uint32_t millis() { return 0; };
97 static inline void randomSeed(int seed) { };
98 static inline void attachInterrupt(int pin, void (*interrupt)(), int level) { };
99
100 // implemented functions for plain AVR
101 void delay(unsigned long ms);
102 #define delayMicroseconds(us) _delay_us(us)
103
104 void digitalWrite(int pin, int level);
105 void pinMode(int pin, int mode);
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #ifdef __cplusplus
112 static inline int random(int max) { return 0; };
113 static inline int random(int min, int max) { return 0; };
114 #endif
115
116 #endif
117
lcdint_t
int lcdint_t
Definition: io.h:63
lcduint_t
unsigned int lcduint_t
Definition: io.h:65
max
#define max(a, b)
Definition: nano_gfx_types.h:40
min
#define min(a, b)
Definition: nano_gfx_types.h:35