73 lines
1.2 KiB
C
Raw Normal View History

2020-10-18 22:02:17 +02:00
#include <string.h>
#include <stdint.h>
2020-10-24 19:34:30 +02:00
#include <stdbool.h>
2020-10-18 22:02:17 +02:00
#include <PontCoopScheduler.h>
#include <stdlib.h>
#include <main.h>
#include <usart.h>
2020-10-27 15:12:19 +01:00
#include <led.h>
#include <loopCtrl.h>
2020-10-18 22:02:17 +02:00
void my_setup_1() {
2020-10-27 15:12:19 +01:00
schInit();
2020-10-18 22:02:17 +02:00
}
void my_errorHandler() {
2020-10-27 15:12:19 +01:00
ledRed(true);
2020-10-18 22:02:17 +02:00
}
void blinkRed(void *handle) {
2020-10-27 15:12:19 +01:00
static bool on = false;
ledRed(on);
on ^= true;
2020-10-18 22:02:17 +02:00
}
void blinkGreen(void *handle) {
2020-10-27 15:12:19 +01:00
static bool on = false;
ledGreen(on);
on ^= true;
2020-10-18 22:02:17 +02:00
}
void helloWorld(void *handle) {
2020-10-27 15:12:19 +01:00
static char hello[] = "Hello World\n\r";
HAL_UART_Transmit_IT(&debugUart, (uint8_t*) hello, strlen(hello));
2020-10-18 22:02:17 +02:00
}
2020-10-25 15:37:16 +01:00
void helloMeterbus(void *handle) {
2020-10-27 15:12:19 +01:00
static char hello[] = "Hello Meterbus\n\r";
HAL_UART_Transmit_IT(&mbusUart, (uint8_t*) hello, strlen(hello));
}
2020-10-24 19:34:30 +02:00
void toggleLoop(void *handle) {
2020-10-27 15:12:19 +01:00
static bool state = false;
if (state) {
loopDisable();
} else {
loopEnable();
}
state ^= true;
2020-10-24 19:34:30 +02:00
}
2020-10-18 22:02:17 +02:00
void my_setup_2() {
2020-10-27 15:12:19 +01:00
ledRed(false);
ledGreen(true);
schAdd(helloWorld, NULL, 0, 5000);
schAdd(toggleLoop, NULL, 0, 10000);
schAdd(helloMeterbus, NULL, 0, 1000);
2020-10-25 15:37:16 +01:00
2020-10-18 22:02:17 +02:00
}
void my_loop() {
2020-10-27 15:12:19 +01:00
schExec();
2020-10-18 22:02:17 +02:00
}
void SYSTICK_Callback() {
2020-10-27 15:12:19 +01:00
schUpdate();
2020-10-18 22:02:17 +02:00
}