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 1 commit
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
11 changes: 11 additions & 0 deletions src/drivers/interface/uart1.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ bool uart1GetDataWithDefaultTimeout(uint8_t *c);
*/
void uart1SendData(uint32_t size, uint8_t* data);

/**
* Get data from the UART. 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 uart1GetData(uint32_t size, uint8_t* data);

/**
* Sends raw data using DMA transfer.
* @param[in] size Number of bytes to send
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 @@ -256,6 +256,13 @@ void uart1Getchar(char * ch)
xQueueReceive(uart1queue, ch, portMAX_DELAY);
}

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

bool uart1DidOverrun()
{
bool result = hasOverrun;
Expand Down