Merged in raiden00/nuttx_h7/sensors (pull request #863)

Add some I2C devices to nucleo-h743zi and a few small fixes

configs/nucleo-h743zi: add support for ssd1306

configs/nucleo-h743zi: add support for pca9635

configs/nucleo-h743zi: add support for i2ctools

include/nuttx/sensors/lsm6dsl.h: remove whitespaces

configs/stm32f103-minimum/src/stm32_ssd1306.c: cosmetics

Documentation/NuttxPortingGuide.html: vsyslog return none

drivers/syslog/README.txt: vsyslog return none

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
raiden00pl 2019-04-28 12:36:55 +00:00 committed by Gregory Nutt
parent 2b81d0dbb3
commit e1e1e0a8db
13 changed files with 678 additions and 130 deletions

View File

@ -6470,7 +6470,7 @@ int kbd_decode(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *sta
<ul><pre> <ul><pre>
#include &lt;syslog.h&gt; #include &lt;syslog.h&gt;
int syslog(int priority, FAR const IPTR char *format, ...); int syslog(int priority, FAR const IPTR char *format, ...);
int vsyslog(int priority, FAR const IPTR char *src, va_list ap); void vsyslog(int priority, FAR const IPTR char *src, va_list ap);
</pre></ul> </pre></ul>
<p><b>Description:</b> <p><b>Description:</b>
<code>syslog()</code> generates a log message. The priority argument is formed by ORing the facility and the level values (see <code>include/syslog.h</code>). The remaining arguments are a format, as in <code>printf()</code> and any arguments to the format. <code>syslog()</code> generates a log message. The priority argument is formed by ORing the facility and the level values (see <code>include/syslog.h</code>). The remaining arguments are a format, as in <code>printf()</code> and any arguments to the format.

View File

@ -321,10 +321,16 @@
#define GPIO_USART6_RX GPIO_USART6_RX_2 /* PG9 */ #define GPIO_USART6_RX GPIO_USART6_RX_2 /* PG9 */
#define GPIO_USART6_TX GPIO_USART6_TX_2 /* PG14 */ #define GPIO_USART6_TX GPIO_USART6_TX_2 /* PG14 */
/* I2C1 Use Nucleo I2C pins */ /* I2C1 Use Nucleo I2C1 pins */
#define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 /* PB8 */ #define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 /* PB8 - D15 */
#define GPIO_I2C1_SDA GPIO_I2C1_SDA_2 /* PB9 */ #define GPIO_I2C1_SDA GPIO_I2C1_SDA_2 /* PB9 - D14 */
/* I2C2 Use Nucleo I2C2 pins */
#define GPIO_I2C2_SCL GPIO_I2C2_SCL_2 /* PF1 - D69 */
#define GPIO_I2C2_SDA GPIO_I2C2_SDA_2 /* PF0 - D68 */
#define GPIO_I2C2_SMBA GPIO_I2C2_SMBA_2 /* PF2 - D70 */
/* SPI3 */ /* SPI3 */

View File

@ -0,0 +1,76 @@
#
# 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_ARCH_FPU is not set
# CONFIG_EXAMPLES_NXLINES_DEFAULT_COLORS is not set
# CONFIG_NSH_DISABLE_IFCONFIG is not set
# CONFIG_NSH_DISABLE_PS is not set
# CONFIG_NX_DISABLE_1BPP is not set
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="nucleo-h743zi"
CONFIG_ARCH_BOARD_NUCLEO_H743ZI=y
CONFIG_ARCH_CHIP_STM32H743ZI=y
CONFIG_ARCH_CHIP_STM32H7=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
CONFIG_ARMV7M_DTCM=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_BOARD_LOOPSPERMSEC=43103
CONFIG_BUILTIN=y
CONFIG_DEBUG_NOOPT=y
CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NXLINES=y
CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=1
CONFIG_EXAMPLES_NXLINES_BPP=1
CONFIG_EXAMPLES_NXLINES_LINECOLOR=0xff
CONFIG_EXAMPLES_NXLINES_LINEWIDTH=1
CONFIG_EXPERIMENTAL=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LCD=y
CONFIG_LCD_MAXCONTRAST=255
CONFIG_LCD_SH1106_OLED_132=y
CONFIG_LCD_SSD1306_I2C=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=3
CONFIG_MQ_MAXMSGSIZE=128
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_NX=y
CONFIG_NXFONTS_DISABLE_1BPP=y
CONFIG_NXFONT_MONO5X8=y
CONFIG_NX_BLOCKING=y
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=4
CONFIG_RAM_SIZE=245760
CONFIG_RAM_START=0x20010000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_STM32H7_I2C2=y
CONFIG_STM32H7_USART3=y
CONFIG_SYSLOG_NONE=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_NSH_CXXINITIALIZE=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WDOG_INTRESERVE=0

View File

@ -60,10 +60,22 @@ ifeq ($(CONFIG_SENSORS_LSM6DSL),y)
CSRCS += stm32_lsm6dsl.c CSRCS += stm32_lsm6dsl.c
endif endif
ifeq ($(CONFIG_SENSORS_LSM9DS1),y)
CSRCS += stm32_lsm9ds1.c
endif
ifeq ($(CONFIG_SENSORS_LSM303AGR),y) ifeq ($(CONFIG_SENSORS_LSM303AGR),y)
CSRCS += stm32_lsm303agr.c CSRCS += stm32_lsm303agr.c
endif endif
ifeq ($(CONFIG_PCA9635PW),y)
CSRCS += stm32_pca9635.c
endif
ifeq ($(CONFIG_LCD_SSD1306),y)
CSRCS += stm32_ssd1306.c
endif
ifeq ($(CONFIG_LIB_BOARDCTL),y) ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += stm32_appinitialize.c CSRCS += stm32_appinitialize.c
endif endif

View File

@ -133,6 +133,19 @@
GPIO_OUTPUT_CLEAR | GPIO_PORTF | GPIO_PIN12) GPIO_OUTPUT_CLEAR | GPIO_PORTF | GPIO_PIN12)
#define GPIO_NRF24L01_IRQ (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTD | GPIO_PIN15) #define GPIO_NRF24L01_IRQ (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTD | GPIO_PIN15)
/* LMS9DS1 configuration */
#define LMS9DS1_I2CBUS 1
/* PCA9635 configuration */
#define PCA9635_I2CBUS 1
#define PCA9635_I2CADDR 0x40
/* Oled configuration */
#define OLED_I2C_PORT 2
/************************************************************************************ /************************************************************************************
* Public Functions * Public Functions
************************************************************************************/ ************************************************************************************/
@ -225,4 +238,26 @@ int stm32_lsm303agr_initialize(char *devpath);
int stm32_wlinitialize(void); int stm32_wlinitialize(void);
#endif #endif
/*****************************************************************************
* Name: stm32_lsm9ds1_initialize
*
* Description:
* Initialize I2C-based LSM9DS1.
****************************************************************************/
#ifdef CONFIG_SENSORS_LSM9DS1
int stm32_lsm9ds1_initialize(char *devpath);
#endif
/****************************************************************************
* Name: stm32_pca9635_initialize
*
* Description:
* Initialize I2C-based PCA9635PW LED driver.
****************************************************************************/
#ifdef CONFIG_PCA9635PW
int stm32_pca9635_initialize(void);
#endif
#endif /* __CONFIGS_NUCLEO_H743ZI_SRC_NUCLEO_H743ZI_H */ #endif /* __CONFIGS_NUCLEO_H743ZI_SRC_NUCLEO_H743ZI_H */

View File

@ -50,6 +50,68 @@
# include <nuttx/input/buttons.h> # include <nuttx/input/buttons.h>
#endif #endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
static void stm32_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = stm32_i2cbus_initialize(bus);
if (i2c == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n",
bus, ret);
stm32_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: stm32_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
static void stm32_i2ctool(void)
{
#ifdef CONFIG_STM32H7_I2C1
stm32_i2c_register(1);
#endif
#ifdef CONFIG_STM32H7_I2C2
stm32_i2c_register(2);
#endif
#ifdef CONFIG_STM32H7_I2C3
stm32_i2c_register(3);
#endif
#ifdef CONFIG_STM32H7_I2C4
stm32_i2c_register(4);
#endif
}
#endif
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@ -74,6 +136,10 @@ int stm32_bringup(void)
UNUSED(ret); UNUSED(ret);
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
stm32_i2ctool();
#endif
#ifdef CONFIG_FS_PROCFS #ifdef CONFIG_FS_PROCFS
#ifdef CONFIG_STM32_CCM_PROCFS #ifdef CONFIG_STM32_CCM_PROCFS
/* Register the CCM procfs entry. This must be done before the procfs is /* Register the CCM procfs entry. This must be done before the procfs is
@ -122,6 +188,14 @@ int stm32_bringup(void)
} }
#endif /* CONFIG_SENSORS_LSM6DSL */ #endif /* CONFIG_SENSORS_LSM6DSL */
#ifdef CONFIG_SENSORS_LSM9DS1
ret = stm32_lsm9ds1_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to initialize LSM9DS1 driver: %d\n", ret);
}
#endif /* CONFIG_SENSORS_LSM6DSL */
#ifdef CONFIG_SENSORS_LSM303AGR #ifdef CONFIG_SENSORS_LSM303AGR
ret = stm32_lsm303agr_initialize("/dev/lsm303mag0"); ret = stm32_lsm303agr_initialize("/dev/lsm303mag0");
if (ret < 0) if (ret < 0)
@ -130,6 +204,16 @@ int stm32_bringup(void)
} }
#endif /* CONFIG_SENSORS_LSM303AGR */ #endif /* CONFIG_SENSORS_LSM303AGR */
#ifdef CONFIG_PCA9635PW
/* Initialize the PCA9635 chip */
ret = stm32_pca9635_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_pca9635_initialize failed: %d\n", ret);
}
#endif
#ifdef CONFIG_WL_NRF24L01 #ifdef CONFIG_WL_NRF24L01
ret = stm32_wlinitialize(); ret = stm32_wlinitialize();
if (ret < 0) if (ret < 0)

View File

@ -86,7 +86,7 @@ int stm32_lsm6dsl_initialize(char *devpath)
sninfo("INFO: Initializing LMS6DSL accelero-gyro sensor over I2C%d\n", ret); sninfo("INFO: Initializing LMS6DSL accelero-gyro sensor over I2C%d\n", ret);
ret = lsm6dsl_sensor_register("/dev/lsm6dsl0", i2c, LSM6DSLACCEL_ADDR1); ret = lsm6dsl_sensor_register(devpath, i2c, LSM6DSLACCEL_ADDR1);
if (ret < 0) if (ret < 0)
{ {
snerr("ERROR: Failed to initialize LMS6DSL accelero-gyro driver %s\n", devpath); snerr("ERROR: Failed to initialize LMS6DSL accelero-gyro driver %s\n", devpath);

View File

@ -0,0 +1,114 @@
/*****************************************************************************
* configs/nucleo-h743zi/src/stm32_lsm9ds1.c
*
* Copyright (C) 2019 Greg Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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 <nuttx/arch.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include "stm32.h"
#include <nucleo-h743zi.h>
#include <nuttx/sensors/lsm9ds1.h>
/*****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_STM32H7_I2C1
# error "LSM9DS1 driver requires CONFIG_STM32H7_I2C1 to be enabled"
#endif
#define LSM9DS1MAG_DEVPATH "/dev/lsm9ds1mag0"
#define LSM9DS1ACC_DEVPATH "/dev/lsm9ds1acc0"
#define LSM9DS1GYR_DEVPATH "/dev/lsm9ds1gyr0"
/*****************************************************************************
* Public Functions
****************************************************************************/
/*****************************************************************************
* Name: stm32_lsm9ds1_initialize
*
* Description:
* Initialize I2C-based LSM9DS1.
****************************************************************************/
int stm32_lsm9ds1_initialize(void)
{
FAR struct i2c_master_s *i2c;
int ret = OK;
sninfo("Initializing LMS9DS1!\n");
#if defined(CONFIG_STM32H7_I2C1)
i2c = stm32_i2cbus_initialize(LMS9DS1_I2CBUS);
if (i2c == NULL)
{
return -ENODEV;
}
sninfo("INFO: Initializing LMS9DS1 9DoF sensor over I2C%d\n", LMS9DS1_I2CBUS);
ret = lsm9ds1mag_register(LSM9DS1MAG_DEVPATH, i2c, LSM9DS1MAG_ADDR1);
if (ret < 0)
{
snerr("ERROR: Failed to initialize LMS9DS1 mag driver %s\n", LSM9DS1MAG_DEVPATH);
return -ENODEV;
}
ret = lsm9ds1gyro_register(LSM9DS1GYR_DEVPATH, i2c, LSM9DS1GYRO_ADDR1);
if (ret < 0)
{
snerr("ERROR: Failed to initialize LMS9DS1 gyro driver %s\n", LSM9DS1MAG_DEVPATH);
return -ENODEV;
}
ret = lsm9ds1accel_register(LSM9DS1ACC_DEVPATH, i2c, LSM9DS1ACCEL_ADDR1);
if (ret < 0)
{
snerr("ERROR: Failed to initialize LMS9DS1 accel driver %s\n", LSM9DS1MAG_DEVPATH);
return -ENODEV;
}
sninfo("INFO: LMS9DS1 sensor has been initialized successfully\n");
#endif
return ret;
}

View File

@ -0,0 +1,98 @@
/************************************************************************************
* configs/nucleo-h743zi/src/stm32_pca9635.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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 <stdbool.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/leds/pca9635pw.h>
#include <arch/irq.h>
#include "stm32.h"
#include "nucleo-h743zi.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_pca9635_initialize
*
* Description:
* This function is called by board initialization logic to configure the
* LED PWM chip. This function will register the driver as /dev/leddrv0.
*
* Input Parameters:
* None
*
* Returned Value:
* Zero is returned on success. Otherwise, a negated errno value is
* returned to indicate the nature of the failure.
*
****************************************************************************/
int stm32_pca9635_initialize(void)
{
FAR struct i2c_master_s *i2c;
int ret;
/* Get the I2C driver that interfaces with the pca9635 */
i2c = stm32_i2cbus_initialize(PCA9635_I2CBUS);
if (!i2c)
{
_err("ERROR: Failed to initialize I2C%d\n", PCA9635_I2CBUS);
return -1;
}
ret = pca9635pw_register("/dev/leddrv0", i2c, PCA9635_I2CADDR);
if (ret < 0)
{
snerr("ERROR: Failed to register PCA9635 driver: %d\n", ret);
return ret;
}
return OK;
}

View File

@ -0,0 +1,123 @@
/****************************************************************************
* config/nucleo-h743zi/src/stm32_ssd1306.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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 <debug.h>
#include <nuttx/board.h>
#include <nuttx/lcd/lcd.h>
#include <nuttx/lcd/ssd1306.h>
#include <nuttx/i2c/i2c_master.h>
#include "stm32.h"
#include "nucleo-h743zi.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_LCD_MAXPOWER
# define CONFIG_LCD_MAXPOWER 1
#endif
/****************************************************************************
* Private Data
****************************************************************************/
FAR struct i2c_master_s *g_i2c;
FAR struct lcd_dev_s *g_lcddev;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_lcd_initialize
****************************************************************************/
int board_lcd_initialize(void)
{
/* Initialize I2C */
g_i2c = stm32_i2cbus_initialize(OLED_I2C_PORT);
if (!g_i2c)
{
lcderr("ERROR: Failed to initialize I2C port %d\n", OLED_I2C_PORT);
return -ENODEV;
}
return OK;
}
/****************************************************************************
* Name: board_lcd_getdev
****************************************************************************/
FAR struct lcd_dev_s *board_lcd_getdev(int devno)
{
/* Bind the I2C port to the OLED */
g_lcddev = ssd1306_initialize(g_i2c, NULL, devno);
if (!g_lcddev)
{
lcderr("ERROR: Failed to bind I2C port 1 to OLED %d: %d\n", devno);
}
else
{
lcdinfo("Bound I2C port %d to OLED %d\n", OLED_I2C_PORT, devno);
/* And turn the OLED on */
(void)g_lcddev->setpower(g_lcddev, CONFIG_LCD_MAXPOWER);
return g_lcddev;
}
return NULL;
}
/****************************************************************************
* Name: board_lcd_uninitialize
****************************************************************************/
void board_lcd_uninitialize(void)
{
/* TO-FIX */
}

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* config/stm32f103-minimum/src/sam_ug2832hsweg04.c * config/stm32f103-minimum/src/stm32_ssd1306.c
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -105,7 +105,7 @@ FAR struct lcd_dev_s *board_lcd_getdev(int devno)
g_lcddev = ssd1306_initialize(g_i2c, NULL, devno); g_lcddev = ssd1306_initialize(g_i2c, NULL, devno);
if (!g_lcddev) if (!g_lcddev)
{ {
lcderr("ERROR: Failed to bind SPI port 1 to OLED %d: %d\n", devno); lcderr("ERROR: Failed to bind I2C port 1 to OLED %d: %d\n", devno);
} }
else else
{ {

View File

@ -16,7 +16,7 @@ SYSLOG Interfaces
Prototypes: Prototypes:
int syslog(int priority, FAR const IPTR char *format, ...); int syslog(int priority, FAR const IPTR char *format, ...);
int vsyslog(int priority, FAR const IPTR char *src, va_list ap); void vsyslog(int priority, FAR const IPTR char *src, va_list ap);
Description: Description: