comparison src/cs/riviera/rvf/rvf_target.h @ 365:f8ad9dcadde0

RV timing: better RVF_MS_TO_TICKS() formula
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 31 Dec 2017 06:32:33 +0000
parents 945cf7f506b2
children
comparison
equal deleted inserted replaced
364:44795dbadbae 365:f8ad9dcadde0
124 #ifdef _WINDOWS 124 #ifdef _WINDOWS
125 #define RVF_MS_TO_TICKS(_x) ((_x) / 50) 125 #define RVF_MS_TO_TICKS(_x) ((_x) / 50)
126 #define RVF_SECS_TO_TICKS(_x) (((_x) * 1000) / 50) 126 #define RVF_SECS_TO_TICKS(_x) (((_x) * 1000) / 50)
127 #define RVF_TICKS_TO_MS(_x) ((_x) * 50) 127 #define RVF_TICKS_TO_MS(_x) ((_x) * 50)
128 #else 128 #else
129 #if 1 /* new FreeCalypso code */
130 /*
131 * In the present GSM firmware, the Nucleus tick is the TDMA frame,
132 * and the duration of one TDMA frame by definition equals 60/13 ms.
133 * Hence we use the natural factors of 13 and 60 instead of TI's
134 * 200 and 923 (computed to fit the rounded 4.615 ms value),
135 * and get not only better accuracy, but also a greater maximum
136 * time value: 330382 s (just under 4 days) instead of the old maximum
137 * of 21474 s (just under 6 h).
138 */
139 #define RVF_MS_TO_TICKS(_x) ((((_x) * 13) + 30) / 60)
140 #define RVF_SECS_TO_TICKS(_x) ((((_x) * 13000) + 30) / 60)
141 /* RVF_TICKS_TO_MS() macro was unused and is being removed */
142 #else /* old code from TI */
129 /* 143 /*
130 * To avoid floating point computation, the tick duration 4.615 ms can be 144 * To avoid floating point computation, the tick duration 4.615 ms can be
131 * resolved to the fraction : 923/200. 145 * resolved to the fraction : 923/200.
132 * 146 *
133 * Due to the multiplication with 200, the maximum usable value for 147 * Due to the multiplication with 200, the maximum usable value for
137 */ 151 */
138 #define RVF_MS_TO_TICKS(_x) ((((_x) * 200) + 462) / 923) 152 #define RVF_MS_TO_TICKS(_x) ((((_x) * 200) + 462) / 923)
139 #define RVF_SECS_TO_TICKS(_x) ((((_x) * 1000 * 200) + 462) / 923) 153 #define RVF_SECS_TO_TICKS(_x) ((((_x) * 1000 * 200) + 462) / 923)
140 #define RVF_TICKS_TO_MS(_x) ((((_x) * 923) + 100) / 200) 154 #define RVF_TICKS_TO_MS(_x) ((((_x) * 923) + 100) / 200)
141 #endif 155 #endif
156 #endif
142 157
143 #endif /* _RVF_TARGET_H */ 158 #endif /* _RVF_TARGET_H */