mock.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Kaspar Schleiser <kaspar@schleiser.de>
3  * 2018 Eistec AB
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser General
6  * Public License v2.1. See the file LICENSE in the top level directory for more
7  * details.
8  */
9 
27 #ifndef ZTIMER_MOCK_H
28 #define ZTIMER_MOCK_H
29 
30 #include <stdint.h>
31 #include "ztimer.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
40 typedef struct {
42  uint32_t mask;
43  uint32_t now;
44  uint32_t target;
45  unsigned armed;
47  struct {
48  unsigned now;
49  unsigned set;
50  unsigned cancel;
51  } calls;
54 
63 void ztimer_mock_advance(ztimer_mock_t *self, uint32_t val);
64 
73 void ztimer_mock_jump(ztimer_mock_t *self, uint32_t target);
74 
83 
90 void ztimer_mock_init(ztimer_mock_t *self, unsigned width);
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif /* ZTIMER_MOCK_H */
97 
ztimer_mock_t::now
uint32_t now
current counter value
Definition: mock.h:43
ztimer_mock_t::cancel
unsigned cancel
Number of calls to ztimer_ops_t::cancel.
Definition: mock.h:50
ztimer_mock_t::now
unsigned now
Number of calls to ztimer_ops_t::now.
Definition: mock.h:48
ztimer_mock_t::super
ztimer_clock_t super
superclass instance
Definition: mock.h:41
ztimer_mock_advance
void ztimer_mock_advance(ztimer_mock_t *self, uint32_t val)
Advance the mock clock counter and update target.
ztimer.h
ztimer API
ztimer_mock_t::armed
unsigned armed
flag for checking if a target has been set
Definition: mock.h:45
ztimer_mock_jump
void ztimer_mock_jump(ztimer_mock_t *self, uint32_t target)
Set the mock clock counter value without updating timer target.
ztimer_mock_t::mask
uint32_t mask
counter mask
Definition: mock.h:42
ztimer_clock
ztimer device structure
Definition: ztimer.h:312
ztimer_mock_t
ztimer mock clock class
Definition: mock.h:40
ztimer_mock_t::set
unsigned set
Number of calls to ztimer_ops_t::set.
Definition: mock.h:49
ztimer_mock_init
void ztimer_mock_init(ztimer_mock_t *self, unsigned width)
Constructor.
ztimer_mock_fire
void ztimer_mock_fire(ztimer_mock_t *self)
Trigger the timer handlers.
ztimer_mock_t::target
uint32_t target
ticks left until alarm is hit
Definition: mock.h:44