Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/include/double/tiny_uart_double.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ typedef struct {
tiny_event_t send_complete;
bool automatic_send_complete;
bool sending;
bool echoing;
} tiny_uart_double_t;

/*!
Expand Down Expand Up @@ -44,4 +45,9 @@ void tiny_uart_double_trigger_receive(tiny_uart_double_t* self, uint8_t byte);
*/
void tiny_uart_double_configure_automatic_send_complete(tiny_uart_double_t* self, bool enabled);

/*!
* When enabled, the double will raise a receive event when a byte is sent. Defaults to disabled.
*/
void tiny_uart_double_enable_echo(tiny_uart_double_t* self);

#endif
11 changes: 11 additions & 0 deletions test/src/tiny_uart_double.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ static void send(i_tiny_uart_t* _self, uint8_t byte)
if(self->automatic_send_complete) {
tiny_uart_double_trigger_send_complete(self);
}

if(self->echoing) {
tiny_uart_double_trigger_receive(self, byte);
}
}

static i_tiny_event_t* on_send_complete(i_tiny_uart_t* _self)
Expand All @@ -37,6 +41,8 @@ void tiny_uart_double_init(tiny_uart_double_t* self)
self->interface.api = &api;
self->sending = false;
self->automatic_send_complete = false;
self->echoing = false;

tiny_event_init(&self->send_complete);
tiny_event_init(&self->receive);
}
Expand All @@ -62,3 +68,8 @@ void tiny_uart_double_configure_automatic_send_complete(tiny_uart_double_t* self
{
self->automatic_send_complete = enabled;
}

void tiny_uart_double_enable_echo(tiny_uart_double_t* self)
{
self->echoing = true;
}
Loading