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

ssd1306_uart_builtin.c
1 /*
2 MIT License
3
4 Copyright (c) 2016-2018, 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 #include "ssd1306_uart_builtin.h"
27 #include "intf/ssd1306_interface.h"
28
29 #include "ssd1306_hal/io.h"
30
31 #if defined(CONFIG_AVR_UART_AVAILABLE) && defined(CONFIG_AVR_UART_ENABLE)
32
33 #include "ssd1306_uart.h"
34
35 static void ssd1306_uartStart(void)
36 {
37 }
38
39 static void ssd1306_uartStop(void)
40 {
41 uart_send_byte(0x7E);
42 }
43
44 static void ssd1306_uartSendByte(uint8_t data)
45 {
46 if ((data == 0x7E) || (data == 0x7D))
47 {
48 uart_send_byte(0x7D);
49 data ^= 0x20;
50 }
51 uart_send_byte(data);
52 }
53
54 static void ssd1306_uartSendBytes(const uint8_t * buffer, uint16_t len)
55 {
56 while (len--)
57 {
58 ssd1306_uartSendByte(*buffer);
59 buffer++;
60 }
61 }
62
63 void ssd1306_uartInit_Builtin(uint32_t baud)
64 {
65 if (!baud) baud = 115200;
66 uart_init(baud);
67 ssd1306_intf.spi = 0;
68 ssd1306_intf.start = ssd1306_uartStart;
69 ssd1306_intf.stop = ssd1306_uartStop;
70 ssd1306_intf.send = ssd1306_uartSendByte;
71 ssd1306_intf.send_buffer = ssd1306_uartSendBytes;
72 ssd1306_intf.close = ssd1306_uartStart;
73 }
74
75 #endif
ssd1306_interface_t::send
void(* send)(uint8_t data)
Definition: ssd1306_interface.h:70
ssd1306_interface_t::stop
void(* stop)(void)
Definition: ssd1306_interface.h:65
ssd1306_uart_builtin.h
uart_init
static void uart_init(uint32_t baud)
Initializes uart module.
Definition: ssd1306_uart.h:68
io.h
ssd1306_interface_t::start
void(* start)(void)
Definition: ssd1306_interface.h:61
ssd1306_interface_t::close
void(* close)(void)
deinitializes internal resources, allocated for interface.
Definition: ssd1306_interface.h:88
ssd1306_intf
ssd1306_interface_t ssd1306_intf
Definition: ssd1306_interface.c:29
ssd1306_uart.h
ssd1306_uartInit_Builtin
void ssd1306_uartInit_Builtin(uint32_t baud)
Definition: ssd1306_uart_builtin.c:63
ssd1306_interface.h
ssd1306_interface_t::spi
uint8_t spi
Definition: ssd1306_interface.h:57
ssd1306_interface_t::send_buffer
void(* send_buffer)(const uint8_t *buffer, uint16_t size)
Sends bytes to SSD1306 device.
Definition: ssd1306_interface.h:80
uart_send_byte
void uart_send_byte(uint8_t c)
Sends single byte over UART.
Definition: ssd1306_uart.c:117