void testFiberStackPopW(void) { uint32_t data; /* data used to put and get from the stack queue */ int rc; TC_PRINT("Test Fiber STACK Pop Wait Interfaces\n\n"); rc = nano_fiber_stack_pop(&nanoStackObj2, &data, TICKS_UNLIMITED); TC_PRINT("FIBER STACK Pop from queue2: %d\n", data); /* Verify results */ if ((rc == 0) || (data != myData[0])) { retCode = TC_FAIL; TCERR2; return; } data = myData[1]; TC_PRINT("FIBER STACK Push to queue1: %d\n", data); nano_fiber_stack_push(&nanoStackObj, data); rc = nano_fiber_stack_pop(&nanoStackObj2, &data, TICKS_UNLIMITED); TC_PRINT("FIBER STACK Pop from queue2: %d\n", data); /* Verify results */ if ((rc == 0) || (data != myData[2])) { retCode = TC_FAIL; TCERR2; return; } data = myData[3]; TC_PRINT("FIBER STACK Push to queue1: %d\n", data); nano_fiber_stack_push(&nanoStackObj, data); TC_END_RESULT(retCode); } /* testFiberStackPopW */
void fiber1(void) { uint32_t data; /* data used to put and get from the stack queue */ int count = 0; /* counter */ TC_PRINT("Test Fiber STACK Pop\n\n"); /* Get all data */ while (nano_fiber_stack_pop(&nanoStackObj, &data, TICKS_NONE) != 0) { TC_PRINT("FIBER STACK Pop: count = %d, data is %d\n", count, data); if ((count >= NUM_STACK_ELEMENT) || (data != myData[NUM_STACK_ELEMENT - 1 - count])) { TCERR1(count); retCode = TC_FAIL; return; } count++; } TC_END_RESULT(retCode); PRINT_LINE; /* Put data */ TC_PRINT("Test Fiber STACK Push\n"); TC_PRINT("\nFIBER STACK Put Order: "); for (int i=NUM_STACK_ELEMENT; i>0; i--) { nano_fiber_stack_push(&nanoStackObj, myData[i-1]); TC_PRINT(" %d,", myData[i-1]); } TC_PRINT("\n"); PRINT_LINE; /* Give semaphore to allow the main task to run */ nano_fiber_sem_give(&nanoSemObj); } /* fiber1 */
void stack_fiber1(int par1, int par2) { int i; uint32_t data; ARG_UNUSED(par1); for (i = 0; i < par2 / 2; i++) { data = nano_fiber_stack_pop_wait(&nano_stack_1); if (data != 2 * i) { break; } data = 2 * i; nano_fiber_stack_push(&nano_stack_2, data); data = nano_fiber_stack_pop_wait(&nano_stack_1); if (data != 2 * i + 1) { break; } data = 2 * i + 1; nano_fiber_stack_push(&nano_stack_2, data); } }
/** * * @brief Stack test fiber * * @param par1 Ignored parameter. * @param par2 Number of test loops. * * @return N/A * */ void stack_fiber1(int par1, int par2) { int i; uint32_t data; ARG_UNUSED(par1); for (i = 0; i < par2 / 2; i++) { nano_fiber_stack_pop(&nano_stack_1, &data, TICKS_UNLIMITED); if (data != 2 * i) { break; } data = 2 * i; nano_fiber_stack_push(&nano_stack_2, data); nano_fiber_stack_pop(&nano_stack_1, &data, TICKS_UNLIMITED); if (data != 2 * i + 1) { break; } data = 2 * i + 1; nano_fiber_stack_push(&nano_stack_2, data); } }
void stack_fiber2(int par1, int par2) { int i; uint32_t data; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { data = i; nano_fiber_stack_push(&nano_stack_1, data); data = nano_fiber_stack_pop_wait(&nano_stack_2); if (data != i) { break; } (*pcounter)++; } }
/** * * @brief Stack test fiber * * @param par1 Address of the counter. * @param par2 Number of test cycles. * * @return N/A * */ void stack_fiber2(int par1, int par2) { int i; uint32_t data; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { data = i; nano_fiber_stack_push(&nano_stack_1, data); nano_fiber_stack_pop(&nano_stack_2, &data, TICKS_UNLIMITED); if (data != i) { break; } (*pcounter)++; } }
void stack_fiber3(int par1, int par2) { int i; uint32_t data; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { data = i; nano_fiber_stack_push(&nano_stack_1, data); data = 0xffffffff; while (!nano_fiber_stack_pop(&nano_stack_2, &data)) { fiber_yield(); } if (data != i) { break; } (*pcounter)++; } }
void fiber3(void) { nano_fiber_timer_start(&timer, SECONDS(1)); nano_fiber_timer_test(&timer, TICKS_UNLIMITED); nano_fiber_stack_push(&nanoStackObj, myData[0]); }