1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/isrpipe: add isrpipe_write

This commit is contained in:
Hendrik van Essen 2021-11-29 17:18:50 +01:00
parent c84a40abc4
commit 774e765d59
2 changed files with 25 additions and 4 deletions

View File

@ -55,16 +55,28 @@ typedef struct {
void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize);
/**
* @brief Put one character into the isrpipe's buffer
* @brief Put one byte into the isrpipe's buffer
*
* @param[in] isrpipe isrpipe object to initialize
* @param[in] c character to add to isrpipe buffer
* @param[in] isrpipe isrpipe object to operate on
* @param[in] c byte to add to isrpipe buffer
*
* @returns 0 if character could be added
* @returns 0 if byte could be added
* @returns -1 if buffer was full
*/
int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c);
/**
* @brief Put number of bytes into the isrpipe's buffer
*
* @param[in] isrpipe isrpipe object to operate on
* @param[in] buf bytes to add to isrpipe buffer
* @param[in] n number of bytes to add from buf to isrpipe's buffer
*
* @returns number of bytes that could be added
* @returns -1 if buffer was full
*/
int isrpipe_write(isrpipe_t *isrpipe, const uint8_t *buf, size_t n);
/**
* @brief Read data from isrpipe (blocking)
*

View File

@ -37,6 +37,15 @@ int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c)
return res;
}
int isrpipe_write(isrpipe_t *isrpipe, const uint8_t *buf, size_t n)
{
int res = tsrb_add(&isrpipe->tsrb, buf, n);
mutex_unlock(&isrpipe->mutex);
return res;
}
int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buffer, size_t count)
{
int res;