28 static uint8_t m_has_sent;
29 static uint8_t m_has_received;
33 void * p_data,
size_t data_len)
52 m_channel.
read (&rx_data);
72 printfp (
"\"init\":");
101 printfp (
"\"fail\",\r\n");
105 printfp (
"\"pass\",\r\n");
117 m_has_received =
false;
118 memset (&rx_data, 0,
sizeof (rx_data));
122 .parity_enabled =
false,
130 m_channel.
on_evt = uart_isr;
136 static bool uart_run_test (
const char *
const test_data)
139 bool timeout =
false;
141 m_has_received =
false;
142 memset (&rx_data, 0,
sizeof (rx_data));
151 err_code |= m_channel.
send (&msg);
153 while (! (m_has_sent && m_has_received)
165 || (m_has_received != 1))
182 printfp (
"\"tx_rx\":");
183 err_code |= uart_init_test (input, output);
185 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor"
186 " incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis "
187 "nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "
188 "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu "
189 "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, "
190 "sunt in culpa qui officia deserunt mollit anim id est laborum";
195 status |= uart_run_test (test_data);
204 printfp (
"\"fail\",\r\n");
208 printfp (
"\"pass\",\r\n");
222 bool timeout =
false;
226 printfp (
"\"rx_corrupt\":");
227 err_code |= uart_init_test (input, output);
228 const char test_data[] =
229 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor "
230 "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis "
231 "nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "
232 "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu "
233 "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in "
234 "culpa qui officia deserunt mollit anim id est laborum\n";
242 m_channel.
on_evt = uart_isr;
244 err_code |= m_channel.
send (&msg);
246 while (! (m_has_sent && m_has_received)
258 const char * cutoff_index = test_data + strlen (test_data) - written;
259 memset (&rx_data, 0,
sizeof (rx_data));
260 err_code |= m_channel.
send (&msg);
262 while ( ( (m_has_sent < 2) && (m_has_received < 2))
274 || (m_has_received != 2)
275 || (m_has_sent != 2))
289 printfp (
"\"fail\",\r\n");
293 printfp (
"\"pass\",\r\n");
305 printfp (
"\"rx_short\":");
306 err_code |= uart_init_test (input, output);
307 const char test_data[] =
"Lorem ipsum dolor sit amet\n";
311 status |= uart_run_test (test_data);
320 printfp (
"\"fail\"\r\n");
324 printfp (
"\"pass\"\r\n");
335 printfp (
"\"uart\":{\r\n");
336 status |= ri_uart_init_test (printfp);
337 status |= ri_uart_tx_test (printfp, input, output);
338 status |= ri_uart_rx_test (printfp, input, output);
339 status |= ri_uart_rx_short_test (printfp, input, output);
uint32_t rd_status_t
bitfield for representing errors
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
bool ri_communication_uart_run_integration_test(const rd_test_print_fp printfp, const ri_gpio_id_t input, const ri_gpio_id_t output)
void(* rd_test_print_fp)(const char *const msg)
function pointer to print test information
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
Functions for testing drivers.
#define RI_COMM_MESSAGE_MAX_LENGTH
The maximum length for the application message for sending over BLE, which depends on whether extende...
ri_comm_evt_t
Communication event type.
@ RI_COMM_CONNECTED
Connection established, OK to send, may receive data.
@ RI_COMM_RECEIVED
New data received, available to read with read function.
@ RI_COMM_SENT
One queued message was sent with all repetitions.
@ RI_COMM_DISCONNECTED
Connection lost, cannot send, may not receive data.
@ RI_UART_BAUD_115200
Run at 115200 baud.
rd_status_t ri_uart_uninit(ri_comm_channel_t *const channel)
rd_status_t ri_uart_config(const ri_uart_init_t *const config)
Configure UART.
rd_status_t ri_uart_init(ri_comm_channel_t *const channel)
Initialize UART.
#define TEST_TIMEOUT_MS
If TX/RX test not ready in this time, fail.
uint16_t ri_gpio_id_t
port<<8 + pin
#define RI_GPIO_ID_UNUSED
Enable implementation selected by application.
rd_status_t ri_rtc_init(void)
Initializes RTC at 0 ms.
rd_status_t ri_rtc_uninit(void)
Stop RTC if applicable.
uint64_t ri_rtc_millis(void)
Get milliseconds since init.
control API for communication via outside world
ri_comm_evt_handler_fp_t on_evt
Callback to application-level event handler, must be set in application.
ri_comm_xfer_fp_t send
Asynchronous send function.
ri_comm_xfer_fp_t read
Asynchronous read function.
Application message structure used for communication.
uint8_t data[RI_COMM_MESSAGE_MAX_LENGTH]
Data payload.
uint8_t repeat_count
Number of times to repeat the message,.
uint8_t data_length
Length of data.
UART initialization data.
bool hwfc_enabled
True to enable hardware flow control.