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:
parent
c84a40abc4
commit
774e765d59
@ -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)
|
||||
*
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user