OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 Gurjant Kalsi <me@gurjantkalsi.com> | 2 * Copyright (c) 2015 Gurjant Kalsi <me@gurjantkalsi.com> |
3 * | 3 * |
4 * Permission is hereby granted, free of charge, to any person obtaining | 4 * Permission is hereby granted, free of charge, to any person obtaining |
5 * a copy of this software and associated documentation files | 5 * a copy of this software and associated documentation files |
6 * (the "Software"), to deal in the Software without restriction, | 6 * (the "Software"), to deal in the Software without restriction, |
7 * including without limitation the rights to use, copy, modify, merge, | 7 * including without limitation the rights to use, copy, modify, merge, |
8 * publish, distribute, sublicense, and/or sell copies of the Software, | 8 * publish, distribute, sublicense, and/or sell copies of the Software, |
9 * and to permit persons to whom the Software is furnished to do so, | 9 * and to permit persons to whom the Software is furnished to do so, |
10 * subject to the following conditions: | 10 * subject to the following conditions: |
11 * | 11 * |
12 * The above copyright notice and this permission notice shall be | 12 * The above copyright notice and this permission notice shall be |
13 * included in all copies or substantial portions of the Software. | 13 * included in all copies or substantial portions of the Software. |
14 * | 14 * |
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 */ | 22 */ |
23 | 23 |
24 #include <err.h> | 24 #include <err.h> |
25 #include <debug.h> | 25 #include <debug.h> |
26 #include <trace.h> | 26 #include <trace.h> |
27 #include <rand.h> | 27 #include <rand.h> |
28 | 28 |
29 #include <dev/display.h> | 29 #include <dev/display.h> |
30 #include <lib/gfx.h> | |
31 #include <platform/gpio.h> | 30 #include <platform/gpio.h> |
32 #include <target/memory_lcd.h> | 31 #include <target/memory_lcd.h> |
33 | 32 |
34 #if defined (LCD_LS013B7DH06) | 33 #if defined (LCD_LS013B7DH06) |
35 #include <target/display/LS013B7DH06.h> | 34 #include <target/display/LS013B7DH06.h> |
36 #elif defined (LCD_LS027B7DH01) | 35 #elif defined (LCD_LS027B7DH01) |
37 #include <target/display/LS027B7DH01.h> | 36 #include <target/display/LS027B7DH01.h> |
| 37 #elif defined (LCD_LS013B7DH03) |
| 38 #include <target/display/LS013B7DH03.h> |
38 #endif | 39 #endif |
39 | 40 |
40 #define LOCAL_TRACE 0 | 41 #define LOCAL_TRACE 0 |
41 | 42 |
42 SPI_HandleTypeDef SpiHandle; | 43 SPI_HandleTypeDef SpiHandle; |
43 | 44 |
44 #define MLCD_WR 0x01 // LCD Write Command | 45 #define MLCD_WR 0x01 // LCD Write Command |
45 #define MLCD_CM 0x04 // LCD Clear Memory Command | 46 #define MLCD_CM 0x04 // LCD Clear Memory Command |
46 #define MLCD_NO 0x00 // LCD No-op command | 47 #define MLCD_NO 0x00 // LCD No-op command |
47 | 48 |
48 // 5 bytes used as control bytes, MLCD_BYTES_LINE bytes used to data | 49 // 5 bytes used as control bytes, MLCD_BYTES_LINE bytes used to data |
49 #define MLCD_BUF_SIZE (MLCD_BYTES_LINE + 5) | 50 #define MLCD_BUF_SIZE (MLCD_BYTES_LINE + 5) |
50 | 51 |
51 #define VCOM_HI 0x02 | 52 #define VCOM_HI 0x02 |
52 #define VCOM_LO 0x00 | 53 #define VCOM_LO 0x00 |
53 | 54 |
54 static uint8_t framebuffer[MLCD_HEIGHT *MLCD_WIDTH]; | 55 static uint8_t framebuffer[MLCD_HEIGHT * FB_STRIDE]; |
55 static uint8_t vcom_state; | 56 static uint8_t vcom_state; |
56 | 57 |
57 static void chip_select(bool s) | 58 static void chip_select(bool s) |
58 { | 59 { |
59 if (s) { | 60 if (s) { |
60 gpio_set(GPIO(GPIO_PORT_B, 12), GPIO_PIN_SET); | 61 gpio_set(GPIO(GPIO_PORT_B, 12), GPIO_PIN_SET); |
61 } else { | 62 } else { |
62 gpio_set(GPIO(GPIO_PORT_B, 12), GPIO_PIN_RESET); | 63 gpio_set(GPIO(GPIO_PORT_B, 12), GPIO_PIN_RESET); |
63 } | 64 } |
64 } | 65 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 151 |
151 finish: | 152 finish: |
152 chip_select(false); | 153 chip_select(false); |
153 } | 154 } |
154 | 155 |
155 status_t display_get_info(struct display_info *info) | 156 status_t display_get_info(struct display_info *info) |
156 { | 157 { |
157 LTRACEF("display_info %p\n", info); | 158 LTRACEF("display_info %p\n", info); |
158 | 159 |
159 info->framebuffer = (void *)framebuffer; | 160 info->framebuffer = (void *)framebuffer; |
160 info->format = MLCD_GFX_FORMAT; | 161 info->format = FB_FORMAT; |
161 info->width = MLCD_WIDTH; | 162 info->width = MLCD_WIDTH; |
162 info->height = MLCD_HEIGHT; | 163 info->height = MLCD_HEIGHT; |
163 info->stride = MLCD_WIDTH; | 164 info->stride = FB_STRIDE; |
164 info->flush = mlcd_flush; | 165 info->flush = mlcd_flush; |
165 | 166 |
166 return NO_ERROR; | 167 return NO_ERROR; |
167 } | 168 } |
OLD | NEW |