/* * Reset the image sensor using GPIO. */ void SensorReset(void) { CyU3PReturnStatus_t apiRetStatus; uint16_t preTick, posTick; /* Drive the GPIO low to reset the sensor. */ //apiRetStatus = CyU3PGpioSetValue(SENSOR_POWER_GPIO, CyFalse); apiRetStatus = CyU3PGpioSetValue(SENSOR_RESET_GPIO, CyFalse); if (apiRetStatus != CY_U3P_SUCCESS) { CyU3PDebugPrint(4, "GPIO Set Value Error, Error Code = %d\n", apiRetStatus); return; } CyU3PDebugPrint(4, "GPIO Set Value\r\n"); /* Wait for some time to allow proper reset. */ uint8_t i = 0; while (i++ < 2){ preTick = CyU3PGetTime(); CyU3PThreadSleep(500); // change the value into 100 from 10. posTick = CyU3PGetTime(); CyU3PDebugPrint(4, "The ticks %d %d \r\n", preTick, posTick); //additional debug //;//CyU3PDebugPrint(4, "cpu pause \r\n"); } /* Drive the GPIO high to bring the sensor out of reset. */ //apiRetStatus = CyU3PGpioSetValue(SENSOR_POWER_GPIO, CyTrue); apiRetStatus = CyU3PGpioSetValue(SENSOR_RESET_GPIO, CyTrue); if (apiRetStatus != CY_U3P_SUCCESS) { CyU3PDebugPrint(4, "GPIO Set Value Error, Error Code = %d\n", apiRetStatus); return; } /* pause the cpu */ while (i++ < 4){ CyU3PThreadSleep(600); // change the value into 100 from 10. //;//CyU3PDebugPrint(4, "cpu pause \r\n"); } return; }
int FpgaBeginProgram(void) { CyBool_t value; unsigned tEnd; CyU3PReturnStatus_t apiRetStatus; apiRetStatus = CyU3PGpioSetValue(GPIO_nCONFIG, CyFalse); if (apiRetStatus != CY_U3P_SUCCESS) { return apiRetStatus; } tEnd = CyU3PGetTime() + 10; while (CyU3PGetTime() < tEnd); apiRetStatus = CyU3PGpioSetValue(GPIO_nCONFIG, CyTrue); tEnd = CyU3PGetTime() + 1000; do { apiRetStatus = CyU3PGpioGetValue(GPIO_nSTATUS, &value); if (CyU3PGetTime() > tEnd) return -1; } while (!value); return 0; }