aboutsummaryrefslogtreecommitdiffstats
path: root/demos/Win32-MinGW
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-11-19 11:09:33 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-11-19 11:09:33 +0000
commitb3361bd0e8ca074dbf7f312a87bbcdbf0019ebc7 (patch)
tree6cb55aa7bf6630b87d07b851ab40b44b662033c6 /demos/Win32-MinGW
parente3617bedb28afefa2993c7e2a8a696d5af16a733 (diff)
downloadChibiOS-b3361bd0e8ca074dbf7f312a87bbcdbf0019ebc7.tar.gz
ChibiOS-b3361bd0e8ca074dbf7f312a87bbcdbf0019ebc7.tar.bz2
ChibiOS-b3361bd0e8ca074dbf7f312a87bbcdbf0019ebc7.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@97 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos/Win32-MinGW')
-rw-r--r--demos/Win32-MinGW/chcore.c4
-rw-r--r--demos/Win32-MinGW/chcore.h5
-rw-r--r--demos/Win32-MinGW/demo.c39
3 files changed, 16 insertions, 32 deletions
diff --git a/demos/Win32-MinGW/chcore.c b/demos/Win32-MinGW/chcore.c
index c96611f8b..eab41ab27 100644
--- a/demos/Win32-MinGW/chcore.c
+++ b/demos/Win32-MinGW/chcore.c
@@ -91,9 +91,7 @@ void ChkIntSources(void) {
}
}
-__attribute__((fastcall)) void chSysPause(void) {
-
- chThdSetPriority(IDLEPRIO);
+t_msg _IdleThread(void *p) {
while (TRUE) {
diff --git a/demos/Win32-MinGW/chcore.h b/demos/Win32-MinGW/chcore.h
index 6d3055081..a28aa2833 100644
--- a/demos/Win32-MinGW/chcore.h
+++ b/demos/Win32-MinGW/chcore.h
@@ -62,12 +62,13 @@ typedef struct {
#define chSysPuts(msg) {}
#define INT_REQUIRED_STACK 0x0
-
#define UserStackSize(n) (sizeof(Thread) + sizeof(void *) * 2 + \
sizeof(struct stackregs) + (n) + (INT_REQUIRED_STACK))
+#define IDLE_THREAD_STACK_SIZE 16384
+t_msg _IdleThread(void *p);
+
__attribute__((fastcall)) void chSysHalt(void);
-__attribute__((fastcall)) void chSysPause(void);
__attribute__((fastcall)) void chSysSwitchI(Context *oldp, Context *newp);
__attribute__((fastcall)) void threadstart(void);
diff --git a/demos/Win32-MinGW/demo.c b/demos/Win32-MinGW/demo.c
index 077877f8e..1d4f4aa16 100644
--- a/demos/Win32-MinGW/demo.c
+++ b/demos/Win32-MinGW/demo.c
@@ -25,16 +25,12 @@
static ULONG32 wdguard;
static BYTE8 wdarea[UserStackSize(2048)];
-static ULONG32 iguard;
-static BYTE8 iarea[UserStackSize(2048)];
-
static ULONG32 cdguard;
static BYTE8 cdarea[UserStackSize(2048)];
static Thread *cdtp;
static t_msg WatchdogThread(void *arg);
static t_msg ConsoleThread(void *arg);
-static t_msg InitThread(void *arg);
t_msg TestThread(void *p);
@@ -43,34 +39,16 @@ extern FullDuplexDriver COM1, COM2;
#define cprint(msg) chMsgSend(cdtp, (t_msg)msg)
-/*------------------------------------------------------------------------*
- * Simulator main, start here your threads, examples inside. *
- *------------------------------------------------------------------------*/
-int main(void) {
-
- InitCore();
-
- // Startup ChibiOS/RT.
- chSysInit();
- chThdCreate(NORMALPRIO + 2, 0, wdarea, sizeof(wdarea), WatchdogThread, NULL);
- cdtp = chThdCreate(NORMALPRIO + 1, 0, cdarea, sizeof(cdarea), ConsoleThread, NULL);
- chThdCreate(NORMALPRIO, 0, iarea, sizeof(iarea), InitThread, NULL);
- chSysPause();
- return 0;
-}
-
/*
* Watchdog thread, it checks magic values located under the various stack
* areas. The system is halted if something is wrong.
*/
static t_msg WatchdogThread(void *arg) {
wdguard = 0xA51F2E3D;
- iguard = 0xA51F2E3D;
cdguard = 0xA51F2E3D;
while (TRUE) {
if ((wdguard != 0xA51F2E3D) ||
- (iguard != 0xA51F2E3D) ||
(cdguard != 0xA51F2E3D)) {
printf("Halted by watchdog");
chSysHalt();
@@ -294,13 +272,20 @@ static t_evhandler fhandlers[2] = {
COM2Handler
};
-/*
- * Init-like thread, it starts the shells and handles their termination.
- * It is a good example of events usage.
- */
-static t_msg InitThread(void *arg) {
+/*------------------------------------------------------------------------*
+ * Simulator main, start here your threads, examples inside. *
+ *------------------------------------------------------------------------*/
+int main(void) {
EventListener c1fel, c2fel;
+ InitCore();
+
+ // Startup ChibiOS/RT.
+ chSysInit();
+
+ chThdCreate(NORMALPRIO + 2, 0, wdarea, sizeof(wdarea), WatchdogThread, NULL);
+ cdtp = chThdCreate(NORMALPRIO + 1, 0, cdarea, sizeof(cdarea), ConsoleThread, NULL);
+
cprint("Console service started on COM1, COM2\n");
cprint(" - Listening for connections on COM1\n");
chFDDGetAndClearFlags(&COM1);