aboutsummaryrefslogtreecommitdiffstats
path: root/demos/STM32/CMSIS-STM32F407-DISCOVERY/main.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-10-07 12:53:22 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-10-07 12:53:22 +0000
commit8920d3403cf0fdde0e17a902ca5c137876e2fce1 (patch)
tree44d823f4bf595e12a4d46847001639f871831ec2 /demos/STM32/CMSIS-STM32F407-DISCOVERY/main.c
parent9edf99296c5936809842f3af03267540d481da1a (diff)
downloadChibiOS-8920d3403cf0fdde0e17a902ca5c137876e2fce1.tar.gz
ChibiOS-8920d3403cf0fdde0e17a902ca5c137876e2fce1.tar.bz2
ChibiOS-8920d3403cf0fdde0e17a902ca5c137876e2fce1.zip
Added messages to CMSIS RTOS, added demo for the STM32F407.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7383 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos/STM32/CMSIS-STM32F407-DISCOVERY/main.c')
-rw-r--r--demos/STM32/CMSIS-STM32F407-DISCOVERY/main.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/demos/STM32/CMSIS-STM32F407-DISCOVERY/main.c b/demos/STM32/CMSIS-STM32F407-DISCOVERY/main.c
new file mode 100644
index 000000000..a0388b92b
--- /dev/null
+++ b/demos/STM32/CMSIS-STM32F407-DISCOVERY/main.c
@@ -0,0 +1,69 @@
+/*
+ ChibiOS - Copyright (C) 2006-2014 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 "hal.h"
+#include "cmsis_os.h"
+
+/*
+ * This is a periodic thread that does absolutely nothing except flashing
+ * a LED.
+ */
+static void Thread1(void const *arg) {
+
+ (void)arg;
+
+ while (TRUE) {
+ palSetPad(GPIOD, GPIOD_LED3); /* Orange. */
+ osDelay(500);
+ palClearPad(GPIOD, GPIOD_LED3); /* Orange. */
+ osDelay(500);
+ }
+}
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+ osThreadDef(Thread1, osPriorityAboveNormal, 1, 128);
+
+ /* HAL initialization, this also initializes the configured device drivers
+ and performs the board-specific initializations.*/
+ halInit();
+
+ /* The kernel is initialized but not started yet, this means that
+ main() is executing with absolute priority but interrupts are
+ already enabled.*/
+ osKernelInitialize();
+
+ /* Activates the serial driver 2 using the driver default configuration.
+ PA2(TX) and PA3(RX) are routed to USART2.*/
+ sdStart(&SD2, NULL);
+ palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
+ palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));
+
+ /* Creates the example thread, it does not start immediately.*/
+ osThreadCreate(osThread(Thread1), NULL);
+
+ /* Kernel started, the main() thread has priority osPriorityNormal
+ by default.*/
+ osKernelStart();
+
+ /* In the ChibiOS/RT CMSIS RTOS implementation the main() is an
+ usable thread.*/
+ while (TRUE) {
+ osDelay(500);
+ }
+}