-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fifo Remaining Space function + Test File #595
Closed
Closed
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
47105d4
Changes + Test
MichaelMohn f4557f9
comment
MichaelMohn 581c874
removed include
MichaelMohn 1b13d92
end line
MichaelMohn e3b395f
space fix
MichaelMohn 50a821f
one line
MichaelMohn baa1d45
fix again LMFAOO
MichaelMohn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* Copyright (c) 2018-2022 UT Longhorn Racing Solar */ | ||
|
||
#include "common.h" | ||
#include "config.h" | ||
#include "Tasks.h" | ||
#include "stdint.h" | ||
#include "stm32f4xx.h" | ||
#include "BSP_UART.h" | ||
#include "BSP_PLL.h" | ||
#include "BSP_Lights.h" | ||
|
||
#define FIFO_TYPE int | ||
#define FIFO_SIZE (128) | ||
#define FIFO_NAME Test_Fifo | ||
#include "fifo.h" | ||
static Test_Fifo_t testFifo; | ||
|
||
OS_TCB Task1_TCB; | ||
CPU_STK Task1_Stk[DEFAULT_STACK_SIZE]; | ||
|
||
void test(){ | ||
//Check empty Fifo | ||
int out = Test_Fifo_is_empty(&testFifo); | ||
printf("Test 1 expected output: 1, Received: %u", out); | ||
|
||
out = Test_Fifo_is_full(&testFifo); | ||
printf("Test 2 expected output: 0, Received: %u", out); | ||
|
||
//Test partially filled Fifo | ||
Test_Fifo_put(&testFifo, 1); | ||
Test_Fifo_put(&testFifo, 2); | ||
Test_Fifo_put(&testFifo, 3); | ||
|
||
out = Test_Fifo_is_empty(&testFifo); | ||
printf("Test 3 expected output: 0, Received: %u", out); | ||
|
||
out = Test_Fifo_is_full(&testFifo); | ||
printf("Test 4 expected output: 0, Received: %u", out); | ||
|
||
Test_Fifo_get(&testFifo, &out); | ||
printf("Test 5 expected output: 3, Received: %u", out); | ||
|
||
Test_Fifo_peek(&testFifo, &out); | ||
printf("Test 6 expected output: 2, Received: %u", out); | ||
|
||
Test_Fifo_popback(&testFifo, &out); | ||
printf("Test 7 expected output: 2, Received: %u", out); | ||
|
||
out = Test_Fifo_space(&testFifo); | ||
printf("Test 8 expected output: 127, Received: %u", out); | ||
|
||
//Fill the Fifo | ||
for(uint8_t i = 0; i < 127; i++){ | ||
Test_Fifo_put(&testFifo, i); | ||
} | ||
|
||
out = Test_Fifo_is_full(&testFifo); | ||
printf("Test 9 expected output: 1, Received: %u", out); | ||
|
||
out = Test_Fifo_space(&testFifo); | ||
printf("Test 10 expected output: 0, Received: %u", out); | ||
} | ||
|
||
// Task for this test | ||
void Task1(void *p_arg){ | ||
OS_CPU_SysTickInit(SystemCoreClock / (CPU_INT32U) OSCfg_TickRate_Hz); | ||
BSP_UART_Init(NULL, NULL, UART_USB); | ||
Test_Fifo_new(&testFifo); | ||
test(); | ||
} | ||
|
||
int main(void){ | ||
OS_ERR err; | ||
BSP_PLL_Init(); | ||
BSP_Lights_Init(); | ||
|
||
OSInit(&err); | ||
assertOSError(err); | ||
|
||
RTOS_BPS_TaskCreate(&Task1_TCB, | ||
"Task 1", | ||
Task1, | ||
(void *)0, | ||
1, | ||
Task1_Stk, | ||
256); | ||
assertOSError(err); | ||
|
||
OSStart(&err); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe represent 127 as a variable for readability?