btstack_uart_block: allow to 'unset' a callback by setting it to NULL. Update code for freertos and embedded to implement this

This commit is contained in:
Matthias Ringwald 2017-07-24 11:53:29 +02:00
parent 2c204492a0
commit 3ce3a4ebf3
3 changed files with 17 additions and 7 deletions

View File

@ -92,15 +92,21 @@ static void btstack_uart_embedded_process(btstack_data_source_t *ds, btstack_dat
case DATA_SOURCE_CALLBACK_POLL:
if (send_complete){
send_complete = 0;
block_sent();
if (block_sent){
block_sent();
}
}
if (receive_complete){
receive_complete = 0;
block_received();
if (block_received){
block_received();
}
}
if (wakeup_event){
wakeup_event = 0;
wakeup_handler();
if (wakeup_handler){
wakeup_handler();
}
}
break;
default:

View File

@ -86,11 +86,15 @@ static void btstack_uart_block_freertos_process(btstack_data_source_t *ds, btsta
case DATA_SOURCE_CALLBACK_POLL:
if (send_complete){
send_complete = 0;
block_sent();
if (block_sent){
block_sent();
}
}
if (receive_complete){
receive_complete = 0;
block_received();
if (block_received){
block_received();
}
}
break;
default:

View File

@ -86,12 +86,12 @@ typedef struct {
int (*close)(void);
/**
* set callback for block received
* set callback for block received. NULL disables callback
*/
void (*set_block_received)(void (*block_handler)(void));
/**
* set callback for sent
* set callback for sent. NULL disables callback
*/
void (*set_block_sent)(void (*block_handler)(void));