23 static char test_output[20];
24 static uint8_t executions;
26 static void test_handler (
void * context)
28 test_output[strlen (test_output)] = ( (
char *) context) [0];
43 printfp (
"\"init\":");
73 printfp (
"\"fail\",\r\n");
77 printfp (
"\"pass\",\r\n");
98 printfp (
"\"create\":");
111 for (
size_t ii = 0; ii < RI_TIMER_MAX_INSTANCES; ii++)
131 for (
size_t ii = 0; ii < RI_TIMER_MAX_INSTANCES; ii++)
144 printfp (
"\"fail\",\r\n");
148 printfp (
"\"pass\",\r\n");
168 char data[] =
"0123456789ABCDEF";
169 printfp (
"\"single_shot\":");
170 char expected_output[RI_TIMER_MAX_INSTANCES + 1] = {0};
171 memcpy (expected_output, data, RI_TIMER_MAX_INSTANCES);
175 for (
size_t ii = 0; ii < RI_TIMER_MAX_INSTANCES; ii++)
178 err_code |=
ri_timer_start (tids[ii], (10U * ii) + 10U, &data[ii]);
188 if (strcmp (expected_output, test_output))
195 printfp (
"\"fail\",\r\n");
199 printfp (
"\"pass\",\r\n");
220 printfp (
"\"repeat\":");
221 char expected_output[] =
"ABCABACBACBA";
222 memset (test_output, 0,
sizeof (test_output));
226 for (
size_t ii = 0; ii < 3; ii++)
246 if (strcmp (expected_output, test_output))
253 printfp (
"\"fail\"\r\n");
257 printfp (
"\"pass\"\r\n");
266 printfp (
"\"timer\":{\r\n");
268 status |= ri_timer_init_test (printfp);
269 status |= ri_timer_create_test (printfp);
270 status |= ri_timer_single_shot_test (printfp);
271 status |= ri_timer_repeat_test (printfp);
uint32_t rd_status_t
bitfield for representing errors
#define RD_ERROR_RESOURCES
Not enough resources for operation.
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
void(* rd_test_print_fp)(const char *const msg)
function pointer to print test information
rd_status_t ri_timer_uninit(void)
rd_status_t ri_timer_start(ri_timer_id_t timer_id, uint32_t ms, void *const context)
Start given timer at a mode defined in ri_timer_create.
rd_status_t ri_timer_create(ri_timer_id_t *p_timer_id, ri_timer_mode_t mode, ruuvi_timer_timeout_handler_t timeout_handler)
rd_status_t ri_timer_init(void)
bool ri_timer_integration_test_run(const rd_test_print_fp printfp)
Run all timer integration tests.
rd_status_t ri_timer_stop(ri_timer_id_t timer_id)
void * ri_timer_id_t
Pointer to timer data.
@ RI_TIMER_MODE_SINGLE_SHOT
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
Interface functions to timer.
rd_status_t ri_delay_ms(uint32_t time)
Delay a given number of milliseconds.