diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-10-01 14:59:51 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-10-01 14:59:51 -0600 |
commit | 76207b1a0233388cc6f8a056b463871f02b3ff2b (patch) | |
tree | fee62d2718d89bd1dc7f62a147d61a8ae26bae30 /nuttx/arch/sim | |
parent | 492df1a94f1fba6ba8e6a4b06293a39e25315cf4 (diff) | |
download | px4-nuttx-76207b1a0233388cc6f8a056b463871f02b3ff2b.tar.gz px4-nuttx-76207b1a0233388cc6f8a056b463871f02b3ff2b.tar.bz2 px4-nuttx-76207b1a0233388cc6f8a056b463871f02b3ff2b.zip |
Simulation: Change how simulated UART data availability is signaled. The last change is not safe (but I don't like this workaround either -- maybe something better will come to me).
Diffstat (limited to 'nuttx/arch/sim')
-rw-r--r-- | nuttx/arch/sim/src/up_idle.c | 19 | ||||
-rw-r--r-- | nuttx/arch/sim/src/up_internal.h | 8 | ||||
-rw-r--r-- | nuttx/arch/sim/src/up_simuart.c | 20 |
3 files changed, 43 insertions, 4 deletions
diff --git a/nuttx/arch/sim/src/up_idle.c b/nuttx/arch/sim/src/up_idle.c index 0106c2959..cfe4a7d6d 100644 --- a/nuttx/arch/sim/src/up_idle.c +++ b/nuttx/arch/sim/src/up_idle.c @@ -106,15 +106,26 @@ void up_idle(void) sched_process_timer(); #endif - /* Run the network if enabled */ +#if defined(CONFIG_DEV_CONSOLE) && !defined(CONFIG_SIM_UART_DATAPOST) + /* Handle UART data availability */ + + if (g_uart_data_available) + { + g_uart_data_available = 0; + simuart_post(); + } +#endif + #ifdef CONFIG_NET + /* Run the network if enabled */ + netdriver_loop(); #endif +#ifdef CONFIG_PM /* Fake some power management stuff for testing purposes */ -#ifdef CONFIG_PM { static enum pm_state_e state = PM_NORMAL; enum pm_state_e newstate; @@ -130,11 +141,11 @@ void up_idle(void) } #endif +#if defined(CONFIG_SIM_WALLTIME) || defined(CONFIG_SIM_X11FB) /* Wait a bit so that the sched_process_timer() is called close to the * correct rate. */ -#if defined(CONFIG_SIM_WALLTIME) || defined(CONFIG_SIM_X11FB) (void)up_hostusleep(1000000 / CLK_TCK); /* Handle X11-related events */ @@ -142,9 +153,9 @@ void up_idle(void) #ifdef CONFIG_SIM_X11FB if (g_x11initialized) { +#ifdef CONFIG_SIM_TOUCHSCREEN /* Drive the X11 event loop */ -#ifdef CONFIG_SIM_TOUCHSCREEN if (g_eventloop) { up_x11events(); diff --git a/nuttx/arch/sim/src/up_internal.h b/nuttx/arch/sim/src/up_internal.h index da0c0c2bb..5cfb71560 100644 --- a/nuttx/arch/sim/src/up_internal.h +++ b/nuttx/arch/sim/src/up_internal.h @@ -84,6 +84,10 @@ # undef CONFIG_RAMLOG_SYSLOG #endif +/* The design for how we signal UART data availability is up in the air */ + +#undef CONFIG_SIM_UART_DATAPOST + /* Context Switching Definitions ******************************************/ /* Storage order: %ebx, $esi, %edi, %ebp, sp, and return PC */ @@ -144,6 +148,10 @@ extern volatile int g_eventloop; #endif #endif +#if defined(CONFIG_DEV_CONSOLE) && !defined(CONFIG_SIM_UART_DATAPOST) +extern volatile int g_uart_data_available; +#endif + /************************************************************************** * Public Function Prototypes **************************************************************************/ diff --git a/nuttx/arch/sim/src/up_simuart.c b/nuttx/arch/sim/src/up_simuart.c index cd14700d4..ba237fb7e 100644 --- a/nuttx/arch/sim/src/up_simuart.c +++ b/nuttx/arch/sim/src/up_simuart.c @@ -50,6 +50,10 @@ #define SIMUART_BUFSIZE 256 +/* The design for how we signal UART data availability is up in the air */ + +#undef CONFIG_SIM_UART_DATAPOST + /**************************************************************************** * Private Data ****************************************************************************/ @@ -59,6 +63,14 @@ static volatile int g_uarthead; static volatile int g_uarttail; /**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef CONFIG_SIM_UART_DATAPOST +volatile int g_uart_data_available; +#endif + +/**************************************************************************** * NuttX Domain Public Function Prototypes ****************************************************************************/ @@ -115,7 +127,9 @@ static void *simuart_thread(void *arg) if (nread == 1) { +#ifdef CONFIG_SIM_UART_DATAPOST sched_lock(); +#endif /* Get the index to the next slot in the UART buffer */ @@ -146,10 +160,15 @@ static void *simuart_thread(void *arg) * input. */ +#ifdef CONFIG_SIM_UART_DATAPOST simuart_post(); +#else + g_uart_data_available = 1; +#endif } } +#ifdef CONFIG_SIM_UART_DATAPOST /* REVISIT: This is very weird and scary here. When sched_unlock() * is called, we may do a lonjmp() style context switch meaning * that the logic will be run running on this thread! (but with a @@ -159,6 +178,7 @@ static void *simuart_thread(void *arg) */ sched_unlock(); +#endif } } |