aboutsummaryrefslogtreecommitdiffstats
path: root/demos/various
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-04-02 13:05:59 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-04-02 13:05:59 +0000
commite8f67437d0007a2a4cd5a05afbd525a1960c188c (patch)
treef98aa8c362c1d8d3b5247a63c1cbaadbced2e6b8 /demos/various
parent4c9f1963a9d92af708dccb93a41f0cebcb43e796 (diff)
downloadChibiOS-e8f67437d0007a2a4cd5a05afbd525a1960c188c.tar.gz
ChibiOS-e8f67437d0007a2a4cd5a05afbd525a1960c188c.tar.bz2
ChibiOS-e8f67437d0007a2a4cd5a05afbd525a1960c188c.zip
Simulator updates, not complete.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9223 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos/various')
-rw-r--r--demos/various/RT-Win32-Simulator/Makefile9
-rw-r--r--demos/various/RT-Win32-Simulator/chconf.h48
-rw-r--r--demos/various/RT-Win32-Simulator/main.c70
3 files changed, 54 insertions, 73 deletions
diff --git a/demos/various/RT-Win32-Simulator/Makefile b/demos/various/RT-Win32-Simulator/Makefile
index cdb121b6b..35e705616 100644
--- a/demos/various/RT-Win32-Simulator/Makefile
+++ b/demos/various/RT-Win32-Simulator/Makefile
@@ -64,6 +64,8 @@ include $(CHIBIOS)/os/hal/osal/rt/osal.mk
include $(CHIBIOS)/os/common/ports/SIMIA32/compilers/GCC/port.mk
include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# List C source files here
SRC = $(PORTSRC) \
@@ -73,9 +75,8 @@ SRC = $(PORTSRC) \
$(OSALSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
- $(CHIBIOS)/os/various/shell.c \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
main.c
# List ASM source files here
@@ -84,7 +85,7 @@ ASRC =
# List all user directories here
UINCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
$(HALINC) $(OSALINC) $(PLATFORMINC) $(BOARDINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC) $(CHIBIOS)/os/various
# List the user directory to look for the libraries here
ULIBDIR =
diff --git a/demos/various/RT-Win32-Simulator/chconf.h b/demos/various/RT-Win32-Simulator/chconf.h
index 7c596f355..708b2b065 100644
--- a/demos/various/RT-Win32-Simulator/chconf.h
+++ b/demos/various/RT-Win32-Simulator/chconf.h
@@ -28,6 +28,8 @@
#ifndef CHCONF_H
#define CHCONF_H
+#define _CHIBIOS_RT_CONF_
+
/*===========================================================================*/
/**
* @name System timers settings
@@ -79,7 +81,7 @@
* @note The round robin preemption is not supported in tickless mode and
* must be set to zero in that case.
*/
-#define CH_CFG_TIME_QUANTUM 20
+#define CH_CFG_TIME_QUANTUM 0
/**
* @brief Managed RAM size.
@@ -138,7 +140,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_TM FALSE
+#define CH_CFG_USE_TM TRUE
/**
* @brief Threads registry APIs.
@@ -352,9 +354,16 @@
* @details If enabled then the context switch circular trace buffer is
* activated.
*
- * @note The default is @p FALSE.
+ * @note The default is @p CH_DBG_TRACE_MASK_NONE.
+ */
+#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_NONE
+
+/**
+ * @brief Trace buffer entries.
+ * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
+ * different from @p CH_DBG_TRACE_MASK_NONE.
*/
-#define CH_DBG_ENABLE_TRACE FALSE
+#define CH_DBG_TRACE_BUFFER_SIZE 128
/**
* @brief Debug option, stack checks.
@@ -387,7 +396,7 @@
* @note This debug option is not currently compatible with the
* tickless mode.
*/
-#define CH_DBG_THREADS_PROFILING TRUE
+#define CH_DBG_THREADS_PROFILING FALSE
/** @} */
@@ -419,10 +428,6 @@
/**
* @brief Threads finalization hook.
* @details User finalization code added to the @p chThdExit() API.
- *
- * @note It is inserted into lock zone.
- * @note It is also invoked when the threads simply return in order to
- * terminate.
*/
#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
/* Add threads finalization code here.*/ \
@@ -437,12 +442,27 @@
}
/**
+ * @brief ISR enter hook.
+ */
+#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
+ /* IRQ prologue code here.*/ \
+}
+
+/**
+ * @brief ISR exit hook.
+ */
+#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
+ /* IRQ epilogue code here.*/ \
+}
+
+/**
* @brief Idle thread enter hook.
* @note This hook is invoked within a critical zone, no OS functions
* should be invoked from here.
* @note This macro can be used to activate a power saving mode.
*/
#define CH_CFG_IDLE_ENTER_HOOK() { \
+ /* Idle-enter code here.*/ \
}
/**
@@ -452,6 +472,7 @@
* @note This macro can be used to deactivate a power saving mode.
*/
#define CH_CFG_IDLE_LEAVE_HOOK() { \
+ /* Idle-leave code here.*/ \
}
/**
@@ -480,6 +501,15 @@
/* System halt code here.*/ \
}
+/**
+ * @brief Trace hook.
+ * @details This hook is invoked each time a new record is written in the
+ * trace buffer.
+ */
+#define CH_CFG_TRACE_HOOK(tep) { \
+ /* Trace code here.*/ \
+}
+
/** @} */
/*===========================================================================*/
diff --git a/demos/various/RT-Win32-Simulator/main.c b/demos/various/RT-Win32-Simulator/main.c
index 17b2346c6..d4a3da302 100644
--- a/demos/various/RT-Win32-Simulator/main.c
+++ b/demos/various/RT-Win32-Simulator/main.c
@@ -30,61 +30,7 @@ static thread_t *cdtp;
static thread_t *shelltp1;
static thread_t *shelltp2;
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%.8lx %.8lx %4lu %4lu %9s %lu\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.esp,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state], (uint32_t)tp->p_time);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
-
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -128,7 +74,8 @@ static void termination_handler(eventid_t id) {
chThdSleepMilliseconds(10);
cputs("Init: shell on SD1 terminated");
chSysLock();
- chOQResetI(&SD1.oqueue);
+ oqResetI(&SD1.oqueue);
+ chSchRescheduleS();
chSysUnlock();
}
if (shelltp2 && chThdTerminatedX(shelltp2)) {
@@ -137,7 +84,8 @@ static void termination_handler(eventid_t id) {
chThdSleepMilliseconds(10);
cputs("Init: shell on SD2 terminated");
chSysLock();
- chOQResetI(&SD2.oqueue);
+ oqResetI(&SD2.oqueue);
+ chSchRescheduleS();
chSysUnlock();
}
}
@@ -161,7 +109,8 @@ static void sd1_handler(eventid_t id) {
if (flags & CHN_DISCONNECTED) {
cputs("Init: disconnection on SD1");
chSysLock();
- chIQResetI(&SD1.iqueue);
+ iqResetI(&SD1.iqueue);
+ chSchRescheduleS();
chSysUnlock();
}
}
@@ -183,7 +132,8 @@ static void sd2_handler(eventid_t id) {
if (flags & CHN_DISCONNECTED) {
cputs("Init: disconnection on SD2");
chSysLock();
- chIQResetI(&SD2.iqueue);
+ iqResetI(&SD2.iqueue);
+ chSchRescheduleS();
chSysUnlock();
}
}
@@ -225,8 +175,8 @@ int main(void) {
/*
* Console thread started.
*/
- cdtp = chThdCreateFromHeap(NULL, CONSOLE_WA_SIZE, NORMALPRIO + 1,
- console_thread, NULL);
+ cdtp = chThdCreateFromHeap(NULL, CONSOLE_WA_SIZE, "console",
+ NORMALPRIO + 1, console_thread, NULL);
/*
* Initializing connection/disconnection events.