Skip to content

Commit

Permalink
bl use boards defines
Browse files Browse the repository at this point in the history
  • Loading branch information
solosky committed Feb 15, 2024
1 parent 77b126a commit 6995c7b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 55 deletions.
63 changes: 19 additions & 44 deletions fw/bootloader/src/lcd_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "nrf_drv_spi.h"
#include "nrf_gpio.h"


#define DATAINTERFACE_WAIT_TICKS 0x5000

#define BUFF_MAX 260
Expand All @@ -29,9 +30,9 @@ static uint32_t lcd_spi_init(void)

uint32_t err_code = NRF_SUCCESS;
nrf_drv_spi_config_t spi_1_cfg = { .ss_pin = NRF_DRV_SPI_PIN_NOT_USED, \
.sck_pin = LCD_SPI_SCL_PIN, \
.miso_pin = FLASH_SPI_MISO_PIN, \
.mosi_pin = LCD_SPI_MOSI_PIN, \
.sck_pin = NRFX_SPIM_SCK_PIN, \
.miso_pin = NRFX_SPIM_MISO_PIN, \
.mosi_pin = NRFX_SPIM_MOSI_PIN, \
.irq_priority = APP_IRQ_PRIORITY_LOW_MID, \
.orc = 0xFF, \
.mode = NRF_DRV_SPI_MODE_0, \
Expand All @@ -56,10 +57,10 @@ static void lcd_spi_uninit(void)
if (m_lcd_spi.enable == false)
return;
nrf_drv_spi_uninit(&m_lcd_spi.instance);
nrf_gpio_cfg_default(LCD_SPI_CS_PIN);
nrf_gpio_cfg_default(LCD_SPI_SCL_PIN);
nrf_gpio_cfg_default(LCD_CS_PIN);
nrf_gpio_cfg_default(NRFX_SPIM_SCK_PIN);
//nrf_gpio_cfg_default(LCD_SPI_MISO_PIN);
nrf_gpio_cfg_default(LCD_SPI_MOSI_PIN);
nrf_gpio_cfg_default(NRFX_SPIM_MOSI_PIN);
nrf_gpio_cfg_default(LCD_BL_PIN);
memset(&m_lcd_spi, 0x00, sizeof(lcd_spi_t));
}
Expand Down Expand Up @@ -122,27 +123,25 @@ static uint32_t lcd_spi_read(const uint8_t * data, const uint8_t len)
void lcd_comm_init(void)
{
lcd_spi_init();
nrf_gpio_cfg_output(LCD_RST_PIN);
nrf_gpio_cfg_output(LCD_DC_RS_PIN);
nrf_gpio_cfg_output(LCD_RESET_PIN);
nrf_gpio_cfg_output(LCD_DC_PIN);
nrf_gpio_cfg_output(LCD_BL_PIN);
nrf_gpio_cfg_output(LED_1);

nrf_gpio_cfg_output(FALSH_SPI_CS_PIN);
nrf_gpio_cfg_output(LCD_SPI_CS_PIN);
nrf_gpio_cfg_output(LCD_CS_PIN);

nrf_gpio_pin_set(LCD_RST_PIN);
nrf_gpio_pin_clear(LCD_DC_RS_PIN);
nrf_gpio_pin_set(LCD_RESET_PIN);
nrf_gpio_pin_clear(LCD_DC_PIN);
nrf_gpio_pin_clear(LCD_BL_PIN);
nrf_gpio_pin_set(LED_1);
nrf_gpio_pin_set(FALSH_SPI_CS_PIN);
nrf_gpio_pin_set(LCD_SPI_CS_PIN);
nrf_gpio_pin_set(LCD_CS_PIN);
}

void lcd_comm_uninit(void)
{
lcd_spi_uninit();
nrf_gpio_cfg_default(LCD_RST_PIN);
nrf_gpio_cfg_default(LCD_DC_RS_PIN);
nrf_gpio_cfg_default(LCD_RESET_PIN);
nrf_gpio_cfg_default(LCD_DC_PIN);
nrf_gpio_cfg_default(LCD_BL_PIN);
nrf_gpio_cfg_default(LED_1);
}
Expand All @@ -159,41 +158,17 @@ void lcd_reset(void)

void lcd_write_command(uint8_t data)
{
nrf_gpio_pin_write(LCD_SPI_CS_PIN, 0);
nrf_gpio_pin_write(LCD_CS_PIN, 0);
LCD_DC_RS_SET(LCD_RS);
lcd_spi_write(&data, 1);
nrf_gpio_pin_write(LCD_SPI_CS_PIN, 1);
nrf_gpio_pin_write(LCD_CS_PIN, 1);
}

void lcd_write_data(uint8_t *data, uint8_t len)
{
nrf_gpio_pin_write(LCD_SPI_CS_PIN, 0);
nrf_gpio_pin_write(LCD_CS_PIN, 0);
LCD_DC_RS_SET(LCD_DC);
lcd_spi_write(data, len);
nrf_gpio_pin_write(LCD_SPI_CS_PIN, 1);
}



/////flash test

void flash_write_read(uint8_t* tx_data, uint8_t tx_len, uint8_t* rx_data, uint32_t rx_len){
nrf_gpio_pin_write(FALSH_SPI_CS_PIN, 0);
APP_ERROR_CHECK(lcd_spi_write(tx_data, tx_len));
if(rx_len > 0){
APP_ERROR_CHECK(lcd_spi_read(rx_data, rx_len));
}
nrf_gpio_pin_write(FALSH_SPI_CS_PIN, 1);
}

void flash_write_write(uint8_t* tx_data, uint8_t tx_len, uint8_t* rx_data, uint32_t rx_len){
nrf_gpio_pin_write(FALSH_SPI_CS_PIN, 0);
APP_ERROR_CHECK(lcd_spi_write(tx_data, tx_len));
if(rx_len > 0){
APP_ERROR_CHECK(lcd_spi_write(rx_data, rx_len));
}
nrf_gpio_pin_write(FALSH_SPI_CS_PIN, 1);
nrf_gpio_pin_write(LCD_CS_PIN, 1);
}



15 changes: 4 additions & 11 deletions fw/bootloader/src/lcd_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,20 @@
#define LCD_COMM_H

#include <stdint.h>
#include "boards_defines.h"

#define LCD_RST_PIN 29
#define LCD_DC_RS_PIN 28
#define LCD_SPI_CS_PIN 27
#define LCD_SPI_SCL_PIN 26
#define LCD_SPI_MOSI_PIN 25
#define LCD_BL_PIN 30
#define LED_1 31

#define FLASH_SPI_MISO_PIN 19
#define FALSH_SPI_CS_PIN 18

enum{
OFF,
ON,
};

#define LCD_POWER_SET(ONOFF) nrf_gpio_pin_write(LCD_POWER_PIN, ONOFF)
#define LCD_RST_SET(ONOFF) nrf_gpio_pin_write(LCD_RST_PIN, ONOFF)
#define LCD_POWER_SET(ONOFF) nrf_gpio_pin_write(LCD_BL_PIN, ONOFF)
#define LCD_RST_SET(ONOFF) nrf_gpio_pin_write(LCD_RESET_PIN, ONOFF)

#define LCD_DC_RS_SET(RS_DC) nrf_gpio_pin_write(LCD_DC_RS_PIN, RS_DC)
#define LCD_DC_RS_SET(RS_DC) nrf_gpio_pin_write(LCD_DC_PIN, RS_DC)

enum{
LCD_RS = 0,
Expand Down
11 changes: 11 additions & 0 deletions fw/ld/bootloader.ld
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,14 @@ SECTIONS


INCLUDE "nrf_common.ld"

SECTIONS
{
.noinit (NOLOAD):
{
PROVIDE(__start_noinit = .);
/* place all symbols in input sections that start with .noinit */
KEEP(*(*.noinit*))
PROVIDE(__stop_noinit = .);
} > NOINIT
}

0 comments on commit 6995c7b

Please sign in to comment.