Commit b0b71c34 authored by Dejan Priversek's avatar Dejan Priversek
Browse files

fix fx3 callback _SETCONF

parent 862efb71
2019-06-16
; bugfix FX3 callback _SETCONF
2019-03-14
; Initial Release
\ No newline at end of file
......@@ -876,4 +876,5 @@
<resource resourceType="PROJECT" workspacePath="/FX3fw"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>
......@@ -82,8 +82,8 @@ CyU3PReturnStatus_t CyFxConfigFpga(uint32_t uiLen)
apiRetStatus |= CyU3PSpiSetSsnLine (CyTrue);
CyU3PThreadSleep(100); // Allow FPGA to startup
/* Check if FPGA is now ready by testing the FPGA_Init_B signal */
apiRetStatus |= CyU3PGpioSimpleGetValue (FPGA_INIT_B, &xFpga_Init_B);
if( (xFpga_Init_B != CyTrue) || (apiRetStatus != CY_U3P_SUCCESS) ){
apiRetStatus |= CyU3PGpioSimpleGetValue (FPGA_INIT_B, &xFpga_Init_B);
if( (xFpga_Init_B != CyTrue) || (apiRetStatus != CY_U3P_SUCCESS) ){
return apiRetStatus;
}
......@@ -113,7 +113,7 @@ CyU3PReturnStatus_t CyFxConfigFpga(uint32_t uiLen)
}
}
CyU3PThreadSleep(1);
CyU3PThreadSleep(10);
apiRetStatus |= CyU3PGpioSimpleGetValue (FPGA_DONE, &xFpga_Done);
if( (xFpga_Done != CyTrue) ){
......@@ -135,6 +135,8 @@ CyFxConfigFpgaApplnStart (
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
CyU3PUSBSpeed_t usbSpeed = CyU3PUsbGetSpeed();
CyU3PDebugPrint (4, "CyFxConfigFpgaApplnStart...");
/* First identify the usb speed. Once that is identified,
* create a DMA channel and start the transfer on this. */
......@@ -215,7 +217,6 @@ CyFxConfigFpgaApplnStart (
/* Update the status flag. */
glIsApplnActive = CyTrue;
}
......@@ -223,6 +224,8 @@ void
CyFxConfigFpgaApplnStop(
void)
{
CyU3PDebugPrint (4, "CyFxConfigFpgaApplnStop...\n\r");
//CyU3PEpConfig_t epCfg;
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
......@@ -242,9 +245,14 @@ CyFxConfigFpgaApplnStop(
/* Flush the endpoint memory */
CyU3PUsbFlushEp(P_DCONFIG_EP2OUT);
/* Destroy the channel */
CyU3PDmaChannelDestroy (&glChHandleUtoCPU);
apiRetStatus = CyU3PDmaChannelDestroy (&glChHandleUtoCPU);
if (apiRetStatus != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "CyU3PDmaChannelDestroy failed, Error code = %d\n", apiRetStatus);
CyFxAppErrorHandler (apiRetStatus);
}
#if 0
/* Disable endpoints. */
CyU3PMemSet ((uint8_t *)&epCfg, 0, sizeof (epCfg));
......
......@@ -54,7 +54,7 @@ extern uint32_t filelen; /* length of Configuration file (.bin) */
extern uint16_t uiPacketSize;
extern volatile CyBool_t glIsApplnActive;
extern CyBool_t glIsApplnActive;
extern CyU3PEvent glFxConfigFpgaAppEvent; /* Configure FPGA event group. */
......
......@@ -45,7 +45,7 @@ CyU3PDmaChannel glChHandleSlFifoPtoU_EP6IN; /* DMA Channel handle for P2U tran
uint32_t glDMARxCount = 0; /* Counter to track the number of buffers received from USB. */
uint32_t glDMATxCount = 0; /* Counter to track the number of buffers sent to USB. */
volatile CyBool_t glIsApplnActive = CyFalse; /* Whether the loopback application is active or not. */
CyBool_t glIsApplnActive = CyFalse; /* Whether the loopback application is active or not. */
//uint8_t glEp0Buffer[32]; /* Buffer used for sending EP0 data. */
uint8_t glEp0Buffer[4096] __attribute__ ((aligned (32)));
/* Firmware ID variable that may be used to verify I2C firmware. */
......@@ -468,7 +468,9 @@ void
CyFxSlFifoApplnStop (
void)
{
CyU3PEpConfig_t epCfg;
CyU3PDebugPrint (4, "CyFxSlFifoApplnStop...\n");
CyU3PEpConfig_t epCfg;
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
/* Update the flag. */
......@@ -483,6 +485,7 @@ CyFxSlFifoApplnStop (
CyU3PDmaChannelDestroy (&glChHandleSlFifoUtoP_EP4OUT);
CyU3PDmaChannelDestroy (&glChHandleSlFifoUtoP_EP2OUT);
CyU3PDmaChannelDestroy (&glChHandleSlFifoPtoU_EP6IN);
CyU3PDmaChannelDestroy (&glChHandleUtoCPU);
/* Disable endpoints. */
CyU3PMemSet ((uint8_t *)&epCfg, 0, sizeof (epCfg));
......@@ -892,21 +895,28 @@ CyFxSlFifoApplnUSBEventCB (
uint16_t evdata
)
{
switch (evtype)
CyU3PDebugPrint (4, "CyFxSlFifoApplnUSBEventCB, event %d\n\r", evtype);
CyU3PDebugPrint (4, "CyFxSlFifoApplnUSBEventCB, glIsApplnActive %d\n\r", glIsApplnActive);
switch (evtype)
{
case CY_U3P_USB_EVENT_SETCONF:
case CY_U3P_USB_EVENT_SETCONF:
/* Stop the application before re-starting. */
if (glIsApplnActive)
{
CyFxSlFifoApplnStop ();
CyU3PDebugPrint (4, "CY_U3P_USB_EVENT_SETCONF: Stopping CyFxSlFifoApp...\n\r");
}
CyU3PUsbLPMDisable();
/* Start the loop back function. */
CyU3PDebugPrint (4, "CY_U3P_USB_EVENT_SETCONF: Starting CyFxConfigFpgaApplnstart...\n\r");
CyFxConfigFpgaApplnStart();
CyU3PDebugPrint (4, "glIsApplnActive = %d\n\r", glIsApplnActive);
break;
case CY_U3P_USB_EVENT_RESET:
CyU3PDebugPrint (4, "glIsApplnActive = %d\n\r", glIsApplnActive);
break;
case CY_U3P_USB_EVENT_DISCONNECT:
/* Stop the loop back function. */
if (glIsApplnActive)
......@@ -916,6 +926,7 @@ CyFxSlFifoApplnUSBEventCB (
//CyU3PDmaChannelReset (&glI2cRxHandle);
CyFxSlFifoApplnStop ();
}
CyU3PDebugPrint (4, "glIsApplnActive = %d\n\r", glIsApplnActive);
break;
default:
......@@ -1114,7 +1125,7 @@ SlFifoAppThread_Entry (
for (;;)
{
/*CyU3PThreadSleep (1000);*/
CyU3PThreadSleep(10);
if (glIsApplnActive)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment