Contiki-NG
cc13xx-cc26xx-def.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
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  * \addtogroup cc13xx-cc26xx-cpu
32  * @{
33  *
34  * \file
35  * Header with configuration defines for the Contiki system.
36  * \author
37  * Edvard Pettersen <e.pettersen@ti.com>
38  */
39 /*---------------------------------------------------------------------------*/
40 #ifndef CC13XX_CC26XX_DEF_H_
41 #define CC13XX_CC26XX_DEF_H_
42 /*---------------------------------------------------------------------------*/
43 #include <ti/devices/DeviceFamily.h>
44 /*---------------------------------------------------------------------------*/
45 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
46 #include <cm3/cm3-def.h>
47 #elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
48 #include <cm4/cm4-def.h>
49 #endif
50 /*---------------------------------------------------------------------------*/
51 #include <stddef.h>
52 #include <stdint.h>
53 /*---------------------------------------------------------------------------*/
54 #define RTIMER_ARCH_SECOND 65536
55 /*---------------------------------------------------------------------------*/
56 #define INT_MASTER_CONF_STATUS_DATATYPE uintptr_t
57 /*---------------------------------------------------------------------------*/
58 /* TSCH related defines */
59 
60 /* 2 bytes header, 4 bytes CRC */
61 #define CC13XX_RADIO_PHY_OVERHEAD 6
62 /* 3 bytes preamble, 3 bytes sync */
63 #define CC13XX_RADIO_PHY_HEADER_LEN 6
64 /* The default data rate is 50 kbps */
65 #define CC13XX_RADIO_BIT_RATE 50000
66 
67 /* 1 len byte, 2 bytes CRC */
68 #define CC26XX_RADIO_PHY_OVERHEAD 3
69 /* 4 bytes preamble, 1 byte sync */
70 #define CC26XX_RADIO_PHY_HEADER_LEN 5
71 /* The fixed data rate is 250 kbps */
72 #define CC26XX_RADIO_BIT_RATE 250000
73 
74 #if defined(DEVICE_LINE_CC13XX)
75 #define RADIO_PHY_HEADER_LEN CC13XX_RADIO_PHY_HEADER_LEN
76 #define RADIO_PHY_OVERHEAD CC13XX_RADIO_PHY_OVERHEAD
77 #define RADIO_BIT_RATE CC13XX_RADIO_BIT_RATE
78 
79 /* The TSCH default slot length of 10ms is too short, use custom one instead */
80 #ifndef TSCH_CONF_DEFAULT_TIMESLOT_TIMING
81 #define TSCH_CONF_DEFAULT_TIMESLOT_TIMING tsch_timing_cc13xx_50kbps
82 #endif /* TSCH_CONF_DEFAULT_TIMESLOT_TIMING */
83 
84 /* Symbol for the custom TSCH timeslot timing template */
85 #define TSCH_CONF_ARCH_HDR_PATH "rf/cc13xx-50kbps-tsch.h"
86 
87 #else
88 #define RADIO_PHY_HEADER_LEN CC26XX_RADIO_PHY_HEADER_LEN
89 #define RADIO_PHY_OVERHEAD CC26XX_RADIO_PHY_OVERHEAD
90 #define RADIO_BIT_RATE CC26XX_RADIO_BIT_RATE
91 #endif
92 
93 #define RADIO_BYTE_AIR_TIME (1000000 / (RADIO_BIT_RATE / 8))
94 
95 /* Delay between GO signal and SFD */
96 #define RADIO_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(RADIO_PHY_HEADER_LEN * RADIO_BYTE_AIR_TIME))
97 /* Delay between GO signal and start listening.
98  * This value is so small because the radio is constantly on within each timeslot. */
99 #define RADIO_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(15))
100 /* Delay between the SFD finishes arriving and it is detected in software. */
101 #define RADIO_DELAY_BEFORE_DETECT ((unsigned)US_TO_RTIMERTICKS(352))
102 
103 /* Timer conversion; radio is running at 4 MHz */
104 #define RAT_SECOND 4000000u
105 #define RAT_TO_RTIMER(x) ((uint32_t)(((uint64_t)(x) * (RTIMER_SECOND / 256)) / (RAT_SECOND / 256)))
106 #define USEC_TO_RAT(x) ((x) * 4)
107 
108 #if (RTIMER_SECOND % 256) || (RAT_SECOND % 256)
109 #error RAT_TO_RTIMER macro must be fixed!
110 #endif
111 
112 /* Do not turn off TSCH within a timeslot: not enough time */
113 #define TSCH_CONF_RADIO_ON_DURING_TIMESLOT 1
114 
115 /* Disable TSCH frame filtering */
116 #define TSCH_CONF_HW_FRAME_FILTERING 0
117 
118 /* Use hardware timestamps */
119 #ifndef TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS
120 #define TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS 1
121 #define TSCH_CONF_TIMESYNC_REMOVE_JITTER 0
122 #endif
123 
124 #ifndef TSCH_CONF_BASE_DRIFT_PPM
125 #if defined(DEVICE_LINE_CC13XX)
126 /* The drift compared to "true" 40ms slots.
127  * Enable adaptive sync to enable compensation for this.
128  * Slot length 40000 usec
129  * 1311 ticks
130  * Tick duration 30.517578125 usec
131  * Real slot duration 40008.544922 usec
132  * Target - real duration = -8.544922 usec
133  * PPM -8.544922 / 40000 = -0.000214
134  */
135 #define TSCH_CONF_BASE_DRIFT_PPM -214
136 #else /* defined(DEVICE_LINE_CC13XX) */
137 /*
138  * The drift compared to "true" 10ms slots.
139  * Enable adaptive sync to enable compensation for this.
140  * Slot length 10000 usec
141  * 328 ticks
142  * Tick duration 30.517578125 usec
143  * Real slot duration 10009.765625 usec
144  * Target - real duration = -9.765625 usec
145  * TSCH_CONF_BASE_DRIFT_PPM -977
146  */
147 #define TSCH_CONF_BASE_DRIFT_PPM -977
148 #endif /* defined(DEVICE_LINE_CC13XX) */
149 #endif /* TSCH_CONF_BASE_DRIFT_PPM */
150 
151 /* 10 times per second */
152 #ifndef TSCH_CONF_CHANNEL_SCAN_DURATION
153 #define TSCH_CONF_CHANNEL_SCAN_DURATION (CLOCK_SECOND / 10)
154 #endif
155 
156 /* Tweak to improve TSCH association speed on this platform */
157 #ifndef TSCH_CONF_ASSOCIATION_POLL_FREQUENCY
158 #define TSCH_CONF_ASSOCIATION_POLL_FREQUENCY 10
159 #endif
160 
161 /* Increase TSCH guard time from 2200 usec to 3000 usec.
162  * This is required for simplelink radio to have stable operation, especially in sub-GHz range . */
163 #ifndef TSCH_CONF_RX_WAIT
164 #define TSCH_CONF_RX_WAIT 3000
165 #endif
166 /*---------------------------------------------------------------------------*/
167 /* Path to CMSIS header */
168 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
169 #define CMSIS_CONF_HEADER_PATH "cc13x0-cc26x0-cm3.h"
170 #elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
171 #define CMSIS_CONF_HEADER_PATH "cc13x2-cc26x2-cm4.h"
172 #endif
173 /*---------------------------------------------------------------------------*/
174 /* Path to headers with implementation of mutexes, atomic and memory barriers */
175 #define MUTEX_CONF_ARCH_HEADER_PATH "mutex-cortex.h"
176 #define ATOMIC_CONF_ARCH_HEADER_PATH "atomic-cortex.h"
177 #define MEMORY_BARRIER_CONF_ARCH_HEADER_PATH "memory-barrier-cortex.h"
178 /*---------------------------------------------------------------------------*/
179 /* GPIO HAL configuration */
180 #define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h"
181 #define GPIO_HAL_CONF_ARCH_SW_TOGGLE 0
182 #define GPIO_HAL_CONF_PORT_PIN_NUMBERING 0
183 /*---------------------------------------------------------------------------*/
184 #endif /* CC13XX_CC26XX_DEF_H_ */
185 /*---------------------------------------------------------------------------*/
186 /** @} */
Compiler and data type definitions for all CM3-based CPUs.
Compiler and data type definitions for all CM4-based CPUs.