Contiki-NG
cc13xx-cc26xx-def.h
1 /*
2  * Copyright (c) 2017, George Oikonomou - http://www.spd.gr
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  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 /*---------------------------------------------------------------------------*/
32 #ifndef CC13XX_CC26XX_DEF_H_
33 #define CC13XX_CC26XX_DEF_H_
34 /*---------------------------------------------------------------------------*/
35 #include "cm3/cm3-def.h"
36 /*---------------------------------------------------------------------------*/
37 /* TSCH related defines */
38 
39 /* Delay between GO signal and SFD */
40 #define RADIO_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(81))
41 /* Delay between GO signal and start listening.
42  * This value is so small because the radio is constantly on within each timeslot. */
43 #define RADIO_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(15))
44 /* Delay between the SFD finishes arriving and it is detected in software. */
45 #define RADIO_DELAY_BEFORE_DETECT ((unsigned)US_TO_RTIMERTICKS(352))
46 
47 /* Timer conversion; radio is running at 4 MHz */
48 #define RADIO_TIMER_SECOND 4000000u
49 #if (RTIMER_SECOND % 256) || (RADIO_TIMER_SECOND % 256)
50 #error RADIO_TO_RTIMER macro must be fixed!
51 #endif
52 #define RADIO_TO_RTIMER(X) ((uint32_t)(((uint64_t)(X) * (RTIMER_SECOND / 256)) / (RADIO_TIMER_SECOND / 256)))
53 #define USEC_TO_RADIO(X) ((X) * 4)
54 
55 /* The PHY header (preamble + SFD, 4+1 bytes) duration is equivalent to 10 symbols */
56 #define RADIO_IEEE_802154_PHY_HEADER_DURATION_USEC 160
57 
58 /* Do not turn off TSCH within a timeslot: not enough time */
59 #define TSCH_CONF_RADIO_ON_DURING_TIMESLOT 1
60 
61 /* Disable TSCH frame filtering */
62 #define TSCH_CONF_HW_FRAME_FILTERING 0
63 
64 /* Use hardware timestamps */
65 #ifndef TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS
66 #define TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS 1
67 #define TSCH_CONF_TIMESYNC_REMOVE_JITTER 0
68 #endif
69 
70 #ifndef TSCH_CONF_BASE_DRIFT_PPM
71 /* The drift compared to "true" 10ms slots.
72  * Enable adaptive sync to enable compensation for this.
73  * Slot length 10000 usec
74  * 328 ticks
75  * Tick duration 30.517578125 usec
76  * Real slot duration 10009.765625 usec
77  * Target - real duration = -9.765625 usec
78  * TSCH_CONF_BASE_DRIFT_PPM -977
79  */
80 #define TSCH_CONF_BASE_DRIFT_PPM -977
81 #endif
82 
83 /* 10 times per second */
84 #ifndef TSCH_CONF_CHANNEL_SCAN_DURATION
85 #define TSCH_CONF_CHANNEL_SCAN_DURATION (CLOCK_SECOND / 10)
86 #endif
87 
88 /* Slightly reduce the TSCH guard time (from 2200 usec to 1800 usec) to make sure
89  * the CC26xx radio has sufficient time to start up. */
90 #ifndef TSCH_CONF_RX_WAIT
91 #define TSCH_CONF_RX_WAIT 1800
92 #endif
93 /*---------------------------------------------------------------------------*/
94 #define RTIMER_ARCH_SECOND 65536
95 /*---------------------------------------------------------------------------*/
96 /* Path to CMSIS header */
97 #define CMSIS_CONF_HEADER_PATH "cc13x0-cc26x0-cm3.h"
98 
99 /* Path to headers with implementation of mutexes and memory barriers */
100 #define MUTEX_CONF_ARCH_HEADER_PATH "mutex-cortex.h"
101 #define MEMORY_BARRIER_CONF_ARCH_HEADER_PATH "memory-barrier-cortex.h"
102 
103 #define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h"
104 /*---------------------------------------------------------------------------*/
105 #define GPIO_HAL_CONF_ARCH_SW_TOGGLE 0
106 /*---------------------------------------------------------------------------*/
107 #define SPI_CONF_CONTROLLER_COUNT 2
108 /*---------------------------------------------------------------------------*/
109 #endif /* CC13XX_CC26XX_DEF_H_ */
110 /*---------------------------------------------------------------------------*/
Compiler and data type definitions for all CM3-based CPUs.