93 lines
1.5 KiB
C
93 lines
1.5 KiB
C
#include "F28x_Project.h"
|
|
#include <stdio.h>
|
|
#include "keyFSM.h"
|
|
#include "childFSM.h"
|
|
#include "parentFSM.h"
|
|
#include "FSM_public.h"
|
|
|
|
#define LED_BLINKY_GPIO 2
|
|
#define INPUT_GPIO 15
|
|
|
|
#pragma diag_suppress 303
|
|
|
|
uint32_t exec_time[50];
|
|
uint32_t stop_time;
|
|
int index = 0;
|
|
|
|
inline void tic(){
|
|
CpuTimer1Regs.TCR.bit.TSS = 1; // stop the timer
|
|
CpuTimer1Regs.TCR.bit.TRB = 1; // 1 = reload timer
|
|
CpuTimer1Regs.TCR.bit.TSS = 0; // start the timer
|
|
}
|
|
|
|
|
|
inline void toc(uint16_t index){
|
|
stop_time = CpuTimer1.RegsAddr->TIM.all;
|
|
CpuTimer1Regs.TCR.bit.TSS = 1;
|
|
exec_time[index] = CpuTimer1.RegsAddr->PRD.all - stop_time;
|
|
}
|
|
|
|
|
|
int isDown = 0;
|
|
|
|
|
|
|
|
|
|
|
|
KeyFSM* keyFSM;
|
|
KeyFSMData* data;
|
|
KeyIn keystat;
|
|
|
|
void keyFSMTest(){
|
|
keyFSM = createKeyFSM();
|
|
|
|
printf("hello 28377\n");
|
|
|
|
while(1){
|
|
|
|
keystat = !GPIO_ReadPin(INPUT_GPIO);
|
|
|
|
tic();
|
|
Step(keyFSM);
|
|
toc(index++);
|
|
|
|
KeyOut out = readKeyFSMOut(keyFSM);
|
|
if(out != Idle){
|
|
printf("\t\t\t\t%d\n", out);
|
|
}
|
|
else{
|
|
index--;
|
|
}
|
|
|
|
DELAY_US(20*1000);
|
|
}
|
|
}
|
|
|
|
typedef int (*fcn)(int, int);
|
|
int printtest(int a, int b){
|
|
return a+b;
|
|
}
|
|
|
|
|
|
void main(void)
|
|
{
|
|
InitSysCtrl();
|
|
InitGpio();
|
|
InitCpuTimers();
|
|
ConfigCpuTimer(&CpuTimer1, 200, 100000);
|
|
CpuTimer1Regs.TCR.all = 0x0000;
|
|
|
|
GPIO_SetupPinOptions(LED_BLINKY_GPIO, GPIO_OUTPUT, GPIO_PUSHPULL);
|
|
GPIO_SetupPinMux(LED_BLINKY_GPIO, GPIO_MUX_CPU1, 0);
|
|
GPIO_SetupPinOptions(INPUT_GPIO, GPIO_INPUT, GPIO_PULLUP);
|
|
|
|
keyFSMTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|