forked from xuos/xiuos
move include files to imxrt_ch438.h on nuttx and change board_ch438_initialize
This commit is contained in:
parent
e007b5567d
commit
522b8848a2
|
@ -21,58 +21,30 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#include "imxrt_ch438.h"
|
#include "imxrt_ch438.h"
|
||||||
|
|
||||||
#define TMP (GPIO_OUTPUT | IOMUX_GOUT_DEFAULT | \
|
|
||||||
GPIO_PORT3 | GPIO_PIN3)
|
|
||||||
|
|
||||||
void CH438Demo(void)
|
void CH438Demo(void)
|
||||||
{
|
{
|
||||||
int fd1,fd2;
|
int fd;
|
||||||
int i;
|
int i;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
int readlen;
|
int readlen;
|
||||||
|
|
||||||
fd1 = open("/dev/extuart_dev2", O_RDWR);
|
while(1)
|
||||||
write(fd1, "AT+BAUD=?",9);
|
{
|
||||||
readlen = read(fd1, buffer, 256);
|
fd = open("/dev/extuart_dev2", O_RDWR);
|
||||||
|
write(fd, "AT+ADDR=?",9);
|
||||||
|
sleep(1);
|
||||||
|
readlen = read(fd, buffer, 256);
|
||||||
|
|
||||||
|
printf("readlen1 = %d\n", readlen);
|
||||||
|
|
||||||
for(i = 0;i< readlen; ++i)
|
for(i = 0;i< readlen; ++i)
|
||||||
{
|
{
|
||||||
printf("%c(0x%x)\n", buffer[i], buffer[i]);
|
printf("%c(0x%x)\n", buffer[i], buffer[i]);
|
||||||
}
|
}
|
||||||
close(fd1);
|
|
||||||
|
|
||||||
up_mdelay(1000);
|
close(fd);
|
||||||
|
|
||||||
fd2 = open("/dev/extuart_dev1", O_RDWR);
|
|
||||||
write(fd2, "AT+BAUD=?",9);
|
|
||||||
readlen = read(fd2, buffer, 256);
|
|
||||||
for(i=0;i<readlen;++i)
|
|
||||||
{
|
|
||||||
printf("%c(0x%x)\n", buffer[i], buffer[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd2);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,6 @@ int imxrt_bringup(void)
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR, "ERROR: Failed to start USB host services: %d\n", ret);
|
syslog(LOG_ERR, "ERROR: Failed to start USB host services: %d\n", ret);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -171,7 +170,6 @@ int imxrt_bringup(void)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret);
|
syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -186,7 +184,12 @@ int imxrt_bringup(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_BSP_USING_CH438
|
#ifdef CONFIG_BSP_USING_CH438
|
||||||
board_ch438_initialize();
|
ret = board_ch438_initialize();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "Failed to initialize ch438 Driver: %d\n", ret);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UNUSED(ret);
|
UNUSED(ret);
|
||||||
|
|
|
@ -18,33 +18,7 @@
|
||||||
* @date 2022.04.26
|
* @date 2022.04.26
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
#include <nuttx/kmalloc.h>
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/pthread.h>
|
|
||||||
#include <nuttx/semaphore.h>
|
|
||||||
#include <nuttx/time.h>
|
|
||||||
#include <nuttx/fs/fs.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
#include "arm_arch.h"
|
|
||||||
|
|
||||||
#include "imxrt_config.h"
|
|
||||||
#include "imxrt_irq.h"
|
|
||||||
#include "imxrt_gpio.h"
|
|
||||||
#include "imxrt_ch438.h"
|
#include "imxrt_ch438.h"
|
||||||
#include "xidatong.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define CH438PORTNUM 8
|
#define CH438PORTNUM 8
|
||||||
#define BUFFERSIZE 128
|
#define BUFFERSIZE 128
|
||||||
|
@ -271,14 +245,12 @@ static uint8_t ReadCH438Data(uint8_t addr)
|
||||||
up_udelay(1);
|
up_udelay(1);
|
||||||
|
|
||||||
imxrt_gpio_write(CH438_ALE_PIN, false);
|
imxrt_gpio_write(CH438_ALE_PIN, false);
|
||||||
|
|
||||||
up_udelay(1);
|
up_udelay(1);
|
||||||
|
|
||||||
CH438SetInput();
|
CH438SetInput();
|
||||||
up_udelay(1);
|
up_udelay(1);
|
||||||
|
|
||||||
imxrt_gpio_write(CH438_NRD_PIN, false);
|
imxrt_gpio_write(CH438_NRD_PIN, false);
|
||||||
|
|
||||||
up_udelay(1);
|
up_udelay(1);
|
||||||
|
|
||||||
if (imxrt_gpio_read(CH438_D7_PIN_INPUT)) dat |= 0x80;
|
if (imxrt_gpio_read(CH438_D7_PIN_INPUT)) dat |= 0x80;
|
||||||
|
@ -292,7 +264,6 @@ static uint8_t ReadCH438Data(uint8_t addr)
|
||||||
|
|
||||||
imxrt_gpio_write(CH438_NRD_PIN, true);
|
imxrt_gpio_write(CH438_NRD_PIN, true);
|
||||||
imxrt_gpio_write(CH438_ALE_PIN, true);
|
imxrt_gpio_write(CH438_ALE_PIN, true);
|
||||||
|
|
||||||
up_udelay(1);
|
up_udelay(1);
|
||||||
|
|
||||||
return dat;
|
return dat;
|
||||||
|
@ -341,12 +312,10 @@ static void WriteCH438Data(uint8_t addr, uint8_t dat)
|
||||||
up_udelay(1);
|
up_udelay(1);
|
||||||
|
|
||||||
imxrt_gpio_write(CH438_NWR_PIN, false);
|
imxrt_gpio_write(CH438_NWR_PIN, false);
|
||||||
|
|
||||||
up_udelay(1);
|
up_udelay(1);
|
||||||
|
|
||||||
imxrt_gpio_write(CH438_NWR_PIN, true);
|
imxrt_gpio_write(CH438_NWR_PIN, true);
|
||||||
imxrt_gpio_write(CH438_ALE_PIN, true);
|
imxrt_gpio_write(CH438_ALE_PIN, true);
|
||||||
|
|
||||||
up_udelay(1);
|
up_udelay(1);
|
||||||
|
|
||||||
CH438SetInput();
|
CH438SetInput();
|
||||||
|
@ -639,39 +608,84 @@ int ch438_register(FAR const char *devpath, uint8_t port)
|
||||||
* ch438 initialize
|
* ch438 initialize
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void board_ch438_initialize(void)
|
int board_ch438_initialize(void)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
Ch438InitDefault();
|
Ch438InitDefault();
|
||||||
|
|
||||||
#ifdef CONFIG_CH438_EXTUART0
|
#ifdef CONFIG_CH438_EXTUART0
|
||||||
ch438_register("/dev/extuart_dev0", 0);
|
ret = ch438_register("/dev/extuart_dev0", 0);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ch438err("Failed to register /dev/extuart_dev0: %d\n", ret);
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CH438_EXTUART1
|
#ifdef CONFIG_CH438_EXTUART1
|
||||||
ch438_register("/dev/extuart_dev1", 1);
|
ret = ch438_register("/dev/extuart_dev1", 1);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ch438err("Failed to register /dev/extuart_dev1: %d\n", ret);
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CH438_EXTUART2
|
#ifdef CONFIG_CH438_EXTUART2
|
||||||
ch438_register("/dev/extuart_dev2", 2);
|
ret = ch438_register("/dev/extuart_dev2", 2);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ch438err("Failed to register /dev/extuart_dev2: %d\n", ret);
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CH438_EXTUART3
|
#ifdef CONFIG_CH438_EXTUART3
|
||||||
ch438_register("/dev/extuart_dev3", 3);
|
ret = ch438_register("/dev/extuart_dev3", 3);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ch438err("Failed to register /dev/extuart_dev3: %d\n", ret);
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CH438_EXTUART4
|
#ifdef CONFIG_CH438_EXTUART4
|
||||||
ch438_register("/dev/extuart_dev4", 4);
|
ret = ch438_register("/dev/extuart_dev4", 4);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ch438err("Failed to register /dev/extuart_dev4: %d\n", ret);
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CH438_EXTUART5
|
#ifdef CONFIG_CH438_EXTUART5
|
||||||
ch438_register("/dev/extuart_dev5", 5);
|
ret = ch438_register("/dev/extuart_dev5", 5);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ch438err("Failed to register /dev/extuart_dev5: %d\n", ret);
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CH438_EXTUART6
|
#ifdef CONFIG_CH438_EXTUART6
|
||||||
ch438_register("/dev/extuart_dev6", 6);
|
ret = ch438_register("/dev/extuart_dev6", 6);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ch438err("Failed to register /dev/extuart_dev6: %d\n", ret);
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CH438_EXTUART7
|
#ifdef CONFIG_CH438_EXTUART7
|
||||||
ch438_register("/dev/extuart_dev7", 7);
|
ret = ch438_register("/dev/extuart_dev7", 7);
|
||||||
#endif
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ch438err("Failed to register /dev/extuart_dev7: %d\n", ret);
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__exit:
|
||||||
|
return ret;
|
||||||
}
|
}
|
|
@ -18,9 +18,44 @@
|
||||||
* @date 2022.04.26
|
* @date 2022.04.26
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __QC_TEST_CH438__
|
#ifndef __BOARDS_ARM_IMXRT_XIDATONG_SRC_IMXRT_CH438_H
|
||||||
#define __QC_TEST_CH438__
|
#define __BOARDS_ARM_IMXRT_XIDATONG_SRC_IMXRT_CH438_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/pthread.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
|
#include <nuttx/time.h>
|
||||||
|
#include <nuttx/fs/fs.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sched.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
#include "arm_arch.h"
|
||||||
|
|
||||||
|
#include "imxrt_config.h"
|
||||||
|
#include "imxrt_irq.h"
|
||||||
|
#include "imxrt_gpio.h"
|
||||||
#include "xidatong.h"
|
#include "xidatong.h"
|
||||||
|
|
||||||
/******************************************************************************************/
|
/******************************************************************************************/
|
||||||
|
@ -320,8 +355,12 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#ifdef CONFIG_BSP_USING_CH438
|
||||||
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);
|
int board_ch438_initialize(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* __BOARDS_ARM_IMXRT_XIDATONG_SRC_IMXRT_CH438_H */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue