This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
fixeria gerrit-no-reply at lists.osmocom.orgfixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/18869 ) Change subject: gsm0502: add TDMA frame number constants and modular arithmetic ...................................................................... gsm0502: add TDMA frame number constants and modular arithmetic These TDMA constatns and modular arithmetic operations are used in a number of osmo-* projects, so it makes sense to have them all in a single header file, with minimalistic documentation. Change-Id: Ic291fd3644f34964374227a191c7045d79d77e0d --- M include/osmocom/gsm/gsm0502.h 1 file changed, 24 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/69/18869/1 diff --git a/include/osmocom/gsm/gsm0502.h b/include/osmocom/gsm/gsm0502.h index cb993dc..189eab0 100644 --- a/include/osmocom/gsm/gsm0502.h +++ b/include/osmocom/gsm/gsm0502.h @@ -7,6 +7,30 @@ #include <osmocom/gsm/protocol/gsm_04_08.h> #include <osmocom/gsm/protocol/gsm_08_58.h> +/* 4.3.3 TDMA frame number : constants and modular arithmetic */ +#define GSM_TDMA_FN_DURATION_nS 4615384 /* in 1e−9 seconds (approx) */ +#define GSM_TDMA_FN_DURATION_uS 4615 /* in 1e-6 seconds (approx) */ + +#define GSM_TDMA_SUPERFRAME (26 * 51) +#define GSM_TDMA_HYPERFRAME (2048 * GSM_TDMA_SUPERFRAME) + +/*! Return the sum of two specified TDMA frame numbers (summation) */ +#define GSM_TDMA_FN_SUM(a, b) \ + ((a + b) % GSM_TDMA_HYPERFRAME) +/*! Return the difference of two specified TDMA frame numbers (subtraction) */ +#define GSM_TDMA_FN_SUB(a, b) \ + ((a + GSM_TDMA_HYPERFRAME - b) % GSM_TDMA_HYPERFRAME) +/*! Return the *minimum* difference of two specified TDMA frame numbers (distance) */ +#define GSM_TDMA_FN_DIFF(a, b) \ + OSMO_MIN(GSM_TDMA_FN_SUB(a, b), GSM_TDMA_FN_SUB(b, a)) + +/*! Increment the given TDMA frame number by 1 and return the result (like ++fn) */ +#define GSM_TDMA_FN_INC(fn) \ + (fn = GSM_TDMA_FN_SUM(fn, 1)) +/*! Decrement the given TDMA frame number by 1 and return the result (like --fn) */ +#define GSM_TDMA_FN_DEC(fn) \ + (fn = GSM_TDMA_FN_SUB(fn, 1)) + /* Table 5 Clause 7 TS 05.02 */ static inline unsigned int gsm0502_get_n_pag_blocks(struct gsm48_control_channel_descr *chan_desc) -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18869 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ic291fd3644f34964374227a191c7045d79d77e0d Gerrit-Change-Number: 18869 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200616/1786acd7/attachment.htm>