forked from xuos/xiuos
support Register gpio as character device on nuttx for xidatong from Wang_guozhu
it is OK
This commit is contained in:
commit
f46cacc158
|
@ -92,10 +92,11 @@ void PrivTaskQuit(void *value_ptr)
|
|||
|
||||
int PrivTaskDelay(int32_t ms)
|
||||
{
|
||||
return usleep(ms);
|
||||
return usleep(1000 * ms);
|
||||
}
|
||||
|
||||
uint32_t PrivGetTickTime(){
|
||||
uint32_t PrivGetTickTime(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
||||
|
|
|
@ -192,7 +192,7 @@ int PrivTaskStartup(pthread_t *thread);
|
|||
int PrivTaskDelete(pthread_t thread, int sig);
|
||||
void PrivTaskQuit(void *value_ptr);
|
||||
int PrivTaskDelay(int32_t ms);
|
||||
uint32_t PrivGetTickTime();
|
||||
uint32_t PrivGetTickTime(void);
|
||||
|
||||
/*********************driver*************************/
|
||||
|
||||
|
|
|
@ -24,34 +24,34 @@ config XIDATONG_SDRAM
|
|||
---help---
|
||||
Activate DCD configuration of SDRAM
|
||||
|
||||
config XIDATONG_SDHC_AUTOMOUNT
|
||||
bool "SDHC automounter"
|
||||
config XIDATONG_SDIO_AUTOMOUNT
|
||||
bool "SD card automounter"
|
||||
default n
|
||||
depends on FS_AUTOMOUNTER && IMXRT_USDHC
|
||||
|
||||
if XIDATONG_SDHC_AUTOMOUNT
|
||||
if XIDATONG_SDIO_AUTOMOUNT
|
||||
|
||||
config XIDATONG_SDHC_AUTOMOUNT_FSTYPE
|
||||
string "SDHC file system type"
|
||||
config XIDATONG_SDIO_AUTOMOUNT_FSTYPE
|
||||
string "SD card file system type"
|
||||
default "vfat"
|
||||
|
||||
config XIDATONG_SDHC_AUTOMOUNT_BLKDEV
|
||||
string "SDHC block device"
|
||||
config XIDATONG_SDIO_AUTOMOUNT_BLKDEV
|
||||
string "SD card block device"
|
||||
default "/dev/mmcsd0"
|
||||
|
||||
config XIDATONG_SDHC_AUTOMOUNT_MOUNTPOINT
|
||||
string "SDHC mount point"
|
||||
config XIDATONG_SDIO_AUTOMOUNT_MOUNTPOINT
|
||||
string "SD card mount point"
|
||||
default "/mnt/sdcard"
|
||||
|
||||
config XIDATONG_SDHC_AUTOMOUNT_DDELAY
|
||||
int "SDHC debounce delay (milliseconds)"
|
||||
config XIDATONG_SDIO_AUTOMOUNT_DDELAY
|
||||
int "SD card debounce delay (milliseconds)"
|
||||
default 1000
|
||||
|
||||
config XIDATONG_SDHC_AUTOMOUNT_UDELAY
|
||||
int "SDHC unmount retry delay (milliseconds)"
|
||||
config XIDATONG_SDIO_AUTOMOUNT_UDELAY
|
||||
int "SD card unmount retry delay (milliseconds)"
|
||||
default 2000
|
||||
|
||||
endif # XIDATONG_SDHC_AUTOMOUNT
|
||||
endif # XIDATONG_SDIO_AUTOMOUNT
|
||||
|
||||
config XIDATONG_USB_AUTOMOUNT
|
||||
bool "USB Mass Storage automounter"
|
||||
|
|
|
@ -44,4 +44,5 @@ CONFIG_START_DAY=8
|
|||
CONFIG_START_MONTH=6
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYS_RESERVED=9
|
||||
CONFIG_DEV_GPIO=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
|
@ -43,4 +43,5 @@ CONFIG_SCHED_WAITPID=y
|
|||
CONFIG_START_DAY=14
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_DEV_GPIO=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
|
@ -65,4 +65,5 @@ CONFIG_START_MONTH=3
|
|||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING6=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_DEV_GPIO=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
|
@ -41,4 +41,5 @@ CONFIG_SCHED_WAITPID=y
|
|||
CONFIG_START_DAY=14
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_DEV_GPIO=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
|
@ -29,6 +29,7 @@ CONFIG_IDLETHREAD_STACKSIZE=2048
|
|||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_IMXRT_GPIO2_16_31_IRQ=y
|
||||
CONFIG_IMXRT_GPIO_IRQ=y
|
||||
CONFIG_DEV_GPIO=y
|
||||
CONFIG_IMXRT_LPUART1=y
|
||||
CONFIG_IMXRT_USDHC1=y
|
||||
CONFIG_IMXRT_USDHC1_WIDTH_D1_D4=y
|
||||
|
|
|
@ -61,4 +61,5 @@ CONFIG_USBDEV=y
|
|||
CONFIG_USBHOST=y
|
||||
CONFIG_USBHOST_MSC=y
|
||||
CONFIG_USBHOST_MSC_NOTIFIER=y
|
||||
CONFIG_DEV_GPIO=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
|
@ -70,8 +70,12 @@ ifeq ($(CONFIG_USBHOST),y)
|
|||
CSRCS += imxrt_usbhost.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_XIDATONG_SDHC_AUTOMOUNT),y)
|
||||
CSRCS += imxrt_sdhc_automount.c
|
||||
ifeq ($(CONFIG_IMXRT_USDHC),y)
|
||||
CSRCS += imxrt_mmcsd.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_XIDATONG_SDIO_AUTOMOUNT),y)
|
||||
CSRCS += imxrt_mmcsd_automount.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/boards/Board.mk
|
||||
|
|
|
@ -43,10 +43,6 @@
|
|||
#include <imxrt_lpi2c.h>
|
||||
#include <imxrt_lpspi.h>
|
||||
|
||||
#ifdef CONFIG_IMXRT_USDHC
|
||||
# include "imxrt_usdhc.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBMONITOR
|
||||
# include <nuttx/usb/usbmonitor.h>
|
||||
#endif
|
||||
|
@ -94,45 +90,6 @@ static void imxrt_i2c_register(int bus)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IMXRT_USDHC
|
||||
static int nsh_sdmmc_initialize(void)
|
||||
{
|
||||
struct sdio_dev_s *sdmmc;
|
||||
int ret = 0;
|
||||
|
||||
/* Get an instance of the SDIO interface */
|
||||
|
||||
sdmmc = imxrt_usdhc_initialize(0);
|
||||
if (!sdmmc)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize SD/MMC\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Bind the SDIO interface to the MMC/SD driver */
|
||||
|
||||
ret = mmcsd_slotinitialize(0, sdmmc);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n",
|
||||
ret);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_XIDATONG_SDHC_AUTOMOUNT
|
||||
imxrt_automount_initialize();
|
||||
imxrt_usdhc_set_sdio_card_isr(sdmmc, imxrt_sdhc_automount_event, NULL);
|
||||
#else
|
||||
imxrt_usdhc_set_sdio_card_isr(sdmmc, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
#else
|
||||
# define nsh_sdmmc_initialize() (OK)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -110,10 +110,8 @@ static const struct gpio_operations_s gpout_ops =
|
|||
|
||||
static const uint32_t g_gpiooutputs[BOARD_NGPIOOUT] =
|
||||
{
|
||||
GPIO_GOUT1,
|
||||
GPIO_GOUT2,
|
||||
GPIO_GOUT3,
|
||||
GPIO_GOUT4,
|
||||
GPIO_E220_M0,
|
||||
GPIO_E220_M1,
|
||||
};
|
||||
|
||||
static struct imxrtgpio_dev_s g_gpout[BOARD_NGPIOOUT];
|
||||
|
@ -177,10 +175,11 @@ static int gpout_write(FAR struct gpio_dev_s *dev, bool value)
|
|||
|
||||
int imxrt_gpio_initialize(void)
|
||||
{
|
||||
int pincount = 0;
|
||||
int pincount;
|
||||
int i;
|
||||
|
||||
#if BOARD_NGPIOIN > 0
|
||||
pincount = 0;
|
||||
for (i = 0; i < BOARD_NGPIOIN; i++)
|
||||
{
|
||||
/* Setup and register the GPIO pin */
|
||||
|
@ -200,6 +199,7 @@ int imxrt_gpio_initialize(void)
|
|||
#endif
|
||||
|
||||
#if BOARD_NGPIOOUT > 0
|
||||
pincount = 0;
|
||||
for (i = 0; i < BOARD_NGPIOOUT; i++)
|
||||
{
|
||||
/* Setup and register the GPIO pin */
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file imxrt_sdhc_automount.c
|
||||
* @brief imxrt board sd card automount
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.04.12
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "xidatong.h"
|
||||
|
||||
#ifdef CONFIG_IMXRT_USDHC
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_sdmmc_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the SDHC SD card slot
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_sdmmc_initialize(void)
|
||||
{
|
||||
struct sdio_dev_s *sdmmc;
|
||||
int ret = 0;
|
||||
|
||||
/* Get an instance of the SDIO interface */
|
||||
|
||||
sdmmc = imxrt_usdhc_initialize(0);
|
||||
if (!sdmmc)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize SD/MMC\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
/* Bind the SDIO interface to the MMC/SD driver */
|
||||
|
||||
ret = mmcsd_slotinitialize(0, sdmmc);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_XIDATONG_SDIO_AUTOMOUNT
|
||||
imxrt_automount_initialize();
|
||||
imxrt_usdhc_set_sdio_card_isr(sdmmc, imxrt_sdhc_automount_event, NULL);
|
||||
#else
|
||||
imxrt_usdhc_set_sdio_card_isr(sdmmc, NULL, NULL);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
|
@ -94,11 +94,11 @@ static const struct imxrt_automount_config_s g_sdhc_config =
|
|||
{
|
||||
.lower =
|
||||
{
|
||||
.fstype = CONFIG_XIDATONG_SDHC_AUTOMOUNT_FSTYPE,
|
||||
.blockdev = CONFIG_XIDATONG_SDHC_AUTOMOUNT_BLKDEV,
|
||||
.mountpoint = CONFIG_XIDATONG_SDHC_AUTOMOUNT_MOUNTPOINT,
|
||||
.ddelay = MSEC2TICK(CONFIG_XIDATONG_SDHC_AUTOMOUNT_DDELAY),
|
||||
.udelay = MSEC2TICK(CONFIG_XIDATONG_SDHC_AUTOMOUNT_UDELAY),
|
||||
.fstype = CONFIG_XIDATONG_SDIO_AUTOMOUNT_FSTYPE,
|
||||
.blockdev = CONFIG_XIDATONG_SDIO_AUTOMOUNT_BLKDEV,
|
||||
.mountpoint = CONFIG_XIDATONG_SDIO_AUTOMOUNT_MOUNTPOINT,
|
||||
.ddelay = MSEC2TICK(CONFIG_XIDATONG_SDIO_AUTOMOUNT_DDELAY),
|
||||
.udelay = MSEC2TICK(CONFIG_XIDATONG_SDIO_AUTOMOUNT_UDELAY),
|
||||
.attach = imxrt_sdhc_attach,
|
||||
.enable = imxrt_sdhc_enable,
|
||||
.inserted = imxrt_sdhc_inserted
|
|
@ -67,21 +67,15 @@
|
|||
/* Test Pins ****************************************************************/
|
||||
|
||||
#define BOARD_NGPIOIN 0 /* Amount of GPIO Input pins */
|
||||
#define BOARD_NGPIOOUT 4 /* Amount of GPIO Output pins */
|
||||
#define BOARD_NGPIOOUT 2 /* Amount of GPIO Output pins */
|
||||
#define BOARD_NGPIOINT 0 /* Amount of GPIO Input w/ Interruption pins */
|
||||
|
||||
#define GPIO_GOUT1 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | IOMUX_GOUT_DEFAULT | \
|
||||
GPIO_PORT1 | GPIO_PIN19)
|
||||
|
||||
#define GPIO_GOUT2 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | IOMUX_GOUT_DEFAULT | \
|
||||
GPIO_PIN18 | GPIO_PORT1)
|
||||
|
||||
#define GPIO_GOUT3 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | IOMUX_GOUT_DEFAULT | \
|
||||
GPIO_PIN10 | GPIO_PORT1)
|
||||
|
||||
#define GPIO_GOUT4 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | IOMUX_GOUT_DEFAULT | \
|
||||
#define GPIO_E220_M0 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | IOMUX_GOUT_DEFAULT | \
|
||||
GPIO_PIN9 | GPIO_PORT1)
|
||||
|
||||
#define GPIO_E220_M1 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | IOMUX_GOUT_DEFAULT | \
|
||||
GPIO_PIN11 | GPIO_PORT1)
|
||||
|
||||
/* Backlight */
|
||||
|
||||
#define GPIO_LCD_BL (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT2 | \
|
||||
|
@ -210,11 +204,13 @@ int imxrt_gpio_initialize(void);
|
|||
int imxrt_usbhost_initialize(void);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_IMXRT_USBOTG) || defined(CONFIG_USBHOST)
|
||||
int imxrt_mmcsd_initialize(void);
|
||||
#ifdef CONFIG_IMXRT_USDHC
|
||||
int nsh_sdmmc_initialize(void);
|
||||
#else
|
||||
# define nsh_sdmmc_initialize() (OK)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_XIDATONG_SDHC_AUTOMOUNT
|
||||
#if defined(CONFIG_IMXRT_USDHC) && defined(CONFIG_XIDATONG_SDIO_AUTOMOUNT)
|
||||
int imxrt_sdhc_automount_event(void *arg);
|
||||
void imxrt_automount_initialize(void);
|
||||
#endif
|
||||
|
|
|
@ -652,7 +652,7 @@ config NSH_DISABLE_RECVZIGBEE
|
|||
default n
|
||||
|
||||
config NSH_DISABLE_ADAPTER_LORATEST
|
||||
bool "Disable sx128 AdapterLoraTest."
|
||||
bool "Disable sx1278 AdapterLoraTest."
|
||||
default n
|
||||
|
||||
config NSH_DISABLE_K210_FFT
|
||||
|
|
Loading…
Reference in New Issue