boards/arm/stm32/stm32f103-minimum/: Add support to LCD1602 using PCF8574 Backpack board.
This commit is contained in:
parent
a4a23ef584
commit
3840889b11
71
boards/arm/stm32/stm32f103-minimum/configs/lcd1602/defconfig
Normal file
71
boards/arm/stm32/stm32f103-minimum/configs/lcd1602/defconfig
Normal file
@ -0,0 +1,71 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_DISABLE_OS_API is not set
|
||||
# CONFIG_NSH_DISABLESCRIPT is not set
|
||||
# CONFIG_NSH_DISABLE_DD is not set
|
||||
# CONFIG_NSH_DISABLE_EXEC is not set
|
||||
# CONFIG_NSH_DISABLE_EXIT is not set
|
||||
# CONFIG_NSH_DISABLE_GET is not set
|
||||
# CONFIG_NSH_DISABLE_HEXDUMP is not set
|
||||
# CONFIG_NSH_DISABLE_MKRD is not set
|
||||
# CONFIG_NSH_DISABLE_PS is not set
|
||||
# CONFIG_NSH_DISABLE_PUT is not set
|
||||
# CONFIG_NSH_DISABLE_WGET is not set
|
||||
# CONFIG_NSH_DISABLE_XD is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="stm32f103-minimum"
|
||||
CONFIG_ARCH_BOARD_STM32F103_MINIMUM=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F103C8=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=5483
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEFAULT_SMALL=y
|
||||
CONFIG_EXAMPLES_SLCD=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2CTOOL_DEFFREQ=100000
|
||||
CONFIG_I2CTOOL_MAXBUS=1
|
||||
CONFIG_I2CTOOL_MINBUS=1
|
||||
CONFIG_LCD_BACKPACK=y
|
||||
CONFIG_LCD_LCD1602=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=1024
|
||||
CONFIG_NSH_LINELEN=80
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PREALLOC_WDOGS=4
|
||||
CONFIG_RAM_SIZE=20480
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_HPWORKPRIORITY=192
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
CONFIG_SLCD=y
|
||||
CONFIG_START_DAY=5
|
||||
CONFIG_START_MONTH=7
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y
|
||||
CONFIG_STM32_I2C1=y
|
||||
CONFIG_STM32_JTAG_FULL_ENABLE=y
|
||||
CONFIG_STM32_USART1=y
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_SYSTEM_I2CTOOL=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_USART1_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WDOG_INTRESERVE=0
|
@ -69,6 +69,10 @@ ifeq ($(CONFIG_SENSORS_ZEROCROSS),y)
|
||||
CSRCS += stm32_zerocross.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LCD_BACKPACK),y)
|
||||
CSRCS += stm32_lcd_backpack.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LEDS_APA102),y)
|
||||
CSRCS += stm32_apa102.c
|
||||
endif
|
||||
|
@ -165,6 +165,15 @@ int stm32_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LCD_BACKPACK
|
||||
ret = stm32_lcd_backpack_init("/dev/slcd0");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize PCF8574 LCD, error %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SENSORS_ZEROCROSS
|
||||
/* Configure the zero-crossing driver */
|
||||
|
||||
|
126
boards/arm/stm32/stm32f103-minimum/src/stm32_lcd_backpack.c
Normal file
126
boards/arm/stm32/stm32f103-minimum/src/stm32_lcd_backpack.c
Normal file
@ -0,0 +1,126 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32/stm32f103-minimum/src/stm32_lcd_backpack.c
|
||||
*
|
||||
* Copyright (C) 2019 Alan Carvalho de Assis. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
#include <nuttx/lcd/pcf8574_lcd_backpack.h>
|
||||
|
||||
#include "stm32.h"
|
||||
#include "stm32f103_minimum.h"
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_LCD_BACKPACK)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define LCDBP_I2C_PORTNO 1 /* PCF8574 connected to I2C1 */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_lcd_backpack_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize the LCD1602 display controlled by Backpack with PCF8574
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the driver to register. E.g., "/dev/slcd0"
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_lcd_backpack_init(FAR const char *devpath)
|
||||
{
|
||||
FAR struct pcf8574_lcd_backpack_config_s cfg =
|
||||
LCD_I2C_BACKPACK_CFG_SAINSMART;
|
||||
FAR struct i2c_master_s *i2c;
|
||||
int ret;
|
||||
|
||||
/* Setup the LCD row and cols size.
|
||||
* Note: We are using the LCD_I2C_BACKPACK_CFG_SAINSMART config that
|
||||
* defined the I2C Address to 0x27 to PCF8574. Double check if all
|
||||
* the bits (pins) from PCF8574 connected to the LCD controller
|
||||
* are correct with with this LCD CFG definition.
|
||||
*/
|
||||
|
||||
cfg.rows = 2;
|
||||
cfg.cols = 16;
|
||||
|
||||
/* Initialize the I2C1 */
|
||||
|
||||
i2c = stm32_i2cbus_initialize(LCDBP_I2C_PORTNO);
|
||||
if (i2c == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_I2C_DRIVER
|
||||
/* Register the I2C to get the "nsh> i2c bus" command working */
|
||||
|
||||
ret = i2c_register(i2c, LCDBP_I2C_PORTNO);
|
||||
if (ret < 0)
|
||||
{
|
||||
rtcerr("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Register the LCD BACKPACK PCF8574 driver at the specified location. */
|
||||
|
||||
ret = pcf8574_lcd_backpack_register(devpath, i2c, &cfg);
|
||||
if (ret < 0)
|
||||
{
|
||||
lcderr("ERROR: pcf8574_lcd_backpack_register(%s) failed: %d\n",
|
||||
devpath, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_I2C && CONFIG_LCD_BACKPACK */
|
@ -440,6 +440,18 @@ int stm32_apa102init(FAR const char *devpath);
|
||||
int stm32_mcp2515initialize(FAR const char *devpath);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_lcd_backpack_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the PCF8574 LCD Backpack driver.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_LCD_BACKPACK
|
||||
int stm32_lcd_backpack_init(FAR const char *devpath);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_usbinitialize
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user