Contiki-NG
nrf-def.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 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 nrf
33  * @{
34  *
35  * \file
36  * Header with defines common to all nrf platforms
37  * \author
38  * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br>
39  */
40 /*---------------------------------------------------------------------------*/
41 #ifndef NRF_DEF_H_
42 #define NRF_DEF_H_
43 /*---------------------------------------------------------------------------*/
44 #include "arm-def.h"
45 /*---------------------------------------------------------------------------*/
46 #include "nrf.h"
47 /*---------------------------------------------------------------------------*/
48 /* Path to headers with implementation of mutexes, atomic and memory barriers */
49 #define MUTEX_CONF_ARCH_HEADER_PATH "mutex-cortex.h"
50 #define ATOMIC_CONF_ARCH_HEADER_PATH "atomic-cortex.h"
51 #define MEMORY_BARRIER_CONF_ARCH_HEADER_PATH "memory-barrier-cortex.h"
52 /*---------------------------------------------------------------------------*/
53 /* Do the math in 32bits to save precision.
54  * Round to nearest integer rather than truncate. */
55 #define US_TO_RTIMERTICKS(US) ((US) >= 0 ? \
56  (((int32_t)(US)*(RTIMER_ARCH_SECOND)+500000) / 1000000L) : \
57  ((int32_t)(US)*(RTIMER_ARCH_SECOND)-500000) / 1000000L)
58 
59 #define RTIMERTICKS_TO_US(T) ((T) >= 0 ? \
60  (((int32_t)(T) * 1000000L + ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND)) : \
61  ((int32_t)(T) * 1000000L - ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND))
62 
63 /* A 64-bit version because the 32-bit one cannot handle T >= 4295 ticks.
64  Intended only for positive values of T. */
65 #define RTIMERTICKS_TO_US_64(T) ((uint32_t)(((uint64_t)(T) * 1000000 + ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND)))
66 /*---------------------------------------------------------------------------*/
67 #define RADIO_PHY_OVERHEAD 3
68 #define RADIO_BYTE_AIR_TIME 32
69 #define RADIO_SHR_LEN 5 /* Synch word + SFD */
70 #define RADIO_DELAY_BEFORE_TX \
71  ((unsigned)US_TO_RTIMERTICKS(RADIO_SHR_LEN * RADIO_BYTE_AIR_TIME))
72 #define RADIO_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(250))
73 #define RADIO_DELAY_BEFORE_DETECT 0
74 /*---------------------------------------------------------------------------*/
75 #define RTIMER_ARCH_SECOND 62500
76 /*---------------------------------------------------------------------------*/
77 #define GPIO_HAL_CONF_ARCH_HDR_PATH "gpio-hal-arch.h"
78 #define GPIO_HAL_CONF_ARCH_SW_TOGGLE 0
79 /*---------------------------------------------------------------------------*/
80 #ifndef TSCH_CONF_HW_FRAME_FILTERING
81 #define TSCH_CONF_HW_FRAME_FILTERING 0
82 #endif /* TSCH_CONF_HW_FRAME_FILTERING */
83 
84 #ifndef TSCH_CONF_RADIO_ON_DURING_TIMESLOT
85 #define TSCH_CONF_RADIO_ON_DURING_TIMESLOT 1
86 #endif /* TSCH_CONF_RADIO_ON_DURING_TIMESLOT */
87 
88 #ifndef TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS
89 #define TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS 1
90 #endif /* TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS */
91 
92 #ifndef TSCH_CONF_TIMESYNC_REMOVE_JITTER
93 #define TSCH_CONF_TIMESYNC_REMOVE_JITTER 0
94 #endif /* TSCH_CONF_TIMESYNC_REMOVE_JITTER */
95 /*---------------------------------------------------------------------------*/
96 #define CSMA_CONF_SEND_SOFT_ACK 1
97 /*---------------------------------------------------------------------------*/
98 #endif /* NRF_DEF_H_ */
99 /*---------------------------------------------------------------------------*/
100 /**
101  * @}
102  */
Compiler and data type definitions for all ARM-based CPUs.