forked from xuos/xiuos
This commit is contained in:
commit
302bf4e1cc
|
@ -89,37 +89,117 @@ menuconfig BSP_USING_CH438
|
||||||
|
|
||||||
if BSP_USING_CH438
|
if BSP_USING_CH438
|
||||||
config CH438_EXTUART0
|
config CH438_EXTUART0
|
||||||
bool "using ch438 port 0"
|
bool "Using Ch438 Port 0"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
menu "Ch438 Port 0 Configuration"
|
||||||
|
depends on CH438_EXTUART0
|
||||||
|
|
||||||
|
config CH438_EXTUART0_BAUD
|
||||||
|
int "Ch438 Port 0 Baud Rate."
|
||||||
|
default 115200
|
||||||
|
---help---
|
||||||
|
The configured BAUD of the CH438 EXTUART0.
|
||||||
|
endmenu
|
||||||
|
|
||||||
config CH438_EXTUART1
|
config CH438_EXTUART1
|
||||||
bool "using ch438 port 1"
|
bool "Using Ch438 Port 1"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
menu "Ch438 Port 1 Configuration"
|
||||||
|
depends on CH438_EXTUART1
|
||||||
|
|
||||||
|
config CH438_EXTUART1_BAUD
|
||||||
|
int "Ch438 Port 1 Baud Rate."
|
||||||
|
default 115200
|
||||||
|
---help---
|
||||||
|
The configured BAUD of the CH438 EXTUART1.
|
||||||
|
endmenu
|
||||||
|
|
||||||
config CH438_EXTUART2
|
config CH438_EXTUART2
|
||||||
bool "using ch438 port 2"
|
bool "Using Ch438 Port 2"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
menu "Ch438 Port 2 Configuration"
|
||||||
|
depends on CH438_EXTUART2
|
||||||
|
|
||||||
|
config CH438_EXTUART2_BAUD
|
||||||
|
int "Ch438 Port 2 Baud Rate."
|
||||||
|
default 115200
|
||||||
|
---help---
|
||||||
|
The configured BAUD of the CH438 EXTUART2.
|
||||||
|
endmenu
|
||||||
|
|
||||||
config CH438_EXTUART3
|
config CH438_EXTUART3
|
||||||
bool "using ch438 port 3"
|
bool "Using Ch438 Port 3"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
menu "Ch438 Port 3 Configuration"
|
||||||
|
depends on CH438_EXTUART3
|
||||||
|
|
||||||
|
config CH438_EXTUART3_BAUD
|
||||||
|
int "Ch438 Port 3 Baud Rate."
|
||||||
|
default 115200
|
||||||
|
---help---
|
||||||
|
The configured BAUD of the CH438 EXTUART3.
|
||||||
|
endmenu
|
||||||
|
|
||||||
config CH438_EXTUART4
|
config CH438_EXTUART4
|
||||||
bool "using ch438 port 4"
|
bool "Using Ch438 Port 4"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
menu "Ch438 Port 4 Configuration"
|
||||||
|
depends on CH438_EXTUART4
|
||||||
|
|
||||||
|
config CH438_EXTUART4_BAUD
|
||||||
|
int "Ch438 Port 4 Baud Rate."
|
||||||
|
default 115200
|
||||||
|
---help---
|
||||||
|
The configured BAUD of the CH438 EXTUART4.
|
||||||
|
endmenu
|
||||||
|
|
||||||
config CH438_EXTUART5
|
config CH438_EXTUART5
|
||||||
bool "using ch438 port 5"
|
bool "Using Ch438 Port 5"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
menu "Ch438 Port 5 Configuration"
|
||||||
|
depends on CH438_EXTUART5
|
||||||
|
|
||||||
|
config CH438_EXTUART5_BAUD
|
||||||
|
int "Ch438 Port 5 Baud Rate."
|
||||||
|
default 115200
|
||||||
|
---help---
|
||||||
|
The configured BAUD of the CH438 EXTUART5.
|
||||||
|
endmenu
|
||||||
|
|
||||||
config CH438_EXTUART6
|
config CH438_EXTUART6
|
||||||
bool "using ch438 port 6"
|
bool "Using Ch438 Port 6"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
menu "Ch438 Port 6 Configuration"
|
||||||
|
depends on CH438_EXTUART6
|
||||||
|
|
||||||
|
config CH438_EXTUART6_BAUD
|
||||||
|
int "Ch438 Port 6 Baud Rate."
|
||||||
|
default 115200
|
||||||
|
---help---
|
||||||
|
The configured BAUD of the CH438 EXTUART6.
|
||||||
|
endmenu
|
||||||
|
|
||||||
config CH438_EXTUART7
|
config CH438_EXTUART7
|
||||||
bool "using ch438 port 7"
|
bool "Using Ch438 Port 7"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
menu "Ch438 Port 7 Configuration"
|
||||||
|
depends on CH438_EXTUART7
|
||||||
|
|
||||||
|
config CH438_EXTUART7_BAUD
|
||||||
|
int "Ch438 Port 7 Baud Rate."
|
||||||
|
default 115200
|
||||||
|
---help---
|
||||||
|
The configured BAUD of the CH438 EXTUART7.
|
||||||
|
endmenu
|
||||||
|
|
||||||
endif # BSP_USING_CH438
|
endif # BSP_USING_CH438
|
||||||
|
|
||||||
endif # ARCH_BOARD_XIDATONG
|
endif # ARCH_BOARD_XIDATONG
|
||||||
|
|
|
@ -36,9 +36,8 @@ void CH438Demo(void)
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
int readlen;
|
int readlen;
|
||||||
|
|
||||||
// while(1)
|
|
||||||
// {
|
|
||||||
fd = open("/dev/extuart_dev3", O_RDWR);
|
fd = open("/dev/extuart_dev3", O_RDWR);
|
||||||
|
ioctl(fd, OPE_INT, (unsigned long)9600);
|
||||||
m0fd = open("/dev/gpout0", O_RDWR);
|
m0fd = open("/dev/gpout0", O_RDWR);
|
||||||
m1fd = open("/dev/gpout1", O_RDWR);
|
m1fd = open("/dev/gpout1", O_RDWR);
|
||||||
ioctl(m0fd, GPIOC_WRITE, (unsigned long)1);
|
ioctl(m0fd, GPIOC_WRITE, (unsigned long)1);
|
||||||
|
@ -82,6 +81,5 @@ void CH438Demo(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,35 @@ static pthread_cond_t cond[CH438PORTNUM] =
|
||||||
PTHREAD_COND_INITIALIZER
|
PTHREAD_COND_INITIALIZER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* This array shows whether the current serial port is selected */
|
||||||
|
static bool const g_uart_selected[CH438PORTNUM] =
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_CH438_EXTUART0
|
||||||
|
[0] = true,
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_CH438_EXTUART1
|
||||||
|
[1] = true,
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_CH438_EXTUART2
|
||||||
|
[2] = true,
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_CH438_EXTUART3
|
||||||
|
[3] = true,
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_CH438_EXTUART4
|
||||||
|
[4] = true,
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_CH438_EXTUART5
|
||||||
|
[5] = true,
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_CH438_EXTUART6
|
||||||
|
[6] = true,
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_CH438_EXTUART7
|
||||||
|
[7] = true,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
/* ch438 Callback work queue structure */
|
/* ch438 Callback work queue structure */
|
||||||
static struct work_s g_ch438irqwork;
|
static struct work_s g_ch438irqwork;
|
||||||
|
|
||||||
|
@ -135,7 +164,7 @@ static FAR void getInterruptStatus(FAR void *arg)
|
||||||
{
|
{
|
||||||
for(i = 0; i < CH438PORTNUM; i++)
|
for(i = 0; i < CH438PORTNUM; i++)
|
||||||
{
|
{
|
||||||
if(gInterruptStatus & Interruptnum[i])
|
if(g_uart_selected[i] && (gInterruptStatus & Interruptnum[i]))
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&mutex[i]);
|
pthread_mutex_lock(&mutex[i]);
|
||||||
done[i] = true;
|
done[i] = true;
|
||||||
|
@ -572,6 +601,11 @@ static void Ch438InitDefault(void)
|
||||||
/* Initialize the mutex */
|
/* Initialize the mutex */
|
||||||
for(i = 0; i < CH438PORTNUM; i++)
|
for(i = 0; i < CH438PORTNUM; i++)
|
||||||
{
|
{
|
||||||
|
if(!g_uart_selected[i])
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ret = pthread_mutex_init(&mutex[i], NULL);
|
ret = pthread_mutex_init(&mutex[i], NULL);
|
||||||
if(ret != 0)
|
if(ret != 0)
|
||||||
{
|
{
|
||||||
|
@ -582,6 +616,11 @@ static void Ch438InitDefault(void)
|
||||||
/* Initialize the condition variable */
|
/* Initialize the condition variable */
|
||||||
for(i = 0; i < CH438PORTNUM; i++)
|
for(i = 0; i < CH438PORTNUM; i++)
|
||||||
{
|
{
|
||||||
|
if(!g_uart_selected[i])
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ret = pthread_cond_init(&cond[i], NULL);
|
ret = pthread_cond_init(&cond[i], NULL);
|
||||||
if(ret != 0)
|
if(ret != 0)
|
||||||
{
|
{
|
||||||
|
@ -590,14 +629,38 @@ static void Ch438InitDefault(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
ImxrtCH438Init();
|
ImxrtCH438Init();
|
||||||
CH438PortInit(0,115200);
|
|
||||||
CH438PortInit(1,115200);
|
#ifdef CONFIG_CH438_EXTUART0
|
||||||
CH438PortInit(2,9600);
|
CH438PortInit(0, CONFIG_CH438_EXTUART0_BAUD);
|
||||||
CH438PortInit(3,9600);
|
#endif
|
||||||
CH438PortInit(4,115200);
|
|
||||||
CH438PortInit(5,115200);
|
#ifdef CONFIG_CH438_EXTUART1
|
||||||
CH438PortInit(6,115200);
|
CH438PortInit(1, CONFIG_CH438_EXTUART1_BAUD);
|
||||||
CH438PortInit(7,115200);
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART2
|
||||||
|
CH438PortInit(2, CONFIG_CH438_EXTUART2_BAUD);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART3
|
||||||
|
CH438PortInit(3, CONFIG_CH438_EXTUART3_BAUD);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART4
|
||||||
|
CH438PortInit(4, CONFIG_CH438_EXTUART4_BAUD);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART5
|
||||||
|
CH438PortInit(5, CONFIG_CH438_EXTUART5_BAUD);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART6
|
||||||
|
CH438PortInit(6, CONFIG_CH438_EXTUART6_BAUD);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CH438_EXTUART7
|
||||||
|
CH438PortInit(7, CONFIG_CH438_EXTUART7_BAUD);
|
||||||
|
#endif
|
||||||
|
|
||||||
up_mdelay(10);
|
up_mdelay(10);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue