Skip to content
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

Added function to read multi-byte data over UART1 #1254

Merged
merged 2 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/drivers/interface/uart1.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ bool uart1GetDataWithTimeout(uint8_t *c, const uint32_t timeoutTicks);
*/
bool uart1GetDataWithDefaultTimeout(uint8_t *c);

/**
* Get data from the UART connection. Blocking until the amount of
* data has been read
*
* @param[in] size Number of bytes to read
* @param[out] data Pointer to data
*
* @return number of bytes read
*/
void uart1GetBytesWithDefaultTimeout(uint32_t size, uint8_t* data);


/**
* Sends raw data using a lock. Should be used from
* exception functions and for debugging when a lot of data
Expand Down
7 changes: 7 additions & 0 deletions src/drivers/src/uart1.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ bool uart1GetDataWithDefaultTimeout(uint8_t *c)
return uart1GetDataWithTimeout(c, UART1_DATA_TIMEOUT_TICKS);
}

void uart1GetBytesWithDefaultTimeout(uint32_t size, uint8_t* data)
{
for (size_t i = 0; i < size; i++) {
xQueueReceive(uart1queue, &data[i], portMAX_DELAY);
}
}

void uart1SendData(uint32_t size, uint8_t* data)
{
uint32_t i;
Expand Down