board_info.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Hamburg University of Applied Sciences
3  * 2020 Inria
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
10 #pragma once
11 
26 #include <stdint.h>
27 #include <string.h>
28 
29 #include "board.h"
30 #include "periph_conf.h"
31 #include "timex.h"
32 
33 #if defined __has_include
34 # if __has_include ("openwsn_defs.h")
35 # include "openwsn_defs.h"
36 # endif
37 #endif
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
47 #define INTERRUPT_DECLARATION() unsigned irq_state;
48 #define DISABLE_INTERRUPTS() irq_state = irq_disable();
49 #define ENABLE_INTERRUPTS() irq_restore(irq_state);
50 #define SCHEDULER_WAKEUP() /* unused by RIOT */
51 #define SCHEDULER_ENABLE_INTERRUPT() /* unused by RIOT */
58 /* Always 32bit when using ztimer */
59 #if RTT_MAX_VALUE == UINT32_MAX || !((RTT_MAX_VALUE + 1) & (RTT_MAX_VALUE)) || \
60  IS_USED(MODULE_OPENWSN_SCTIMER_ZTIMER)
61 #define PORT_TIMER_WIDTH uint32_t
62 #define PORT_RADIOTIMER_WIDTH uint32_t
63 #else
64 #error "RTT_MAX_VALUE not supported"
65 #endif
66 
67 #if __SIZEOF_POINTER__ == 2
68 #define PORT_SIGNED_INT_WIDTH int16_t
69 #else
70 #define PORT_SIGNED_INT_WIDTH int32_t
71 #endif
72 
73 #define SCTIMER_FREQUENCY (32768U)
74 
75 /* 32 ticks @32768Hz */
76 #define PORT_TICS_PER_MS (SCTIMER_FREQUENCY / MS_PER_SEC)
77 /* 30 us per tick @32768Hz */
78 #define PORT_US_PER_TICK (US_PER_SEC / SCTIMER_FREQUENCY)
95 /* standard slot duration is 10ms but code execution time for most OpenWSN
96  supported BOARDS takes longer than 10ms, so use the default 20ms upstream
97  slot */
98 #ifndef SLOTDURATION
99 #define SLOTDURATION 20 /* in milliseconds */
100 #endif
101 
102 #if SLOTDURATION == 20
103 #ifndef PORT_TsSlotDuration /* 655 ticks at @32768Hz */
104 #define PORT_TsSlotDuration ((SCTIMER_FREQUENCY * SLOTDURATION) / MS_PER_SEC)
105 #endif
106 
107 /* Execution speed related parameters */
108 #ifndef PORT_maxTxDataPrepare
109 #define PORT_maxTxDataPrepare (3355 / PORT_US_PER_TICK ) /* ~110 ticks at @32768Hz */
110 #endif
111 #ifndef PORT_maxRxAckPrepare
112 #define PORT_maxRxAckPrepare (610 / PORT_US_PER_TICK ) /* ~20 ticks at @32768Hz */
113 #endif
114 #ifndef PORT_maxRxDataPrepare
115 #define PORT_maxRxDataPrepare (1000 / PORT_US_PER_TICK ) /* ~33 ticks at@32768Hz */
116 #endif
117 #ifndef PORT_maxTxAckPrepare
118 #define PORT_maxTxAckPrepare (1525 / PORT_US_PER_TICK ) /* ~50 ticks at@32768Hz */
119 #endif
120 
121 /* Radio speed related parameters */
122 #ifndef PORT_delayTx
123 #define PORT_delayTx (300 / PORT_US_PER_TICK ) /* ~10 ticks at@32768Hz */
124 #endif
125 #ifndef PORT_delayRx
126 #define PORT_delayRx (0 / PORT_US_PER_TICK ) /* ~0 ticks at@32768Hz */
127 #endif
128 #else
129 #error "Only 20ms slot duration is currently supported"
130 #endif /* SLOTDURATION == 20 */
132 
140 #define SYNC_ACCURACY (1) /* ticks */
143 #ifdef __cplusplus
144 }
145 #endif
Utility library for comparing and computing timestamps.