diff --git a/lib/gfx/display.c b/lib/card10/display.c similarity index 83% rename from lib/gfx/display.c rename to lib/card10/display.c index 1caa81c300b2e0d00e6f705833eab42d1656ee4f..1e334202880580c194a843f8dc81ca4374ca4a35 100644 --- a/lib/gfx/display.c +++ b/lib/card10/display.c @@ -3,11 +3,12 @@ #include "gpio.h" #include "tmr.h" +#include "portexpander.h" +#include "MAX77650-Arduino-Library.h" #include <stdint.h> #include <stdio.h> /***** Globals *****/ -//const gpio_cfg_t DEV_RST_PIN = {PORT_0, PIN_28, GPIO_FUNC_OUT, GPIO_PAD_NONE}; const gpio_cfg_t DEV_DC_PIN = {PORT_1, PIN_6, GPIO_FUNC_OUT, GPIO_PAD_NONE}; // Parameters for PWM output @@ -70,10 +71,24 @@ void PWM_Output(void) printf("PWM started.\n"); } +void display_set_reset_pin(uint8_t state) +{ + if(!portexpander_detected()) { + MAX77650_setDO(state ? true:false); + } else { + portexpander_set(4, state); + } +} void display_init(void) { - //GPIO_Config(&DEV_RST_PIN); + if(!portexpander_detected()) { + // Open-drain + MAX77650_setDRV(false); + // Output + MAX77650_setDIR(false); + } + GPIO_Config(&DEV_DC_PIN); PWM_Output(); diff --git a/lib/gfx/display.h b/lib/card10/display.h similarity index 100% rename from lib/gfx/display.h rename to lib/card10/display.h diff --git a/lib/card10/meson.build b/lib/card10/meson.build index 5c51f5f1014d0e60268073077fb92d0f0eec1918..5cde6614586dcd3cd2c87f5c7f53c0ac2a5174e9 100644 --- a/lib/card10/meson.build +++ b/lib/card10/meson.build @@ -8,7 +8,8 @@ sources = files( 'leds.c', 'pmic.c', 'portexpander.c', - 'pb.c' + 'pb.c', + 'display.c' ) deps = [ diff --git a/lib/card10/portexpander.c b/lib/card10/portexpander.c index 554d618ad09ded95936acd77ca4a0cc3fc7f10b8..67192cc06d767f62cdd5942ca05a75d6350422f4 100644 --- a/lib/card10/portexpander.c +++ b/lib/card10/portexpander.c @@ -8,6 +8,7 @@ #include <stdbool.h> static bool detected = false; +static uint8_t output_state; void portexpander_init(void) { @@ -29,12 +30,13 @@ void portexpander_init(void) command[0] = 0x4F; command[1] = 0x01; I2C_MasterWrite(MXC_I2C1_BUS0, addr << 1, command, 2, 0); - // Enable outputs for transistors and the LED + // Enable outputs for the transistors, the LED and the LCD reset command[0] = 0x03; command[1] = 0x68; I2C_MasterWrite(MXC_I2C1_BUS0, addr << 1, command, 2, 0); // Set outputs to high (i.e. open-drain) - command[0] = 0x01; command[1] = 0x97; + output_state = 0x97; + command[0] = 0x01; command[1] = output_state; I2C_MasterWrite(MXC_I2C1_BUS0, addr << 1, command, 2, 0); // Turn on LEDs @@ -62,3 +64,20 @@ bool portexpander_detected(void) { return detected; } + +void portexpander_set(uint8_t pin, uint8_t value) +{ + uint8_t addr = 0x21; + uint8_t command[2]; + + if(detected && pin < 8) { + if(value) { + output_state |= (1 << pin); + } else { + output_state &= ~(1 << pin); + } + + command[0] = 0x01; command[1] = output_state; + I2C_MasterWrite(MXC_I2C1_BUS0, addr << 1, command, 2, 0); + } +} diff --git a/lib/card10/portexpander.h b/lib/card10/portexpander.h index 66937c29da1a769e2de824f0a8b3a5f2ec545909..b81c7070d4d412714d1df08b1f424fabf37291b0 100644 --- a/lib/card10/portexpander.h +++ b/lib/card10/portexpander.h @@ -6,6 +6,7 @@ void portexpander_init(void); uint8_t portexpander_get(void); +void portexpander_set(uint8_t pin, uint8_t value); bool portexpander_detected(void); #endif diff --git a/lib/gfx/GUI_DEV/DEV_Config.h b/lib/gfx/GUI_DEV/DEV_Config.h index 94eaa7ae50e265cd8f7701ec1e2dbd56faf1dab2..644870058ac120db1f3a83f6dcdb3e890c11344f 100644 --- a/lib/gfx/GUI_DEV/DEV_Config.h +++ b/lib/gfx/GUI_DEV/DEV_Config.h @@ -46,24 +46,22 @@ /** * GPIO config **/ -//extern const gpio_cfg_t DEV_RST_PIN; extern const gpio_cfg_t DEV_DC_PIN; -//extern const gpio_cfg_t DEV_CS_PIN; -//extern const gpio_cfg_t DEV_BL_PIN; + /** * GPIO read and write **/ #define DEV_Digital_Write(_pin, _value) GPIO_OutPut(&_pin, _value == 0? 0 : _pin.mask) -//#define DEV_Digital_Read(_pin) HAL_GPIO_ReadPin(_pin) /** * SPI **/ void lcd_write(uint8_t* data, int size); -//#define DEV_SPI_WRITE(_dat) HAL_SPI_Transmit(&hspi1, (uint8_t *)&_dat, 1, 500); +void display_set_reset_pin(uint8_t state); #define DEV_SPI_WRITE(_dat) lcd_write(&_dat, 1) - +#define DEV_RESET_LOW() display_set_reset_pin(0) +#define DEV_RESET_HIGH() display_set_reset_pin(1) /** * delay x ms **/ diff --git a/lib/gfx/LCD/LCD_Driver.c b/lib/gfx/LCD/LCD_Driver.c index 20f12e5815bb2bcfc55001b4db36a31fb02c689c..7005fda5244f2fa109bba77e40c8cc30948fd095 100644 --- a/lib/gfx/LCD/LCD_Driver.c +++ b/lib/gfx/LCD/LCD_Driver.c @@ -38,9 +38,9 @@ static void LCD_Reset(void) { //DEV_Digital_Write(DEV_CS_PIN,0); DEV_Delay_ms(20); - //DEV_Digital_Write(DEV_RST_PIN,0); + DEV_RESET_LOW(); DEV_Delay_ms(20); - //DEV_Digital_Write(DEV_RST_PIN,1); + DEV_RESET_HIGH(); DEV_Delay_ms(20); } diff --git a/lib/gfx/meson.build b/lib/gfx/meson.build index a29e567871615649a9baa3a7650133763e30b907..41b377b1fbe12469e8411b23f597b2af51f40e5c 100644 --- a/lib/gfx/meson.build +++ b/lib/gfx/meson.build @@ -9,8 +9,6 @@ sources = files( './GUI_DEV/DEV_Config.c', './GUI_DEV/GUI_Paint.c', './LCD/LCD_Driver.c', - './display.c', - './Fonts/font8.c', './Fonts/font12.c', './Fonts/font12CN.c',