1 /*! 2 * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 * All rights reserved. 4 * 5 * \file tsm_ll_timing.h 6 * Header file for the TSM and LL timing initialization module. 7 * 8 * Redistribution and use in source and binary forms, with or without modification, 9 * are permitted provided that the following conditions are met: 10 * 11 * o Redistributions of source code must retain the above copyright notice, this list 12 * of conditions and the following disclaimer. 13 * 14 * o Redistributions in binary form must reproduce the above copyright notice, this 15 * list of conditions and the following disclaimer in the documentation and/or 16 * other materials provided with the distribution. 17 * 18 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 19 * contributors may be used to endorse or promote products derived from this 20 * software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 26 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 #ifndef TSM_LL_TIMING_H 34 #define TSM_LL_TIMING_H 35 36 /*! ********************************************************************************* 37 ************************************************************************************* 38 * Include 39 ************************************************************************************* 40 ********************************************************************************** */ 41 #include "tsm_timing_ble.h" 42 #include "tsm_timing_zigbee.h" 43 44 /*! ********************************************************************************* 45 ************************************************************************************* 46 * Macros 47 ************************************************************************************* 48 ********************************************************************************** */ 49 #define mem16(x) (*(volatile uint16_t *)(x)) 50 51 /* Static assertion checks */ 52 #define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(!!(COND))*2-1] 53 54 #define COMPILE_TIME_ASSERT3(X,L) STATIC_ASSERT(X,static_assertion_at_line_##L) 55 #define COMPILE_TIME_ASSERT2(X,L) COMPILE_TIME_ASSERT3(X,L) 56 #define COMPILE_TIME_ASSERT(X) COMPILE_TIME_ASSERT2(X,__LINE__) 57 58 /*! ********************************************************************************* 59 ************************************************************************************* 60 * Constants 61 ************************************************************************************* 62 ********************************************************************************** */ 63 /* LL register setting defines for BLE */ 64 #define TX_ON_DELAY (146) 65 #ifndef BLE_SNIFFER_CORE 66 #define RX_ON_DELAY (128) 67 #else 68 #define RX_ON_DELAY (119) 69 #endif /* BLE_SNIFFER_CORE */ 70 #define TX_ON_DELAY_SHIFT (8) 71 #define RX_ON_DELAY_SHIFT (0) 72 STATIC_ASSERT((TX_ON_DELAY>END_OF_TX_WU_BLE),TX_Warmup_is_too_long_for_specified_TX_ON_Delay); 73 STATIC_ASSERT((RX_ON_DELAY>(END_OF_RX_WU_BLE+1)),RX_Warmup_is_too_long_for_specified_RX_ON_Delay); 74 #define TX_SYNTH_DELAY (TX_ON_DELAY-(END_OF_TX_WU_BLE-0)) /* END_OF_TX_WU_BLE from tsm_timing_ble.h */ 75 #define RX_SYNTH_DELAY (RX_ON_DELAY-(END_OF_RX_WU_BLE-1)) /* END_OF_RX_WU_BLE from tsm_timing_ble.h */ 76 #define TX_RX_ON_DELAY_VALUE ((TX_ON_DELAY<<TX_ON_DELAY_SHIFT) | (RX_ON_DELAY<<RX_ON_DELAY_SHIFT)) 77 #define TX_RX_SYNTH_DELAY_VALUE ((TX_SYNTH_DELAY<<TX_ON_DELAY_SHIFT) | (RX_SYNTH_DELAY<<RX_ON_DELAY_SHIFT)) 78 79 /* LL timing defines for Zigbee */ 80 #define END_OF_TX_WU_ZB END_OF_TX_WU_BLE+ZB_TSM_EXTRA_DELAY /* Zigbee == BLE timing plus an adjustment */ 81 #define END_OF_RX_WU_ZB END_OF_RX_WU_BLE+ZB_TSM_EXTRA_DELAY /* Zigbee == BLE timing plus an adjustment */ 82 83 #define NUM_TSM_TIMING_REGS (45) 84 85 /*! ********************************************************************************* 86 ************************************************************************************* 87 * Public type definitions 88 ************************************************************************************* 89 ********************************************************************************** */ 90 typedef enum 91 { 92 BLE_RADIO = 0, 93 ZIGBEE_RADIO = 1 94 } PHY_RADIO_T; 95 96 /*! ********************************************************************************* 97 ************************************************************************************* 98 * Public prototypes 99 ************************************************************************************* 100 ********************************************************************************** */ 101 #ifdef __cplusplus 102 extern "C" 103 { 104 #endif 105 106 void tsm_ll_timing_init(PHY_RADIO_T mode); 107 108 #ifdef __cplusplus 109 } 110 #endif 111 112 113 #endif /* TSM_LL_TIMING_H */ 114