Contiki-NG
Loading...
Searching...
No Matches
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#define RADIO_FRAME_DURATION(payload_len) \
96 US_TO_RTIMERTICKS(RADIO_BYTE_AIR_TIME * (RADIO_PHY_OVERHEAD + (payload_len)))
97
98/* Delay between GO signal and SFD */
99#define RADIO_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(RADIO_PHY_HEADER_LEN * RADIO_BYTE_AIR_TIME))
100/* Delay between GO signal and start listening.
101 * This value is so small because the radio is constantly on within each timeslot. */
102#define RADIO_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(15))
103/* Delay between the SFD finishes arriving and it is detected in software. */
104#define RADIO_DELAY_BEFORE_DETECT ((unsigned)US_TO_RTIMERTICKS(352))
105
106/* Timer conversion; radio is running at 4 MHz */
107#define RAT_SECOND 4000000u
108#define RAT_TO_RTIMER(x) ((uint32_t)(((uint64_t)(x) * (RTIMER_SECOND / 256)) / (RAT_SECOND / 256)))
109#define USEC_TO_RAT(x) ((x) * 4)
110
111#if (RTIMER_SECOND % 256) || (RAT_SECOND % 256)
112#error RAT_TO_RTIMER macro must be fixed!
113#endif
114
115/* Do not turn off TSCH within a timeslot: not enough time */
116#define TSCH_CONF_RADIO_ON_DURING_TIMESLOT 1
117
118/* Disable TSCH frame filtering */
119#define TSCH_CONF_HW_FRAME_FILTERING 0
120
121/* Use hardware timestamps */
122#ifndef TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS
123#define TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS 1
124#define TSCH_CONF_TIMESYNC_REMOVE_JITTER 0
125#endif
126
127#ifndef TSCH_CONF_BASE_DRIFT_PPM
128#if defined(DEVICE_LINE_CC13XX)
129/* The drift compared to "true" 40ms slots.
130 * Enable adaptive sync to enable compensation for this.
131 * Slot length 40000 usec
132 * 1311 ticks
133 * Tick duration 30.517578125 usec
134 * Real slot duration 40008.544922 usec
135 * Target - real duration = -8.544922 usec
136 * PPM -8.544922 / 40000 = -0.000214
137 */
138#define TSCH_CONF_BASE_DRIFT_PPM -214
139#else /* defined(DEVICE_LINE_CC13XX) */
140/*
141 * The drift compared to "true" 10ms slots.
142 * Enable adaptive sync to enable compensation for this.
143 * Slot length 10000 usec
144 * 328 ticks
145 * Tick duration 30.517578125 usec
146 * Real slot duration 10009.765625 usec
147 * Target - real duration = -9.765625 usec
148 * TSCH_CONF_BASE_DRIFT_PPM -977
149 */
150#define TSCH_CONF_BASE_DRIFT_PPM -977
151#endif /* defined(DEVICE_LINE_CC13XX) */
152#endif /* TSCH_CONF_BASE_DRIFT_PPM */
153
154/* 10 times per second */
155#ifndef TSCH_CONF_CHANNEL_SCAN_DURATION
156#define TSCH_CONF_CHANNEL_SCAN_DURATION (CLOCK_SECOND / 10)
157#endif
158
159/* Tweak to improve TSCH association speed on this platform */
160#ifndef TSCH_CONF_ASSOCIATION_POLL_FREQUENCY
161#define TSCH_CONF_ASSOCIATION_POLL_FREQUENCY 10
162#endif
163
164/* Increase TSCH guard time from 2200 usec to 3000 usec.
165 * This is required for simplelink radio to have stable operation, especially in sub-GHz range . */
166#ifndef TSCH_CONF_RX_WAIT
167#define TSCH_CONF_RX_WAIT 3000
168#endif
169/*---------------------------------------------------------------------------*/
170/* Path to CMSIS header */
171#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
172#define CMSIS_CONF_HEADER_PATH "cc13x0-cc26x0-cm3.h"
173#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
174#define CMSIS_CONF_HEADER_PATH "cc13x2-cc26x2-cm4.h"
175#endif
176/*---------------------------------------------------------------------------*/
177/* Path to headers with implementation of mutexes, atomic and memory barriers */
178#define MUTEX_CONF_ARCH_HEADER_PATH "mutex-cortex.h"
179#define ATOMIC_CONF_ARCH_HEADER_PATH "atomic-cortex.h"
180#define MEMORY_BARRIER_CONF_ARCH_HEADER_PATH "memory-barrier-cortex.h"
181/*---------------------------------------------------------------------------*/
182/* GPIO HAL configuration */
183#define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h"
184#define GPIO_HAL_CONF_ARCH_SW_TOGGLE 0
185#define GPIO_HAL_CONF_PORT_PIN_NUMBERING 0
186/*---------------------------------------------------------------------------*/
187#endif /* CC13XX_CC26XX_DEF_H_ */
188/*---------------------------------------------------------------------------*/
189/** @} */
Compiler and data type definitions for all CM3-based CPUs.
Compiler and data type definitions for all CM4-based CPUs.