/* Application define function which creates the threads. */ void CyFxApplicationDefine ( void) { void *ptr = NULL; CyU3PReturnStatus_t status = CY_U3P_SUCCESS; /* Allocate the memory for the threads */ ptr = CyU3PMemAlloc (CY_FX_APPLN_THREAD_STACK); /* Create the thread for the application */ status = CyU3PThreadCreate (&applnThread, /* App Thread structure */ "21:USB_DEBUG", /* Thread ID and Thread name */ ApplnThread_Entry, /* App Thread Entry function */ 0, /* No input parameter to thread */ ptr, /* Pointer to the allocated thread stack */ CY_FX_APPLN_THREAD_STACK, /* App Thread stack size */ CY_FX_APPLN_THREAD_PRIORITY, /* App Thread priority */ CY_FX_APPLN_THREAD_PRIORITY, /* App Thread pre-emption threshold */ CYU3P_NO_TIME_SLICE, /* No time slice for the application thread */ CYU3P_AUTO_START /* Start the Thread immediately */ ); /* Check the return code */ if (status != 0) { /* Add custom recovery or debug actions here */ /* Application cannot continue */ /* Loop indefinitely */ while(1); } }
/* * Create the application thread and other OS objects required for this example. */ void CyFxApplicationDefine ( void) { void *ptr; uint32_t txstatus; /* Allocate the memory for the threads */ ptr = CyU3PMemAlloc (CYFXAPP_STACK_SIZE); if (ptr == 0) goto error; /* Event structure used by this application. */ txstatus = CyU3PEventCreate (&fxAppEvent); if (txstatus != 0) goto error; /* Create the thread for the application */ txstatus = CyU3PThreadCreate (&fxAppThread, "25:GpifToStorage App", GpifAppThreadEntry, 0, ptr, CYFXAPP_STACK_SIZE, CYFXAPP_THREAD_PRIORITY, CYFXAPP_THREAD_PRIORITY, CYU3P_NO_TIME_SLICE, CYU3P_AUTO_START); if (txstatus != 0) goto error; return; error: /* Application cannot continue. Loop indefinitely. */ while (1); }
/* Application define function which creates the threads. */ void CyFxApplicationDefine ( void) { void *ptr = NULL; uint32_t retThrdCreate = CY_U3P_SUCCESS; /* Allocate the memory for the threads */ ptr = CyU3PMemAlloc (CY_FX_UARTLP_THREAD_STACK); /* Create the thread for the application */ retThrdCreate = CyU3PThreadCreate (&UartLpAppThread, /* UART Example App Thread structure */ "21:UART_loopback_register_mode", /* Thread ID and Thread name */ UartLpAppThread_Entry, /* UART Example App Thread Entry function */ 0, /* No input parameter to thread */ ptr, /* Pointer to the allocated thread stack */ CY_FX_UARTLP_THREAD_STACK, /* UART Example App Thread stack size */ CY_FX_UARTLP_THREAD_PRIORITY, /* UART Example App Thread priority */ CY_FX_UARTLP_THREAD_PRIORITY, /* UART Example App Thread priority */ CYU3P_NO_TIME_SLICE, /* No time slice for the application thread */ CYU3P_AUTO_START /* Start the Thread immediately */ ); /* Check the return code */ if (retThrdCreate != 0) { /* Thread creation failed with the error code retThrdCreate */ /* Add custom recovery or debug actions here */ /* Application cannot continue */ /* Loop indefinitely */ while(1); } }
/* This function shall be invoked by the API library * and should not be explicitly invoked. * If other buffer sizes are required by the application code, this function must * be modified to create other block pools. */ void CyU3PDmaBufferInit ( void) { uint32_t status, size; uint32_t tmp; /* If buffer manager has already been initialized, just return. */ if ((glBufferManager.startAddr != 0) && (glBufferManager.regionSize != 0)) { return; } /* Create a mutex variable for safe allocation. */ status = CyU3PMutexCreate (&glBufferManager.lock, CYU3P_NO_INHERIT); if (status != CY_U3P_SUCCESS) { return; } /* No threads are running at this point in time. There is no need to get the mutex. */ /* Allocate the memory buffer to be used to track memory status. We need one bit per 32 bytes of memory buffer space. Since a 32 bit array is being used, round up to the necessary number of 32 bit words. */ size = ((CY_U3P_BUFFER_HEAP_SIZE / 32) + 31) / 32; glBufferManager.usedStatus = (uint32_t *)CyU3PMemAlloc (size * 4); if (glBufferManager.usedStatus == 0) { CyU3PMutexDestroy (&glBufferManager.lock); return; } /* Initially mark all memory as available. If there are any status bits beyond the valid memory range, mark these as unavailable. */ CyU3PMemSet ((uint8_t *)glBufferManager.usedStatus, 0, (size * 4)); if ((CY_U3P_BUFFER_HEAP_SIZE / 32) & 31) { tmp = 32 - ((CY_U3P_BUFFER_HEAP_SIZE / 32) & 31); glBufferManager.usedStatus[size - 1] = ~((1 << tmp) - 1); } /* Initialize the start address and region size variables. */ glBufferManager.startAddr = CY_U3P_BUFFER_HEAP_BASE; glBufferManager.regionSize = CY_U3P_BUFFER_HEAP_SIZE; glBufferManager.statusSize = size; glBufferManager.searchPos = 0; }
/* Application define function which creates the threads. */ void CyFxApplicationDefine ( void) { void *ptr = NULL; uint32_t retThrdCreate = CY_U3P_SUCCESS; /* Allocate the memory for the threads */ ptr = CyU3PMemAlloc (CY_FX_GPIOAPP_THREAD_STACK); /* Create the thread for the application */ retThrdCreate = CyU3PThreadCreate (&gpioPWMThread, /* GPIO Example App Thread structure */ "21:GPIO_PWM", /* Thread ID and Thread name */ GpioPWMThread_Entry, /* GPIO Example App Thread Entry function */ 0, /* No input parameter to thread */ ptr, /* Pointer to the allocated thread stack */ CY_FX_GPIOAPP_THREAD_STACK, /* Thread stack size */ CY_FX_GPIOAPP_THREAD_PRIORITY, /* Thread priority */ CY_FX_GPIOAPP_THREAD_PRIORITY, /* Pre-emption threshold for the thread. */ CYU3P_NO_TIME_SLICE, /* No time slice for the application thread */ CYU3P_AUTO_START /* Start the Thread immediately */ ); /* Check the return code */ if (retThrdCreate != 0) { /* Thread creation failed with the error code retThrdCreate */ /* Add custom recovery or debug actions here */ /* Application cannot continue */ /* Loop indefinitely */ while(1); } /* Allocate the memory for the threads */ ptr = CyU3PMemAlloc (CY_FX_GPIOAPP_THREAD_STACK); /* Create the thread for the application */ retThrdCreate = CyU3PThreadCreate (&gpioMeasureThread, /* GPIO Example App Thread structure */ "22:GPIO_measure", /* Thread ID and Thread name */ GpioMeasureThread_Entry, /* GPIO Example App Thread entry function */ 0, /* No input parameter to thread */ ptr, /* Pointer to the allocated thread stack */ CY_FX_GPIOAPP_THREAD_STACK, /* Thread stack size */ CY_FX_GPIOAPP_THREAD_PRIORITY, /* Thread priority */ CY_FX_GPIOAPP_THREAD_PRIORITY, /* Pre-emption threshold for the thread */ CYU3P_NO_TIME_SLICE, /* No time slice for the application thread */ CYU3P_AUTO_START /* Start the Thread immediately */ ); /* Check the return code */ if (retThrdCreate != 0) { /* Thread creation failed with the error code retThrdCreate */ /* Add custom recovery or debug actions here */ /* Application cannot continue */ /* Loop indefinitely */ while(1); } /* Allocate the memory for the threads */ ptr = CyU3PMemAlloc (CY_FX_GPIOAPP_THREAD_STACK); /* Create the thread for the application */ retThrdCreate = CyU3PThreadCreate (&gpioCounterThread, /* GPIO Example App Thread structure */ "23:GPIO_counter", /* Thread ID and Thread name */ GpioCounterThread_Entry, /* GPIO Example App Thread entry function */ 0, /* No input parameter to thread */ ptr, /* Pointer to the allocated thread stack */ CY_FX_GPIOAPP_THREAD_STACK, /* Thread stack size */ CY_FX_GPIOAPP_THREAD_PRIORITY, /* Thread priority */ CY_FX_GPIOAPP_THREAD_PRIORITY, /* Pre-emption threshold for the thread */ CYU3P_NO_TIME_SLICE, /* No time slice for the application thread */ CYU3P_AUTO_START /* Start the Thread immediately */ ); /* Check the return code */ if (retThrdCreate != 0) { /* Thread creation failed with the error code retThrdCreate */ /* Add custom recovery or debug actions here */ /* Application cannot continue */ /* Loop indefinitely */ while(1); } }