forked from xuos/xiuos
Register ch438 to character driver
This commit is contained in:
parent
d18eda5f26
commit
e007b5567d
|
@ -83,5 +83,43 @@ config XIDATONG_USB_AUTOMOUNT_UDELAY
|
||||||
|
|
||||||
endif # XIDATONG_USB_AUTOMOUNT
|
endif # XIDATONG_USB_AUTOMOUNT
|
||||||
|
|
||||||
|
menuconfig BSP_USING_CH438
|
||||||
|
bool "Using CH438 device"
|
||||||
|
default n
|
||||||
|
|
||||||
endif
|
if BSP_USING_CH438
|
||||||
|
config CH438_EXTUART0
|
||||||
|
bool "using ch438 port 0"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config CH438_EXTUART1
|
||||||
|
bool "using ch438 port 1"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config CH438_EXTUART2
|
||||||
|
bool "using ch438 port 2"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config CH438_EXTUART3
|
||||||
|
bool "using ch438 port 3"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config CH438_EXTUART4
|
||||||
|
bool "using ch438 port 4"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config CH438_EXTUART5
|
||||||
|
bool "using ch438 port 5"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config CH438_EXTUART6
|
||||||
|
bool "using ch438 port 6"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config CH438_EXTUART7
|
||||||
|
bool "using ch438 port 7"
|
||||||
|
default n
|
||||||
|
|
||||||
|
endif # BSP_USING_CH438
|
||||||
|
|
||||||
|
endif # ARCH_BOARD_XIDATONG
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
include $(TOPDIR)/Make.defs
|
include $(TOPDIR)/Make.defs
|
||||||
|
|
||||||
CSRCS = imxrt_boot.c imxrt_flexspi_nor_boot.c imxrt_flexspi_nor_flash.c imxrt_ch438.c ch438_demo.c
|
CSRCS = imxrt_boot.c imxrt_flexspi_nor_boot.c imxrt_flexspi_nor_flash.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_IMXRT_SDRAMC),y)
|
ifeq ($(CONFIG_IMXRT_SDRAMC),y)
|
||||||
CSRCS += imxrt_sdram.c
|
CSRCS += imxrt_sdram.c
|
||||||
|
@ -82,4 +82,8 @@ ifeq ($(CONFIG_XIDATONG_SDIO_AUTOMOUNT),y)
|
||||||
CSRCS += imxrt_mmcsd_automount.c
|
CSRCS += imxrt_mmcsd_automount.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_BSP_USING_CH438),y)
|
||||||
|
CSRCS += imxrt_ch438.c ch438_demo.c
|
||||||
|
endif
|
||||||
|
|
||||||
include $(TOPDIR)/boards/Board.mk
|
include $(TOPDIR)/boards/Board.mk
|
||||||
|
|
|
@ -53,26 +53,26 @@ void CH438Demo(void)
|
||||||
int i;
|
int i;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
int readlen;
|
int readlen;
|
||||||
_info("ch438_main\n");
|
|
||||||
Ch438InitDefault();
|
|
||||||
ch438_register("/dev/ext_uart3",2);
|
|
||||||
ch438_register("/dev/ext_uart2",1);
|
|
||||||
|
|
||||||
fd1 = open("/dev/ext_uart3", O_RDWR);
|
fd1 = open("/dev/extuart_dev2", O_RDWR);
|
||||||
write(fd1, "AT+BAUD=?",9);
|
write(fd1, "AT+BAUD=?",9);
|
||||||
readlen = read(fd1, buffer, 256);
|
readlen = read(fd1, buffer, 256);
|
||||||
|
|
||||||
for(i=0;i<readlen;++i)
|
for(i=0;i<readlen;++i)
|
||||||
{
|
{
|
||||||
_info("%c(0x%x)\n", buffer[i], buffer[i]);
|
printf("%c(0x%x)\n", buffer[i], buffer[i]);
|
||||||
}
|
}
|
||||||
|
close(fd1);
|
||||||
|
|
||||||
up_mdelay(1000);
|
up_mdelay(1000);
|
||||||
|
|
||||||
fd2 = open("/dev/ext_uart2", O_RDWR);
|
fd2 = open("/dev/extuart_dev1", O_RDWR);
|
||||||
write(fd2, "AT+BAUD=?",9);
|
write(fd2, "AT+BAUD=?",9);
|
||||||
readlen = read(fd2, buffer, 256);
|
readlen = read(fd2, buffer, 256);
|
||||||
for(i=0;i<readlen;++i)
|
for(i=0;i<readlen;++i)
|
||||||
{
|
{
|
||||||
_info("%c(0x%x)\n", buffer[i], buffer[i]);
|
printf("%c(0x%x)\n", buffer[i], buffer[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(fd2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,10 @@
|
||||||
# include <nuttx/usb/usbmonitor.h>
|
# include <nuttx/usb/usbmonitor.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_BSP_USING_CH438
|
||||||
|
# include "imxrt_ch438.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "xidatong.h"
|
#include "xidatong.h"
|
||||||
|
|
||||||
#include <arch/board/board.h> /* Must always be included last */
|
#include <arch/board/board.h> /* Must always be included last */
|
||||||
|
@ -181,6 +185,10 @@ int imxrt_bringup(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_BSP_USING_CH438
|
||||||
|
board_ch438_initialize();
|
||||||
|
#endif
|
||||||
|
|
||||||
UNUSED(ret);
|
UNUSED(ret);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,7 +452,7 @@ static size_t ImxrtCh438ReadData(uint8_t ext_uart_no)
|
||||||
REG_LSR_ADDR = offsetadd[ext_uart_no] | REG_LSR0_ADDR;
|
REG_LSR_ADDR = offsetadd[ext_uart_no] | REG_LSR0_ADDR;
|
||||||
REG_MSR_ADDR = offsetadd[ext_uart_no] | REG_MSR0_ADDR;
|
REG_MSR_ADDR = offsetadd[ext_uart_no] | REG_MSR0_ADDR;
|
||||||
InterruptStatus = ReadCH438Data(REG_IIR_ADDR) & 0x0f; /* 读串口的中断状态 */
|
InterruptStatus = ReadCH438Data(REG_IIR_ADDR) & 0x0f; /* 读串口的中断状态 */
|
||||||
_info("InterruptStatus is %d\n", InterruptStatus);
|
ch438info("InterruptStatus is %d\n", InterruptStatus);
|
||||||
|
|
||||||
switch(InterruptStatus)
|
switch(InterruptStatus)
|
||||||
{
|
{
|
||||||
|
@ -498,7 +498,7 @@ void Ch438InitDefault(void)
|
||||||
ret = pthread_mutex_init(&mutex, NULL);
|
ret = pthread_mutex_init(&mutex, NULL);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
_info("pthread_mutex_init failed, status=%d\n", ret);
|
ch438err("pthread_mutex_init failed, status=%d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the condition variable */
|
/* Initialize the condition variable */
|
||||||
|
@ -506,13 +506,13 @@ void Ch438InitDefault(void)
|
||||||
ret = pthread_cond_init(&cond, NULL);
|
ret = pthread_cond_init(&cond, NULL);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
_info("pthread_cond_init failed, status=%d\n", ret);
|
ch438err("pthread_cond_init failed, status=%d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = task_create("ch438_task", 60, 8192, getInterruptStatus, NULL);
|
ret = task_create("ch438_task", 60, 8192, getInterruptStatus, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
_info("task create failed, status=%d\n", ret);
|
ch438err("task create failed, status=%d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImxrtCH438Init();
|
ImxrtCH438Init();
|
||||||
|
@ -615,6 +615,7 @@ int ch438_register(FAR const char *devpath, uint8_t port)
|
||||||
priv = (FAR struct ch438_dev_s *)kmm_malloc(sizeof(struct ch438_dev_s));
|
priv = (FAR struct ch438_dev_s *)kmm_malloc(sizeof(struct ch438_dev_s));
|
||||||
if (priv == NULL)
|
if (priv == NULL)
|
||||||
{
|
{
|
||||||
|
ch438err("ERROR: Failed to allocate instance\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,8 +625,53 @@ int ch438_register(FAR const char *devpath, uint8_t port)
|
||||||
ret = register_driver(devpath, &g_ch438fops, 0666, priv);
|
ret = register_driver(devpath, &g_ch438fops, 0666, priv);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
ch438err("ERROR: Failed to register driver: %d\n", ret);
|
||||||
kmm_free(priv);
|
kmm_free(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_ch438_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* ch438 initialize
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
void board_ch438_initialize(void)
|
||||||
|
{
|
||||||
|
Ch438InitDefault();
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART0
|
||||||
|
ch438_register("/dev/extuart_dev0", 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART1
|
||||||
|
ch438_register("/dev/extuart_dev1", 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART2
|
||||||
|
ch438_register("/dev/extuart_dev2", 2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART3
|
||||||
|
ch438_register("/dev/extuart_dev3", 3);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART4
|
||||||
|
ch438_register("/dev/extuart_dev4", 4);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART5
|
||||||
|
ch438_register("/dev/extuart_dev5", 5);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART6
|
||||||
|
ch438_register("/dev/extuart_dev6", 6);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART7
|
||||||
|
ch438_register("/dev/extuart_dev7", 7);
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -299,10 +299,29 @@
|
||||||
GPIO_PORT1 | GPIO_PIN29)
|
GPIO_PORT1 | GPIO_PIN29)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_CH438_ERROR
|
||||||
|
# define ch438err _err
|
||||||
|
#else
|
||||||
|
# define ch438err _none
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_CH438_WARN
|
||||||
|
# define ch438warn _warn
|
||||||
|
#else
|
||||||
|
# define ch438warn _none
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_CH438_INFO
|
||||||
|
# define ch438info _info
|
||||||
|
#else
|
||||||
|
# define ch438info _none
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int getInterruptStatus(int argc, char **argv);
|
int getInterruptStatus(int argc, char **argv);
|
||||||
void Ch438InitDefault(void);
|
void Ch438InitDefault(void);
|
||||||
int ch438_register(FAR const char *devpath,uint8_t port);
|
int ch438_register(FAR const char *devpath,uint8_t port);
|
||||||
|
void board_ch438_initialize(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -587,6 +587,11 @@ config NSH_DISABLE_XD
|
||||||
bool "Disable xd"
|
bool "Disable xd"
|
||||||
default y if DEFAULT_SMALL
|
default y if DEFAULT_SMALL
|
||||||
default n if !DEFAULT_SMALL
|
default n if !DEFAULT_SMALL
|
||||||
|
|
||||||
|
config NSH_DISABLE_CH438
|
||||||
|
bool "Disable the ch438 demo."
|
||||||
|
default n
|
||||||
|
|
||||||
config NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS
|
config NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS
|
||||||
bool "Disable the sensor tb600b_wq_hcho1os."
|
bool "Disable the sensor tb600b_wq_hcho1os."
|
||||||
default n
|
default n
|
||||||
|
|
|
@ -1417,7 +1417,9 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb,
|
||||||
FAR void *arg);
|
FAR void *arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int cmd_Ch438(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
#if defined(CONFIG_BSP_USING_CH438) && !defined(CONFIG_NSH_DISABLE_CH438)
|
||||||
|
int cmd_Ch438(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS)
|
#if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS)
|
||||||
int cmd_Hcho1os(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
int cmd_Hcho1os(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
|
|
|
@ -36,8 +36,10 @@
|
||||||
#include "nsh.h"
|
#include "nsh.h"
|
||||||
#include "nsh_console.h"
|
#include "nsh_console.h"
|
||||||
|
|
||||||
extern int FrameworkInit(void);
|
/****************************************************************************
|
||||||
|
* Name: cmd_Ch438
|
||||||
|
****************************************************************************/
|
||||||
|
#if defined(CONFIG_BSP_USING_CH438) && !defined(CONFIG_NSH_DISABLE_CH438)
|
||||||
extern void CH438Demo(void);
|
extern void CH438Demo(void);
|
||||||
int cmd_Ch438(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
int cmd_Ch438(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -45,8 +47,7 @@ int cmd_Ch438(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
CH438Demo();
|
CH438Demo();
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cmd_Hcho1os
|
* Name: cmd_Hcho1os
|
||||||
|
|
|
@ -590,7 +590,9 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||||
{ "xd", cmd_xd, 3, 3, "<hex-address> <byte-count>" },
|
{ "xd", cmd_xd, 3, 3, "<hex-address> <byte-count>" },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{ "ch438", cmd_Ch438, 1, 1, "[ch438 demo cmd.]" },
|
#if defined(CONFIG_BSP_USING_CH438) && !defined(CONFIG_NSH_DISABLE_CH438)
|
||||||
|
{ "ch438", cmd_Ch438, 1, 1, "[ch438 demo cmd.]" },
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS)
|
#if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS)
|
||||||
{ "hcho1os", cmd_Hcho1os, 1, 1, "[get the concentration of formaldehyde with sensor tb600b_wq_hcho1os.]" },
|
{ "hcho1os", cmd_Hcho1os, 1, 1, "[get the concentration of formaldehyde with sensor tb600b_wq_hcho1os.]" },
|
||||||
|
|
|
@ -1812,6 +1812,38 @@ config DEBUG_VIDEO_INFO
|
||||||
Enable video informational output to SYSLOG.
|
Enable video informational output to SYSLOG.
|
||||||
|
|
||||||
endif # DEBUG_VIDEO
|
endif # DEBUG_VIDEO
|
||||||
|
|
||||||
|
config DEBUG_CH438
|
||||||
|
bool "CH438 Debug Features"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Enable CH438 debug features.
|
||||||
|
|
||||||
|
if DEBUG_CH438
|
||||||
|
|
||||||
|
config DEBUG_CH438_ERROR
|
||||||
|
bool "CH438 Error Output"
|
||||||
|
default n
|
||||||
|
depends on DEBUG_ERROR
|
||||||
|
---help---
|
||||||
|
Enable CH438 error output to SYSLOG.
|
||||||
|
|
||||||
|
config DEBUG_CH438_WARN
|
||||||
|
bool "CH438 Warnings Output"
|
||||||
|
default n
|
||||||
|
depends on DEBUG_WARN
|
||||||
|
---help---
|
||||||
|
Enable CH438 warning output to SYSLOG.
|
||||||
|
|
||||||
|
config DEBUG_CH438_INFO
|
||||||
|
bool "CH438 Informational Output"
|
||||||
|
default n
|
||||||
|
depends on DEBUG_INFO
|
||||||
|
---help---
|
||||||
|
Enable CH438 informational output to SYSLOG.
|
||||||
|
|
||||||
|
endif # DEBUG_CH438
|
||||||
|
|
||||||
endif # DEBUG_FEATURES
|
endif # DEBUG_FEATURES
|
||||||
|
|
||||||
config ARCH_HAVE_STACKCHECK
|
config ARCH_HAVE_STACKCHECK
|
||||||
|
|
Loading…
Reference in New Issue