stm32h7/linum-stm32h753bi: Add support to eeprom using the i2c3
Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
parent
b4b7710c63
commit
4b5ad956c3
@ -225,7 +225,7 @@ The LINUM-STM32H753BI connects the EEPROM memory and the touchscreen sensor to I
|
||||
EEPROM MEMORY
|
||||
--------------
|
||||
|
||||
EEPROM memory used is the 24LC256 with 256Kb.
|
||||
EEPROM memory used is the 24LC256 with 256Kb with the control bytes value 0x54.
|
||||
|
||||
TOUCHSCREEN SENSOR
|
||||
------------------
|
||||
@ -447,3 +447,14 @@ The SD card can then be mounted by the NSH commands::
|
||||
test_file.txt
|
||||
nsh> cat /mnt/test_file.txt
|
||||
Hello World!!
|
||||
|
||||
eeprom
|
||||
------
|
||||
|
||||
Use dd command to write and read data from EEPROM as below:::
|
||||
|
||||
nsh> dd if=/dev/console of=/dev/eeprom bs=1 count=35
|
||||
Witte-Tech Linum-STM32H753BI board
|
||||
nsh> dd if=/dev/eeprom of=/dev/console bs=4 count=35
|
||||
Witte-Tech Linum-STM32H753BI board
|
||||
nsh>
|
@ -0,0 +1,60 @@
|
||||
#
|
||||
# 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_STANDARD_SERIAL is not set
|
||||
# CONFIG_STM32H7_USE_LEGACY_PINMAP is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="linum-stm32h753bi"
|
||||
CONFIG_ARCH_BOARD_LINUM_STM32H753BI=y
|
||||
CONFIG_ARCH_CHIP="stm32h7"
|
||||
CONFIG_ARCH_CHIP_STM32H753BI=y
|
||||
CONFIG_ARCH_CHIP_STM32H7=y
|
||||
CONFIG_ARCH_CHIP_STM32H7_CORTEXM7=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_FEATURES=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_EEPROM=y
|
||||
CONFIG_EXAMPLES_ALARM=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_EE_24XX=y
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBM=y
|
||||
CONFIG_MM_REGIONS=4
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_DISABLE_IFUPDOWN=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=245760
|
||||
CONFIG_RAM_START=0x20010000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_RTC_ALARM=y
|
||||
CONFIG_RTC_DATETIME=y
|
||||
CONFIG_RTC_DRIVER=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32H7_I2C3=y
|
||||
CONFIG_STM32H7_PWR=y
|
||||
CONFIG_STM32H7_RTC=y
|
||||
CONFIG_STM32H7_USART1=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_USART1_SERIAL_CONSOLE=y
|
@ -382,21 +382,19 @@
|
||||
#define GPIO_OTGFS_DM (GPIO_OTGFS_DM_0 | GPIO_SPEED_100MHz)
|
||||
#define GPIO_OTGFS_DP (GPIO_OTGFS_DP_0 | GPIO_SPEED_100MHz)
|
||||
|
||||
/* SDMMC1 Pin mapping
|
||||
* CLK - PC12
|
||||
* CMD - PD2
|
||||
* D0 - PC8
|
||||
* D1 - PC9
|
||||
* D2 - PC10
|
||||
* D3 - PC11
|
||||
*/
|
||||
/* SDMMC1 - Used SD Card memory */
|
||||
|
||||
#define GPIO_SDMMC1_CK (GPIO_SDMMC1_CK_0 | GPIO_SPEED_100MHz)
|
||||
#define GPIO_SDMMC1_CMD (GPIO_SDMMC1_CMD_0 | GPIO_SPEED_100MHz)
|
||||
#define GPIO_SDMMC1_D0 (GPIO_SDMMC1_D0_0 | GPIO_SPEED_100MHz)
|
||||
#define GPIO_SDMMC1_D1 (GPIO_SDMMC1_D1_0 | GPIO_SPEED_100MHz)
|
||||
#define GPIO_SDMMC1_D2 (GPIO_SDMMC1_D2_0 | GPIO_SPEED_100MHz)
|
||||
#define GPIO_SDMMC1_D3 (GPIO_SDMMC1_D3_0 | GPIO_SPEED_100MHz)
|
||||
#define GPIO_SDMMC1_CK (GPIO_SDMMC1_CK_0 | GPIO_SPEED_100MHz) /* PC12 */
|
||||
#define GPIO_SDMMC1_CMD (GPIO_SDMMC1_CMD_0 | GPIO_SPEED_100MHz) /* PD2 */
|
||||
#define GPIO_SDMMC1_D0 (GPIO_SDMMC1_D0_0 | GPIO_SPEED_100MHz) /* PC8 */
|
||||
#define GPIO_SDMMC1_D1 (GPIO_SDMMC1_D1_0 | GPIO_SPEED_100MHz) /* PC9 */
|
||||
#define GPIO_SDMMC1_D2 (GPIO_SDMMC1_D2_0 | GPIO_SPEED_100MHz) /* PC10 */
|
||||
#define GPIO_SDMMC1_D3 (GPIO_SDMMC1_D3_0 | GPIO_SPEED_100MHz) /* PC11 */
|
||||
|
||||
/* I2C3 - Used by eeprom memory */
|
||||
|
||||
#define GPIO_I2C3_SCL (GPIO_I2C3_SCL_2 | GPIO_SPEED_100MHz) /* PH7 */
|
||||
#define GPIO_I2C3_SDA (GPIO_I2C3_SDA_2 | GPIO_SPEED_100MHz) /* PH8 */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
|
@ -44,6 +44,10 @@ if(CONFIG_FAT_DMAMEMORY)
|
||||
list(APPEND SRCS stm32_dma_alloc.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_I2C_EE_24XX)
|
||||
list(APPEND SRCS stm32_at24.c)
|
||||
endif()
|
||||
|
||||
target_sources(board PRIVATE ${SRCS})
|
||||
|
||||
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")
|
||||
|
@ -42,6 +42,10 @@ ifeq ($(CONFIG_FAT_DMAMEMORY),y)
|
||||
CSRCS += stm32_dma_alloc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_I2C_EE_24XX),y)
|
||||
CSRCS += stm32_at24.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BOARDCTL),y)
|
||||
CSRCS += stm32_appinitialize.c
|
||||
endif
|
||||
|
@ -160,4 +160,16 @@ int stm32_dma_alloc_init(void);
|
||||
int stm32_sdio_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_at24_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the EEPROM for 24XX driver.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_I2C_EE_24XX
|
||||
int stm32_at24_init(char *path);
|
||||
#endif
|
||||
|
||||
#endif /* __BOARDS_ARM_STM32H7_LINUM_STM32H753BI_SRC_LINUM_STM32H753BI_H */
|
||||
|
96
boards/arm/stm32h7/linum-stm32h753bi/src/stm32_at24.c
Normal file
96
boards/arm/stm32h7/linum-stm32h753bi/src/stm32_at24.c
Normal file
@ -0,0 +1,96 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32h7/linum-stm32h753bi/src/stm32_at24.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
#include <nuttx/eeprom/i2c_xx24xx.h>
|
||||
#include "stm32_i2c.h"
|
||||
|
||||
#include "linum-stm32h753bi.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define AT24_I2C_BUS 3 /* EEPROM chip is configured to use I2C3 */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_at24_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize and configure the AT24 serial EEPROM
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_at24_init(char *path)
|
||||
{
|
||||
FAR struct i2c_master_s *i2c;
|
||||
static bool initialized = false;
|
||||
int ret;
|
||||
|
||||
/* Have we already initialized? */
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
/* No.. Get the I2C bus driver */
|
||||
|
||||
finfo("Initialize I2C%d\n", AT24_I2C_BUS);
|
||||
i2c = stm32_i2cbus_initialize(AT24_I2C_BUS);
|
||||
if (!i2c)
|
||||
{
|
||||
ferr("ERROR: Failed to initialize I2C%d\n", AT24_I2C_BUS);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Now bind the I2C interface to the AT24 I2C EEPROM driver */
|
||||
|
||||
finfo("Bind the AT24 EEPROM driver to I2C%d\n", AT24_I2C_BUS);
|
||||
ret = ee24xx_initialize(i2c, 0x54, path, EEPROM_24XX256, false);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: Failed to bind I2C%d to the AT24 EEPROM driver\n",
|
||||
AT24_I2C_BUS);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Now we are initialized */
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32_i2c.h"
|
||||
|
||||
#include "linum-stm32h753bi.h"
|
||||
|
||||
@ -48,6 +49,58 @@
|
||||
* 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)
|
||||
{
|
||||
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_I2C3
|
||||
stm32_i2c_register(3);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32H7_I2C4
|
||||
stm32_i2c_register(4);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -142,5 +195,18 @@ int stm32_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
|
||||
stm32_i2ctool();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_I2C_EE_24XX
|
||||
ret = stm32_at24_init("/dev/eeprom");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize EEPROM HX24LCXXB: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -873,7 +873,7 @@ int ee24xx_initialize(FAR struct i2c_master_s *bus, uint8_t devaddr,
|
||||
}
|
||||
}
|
||||
|
||||
finfo("EEPROM device %s, %d bytes, %d per page, addrlen %d, %s\n",
|
||||
finfo("EEPROM device %s, %" PRIu32 " bytes, %d per page, addrlen %d, %s\n",
|
||||
devname, eedev->size, eedev->pgsize, eedev->addrlen,
|
||||
eedev->readonly ? "readonly" : "");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user