Skip to content
Snippets Groups Projects
Commit b4c549e5 authored by schneider's avatar schneider
Browse files

fix(display): Make use of the display reset pin

parent fc83ae6e
No related branches found
No related tags found
No related merge requests found
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
#include "gpio.h" #include "gpio.h"
#include "tmr.h" #include "tmr.h"
#include "portexpander.h"
#include "MAX77650-Arduino-Library.h"
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
/***** Globals *****/ /***** 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}; const gpio_cfg_t DEV_DC_PIN = {PORT_1, PIN_6, GPIO_FUNC_OUT, GPIO_PAD_NONE};
// Parameters for PWM output // Parameters for PWM output
...@@ -70,10 +71,24 @@ void PWM_Output(void) ...@@ -70,10 +71,24 @@ void PWM_Output(void)
printf("PWM started.\n"); 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) 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); GPIO_Config(&DEV_DC_PIN);
PWM_Output(); PWM_Output();
......
File moved
...@@ -8,7 +8,8 @@ sources = files( ...@@ -8,7 +8,8 @@ sources = files(
'leds.c', 'leds.c',
'pmic.c', 'pmic.c',
'portexpander.c', 'portexpander.c',
'pb.c' 'pb.c',
'display.c'
) )
deps = [ deps = [
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <stdbool.h> #include <stdbool.h>
static bool detected = false; static bool detected = false;
static uint8_t output_state;
void portexpander_init(void) void portexpander_init(void)
{ {
...@@ -29,12 +30,13 @@ void portexpander_init(void) ...@@ -29,12 +30,13 @@ void portexpander_init(void)
command[0] = 0x4F; command[1] = 0x01; command[0] = 0x4F; command[1] = 0x01;
I2C_MasterWrite(MXC_I2C1_BUS0, addr << 1, command, 2, 0); 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; command[0] = 0x03; command[1] = 0x68;
I2C_MasterWrite(MXC_I2C1_BUS0, addr << 1, command, 2, 0); I2C_MasterWrite(MXC_I2C1_BUS0, addr << 1, command, 2, 0);
// Set outputs to high (i.e. open-drain) // 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); I2C_MasterWrite(MXC_I2C1_BUS0, addr << 1, command, 2, 0);
// Turn on LEDs // Turn on LEDs
...@@ -62,3 +64,20 @@ bool portexpander_detected(void) ...@@ -62,3 +64,20 @@ bool portexpander_detected(void)
{ {
return detected; 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);
}
}
...@@ -46,24 +46,22 @@ ...@@ -46,24 +46,22 @@
/** /**
* GPIO config * GPIO config
**/ **/
//extern const gpio_cfg_t DEV_RST_PIN;
extern const gpio_cfg_t DEV_DC_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 * GPIO read and write
**/ **/
#define DEV_Digital_Write(_pin, _value) GPIO_OutPut(&_pin, _value == 0? 0 : _pin.mask) #define DEV_Digital_Write(_pin, _value) GPIO_OutPut(&_pin, _value == 0? 0 : _pin.mask)
//#define DEV_Digital_Read(_pin) HAL_GPIO_ReadPin(_pin)
/** /**
* SPI * SPI
**/ **/
void lcd_write(uint8_t* data, int size); 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_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 * delay x ms
**/ **/
......
...@@ -38,9 +38,9 @@ static void LCD_Reset(void) ...@@ -38,9 +38,9 @@ static void LCD_Reset(void)
{ {
//DEV_Digital_Write(DEV_CS_PIN,0); //DEV_Digital_Write(DEV_CS_PIN,0);
DEV_Delay_ms(20); DEV_Delay_ms(20);
//DEV_Digital_Write(DEV_RST_PIN,0); DEV_RESET_LOW();
DEV_Delay_ms(20); DEV_Delay_ms(20);
//DEV_Digital_Write(DEV_RST_PIN,1); DEV_RESET_HIGH();
DEV_Delay_ms(20); DEV_Delay_ms(20);
} }
......
...@@ -9,8 +9,6 @@ sources = files( ...@@ -9,8 +9,6 @@ sources = files(
'./GUI_DEV/DEV_Config.c', './GUI_DEV/DEV_Config.c',
'./GUI_DEV/GUI_Paint.c', './GUI_DEV/GUI_Paint.c',
'./LCD/LCD_Driver.c', './LCD/LCD_Driver.c',
'./display.c',
'./Fonts/font8.c', './Fonts/font8.c',
'./Fonts/font12.c', './Fonts/font12.c',
'./Fonts/font12CN.c', './Fonts/font12CN.c',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment