Skip to content

Commit

Permalink
Merge pull request #1254 from bhabas/UART1_Data_Transfer
Browse files Browse the repository at this point in the history
Added function to read multi-byte data over UART1
  • Loading branch information
krichardsson authored Mar 22, 2023
2 parents b6f349c + 81c09cb commit 1346781
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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

0 comments on commit 1346781

Please sign in to comment.