Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
rtimer-arch.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2022 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br>
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the copyright holder nor the names of its
14
* contributors may be used to endorse or promote products derived
15
* from this software without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
* OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
/*---------------------------------------------------------------------------*/
31
/**
32
* \addtogroup gecko
33
* @{
34
*
35
* \addtogroup gecko-sys System drivers
36
* @{
37
*
38
* \addtogroup gecko-rtimer Rtimer driver
39
* @{
40
*
41
* \file
42
* Implementation of the architecture dependent rtimer functions for the Gecko
43
* \author
44
* Yago Fontoura do Rosario <yago.rosario@hotmail.com.br>
45
*
46
*/
47
/*---------------------------------------------------------------------------*/
48
#include "contiki.h"
49
50
#include "sl_sleeptimer.h"
51
52
#include "
rtimer-arch.h
"
53
/*---------------------------------------------------------------------------*/
54
static
sl_sleeptimer_timer_handle_t rtimer_timer;
55
/*---------------------------------------------------------------------------*/
56
static
void
57
on_rtimer_timeout(sl_sleeptimer_timer_handle_t *handle,
58
void
*data)
59
{
60
(void)handle;
61
(void)data;
62
rtimer_run_next
();
63
}
64
/*---------------------------------------------------------------------------*/
65
void
66
rtimer_arch_init
(
void
)
67
{
68
sl_sleeptimer_init();
69
}
70
/*---------------------------------------------------------------------------*/
71
void
72
rtimer_arch_schedule
(rtimer_clock_t t)
73
{
74
uint32_t now = sl_sleeptimer_get_tick_count();
75
uint32_t timeout = t - now;
76
77
/* t is an absolute time */
78
/* sl_sleeptimer_start_timer takes a timeout */
79
/* Check for overflow and compensate */
80
if
(timeout > 0x80000000UL) {
81
timeout -= 0x80000000UL;
82
}
83
84
sl_sleeptimer_start_timer(&rtimer_timer,
85
timeout,
86
on_rtimer_timeout, NULL,
87
0,
88
0);
89
}
90
/*---------------------------------------------------------------------------*/
91
rtimer_clock_t
92
rtimer_arch_now
()
93
{
94
return
sl_sleeptimer_get_tick_count();
95
}
96
/*---------------------------------------------------------------------------*/
97
/**
98
* @}
99
* @}
100
* @}
101
*/
rtimer-arch.h
Architecture dependent rtimer implementation header file.
rtimer_arch_init
void rtimer_arch_init(void)
We don't need to explicitly initialise anything but this routine is required by the API.
Definition
rtimer-arch.c:59
rtimer_arch_now
rtimer_clock_t rtimer_arch_now()
Returns the current real-time clock time.
Definition
rtimer-arch.c:109
rtimer_arch_schedule
void rtimer_arch_schedule(rtimer_clock_t t)
Schedules an rtimer task to be triggered at time t.
Definition
rtimer-arch.c:65
rtimer_run_next
void rtimer_run_next(void)
Execute the next real-time task and schedule the next task, if any.
Definition
rtimer.c:78
arch
cpu
gecko
sys
rtimer-arch.c
Generated on
for Contiki-NG by
1.17.0