mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Working blinky demo using FreeRTOS
This commit is contained in:
@@ -4,11 +4,28 @@
|
||||
#include <timers.h>
|
||||
#include <semphr.h>
|
||||
|
||||
void BlinkGreenLed(void * pvParameters) {
|
||||
while(1) {
|
||||
vTaskDelay(100);
|
||||
GPIO_ODR(GPIOG)->ODR13 = 0;
|
||||
vTaskDelay(100);
|
||||
GPIO_ODR(GPIOG)->ODR13 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void BlinkRedLed(void * pvParameters) {
|
||||
int delay = 10;
|
||||
while (1) {
|
||||
vTaskDelay(delay);
|
||||
GPIO_ODR(GPIOG)->ODR14 = 1;
|
||||
vTaskDelay(delay);
|
||||
GPIO_ODR(GPIOG)->ODR14 = 0;
|
||||
delay++;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
||||
// We want to blink LEDs connected to GPIO pin G13 and G14
|
||||
// We want to blink LEDs connected to GPIO pin G13 and G14
|
||||
// (this is documented in our board's PDF)
|
||||
//
|
||||
// GPIO are grouped by letter, and GPIO "G" live on the "AHB1" bus
|
||||
@@ -22,21 +39,19 @@ int main(int argc, char * argv[]) {
|
||||
GPIO_MODER(GPIOG)->MODER13 = GPIO_MODE_OUTPUT;
|
||||
GPIO_MODER(GPIOG)->MODER14 = GPIO_MODE_OUTPUT;
|
||||
|
||||
// Per doc, the output is push-pull by default (yay)
|
||||
// And we should also set the output speed, but really
|
||||
// we don't care (we're doing something super slow)
|
||||
|
||||
long delay = 50000;
|
||||
BaseType_t success = xTaskCreate(BlinkGreenLed,
|
||||
"BlkGrn",
|
||||
100, // Stack size
|
||||
NULL, // Parameters
|
||||
2,
|
||||
NULL);
|
||||
|
||||
xTaskCreate(BlinkRedLed, "BlkRed", 100, NULL, 2, NULL);
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
||||
while (1) {
|
||||
GPIO_ODR(GPIOG)->ODR13 = 0;
|
||||
GPIO_ODR(GPIOG)->ODR14 = 1;
|
||||
|
||||
// sleep(delay);
|
||||
|
||||
GPIO_ODR(GPIOG)->ODR13 = 1;
|
||||
GPIO_ODR(GPIOG)->ODR14 = 0;
|
||||
|
||||
// sleep(delay);
|
||||
// We should never get here
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user