/* GPIO interrupt callback handler. This is received from * the interrupt context. So DebugPrint API is not available * from here. Set an event in the event group so that the * GPIO thread can print the event information. */ void CyFxGpioIntrCb ( uint8_t gpioId /* Indicates the pin that triggered the interrupt */ ) { CyBool_t gpioValue = CyFalse; CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS; /* Get the status of the pin */ apiRetStatus = CyU3PGpioGetValue (gpioId, &gpioValue); if (apiRetStatus == CY_U3P_SUCCESS) { /* Check status of the pin */ if (gpioValue == CyTrue) { /* Set GPIO high event */ CyU3PEventSet(&glFxGpioAppEvent, CY_FX_GPIOAPP_GPIO_HIGH_EVENT, CYU3P_EVENT_OR); } else { /* Set GPIO low Event */ CyU3PEventSet(&glFxGpioAppEvent, CY_FX_GPIOAPP_GPIO_LOW_EVENT, CYU3P_EVENT_OR); } } }
uint16_t uxn1330_read(CyU3PDmaBuffer_t* pBuf) { memset(pBuf->buffer,0,gRdwrCmd.header.transfer_length); switch ( gRdwrCmd.header.reg_addr ) { case UXN1330_VERSION: { uint32_t version=VERSION; CyU3PMemCopy( pBuf->buffer, (uint8_t*)&version, sizeof(version) ); return 0; } case UXN1330_LP_B: case UXN1330_V18_EN: case UXN1330_VCON_EN: { CyBool_t val; CyU3PReturnStatus_t ret; ret=CyU3PGpioGetValue( gRdwrCmd.header.reg_addr, &val ); log_debug ( "gpio pin %d val: %d\n", gRdwrCmd.header.reg_addr, val ); if (ret == CY_U3P_SUCCESS) { pBuf->buffer[0] = val; pBuf->buffer[1] = 0; return 0; } else { log_error ( "gpio read failed: %d\n", ret ); } } break; case UXN1330_VCON_POT: { uint8_t val; uint16_t ret=rdwr_vcon_pot(&val,CyFalse); if (ret == CY_U3P_SUCCESS) { pBuf->buffer[0] = val; pBuf->buffer[1] = 0; return 0; } return ret; } break; default: log_info("Unhandled UXN1330 read reg addr: %d\n", gRdwrCmd.header.reg_addr ); } return 1; }
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; }