Contiki-NG
gecko-def.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 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 gecko
33 * @{
34 *
35 * \file
36 * Header with defines common to all gecko platforms
37 * \author
38 * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br>
39 */
40/*---------------------------------------------------------------------------*/
41#ifndef GECKO_DEF_H_
42#define GECKO_DEF_H_
43/*---------------------------------------------------------------------------*/
44#include "arm-def.h"
45/*---------------------------------------------------------------------------*/
46/* Path to headers with implementation of mutexes, atomic and memory barriers */
47#define MUTEX_CONF_ARCH_HEADER_PATH "mutex-cortex.h"
48#define ATOMIC_CONF_ARCH_HEADER_PATH "atomic-cortex.h"
49#define MEMORY_BARRIER_CONF_ARCH_HEADER_PATH "memory-barrier-cortex.h"
50/*---------------------------------------------------------------------------*/
51#define RTIMER_ARCH_SECOND 32768
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_HEADER_LEN (5)
68#define RADIO_PHY_OVERHEAD (3)
69#define RADIO_BIT_RATE (250000)
70#define RADIO_BYTE_AIR_TIME (1000000 / (RADIO_BIT_RATE / 8))
71#define RADIO_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(192))
72#define RADIO_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(182))
73#define RADIO_DELAY_BEFORE_DETECT ((unsigned)US_TO_RTIMERTICKS(358))
74/*---------------------------------------------------------------------------*/
75#define GPIO_HAL_CONF_ARCH_HDR_PATH "gpio-hal-arch.h"
76#define GPIO_HAL_CONF_ARCH_SW_TOGGLE 0
77/*---------------------------------------------------------------------------*/
78#define TSCH_CONF_HW_FRAME_FILTERING 0
79#define TSCH_CONF_RADIO_ON_DURING_TIMESLOT 1
80#define TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS 1
81#define TSCH_CONF_TIMESYNC_REMOVE_JITTER 0
82#define TSCH_CONF_BASE_DRIFT_PPM -977
83/*---------------------------------------------------------------------------*/
84#endif /* GECKO_DEF_H_ */
85/*---------------------------------------------------------------------------*/
86/**
87 * @}
88 */
Compiler and data type definitions for all ARM-based CPUs.