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
10#pragma once
11
28
29#include <stdint.h>
30#include "ztimer.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
39typedef struct {
41 uint32_t mask;
42 uint32_t now;
43 uint32_t target;
44 unsigned armed;
45 unsigned running;
46
47 struct {
48 unsigned now;
49 unsigned set;
50 unsigned cancel;
51 unsigned start;
52 unsigned stop;
53 } calls;
56
65void ztimer_mock_advance(ztimer_mock_t *self, uint32_t val);
66
75void ztimer_mock_jump(ztimer_mock_t *self, uint32_t target);
76
85
92void ztimer_mock_init(ztimer_mock_t *self, unsigned width);
93
94#ifdef __cplusplus
95}
96#endif
97
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:290
ztimer mock clock class
Definition mock.h:39
uint32_t target
ticks left until alarm is hit
Definition mock.h:43
unsigned set
Number of calls to ztimer_ops_t::set.
Definition mock.h:49
uint32_t now
current counter value
Definition mock.h:42
unsigned cancel
Number of calls to ztimer_ops_t::cancel.
Definition mock.h:50
unsigned stop
Number of calls to ztimer_ops_t::stop.
Definition mock.h:52
ztimer_clock_t super
superclass instance
Definition mock.h:40
unsigned running
flag for checking if the timer is running
Definition mock.h:45
unsigned start
Number of calls to ztimer_ops_t::start.
Definition mock.h:51
uint32_t mask
counter mask
Definition mock.h:41
unsigned armed
flag for checking if a target has been set
Definition mock.h:44
ztimer API