<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/18869">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gsm0502: add TDMA frame number constants and modular arithmetic<br><br>These TDMA constatns and modular arithmetic operations are used in<br>a number of osmo-* projects, so it makes sense to have them all<br>in a single header file, with minimalistic documentation.<br><br>Change-Id: Ic291fd3644f34964374227a191c7045d79d77e0d<br>---<br>M include/osmocom/gsm/gsm0502.h<br>1 file changed, 24 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/69/18869/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/gsm/gsm0502.h b/include/osmocom/gsm/gsm0502.h</span><br><span>index cb993dc..189eab0 100644</span><br><span>--- a/include/osmocom/gsm/gsm0502.h</span><br><span>+++ b/include/osmocom/gsm/gsm0502.h</span><br><span>@@ -7,6 +7,30 @@</span><br><span> #include <osmocom/gsm/protocol/gsm_04_08.h></span><br><span> #include <osmocom/gsm/protocol/gsm_08_58.h></span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* 4.3.3 TDMA frame number : constants and modular arithmetic */</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_TDMA_FN_DURATION_nS         4615384         /* in 1e−9 seconds (approx) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_TDMA_FN_DURATION_uS               4615            /* in 1e-6 seconds (approx) */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_TDMA_SUPERFRAME           (26 * 51)</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_TDMA_HYPERFRAME          (2048 * GSM_TDMA_SUPERFRAME)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Return the sum of two specified TDMA frame numbers (summation) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_TDMA_FN_SUM(a, b) \</span><br><span style="color: hsl(120, 100%, 40%);">+        ((a + b) % GSM_TDMA_HYPERFRAME)</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Return the difference of two specified TDMA frame numbers (subtraction) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_TDMA_FN_SUB(a, b) \</span><br><span style="color: hsl(120, 100%, 40%);">+      ((a + GSM_TDMA_HYPERFRAME - b) % GSM_TDMA_HYPERFRAME)</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Return the *minimum* difference of two specified TDMA frame numbers (distance) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_TDMA_FN_DIFF(a, b) \</span><br><span style="color: hsl(120, 100%, 40%);">+        OSMO_MIN(GSM_TDMA_FN_SUB(a, b), GSM_TDMA_FN_SUB(b, a))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Increment the given TDMA frame number by 1 and return the result (like ++fn) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_TDMA_FN_INC(fn) \</span><br><span style="color: hsl(120, 100%, 40%);">+  (fn = GSM_TDMA_FN_SUM(fn, 1))</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Decrement the given TDMA frame number by 1 and return the result (like --fn) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_TDMA_FN_DEC(fn) \</span><br><span style="color: hsl(120, 100%, 40%);">+     (fn = GSM_TDMA_FN_SUB(fn, 1))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Table 5 Clause 7 TS 05.02 */</span><br><span> static inline unsigned int</span><br><span> gsm0502_get_n_pag_blocks(struct gsm48_control_channel_descr *chan_desc)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/18869">change 18869</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/18869"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ic291fd3644f34964374227a191c7045d79d77e0d </div>
<div style="display:none"> Gerrit-Change-Number: 18869 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>