#include #include #include #include #include #include #include #include #include #include #include #include #include "Drivers.h" void DSP_Init(void); void hwiServiceGPIOINT0A(UArg arg0); void ServiceEOF(UArg arg0,UArg arg1 ); Semaphore_Handle semEOF; Hwi_Handle hwiGPIO; Hwi_Params hwiParams; Task_Params taskParams; Error_Block eb; uint32_T numfilts = 0; uint32_T numEOFs = 0; uint32_T num29s = 0; UInt32 ticks,lastticks; float elapsed; void hwiServiceGPIOINT0A(UArg arg0 ) { /*NOT GETTING HERE*/ Types_FreqHz freq; Timestamp_getFreq(&freq); uint32_T *pgpio_irqstatus_0 = (uint32_T*)(GPIO_IRQSTATUS_0); ticks = (UInt32)Timestamp_get32(); elapsed = ((float)ticks - (float)lastticks)/(float)freq.lo; numEOFs++; lastticks = ticks; /*Check the GPIO_IRQSTATUS_0 to see if pin 29 went high */ if(RD_MEM_32(GPIO_IRQSTATUS_0) & 0x20000000 > 0) { num29s++; } /*Release the interrupt */ RD_MEM_32(GPIO_IRQSTATUS_0,0x20000000); Semaphore_post(semEOF); } void ServiceEOF(UArg arg0,UArg arg1 ) { UInt32 start_time; UInt32 end_time; Uint32 elapse_time; for(;;) { /*Wait until HWI posts semaphore*/ Semaphore_pend(semEOF, BIOS_WAIT_FOREVER); // /* Start timer */ // GetInputs(); // DoStuff(); // WriteOutputs(); } } void main() { DSP_Init(); for(;;); } void DSP_Init(void) { uint32_T a; Error_init(&eb); semEOF = Semaphore_create(0, NULL, &eb); if (semEOF == NULL) { System_abort("Semaphore for EOF create failed"); } Error_init(&eb); Hwi_Params_init(&hwiParams); hwiParams.arg = 5; hwiGPIO = Hwi_create(64, hwiServiceGPIOINT0A, &hwiParams, &eb); /*GPIOINT0A*/ if (hwiGPIO == NULL) { System_abort("Hwi create failed"); } /* Task for image processing */ Task_Params_init(&taskParams); taskParams.priority = 1; taskParams.stackSize = 4000; Task_create (ServiceEOF, &taskParams, NULL); /* Setup GPIO */ /* setup GPIO_SYSCONFIG: No idle, (0x8) */ WR_MEM_32(GPIO_SYSCONFIG, 0x8); /* Interrupts for the GPIO channel must be enabled in the GPIO_IRQSTATUS_SET_0 */ /* Enable interrupt on GPIO_0_29 (0x20000000) */ WR_MEM_32(GPIO_IRQSTATUS_SET_0, 0xFFFFFFFF);//0x20000000; /* The expected event(s) on input GPIO to trigger the interrupt request has to be selected in the * GPIO_RISINGDETECT(0x20000000) */ WR_MEM_32(GPIO_RISINGDETECT, 0xFFFFFFFF);//0x20000000; a = RD_MEM_32(CM_ALWON_GPIO_0_CLKCTRL); WR_MEM_32(CM_ALWON_GPIO_0_CLKCTRL,0x102); // for(;;) // { // a = RD_MEM_32(GPIO_DATAIN); //using this to poll to check if I can see the signal (I can) // } WR_MEM_32(GPIO_IRQSTATUS_0,0xFFFFFFFF); // Dont think I need this, but I was trying to get the interrupt. Hwi_enableInterrupt(64); // Dont think I need this, but I was trying to get the interrupt. a = Hwi_enable();// Dont think I need this, but I was trying to get the interrupt. BIOS_start(); }