#include "xparameters.h" #include "xbasic_types.h" #include "xgpio.h" /* The below code instantiates instances of the drivers used to interact with peripherals such as timers, general purpose io, etc. It provides a layer of abstraction with a nice API so that we don't have to manually write to control registers like on the AVR, instead we can call a function such as Initialize() or Start(). Do not remove the following 3 lines. */ XGpio led_gpio; /* The driver instance for the LED GPIO (general purpose input/output) */ XGpio button_gpio; /* The driver instance for the Button GPIO */ XGpio switch_gpio; /* The driver instance for the Switch GPIO */ volatile unsigned int SM_Period = 1000; //default 1000 ms period volatile unsigned int SM_Counter = 0; volatile unsigned char timer_flag = 0; unsigned int test = 1; void TimerInterrupt(void* CallBackRef) { //fill this in. } enum SM_States { INIT, S0 } SM_State; void SM_Tick() { //complete the state machine switch(SM_State) { //transitions case INIT: break; } switch(SM_State) { //actions case S0: break; } } void InitProcessor() { XGpio_Initialize(&led_gpio, XPAR_LEDS_1_DEVICE_ID); //Init LEDs GPIO driver XGpio_Initialize(&button_gpio, XPAR_PUSH_BUTTONS_1_DEVICE_ID); //Init Buttons GPIO driver XGpio_Initialize(&switch_gpio, XPAR_DIP_SWITCHES_1_DEVICE_ID); //Init Switches GPIO driver //Set data direction registers - 0 for output, 1 for input. // XGpio_SetDataDirection(&led_gpio, 1, /*????*/); //LEDs are outputs //setup timer interrupt microblaze_register_handler((XInterruptHandler)TimerInterrupt, (void*)0); microblaze_enable_interrupts(); //enable global interrupts } int main (void) { //Initialize Processor// InitProcessor(); while(1) { //fill this in } }