diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-06-15 15:58:20 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-06-15 15:58:20 +0000 |
commit | 7c68ef157d009f9932ac47ba21ba5d74e321623f (patch) | |
tree | 6c2442ca44cd090656ec3059ffb959f3d747e18d /demos/ARMCM3-LPC1343-OLIMEX/main.c | |
parent | 076746af63d317f8e96766b9137a65679f60463f (diff) | |
parent | e0d850113610f3efa0c0ac4946901f683e5e7332 (diff) | |
download | ChibiOS-7c68ef157d009f9932ac47ba21ba5d74e321623f.tar.gz ChibiOS-7c68ef157d009f9932ac47ba21ba5d74e321623f.tar.bz2 ChibiOS-7c68ef157d009f9932ac47ba21ba5d74e321623f.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5854 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos/ARMCM3-LPC1343-OLIMEX/main.c')
-rw-r--r-- | demos/ARMCM3-LPC1343-OLIMEX/main.c | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/demos/ARMCM3-LPC1343-OLIMEX/main.c b/demos/ARMCM3-LPC1343-OLIMEX/main.c new file mode 100644 index 000000000..6cdaf6dcf --- /dev/null +++ b/demos/ARMCM3-LPC1343-OLIMEX/main.c @@ -0,0 +1,112 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+
+/*
+ * LED blinker1 thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker1");
+ while (TRUE) {
+ palClearPad(GPIO3, GPIO3_LED1);
+ chThdSleepMilliseconds(500);
+ palSetPad(GPIO3, GPIO3_LED1);
+ chThdSleepMilliseconds(500);
+ }
+}
+
+/*
+ * LED blinker2 thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread2, 128);
+static msg_t Thread2(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker2");
+ while (TRUE) {
+ palClearPad(GPIO3, GPIO3_LED2);
+ chThdSleepMilliseconds(500);
+ palSetPad(GPIO3, GPIO3_LED2);
+ chThdSleepMilliseconds(480);
+ }
+}
+
+/*
+ * LED scanlight thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread3, 128);
+static msg_t Thread3(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("scanner1");
+ palSetPort(GPIO2, PAL_PORT_BIT(GPIO2_LED5) |
+ PAL_PORT_BIT(GPIO2_LED6) |
+ PAL_PORT_BIT(GPIO2_LED7) |
+ PAL_PORT_BIT(GPIO2_LED8));
+ while (TRUE) {
+ palClearPort( GPIO2, PAL_PORT_BIT(GPIO2_LED5));
+ chThdSleepMilliseconds(50);
+ palSetPort( GPIO2, PAL_PORT_BIT(GPIO2_LED8));
+ chThdSleepMilliseconds(150);
+ palClearPort( GPIO2, PAL_PORT_BIT(GPIO2_LED6));
+ chThdSleepMilliseconds(50);
+ palSetPort( GPIO2, PAL_PORT_BIT(GPIO2_LED5));
+ chThdSleepMilliseconds(150);
+ palClearPort( GPIO2, PAL_PORT_BIT(GPIO2_LED7));
+ chThdSleepMilliseconds(50);
+ palSetPort( GPIO2, PAL_PORT_BIT(GPIO2_LED6));
+ chThdSleepMilliseconds(150);
+ palClearPort( GPIO2, PAL_PORT_BIT(GPIO2_LED8));
+ chThdSleepMilliseconds(50);
+ palSetPort( GPIO2, PAL_PORT_BIT(GPIO2_LED7));
+ chThdSleepMilliseconds(150);
+ }
+}
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Creates the LED threads.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+ chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
+ chThdCreateStatic(waThread3, sizeof(waThread3), NORMALPRIO, Thread3, NULL);
+
+ /*
+ * Normal main() thread activity, in this demo it does nothing.
+ */
+ while (TRUE) {
+ chThdSleepMilliseconds(500);
+ }
+}
|