import superfemto v0.1pre

This commit is contained in:
Harald Welte 2012-10-27 19:16:46 +02:00
commit 71f6e50377
8 changed files with 2545 additions and 0 deletions

521
include/gsml1const.h Normal file
View File

@ -0,0 +1,521 @@
#ifndef GSML1CONST_H__
#define GSML1CONST_H__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#define L1_HAS_EFR
#define L1_HAS_RTP_MODE
/****************************************************************************
* Public macro *
****************************************************************************/
/****************************************************************************
* Macro : CALL_GSML1
************************************************************************//**
*
* This macro calls a GsmL1 function and jump to the gsml1_error label if the
* returned value is different from GsmL1_Status_Success.
*
* @note A gsml1_error label must be defined in the function.
*
* @ingroup gsml1_api_const
*
***************************************************************************/
#define CALL_GSML1(x) if( ( status = x ) != GsmL1_Status_Success ) goto gsml1_error;
/****************************************************************************
* Public constants *
****************************************************************************/
/****************************************************************************
* Enum: : GsmL1_SubCh_t
************************************************************************//**
*
* GSM Layer 1 sub-channel identifiers.
*
* @ingroup gsml1_api_const
*
***************************************************************************/
typedef enum GsmL1_SubCh_t
{
GsmL1_SubCh_0 = 0, ///< Sub-channel 0
GsmL1_SubCh_1, ///< Sub-channel 1
GsmL1_SubCh_2, ///< Sub-channel 2
GsmL1_SubCh_3, ///< Sub-channel 3
GsmL1_SubCh_4, ///< Sub-channel 4
GsmL1_SubCh_5, ///< Sub-channel 5
GsmL1_SubCh_6, ///< Sub-channel 6
GsmL1_SubCh_7, ///< Sub-channel 7
GsmL1_SubCh_8, ///< Sub-channel 8
GsmL1_SubCh_9, ///< Sub-channel 9
GsmL1_SubCh_10, ///< Sub-channel 10
GsmL1_SubCh_11, ///< Sub-channel 11
GsmL1_SubCh_12, ///< Sub-channel 12
GsmL1_SubCh_13, ///< Sub-channel 13
GsmL1_SubCh_14, ///< Sub-channel 14
GsmL1_SubCh_15, ///< Sub-channel 15
GsmL1_SubCh_NA = 0x1F ///< No sub-channel (not applicable)
} GsmL1_SubCh_t;
/****************************************************************************
* typedef : GsmL1_Sapi_t
************************************************************************//**
*
* Service Access Point Identifier (SAPI).
*
* An SAPI is used to identifie a specific Service Access Point (SAP)
*
* @ingroup gsml1_api_const
*
***************************************************************************/
typedef enum GsmL1_Sapi_t
{
GsmL1_Sapi_Idle = 0, ///< Idle burst pseudo-channel
GsmL1_Sapi_Fcch, ///< Frequency correction burst pseudo-channel
GsmL1_Sapi_Sch, ///< Synchronization channel
GsmL1_Sapi_Sacch, ///< Slow associated control channel
GsmL1_Sapi_Sdcch, ///< Stand-alone dedicated control channel
GsmL1_Sapi_Bcch, ///< Broadcast control channel
GsmL1_Sapi_Pch, ///< Paging channel
GsmL1_Sapi_Agch, ///< Access grant channel
GsmL1_Sapi_Cbch, ///< Cell Broadcast Channel
GsmL1_Sapi_Rach, ///< Random access channel
GsmL1_Sapi_TchF, ///< Full rate speech traffic channel
GsmL1_Sapi_FacchF, ///< Fast associated control channel at full rate
GsmL1_Sapi_TchH, ///< Half rate speech traffic channel
GsmL1_Sapi_FacchH, ///< Fast associated control channel at half rate
GsmL1_Sapi_Nch, ///< Notification Channel
GsmL1_Sapi_Pdtch, ///< Packet data traffic channel
GsmL1_Sapi_Pacch, ///< Packet associated control channel
GsmL1_Sapi_Pbcch, ///< Packet broadcast control channel
GsmL1_Sapi_Pagch, ///< Packet access grant channel
GsmL1_Sapi_Ppch, ///< Packet paging channel
GsmL1_Sapi_Pnch, ///< Packet notification channel
GsmL1_Sapi_Ptcch, ///< Packet timing advance control channel
GsmL1_Sapi_Prach, ///< Packet random access channel
GsmL1_Sapi_NUM ///< Only used to retrieve the last SAPI number
} GsmL1_Sapi_t;
/****************************************************************************
* Enum: GsmL1_Status_t
************************************************************************//**
*
* Status used by layer 1 functions.
*
* @ingroup gsml1_api_const
*
****************************************************************************/
typedef enum GsmL1_Status_t
{
GsmL1_Status_Success = 0, ///< No error
GsmL1_Status_Generic = -1, ///< Generic error
GsmL1_Status_NoMemory = -2, ///< Not enough memory error
GsmL1_Status_Timeout = -3, ///< Timeout error
GsmL1_Status_InvalidParam = -4, ///< Invalid parameter error
GsmL1_Status_Busy = -5, ///< Busy ressource error
GsmL1_Status_NoRessource = -6, ///< No more ressource available error
GsmL1_Status_Uninitialized = -7, ///< Trying to use an unitialized resource
GsmL1_Status_NullInterface = -8, ///< Trying to call a NULL interface
GsmL1_Status_NullFctnPtr = -9, ///< Trying to call a NULL function ptr
GsmL1_Status_BadCrc = -10, ///< Bad CRC error
GsmL1_Status_BadUsf = -11, ///< Bad USF error
GsmL1_Status_InvalidCPS = -12, ///< Invalid CPS field
GsmL1_Status_UnexpectedBurst = -13, ///< Unexpected Burst
GsmL1_Status_UnavailCodec = -14, ///< AMR codec is unavailable
GsmL1_Status_CriticalError = -15, ///< Critical error
GsmL1_Status_OverheatError = -16, ///< Overheat error
GsmL1_Status_DeviceError = -17, ///< Device error
GsmL1_Status_FacchError = -18, /**< Trying to activate a Facch prior activating a Tch logCh or
Trying to deactivate a Tch logCh prior deactivating all active Facch blocks */
GsmL1_Status_AlreadyDeactivated = -19, ///< Trying to deactivate an already deactivated LogCh
GsmL1_Status_TxBurstFifoOvrn = -20, ///< Trying to write into a Full Fifo
GsmL1_Status_TxBurstFifoUndr = -21, ///< Fifo underrun
GsmL1_Status_NotSynchronized = -22, ///< Not synchronized
GsmL1_Status_Unsupported = -23, ///< Unsupported feature
GSML1_STATUS_NUM = 24
} GsmL1_Status_t;
/****************************************************************************
* Enum: GsmL1_LogChComb_t
************************************************************************//**
*
* Permitted logical channel combinations over a physical channel.
*
* @ingroup gsml1_api_const
*
****************************************************************************/
typedef enum GsmL1_LogChComb_t
{
GsmL1_LogChComb_0 = 0, ///< UNUSED (DUMMY BURST)
GsmL1_LogChComb_I, ///< TCH/F + FACCH/F + SACCH/TF
GsmL1_LogChComb_II, ///< TCH/H(0,1) + FACCH/H(0,1) + SACCH/TH(0,1)
GsmL1_LogChComb_IV, ///< FCCH + SCH + BCCH + CCCH
GsmL1_LogChComb_V, ///< FCCH + SCH + BCCH + CCCH + SDCCH/4(0..3) + SACCH/C4(0..3)
GsmL1_LogChComb_VII, ///< SDCCH/8(0 .7) + SACCH/C8(0 . 7)
GsmL1_LogChComb_XIII ///< PDTCH/F + PACCH/F + PTCCH/F
} GsmL1_LogChComb_t;
/****************************************************************************
* Enum : GsmL1_DevType_t
************************************************************************//**
*
* PHY device type.
*
* @ingroup gsml1_api_const
*
****************************************************************************/
typedef enum GsmL1_DevType_t
{
GsmL1_DevType_TxdRxu = 0x06, ///< Base station type (TX downlink, RX uplink)
GsmL1_DevType_TxuRxd = 0x09, ///< Mobile station type (TX uplink, RX downlink)
GsmL1_DevType_Rxd = 0x01, ///< Monitor type (RX downlink only)
GsmL1_DevType_Rxu = 0x02, ///< Monitor type (RX uplink only)
GsmL1_DevType_Txd = 0x04, ///< Jammer type (TX downlink only)
GsmL1_DevType_Txu = 0x08 ///< Jammer type (TX uplink only)
} GsmL1_DevType_t;
/****************************************************************************
* Enum : GsmL1_Dir_t
************************************************************************//**
*
* Indicate the path of the transmission.
*
* @ingroup gsml1_api_const
*
****************************************************************************/
typedef enum GsmL1_Dir_t
{
GsmL1_Dir_None = 0x00, ///< No path
GsmL1_Dir_RxDownlink = 0x01, ///< Receive transmission path from Bts to the mobile station
GsmL1_Dir_RxUplink = 0x02, ///< Receive transmission path from mobile station to the Bts
GsmL1_Dir_TxDownlink = 0x04, ///< Transmit on transmission path from Bts to the mobile station
GsmL1_Dir_TxUplink = 0x08 ///< Transmit on transmission path from mobile station to the Bts
} GsmL1_Dir_t;
/****************************************************************************
* Enum : GsmL1_CipherId_t
************************************************************************//**
*
* Ciphering algorithm ID.
*
* @ingroup gsml1_api_const
*
****************************************************************************/
typedef enum GsmL1_CipherId_t
{
GsmL1_CipherId_A50 = 0x00, ///< No encryption
GsmL1_CipherId_A51 = 0x01, ///< A5/1
GsmL1_CipherId_A52 = 0x02, ///< A5/2
GsmL1_CipherId_A53 = 0x03 ///< A5/3
} GsmL1_CipherId_t;
/****************************************************************************
* Enum : GsmL1_FreqBand_t
************************************************************************//**
*
* GSM frequency bands.
*
* @ingroup gsml1_api_const
*
****************************************************************************/
typedef enum GsmL1_FreqBand_t
{
GsmL1_FreqBand_850 = 0, ///< GSM-850 frequency band
GsmL1_FreqBand_900, ///< GSM-900 frequency band
GsmL1_FreqBand_1800, ///< GSM-1800 frequency band
GsmL1_FreqBand_1900, ///< GSM-1900 frequency band
Num_GsmL1_FreqBand ///< Number of frequency bands
} GsmL1_FreqBand_t;
/****************************************************************************
* Enum : GsmL1_TchFormat_t
************************************************************************//**
*
* TCH message packin format.
*
* @ingroup gsml1_api_const
*
****************************************************************************/
typedef enum GsmL1_TchFormat_t
{
GsmL1_TchFormat_Rtp = 0, ///< RTP format
GsmL1_TchFormat_If2 ///< IF2 format (AMR), custom (HR, FR, EFR)
} GsmL1_TchFormat_t;
/****************************************************************************
* Enum : GsmL1_PrimId_t
************************************************************************//**
*
* Inter-layer communication primitives ID definitions
*
* @ingroup gsml1_api_const
*
****************************************************************************/
typedef enum GsmL1_PrimId_t
{
GsmL1_PrimId_MphInitReq = 0, ///< Initialize the base station.
GsmL1_PrimId_MphCloseReq, ///< Closes the base station.
GsmL1_PrimId_MphConnectReq, ///< Connect a physical channel.
GsmL1_PrimId_MphDisconnectReq, ///< Disconnect a physical channel.
GsmL1_PrimId_MphActivateReq, ///< Activate a logical channel over a physical channel.
GsmL1_PrimId_MphDeactivateReq, ///< Deactivate a logical channel from a physical channel.
GsmL1_PrimId_MphConfigReq, ///< Configure a physical channel.
GsmL1_PrimId_MphMeasureReq, ///< Measure the received signal strenght indication on a device.
GsmL1_PrimId_MphInitCnf, ///< Confirm the reception of a MPH-INIT_REQ primitive.
GsmL1_PrimId_MphCloseCnf, ///< Confirm the reception of a MPH-CLOSE_REQ primitive.
GsmL1_PrimId_MphConnectCnf, ///< Returns an handle pointing to the connected physical channel.
GsmL1_PrimId_MphDisconnectCnf, ///< Confirm the reception of a MPH-DISCONNECT_REQ primitive.
GsmL1_PrimId_MphActivateCnf, ///< Confirm the reception of a MPH-ACTIVATE_REQ primitive.
GsmL1_PrimId_MphDeactivateCnf, ///< Confirm the reception of a MPH-DEACTIVATE_REQ primitive.
GsmL1_PrimId_MphConfigCnf, ///< Confirm the reception of a MPH-CONFIG_REQ primitive.
GsmL1_PrimId_MphMeasureCnf, ///< Returns the measurement made on the reception of a MPH-MEASURE-REQ primitive.
GsmL1_PrimId_MphTimeInd, ///< Infom upper layer of the actual timeslot and frame number.
GsmL1_PrimId_MphSyncInd, ///< Synchronization status indication
GsmL1_PrimId_PhEmptyFrameReq, ///< Layer 2 has nothing to transmit on a PH-READY-TO-SEND.
GsmL1_PrimId_PhDataReq, ///< Transfer a message frame unit to the layer 1.
GsmL1_PrimId_PhConnectInd, ///< Inform layer 2 that a logical channel has connected on layer 1.
GsmL1_PrimId_PhReadyToSendInd, ///< Ask layer 3 for something to transmit.
GsmL1_PrimId_PhDataInd, ///< Transmit a message frame unit to layer 2.
GsmL1_PrimId_PhRaInd, ///< Inform the layer 2 of a random access initiated by the MS.
GsmL1_PrimId_NUM ///< Only used to validate parameters
} GsmL1_PrimId_t;
/****************************************************************************
* enum: GsmL1_BurstType_t
************************************************************************//**
*
* GSM Burst Types
*
* @see
* TS 3GPP 45.002 - 5.0
*
* @ingroup gsml1_common_const
*
***************************************************************************/
typedef enum GsmL1_BurstType_t
{
GsmL1_BurstType_Sync = 0, ///< Synchronization Burst
GsmL1_BurstType_Normal = 1, ///< Normal Burst
GsmL1_BurstType_Dummy = 2, ///< Dummy Burst
GsmL1_BurstType_Normal8Psk = 3, ///< Normal Burst (8PSK)
GsmL1_BurstType_Access_0 = 4, ///< Access Burst (Training sequence 0)
GsmL1_BurstType_Access_1 = 5, ///< Access Burst (Training sequence 1)
GsmL1_BurstType_Access_2 = 6, ///< Access Burst (Training sequence 2)
GsmL1_BurstType_Freq = 7, ///< Frequency Correction Burst
GsmL1_BurstType_NUM ///< Only used to validate parameters
} GsmL1_BurstType_t;
/****************************************************************************
* typedef enum : GsmL1_If2FrTypeIdx_t
************************************************************************//**
*
* List of every IF2 frame types.
*
* @ingroup gsml1_api_const
*
***************************************************************************/
typedef enum GsmL1_If2FrTypeIdx_t
{
GsmL1_If2FrTypeIdx_4_75 = 0, ///< AMR 4,75
GsmL1_If2FrTypeIdx_5_15, ///< AMR 5,15
GsmL1_If2FrTypeIdx_5_9, ///< AMR 5,9
GsmL1_If2FrTypeIdx_6_7, ///< AMR 6,7
GsmL1_If2FrTypeIdx_7_4, ///< AMR 7,4
GsmL1_If2FrTypeIdx_7_95, ///< AMR 7,95
GsmL1_If2FrTypeIdx_10_2, ///< AMR 10,2
GsmL1_If2FrTypeIdx_12_2, ///< AMR 12,2
GsmL1_If2FrTypeIdx_SID, ///< AMR SID
GsmL1_If2FrTypeIdx_NoData = 15 ///< NO DATA
} GsmL1_If2FrTypeIdx_t;
/****************************************************************************
* typedef enum : GsmL1_TchPlType_t
************************************************************************//**
*
* List of every payload type supported on a TCH physical channel.
*
* @ingroup gsml1_api_const
*
***************************************************************************/
typedef enum GsmL1_TchPlType_t
{
GsmL1_TchPlType_NA = 0, ///< Not applicable, unknown, invalid
GsmL1_TchPlType_Fr, ///< Compacted ETSI full-rate traffic speech frame
GsmL1_TchPlType_Hr, ///< Compacted ETSI half-rate traffic speech frame
GsmL1_TchPlType_Efr, ///< Compacted ETSI enhanced full-rate traffic speech frame
GsmL1_TchPlType_Amr, ///< RTP/IF2 adaptive multi-rate traffic speech frame
// These cannot be formatted using IF2 format !!
GsmL1_TchPlType_Amr_SidBad, ///< Indicates that errors are detected
GsmL1_TchPlType_Amr_Onset, ///< Used to signal the Codec mode for the first speech frame after DTX
GsmL1_TchPlType_Amr_Ratscch, ///< Frames used to convey RATSCCH messages
GsmL1_TchPlType_Amr_SidUpdateInH, ///< Used to inhibit the second part of a SID_UPDATE frame if there is a speech onset
GsmL1_TchPlType_Amr_SidFirstP1, ///< First part of marker to define end of speech, start of DTX
GsmL1_TchPlType_Amr_SidFirstP2, ///< Second part of marker to define end of speech, start of DTX
GsmL1_TchPlType_Amr_SidFirstInH, ///< Used to inhibit the second part of a SID_FIRST_P1 frame if there is a speech onset
GsmL1_TchPlType_Amr_RatscchMarker, ///< Marker to identify Ratscch frames
GsmL1_TchPlType_Amr_RatscchData ///< Frame that conveys the actual Ratscch message
} GsmL1_TchPlType_t;
/****************************************************************************
* Enum : GsmL1_TchPlFmt_t
************************************************************************//**
*
* List of every payload packing format supported on a TCH physical channel.
*
* @ingroup gsml1_api_const
*
****************************************************************************/
typedef enum GsmL1_TchPlFmt_t
{
GsmL1_TchPlFmt_Rtp = 0, ///< RFC XXXX - RTP format
GsmL1_TchPlFmt_If2 ///< Etsi IF2 format (AMR), custom (HR, FR, EFR)
} GsmL1_TchPlFmt_t;
/****************************************************************************
* typedef enum : GsmL1_PdtchPlType_t
************************************************************************//**
*
* List of every payload type supported on a PDTCH physical channel.
*
* @ingroup gsml1_api_const
*
***************************************************************************/
typedef enum GsmL1_PdtchPlType_t
{
GsmL1_PdtchPlType_NA = 0x00, ///< Not applicable, unknown, invalid
GsmL1_PdtchPlType_Hdr = 0x01, ///< Header only is present and valid
GsmL1_PdtchPlType_Hdr_Data1 = 0x03, ///< Header and 1st half of data (2nd half is present but invalid)
GsmL1_PdtchPlType_Hdr_Data2 = 0x05, ///< Header and 2nd half of data (1st half is present but invalid)
GsmL1_PdtchPlType_Full = 0x07 ///< Full data present and valid
} GsmL1_PdtchPlType_t;
/****************************************************************************
* typedef enum : GsmL1_AmrCodec_t
************************************************************************//**
*
* List of every supported codecs of a TCH/AMR active codec set.
*
* @ingroup gsml1_api_const
*
***************************************************************************/
typedef enum GsmL1_AmrCodec_t
{
GsmL1_AmrCodec_Unset = 0, ///< Used to indicate that a slot of the Active Codec Slot is unset
GsmL1_AmrCodec_4_75, ///< 4,75 Kbits/s codec
GsmL1_AmrCodec_5_15, ///< 5,15 Kbits/s codec
GsmL1_AmrCodec_5_9, ///< 5,9 Kbits/s codec
GsmL1_AmrCodec_6_7, ///< 6,7 Kbits/s codec
GsmL1_AmrCodec_7_4, ///< 7,4 Kbits/s codec
GsmL1_AmrCodec_7_95, ///< 7,95 Kbits/s codec
GsmL1_AmrCodec_10_2, ///< 10,2 Kbits/s codec
GsmL1_AmrCodec_12_2, ///< 12,2 Kbits/s codec
GsmL1_AmrCodec_NUM ///< Only used to retrieve the last Codec number
} GsmL1_AmrCodec_t;
/****************************************************************************
* typedef enum : GsmL1_AmrCmiPhase_t
************************************************************************//**
*
* Available codec mode indication phase.
*
* @ingroup gsml1_api_const
*
***************************************************************************/
typedef enum GsmL1_AmrCmiPhase_t
{
GsmL1_AmrCmiPhase_NA = 0, ///< AMR CMI phase is not applicable
GsmL1_AmrCmiPhase_Odd, ///< AMR odd phase codec mode indication (default)
GsmL1_AmrCmiPhase_Even ///< AMR even phase codec mode indication
} GsmL1_AmrCmiPhase_t;
/****************************************************************************
* typedef enum : GsmL1_AmrCodecMode_t
************************************************************************//**
*
* Available codec modes of a TCH/AFS or TCH/AHS active codec set.
*
* @ingroup gsml1_api_const
*
***************************************************************************/
typedef enum GsmL1_AmrCodecMode_t
{
GsmL1_AmrCodecMode_1 = 0, ///< AMR Codec Mode 1
GsmL1_AmrCodecMode_2, ///< AMR Codec Mode 2
GsmL1_AmrCodecMode_3, ///< AMR Codec Mode 3
GsmL1_AmrCodecMode_4, ///< AMR Codec Mode 4
GsmL1_AmrCodecMode_Unset ///< Unset AMR Codec Mode
} GsmL1_AmrCodecMode_t;
/****************************************************************************
* typedef : GsmL1_ConfigParamId_t
************************************************************************//**
*
* Id used to identify which parameter is configured through a MPH-CONFIG-REQ.
*
* @ingroup gsml1_api_const
*
***************************************************************************/
typedef enum GsmL1_ConfigParamId_t
{
GsmL1_ConfigParamId_SetNbTsc, ///< Set the normal burst TSC of the specified RF device
GsmL1_ConfigParamId_SetTxPowerLevel, ///< Set the TX power level of the specified RF device
GsmL1_ConfigParamId_SetLogChParams, ///< Configure the logical channel specific parameters
GsmL1_ConfigParamId_SetCipheringParams, ///< Configure the ciphering parameters
GsmL1_ConfigParamId_NUM ///< Only used to validate parameters
} GsmL1_ConfigParamId_t;
/****************************************************************************
* Public constant *
****************************************************************************/
/// Maximum length of a layer 2 message unit.
#define MAX_L2MSGSIZE 160 // ( Based on a PDTCH block type 13 (MCS-9) [155 bytes] )
/// Advance taken by the library (counted in frames where 1 frame = 8 timeslots )
#define GSML1_FN_ADVANCE 6
///< Size (in byte) of a Traffic Channel header located at the start of every msg unit
#define TCH_HEADER_SIZE 1
#ifdef __cplusplus
}
#endif // extern "C"
#endif // GSML1CONST_H__

194
include/gsml1dbg.h Normal file
View File

@ -0,0 +1,194 @@
#ifndef GSMDBG_H__
#define GSMDBG_H__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/****************************************************************************
* Includes *
****************************************************************************/
#include <stdint.h>
#include <stdio.h>
#include "gsml1types.h" // GsmL1_RxBurst_t
/****************************************************************************
* Defines *
****************************************************************************/
// Debugging system's verbosity level flags
#define DBG_NONE 0x00000000
#define DBG_ALL 0xFFFFFFFF
#define DBG_DEBUG 0x80000000
#define DBG_L1WARNING 0x40000000
#define DBG_ERROR 0x20000000
#define DBG_L1RXMSG 0x10000000
#define DBG_L1RXMSGBYTE 0x08000000
#define DBG_L1TXMSG 0x04000000
#define DBG_L1TXMSGBYTE 0x02000000
#define DBG_MPHCNF 0x01000000
#define DBG_MPHIND 0x00800000
#define DBG_MPHREQ 0x00400000
#define DBG_PHIND 0x00200000
#define DBG_PHREQ 0x00100000
#define DBG_PHYRF 0x00080000
#define DBG_PHYRFMSGBYTE 0x00040000
#define DBG_MODE 0x00020000
#define DBG_TDMAINFO 0x00010000
#define DBG_BADCRC 0x00008000
#define DBG_PHINDBYTE 0x00004000
#define DBG_PHREQBYTE 0x00002000
#define DBG_DEVICEMSG 0x00000800
#define DBG_RACHINFO 0x00000040
#define DBG_LOGCHINFO 0x00000020
#define DBG_MEMORY 0x00000010
#define DBG_PROFILING 0x00000008
#define DBG_TESTCOMMENT 0x00000004
#define DBG_TEST 0x00000002
#define DBG_STATUS 0x00000001
#define DBG_RSSI_THRESHOLD -60.0f ///< Minimum RSSI to be considered a valid burst
/****************************************************************************
* Public functions *
****************************************************************************/
/****************************************************************************
* Function : GsmL1Dbg_Init
************************************************************************//**
*
* Print a debug string to the standard output.
*
* @param [in] u32Level
* Verbosity level of the printed message.
*
* @param [in] pExtPrintfCb
* Function pointer to an external routine able to print the formated string.
*
* @param [out] pstrOutputFileName
* Name of the output file ( Set to NULL in order to disable this feature )
*
* @return
* None.
*
* @ingroup gsm_common_debug
*
***************************************************************************/
void GsmL1Dbg_Init( uint32_t u32Level,
void (*pExtPrintfCb) ( char *pString),
char *pstrOutputFileName );
/****************************************************************************
* Function : GsmL1Dbg_SetLevel
************************************************************************//**
*
* Set the verbosity level.
*
* @param [in] u32Level
* Verbosity level of the printed message.
*
* @return
* None.
*
* @ingroup gsm_common_debug
*
***************************************************************************/
void GsmL1Dbg_SetLevel( uint32_t u32Level );
/****************************************************************************
* Function : GsmL1Dbg_Close
************************************************************************//**
*
* Close the debugging system.
*
* @return
* None.
*
* @ingroup gsm_common_debug
*
***************************************************************************/
void GsmL1Dbg_Close();
/****************************************************************************
* Function : GsmL1Dbg_Printf
************************************************************************//**
*
* Print a debug string to the standard output.
*
* @param [in] u32Level
* Verbosity level of the printed message.
*
* @param [in] *format
* String that contains the text to be written to the stdout.
*
* @return
* None.
*
* @ingroup gsm_common_debug
*
***************************************************************************/
void GsmL1Dbg_Printf( uint32_t u32Level, char const *format, ... );
/****************************************************************************
* Function : GsmL1Dbg_DumpBuffer
************************************************************************//**
*
* Dump a generic uint8_t buffer.
*
* @param [in] u32Level
* Verbosity level of the printed message.
*
* @param [in] u32FirstByte
* Starting byte index
*
* @param [in] u32Length
* Number of bytes to dump
*
* @param [in] pu8Buffer
* Pointer to the dumped buffer
*
* @return
* None.
*
* @ingroup gsm_common_debug
*
***************************************************************************/
void GsmL1Dbg_DumpBuffer( uint32_t u32Level,
uint32_t u32FirstByte,
uint32_t u32Length,
uint8_t *pu8Buffer );
/****************************************************************************
* Function : GsmL1Dbg_DumpRxBurst
************************************************************************//**
*
* Dump a RxBurst
*
* @param [in] u32Level
* Verbosity level of the printed message.
*
* @param [in] prxBurst
* Pointer to the dumped RX burst
*
* @return
* None.
*
* @ingroup gsm_common_debug
*
***************************************************************************/
void GsmL1Dbg_DumpRxBurst( uint32_t u32Level, GsmL1_RxBurst_t *prxBurst );
#ifdef __cplusplus
}
#endif // extern "C"
#endif // GSMDBG_H__

101
include/gsml1link.h Normal file
View File

@ -0,0 +1,101 @@
#ifndef GSML1LINK_H__
#define GSML1LINK_H__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/****************************************************************************
* Includes *
****************************************************************************/
#include "gsml1serv.h"
#include "gsml1prim.h"
#include "gsml1const.h"
#include "gsml1types.h"
/****************************************************************************
* Types *
****************************************************************************/
/****************************************************************************
* Public Functions *
****************************************************************************/
/****************************************************************************
* Function : GsmL1Link_Init
************************************************************************//**
*
* Initialise the GSM layer 1 library.
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup gsml1_api_services
*
****************************************************************************/
GsmL1_Status_t GsmL1Link_Init( void );
/****************************************************************************
* Function : GsmL1Link_SetExternalServices
************************************************************************//**
*
* Set every services provided to the layer 1 by external libraries
*
* @param [in] pL3ProvidedServices
* Points to a structure containing all Layer 3 external services
*
* @param [in] pL2ProvidedServices
* Points to a structure containing all Layer 3 external services
*
* @param [in] pPhyRfProvidedServices
* Points to a structure containing all PhyRf external services
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup gsml1_api_services
*
****************************************************************************/
GsmL1_Status_t GsmL1Link_SetExternalServices( Gsm_L3ProvidedServices_t *pL3ProvidedServices,
Gsm_L2ProvidedServices_t *pL2ProvidedServices,
Gsm_PhyRfProvidedServices_t *pPhyRfProvidedServices );
/****************************************************************************
* Function : GsmL1Link_GetProvidedServices
************************************************************************//**
*
* Return a strucuture containing all service functions pointer provided
* by the physical link layer library to the external context.
*
* @param [out] pPhyLinkProvidedServices
* Points to a structure of all GSM layer 1 library services function pointer.
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup gsml1_api_services
*
****************************************************************************/
GsmL1_Status_t GsmL1Link_GetProvidedServices( Gsm_PhyLinkProvidedServices_t *pPhyLinkProvidedServices );
/****************************************************************************
* Function : GsmL1Link_Close
************************************************************************//**
*
* Close the GSM layer 1 instance and free every allocated ressources.
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup gsml1_api_services
*
****************************************************************************/
GsmL1_Status_t GsmL1Link_Close( void );
#ifdef __cplusplus
}
#endif // extern "C"
#endif // GSML1_H__

873
include/gsml1prim.h Normal file
View File

@ -0,0 +1,873 @@
#ifndef GSML1PRIM_H__
#define GSML1PRIM_H__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/****************************************************************************
* Includes *
****************************************************************************/
#ifndef WIN32
#include <stdint.h>
#endif
#include "gsml1const.h"
#include "gsml1types.h"
/****************************************************************************
* Types (Primitive Parameters) *
****************************************************************************/
/****************************************************************************
* typedef : GsmL1_MsgUnitParam_t
************************************************************************//**
*
* Buffer structure used to transfer all messages frame units between
* the layers.
*
* @ingroup gsml1_api_prim_params
*
***************************************************************************/
typedef struct GsmL1_MsgUnitParam_t
{
uint8_t u8Size; ///< Size of the msg. unit
uint8_t u8Buffer[MAX_L2MSGSIZE]; ///< Buffer containing the msg. unit
// uint32_t u32Control; ///< Control word associated with the MsgUnit (0 if not applicable)
} GsmL1_MsgUnitParam_t;
/****************************************************************************
* typedef : GsmL1_MeasParam_t
************************************************************************//**
*
* Used to report library specific measured informations.
*
* @ingroup gsml1_api_prim_params
*
***************************************************************************/
typedef struct GsmL1_MeasParam_t
{
float fRssi; ///< Received Signal Strength Indication (in dBm)
int16_t i16BurstTiming; ///< Burst timing (in quarter of bits)
float fLinkQuality; ///< Link quality of the communication (dB)
float fBer; ///< Bit error rate of the last decoded frame [0..1]
} GsmL1_MeasParam_t;
/****************************************************************************
* typedef : GsmL1_DeviceParam_t
************************************************************************//**
*
* TRX device parameters
*
* @ingroup gsml1_api_prim_params
*
***************************************************************************/
typedef struct GsmL1_DeviceParam_t
{
GsmL1_DevType_t devType; ///< Device type
GsmL1_FreqBand_t freqBand; ///< GSM Frequency band used by the TRX device
uint16_t u16Arfcn; ///< Radio frequency channel number
uint16_t u16BcchArfcn; ///< Associated beacon radio frequency channel number
uint8_t u8NbTsc; ///< Training sequence code to be used for normal bursts
uint8_t u8AutoTA; ///< Automatic timing advance (0:TA is handled by upper layers, 1:TA is handled by layer 1)
float fRxPowerLevel; ///< Nominal RX power level in dBm (use 0 if the control is handled by upper layers)
float fTxPowerLevel; /**< Transmission power level if applicable (in dBm).
@see Verify the values supported by the hardware. */
} GsmL1_DeviceParam_t;
/****************************************************************************
* Types (Primitives) *
****************************************************************************/
/****************************************************************************
* Struct : GsmL1_MphInitReq_t
************************************************************************//**
*
* This structure contains every necessary parameters to initialize a
* Base Tranceiver Station on a specific GSM Radio Frequency band.
*
* Primitive : MPH-INIT-REQ (L3 -> L1)
*
* @ingroup gsml1_api_prim_mph
*
****************************************************************************/
typedef struct GsmL1_MphInitReq_t
{
HANDLE hLayer3; ///< Handle to a layer 3 entity
GsmL1_DeviceParam_t deviceParam; ///< TRX Device parameters
} GsmL1_MphInitReq_t;
/***************************************************************************
* Struct : GsmL1_MphInitCnf
************************************************************************//**
*
* This structure is sent back to the layer 3 in order to confirm the
* reception of a MPH-INIT-REQ primitive.
*
* @ingroup gsml1_api_prim_mph
*
***************************************************************************/
typedef struct GsmL1_MphInitCnf_t
{
HANDLE hLayer3; /**< Handle to the layer 3 entity.
The layer 3 handle received in the
MPH-INIT-REQ primitive is sent back
to the layer 3 (unmodified). */
HANDLE hLayer1; ///< Handle to the initialized Layer1 entity
GsmL1_FreqBand_t freqBand; ///< GSM Frequency band used by the TRX device
GsmL1_Status_t status; ///< Status of the MPH-INIT-REQ primitive
} GsmL1_MphInitCnf_t;
/***************************************************************************
* Struct : GsmL1_MphCloseReq
************************************************************************//**
*
* This structure contains every necessary parameters to close a
* Base Tranceiver Station using a specific GSM Radio Frequency band.
*
* @ingroup gsml1_api_prim_mph
*
***************************************************************************/
typedef struct GsmL1_MphCloseReq_t
{
HANDLE hLayer3; ///< Handle to the layer 3 entity
HANDLE hLayer1; ///< Handle of the Layer1 entity to close
} GsmL1_MphCloseReq_t;
/***************************************************************************
* Struct : GsmL1_MphCloseCnf
************************************************************************//**
*
* This structure is sent back to the layer 3 in order to confirm the
* reception of a MPH-CLOSE-REQ primitive.
*
* @ingroup gsml1_api_prim_mph
*
***************************************************************************/
typedef struct GsmL1_MphCloseCnf_t
{
HANDLE hLayer3; ///< Handle to the layer 3 entity
GsmL1_Status_t status; ///< Status of the MPH-CLOSE-REQ primitive
} GsmL1_MphCloseCnf_t;
/****************************************************************************
* Struct : GsmL1_MphConnectReq_t
************************************************************************//**
*
* This structure contains all the necessary parameters to connect a physical
* channel on an layer 1 entity.
*
* Primitive : MPH-CONNECT-REQ (L3 -> L1)
*
* @ingroup gsml1_api_prim_mph
*
****************************************************************************/
typedef struct GsmL1_MphConnectReq_t
{
HANDLE hLayer3; ///< Handle to a layer 3 entity
HANDLE hLayer1; /**< Handle to the layer1 on which the
physical channel is connected. */
uint8_t u8Tn; ///< Time-slot [0..7]
GsmL1_LogChComb_t logChComb; /**< Logical channel multiplexing
over the physical channel */
} GsmL1_MphConnectReq_t;
/***************************************************************************
* Struct : GsmL1_MphConnectCnf
************************************************************************//**
*
* This structure is sent back to the layer 3 in order to confirm the
* reception of a MPH-CONNECT-REQ primitive.
*
* @ingroup gsml1_api_prim_mph
*
***************************************************************************/
typedef struct GsmL1_MphConnectCnf_t
{
HANDLE hLayer3; /**< The layer 3 handle received from in
MPH-CONNECT-REQ primitive is sent back to
the layer 3 (unmodified). */
HANDLE hLayer1; /**< Handle to the layer1 on which the
physical channel is connected. */
GsmL1_Status_t status; ///< Status of the MPH-INIT-CONNECT-REQ primitive
uint8_t u8Tn; ///< Time-slot [0..7]
} GsmL1_MphConnectCnf_t;
/***************************************************************************
* Struct : GsmL1_MphDisconnectReq_t
************************************************************************//**
*
* This structure contains all the necessary parameters to disconnect a
* physical channel on an layer 1 entity.
*
* @ingroup gsml1_api_prim_mph
*
***************************************************************************/
typedef struct GsmL1_MphDisconnectReq_t
{
HANDLE hLayer3; ///< Handle to a layer 3 entity
HANDLE hLayer1; /**< Handle to the layer1 on which the
physical channel is disconnected. */
uint8_t u8Tn; ///< Time-slot [0..7]
} GsmL1_MphDisconnectReq_t;
/***************************************************************************
* Struct : GsmL1_MphDisconnectCnf
************************************************************************//**
*
* This structure is sent back to the layer 3 in order to confirm the
* reception of a MPH-DISCONNECT-REQ primitive.
*
* @ingroup gsml1_api_prim_mph
*
***************************************************************************/
typedef struct GsmL1_MphDisconnectCnf_t
{
HANDLE hLayer3; /**< The layer 3 handle received from in
MPH-DISCONNECT-REQ primitive is sent
back to the layer 3 (unmodified). */
HANDLE hLayer1; /**< Handle to the layer1 on which the
physical channel is disconnected. */
GsmL1_Status_t status; ///< Status of the MPH-DISCONNECT-REQ primitive
uint8_t u8Tn; ///< Time-slot [0..7]
} GsmL1_MphDisconnectCnf_t;
/****************************************************************************
* Struct : GsmL1_MphActivateReq_t
************************************************************************//**
*
* This structure contains all the necessary parameters to activate a
* logical channel over a connected physical channel.
*
* Primitive : MPH-ACTIVATE-REQ (L3 -> L1)
*
* @ingroup gsml1_api_prim_mph
*
****************************************************************************/
typedef struct GsmL1_MphActivateReq_t
{
HANDLE hLayer3; ///< Layer 3 entity
HANDLE hLayer2; ///< Layer 2 entity
HANDLE hLayer1; /**< Handle of the Layer 1 entity on which the
logical channel is activated */
uint8_t u8Tn; ///< Time-slot [0..7]
GsmL1_SubCh_t subCh; ///< Sub-channel number (1Fh if not applicable)
GsmL1_Sapi_t sapi; ///< Service access point identifier
GsmL1_Dir_t dir; ///< Direction path to configure
float fBFILevel; /**< Bad Frame Indication RX power level in dBm
(use 0 do disable BFI) */
GsmL1_LogChParam_t logChPrm; ///< Additional configuration parameters
} GsmL1_MphActivateReq_t;
/***************************************************************************
* Struct : GsmL1_MphActivateCnf
************************************************************************//**
*
* This structure is sent back to the layer 3 in order to confirm the
* reception of a MPH-ACTIVATE-REQ primitive.
*
* @ingroup gsml1_api_prim_mph
*
***************************************************************************/
typedef struct GsmL1_MphActivateCnf
{
HANDLE hLayer3; /**< The layer 3 handle received from in
MPH-ACTIVATE-REQ primitive is sent
back to the layer 3 (unmodified). */
HANDLE hLayer1; /**< Handle of the Layer 1 entity on which the
logical channel is activated */
GsmL1_Status_t status; ///< Status of the MPH-INIT-ACTIVATE-REQ primitive
uint8_t u8Tn; ///< Time-slot [0..7]
GsmL1_SubCh_t subCh; ///< Sub-channel number (1Fh if not applicable)
GsmL1_Sapi_t sapi; ///< Service access point identifier
GsmL1_Dir_t dir; ///< Uplink/Downlink
} GsmL1_MphActivateCnf_t;
/****************************************************************************
* Struct : GsmL1_MphDeactivateReq_t
************************************************************************//**
*
* This structure contains all the necessary parameters to deactivate a
* logical channel from a connected physical channel.
*
* Primitive : MPH-DEACTIVATE-REQ (L3 -> L1)
*
* @ingroup gsml1_api_prim_mph
*
****************************************************************************/
typedef struct GsmL1_MphDeactivateReq_t
{
HANDLE hLayer3; ///< Layer 3 entity
HANDLE hLayer1; /**< Handle of the Layer 1 entity on which the
logical channel is activated */
uint8_t u8Tn; ///< Time-slot [0..7]
GsmL1_SubCh_t subCh; ///< Sub-channel number (1Fh if not applicable)
GsmL1_Sapi_t sapi; ///< Service access point identifier
GsmL1_Dir_t dir; ///< Uplink/Downlink/Both
} GsmL1_MphDeactivateReq_t;
/***************************************************************************
* Struct : GsmL1_MphDeactivateCnf
************************************************************************//**
*
* This structure is sent back to the layer 3 in order to confirm the
* reception of a MPH-DEACTIVATE-REQ primitive.
*
* @ingroup gsml1_api_prim_mph
*
***************************************************************************/
typedef struct GsmL1_MphDeactivateCnf
{
HANDLE hLayer3; /**< The layer 3 handle received from in
MPH-DEACTIVATE-REQ primitive is sent
back to the layer 3 (unmodified). */
HANDLE hLayer1; /**< Handle of the Layer 1 entity on which the
logical channel is activated */
GsmL1_Status_t status; ///< Status of the MPH-INIT-DEACTIVATE-REQ primitive
uint8_t u8Tn; ///< Time-slot [0..7]
GsmL1_SubCh_t subCh; ///< Sub-channel number (1Fh if not applicable)
GsmL1_Sapi_t sapi; ///< Service access point identifier
GsmL1_Dir_t dir; ///< Uplink/Downlink
} GsmL1_MphDeactivateCnf_t;
/****************************************************************************
* Struct : GsmL1_MphConfigReq_t
************************************************************************//**
*
* This structure contains all the necessary parameters to configure
* physical channel parameters through the SACCH burst.
*
* Primitive : MPH-CONFIG-REQ (L3 -> L1)
*
* @ingroup gsml1_api_prim_mph
*
****************************************************************************/
typedef struct GsmL1_MphConfigReq_t
{
HANDLE hLayer3; ///< Layer 3 instance handle
HANDLE hLayer1; /**< Handle of the Layer 1 entity which has the
physical channel on which the configuration
is done. */
GsmL1_ConfigParamId_t cfgParamId; ///< Configuration parameter ID
GsmL1_ConfigParam_t cfgParams; ///< Configuration parameters
} GsmL1_MphConfigReq_t;
/***************************************************************************
* Struct : GsmL1_MphConfigCnf
************************************************************************//**
*
* This structure is sent back to the layer 3 in order to confirm the
* reception of a MPH-CONFIG-REQ primitive.
*
* @ingroup gsml1_api_prim_mph
*
***************************************************************************/
typedef struct GsmL1_MphConfigCnf_t
{
GsmL1_Status_t status; ///< Status of the MPH-CONFIG-REQ primitive
HANDLE hLayer3; ///< Layer 3 instance handle
HANDLE hLayer1; /**< Handle of the Layer 1 entity which has the
physical channel on which the configuration
is done. */
GsmL1_ConfigParamId_t cfgParamId; ///< Configuration parameter ID
GsmL1_ConfigParam_t cfgParams; ///< Configuration parameters
} GsmL1_MphConfigCnf_t;
/****************************************************************************
* Struct : GsmL1_MphMeasureReq_t
************************************************************************//**
*
* This structure contains all the necessary parameters to measure the
* RSSI on a RF channel.
*
* Primitive : MPH-MEASURE-REQ (L3 -> L1)
*
* @ingroup gsml1_api_prim_mph
*
*
****************************************************************************/
typedef struct GsmL1_MphMeasureReq_t
{
HANDLE hLayer3; ///< Layer 3 instance handle
HANDLE hLayer1; /**< Handle of the Layer 1 entity which has the
physical channel on which the configuration
is done. */
uint32_t u32Duration; ///< Duration of the measurement (in number of frames, 0:now)
} GsmL1_MphMeasureReq_t;
/****************************************************************************
* Struct : GsmL1_MphMeasureCnf_t
************************************************************************//**
*
* This structure is sent back to the layer 3 in order to confirm the
* reception of a MPH-MEASURE-REQ primitive.
*
* Primitive : MPH-MEASURE-CNF (L3 -> L1)
*
* @ingroup gsml1_api_prim_mph
*
*
****************************************************************************/
typedef struct GsmL1_MphMeasureCnf_t
{
HANDLE hLayer3; ///< Layer 3 instance handle
HANDLE hLayer1; /**< Handle of the Layer 1 entity which has the
physical channel on which the configuration
is done. */
GsmL1_Status_t status; ///< Status of the MPH-MEASURE-REQ primitive
float fMeanRssi; ///< RF channel mean received signal strength (dBm)
float fPeakRssi; ///< RF channel maximum received signal strength (dBm)
struct
{
float fMeanRssi; ///< Timeslot N mean received signal strength (dBm)
float fPeakRssi; ///< Timeslot N maximum received signal strength (dBm)
} tn[8];
} GsmL1_MphMeasureCnf_t;
/***************************************************************************
* Struct : GsmL1_MphTimeInd
************************************************************************//**
*
* This structure is sent to the layer 3 at the beginning of every frame.
* It is sent when u8Tn is equal to 0.
*
* @ingroup gsml1_api_prim_mph
*
***************************************************************************/
typedef struct GsmL1_MphTimeInd_t
{
HANDLE hLayer1; /**< Handle of the Layer 1 entity sending the
MphTimeInd primitive */
uint32_t u32Fn; ///< Current frame number [0 .. 2 715 647]
uint8_t u8Tn; ///< Current timeslot [0..7]
} GsmL1_MphTimeInd_t;
/****************************************************************************
* Struct : GsmL1_MphSyncInd_t
************************************************************************//**
*
* This structure is sent back to the layer 3 in order indicate when the
* RF device is synchronized to a surrounding BTS or also when it looses its
* synchronization.
*
* Primitive : MPH-SYNC-IND (L1 -> L3)
*
* @ingroup gsml1_api_prim_mph
*
*
****************************************************************************/
typedef struct GsmL1_MphSyncInd_t
{
HANDLE hLayer1; ///< Handle of the device which is sync/unsynced
uint8_t u8Synced; ///< Indicates if the RF device is synchronized to a BTS.
} GsmL1_MphSyncInd_t;
/******************************************************************************
* Struct : GsmL1_PhDataInd_t
**************************************************************************//**
*
* This structure is sent to the layer 2 to pass message units containing
* frames used by the data link layer or RLC/MAC peer-to-peer communications.
*
* @ingroup gsml1_api_prim_ph
*
*****************************************************************************/
typedef struct GsmL1_PhDataInd_t
{
HANDLE hLayer2; /**< Layer 2 instance handle.
This handle is sent through the
MPH-CONNECT-REQ primitive. */
HANDLE hLayer1; /**< Handle of the Layer 1 entity on which the
logical channel is activated */
GsmL1_Sapi_t sapi; ///< Service access point identifier
GsmL1_Dir_t dir; ///< Uplink/Downlink
GsmL1_MeasParam_t measParam; ///< Measurement parameters infos
GsmL1_MsgUnitParam_t msgUnitParam; ///< Message unit sent from the MS
uint16_t u16Arfcn; ///< Absolute radio frequency number
uint8_t u8Tn; ///< Time-slot [0..7]
GsmL1_SubCh_t subCh; ///< Sub-channel number (1Fh if not applicable)
uint32_t u32Fn; ///< Frame number of the 1st RX burst
uint8_t u8BlockNbr; ///< Block number
} GsmL1_PhDataInd_t;
/******************************************************************************
* Struct : GsmL1_PhConnectInd_t
**************************************************************************//**
*
* This structure is sent to the layer 2 in order to indicate that a
* specific type of logical channel has been connected on a physical channel.
*
* @ingroup gsml1_api_prim_ph
*
*****************************************************************************/
typedef struct GsmL1_PhConnectInd_t
{
HANDLE hLayer2; /**< Layer 2 instance handle.
This handle is sent in the MPH-ACTIVATE-REQ
primitive. */
HANDLE hLayer1; /**< Handle of the Layer 1 entity on which the
logical channel is activated */
uint16_t u16Arfcn; ///< Absolute radio frequency number
uint8_t u8Tn; ///< Time-slot [0..7]
GsmL1_SubCh_t subCh; ///< Sub-channel number (1Fh if not applicable)
GsmL1_Sapi_t sapi; ///< Service access point identifier
GsmL1_Dir_t dir; ///< Indicate the path of the transmission.
} GsmL1_PhConnectInd_t;
/******************************************************************************
* Struct : GsmL1_PhReadyToSendInd_t
**************************************************************************//**
*
* This structure is sent to allow the data link or the RLC/MAC layer
* to synchronize to the next instant of physical transmission.
*
* @ingroup gsml1_api_prim_ph
*
*****************************************************************************/
typedef struct GsmL1_PhReadyToSendInd_t
{
HANDLE hLayer1; /**< Handle of the Layer 1 entity on which the
logical channel is activated */
HANDLE hLayer2; /**< Layer 2 instance handle.
This handle is sent in the MPH-ACTIVATE-REQ
primitive. */
GsmL1_Sapi_t sapi; ///< Service access point identifier
uint32_t u32Fn; ///< Frame number of the 1st TX burst
uint16_t u16Arfcn; ///< Absolute radio frequency number
uint8_t u8Tn; ///< Timeslot number [0..7]
GsmL1_SubCh_t subCh; ///< Sub-channel number (1Fh if not applicable)
uint8_t u8BlockNbr; ///< Block number
} GsmL1_PhReadyToSendInd_t;
/******************************************************************************
* Struct : GsmL1_PhEmptyFrameReq_t
**************************************************************************//**
*
* This structure is sent back to the layer 1 when no frame has to be
* transmitted on the reception of a PH-READY-TO-SEND-IND primitive.
*
* @ingroup gsml1_api_prim_ph
*
*****************************************************************************/
typedef struct GsmL1_PhEmptyFrameReq_t
{
HANDLE hLayer1; /**< Handle of the Layer 1 entity on which the
logical channel is activated */
uint32_t u32Fn; ///< Frame number of the 1st TX burst
uint8_t u8Tn; ///< Timeslot number
GsmL1_SubCh_t subCh; ///<Sub-channel number (1Fh if not applicable)
GsmL1_Sapi_t sapi; ///< Service access point identifier
uint8_t u8BlockNbr; ///< Block number
} GsmL1_PhEmptyFrameReq_t;
/******************************************************************************
* Struct : GsmL1_PhDataReq_t
**************************************************************************//**
*
* This structure is used to send a message unit to the layer 1 in response
* to a PH-READY-To-SEND-IND primitive.
*
* @note
* For FR and HR traffic channel (TCH/FS, TCH/HS), the first byte of the
* message unit represents the payload type of the data (GsmL1_FrPlType_t
* or GsmL1_HrPlType_t). It is follow by the paqcked bits output from the
* vocoder.
*
* For AMR traffic channel (TCH/AFS, TCH/AHS), the first byte of the message
* unit represents the payload type of the data (GsmL1_FrPlType_t or
* GsmL1_HrPlType_t). The second byte is always the codec mode indication
* (CMI) and the third byte is always the codec mode response (CMR). They
* are followed by the IF2 frame.
*
* Refer to 3GPP TS 45.009 for more information about the in-band signaling.
* The format of IF2 frames are defined in 3GPP TS 26.101.
*
* @see GsmL1_FrPlType_t
* @see GsmL1_HrPlType_t
* @see GsmL1_CodecMode_t
*
* @ingroup gsml1_api_prim_ph
*
*****************************************************************************/
typedef struct GsmL1_PhDataReq_t
{
HANDLE hLayer1; /**< Handle of the Layer 1 entity on which the
logical channel is activated */
uint32_t u32Fn; ///< Frame number of the 1st TX burst
GsmL1_Sapi_t sapi; ///< Service access point identifier
GsmL1_MsgUnitParam_t msgUnitParam; ///< Message unit structure
uint8_t u8Tn; ///< Timeslot number
GsmL1_SubCh_t subCh; ///< Sub-channel number (1Fh if not applicable)
uint8_t u8BlockNbr; ///< Block number
} GsmL1_PhDataReq_t;
/***************************************************************************
* Struct : GsmL1_PhRaInd_t
************************************************************************//**
*
* This structure is sent to the layer 3 on the arrival (in the network )
* of a RACH frame.
*
* @ingroup gsml1_api_prim_ph
*
***************************************************************************/
typedef struct GsmL1_PhRaInd_t
{
HANDLE hLayer1; /**< Handle of the Layer 1 entity on which the
logical channel is activated */
HANDLE hLayer2; ///< Layer 2 instance handle.
uint32_t u32Fn; ///< Frame number of the RX burst
uint16_t u16Arfcn; ///< Absolute radio frequency number
uint8_t u8Tn; ///< Timeslot number
uint8_t u8BlockNbr; ///< Block number
GsmL1_Sapi_t sapi; ///< Service access point identifier
GsmL1_MsgUnitParam_t msgUnitParam; ///< Message unit structure
GsmL1_MeasParam_t measParam; ///< Measurement parameters infos
GsmL1_BurstType_t burstType; /**< Indicate which training sequence was used
to send the RACH/PRACH burst */
GsmL1_SubCh_t subCh; ///< Sub-channel number (1Fh if not applicable)
} GsmL1_PhRaInd_t;
/***************************************************************************
* Struct : GsmL1_Prim_t
************************************************************************//**
*
* Layer 1 primitive definition.
*
* @ingroup gsml1_api_prim
*
***************************************************************************/
typedef struct
{
GsmL1_PrimId_t id; ///< Primitive ID
union
{
GsmL1_MphInitReq_t mphInitReq; ///< Initialize the base station.
GsmL1_MphCloseReq_t mphCloseReq; ///< Closes the base station.
GsmL1_MphConnectReq_t mphConnectReq; ///< Connect a physical channel.
GsmL1_MphDisconnectReq_t mphDisconnectReq; ///< Disconnect a physical channel.
GsmL1_MphActivateReq_t mphActivateReq; ///< Activate a logical channel over a physical channel.
GsmL1_MphDeactivateReq_t mphDeactivateReq; ///< Deactivate a logical channel from a physical channel.
GsmL1_MphConfigReq_t mphConfigReq; ///< Configure a physical channel.
GsmL1_MphMeasureReq_t mphMeasureReq; ///< Measure the RSSI and frequency drift
GsmL1_MphInitCnf_t mphInitCnf; ///< Confirm the reception of a MPH-INIT_REQ primitive.
GsmL1_MphCloseCnf_t mphCloseCnf; ///< Confirm the reception of a MPH-CLOSE_REQ primitive.
GsmL1_MphConnectCnf_t mphConnectCnf; ///< Returns an handle pointing to the connected physical channel.
GsmL1_MphDisconnectCnf_t mphDisconnectCnf; ///< Confirm the reception of a MPH-DISCONNECT_REQ primitive.
GsmL1_MphActivateCnf_t mphActivateCnf; ///< Confirm the reception of a MPH-ACTIVATE_REQ primitive.
GsmL1_MphDeactivateCnf_t mphDeactivateCnf; ///< Confirm the reception of a MPH-DEACTIVATE_REQ primitive.
GsmL1_MphConfigCnf_t mphConfigCnf; ///< Confirm the reception of a MPH-CONFIG_REQ primitive.
GsmL1_MphMeasureCnf_t mphMeasureCnf; ///< Return the RSSI and freq. drift
GsmL1_MphTimeInd_t mphTimeInd; ///< Infom upper layer of the actual timeslot and frame number.
GsmL1_MphSyncInd_t mphSyncInd; ///< Synchronization status indication
GsmL1_PhEmptyFrameReq_t phEmptyFrameReq; ///< Layer 2 has nothing to transmit on a PH-READY-TO-SEND.
GsmL1_PhDataReq_t phDataReq; ///< Transfer a message frame unit to the layer 1.
GsmL1_PhConnectInd_t phConnectInd; ///< Inform layer 2 that a logical channel has connected on layer 1.
GsmL1_PhReadyToSendInd_t phReadyToSendInd; ///< Ask layer 3 for something to transmit.
GsmL1_PhDataInd_t phDataInd; ///< Transmit a message frame unit to layer 2.
GsmL1_PhRaInd_t phRaInd; ///< Inform the layer 2 of a random access initiated by the MS.
} u;
} GsmL1_Prim_t;
/****************************************************************************
* Public Functions *
****************************************************************************/
#ifdef _TMS320C6400
/****************************************************************************
* Public routines *
****************************************************************************/
/****************************************************************************
* Function : GsmL1_SendMphReq
************************************************************************//**
*
* This routine is used by the layer 3 to request a service from layer 1.
*
* @param [in] pMphReq
* Structure containing the primitive parameters
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup gsml1_api_prim_mph
*
****************************************************************************/
GsmL1_Status_t GsmL1_SendMphReq( GsmL1_Prim_t *pMphReq );
/****************************************************************************
* Function : GsmL1_SendMphCnf
************************************************************************//**
*
* This routine is used by layer 1 to send the confirmation of a previously
* received request.
*
* @param [out] pMphCnf
* Structure containing the confirmation primitive parameters
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup gsml1_api_prim_mph
*
****************************************************************************/
GsmL1_Status_t GsmL1_SendMphCnf( GsmL1_Prim_t *pMphCnf );
/****************************************************************************
* Function : GsmL1_SendMphInd
************************************************************************//**
*
* This routine is used by layer 1 to indicate something to layer 3.
*
* @param [out] pMphInd
* Structure containing indication primitive parameters
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup gsml1_api_prim_mph
*
****************************************************************************/
GsmL1_Status_t GsmL1_SendMphInd( GsmL1_Prim_t *pMphInd );
/****************************************************************************
* Function : GsmL1_SendPhReq
************************************************************************//**
*
* This routine is used by the layer 2 to request a service from layer 1.
*
* @param [in] pPhReq
* Structure containing request primitive parameters
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup gsml1_api_prim_ph
*
****************************************************************************/
GsmL1_Status_t GsmL1_SendPhReq( GsmL1_Prim_t *pPhReq );
/****************************************************************************
* Function : GsmL1_SendPhCnf
************************************************************************//**
*
* This routine is used by layer 1 to send the confirmation of a previously
* received request from layer 2.
*
* @param [out] pPhCnf
* Structure containing the confirmation primitive parameters
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup gsml1_api_prim_mph
*
****************************************************************************/
GsmL1_Status_t GsmL1_SendPhCnf( GsmL1_Prim_t *pPhCnf );
/****************************************************************************
* Function : GsmL1_SendPhInd
************************************************************************//**
*
* This routine is used by layer 1 to indicate something to layer 2.
*
* @param [out] pPhInd
* Structure containing indication primitive parameters
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup gsml1_api_prim_mph
*
****************************************************************************/
GsmL1_Status_t GsmL1_SendPhInd( GsmL1_Prim_t *pPhInd );
#endif // _TMS320C6400
#ifdef __cplusplus
}
#endif // extern "C"
#endif // GSML1PRIM_H__

87
include/gsml1rf.h Normal file
View File

@ -0,0 +1,87 @@
#ifndef GSML1RF_H__
#define GSML1RF_H__
/****************************************************************************
* Includes *
****************************************************************************/
#include <stdint.h>
#include "gsml1serv.h"
/****************************************************************************
* Defines *
****************************************************************************/
#define GSML1RF_NOCHANGE 2 ///< Do not modify RX or TX device in the FPGA side
#define GSML1RF_ENABLE 1 ///< Enable RX or TX device in the FPGA side
#define GSML1RF_DISABLE 0 ///< Disable RX or TX device in the FPGA side
/****************************************************************************
* Public functions *
****************************************************************************/
/****************************************************************************
* Function : GsmL1Rf_Init
************************************************************************//**
*
* Initialize the PhyRf library.
*
* @return
* GsmL1_Status_Success or an error code otherwise.
*
* @ingroup gsml1_api_phyrf
*
****************************************************************************/
GsmL1_Status_t GsmL1Rf_Init( void );
/****************************************************************************
* Function : GsmL1Rf_Close
************************************************************************//**
*
* Uninitialize the PhyRf library.
*
* @return
* GsmL1_Status_Success or an error code otherwise.
*
* @ingroup gsml1_api_phyrf
*
****************************************************************************/
void GsmL1Rf_Close( void );
/****************************************************************************
* Function : GsmL1Rf_GetProvidedServices
************************************************************************//**
*
* Used to retrieve a structure of every services provided by the PhyRf layer.
*
* @param [out] pPhyRfProvidedServices
* Points to a structure of every services provided by the PhyRf layer
*
* @return
* GsmL1_Status_Success or an error code otherwise.
*
* @ingroup gsml1_api_phyrf
*
****************************************************************************/
GsmL1_Status_t GsmL1Rf_GetProvidedServices( Gsm_PhyRfProvidedServices_t *pPhyRfProvidedServices );
/****************************************************************************
* Function : GsmL1Rf_IsInitialized
************************************************************************//**
*
* Used to determinate if the PhyRf library is initialized
*
* @return
* 1 if initialized, 0 otherwise
*
* @ingroup gsml1_api_phyrf
*
****************************************************************************/
uint8_t GsmL1Rf_IsInitialized( void );
#ifdef __cplusplus
}
#endif // extern "C"
#endif // GSML1PHYRF_H__

135
include/gsml1serv.h Normal file
View File

@ -0,0 +1,135 @@
#ifndef GSML1SERV_H__
#define GSML1SERV_H__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/****************************************************************************
* Includes *
****************************************************************************/
#include "gsml1const.h"
#include "gsml1types.h"
#include "gsml1prim.h"
/****************************************************************************
* Struct : PhyRf_ExternalServices_t
************************************************************************//**
*
* All external services provided from the PhyLink Layer to the PhyRf layer.
*
* @ingroup gsml1_api_phyrf
*
****************************************************************************/
typedef struct PhyRf_ExternalServices_t
{
GsmL1_Status_t (*pfRecvBurst) ( HANDLE hPhyLink, GsmL1_RxBurst_t *pRxBurst );
GsmL1_Status_t (*pfUpdateTn) ( HANDLE hPhyLink, uint32_t u32Fn, uint8_t u8Tn );
} PhyRf_ExternalServices_t;
/****************************************************************************
* typedef : Gsm_L3ProvidedServices_t
************************************************************************//**
*
* Structure which contains a function pointer to every service provided
* by the Gsm Layer 3 library.
*
* @ingroup gsml1_api_services
*
***************************************************************************/
typedef struct Gsm_L3ProvidedServices
{
GsmL1_Status_t (*pfMphCnf)( GsmL1_Prim_t *pPrim );
GsmL1_Status_t (*pfMphInd)( GsmL1_Prim_t *pPrim );
} Gsm_L3ProvidedServices_t;
/****************************************************************************
* typedef : Gsm_L2ProvidedServices_t
************************************************************************//**
*
* Structure which contains a function pointer to every service provided
* by the Gsm Layer 2 library.
*
* @ingroup gsml1_api_services
*
***************************************************************************/
typedef struct Gsm_L2ProvidedServices_t
{
GsmL1_Status_t (*pfPhCnf)( GsmL1_Prim_t *pPrim );
GsmL1_Status_t (*pfPhInd)( GsmL1_Prim_t *pPrim );
} Gsm_L2ProvidedServices_t;
/****************************************************************************
* typedef : Gsm_PhyLinkProvidedServices_t
************************************************************************//**
*
* Structure which contains a function pointer to every service provided
* by the physical link layer library.
*
* @ingroup gsml1_api_services
*
***************************************************************************/
typedef struct Gsm_PhyLinkProvidedServices_t
{
// Services provided to the layer 3
GsmL1_Status_t (*pfMphReq)( GsmL1_Prim_t *pPrim );
// Services provided to the Layer 2
GsmL1_Status_t (*pfPhReq)( GsmL1_Prim_t *pPrim );
// Services provided to the physical radio frequency layer
GsmL1_Status_t (*pfRecvBurst) ( HANDLE hDevice, GsmL1_RxBurst_t *pRxBurst );
GsmL1_Status_t (*pfUpdateTn) ( HANDLE hDevice, uint32_t u32Fn, uint8_t u8Tn );
} Gsm_PhyLinkProvidedServices_t;
/****************************************************************************
* typedef : Gsm_PhyRfProvidedServices_t
************************************************************************//**
*
* Structure which contains a function pointer to every service provided
* by the PhyRf library.
*
* @ingroup gsml1_api_services
*
***************************************************************************/
typedef struct Gsm_PhyRfProvidedServices_t
{
// Services provided from the physical radio frequency layer
GsmL1_Status_t (*pfInitDevice) ( PhyRf_ExternalServices_t *pPhyRfExternalServices,
GsmL1_DevType_t devType,
GsmL1_FreqBand_t freqBand,
uint16_t u16Arfcn,
float fTxPowerLevel,
uint8_t u8NbTsc,
HANDLE hPhyLink,
HANDLE *hPhyRf );
void (*pfCloseDevice ) ( HANDLE hPhyRfDevice );
GsmL1_Status_t (*pfSendBurst ) ( HANDLE hPhyRfDevice, GsmL1_TxBurst_t *pTxBurst );
GsmL1_Status_t (*pfConfigTs ) ( HANDLE hPhyRfDevice,
uint8_t u8Tn,
uint8_t u8EnableRx,
uint8_t u8EnableTxAutoDummy );
GsmL1_Status_t (*pfSetTxPowerLevel) ( HANDLE hPhyRfDevice,
float fTxPowerLevel );
GsmL1_Status_t (*pfSetNbTsc) ( HANDLE hPhyRfDevice,
uint8_t u8NbTsc );
// Services provided by the physical RF layer to the FPGA layer
void (*pfNewTnIsr) ( void );
} Gsm_PhyRfProvidedServices_t;
#ifdef __cplusplus
}
#endif // extern "C"
#endif // GSMSERVICES_H__

255
include/gsml1types.h Normal file
View File

@ -0,0 +1,255 @@
#ifndef GSML1TYPES_H__
#define GSML1TYPES_H__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/****************************************************************************
* Includes *
****************************************************************************/
#ifndef WIN32
#include <stdint.h>
#endif
#include "gsml1const.h"
/****************************************************************************
* Types *
****************************************************************************/
/****************************************************************************
* typedef : HANDLE
************************************************************************//**
*
* Generic type used to identify an entity.
*
* @ingroup gsml1_api_types
*
***************************************************************************/
typedef uint32_t HANDLE;
/****************************************************************************
* typedef : GsmL1_RxBurst
************************************************************************//**
*
* Individual physical channel message received from the demodulator.
*
* @ingroup gsml1_api_types
*
***************************************************************************/
#ifdef QUAD_BAND__ // Quad-Band
typedef struct GsmL1_RxBurst_t
{
uint32_t u32Sync; ///< Synchronization word (Word 1)
uint32_t u22Fn : 24; ///< Frame number (Word 2 [0-23])
uint32_t u8Tn : 8; ///< Time slot number (Word 2 [24-32])
uint32_t u8DeviceId : 8; ///< Device Id ( Word 3 [0-7] )
uint32_t u8AgcScaleFactor : 8; ///< Agc Gain applied to the burst sample is 2^(AGC_SCALE_FACTOR) ( Word 3 [8 - 15] )
uint32_t u16RfAtten :16; ///< RF attenuator ( Word 3 [16 - 31] )
uint32_t u8BurstType : 8; ///< Burst type ( Word 4 [0-7] )
uint32_t u8RfSync : 8; ///< RF synchronization flag ( Word 4 [8 - 15] )
int32_t i16Offset : 16; ///< Burst offset ( Word 4 [16-31] )
float fRssi; ///< Received signal strength indicator in femtowatt( Word 5 )
union
{
float fLQ; ///< Link quality ( Word 6 [0 - 31] )
float fTsRssi; ///< Received training sequence signal strength indicator in femtowatt( Word 6 )
} u;
uint32_t u16XCorr : 16; ///< Correlation result ( Word 7 [0 - 15] )
uint32_t u16Arfcn : 16; ///< Arfcn (Set by the PhyRf layer ( Word 8 [0 - 15] )
GsmL1_Dir_t dir; ///< Direction ( Word 8 [0 - 31] )
//uint32_t u16Arfcn : 16; ///< Arfcn (Set by the PhyRf layer ( Word 8 [0 - 15] )
//uint32_t : 16; ///< Reserved bits ( Word 8, [16 - 31] )
int8_t pi8Burst[148]; ///< Burst data (148 bytes)
} GsmL1_RxBurst_t;
#else // DCS-1800
typedef struct GsmL1_RxBurst_t
{
uint32_t u32Sync; ///< Synchronization word (Word 1)
uint32_t u22Fn : 24; ///< Frame number (Word 2 [0-23])
uint32_t u8Tn : 8; ///< Time slot number (Word 2 [24-32])
uint32_t u16DeviceId :16; ///< Device Id ( Word 3 [0-15] )
uint32_t u8AgcScaleFactor : 8; ///< Agc Gain applied to the burst sample is 2^(AGC_SCALE_FACTOR) ( Word 3 [16 - 23] )
uint32_t u8RfAtten : 8; ///< RF attenuator ( Word 3 [24 - 31] )
uint32_t u8BurstType : 8; ///< Burst type ( Word 4 [0-7] )
uint32_t u8RfSync : 8; ///< RF synchronization flag ( Word 4 [8 - 15] )
int32_t i16Offset : 16; ///< Burst offset ( Word 4 [16-31] )
float fRssi; ///< Received signal strength indicator in femtowatt( Word 5 )
union
{
float fLQ; ///< Link quality ( Word 6 [0 - 31] )
float fTsRssi; ///< Received training sequence signal strength indicator in femtowatt( Word 6 )
} u;
uint32_t u16XCorr : 16; ///< Correlation result ( Word 7 [0 - 15] )
uint32_t u16Arfcn : 16; ///< Arfcn (Set by the PhyRf layer ( Word 8 [0 - 15] )
GsmL1_Dir_t dir; ///< Direction ( Word 8 [0 - 31] )
//uint32_t u16Arfcn : 16; ///< Arfcn (Set by the PhyRf layer ( Word 8 [0 - 15] )
//uint32_t : 16; ///< Reserved bits ( Word 8, [16 - 31] )
int8_t pi8Burst[148]; ///< Burst data (148 bytes)
} GsmL1_RxBurst_t;
#endif
/****************************************************************************
* typedef : GsmL1_TxBurst
************************************************************************//**
*
* Individual physical channel message transmitted to the demodulator.
*
* @ingroup gsml1_api_types
*
* @note The [LB] tag means that this field is set in Dsp/Fpga loopback only
***************************************************************************/
typedef struct GsmL1_TxBurst_t
{
uint32_t u32Sync; ///< Synchronization word (Word 1 [0 - 31] )
uint32_t u22Fn : 24; ///< Frame number (Word 2 [0-23])
uint32_t u8Tn : 8; ///< Time slot number (Word 2 [24-32])
uint32_t u16DeviceId : 16; ///< Fpga device Id (Word 3 [0 - 15] )
uint32_t : 16; ///< Reserved bits ( Word 3 [16 - 31] )
uint32_t u8BurstType : 8; ///< Burst type ( Word 4 [0-7] )
uint32_t : 24; ///< Reserved bits ( Word 4 [8-31] )
uint32_t u32SubCh : 32; ///< Reserved bits ( Word 5 )
uint32_t : 32; ///< Reserved bits ( Word 6 )
uint32_t u16Arfcn : 16; ///< [LB] Absolute radio frequency channel number ( Word 8 [ 16-31 ] )
uint32_t : 16; ///< Reserved word ( Word 8 [ 0-15 ] )
GsmL1_Dir_t dir; ///< Direction ( Word 8 [0 - 31] )
int8_t pi8Burst[148]; ///< Burst data (148 bytes)
} GsmL1_TxBurst_t;
/****************************************************************************
* typedef : GsmL1_LogChParam_t
************************************************************************//**
*
* Logical channel configuration parameters
*
* @ingroup gsml1_api_prim_params
*
***************************************************************************/
typedef union
{
// RACH
struct
{
uint8_t u8Bsic; ///< Base Station Identity Code
} rach;
// AGCH
struct
{
uint8_t u8NbrOfAgch; /**< Number of AGCH blocks on a CCCH
@see BS_AG_BLKS_RES parameter in 3GPP TS 45_02 Section 7 Table 5 */
} agch;
// SACCH
struct
{
uint8_t u8MsPowerLevel; /**< Power level control
@see TS 3GPP 45.005 - 4.1.1 Mobile station output power */
} sacch;
// TCH
struct
{
GsmL1_TchPlFmt_t tchPlFmt; ///< Payload format (RFC RTP, Etsi IF2)
GsmL1_TchPlType_t tchPlType; ///< Expected payload type (HR, FR, EFR or AMR)
GsmL1_AmrCmiPhase_t amrCmiPhase; ///< AMR Codec Mode Indication phase (downlink)
GsmL1_AmrCodecMode_t amrInitCodecMode; ///< AMR Initial Codec Mode
GsmL1_AmrCodec_t amrActiveCodecSet[4]; ///< AMR Active Codec Set
} tch;
// PRACH
struct
{
uint8_t u8Bsic; ///< Base Station Identity Code
} prach;
// PTCCH
struct
{
uint8_t u8Bsic; ///< Base Station Identity Code
} ptcch;
} GsmL1_LogChParam_t;
/****************************************************************************
* typedef : GsmL1_ConfigParam_t
************************************************************************//**
*
* Layer 1 configuration parameters
*
* @ingroup gsml1_api_prim_params
*
***************************************************************************/
typedef union
{
// Set the normal burst TSC of the specified RF device
struct
{
uint8_t u8NbTsc; ///< Normal burst training sequence code of the specified RF device
} setNbTsc;
// Set the TX power level of the specified RF device
struct
{
float fTxPowerLevel; ///< Transmitter power of the specified RF device
} setTxPowerLevel;
// Set the logical channel specific parameters
struct
{
GsmL1_Sapi_t sapi; ///< Service access point identifier
uint8_t u8Tn; ///< Time-slot [0..7]
GsmL1_SubCh_t subCh; ///< Sub-channel number (0x1F if not applicable)
GsmL1_Dir_t dir; ///< Direction path to configure
GsmL1_LogChParam_t logChParams; ///< Logical channel parameters
} setLogChParams;
///< Configure the ciphering parameters
struct
{
uint8_t u8Tn; ///< Time-slot [0..7]
GsmL1_SubCh_t subCh; ///< Sub-channel number (0x1F if not applicable)
GsmL1_Dir_t dir; ///< Direction path to configure
GsmL1_CipherId_t cipherId; ///< Ciphering algorithm
uint8_t u8Kc[8]; ///< 64-bit ciphering key
} setCipheringParams;
} GsmL1_ConfigParam_t;
#ifdef __cplusplus
}
#endif // extern "C"
#endif // GSML1TYPES_H__

379
include/superfemto.h Normal file
View File

@ -0,0 +1,379 @@
#ifndef SUPERFEMTO_H__
#define SUPERFEMTO_H__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/****************************************************************************
* Includes *
****************************************************************************/
#include <stdint.h>
#include "gsml1const.h"
#define SUPERFEMTO_API(x,y,z) ((x << 16) | (y << 8) | z)
#define SUPERFEMTO_API_VERSION SUPERFEMTO_API(0,1,0)
/****************************************************************************
* Const *
****************************************************************************/
/****************************************************************************
* Enum: SuperFemto_Status_t
************************************************************************//**
*
* Status used by the SuperFemto.
*
* @ingroup superfemto_api
*
****************************************************************************/
typedef GsmL1_Status_t SuperFemto_Status_t;
/****************************************************************************
* Enum : SuperFemto_PrimId_t
************************************************************************//**
*
* System management primitives.
*
* @ingroup superfemto_api
*
****************************************************************************/
typedef enum SuperFemto_PrimId_t
{
SuperFemto_PrimId_SystemInfoReq, ///< Request system information
SuperFemto_PrimId_SystemInfoCnf, ///< Confirm system information
SuperFemto_PrimId_SystemFailureInd, ///< System failure indication
SuperFemto_PrimId_ActivateRfReq, ///< Request activation of the RF section
SuperFemto_PrimId_ActivateRfCnf, ///< Confirm activation of the RF section
SuperFemto_PrimId_DeactivateRfReq, ///< Request deactivation of the RF section
SuperFemto_PrimId_DeactivateRfCnf, ///< Confirm deactivation of the RF section
SuperFemto_PrimId_SetTraceFlagsReq, ///< Set the verbosity of the system
SuperFemto_PrimId_RfClockInfoReq, ///< Request information about the RF clock sub-system
SuperFemto_PrimId_RfClockInfoCnf, ///< Returns the RF clock sub-system information
SuperFemto_PrimId_RfClockSetupReq, ///< Configure the RF clock sub-system
SuperFemto_PrimId_RfClockSetupCnf, ///< Confirm the configuration of the RF clock sub-system
SuperFemto_PrimId_Layer1ResetReq, ///< Trigger a reset of the GSM layer 1 library
SuperFemto_PrimId_Layer1ResetCnf, ///< Confirm that the GSM layer 1 library was reset
SuperFemto_PrimId_NUM
} SuperFemto_PrimId_t;
/****************************************************************************
* Types *
****************************************************************************/
/****************************************************************************
* Struct : SuperFemto_SystemInfoCnf_t
************************************************************************//**
*
* Structure is used to confirm the information about the system.
*
* @ingroup superfemto_api_prim_sys
*
****************************************************************************/
typedef struct SuperFemto_SystemInfoCnf
{
SuperFemto_Status_t status; ///< Status
struct
{
uint8_t major; ///< DSP firmware major version number
uint8_t minor; ///< DSP firmware minor version number
uint8_t build; ///< DSP firmware build version number
} dspVersion;
struct
{
uint8_t major; ///< FPGA firmware major version number
uint8_t minor; ///< FPGA firmware minor version number
uint8_t build; ///< FPGA firmware build version number
} fpgaVersion;
} SuperFemto_SystemInfoCnf_t;
/****************************************************************************
* Struct : SuperFemto_SystemFailureInd_t
************************************************************************//**
*
* Structure is used to indicate a system failure.
*
* @ingroup superfemto_api_prim_sys
*
****************************************************************************/
typedef struct SuperFemto_SystemFailureInd
{
SuperFemto_Status_t status; ///< Status
} SuperFemto_SysemFailureInd_t;
/****************************************************************************
* Struct : SuperFemto_ActivateRfReq_t
************************************************************************//**
*
* This primitive is used to request the activation the RF section of the system.
*
* @ingroup superfemto_api
*
***************************************************************************/
typedef struct SuperFemto_ActivateRfReq
{
// Message queue options
struct {
uint8_t u8UseTchMsgq; ///< Set to '1' to use a separate MSGQUEUE for TCH primitives
uint8_t u8UsePdtchMsgq; ///< Set to '1' to use a separate MSGQUEUE for PDTCH primitives
} msgq;
// TRX RF clock options
struct
{
int iClkCor; ///< Clock correction value in PPB.
uint8_t u8ClkSrc; ///< Clock source (0:None, 1:OCXO, 2:TCXO, 3:External, 4:GPS PPS, 5:reserved, 6:RX)
} rfTrx;
// RX RF clock options
struct
{
int iClkCor; ///< Clock calibration value in PPB.
uint8_t u8ClkSrc; ///< Clock source (0:None, 1:OCXO, 2:TCXO, 3:External, 4:GPS PPS, 5:TRX, 6:reserved)
} rfRx;
} SuperFemto_ActivateRfReq_t;
/****************************************************************************
* Struct : SuperFemto_ActivateRfCnf_t
************************************************************************//**
*
* This primitive is used to confirm the activation the RF section of the system.
*
* @ingroup superfemto_api
*
***************************************************************************/
typedef struct SuperFemto_ActivateRfCnf
{
SuperFemto_Status_t status; ///< Status
} SuperFemto_ActivateRfCnf_t;
/****************************************************************************
* Struct : SuperFemto_DeactivateRfCnf_t
************************************************************************//**
*
* This primitive is used to confirm the deactivation the RF section of the system.
*
* @ingroup superfemto_api
*
***************************************************************************/
typedef struct SuperFemto_DeactivateRfCnf
{
SuperFemto_Status_t status; ///< Status
} SuperFemto_DeactivateRfCnf_t;
/****************************************************************************
* Struct : SuperFemto_SetTraceFlagsReq_t
************************************************************************//**
*
* This primitive is used to setup the trace flag values.
*
* @ingroup superfemto_api_prim_dbg
*
***************************************************************************/
typedef struct SuperFemto_SetTraceFlagsReq
{
uint32_t u32Tf; ///< Trace flag level
} SuperFemto_SetTraceFlagsReq_t;
/****************************************************************************
* Struct : SuperFemto_RfClockInfoReq
************************************************************************//**
*
* This primitive is used to retrive information about the RF clock
*
* @ingroup superfemto_api_prim_dbg
*
***************************************************************************/
typedef struct SuperFemto_RfClockInfoReq
{
uint8_t u8RstClkCal; ///< Set to '1' to reset the calibration module
} SuperFemto_RfClockInfoReq_t;
/****************************************************************************
* Struct : SuperFemto_RfClockSetupReq
************************************************************************//**
*
* This primitive is used to configure the RF clock sub-system.
*
* @ingroup superfemto_api_prim_dbg
*
***************************************************************************/
typedef struct SuperFemto_RfClockSetupReq
{
// TRX RF clock options
struct
{
int iClkCor; ///< Clock correction value in PPB.
uint8_t u8ClkSrc; ///< Clock source (0:None, 1:OCXO, 2:TCXO, 3:External, 4:GPS PPS, 5:reserved, 6:RX)
} rfTrx;
// RX RF clock options
struct
{
int iClkCor; ///< Clock calibration value in PPB.
uint8_t u8ClkSrc; ///< Clock source (0:None, 1:OCXO, 2:TCXO, 3:External, 4:GPS PPS, 5:TRX, 6:reserved)
} rfRx;
// RF clock calibration
struct {
uint8_t u8ClkSrc; ///< Reference clock source (0:Off, 1:OCXO, 2:TCXO, 3:External, 4:GPS PPS, 5:reserved, 6:reserved, 7:NL)
} rfTrxClkCal;
} SuperFemto_RfClockSetupReq_t;
/****************************************************************************
* Struct : SuperFemto_RfClockSetupCnf
************************************************************************//**
*
* This primitive is sent back to confirm the configuration of the RF clock sub-system.
*
* @ingroup superfemto_api_prim_dbg
*
***************************************************************************/
typedef struct SuperFemto_RfClockSetupCnf
{
SuperFemto_Status_t status; ///< Status of the RF-CLOCK-SETUP-REQ
} SuperFemto_RfClockSetupCnf_t;
/****************************************************************************
* Struct : SuperFemto_RfClockInfoCnf
************************************************************************//**
*
* This primitive is used to send back information on the RF clock sub-system.
*
* @ingroup superfemto_api_prim_dbg
*
***************************************************************************/
typedef struct SuperFemto_RfClockInfoCnf
{
// TRX RF clock options
struct
{
int iClkCor; ///< Clock correction value in PPB.
uint8_t u8ClkSrc; ///< Clock source (0:None, 1:OCXO, 2:TCXO, 3:External, 4:GPS PPS, 5:reserved, 6:RX)
} rfTrx;
// RX RF clock options
struct
{
int iClkCor; ///< Clock calibration value in PPB.
uint8_t u8ClkSrc; ///< Clock source (0:None, 1:OCXO, 2:TCXO, 3:External, 4:GPS PPS, 5:TRX, 6:reserved)
} rfRx;
// RF clock calibration
struct {
uint8_t u8ClkSrc; ///< Reference clock source (0:Off, 1:OCXO, 2:TCXO, 3:External, 4:GPS PPS, 5:reserved, 6:reserved, 7:NL)
int iClkErr; ///< RF clock error (PPB).
int iClkErrRes; ///< Clock error resolution (PPT).
} rfTrxClkCal;
} SuperFemto_RfClockInfoCnf_t;
/****************************************************************************
* Struct : SuperFemto_Layer1ResetReq_t
************************************************************************//**
*
* Structure is used to request a reset of the layer 1 module.
*
* @ingroup superfemto_api_prim_sys
*
****************************************************************************/
typedef struct SuperFemto_Layer1ResetReq
{
uint32_t u32Reserved;
} SuperFemto_Layer1ResetReq_t;
/****************************************************************************
* Struct : SuperFemto_Layer1ResetCnf_t
************************************************************************//**
*
* Structure is used to confirm the reset of the layer 1 module.
*
* @ingroup superfemto_api_prim_sys
*
****************************************************************************/
typedef struct SuperFemto_Layer1ResetCnf
{
GsmL1_Status_t status;
} SuperFemto_Layer1ResetCnf_t;
/****************************************************************************
* Struct : SuperFemto_Primt_t
************************************************************************//**
*
* System level primitive definition.
*
* @ingroup superfemto_api_prim_sys
*
****************************************************************************/
typedef struct SuperFemto_Prim
{
SuperFemto_PrimId_t id; ///< Primitive ID
union
{
SuperFemto_SystemInfoCnf_t systemInfoCnf; ///< Confirm system information
SuperFemto_SysemFailureInd_t sysemFailureInd; ///< System failure indication
SuperFemto_ActivateRfReq_t activateRfReq; ///< Request activation of the RF section
SuperFemto_ActivateRfCnf_t activateRfCnf; ///< Confirm activation of the RF section
SuperFemto_DeactivateRfCnf_t deactivateRfCnf; ///< Confirm deactivation of the RF section
SuperFemto_SetTraceFlagsReq_t setTraceFlagsReq; ///< Set the verbosity of the system
SuperFemto_RfClockInfoReq_t rfClockInfoReq; ///< Request information about the RF clock
SuperFemto_RfClockInfoCnf_t rfClockInfoCnf; ///< Returns information about the RF clock
SuperFemto_RfClockSetupReq_t rfClockSetupReq; ///< Setup the RF clock
SuperFemto_RfClockSetupCnf_t rfClockSetupCnf; ///< Confirm the setup of the RF clock
SuperFemto_Layer1ResetReq_t layer1ResetReq; ///< Request a reset of the layer 1 module
SuperFemto_Layer1ResetCnf_t layer1ResetCnf; ///< Conrifm that the layer 1 module was reset
} u;
} SuperFemto_Prim_t;
#ifdef _TMS320C6400
/****************************************************************************
* Public Functions *
****************************************************************************/
/****************************************************************************
* Function : SuperFemto_RxPrimCallback
************************************************************************//**
*
* SuperFemto primitive reception callback routine. Process primitives sent
* by the ARM processor.
*
* @param [in] pPrim
* Address of the buffer containing the received primitive.
*
* @return
* GsmL1_Status_Success or the error code
*
* @ingroup superfemto_api_prim_sys
*
****************************************************************************/
void SuperFemto_RxPrimCallback( SuperFemto_Prim_t *pPrim );
#endif // _TMS320C6400
#ifdef __cplusplus
}
#endif // extern "C"
#endif // SUPERFEMTO_H__