diff --git a/epicardium/modules/display.c b/epicardium/modules/display.c index 2f5cf112cae88497ee0262bc7892f7118b72990c..1f521553256afbb1d30e80a9c7a3e9cbbc0b68c7 100644 --- a/epicardium/modules/display.c +++ b/epicardium/modules/display.c @@ -127,7 +127,7 @@ int epic_disp_update() struct disp_framebuffer *epic_disp_framebuffer() { - return (struct disp_framebuffer*)LCD_Framebuffer(); + return (struct disp_framebuffer *)LCD_Framebuffer(); } int epic_disp_open() diff --git a/lib/gfx/GUI_DEV/DEV_Config.c b/lib/gfx/GUI_DEV/DEV_Config.c index 7a09c400cd166fb976751ba43c81217552132407..4279efdd6af2c2d39176f8ec61c4e970980e8785 100644 --- a/lib/gfx/GUI_DEV/DEV_Config.c +++ b/lib/gfx/GUI_DEV/DEV_Config.c @@ -1,65 +1,72 @@ -/***************************************************************************** -* | File : DEV_Config.c -* | Author : Waveshare team -* | Function : Hardware underlying interface -* | Info : -* Used to shield the underlying layers of each master -* and enhance portability -*---------------- -* | This version: V1.0 -* | Date : 2018-11-22 -* | Info : - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documnetation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -******************************************************************************/ -#include "DEV_Config.h" -#include "spi.h" - -#define SPI SPI2 - -//const gpio_cfg_t DEV_CS_PIN = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE}; -//const gpio_cfg_t DEV_BL_PIN = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE}; -static spi_req_t req = {.rx_data = NULL, .bits=8, .width = SPI17Y_WIDTH_1, .ssel = 0, .deass = 1, .ssel_pol = SPI17Y_POL_LOW, .tx_num = 0, .rx_num = 0}; - -/********************************************************************************/ -void lcd_write_async(uint8_t *data, int size, lcd_write_cb_t wr_callback) -{ - req.tx_data = data; - req.len = size; - req.callback = wr_callback; - SPI_MasterTransAsync(SPI, &req); -} - -void lcd_write(uint8_t *data, int size) -{ - req.tx_data = data; - req.len = size; - SPI_MasterTrans(SPI, &req); -} - -void lcd_irq_init(void) -{ - NVIC_EnableIRQ(SPI2_IRQn); -} - -void SPI2_IRQHandler(void) -{ - SPI_Handler(SPI); -} +/***************************************************************************** +* | File : DEV_Config.c +* | Author : Waveshare team +* | Function : Hardware underlying interface +* | Info : +* Used to shield the underlying layers of each master +* and enhance portability +*---------------- +* | This version: V1.0 +* | Date : 2018-11-22 +* | Info : + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documnetation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +******************************************************************************/ +#include "DEV_Config.h" +#include "spi.h" + +#define SPI SPI2 + +//const gpio_cfg_t DEV_CS_PIN = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE}; +//const gpio_cfg_t DEV_BL_PIN = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE}; +static spi_req_t req = { .rx_data = NULL, + .bits = 8, + .width = SPI17Y_WIDTH_1, + .ssel = 0, + .deass = 1, + .ssel_pol = SPI17Y_POL_LOW, + .tx_num = 0, + .rx_num = 0 }; + +/********************************************************************************/ +void lcd_write_async(uint8_t *data, int size, lcd_write_cb_t wr_callback) +{ + req.tx_data = data; + req.len = size; + req.callback = wr_callback; + SPI_MasterTransAsync(SPI, &req); +} + +void lcd_write(uint8_t *data, int size) +{ + req.tx_data = data; + req.len = size; + SPI_MasterTrans(SPI, &req); +} + +void lcd_irq_init(void) +{ + NVIC_EnableIRQ(SPI2_IRQn); +} + +void SPI2_IRQHandler(void) +{ + SPI_Handler(SPI); +} diff --git a/lib/gfx/LCD/LCD_Driver.c b/lib/gfx/LCD/LCD_Driver.c index a6c50e5a5e19639f1dc9721c37a3983bcf170057..e8c85a67fc7a6003c85dd317a64624e94fbbc6c6 100644 --- a/lib/gfx/LCD/LCD_Driver.c +++ b/lib/gfx/LCD/LCD_Driver.c @@ -37,12 +37,12 @@ static uint8_t update_in_progress; static inline frame_t *frame(void) { - return &frames[active_frame]; + return &frames[active_frame]; } static void update_cb(void *spi_req, int error_code) { - update_in_progress = 0; + update_in_progress = 0; } /******************************************************************************* @@ -322,20 +322,21 @@ static void LCD_Set(uint8_t *data, int len) { LCD_SetCursor(0, 0, 160 - 1, 80 - 1); DEV_Digital_Write(DEV_DC_PIN, 1); - update_in_progress = 1; - lcd_write_async(data, len, update_cb); + update_in_progress = 1; + lcd_write_async(data, len, update_cb); } int LCD_Update(void) { - if (update_in_progress) - return 1; + if (update_in_progress) + return 1; - LCD_Set(frame()->raw, FRAME_SIZE); - active_frame = !active_frame; - return 0; + LCD_Set(frame()->raw, FRAME_SIZE); + active_frame = !active_frame; + return 0; } -frame_t *LCD_Framebuffer(void) { +frame_t *LCD_Framebuffer(void) +{ return frame(); }