projects
/
libsi24
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1fd3c80
)
libsi24: return bytes sent in si24_send
author
Robin Krens
<robin@robinkrens.nl>
Sun, 22 Jan 2023 16:41:27 +0000
(17:41 +0100)
committer
Robin Krens
<robin@robinkrens.nl>
Sun, 22 Jan 2023 16:41:27 +0000
(17:41 +0100)
libsi24.c
patch
|
blob
|
history
diff --git
a/libsi24.c
b/libsi24.c
index
32f78a2
..
08fcdd6
100644
(file)
--- a/
libsi24.c
+++ b/
libsi24.c
@@
-169,6
+169,7
@@
si24_t* si24_init(const si24_opts_t *opts, si24_event_handler_t eh)
size_t si24_send(si24_t* si, const unsigned char * buf, size_t size)
{
si24_event_t ev;
size_t si24_send(si24_t* si, const unsigned char * buf, size_t size)
{
si24_event_t ev;
+ size_t bytes_sent = 0;
uint16_t timeout = 0;
int sz;
uint8_t flags;
uint16_t timeout = 0;
int sz;
uint8_t flags;
@@
-215,7
+216,7
@@
size_t si24_send(si24_t* si, const unsigned char * buf, size_t size)
si24_reset(si);
return -1;
}
si24_reset(si);
return -1;
}
-
+ bytes_sent += sz;
timeout = 0;
}
timeout = 0;
}
@@
-223,7
+224,7
@@
size_t si24_send(si24_t* si, const unsigned char * buf, size_t size)
si->eh(si, &ev);
si->ctl->chip_enable(0);
si->eh(si, &ev);
si->ctl->chip_enable(0);
- return
0
;
+ return
bytes_sent
;
}
size_t si24_recv(si24_t* si, unsigned char * buf, size_t size)
}
size_t si24_recv(si24_t* si, unsigned char * buf, size_t size)
@@
-306,10
+307,13
@@
int spi_w_r(unsigned char *data, size_t sz)
void ce(unsigned val)
{
void ce(unsigned val)
{
+ (void) val;
}
void eh(si24_t *si, si24_event_t * e)
{
}
void eh(si24_t *si, si24_event_t * e)
{
+ (void) si;
+
switch(e->type) {
case EV_TX_COMPLETE:
printf("SENT SUCCESFUL\n");
switch(e->type) {
case EV_TX_COMPLETE:
printf("SENT SUCCESFUL\n");
@@
-331,7
+335,7
@@
void eh(si24_t *si, si24_event_t * e)
int main(void)
{
int main(void)
{
- const unsigned char buf[] = "THIS IS A WIRELESS TEST MESSAGE!";
+ /* const unsigned char buf[] = "THIS IS A WIRELESS TEST MESSAGE!";*/
unsigned char recv_buf[29];
si24_ioctl_t ctl = {
unsigned char recv_buf[29];
si24_ioctl_t ctl = {