some minimal progress
This commit is contained in:
parent
5aa62d9f38
commit
1edf9355aa
@ -37,7 +37,7 @@ BUILD_DIR = build
|
||||
######################################
|
||||
# C sources
|
||||
C_SOURCES = \
|
||||
User/Src/main2.c hottislib/PontCoopScheduler.c \
|
||||
User/Src/main2.c User/Src/led.c User/Src/loopCtrl.c hottislib/PontCoopScheduler.c \
|
||||
Core/Src/main.c \
|
||||
Core/Src/gpio.c \
|
||||
Core/Src/adc.c \
|
||||
|
9
cube/User/Inc/led.h
Normal file
9
cube/User/Inc/led.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef _LED_H_
|
||||
#define _LED_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
void ledRed(bool on);
|
||||
void ledGreen(bool on);
|
||||
|
||||
#endif // _LED_H_
|
8
cube/User/Inc/loopCtrl.h
Normal file
8
cube/User/Inc/loopCtrl.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _LOOPCTRL_H_
|
||||
#define _LOOPCTRL_H_
|
||||
|
||||
void loopEnable();
|
||||
void loopDisable();
|
||||
|
||||
|
||||
#endif // _LOOPCTRL_H_
|
10
cube/User/Src/led.c
Normal file
10
cube/User/Src/led.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <main.h>
|
||||
#include <led.h>
|
||||
|
||||
void ledRed(bool on) {
|
||||
HAL_GPIO_WritePin(LED_Red_GPIO_Port, LED_Red_Pin, on ? GPIO_PIN_SET : GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
void ledGreen(bool on) {
|
||||
HAL_GPIO_WritePin(LED_Green_GPIO_Port, LED_Green_Pin, on ? GPIO_PIN_SET : GPIO_PIN_RESET);
|
||||
}
|
12
cube/User/Src/loopCtrl.c
Normal file
12
cube/User/Src/loopCtrl.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include <main.h>
|
||||
#include <loopCtrl.h>
|
||||
|
||||
void loopEnable() {
|
||||
HAL_GPIO_WritePin(Loop_Enable_GPIO_Port, Loop_Enable_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(Loop_Enable_GPIO_Port, Loop_Enable_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
void loopDisable() {
|
||||
HAL_GPIO_WritePin(Loop_Disable_GPIO_Port, Loop_Disable_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(Loop_Disable_GPIO_Port, Loop_Disable_Pin, GPIO_PIN_RESET);
|
||||
}
|
@ -7,24 +7,29 @@
|
||||
#include <main.h>
|
||||
#include <usart.h>
|
||||
|
||||
#include <led.h>
|
||||
#include <loopCtrl.h>
|
||||
|
||||
void my_setup_1() {
|
||||
schInit();
|
||||
|
||||
}
|
||||
|
||||
void my_errorHandler() {
|
||||
|
||||
ledRed(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void blinkRed(void *handle) {
|
||||
HAL_GPIO_TogglePin(LED_Red_GPIO_Port, LED_Red_Pin);
|
||||
static bool on = false;
|
||||
ledRed(on);
|
||||
on ^= true;
|
||||
}
|
||||
|
||||
void blinkGreen(void *handle) {
|
||||
HAL_GPIO_TogglePin(LED_Green_GPIO_Port, LED_Green_Pin);
|
||||
static bool on = false;
|
||||
ledGreen(on);
|
||||
on ^= true;
|
||||
}
|
||||
|
||||
void helloWorld(void *handle) {
|
||||
@ -37,33 +42,22 @@ void helloMeterbus(void *handle) {
|
||||
HAL_UART_Transmit_IT(&mbusUart, (uint8_t*) hello, strlen(hello));
|
||||
}
|
||||
|
||||
void enableLoop(void *handle) {
|
||||
HAL_GPIO_WritePin(Loop_Enable_GPIO_Port, Loop_Enable_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(Loop_Enable_GPIO_Port, Loop_Enable_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
void disableLoop(void *handle) {
|
||||
HAL_GPIO_WritePin(Loop_Disable_GPIO_Port, Loop_Disable_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(Loop_Disable_GPIO_Port, Loop_Disable_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
void toggleLoop(void *handle) {
|
||||
static bool state = false;
|
||||
|
||||
if (state) {
|
||||
disableLoop(NULL);
|
||||
loopDisable();
|
||||
} else {
|
||||
enableLoop(NULL);
|
||||
loopEnable();
|
||||
}
|
||||
state ^= true;
|
||||
}
|
||||
|
||||
void my_setup_2() {
|
||||
schAdd(blinkRed, NULL, 0, 500);
|
||||
schAdd(blinkGreen, NULL, 0, 1000);
|
||||
ledRed(false);
|
||||
ledGreen(true);
|
||||
|
||||
schAdd(helloWorld, NULL, 0, 5000);
|
||||
// schAdd(enableLoop, NULL, 10000, 0);
|
||||
// schAdd(disableLoop, NULL, 20000, 0);
|
||||
schAdd(toggleLoop, NULL, 0, 10000);
|
||||
schAdd(helloMeterbus, NULL, 0, 1000);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user