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

isrpipe: change API to be in line with tsrb

The API of `tsrb` was changed because of confusing type situations.
This API change takes this API change of changing `char` to `uint8_t`
up a level. Since `isrpipe` most often is used together with
`periph_uart` this change even is beneficial, as `periph_uart` also
uses `uint8_t` instead of `char`.
This commit is contained in:
Martine Lenders 2019-06-05 18:03:40 +02:00
parent 9b47dcb542
commit d9049dad87
4 changed files with 14 additions and 14 deletions

View File

@ -52,7 +52,7 @@ typedef struct {
* @param[in] buf buffer to use as ringbuffer (must be power of two sized!)
* @param[in] bufsize size of @p buf
*/
void isrpipe_init(isrpipe_t *isrpipe, char *buf, size_t bufsize);
void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize);
/**
* @brief Put one character into the isrpipe's buffer
@ -63,7 +63,7 @@ void isrpipe_init(isrpipe_t *isrpipe, char *buf, size_t bufsize);
* @returns 0 if character could be added
* @returns -1 if buffer was full
*/
int isrpipe_write_one(isrpipe_t *isrpipe, char c);
int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c);
/**
* @brief Read data from isrpipe (blocking)
@ -74,7 +74,7 @@ int isrpipe_write_one(isrpipe_t *isrpipe, char c);
*
* @returns number of bytes read
*/
int isrpipe_read(isrpipe_t *isrpipe, char *buf, size_t count);
int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buf, size_t count);
#ifdef __cplusplus
}

View File

@ -44,7 +44,7 @@ extern "C" {
* @returns number of bytes read
* @returns -ETIMEDOUT on timeout
*/
int isrpipe_read_timeout(isrpipe_t *isrpipe, char *buf, size_t count, uint32_t timeout);
int isrpipe_read_timeout(isrpipe_t *isrpipe, uint8_t *buf, size_t count, uint32_t timeout);
/**
* @brief Read data from isrpipe (with timeout, blocking, wait until all read)
@ -60,7 +60,7 @@ int isrpipe_read_timeout(isrpipe_t *isrpipe, char *buf, size_t count, uint32_t t
* @returns number of bytes read
* @returns -ETIMEDOUT on timeout
*/
int isrpipe_read_all_timeout(isrpipe_t *isrpipe, char *buf, size_t count, uint32_t timeout);
int isrpipe_read_all_timeout(isrpipe_t *isrpipe, uint8_t *buf, size_t count, uint32_t timeout);
#ifdef __cplusplus
}

View File

@ -19,13 +19,13 @@
#include "isrpipe.h"
void isrpipe_init(isrpipe_t *isrpipe, char *buf, size_t bufsize)
void isrpipe_init(isrpipe_t *isrpipe, uint8_t *buf, size_t bufsize)
{
mutex_init(&isrpipe->mutex);
tsrb_init(&isrpipe->tsrb, (uint8_t *)buf, bufsize);
tsrb_init(&isrpipe->tsrb, buf, bufsize);
}
int isrpipe_write_one(isrpipe_t *isrpipe, char c)
int isrpipe_write_one(isrpipe_t *isrpipe, uint8_t c)
{
int res = tsrb_add_one(&isrpipe->tsrb, c);
@ -37,11 +37,11 @@ int isrpipe_write_one(isrpipe_t *isrpipe, char c)
return res;
}
int isrpipe_read(isrpipe_t *isrpipe, char *buffer, size_t count)
int isrpipe_read(isrpipe_t *isrpipe, uint8_t *buffer, size_t count)
{
int res;
while (!(res = tsrb_get(&isrpipe->tsrb, (uint8_t *)buffer, count))) {
while (!(res = tsrb_get(&isrpipe->tsrb, buffer, count))) {
mutex_lock(&isrpipe->mutex);
}
return res;

View File

@ -35,7 +35,7 @@ static void _cb(void *arg)
mutex_unlock(_timeout->mutex);
}
int isrpipe_read_timeout(isrpipe_t *isrpipe, char *buffer, size_t count, uint32_t timeout)
int isrpipe_read_timeout(isrpipe_t *isrpipe, uint8_t *buffer, size_t count, uint32_t timeout)
{
int res;
@ -44,7 +44,7 @@ int isrpipe_read_timeout(isrpipe_t *isrpipe, char *buffer, size_t count, uint32_
xtimer_t timer = { .callback = _cb, .arg = &_timeout };
xtimer_set(&timer, timeout);
while (!(res = tsrb_get(&isrpipe->tsrb, (uint8_t *)buffer, count))) {
while (!(res = tsrb_get(&isrpipe->tsrb, buffer, count))) {
mutex_lock(&isrpipe->mutex);
if (_timeout.flag) {
res = -ETIMEDOUT;
@ -57,9 +57,9 @@ int isrpipe_read_timeout(isrpipe_t *isrpipe, char *buffer, size_t count, uint32_
}
int isrpipe_read_all_timeout(isrpipe_t *isrpipe, char *buffer, size_t count, uint32_t timeout)
int isrpipe_read_all_timeout(isrpipe_t *isrpipe, uint8_t *buffer, size_t count, uint32_t timeout)
{
char *pos = buffer;
uint8_t *pos = buffer;
while (count) {
int res = isrpipe_read_timeout(isrpipe, pos, count, timeout);