|
@@ -9,6 +9,7 @@
|
|
|
#include <stdlib.h>
|
|
|
#include <avr/io.h>
|
|
|
#include <avr/interrupt.h>
|
|
|
+#include <avr/sleep.h >
|
|
|
|
|
|
#include "main.h"
|
|
|
#include "i2c.h"
|
|
@@ -33,6 +34,8 @@ volatile struct {
|
|
|
/* Constants */
|
|
|
/* Function prototypes */
|
|
|
void Board_Init(void);
|
|
|
+void onDot(void);
|
|
|
+void offDot(void);
|
|
|
|
|
|
void main(void) {
|
|
|
/**
|
|
@@ -57,25 +60,36 @@ void main(void) {
|
|
|
// Initialize Event State Machine
|
|
|
ES_Init(stNoChange);
|
|
|
|
|
|
+ //RTOS_SetTask(onDot, 0, 1000);
|
|
|
+ //RTOS_SetTask(offDot, 500, 1000);
|
|
|
+
|
|
|
/** main loop */
|
|
|
do {
|
|
|
-
|
|
|
if (Flag.RTC_Int != 0) {
|
|
|
Flag.RTC_Int = 0;
|
|
|
+
|
|
|
RTC_ReadTime(&RTC);
|
|
|
Digit[0] = RTC.Min >> 4;
|
|
|
Digit[1] = RTC.Min & 0x0F;
|
|
|
Digit[2] = RTC.Sec >> 4;
|
|
|
Digit[3] = RTC.Sec & 0x0F;
|
|
|
+
|
|
|
+ onDot();
|
|
|
+ RTOS_SetTask(offDot, 500, 0);
|
|
|
}
|
|
|
- // крутим диспетчер
|
|
|
- RTOS_DispatchTask();
|
|
|
|
|
|
event = ES_GetEvent();
|
|
|
if (event) {
|
|
|
ES_Dispatch(event);
|
|
|
}
|
|
|
|
|
|
+ // крутим диспетчер
|
|
|
+ RTOS_DispatchTask();
|
|
|
+
|
|
|
+ // делать нечего -- спим, ждём прерывание
|
|
|
+ set_sleep_mode(SLEEP_MODE_IDLE);
|
|
|
+ sleep_mode();
|
|
|
+
|
|
|
} while(1);
|
|
|
}
|
|
|
|
|
@@ -108,6 +122,15 @@ void Board_Init(void) {
|
|
|
sei();
|
|
|
}
|
|
|
|
|
|
+void onDot(void) {
|
|
|
+ PORTD |= DOT_PIN;
|
|
|
+}
|
|
|
+
|
|
|
+void offDot(void) {
|
|
|
+ PORTD &= ~(DOT_PIN);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* П р е р ы в а н и я
|
|
|
*/
|
|
@@ -115,9 +138,7 @@ void Board_Init(void) {
|
|
|
/**
|
|
|
* @brief RTC one seconds interrupt
|
|
|
*/
|
|
|
-ISR (INT0_vect) {
|
|
|
- // Blink Dot for test
|
|
|
- PIND |= DOT_PIN;
|
|
|
+ISR (INT1_vect) {
|
|
|
Flag.RTC_Int = 1;
|
|
|
}
|
|
|
|