示例#1
0
/* @req SWS_Ocu_00100 */
Ocu_ReturnType Ocu_SetRelativeThreshold(Ocu_ChannelType ChannelNumber,Ocu_ValueType RelativeValue)
{

    Ocu_ValueType newAbsThreshld;
    Ocu_ValueType cntrval;
    uint8 cntrchnl;
    const volatile struct EMIOS_tag * emiosUnit;
    uint8 channelId;
    uint8 absChnlId;


    /* @req SWS_Ocu_00104 **/
    VALIDATE_W_RV( (OcuDriverStatus != OCU_UNINIT), OCU_SETRELATIVETHRESHOLD_SERVICE_ID, OCU_E_UNINIT,OCU_CM_OUT_REF_INTERVAL );

    /* @req SWS_Ocu_00105 **/
    VALIDATE_W_RV( (ChannelNumber < OCU_MATCH_CHANNEL_COUNT), OCU_SETRELATIVETHRESHOLD_SERVICE_ID, OCU_E_PARAM_INVALID_CHANNEL,OCU_CM_OUT_REF_INTERVAL );

    channelId = OcuConfigPtr->OcuChannelConfig[ChannelNumber].OcuChannelId;
    if (CHANNELS_PER_EMIOS_UNIT != 0) {
    	emiosUnit = GET_EMIOS_UNIT(channelId/CHANNELS_PER_EMIOS_UNIT);
    } else { return OCU_CM_OUT_REF_INTERVAL; }
    absChnlId = GET_EMIOS_CHANNEL(channelId);

    cntrchnl  = (absChnlId < UNIFIED_CHANNEL_D) ? UNIFIED_CHANNEL_C:UNIFIED_CHANNEL_D ;

    cntrval = (Ocu_ValueType)(emiosUnit->CH[cntrchnl].CCNTR.R - 1UL);
    /* @req SWS_Ocu_00101 */
    newAbsThreshld = cntrval + RelativeValue;

    /* @req SWS_Ocu_00106 */
    /* @req SWS_Ocu_00107 */
    return setthrshld(ChannelNumber, cntrval, newAbsThreshld);

}
示例#2
0
Gpt_ValueType Gpt_GetTimeRemaining(Gpt_ChannelType channel)
{
	VALIDATE_W_RV( (Gpt_Global.initRun == STD_ON), GPT_GETTIMEREMAINING_SERVICE_ID, GPT_E_UNINIT, 0 );
	VALIDATE_W_RV( VALID_CHANNEL(channel),GPT_GETTIMEREMAINING_SERVICE_ID, GPT_E_PARAM_CHANNEL, 0 );

	Gpt_ValueType remaining = 0;

	/* @req SWS_Gpt_00301 */
	/* @req SWS_Gpt_00305 */
    if( (GPT_STATE_INITIALIZED == Gpt_Unit[channel].state) ||
        (GPT_STATE_EXPIRED == Gpt_Unit[channel].state) ||
        ((GPT_STATE_STOPPED == Gpt_Unit[channel].state) && (Gpt_Unit[channel].expiredWhenStopped)) ) {
        return 0;
    }


	if (channel <= GPT_CHANNEL_CNT)
	{
		uint32 *tval = (uint32 *)&(TimAddr[channel]->CNT);
		// Time remaining is the time until it hits 0, so just return the current timer value
		remaining = *tval;
	}

	return remaining;
}
示例#3
0
Gpt_ValueType Gpt_GetTimeElapsed(Gpt_ChannelType channel)
{
	Gpt_ValueType timer = 0;

	VALIDATE_W_RV( (Gpt_Global.initRun == STD_ON), GPT_GETTIMEELAPSED_SERVICE_ID, GPT_E_UNINIT ,0 );
	VALIDATE_W_RV( VALID_CHANNEL(channel),GPT_GETTIMEELAPSED_SERVICE_ID, GPT_E_PARAM_CHANNEL, 0 );

    /* @req SWS_Gpt_00295 */
    if(Gpt_Unit[channel].state == GPT_STATE_INITIALIZED) {
        return timer;
    }
    /* @req SWS_Gpt_00299 */
    if( (GPT_STATE_EXPIRED == Gpt_Unit[channel].state) ||
            ((GPT_STATE_STOPPED == Gpt_Unit[channel].state) && (Gpt_Unit[channel].expiredWhenStopped)) ) {
        return TimAddr[channel]->ARR;
    }
	// NOTE!
	// These little creatures count down

	if (channel <= GPT_CHANNEL_CNT)
	{
		uint32 *tlval = (uint32 *)&(TimAddr[channel]->ARR);
	    uint32 *tval = (uint32 *)&(TimAddr[channel]->CNT);
		timer = *tlval - *tval;
	}

	return (timer);
}
示例#4
0
/* @req SWS_Ocu_00085 */
Ocu_ValueType  Ocu_GetCounter(Ocu_ChannelType ChannelNumber)
{

    vuint32_t cntr;
    uint8 cntrchnl;
    const volatile struct EMIOS_tag * emiosUnit;
    uint8 channelId;
    uint8 absChnlId;


    /* @req SWS_Ocu_00090 **/
    VALIDATE_W_RV( (OcuDriverStatus != OCU_UNINIT), OCU_GETCOUNTER_SERVICE_ID, OCU_E_UNINIT,INVALID_COUNTERVALUE );

    /* @req SWS_Ocu_00089 **/
    VALIDATE_W_RV( (ChannelNumber < OCU_MATCH_CHANNEL_COUNT), OCU_GETCOUNTER_SERVICE_ID, OCU_E_PARAM_INVALID_CHANNEL,INVALID_COUNTERVALUE );

    channelId = OcuConfigPtr->OcuChannelConfig[ChannelNumber].OcuChannelId;
    if (CHANNELS_PER_EMIOS_UNIT != 0) {
    	emiosUnit = GET_EMIOS_UNIT(channelId/CHANNELS_PER_EMIOS_UNIT);
    } else { return INVALID_COUNTERVALUE; }
    absChnlId = GET_EMIOS_CHANNEL(channelId);


    // Get the unified channel section which drives the counter
    cntrchnl  = (absChnlId < UNIFIED_CHANNEL_D) ? UNIFIED_CHANNEL_C:UNIFIED_CHANNEL_D ;

    /* @req SWS_Ocu_00086 */
    cntr = emiosUnit->CH[cntrchnl].CCNTR.R -1UL; //In MCB mode CNTR is 1 based
    return (Ocu_ValueType)cntr;
}
示例#5
0
文件: LinFlex.c 项目: uincore/OpenSAR
Lin_StatusType Lin_GetStatus( uint8 Channel, uint8** Lin_SduPtr )
{
	volatile struct LINFLEX_tag * LINFLEXHw = LINFLEX(Channel);

	VALIDATE_W_RV( (LinDriverStatus != LIN_UNINIT), LIN_GETSTATUS_SERVICE_ID, LIN_E_UNINIT, LIN_NOT_OK);
	VALIDATE_W_RV( (LinChannelStatus[Channel] != LIN_CH_UNINIT), LIN_GETSTATUS_SERVICE_ID, LIN_E_CHANNEL_UNINIT, LIN_NOT_OK);
	VALIDATE_W_RV( (Channel < LIN_CONTROLLER_CNT), LIN_GETSTATUS_SERVICE_ID, LIN_E_INVALID_CHANNEL, LIN_NOT_OK);
	VALIDATE_W_RV( (Lin_SduPtr!=NULL), LIN_GETSTATUS_SERVICE_ID, LIN_E_INVALID_POINTER, LIN_NOT_OK);

	imask_t state;
    Irq_Save(state);
	Lin_StatusType res = LinChannelStatus[Channel];
	/* We can only check for valid sdu ptr when LIN_RX_OK */
	if(LinChannelStatus[Channel] == LIN_RX_OK || LinChannelStatus[Channel] == LIN_RX_ERROR){
		CopyToBuffer(LinBufRx[Channel], LINFLEXHw);
		*Lin_SduPtr = LinBufRx[Channel];
		if(LinChannelStatus[Channel] == LIN_RX_ERROR){
			ResyncDriver(Channel);
		}
		LinChannelStatus[Channel]=LIN_CH_OPERATIONAL;
	} else if(LinChannelStatus[Channel] == LIN_TX_OK || LinChannelStatus[Channel] == LIN_TX_ERROR){
		if(LinChannelStatus[Channel] == LIN_TX_ERROR){
			ResyncDriver(Channel);
		}
		LinChannelStatus[Channel]=LIN_CH_OPERATIONAL;
	}
    Irq_Restore(state);
	return res;
}
示例#6
0
文件: LinSM.c 项目: uincore/OpenSAR
Std_ReturnType LinSM_RequestComMode(NetworkHandleType network,ComM_ModeType mode)
{
	Std_ReturnType res = E_NOT_OK;
	VALIDATE_W_RV( (LinSMStatus != LINSM_UNINIT), LINSM_REQUEST_COM_MODE_SERVICE_ID, LINSM_E_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (network < LINIF_CONTROLLER_CNT), LINSM_REQUEST_COM_MODE_SERVICE_ID, LINSM_E_NOXEXISTENT_CHANNEL, E_NOT_OK);

	switch(mode)
	{
		case COMM_NO_COMMUNICATION:
			if (E_OK == LinIf_GotoSleep(network)){
				LinSMChannelStatus[network] = LINSM_GOTO_SLEEP;
				GoToSleepTimer[network]=LINSM_GOTO_SLEEP_TIMEOUT;
				res = E_OK;
			}
			break;
		case COMM_SILENT_COMMUNICATION:
			// Standard say nothing about this case.
			break;
		case COMM_FULL_COMMUNICATION:
			WakeUpTimer[network]=LINSM_WAKEUP_TIMEOUT; //should be done here since some implementations will confirm immediatly
			if (E_OK == LinIf_WakeUp(network)){
				res = E_OK;
			}
			else
			{
				WakeUpTimer[network]=0;
			}
			break;
		default:
			break;
	}
	return res;
}
示例#7
0
文件: LinFlex.c 项目: uincore/OpenSAR
Std_ReturnType Lin_GoToSleepInternal(  uint8 Channel )
{
	VALIDATE_W_RV( (LinDriverStatus != LIN_UNINIT), LIN_GO_TO_SLEEP_INTERNAL_SERVICE_ID, LIN_E_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (LinChannelStatus[Channel] != LIN_CH_UNINIT), LIN_GO_TO_SLEEP_INTERNAL_SERVICE_ID, LIN_E_CHANNEL_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (Channel < LIN_CONTROLLER_CNT), LIN_GO_TO_SLEEP_INTERNAL_SERVICE_ID, LIN_E_INVALID_CHANNEL, E_NOT_OK);
	VALIDATE_W_RV( (LinChannelStatus[Channel] != LIN_CH_SLEEP), LIN_GO_TO_SLEEP_INTERNAL_SERVICE_ID, LIN_E_STATE_TRANSITION, E_NOT_OK);
	Lin_GoToSleep(Channel);
	return E_OK;
}
示例#8
0
文件: Mcu.c 项目: t8534/acore_repo
Std_ReturnType Mcu_InitRamSection(const Mcu_RamSectionType RamSection)
{
	VALIDATE_W_RV( ( 1 == Mcu_Global.initRun ), MCU_INITRAMSECTION_SERVICE_ID, MCU_E_UNINIT, E_NOT_OK );
	VALIDATE_W_RV( ( RamSection <= Mcu_Global.config->McuRamSectors ), MCU_INITRAMSECTION_SERVICE_ID, MCU_E_PARAM_RAMSECTION, E_NOT_OK );

    /* NOT SUPPORTED, reason: no support for external RAM */

    return E_OK;
}
示例#9
0
/* !req SWS_Mcu_00056 */
Std_ReturnType Mcu_DistributePllClock(void)
{
    /* @req SWS_Mcu_00125 */
    /* !req SWS_Mcu_00122 */

    VALIDATE_W_RV( ( TRUE == Mcu_Global.initRun ), MCU_DISTRIBUTEPLLCLOCK_SERVICE_ID, MCU_E_UNINIT, E_NOT_OK );
    VALIDATE_W_RV( ( zynq_GetPllStatus() == MCU_PLL_LOCKED), MCU_DISTRIBUTEPLLCLOCK_SERVICE_ID, MCU_E_PLL_NOT_LOCKED, E_NOT_OK);

    return E_OK;
}
示例#10
0
文件: LinSM.c 项目: uincore/OpenSAR
Std_ReturnType LinSM_ScheduleRequest(NetworkHandleType channel,LinIf_SchHandleType schedule)
{
	VALIDATE_W_RV( (LinSMStatus != LINSM_UNINIT), LINSM_SCHEDULE_REQUEST_SERVICE_ID, LINSM_E_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (channel < LINIF_CONTROLLER_CNT), LINSM_SCHEDULE_REQUEST_SERVICE_ID, LINSM_E_NOXEXISTENT_CHANNEL, E_NOT_OK);
	VALIDATE_W_RV( (LinSMChannelStatus[channel] == LINSM_RUN_SCHEDULE), LINSM_SCHEDULE_REQUEST_SERVICE_ID, LINSM_E_NOT_IN_RUN_SCHEDULE, E_NOT_OK);
	VALIDATE_W_RV( (schedule < LINIF_SCH_CNT), LINSM_SCHEDULE_REQUEST_SERVICE_ID, LINSM_E_PARAMETER, E_NOT_OK);

	ScheduleRequestTimer[channel]=LINSM_SCHEDULE_REQUEST_TIMEOUT;
	return LinIf_ScheduleRequest(channel, schedule);
}
示例#11
0
文件: LinFlex.c 项目: uincore/OpenSAR
Std_ReturnType Lin_SendResponse(  uint8 Channel,   Lin_PduType* PduInfoPtr )
{
	VALIDATE_W_RV( (LinDriverStatus != LIN_UNINIT), LIN_SEND_RESPONSE_SERVICE_ID, LIN_E_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (LinChannelStatus[Channel] != LIN_CH_UNINIT), LIN_SEND_RESPONSE_SERVICE_ID, LIN_E_CHANNEL_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (Channel < LIN_CONTROLLER_CNT), LIN_SEND_RESPONSE_SERVICE_ID, LIN_E_INVALID_CHANNEL, E_NOT_OK);
	VALIDATE_W_RV( (LinChannelStatus[Channel] != LIN_CH_SLEEP), LIN_SEND_RESPONSE_SERVICE_ID, LIN_E_STATE_TRANSITION, E_NOT_OK);
	VALIDATE_W_RV( (PduInfoPtr != NULL), LIN_SEND_RESPONSE_SERVICE_ID, LIN_E_INVALID_POINTER, E_NOT_OK);

	/* The response is sent from within the header in this implementation since this is a master only implementation */
	return E_OK;
}
示例#12
0
Std_ReturnType Mcu_InitRamSection(Mcu_RamSectionType RamSection)
{
    /* @req SWS_Mcu_00021 */
    /* @req SWS_Mcu_00125 */
	VALIDATE_W_RV( ( TRUE == Mcu_Global.initRun ), MCU_INITRAMSECTION_SERVICE_ID, MCU_E_UNINIT, E_NOT_OK );
	VALIDATE_W_RV( ( RamSection <= Mcu_Global.config->McuRamSectors ), MCU_INITRAMSECTION_SERVICE_ID, MCU_E_PARAM_RAMSECTION, E_NOT_OK );

	memset(	(void *)Mcu_Global.config->McuRamSectorSettingConfig[RamSection].McuRamSectionBaseAddress,
			Mcu_Global.config->McuRamSectorSettingConfig[RamSection].McuRamDefaultValue,
			Mcu_Global.config->McuRamSectorSettingConfig[RamSection].McuRamSectionSize);

    return E_OK;
}
示例#13
0
/* @req SWS_Ocu_00091 */
Ocu_ReturnType Ocu_SetAbsoluteThreshold(Ocu_ChannelType ChannelNumber,Ocu_ValueType ReferenceValue,Ocu_ValueType AbsoluteValue)
{


    /* @req SWS_Ocu_00095 **/
    VALIDATE_W_RV( (OcuDriverStatus != OCU_UNINIT), OCU_SETABSOLUTETHRESHOLD_SERVICE_ID, OCU_E_UNINIT,OCU_CM_OUT_REF_INTERVAL );

    /* @req SWS_Ocu_00096 **/
    VALIDATE_W_RV( (ChannelNumber < OCU_MATCH_CHANNEL_COUNT), OCU_SETABSOLUTETHRESHOLD_SERVICE_ID, OCU_E_PARAM_INVALID_CHANNEL,OCU_CM_OUT_REF_INTERVAL );


    /* @req SWS_Ocu_00098 */
    return setthrshld(ChannelNumber,ReferenceValue,AbsoluteValue);
}
示例#14
0
文件: Mcu.c 项目: uincore/OpenSAR
Std_ReturnType Mcu_InitClock(const Mcu_ClockType ClockSetting)
{
  const Mcu_ClockSettingConfigType *clockSettingsPtr;
  VALIDATE_W_RV( ( 1 == Mcu_Global.initRun ), MCU_INITCLOCK_SERVICE_ID, MCU_E_UNINIT, E_NOT_OK );
  VALIDATE_W_RV( ( ClockSetting < Mcu_Global.config->McuClockSettings ), MCU_INITCLOCK_SERVICE_ID, MCU_E_PARAM_CLOCK, E_NOT_OK );

  Mcu_Global.clockSetting = ClockSetting;
  clockSettingsPtr = &Mcu_Global.config->McuClockSettingConfig[Mcu_Global.clockSetting];

  InitMcuClocks(clockSettingsPtr);

  InitPerClocks(clockSettingsPtr);

  return E_OK;
}
示例#15
0
RamTst_TestResultType RamTst_GetTestResultPerBlock( RamTst_NumberOfBlocksType BlockID )
{
    /* @req SWS_RamTst_00089 */
    VALIDATE_W_RV( ( RamTst_Internal.InitStatus != RAMTST_UNINIT ), RAMTST_GETRESULTPERBLOCK_SERVICE_ID, RAMTST_E_UNINIT, RAMTST_RESULT_NOT_TESTED);

    /* Find the block */
    const RamTst_BlockParamsType *blockParamPtr = NULL;
    const RamTst_AlgParamsType *algParams = NULL;
    for(RamTst_AlgParamsIdType i = 0; (i < RamTst_ConfigParams.RamTstNumberOfAlgParamSets) && (NULL == blockParamPtr); i++) {
        algParams = &RamTst_ConfigParams.RamTstAlgParams[i];
        /* Run for all blocks */
        for(RamTst_NumberOfBlocksType block = 0; (block < algParams->RamTstNumberOfBlocks) && (NULL == blockParamPtr); block++) {
            if(algParams->RamTstBlockParams[block].RamTstBlockId == BlockID) {
                blockParamPtr = &algParams->RamTstBlockParams[block];
            }
        }
    }

    if(NULL != blockParamPtr) {
        /* @req SWS_RamTst_00038 */
        return RamTst_Internal.RamTst_BlockResultBuffer[blockParamPtr->RamTstBlockIndex];
    } else {
        /* Invalid block id */
#if ( RAMTST_DEV_ERROR_DETECT == STD_ON )
        /* @req SWS_RamTst_00039 */
        (void)Det_ReportError(MODULE_ID_RAMTST, 0, RAMTST_GETRESULTPERBLOCK_SERVICE_ID, RAMTST_E_OUT_OF_RANGE);
#endif
        return RAMTST_RESULT_UNDEFINED;
    }
}
示例#16
0
RamTst_TestResultType RamTst_GetTestResult( void )
{
    /* @req SWS_RamTst_00089 */
    VALIDATE_W_RV( ( RamTst_Internal.InitStatus != RAMTST_UNINIT ), RAMTST_GETTESTRESULT_SERVICE_ID, RAMTST_E_UNINIT, RAMTST_RESULT_NOT_TESTED);
    /* @req SWS_RamTst_00024 */
    return RamTst_Internal.CurrentTestResult;
}
示例#17
0
文件: Mcu.c 项目: t8534/acore_repo
Mcu_ResetType Mcu_GetResetReason(void)
{
	Mcu_ResetType rv;

	VALIDATE_W_RV( ( 1 == Mcu_Global.initRun ), MCU_GETRESETREASON_SERVICE_ID, MCU_E_UNINIT, MCU_RESET_UNDEFINED );

#if defined(CFG_MPC560X)
	if( RGM.FES.B.F_SOFT ) {
		rv = MCU_SW_RESET;
	} else if( RGM.DES.B.F_SWT ) {
		rv = MCU_WATCHDOG_RESET;
	} else if( RGM.DES.B.F_POR ) {
		rv = MCU_POWER_ON_RESET;
	} else {
		rv = MCU_RESET_UNDEFINED;
	}
#else
	if( SIU.RSR.B.SSRS ) {
		rv = MCU_SW_RESET;
	} else if( SIU.RSR.B.WDRS ) {
		rv = MCU_WATCHDOG_RESET;
	} else if( SIU.RSR.B.PORS || SIU.RSR.B.ERS ) {
		rv = MCU_POWER_ON_RESET;
	} else {
		rv = MCU_RESET_UNDEFINED;
	}
#endif

	return rv;
}
示例#18
0
RamTst_AlgParamsIdType RamTst_GetAlgParams( void )
{
    /* @req SWS_RamTst_00089 */
    VALIDATE_W_RV( ( RamTst_Internal.InitStatus != RAMTST_UNINIT ), RAMTST_GETALGPARAMS_SERVICE_ID, RAMTST_E_UNINIT, 0);
    return RamTst_Internal.ActiveAlgParamID;

}
示例#19
0
文件: LinFlex.c 项目: uincore/OpenSAR
Std_ReturnType Lin_GoToSleep(  uint8 Channel )
{
	volatile struct LINFLEX_tag * LINFLEXHw = LINFLEX(Channel);

	VALIDATE_W_RV( (LinDriverStatus != LIN_UNINIT), LIN_GO_TO_SLEEP_SERVICE_ID, LIN_E_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (LinChannelStatus[Channel] != LIN_CH_UNINIT), LIN_GO_TO_SLEEP_SERVICE_ID, LIN_E_CHANNEL_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (Channel < LIN_CONTROLLER_CNT), LIN_GO_TO_SLEEP_SERVICE_ID, LIN_E_INVALID_CHANNEL, E_NOT_OK);
	VALIDATE_W_RV( (LinChannelStatus[Channel] != LIN_CH_SLEEP), LIN_GO_TO_SLEEP_SERVICE_ID, LIN_E_STATE_TRANSITION, E_NOT_OK);

	LINFLEXHw->LINCR1.B.SLEEP = 1;

	LINFLEXHw->LINIER.B.WUIE = 1; /* enable wake-up irq */

    LinChannelStatus[Channel]=LIN_CH_SLEEP;

    return E_OK;
}
示例#20
0
文件: LinFlex.c 项目: uincore/OpenSAR
Std_ReturnType Lin_WakeUp( uint8 Channel )
{
	volatile struct LINFLEX_tag * LINFLEXHw = LINFLEX(Channel);

	VALIDATE_W_RV( (LinDriverStatus != LIN_UNINIT), LIN_WAKE_UP_SERVICE_ID, LIN_E_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (LinChannelStatus[Channel] != LIN_CH_UNINIT), LIN_WAKE_UP_SERVICE_ID, LIN_E_CHANNEL_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (Channel < LIN_CONTROLLER_CNT), LIN_WAKE_UP_SERVICE_ID, LIN_E_INVALID_CHANNEL, E_NOT_OK);
	VALIDATE_W_RV( (LinChannelStatus[Channel] == LIN_CH_SLEEP), LIN_WAKE_UP_SERVICE_ID, LIN_E_STATE_TRANSITION, E_NOT_OK);

	/* Disable wake interrupt */
	LINFLEXHw->LINIER.B.WUIE = 0;
	/* Clear sleep bit */
	LINFLEXHw->LINCR1.B.SLEEP = 0;

	LinChannelStatus[Channel]=LIN_CH_OPERATIONAL;
	return E_OK;
}
示例#21
0
Std_ReturnType Mcu_InitClock(Mcu_ClockType ClockSetting)
{
    const Mcu_ClockSettingConfigType *clockSettingsPtr;

    /* @req SWS_Mcu_00125  */
    /* @req SWS_Mcu_00019  */
    VALIDATE_W_RV( ( TRUE == Mcu_Global.initRun ), MCU_INITCLOCK_SERVICE_ID, MCU_E_UNINIT, E_NOT_OK );
    VALIDATE_W_RV( ( ClockSetting < Mcu_Global.config->McuClockSettings ), MCU_INITCLOCK_SERVICE_ID, MCU_E_PARAM_CLOCK, E_NOT_OK );

    Mcu_Global.clockSetting = ClockSetting;
    clockSettingsPtr = &Mcu_Global.config->McuClockSettingConfig[Mcu_Global.clockSetting];

    zynq_InitPll(clockSettingsPtr);
    zynq_InitClocks(clockSettingsPtr);

    return E_OK;
}
示例#22
0
文件: LinSM.c 项目: uincore/OpenSAR
Std_ReturnType LinSM_GetCurrentComMode(NetworkHandleType network,ComM_ModeType* mode)
{
	VALIDATE_W_RV( (LinSMStatus != LINSM_UNINIT), LINSM_GET_CURRENT_COM_MODE_SERVICE_ID, LINSM_E_UNINIT, E_NOT_OK);
	VALIDATE_W_RV( (network < LINIF_CONTROLLER_CNT), LINSM_GET_CURRENT_COM_MODE_SERVICE_ID, LINSM_E_NOXEXISTENT_CHANNEL, E_NOT_OK);
	VALIDATE_W_RV( (mode != NULL), LINSM_GET_CURRENT_COM_MODE_SERVICE_ID, LINSM_E_PARAMETER_POINTER, E_NOT_OK);

	switch (LinSMChannelStatus[network])
	{
	case LINSM_RUN_SCHEDULE:
		*mode= COMM_FULL_COMMUNICATION;
		break;
	default:
		*mode= COMM_NO_COMMUNICATION;
		break;
	}
	return E_OK;
}
示例#23
0
Mcu_ResetType Mcu_GetResetReason(void)
{
	/* @req SWS_Mcu_00133 */
    /* @req SWS_Mcu_00125 */
	/* @req SWS_Mcu_00005 */
	VALIDATE_W_RV( ( TRUE == Mcu_Global.initRun ), MCU_GETRESETREASON_SERVICE_ID, MCU_E_UNINIT, MCU_RESET_UNDEFINED );

	return Mcu_Global.resetReason;
}
示例#24
0
文件: Fls.c 项目: uincore/OpenSAR
/**
 * Read from flash memory
 *
 * @param SourceAddress
 * @param TargetAddressPtr
 * @param Length
 * @return
 */
Std_ReturnType Fls_Read(	Fls_AddressType SourceAddress,
							uint8 *TargetAddressPtr,
							Fls_LengthType Length)
{
	SourceAddress += FLS_BASE_ADDRESS;
	/** @req FLS256 */
	/** @req FLS236 */
	/** !req FLS239 TODO */
	/** !req FLS240 Have no idea what the requirement means*/

	/** @req FLS099 */
	VALIDATE_W_RV(Fls_Global.status != MEMIF_UNINIT,FLS_READ_ID, FLS_E_UNINIT,E_NOT_OK );
	/** @req FLS100 */
	VALIDATE_W_RV( Fls_Global.status != MEMIF_BUSY, FLS_READ_ID, FLS_E_BUSY, E_NOT_OK );
	/** @req FLS158 */
	VALIDATE_W_RV( TargetAddressPtr != NULL , FLS_READ_ID, FLS_E_PARAM_DATA, E_NOT_OK );
	/** @req FLS097  */
	VALIDATE_W_RV( E_OK == fls_CheckValidAddress(SourceAddress), FLS_READ_ID, FLS_E_PARAM_ADDRESS, E_NOT_OK );
	/** @req FLS098  */
	VALIDATE_W_RV( (Length != 0) && (E_OK == fls_CheckValidAddress(SourceAddress + Length)), FLS_READ_ID, FLS_E_PARAM_LENGTH, E_NOT_OK );

	// Always check if status is not busy
	if (Fls_Global.status == MEMIF_BUSY)
		return E_NOT_OK;

	Fls_Global.status = MEMIF_BUSY;
	Fls_Global.jobResultType = MEMIF_JOB_PENDING;
	Fls_Global.jobType = FLS_JOB_READ;

	LOG_HEX2("Fls_Read() ",(uint32)TargetAddressPtr," ", Length);

	/** @req FLS237 */
	Fls_Global.flashAddr = SourceAddress;
	Fls_Global.ramAddr = TargetAddressPtr;
	Fls_Global.length = Length;

	if( Fls_Global.mode == MEMIF_MODE_FAST ) {
		Fls_Global.readChunkSize = Fls_Global.config->FlsMaxReadFastMode;
	} else {
		Fls_Global.readChunkSize = Fls_Global.config->FlsMaxReadNormalMode;
	}

	return E_OK;
}
示例#25
0
文件: Fls.c 项目: uincore/OpenSAR
Std_ReturnType Fls_Compare( Fls_AddressType SourceAddress,
							uint8 *TargetAddressPtr,
							Fls_LengthType Length )
{
	SourceAddress += FLS_BASE_ADDRESS;
    /** @req FLS257 */
    /** @req FLS241 */
    /** @req FLS186 */

    /** @req FLS152 */
    VALIDATE_W_RV(Fls_Global.status != MEMIF_UNINIT,FLS_COMPARE_ID, FLS_E_UNINIT,E_NOT_OK );
    /** @req FLS153 */
    VALIDATE_W_RV( Fls_Global.status != MEMIF_BUSY, FLS_COMPARE_ID, FLS_E_BUSY, E_NOT_OK );
    /** @req FLS273 */
    VALIDATE_W_RV( TargetAddressPtr != NULL , FLS_COMPARE_ID, FLS_E_PARAM_DATA, E_NOT_OK );
	/** @req FLS150  */
	VALIDATE_W_RV( E_OK == fls_CheckValidAddress(SourceAddress), FLS_COMPARE_ID, FLS_E_PARAM_ADDRESS, E_NOT_OK );
	/** @req FLS151  */
	VALIDATE_W_RV( (Length != 0) && (E_OK == fls_CheckValidAddress(SourceAddress + Length)),
			FLS_COMPARE_ID, FLS_E_PARAM_LENGTH, E_NOT_OK );


	// Always check if status is not busy
	if (Fls_Global.status == MEMIF_BUSY )
	    return E_NOT_OK;

	Fls_Global.status = MEMIF_BUSY;
	Fls_Global.jobResultType = MEMIF_JOB_PENDING;
	Fls_Global.jobType = FLS_JOB_COMPARE;

	if( Fls_Global.mode == MEMIF_MODE_FAST ) {
		Fls_Global.readChunkSize = Fls_Global.config->FlsMaxReadFastMode;
	} else {
		Fls_Global.readChunkSize = Fls_Global.config->FlsMaxReadNormalMode;
	}

	/* @req FLS242 */
	Fls_Global.flashAddr = SourceAddress;
	Fls_Global.ramAddr = TargetAddressPtr;
	Fls_Global.length = Length;

	return E_OK;
}
示例#26
0
/**
 * Erase flash sectors
 *
 * @param TargetAddress Always from 0 to FLS_TOTAL_SIZE
 * @param Length
 * @return
 */
Std_ReturnType Fls_Erase(Fls_AddressType TargetAddress, Fls_LengthType Length) {
#if FLS_BASE_ADDRESS > 0
	/* Avoid compiler warning */
	TargetAddress += FLS_BASE_ADDRESS;
#endif

	/** @req SWS_Fls_00218  */
	/** @req SWS_Fls_00220 */
	/** @req SWS_Fls_00327 */

	/** @req SWS_Fls_00065 */
	VALIDATE_W_RV( Fls_Global.status != MEMIF_UNINIT, FLS_ERASE_ID, FLS_E_UNINIT, E_NOT_OK );
	/** @req SWS_Fls_00023 */
	VALIDATE_W_RV( Fls_Global.status != MEMIF_BUSY, FLS_ERASE_ID, FLS_E_BUSY, E_NOT_OK );
    /** @req SWS_Fls_00020 */
	VALIDATE_W_RV( E_OK == sectorAligned( TargetAddress ),
	        FLS_ERASE_ID, FLS_E_PARAM_ADDRESS, E_NOT_OK );
    /** @req SWS_Fls_00021  */
    VALIDATE_W_RV( (Length != 0) && (EE_OK == sectorAligned( TargetAddress + Length)),
            FLS_ERASE_ID, FLS_E_PARAM_LENGTH, E_NOT_OK );
#if defined(CFG_MPC5777M)
    VALIDATE_W_RV((E_OK == checkValidChunk(TargetAddress, TargetAddress + Length - 1)), FLS_ERASE_ID, FLS_E_INVALID_AREA, E_NOT_OK);
#endif

	Fls_Global.status = MEMIF_BUSY;				    /** @req SWS_Fls_00328 */
	Fls_Global.jobResultType = MEMIF_JOB_PENDING;   /** @req SWS_Fls_00329 */
	Fls_Global.jobType = FLS_JOB_ERASE;
	Fls_Global.flashAddr = TargetAddress;
	Fls_Global.length = Length;

	LOG_HEX2("Fls_Erase() ",TargetAddress," ", Length);

	/* Unlock */
	Flash_Lock(Fls_Global.config->FlsInfo,FLASH_OP_UNLOCK,TargetAddress, Length );

	/** @req SWS_Fls_00145 */
	if (EE_OK != Flash_Erase(Fls_Global.config->FlsInfo,TargetAddress, Length, NULL )) {
	    return E_NOT_OK;
	}

	return E_OK;	/** @req SWS_Fls_00330 */
}
示例#27
0
Std_ReturnType Mcu_InitClock(const Mcu_ClockType ClockSetting)
{
  const Mcu_ClockSettingConfigType *clockSettingsPtr;
  VALIDATE_W_RV( ( 1 == Mcu_Global.initRun ), MCU_INITCLOCK_SERVICE_ID, MCU_E_UNINIT, E_NOT_OK );
  VALIDATE_W_RV( ( ClockSetting < Mcu_Global.config->McuClockSettings ), MCU_INITCLOCK_SERVICE_ID, MCU_E_PARAM_CLOCK, E_NOT_OK );

  Mcu_Global.clockSetting = ClockSetting;
  clockSettingsPtr = &Mcu_Global.config->McuClockSettingConfig[Mcu_Global.clockSetting];

  CLKSEL &= ~BM_PLLSEL; // Turn off PLL
  PLLCTL |= BM_PLLON+BM_AUTO;  // Enable PLL module, Auto Mode

  REFDV = clockSettingsPtr->Pll1;  // Set reference divider
  SYNR = clockSettingsPtr->Pll2;  // Set synthesizer multiplier

  while (Mcu_GetPllStatus() != MCU_PLL_LOCKED) ;
  CLKSEL |= BM_PLLSEL; // Switch to PLL clock

  return E_OK;
}
示例#28
0
文件: Fls.c 项目: uincore/OpenSAR
/**
 * Erase flash sectors
 *
 * @param TargetAddress Always from 0 to FLS_TOTAL_SIZE
 * @param Length
 * @return
 */
Std_ReturnType Fls_Erase(Fls_AddressType TargetAddress, Fls_LengthType Length) {
	TargetAddress += FLS_BASE_ADDRESS;

	/** @req FLS250 3.0/4.0 */
	/** @req FLS218 3.0/4.0 */
	/** @req FLS220 3.0/4.0 */
	/** @req FLS327 4.0     */

	/** @req FLS065 */
	VALIDATE_W_RV( Fls_Global.status != MEMIF_UNINIT, FLS_ERASE_ID, FLS_E_UNINIT, E_NOT_OK );
	/** @req FLS023 */
	VALIDATE_W_RV( Fls_Global.status != MEMIF_BUSY, FLS_ERASE_ID, FLS_E_BUSY, E_NOT_OK );
    /** @req FLS020 3.0/4.0 */
	VALIDATE_W_RV( E_OK == fls_SectorAligned( TargetAddress ),
	        FLS_ERASE_ID, FLS_E_PARAM_ADDRESS, E_NOT_OK );
    /** @req FLS021 3.0/4.0 */
    VALIDATE_W_RV( (Length != 0) && (EE_OK == fls_SectorAligned( TargetAddress + Length)),
            FLS_ERASE_ID, FLS_E_PARAM_LENGTH, E_NOT_OK );

	// Check if we trying to erase a partition that we are executing in
#if 0
	pc = fls_GetPc();
#endif


	Fls_Global.status = MEMIF_BUSY;				    /** @req FLS219 3.0 */ /** @req FLS328 4.0 */
	Fls_Global.jobResultType = MEMIF_JOB_PENDING;   /** @req FLS329 4.0 */
	Fls_Global.jobType = FLS_JOB_ERASE;
	Fls_Global.flashAddr = TargetAddress;
	Fls_Global.length = Length;

	LOG_HEX2("Fls_Erase() ",TargetAddress," ", Length);

	/* Unlock */
	Flash_Lock(Fls_Global.config->FlsInfo,FLASH_OP_UNLOCK,TargetAddress, Length );

	/** @req FLS145 */
	Flash_Erase(Fls_Global.config->FlsInfo,TargetAddress, Length, NULL );

	return E_OK;	/** @req FLS330 4.0 */
}
示例#29
0
文件: Mcu.c 项目: uincore/OpenSAR
Mcu_RawResetType Mcu_GetResetRawValue(void) {
	VALIDATE_W_RV( ( 1 == Mcu_Global.initRun ), MCU_GETRESETREASON_SERVICE_ID, MCU_E_UNINIT, MCU_GETRESETRAWVALUE_UNINIT_RV );

	if (!Mcu_Global.initRun) {
		return MCU_GETRESETRAWVALUE_UNINIT_RV;
	} else {
		return (RCC->CSR) & (RCC_CSR_RMVF | RCC_CSR_PINRSTF | RCC_CSR_PORRSTF
				| RCC_CSR_SFTRSTF | RCC_CSR_IWDGRSTF | RCC_CSR_WWDGRSTF
				| RCC_CSR_LPWRRSTF);
	}
	return 0;
}
示例#30
0
/* @req SWS_Mcu_00006 */
Mcu_RawResetType Mcu_GetResetRawValue(void)
{
	/* @req SWS_Mcu_00135 */
    /* @req SWS_Mcu_00125 */
	VALIDATE_W_RV( ( TRUE == Mcu_Global.initRun ), MCU_GETRESETREASON_SERVICE_ID, MCU_E_UNINIT, MCU_GETRESETRAWVALUE_UNINIT_RV );

	if( !Mcu_Global.initRun ) {
		return MCU_GETRESETRAWVALUE_UNINIT_RV;
	}

	return Mcu_Global.rawResetvalue;
}