Created
November 10, 2016 14:56
-
-
Save jetpax/701d65c3270bd2c150447f67c44017a2 to your computer and use it in GitHub Desktop.
Revisions
-
jetpax created this gist
Nov 10, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ typedef void (*FSM)(void); /***************************************************** * FSM: test pin * States */ void smTestPinInit(void); void smTestPinLo(void); void smTestPinHi(void); //FSM Variables unsigned long test_tmr; //Initial state FSM testPinFSM = smTestPinInit; /****************************************************** State functions */ void smTestPinInit(void) { DDRD |= 0x80; // ***DEBUG*** toggle test pin testPinFSM = smTestPinLo; // change state test_tmr = millis(); } void smTestPinLo(void) { if (millis() - test_tmr >= 30){ test_tmr = millis(); PORTD &= ~0x80; // ***DEBUG*** toggle test pin testPinFSM = smTestPinHi; // change state } } void smTestPinHi(void) { if (millis() - test_tmr >= 50){ test_tmr = millis(); PORTD |= 0x80; // ***DEBUG*** toggle test pin testPinFSM = smTestPinLo; // change state } }