boards/nrf52840-dk: add MX25 QSPI memory support
This commit is contained in:
parent
cc7826df4d
commit
4f86a62f91
45
boards/arm/nrf52/nrf52840-dk/configs/qspi/defconfig
Normal file
45
boards/arm/nrf52/nrf52840-dk/configs/qspi/defconfig
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# 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_NSH_DISABLE_IFCONFIG is not set
|
||||
# CONFIG_NSH_DISABLE_PS is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="nrf52840-dk"
|
||||
CONFIG_ARCH_BOARD_NRF52840_DK=y
|
||||
CONFIG_ARCH_CHIP="nrf52"
|
||||
CONFIG_ARCH_CHIP_NRF52840=y
|
||||
CONFIG_ARCH_CHIP_NRF52=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_STDARG_H=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=5500
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_FS_LITTLEFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=4098
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_MTD=y
|
||||
CONFIG_MTD_MX25RXX=y
|
||||
CONFIG_NRF52_QSPI=y
|
||||
CONFIG_NRF52_UART0=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=65535
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=26
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
@ -165,4 +165,22 @@
|
||||
#define NRF52_ADC_CH2_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(28))
|
||||
#define NRF52_ADC_CH3_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(29))
|
||||
|
||||
/* QSPI Pins ****************************************************************/
|
||||
|
||||
/* QSPI0
|
||||
* QSPI CS - P0.17
|
||||
* QSPI SCK - P0.19
|
||||
* QSPI IO0 - P0.20
|
||||
* QSPI IO1 - P0.21
|
||||
* QSPI IO2 - P0.22
|
||||
* QSPI IO3 - P0.23
|
||||
*/
|
||||
|
||||
#define NRF52_QSPI0_CSN_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(17))
|
||||
#define NRF52_QSPI0_SCK_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(19))
|
||||
#define NRF52_QSPI0_IO0_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(20))
|
||||
#define NRF52_QSPI0_IO1_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(21))
|
||||
#define NRF52_QSPI0_IO2_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(22))
|
||||
#define NRF52_QSPI0_IO3_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(23))
|
||||
|
||||
#endif /* __BOARDS_ARM_NRF52_NRF52840_DK_INCLUDE_BOARD_H */
|
||||
|
@ -82,4 +82,8 @@ ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
|
||||
CSRCS += nrf52_composite.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NRF52_QSPI),y)
|
||||
CSRCS += nrf52_mx25.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/boards/Board.mk
|
||||
|
@ -201,5 +201,17 @@ int nrf52_pwm_setup(void);
|
||||
int nrf52_adc_setup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nrf52_mx25_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the MX25RXX QSPI memeory
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NRF52_QSPI
|
||||
int nrf52_mx25_initialize(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_ARM_NRF52_NRF52840_DK_SRC_NRF52840_DK_H */
|
||||
|
@ -261,9 +261,18 @@ int nrf52_bringup(void)
|
||||
usbdev_rndis_initialize(mac);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NRF52_QSPI
|
||||
/* Initialize the MX25 QSPU memory */
|
||||
|
||||
ret = nrf52_mx25_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: nrf52_mx25_initialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NRF52_SOFTDEVICE_CONTROLLER
|
||||
ret = nrf52_sdc_initialize();
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: nrf52_sdc_initialize() failed: %d\n", ret);
|
||||
|
107
boards/arm/nrf52/nrf52840-dk/src/nrf52_mx25.c
Normal file
107
boards/arm/nrf52/nrf52840-dk/src/nrf52_mx25.c
Normal file
@ -0,0 +1,107 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/nrf52/nrf52840-dk/src/nrf52_mx25.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 <debug.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
#include <nuttx/spi/qspi.h>
|
||||
|
||||
#include "nrf52_qspi.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nrf52_mx25_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the MX25RXX QSPI memeory
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nrf52_mx25_initialize(void)
|
||||
{
|
||||
struct qspi_dev_s *qspi_dev;
|
||||
struct mtd_dev_s *mtd_dev;
|
||||
char blockdev[32];
|
||||
int ret = -1;
|
||||
|
||||
/* Create an instance of the NRF52 QSPI device driver */
|
||||
|
||||
qspi_dev = nrf52_qspi_initialize(0);
|
||||
if (!qspi_dev)
|
||||
{
|
||||
_err("nrf52_qspi_initialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
_info("nrf52_qspi_initialize() successful\n");
|
||||
|
||||
/* Use the QSPI device instance to initialize the MX25 device */
|
||||
|
||||
mtd_dev = mx25rxx_initialize(qspi_dev, true);
|
||||
if (!mtd_dev)
|
||||
{
|
||||
_err("mx25rxx_initialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure the device with no partition support */
|
||||
|
||||
snprintf(blockdev, sizeof(blockdev), "/dev/mtdqspi%d", 0);
|
||||
|
||||
ret = register_mtddriver(blockdev, mtd_dev, 0755, NULL);
|
||||
if (ret != OK)
|
||||
{
|
||||
_err("register_mtddriver() failed: %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
_info("register_mtddriver() successful\n");
|
||||
|
||||
#ifdef CONFIG_FS_LITTLEFS
|
||||
ret = nx_mount(blockdev, "/mnt/qspi", "littlefs", 0, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = nx_mount(blockdev, "/mnt/qspi", "littlefs", 0,
|
||||
"forceformat");
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("nx_mount() failed: %d\n", ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
_info("nx_mount() successful\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue
Block a user