Skip to content

Commit

Permalink
projects: eval-pqmon: add lcd example
Browse files Browse the repository at this point in the history
Add nhd_c12832a1z lcd example to peoject.

Signed-off-by: Robert Budai <[email protected]>
  • Loading branch information
rbudai98 authored and buha committed Nov 5, 2024
1 parent b3b5e2e commit c0f70a1
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 30 deletions.
65 changes: 35 additions & 30 deletions projects/eval-pqmon/src.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,43 @@ include $(PROJECT)/src/platform/$(PLATFORM)/platform_src.mk
include $(PROJECT)/src/examples/examples_src.mk
include $(PROJECT)/src/common/common_src.mk

SRCS += $(DRIVERS)/api/no_os_uart.c \
$(DRIVERS)/api/no_os_spi.c \
$(DRIVERS)/api/no_os_timer.c \
$(DRIVERS)/api/no_os_i2c.c \
$(DRIVERS)/api/no_os_irq.c \
$(DRIVERS)/api/no_os_dma.c \
$(DRIVERS)/api/no_os_gpio.c \
$(NO-OS)/util/no_os_fifo.c \
$(NO-OS)/util/no_os_list.c \
$(NO-OS)/util/no_os_lf256fifo.c \
$(NO-OS)/util/no_os_util.c \
$(NO-OS)/util/no_os_alloc.c \
SRCS += $(DRIVERS)/api/no_os_uart.c \
$(DRIVERS)/api/no_os_spi.c \
$(DRIVERS)/api/no_os_timer.c \
$(DRIVERS)/api/no_os_i2c.c \
$(DRIVERS)/api/no_os_irq.c \
$(DRIVERS)/api/no_os_dma.c \
$(DRIVERS)/api/no_os_gpio.c \
$(NO-OS)/util/no_os_fifo.c \
$(NO-OS)/util/no_os_list.c \
$(NO-OS)/util/no_os_lf256fifo.c \
$(NO-OS)/util/no_os_util.c \
$(NO-OS)/util/no_os_alloc.c \
$(NO-OS)/util/no_os_mutex.c

INCS += $(INCLUDE)/no_os_delay.h \
$(INCLUDE)/no_os_error.h \
$(INCLUDE)/no_os_fifo.h \
$(INCLUDE)/no_os_gpio.h \
$(INCLUDE)/no_os_irq.h \
$(INCLUDE)/no_os_lf256fifo.h \
$(INCLUDE)/no_os_list.h \
$(INCLUDE)/no_os_uart.h \
$(INCLUDE)/no_os_spi.h \
$(INCLUDE)/no_os_i2c.h \
$(INCLUDE)/no_os_dma.h \
$(INCLUDE)/no_os_timer.h \
$(INCLUDE)/no_os_util.h \
$(INCLUDE)/no_os_units.h \
$(INCLUDE)/no_os_init.h \
$(INCLUDE)/no_os_print_log.h \
$(INCLUDE)/no_os_alloc.h \
$(INCLUDE)/no_os_mutex.h
INCS += $(INCLUDE)/no_os_delay.h \
$(INCLUDE)/no_os_error.h \
$(INCLUDE)/no_os_fifo.h \
$(INCLUDE)/no_os_gpio.h \
$(INCLUDE)/no_os_irq.h \
$(INCLUDE)/no_os_lf256fifo.h \
$(INCLUDE)/no_os_list.h \
$(INCLUDE)/no_os_uart.h \
$(INCLUDE)/no_os_spi.h \
$(INCLUDE)/no_os_i2c.h \
$(INCLUDE)/no_os_dma.h \
$(INCLUDE)/no_os_timer.h \
$(INCLUDE)/no_os_util.h \
$(INCLUDE)/no_os_units.h \
$(INCLUDE)/no_os_init.h \
$(INCLUDE)/no_os_print_log.h \
$(INCLUDE)/no_os_alloc.h \
$(INCLUDE)/no_os_mutex.h

# LCD driver
SRCS += $(NO-OS)/drivers/display/nhd_c12832a1z/nhd_c12832a1z.c
INCS += $(NO-OS)/drivers/display/nhd_c12832a1z/nhd_c12832a1z.h


# Platforms
INCS += $(PROJECT)/src/platform/platform_includes.h
Expand Down
81 changes: 81 additions & 0 deletions projects/eval-pqmon/src/common/afe_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,87 @@ extern struct no_os_gpio_init_param reset_gpio_ip;
/************************* Functions Definitions ******************************/
/******************************************************************************/

int init_lcd(void)
{
int status;
char buff[50];
struct no_os_gpio_sec *spi_cs;
struct nhd_c12832a1z_dev *nhd_c12832a1z_device;

struct max_gpio_init_param gpio_extra_ip_cs = {
.vssel = MXC_GPIO_VSSEL_VDDIOH,
};

struct no_os_gpio_init_param gpio_dc_ip_cs = {
.port = 2,
.number = 26,
.pull = NO_OS_PULL_NONE,
.platform_ops = &max_gpio_ops,
.extra = &gpio_extra_ip_cs,
};

status = no_os_gpio_get(&spi_cs, &gpio_dc_ip_cs);
if (status)
return status;

struct max_gpio_init_param gpio_extra_ip = {
.vssel = MXC_GPIO_VSSEL_VDDIOH,
};

struct no_os_gpio_init_param gpio_dc_ip = {
.port = 3,
.number = 5,
.pull = NO_OS_PULL_NONE,
.platform_ops = &max_gpio_ops,
.extra = &gpio_extra_ip,
};

struct no_os_gpio_init_param gpio_lcd_rst_ip = {
.port = 3,
.number = 4,
.pull = NO_OS_PULL_NONE,
.platform_ops = &max_gpio_ops,
.extra = &gpio_extra_ip,
};

struct max_spi_init_param spi_extra_ip = {
.num_slaves = 1,
.polarity = SPI_SS_POL_LOW,
.vssel = MXC_GPIO_VSSEL_VDDIOH
};

struct no_os_spi_init_param spi_lcd_ip = {
.device_id = 0,
.max_speed_hz = 1000000,
.bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST,
.mode = NO_OS_SPI_MODE_3,
.platform_ops = &max_spi_ops,
.chip_select = 0,
.extra = &spi_extra_ip,
};

struct nhd_c12832a1z_init_param nhd_c12832a1z_ip = {
.spi_ip = &spi_lcd_ip,
.dc_pin_ip = &gpio_dc_ip,
.reset_pin_ip = &gpio_lcd_rst_ip
};

status = nhd_c12832a1z_init (&nhd_c12832a1z_device, nhd_c12832a1z_ip);
if (status)
return status;
sprintf (buff, " AD-PQMON-SL Eval Board");
status = no_os_gpio_set_value (spi_cs, 1);
if (status)
return status;
status = nhd_c12832a1z_print_string (nhd_c12832a1z_device, buff);
if (status)
return status;
status = no_os_gpio_set_value (spi_cs, 0);
if (status)
return status;

}

int afe_init(void)
{
int status = 0;
Expand Down
8 changes: 8 additions & 0 deletions projects/eval-pqmon/src/common/afe_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "status.h"
#include <stdint.h>
#include <string.h>
#include "nhd_c12832a1z.h"

/******************************************************************************/
/********************** Macros and Constants Definitions **********************/
Expand Down Expand Up @@ -109,6 +110,13 @@ typedef enum {
/************************ Functions Definitions *******************************/
/******************************************************************************/

/**
* @brief Initialize LCD screen and text
*
* @return Return value of initialization, 0 onn success, different from 0 otherwise.
*/
int init_lcd(void);

/**
* @brief SPI Initialization Function
* @retval status 0 for success
Expand Down
4 changes: 4 additions & 0 deletions projects/eval-pqmon/src/examples/basic/basic_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ int basic_pqm_firmware()

int status = SYS_STATUS_SUCCESS;

status = init_lcd();
if (status)
goto exit;

status = no_os_uart_init(&uart_desc, &uart_ip_stdio);
if (status)
goto exit;
Expand Down

0 comments on commit c0f70a1

Please sign in to comment.