1 /******************************************************************************
3 * Copyright (c) 2020 Intel.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 *******************************************************************************/
20 * @brief This file provides interface to Timing for XRAN.
23 * @ingroup group_lte_source_xran
24 * @author Intel Corporation
40 /* Difference between Unix seconds to GPS seconds
41 GPS epoch: 1980.1.6 00:00:00 (UTC); Unix time epoch: 1970:1.1 00:00:00 UTC
42 Value is calculated on Sep.6 2019. Need to be change if International
43 Earth Rotation and Reference Systems Service (IERS) adds more leap seconds
44 1970:1.1 - 1980.1.6: 3657 days
45 3657*24*3600=315 964 800 seconds (unix seconds value at 1980.1.6 00:00:00 (UTC))
46 There are 18 leap seconds inserted after 1980.1.6 00:00:00 (UTC), which means
47 GPS is 18 larger. 315 964 800 - 18 = 315 964 782
49 #define UNIX_TO_GPS_SECONDS_OFFSET 315964782UL
50 #define NUM_OF_FRAMES_PER_SFN_PERIOD 1024
51 #define NUM_OF_FRAMES_PER_SECOND 100
53 #define MSEC_PER_SEC 1000L
55 #define XranIncrementSymIdx(sym_idx, numSymPerMs) (((uint32_t)sym_idx >= (((uint32_t)numSymPerMs * MSEC_PER_SEC) - 1)) ? 0 : (uint32_t)sym_idx+1)
56 #define XranDecrementSymIdx(sym_idx, numSymPerMs) (((uint32_t)sym_idx == 0) ? (((uint32_t)numSymPerMs * MSEC_PER_SEC)) - 1) : (uint32_t)sym_idx-1)
58 uint64_t xran_tick(void);
59 unsigned long get_ticks_diff(unsigned long curr_tick, unsigned long last_tick);
60 long poll_next_tick(long interval_ns, unsigned long *used_tick);
61 long sleep_next_tick(long interval);
62 int timing_set_debug_stop(int value, int count);
63 int timing_get_debug_stop(void);
64 uint64_t timing_get_current_second(void);
65 uint8_t timing_get_numerology(void);
66 int timing_set_numerology(uint8_t value);
67 uint32_t xran_max_ota_sym_idx(uint8_t numerlogy);