Ejemplo n.º 1
0
FMC_UINT FMC_UTILS_ChannelSpacingInKhz(FmcChannelSpacing channelSpacing)
{
    FMC_UINT    channelSpacingInKhz;
    
    FMC_FUNC_START("FMC_UTILS_ChannelSpacingInKhz");
    
    switch (channelSpacing)
    {
        case FMC_CHANNEL_SPACING_50_KHZ:
            
            channelSpacingInKhz = 50;

        break;
        
        case FMC_CHANNEL_SPACING_100_KHZ:
            
            channelSpacingInKhz = 100;

        break;
        
        case FMC_CHANNEL_SPACING_200_KHZ:

            channelSpacingInKhz = 200;

        break;
        
        default:
            FMC_FATAL_SET_RETVAR((channelSpacingInKhz = 50), 
                                    ("FMC_UTILS_ChannelSpacingInKhz: Invalid Channel Spacing (%d)", channelSpacing));
    }

    FMC_FUNC_END();

    return channelSpacingInKhz;
}
Ejemplo n.º 2
0
FmTxStatus FM_TX_Init(void)
{
	/*FmcStatus	fmcStatus = FM_TX_STATUS_SUCCESS;*/
	FmTxStatus	status = FM_TX_STATUS_SUCCESS;
	FmcStatus  fmcStatus;
	FMC_FUNC_START(("FM_TX_Init"));

	FMC_VERIFY_ERR((_fmTxInitState == _FM_TX_INIT_STATE_NOT_INITIALIZED), FM_TX_STATUS_NOT_DE_INITIALIZED,
						("FM_TX_Init: Invalid call while FM TX Is not De-Initialized"));

	/* Assume failure. If we fail before reaching the end, we will stay in this state */
	_fmTxInitState = _FM_TX_INIT_STATE_INIT_FAILED;

	/* Init RX & TX common module */
	fmcStatus = FMCI_Init();
	FMC_VERIFY_FATAL((status == FMC_STATUS_SUCCESS), fmcStatus, 
						("FM_TX_Init: FMCI_Init Failed (%s)", FMC_DEBUG_FmcStatusStr(fmcStatus)));

	/* Init FM TX state machine */
	FM_TX_SM_Init();
	
	
	_fmTxInitState = _FM_TX_INIT_STATE_INITIALIZED;

	FMC_LOG_INFO(("FM_TX_Init: FM TX Initialization completed Successfully"));
	
	FMC_FUNC_END();
	
	return status;
}
Ejemplo n.º 3
0
FmTxStatus _FM_TX_SetRdsTextRtMsgVerifyParms(	FmcRdsRtMsgType		msgType, 
															const FMC_U8 		*msg,
															FMC_UINT 			len)
{
	FmTxStatus status;

	FMC_FUNC_START("_FM_TX_SetRdsTextRtMsgVerifyParms");

	FMC_VERIFY_ERR(((msgType == FMC_RDS_RT_MSG_TYPE_AUTO)||(msgType == FMC_RDS_RT_MSG_TYPE_A) || (msgType == FMC_RDS_RT_MSG_TYPE_B)),
						FM_TX_STATUS_INVALID_PARM, ("_FM_TX_SetRdsTextRtMsgVerifyParms: Invalid Type (%d)", msgType));

	FMC_VERIFY_ERR((msg != NULL), FM_TX_STATUS_INVALID_PARM, ("_FM_TX_SetRdsTextRtMsgVerifyParms: Null msg"));
	
	if (msgType == FMC_RDS_RT_MSG_TYPE_A)
	{
		FMC_VERIFY_ERR((len <= FM_RDS_RT_A_MAX_MSG_LEN), FM_TX_STATUS_INVALID_PARM,
							("_FM_TX_SetRdsTextRtMsgVerifyParms: Msg too long (%d) for RT Type A (Max: %d)",
							len, FM_RDS_RT_A_MAX_MSG_LEN));
	}
	else/*B or Auto*/
	{
		/* In Auto mode the BB will decide ,depending on the length, wich group type to send*/
		FMC_VERIFY_ERR((len <= FM_RDS_RT_B_MAX_MSG_LEN), FM_TX_STATUS_INVALID_PARM,
							("_FM_TX_SetRdsTextRtMsgVerifyParms: Msg too long (%d) for RT Type B (Max: %d)",
							len, FM_RDS_RT_B_MAX_MSG_LEN));
	}

	status = FM_TX_STATUS_SUCCESS;
	
	FMC_FUNC_END();

	return status;
}
Ejemplo n.º 4
0
FmTxStatus FM_TX_Deinit(void)
{
	FmTxStatus	status = FM_TX_STATUS_SUCCESS;

	FMC_FUNC_START(("FM_TX_Deinit"));

	if (_fmTxInitState !=_FM_TX_INIT_STATE_INITIALIZED)
	{
		FMC_LOG_INFO(("FM_TX_Deinit: Module wasn't properly initialized. Exiting without de-initializing"));
		FMC_RET(FM_TX_STATUS_SUCCESS);
	}

	FMC_VERIFY_FATAL((FM_TX_SM_GetContextState() ==  FM_TX_SM_CONTEXT_STATE_DESTROYED), 
						FM_TX_STATUS_CONTEXT_NOT_DESTROYED, ("FM_TX_Deinit: FM TX Context must first be destoryed"));

	/* De-Init FM TX state machine */
	FM_TX_SM_Deinit();

	/* De-Init RX & TX common module */
	FMCI_Deinit();
	
	_fmTxInitState = _FM_TX_INIT_STATE_NOT_INITIALIZED;
	
	FMC_FUNC_END();
	
	return status;
}
Ejemplo n.º 5
0
FmcListNodeIndex FMC_GetNodeIndex(const FMC_ListNode* head, const FMC_ListNode* node)
{
    FmcListNodeIndex        index;      /* Holds the result */
    FMC_BOOL            nodeOnList; /* Indicates if node was found or not */
    FMC_ListNode*       tmpNode;

    FMC_FUNC_START("FMC_GetNodeIndex");
    
    FMC_VERIFY_FATAL_SET_RETVAR((FMC_IsListCircular(head) == FMC_TRUE), (index = FMC_LIST_NODE_INVALID_INDEX), 
                                    ("FMC_GetNodeIndex: List is not circular"));

    pthread_mutex_lock(&list_mutex);

    /* Start the search from the first node */
    tmpNode = FMC_GetHeadList((FMC_ListNode*)head);
    nodeOnList = FMC_FALSE;

    index = 0;

    /* Traverse list until we find the node or exhaust the list */
    while (tmpNode != head)
    {       
        if (tmpNode == node)
        {
            /* node found  */
            nodeOnList = FMC_TRUE;
            break;
        }

        /* Move to next node */
        ++index;
        tmpNode = tmpNode->NextNode;
    }

    /* Handle the node-not-found case */
    if (nodeOnList == FMC_FALSE)
    {
        index = FMC_LIST_NODE_INVALID_INDEX;
    }
    
    pthread_mutex_unlock(&list_mutex);
    FMC_FUNC_END();

    return index;
}
Ejemplo n.º 6
0
void FMC_RemoveNodeList(FMC_ListNode* Node)
{
    FMC_FUNC_START("FMC_RemoveNodeList");
    
    FMC_VERIFY_FATAL_NO_RETVAR((FMC_IsListCircular(Node) == FMC_TRUE), ("FMC_IsNodeOnList: List is not circular"));
    
    pthread_mutex_lock(&list_mutex);

    Node->PrevNode->NextNode = Node->NextNode;
    Node->NextNode->PrevNode = Node->PrevNode;
    
    pthread_mutex_unlock(&list_mutex);

    FMC_VERIFY_FATAL_NO_RETVAR((FMC_IsListCircular(Node->PrevNode) == FMC_TRUE), ("FMC_RemoveNodeList: List is not circular"));

    FMC_InitializeListNode(Node);

    FMC_FUNC_END();
}
Ejemplo n.º 7
0
FMC_ListNode*FMC_RemoveHeadList(FMC_ListNode* head)
{
    FMC_ListNode* first = NULL;

    FMC_FUNC_START("FMC_RemoveHeadList");
    
    pthread_mutex_lock(&list_mutex);

    first = head->NextNode;
    first->NextNode->PrevNode = head;
    head->NextNode = first->NextNode;

    pthread_mutex_unlock(&list_mutex);

    FMC_VERIFY_FATAL_SET_RETVAR((FMC_IsListCircular(head) == FMC_TRUE), (first = NULL), ("_FMC_RemoveHeadList: List is not circular"));

    FMC_FUNC_END();
    
    return first;
}
Ejemplo n.º 8
0
/*
	A PS Message is valid if Its length is between 1 - FM_RDS_PS_MAX_MSG_LEN
*/
FmTxStatus _FM_TX_SetRdsTextPsMsgVerifyParms(	const FMC_U8 		*msg,
															FMC_UINT 			len)
{
	FmTxStatus status;

	FMC_FUNC_START("_FM_TX_SetRdsTextPsMsgVerifyParms");

	FMC_VERIFY_ERR((msg != NULL), FM_TX_STATUS_INVALID_PARM,
						("FM_TX_SetRdsTextPsMsg: Null msg pointer"));
	FMC_VERIFY_ERR((len > 0), FM_TX_STATUS_INVALID_PARM,
						("FM_TX_SetRdsTextPsMsg: Empty Msg"));
	FMC_VERIFY_ERR((len <= FM_RDS_PS_MAX_MSG_LEN), FM_TX_STATUS_INVALID_PARM,
						("FM_TX_SetRdsTextPsMsg: Msg too long (%d), Max: %d", len, FM_RDS_PS_MAX_MSG_LEN));
	
	status = FM_TX_STATUS_SUCCESS;
	
	FMC_FUNC_END();

	return status;
}
Ejemplo n.º 9
0
/*
	A fields mask is valid if:
	1. At least one field is transmitted
*/
FmTxStatus _FM_TX_SetRdsTransmittedFieldsMaskVerifyParms(FmTxRdsTransmittedGroupsMask fieldsMask)
{
	FmTxStatus status;

	FMC_FUNC_START("_FM_TX_SetRdsTransmittedFieldsMaskVerifyParms");
	
	/* Verify that either PS or RT are transmitted */

	FMC_VERIFY_ERR(((fieldsMask & FM_TX_RDS_RADIO_TRANSMITTED_GROUP_PS_MASK ) || 
							(fieldsMask & FM_TX_RDS_RADIO_TRANSMITTED_GROUP_RT_MASK )||
							(fieldsMask & FM_TX_RDS_RADIO_TRANSMITTED_GROUP_ECC_MASK )),
						FM_TX_STATUS_INVALID_PARM,
						("_FM_TX_SetRdsTransmittedFieldsMaskVerifyParms: Either PS or RT or ECC must be transmitted"));

	status = FM_TX_STATUS_SUCCESS;

	FMC_FUNC_END();

	return status;
}
Ejemplo n.º 10
0
void FMC_MoveList(FMC_ListNode* dest, FMC_ListNode* src)
{
    FMC_FUNC_START("FMC_MoveList");
    
    FMC_VERIFY_FATAL_NO_RETVAR((FMC_IsListCircular(src) == FMC_TRUE), ("FMC_MoveList: List is not circular"));

    pthread_mutex_lock(&list_mutex);

    /* New head points at list*/
    dest->NextNode = src->NextNode;
    dest->PrevNode = src->PrevNode;

    /* Detach source head from list */
    src->NextNode->PrevNode = dest;
    src->PrevNode->NextNode = dest;

    FMC_InitializeListHead(src);
    pthread_mutex_unlock(&list_mutex);

    FMC_FUNC_END();
}
Ejemplo n.º 11
0
void FMC_InsertHeadList(FMC_ListNode* head, FMC_ListNode* Node)
{
    FMC_FUNC_START("FMC_InsertHeadList");
    
    pthread_mutex_lock(&list_mutex);

    /* set the new node's links */
    Node->NextNode = head->NextNode;
    Node->PrevNode = head;
    
    /* Make current first node second */
    head->NextNode->PrevNode = Node;
    
    /* Head's next should point to first element*/
    head->NextNode = Node;

    pthread_mutex_unlock(&list_mutex);

    FMC_VERIFY_FATAL_NO_RETVAR((FMC_IsNodeConnected(Node) == FMC_TRUE), ("FMC_InsertHeadList: Node is not connected"));

    FMC_FUNC_END();
}
Ejemplo n.º 12
0
FmTxStatus FM_TX_Destroy(FmTxContext **fmContext)
{
	FmTxStatus	status = FM_TX_STATUS_SUCCESS;

	FMC_FUNC_START(("FM_TX_Destroy"));

	FMC_VERIFY_ERR((*fmContext == FM_TX_SM_GetContext()), FMC_STATUS_INVALID_PARM, ("FM_TX_Destroy: Invalid Context Ptr"));
	FMC_VERIFY_ERR((FM_TX_SM_GetContextState() ==  FM_TX_SM_CONTEXT_STATE_DISABLED), 
						FM_TX_STATUS_CONTEXT_NOT_DISABLED, ("FM_TX_Destroy: FM TX Context must be disabled before destroyed"));

	status = FM_TX_SM_Destroy(fmContext);
	FMC_VERIFY_FATAL((status == FM_TX_STATUS_SUCCESS), status, 
						("FM_TX_Destroy: FM_TX_SM_Destroy Failed (%s)", FMC_DEBUG_FmcStatusStr(status)));

	/* Make sure pointer will not stay dangling */
	*fmContext = NULL;

	FMC_LOG_INFO(("FM_TX_Destroy: Successfully Destroyed FM TX Context"));
	
	FMC_FUNC_END();
	
	return status;
}
Ejemplo n.º 13
0
FmTxStatus FM_TX_Create(FmcAppHandle *appHandle, const FmTxCallBack fmCallback, FmTxContext **fmContext)
{
	FmTxStatus	status = FM_TX_STATUS_SUCCESS;

	FMC_FUNC_START(("FM_TX_Create"));

	FMC_VERIFY_ERR((appHandle == NULL), FMC_STATUS_NOT_SUPPORTED, ("FM_TX_Create: appHandle Must be null currently"));
	FMC_VERIFY_ERR((_fmTxInitState == _FM_TX_INIT_STATE_INITIALIZED), FM_TX_STATUS_NOT_INITIALIZED,
						("FM_TX_Create: FM TX Not Initialized"));
	FMC_VERIFY_FATAL((FM_TX_SM_GetContextState() ==  FM_TX_SM_CONTEXT_STATE_DESTROYED), 
						FM_TX_STATUS_CONTEXT_NOT_DESTROYED, ("FM_TX_Deinit: FM TX Context must first be destoryed"));

	status = FM_TX_SM_Create(fmCallback, fmContext);
	FMC_VERIFY_FATAL((status == FM_TX_STATUS_SUCCESS), status, 
						("FM_TX_Create: FM_TX_SM_Create Failed (%s)", FMC_DEBUG_FmcStatusStr(status)));
	
	
	FMC_LOG_INFO(("FM_TX_Create: Successfully Create FM TX Context"));
	
	FMC_FUNC_END();
	
	return status;
}
Ejemplo n.º 14
0
FMC_ListNode *_FMC_UTILS_FindMatchingListNodeAndLoc(    FMC_ListNode                *listHead, 
                                                        FMC_ListNode                *prevNode,
                                                        FmcUtilsSearchDir           searchDir,
                                                        const FMC_ListNode      *nodeToMatch, 
                                                        FmcUtilsListComparisonFunc  comparisonFunc,
                                                        FMC_U32             *location)
{
    FMC_ListNode        *checkedNode = NULL;
    FMC_ListNode        *matchingNode = NULL;
    FMC_U32         tempLoc=0;
    FMC_FUNC_START("FMC_UTILS_FindMatchingListEntry");
    
    FMC_VERIFY_FATAL_SET_RETVAR((NULL != listHead), (matchingNode = NULL), ("Null list argument"));
    FMC_VERIFY_FATAL_SET_RETVAR((NULL != nodeToMatch), (matchingNode = NULL), ("Null nodeToMatch argument"));
    FMC_VERIFY_FATAL_SET_RETVAR((NULL != comparisonFunc), (matchingNode = NULL), ("Null comparisonFunc argument"));

    /* Assume a matching entry will not be found */
    matchingNode = NULL;

    /* Decide from which node to start the search */
    
    pthread_mutex_lock(&list_mutex);

    if (prevNode == NULL)
    {
        checkedNode = listHead;
    }
    else
    {
        checkedNode = prevNode;
    }
        
    if (searchDir == FMC_UTILS_SEARCH_FIRST_TO_LAST)
    {
        checkedNode = checkedNode->NextNode;
    }
    else
    {
        checkedNode = checkedNode->PrevNode;
    }

    /* Check all list entries, until a match is found, or list exhausted */
    while (checkedNode != listHead)
    {
        tempLoc ++;
        /* Check the current entry, using the specified comparison function */
        
        if (FMC_TRUE == comparisonFunc(nodeToMatch, checkedNode))
        {
            matchingNode = checkedNode;

            /* entry matches, stop comparing */
            break;
        }

        /* Move on to check the next entry, according to the search direction */
        if (searchDir == FMC_UTILS_SEARCH_FIRST_TO_LAST)
        {
            checkedNode = checkedNode->NextNode;
        }
        else
        {
            checkedNode = checkedNode->PrevNode;
        }
    }
    *location = tempLoc;

    pthread_mutex_unlock(&list_mutex);

    FMC_FUNC_END();
    
    return matchingNode;
}