Loading...
Searching...
No Matches
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
25
26#include <stdint.h>
27#include "ztimer.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
36typedef struct {
38 uint32_t mask;
39 uint32_t now;
40 uint32_t target;
41 unsigned armed;
42 unsigned running;
43
44 struct {
45 unsigned now;
46 unsigned set;
47 unsigned cancel;
48 unsigned start;
49 unsigned stop;
50 } calls;
53
62void ztimer_mock_advance(ztimer_mock_t *self, uint32_t val);
63
72void ztimer_mock_jump(ztimer_mock_t *self, uint32_t target);
73
82
89void 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.
struct ztimer_clock ztimer_clock_t
ztimer_clock_t forward declaration
Definition ztimer.h:287
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
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