Revision 298
implemented chat. changed place of some macros
uart.c | ||
---|---|---|
284 | 284 |
|
285 | 285 |
queue_t *out = NULL; |
286 | 286 |
queue_t *in = NULL; |
287 |
void (*process)(const uint8_t*, const size_t); |
|
287 |
void (*process)(const uint8_t*, const size_t) = NULL;
|
|
288 | 288 |
|
289 |
int nctp_init(){ |
|
289 |
int nctp_init(void){
|
|
290 | 290 |
out = queue_ctor(); if(out == NULL) return NULL_PTR; |
291 | 291 |
in = queue_ctor(); if(in == NULL) return NULL_PTR; |
292 | 292 |
return SUCCESS; |
293 | 293 |
} |
294 |
int nctp_dump(void){ |
|
295 |
int ret; |
|
296 |
if((ret = nctp_free())) return ret; |
|
297 |
return nctp_init(); |
|
298 |
} |
|
294 | 299 |
int nctp_set_processor(void (*proc_func)(const uint8_t*, const size_t)){ |
295 | 300 |
process = proc_func; |
296 | 301 |
return SUCCESS; |
... | ... | |
350 | 355 |
if(i >= sz) p = realloc(p, sz=2*sz); |
351 | 356 |
} |
352 | 357 |
free(queue_top(in)); queue_pop(in); |
353 |
process(p, i); |
|
358 |
if(process != NULL) process(p, i);
|
|
354 | 359 |
free(p); |
355 | 360 |
} |
356 | 361 |
static int nctp_receive(void){ |
Also available in: Unified diff