aboutsummaryrefslogtreecommitdiff
path: root/stm32f091/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'stm32f091/main.c')
-rw-r--r--stm32f091/main.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/stm32f091/main.c b/stm32f091/main.c
index 180240e..848bfac 100644
--- a/stm32f091/main.c
+++ b/stm32f091/main.c
@@ -1,21 +1,29 @@
+#include <FreeRTOS.h>
+#include <task.h>
#include <stm32f0xx.h>
#include <stdint.h>
#define PORT GPIOA
#define PIN 5
-int main() {
- RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN;
-
- PORT->MODER &= ~(0b11 << (PIN * 2));
- PORT->MODER |= (0b01 << (PIN * 2));
-
+void task_1() {
uint8_t led = 1;
while (1) {
PORT->ODR &= ~(1 << PIN);
PORT->ODR |= (led << PIN);
led ^= 1;
- for (unsigned long i = 0; i < 50000; i++) asm("nop");
+
+ vTaskDelay(1000 / portTICK_RATE_MS);
}
}
+
+int main() {
+ RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN;
+
+ PORT->MODER &= ~(0b11 << (PIN * 2));
+ PORT->MODER |= (0b01 << (PIN * 2));
+
+ xTaskCreate(task_1, "task1", 128, NULL, 1, NULL);
+ vTaskStartScheduler();
+}