Loading...
Searching...
No Matches
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
34extern "C" {
35#endif
36
40typedef struct {
42 uint32_t mask;
43 uint32_t now;
44 uint32_t target;
45 unsigned armed;
46 unsigned running;
48 struct {
49 unsigned now;
50 unsigned set;
51 unsigned cancel;
52 unsigned start;
53 unsigned stop;
54 } calls;
57
66void ztimer_mock_advance(ztimer_mock_t *self, uint32_t val);
67
76void ztimer_mock_jump(ztimer_mock_t *self, uint32_t target);
77
86
93void ztimer_mock_init(ztimer_mock_t *self, unsigned width);
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif /* ZTIMER_MOCK_H */
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:369
ztimer mock clock class
Definition mock.h:40
uint32_t target
ticks left until alarm is hit
Definition mock.h:44
unsigned set
Number of calls to ztimer_ops_t::set.
Definition mock.h:50
uint32_t now
current counter value
Definition mock.h:43
unsigned cancel
Number of calls to ztimer_ops_t::cancel.
Definition mock.h:51
unsigned stop
Number of calls to ztimer_ops_t::stop.
Definition mock.h:53
unsigned now
Number of calls to ztimer_ops_t::now.
Definition mock.h:49
ztimer_clock_t super
superclass instance
Definition mock.h:41
unsigned running
flag for checking if the timer is running
Definition mock.h:46
unsigned start
Number of calls to ztimer_ops_t::start.
Definition mock.h:52
uint32_t mask
counter mask
Definition mock.h:42
unsigned armed
flag for checking if a target has been set
Definition mock.h:45
ztimer API