diff --git a/test/include/double/tiny_uart_double.h b/test/include/double/tiny_uart_double.h index cc93c2b..3cb94ff 100644 --- a/test/include/double/tiny_uart_double.h +++ b/test/include/double/tiny_uart_double.h @@ -15,6 +15,7 @@ typedef struct { i_tiny_uart_t interface; tiny_event_t receive; tiny_event_t send_complete; + bool automatic_send_complete; bool sending; } tiny_uart_double_t; @@ -38,4 +39,9 @@ void tiny_uart_double_trigger_send_complete(tiny_uart_double_t* self); */ void tiny_uart_double_trigger_receive(tiny_uart_double_t* self, uint8_t byte); +/*! + * When enabled, the double will raise a send complete event when a byte is sent. Defaults to disabled. + */ +void tiny_uart_double_configure_automatic_send_complete(tiny_uart_double_t* self, bool enabled); + #endif diff --git a/test/src/tiny_uart_double.cpp b/test/src/tiny_uart_double.cpp index 9b9d6ea..58a0cdd 100644 --- a/test/src/tiny_uart_double.cpp +++ b/test/src/tiny_uart_double.cpp @@ -12,6 +12,10 @@ static void send(i_tiny_uart_t* _self, uint8_t byte) auto self = reinterpret_cast(_self); self->sending = true; mock().actualCall("send").onObject(self).withParameter("byte", byte); + + if(self->automatic_send_complete) { + tiny_uart_double_trigger_send_complete(self); + } } static i_tiny_event_t* on_send_complete(i_tiny_uart_t* _self) @@ -32,6 +36,7 @@ void tiny_uart_double_init(tiny_uart_double_t* self) { self->interface.api = &api; self->sending = false; + self->automatic_send_complete = false; tiny_event_init(&self->send_complete); tiny_event_init(&self->receive); } @@ -52,3 +57,8 @@ void tiny_uart_double_trigger_receive(tiny_uart_double_t* self, uint8_t byte) tiny_uart_on_receive_args_t args = { byte }; tiny_event_publish(&self->receive, &args); } + +void tiny_uart_double_configure_automatic_send_complete(tiny_uart_double_t* self, bool enabled) +{ + self->automatic_send_complete = enabled; +}