alarm stuff
This commit is contained in:
parent
56f96e5f26
commit
4739491654
@ -98,9 +98,10 @@ PB9.GPIOParameters=GPIO_Label
|
||||
PB9.GPIO_Label=OLED_RST
|
||||
PB9.Locked=true
|
||||
PB9.Signal=GPIO_Output
|
||||
PC13-TAMPER-RTC.GPIOParameters=GPIO_Label
|
||||
PC13-TAMPER-RTC.GPIOParameters=PinState,GPIO_Label
|
||||
PC13-TAMPER-RTC.GPIO_Label=LED
|
||||
PC13-TAMPER-RTC.Locked=true
|
||||
PC13-TAMPER-RTC.PinState=GPIO_PIN_RESET
|
||||
PC13-TAMPER-RTC.Signal=GPIO_Output
|
||||
PC14-OSC32_IN.GPIOParameters=GPIO_Label
|
||||
PC14-OSC32_IN.GPIO_Label=ERROR
|
||||
|
24
my_src/alarm.c
Normal file
24
my_src/alarm.c
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* alarm.c
|
||||
*
|
||||
* Created on: Jun 2, 2017
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
|
||||
void blink(void *handle) {
|
||||
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
|
||||
}
|
||||
|
||||
|
||||
void enableAlarm() {
|
||||
schAdd(blink, NULL, 0, 100);
|
||||
}
|
||||
|
||||
void disableAlarm() {
|
||||
schDel(blink, NULL);
|
||||
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, RESET);
|
||||
}
|
16
my_src/alarm.h
Normal file
16
my_src/alarm.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* alarm.h
|
||||
*
|
||||
* Created on: Jun 2, 2017
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef ALARM_H_
|
||||
#define ALARM_H_
|
||||
|
||||
|
||||
void enableAlarm();
|
||||
void disableAlarm();
|
||||
|
||||
|
||||
#endif /* ALARM_H_ */
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "display.h"
|
||||
#include "alarm.h"
|
||||
#include <PontCoopScheduler.h>
|
||||
|
||||
|
||||
@ -124,6 +125,9 @@ void buttonShort() {
|
||||
toggleSetMode();
|
||||
} else if (display.timerState == IDLE) {
|
||||
startTimer();
|
||||
} else if (display.timerState == RUNNING || display.timerState == OVERRUN) {
|
||||
stopTimer();
|
||||
disableAlarm();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,13 +26,9 @@
|
||||
|
||||
extern tDisplay display;
|
||||
|
||||
void blink(void *handle) {
|
||||
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
|
||||
}
|
||||
|
||||
void my_setup_1() {
|
||||
schInit();
|
||||
// schAdd(blink, NULL, 0, 100);
|
||||
schAdd(updateDisplay, &display, 0, 250);
|
||||
schAdd(secondTick, &display, 0, 1000);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "timer.h"
|
||||
#include "display.h"
|
||||
#include "alarm.h"
|
||||
|
||||
|
||||
extern tDisplay display;
|
||||
@ -15,23 +16,32 @@ void startTimer() {
|
||||
display.timerState = STARTED;
|
||||
}
|
||||
|
||||
void stopTimer() {
|
||||
display.timerState = IDLE;
|
||||
}
|
||||
|
||||
void secondTick(void *handle) {
|
||||
tDisplay *lDisplay = (tDisplay*) handle;
|
||||
|
||||
switch (lDisplay->timerState) {
|
||||
case STARTED:
|
||||
lDisplay->currentTime = lDisplay->targetTime;
|
||||
lDisplay->overrunTime = 0;
|
||||
lDisplay->timerState = RUNNING;
|
||||
break;
|
||||
case RUNNING:
|
||||
lDisplay->currentTime -= 1;
|
||||
if (lDisplay->currentTime == 0) {
|
||||
enableAlarm();
|
||||
lDisplay->timerState = OVERRUN;
|
||||
}
|
||||
break;
|
||||
case OVERRUN:
|
||||
lDisplay->overrunTime += 1;
|
||||
break;
|
||||
case IDLE:
|
||||
;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ typedef enum {
|
||||
|
||||
void secondTick(void *handle);
|
||||
void startTimer();
|
||||
void stopTimer();
|
||||
|
||||
#endif /* TIMER_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user