mock.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2019 Kaspar Schleiser <kaspar@schleiser.de>
3  * SPDX-FileCopyrightText: 2018 Eistec AB
4  * SPDX-License-Identifier: LGPL-2.1-only
5  */
6 
7 #pragma once
8 
26 #include <stdint.h>
27 #include "ztimer.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
36 typedef struct {
38  uint32_t mask;
39  uint32_t now;
40  uint32_t target;
41  unsigned armed;
42  unsigned running;
44  struct {
45  unsigned now;
46  unsigned set;
47  unsigned cancel;
48  unsigned start;
49  unsigned stop;
50  } calls;
53 
62 void ztimer_mock_advance(ztimer_mock_t *self, uint32_t val);
63 
72 void ztimer_mock_jump(ztimer_mock_t *self, uint32_t target);
73 
82 
89 void ztimer_mock_init(ztimer_mock_t *self, unsigned width);
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 
void ztimer_mock_fire(ztimer_mock_t *self)
Trigger the timer handlers.
void ztimer_mock_advance(ztimer_mock_t *self, uint32_t val)
Advance the mock clock counter and update target.
void ztimer_mock_jump(ztimer_mock_t *self, uint32_t target)
Set the mock clock counter value without updating timer target.
void ztimer_mock_init(ztimer_mock_t *self, unsigned width)
Constructor.
ztimer device structure
Definition: ztimer.h:367
ztimer mock clock class
Definition: mock.h:36
uint32_t target
ticks left until alarm is hit
Definition: mock.h:40
unsigned set
Number of calls to ztimer_ops_t::set.
Definition: mock.h:46
uint32_t now
current counter value
Definition: mock.h:39
unsigned cancel
Number of calls to ztimer_ops_t::cancel.
Definition: mock.h:47
unsigned stop
Number of calls to ztimer_ops_t::stop.
Definition: mock.h:49
unsigned now
Number of calls to ztimer_ops_t::now.
Definition: mock.h:45
ztimer_clock_t super
superclass instance
Definition: mock.h:37
unsigned running
flag for checking if the timer is running
Definition: mock.h:42
unsigned start
Number of calls to ztimer_ops_t::start.
Definition: mock.h:48
uint32_t mask
counter mask
Definition: mock.h:38
unsigned armed
flag for checking if a target has been set
Definition: mock.h:41
ztimer API