/* ** =================================================================== ** Method : TickTimer_Init (bean TimerInt) ** ** Description : ** This method is internal. It is used by Processor Expert ** only. ** =================================================================== */ void TickTimer_Init(void) { CmpHighVal = 3124; /* Compare register value for high speed CPU mode */ SetCV(CmpHighVal); /* Store appropriate value to the compare register according to the selected high speed CPU mode */ SetPV(3); /* Set prescaler register according to the selected high speed CPU mode */ HWEnDi(); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : COREUART_Enable (component AsynchroSerial) ** Description : ** Enables the component - it starts the send and receive ** functions. Events may be generated ** ("DisableEvent"/"EnableEvent"). ** Parameters : None ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** =================================================================== */ byte COREUART_Enable(void) { if (!EnUser) { /* Is the device disabled by user? */ EnUser = TRUE; /* If yes then set the flag "device enabled" */ HWEnDi(); /* Enable the device */ } return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : PIT_1ms_Init (component TimerInt) ** ** Description : ** Initializes the associated peripheral(s) and the beans ** internal variables. The method is called automatically as a ** part of the application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void PIT_1ms_Init(void) { /* PIT0_CTRL: SLAVE=0,??=0,??=0,??=0,??=0,??=0,CLKSEL=0,??=0,PRESCALER=0,PRF=0,PRIE=1,CNT_EN=0 */ setReg(PIT0_CTRL,0x02); /* Set up control register */ SetCV((word)0xC350); /* Store appropriate value to the compare register according to the selected high speed CPU mode */ SetPV((byte)0x01); /* Set prescaler register according to the selected high speed CPU mode */ HWEnDi(); /* Enable/disable device according to status flags */ }
/* ===================================================================*/ LDD_TError SM1_Disable(LDD_TDeviceData *DeviceDataPtr) { if (((SM1_TDeviceDataPtr)DeviceDataPtr)->EnUser) { /* Is the device enabled by user? */ ((SM1_TDeviceDataPtr)DeviceDataPtr)->EnUser = FALSE; /* If yes then set the flag "device disabled" */ HWEnDi((SM1_TDeviceDataPtr)DeviceDataPtr); /* Disable the device */ } return ERR_OK; /* OK */ }
/* ===================================================================*/ LDD_TError SS_SPI1_Enable(LDD_TDeviceData *DeviceDataPtr) { if (!((SS_SPI1_TDeviceDataPtr)DeviceDataPtr)->EnUser) { /* Is the device disabled by user? */ ((SS_SPI1_TDeviceDataPtr)DeviceDataPtr)->EnUser = TRUE; /* If yes then set the flag "device enabled" */ HWEnDi((SS_SPI1_TDeviceDataPtr)DeviceDataPtr); /* Enable the device */ } return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : SM1_Disable (component SynchroMaster) ** Description : ** Disable the component - it stops the send and receive ** functions. No events will be generated. Note: When this ** method is called while a transmission is in progress, the ** data being transmitted/received may be lost. ** Parameters : None ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** =================================================================== */ byte SM1_Disable(void) { if (EnUser) { /* Is the device enabled by user? */ EnUser = FALSE; /* If yes then set the flag "device disabled" */ HWEnDi(); /* Disable the device */ } return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : AS1_Init (component AsynchroSerial) ** ** Description : ** Initializes the associated peripheral(s) and the bean internal ** variables. The method is called automatically as a part of the ** application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void AS1_Init(void) { SerFlag = 0U; /* Reset flags */ /* SCI_SCICR: LOOP=0,SWAI=0,RSRC=0,M=0,WAKE=0,POL=0,PE=0,PT=0,TEIE=0,TIIE=0,RFIE=0,REIE=0,TE=0,RE=0,RWU=0,SBK=0 */ setReg(SCI_SCICR, 0U); /* Set the SCI configuration */ /* SCI_SCIBR: ??=0,??=0,??=0,SBR=17 */ setReg(SCI_SCIBR, 17U); /* Set prescaler bits */ HWEnDi(); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : Inhr6_Init (component AsynchroSerial) ** ** Description : ** Initializes the associated peripheral(s) and the bean internal ** variables. The method is called automatically as a part of the ** application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void Inhr6_Init(void) { SerFlag = 0; /* Reset flags */ /* SCI_CTRL1: LOOP=0,SWAI=0,RSRC=0,M=0,WAKE=0,POL=0,PE=0,PT=0,TEIE=0,TIIE=0,RFIE=0,REIE=0,TE=0,RE=0,RWU=0,SBK=0 */ setReg(SCI_CTRL1, 0); /* Set the SCI configuration */ /* SCI_RATE: SBR=26,FRAC_SBR=0 */ setReg(SCI_RATE, 208); /* Set prescaler bits */ HWEnDi(); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : RC_Init (component AsynchroSerial) ** ** Description : ** Initializes the associated peripheral(s) and the bean internal ** variables. The method is called automatically as a part of the ** application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void RC_Init(void) { SerFlag = 0x00U; /* Reset flags */ RC_InpLen = 0x00U; /* No char in the receive buffer */ InpIndexR = 0x00U; /* Set index on the first item in the receive buffer */ InpIndexW = 0x00U; ASerialLdd1_DeviceDataPtr = ASerialLdd1_Init(NULL); /* Calling init method of the inherited component */ HWEnDi(); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : COREUART_Init (component AsynchroSerial) ** ** Description : ** Initializes the associated peripheral(s) and the bean internal ** variables. The method is called automatically as a part of the ** application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void COREUART_Init(void) { SerFlag = 0x00U; /* Reset flags */ EnUser = FALSE; /* Disable device */ COREUART_ClearRxBuf(); COREUART_ClearTxBuf(); ASerialLdd2_DeviceDataPtr = ASerialLdd2_Init(NULL); /* Calling init method of the inherited component */ HWEnDi(); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : TI1_Init (component TimerInt) ** ** Description : ** Initializes the associated peripheral(s) and the component ** internal variables. The method is called automatically as a ** part of the application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void TI1_Init(void) { /* RTCSC: RTIF=0,RTCLKS=0,RTIE=0,RTCPS=0 */ setReg8(RTCSC, 0x00U); /* Stop HW */ EnUser = TRUE; /* Enable device */ TI1_SetCV(0x0FU); /* Initialize appropriate value to the compare/modulo/reload register */ RTCMOD = RTCMOD; /* Reset HW counter */ HWEnDi(); }
/* ** =================================================================== ** Method : hwI2c_Disable (bean InternalI2C) ** ** Description : ** Disables I2C bean. No events will be generated. ** Parameters : None ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** =================================================================== */ byte hwI2c_Disable(void) { if (!EnMode) { /* Is the device disabled in the actual speed CPU mode? */ return ERR_SPEED; /* If yes then error */ } if (EnUser) { /* Is the device enabled by user? */ EnUser = FALSE; /* If yes then set the flag "device disabled" */ HWEnDi(); /* Disable the device */ } return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : Resolver_Init (component SynchroMaster) ** ** Description : ** Initializes the associated peripheral(s) and the beans ** internal variables. The method is called automatically as a ** part of the application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void Resolver_Init(void) { /* QSPI0_SCTRL: SPR=4,DSO=0,ERRIE=0,MODFEN=0,SPRIE=0,SPMSTR=1,CPOL=1,CPHA=1,SPE=0,SPTIE=0,SPRF=0,OVRF=0,MODF=1,SPTE=0 */ setReg(QSPI0_SCTRL,0x81C2); /* Set control register */ /* QSPI0_DSCTRL: WOM=0,??=0,??=0,BD2X=0,SSB_IN=0,SSB_DATA=1,SSB_ODM=0,SSB_AUTO=0,SSB_DDR=1,SSB_STRB=0,SSB_OVER=0,SPR3=0,DS=0x0B */ setReg(QSPI0_DSCTRL,0x048B); /* Set data size and control register */ /* QSPI0_DELAY: ??=0,??=0,??=0,WAIT=1 */ setReg(QSPI0_DELAY,0x01); /* Set data size and control register */ SerFlag = 0; /* Reset all flags */ EnUser = FALSE; /* Disable device */ HWEnDi(); /* Enable/disable device according to the status flags */ }
/* ===================================================================*/ LDD_TError SMasterLdd3_Disable(LDD_TDeviceData *DeviceDataPtr) { /* Clock configuration test - this test can be disabled by setting the "Ignore clock configuration test" property to the "yes" value in the "Configuration inspector" */ if (!((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->EnMode) { /* Is the device disabled in the actual speed CPU mode? */ return ERR_SPEED; /* If yes then error */ } if (((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->EnUser) { /* Is the device enabled by user? */ ((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->EnUser = FALSE; /* If yes then set the flag "device disabled" */ HWEnDi((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr); /* Disable the device */ } return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : COREUART_Init (component AsynchroSerial) ** ** Description : ** Initializes the associated peripheral(s) and the bean internal ** variables. The method is called automatically as a part of the ** application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void COREUART_Init(void) { SerFlag = 0x00U; /* Reset flags */ EnUser = FALSE; /* Disable device */ COREUART_InpLen = 0x00U; /* No char in the receive buffer */ InpIndexR = 0x00U; /* Set index on the first item in the receive buffer */ InpIndexW = 0x00U; COREUART_OutLen = 0x00U; /* No char in the transmit buffer */ OutIndexR = 0x00U; /* Set index on the first item in the transmit buffer */ OutIndexW = 0x00U; ASerialLdd1_DeviceDataPtr = ASerialLdd1_Init(NULL); /* Calling init method of the inherited component */ HWEnDi(); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : SM1_SetIdleClockPolarity (component SynchroMaster) ** Description : ** Sets the idle clock polarity at runtime. If the ** communication does not run, the clock signal will have ** required level. The method will disable communication (if ** enabled), change the idle clock polarity end re-enable the ** communication (if it was enabled before). ** Parameters : ** NAME - DESCRIPTION ** Level - Idle clock polarity: ** 0-low ** 1-high ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** ERR_RANGE - Parameter out of range ** ** [ Version specific information neither for ** Freescale HC08 derivatives ] ** [ERR_DISABLED] - Obsolete, this error code ** is not used. ** ** =================================================================== */ byte SM1_SetIdleClockPolarity(byte Level) { if (Level > 1U) { return ERR_RANGE; } SpiClockfeatures = ((SpiClockfeatures & 0xFEU) | Level); EnterCritical(); /* Disable global interrupts */ (void)SMasterLdd1_Disable(SMasterLdd1_DeviceDataPtr); /* Disable device */ (void)SMasterLdd1_Enable(SMasterLdd1_DeviceDataPtr); /* Enable device and cancel receive data request */ (void)SMasterLdd1_SelectConfiguration(SMasterLdd1_DeviceDataPtr, 0x00U, SpiClockfeatures); HWEnDi(); /* Enable/Disable device */ ExitCritical(); /* Enable global interrupts */ return ERR_OK; }
/* ===================================================================*/ byte AD1_Measure(bool WaitForResult) { if (AD1_ModeFlg != IDLE) { /* Is the device in running mode? */ return ERR_BUSY; /* If yes then error */ } AD1_ModeFlg = MEASURE; /* Set state of device to the measure mode */ HWEnDi(); /* Enable the device */ if (WaitForResult) { /* Is WaitForResult TRUE? */ while (AD1_ModeFlg == MEASURE) { /* Calling MainMeasure while IDLE state occured */ MainMeasure(); /* A/D converter handler */ } } return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : SPI_SD_SetClockConfiguration (component SPIMaster_LDD) ** ** Description : ** This method changes the clock configuration. During a clock ** configuration change the component changes it`s setting ** immediately upon a request. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void SPI_SD_SetClockConfiguration(LDD_TDeviceData *DeviceDataPtr, LDD_TClockConfiguration ClockConfiguration) { SPI_SD_TDeviceData *DeviceDataPrv = (SPI_SD_TDeviceData *)DeviceDataPtr; switch (ClockConfiguration) { case CPU_CLOCK_CONFIG_0: DeviceDataPrv->EnMode = TRUE; /* Set the flag "device enabled" in the actual speed CPU mode */ SPI_PDD_WriteMasterClockTransferAttributeReg(SPI1_BASE_PTR,0U,ConfigurationSet0[((SPI_SD_TDeviceDataPtr)DeviceDataPtr)->CurrentAttributeSet]); /* Set required configuration */ break; default: DeviceDataPrv->EnMode = FALSE; /* Set the flag "device disabled" in the actual speed CPU mode */ break; } HWEnDi(DeviceDataPtr); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : MotorD1_Init (component PWM) ** ** Description : ** Initializes the associated peripheral(s) and the components ** internal variables. The method is called automatically as a ** part of the application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void MotorD1_Init(void) { /* TPM3SC: TOF=0,TOIE=0,CPWMS=0,CLKSB=0,CLKSA=0,PS2=0,PS1=0,PS0=0 */ setReg8(TPM3SC, 0x00U); /* Disable device */ /* TPM3C0SC: CH0F=0,CH0IE=0,MS0B=1,MS0A=1,ELS0B=1,ELS0A=0,??=0,??=0 */ setReg8(TPM3C0SC, 0x38U); /* Set up PWM mode with output signal level high */ ActualRatio = 0x00U; /* Store initial value of the ratio */ EnUser = FALSE; /* Disable device */ /* TPM3MOD: BIT15=0,BIT14=1,BIT13=1,BIT12=0,BIT11=0,BIT10=0,BIT9=1,BIT8=0,BIT7=0,BIT6=1,BIT5=0,BIT4=0,BIT3=1,BIT2=1,BIT1=0,BIT0=1 */ setReg16(TPM3MOD, 0x624DU); /* Set modulo register */ /* TPM3C0SC: CH0F=0,CH0IE=0,MS0B=1,MS0A=0,ELS0B=0,ELS0A=0,??=0,??=0 */ setReg8(TPM3C0SC, 0x20U); /* Temporary set compare mode to enable modifications of compare register */ SetRatio(); /* Calculate and set up new values of the compare according to the selected speed CPU mode */ HWEnDi(); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : UART_SDA_SetClockConfiguration (component Serial_LDD) ** ** Description : ** This method changes the clock configuration. During a clock ** configuration change the component changes it`s setting ** immediately upon a request. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void UART_SDA_SetClockConfiguration(LDD_TDeviceData *DeviceDataPtr, LDD_TClockConfiguration ClockConfiguration) { UART_SDA_TDeviceDataPtr DeviceDataPrv = (UART_SDA_TDeviceDataPtr)DeviceDataPtr; switch (ClockConfiguration) { case CPU_CLOCK_CONFIG_0: UART_PDD_SetBaudRateFineAdjust(UART0_BASE_PTR, 12u); /* Set baud rate fine adjust */ UART_PDD_SetBaudRate(UART0_BASE_PTR, 11U); /* Set the baud rate register. */ DeviceDataPrv->EnMode = TRUE; /* Set the flag "device enabled" in the actual speed CPU mode */ break; default: DeviceDataPrv->EnMode = FALSE; /* Set the flag "device disabled" in the actual speed CPU mode */ break; } HWEnDi(DeviceDataPtr); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : SM1_Init (component SynchroMaster) ** ** Description : ** Initializes the associated peripheral(s) and the component ** internal variables. The method is called automatically as a ** part of the application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void SM1_Init(void) { SerFlag = 0U; /* Reset all flags */ ErrFlag = 0U; /* Reset all flags in mirror */ OnFreeTxBufSemaphore = FALSE; /* Clear the OnFreeTxBufSemaphore */ SpiClockfeatures = 0x00U; /* Initialize actual clock feature state */ SetAttributeCmd = FALSE; /* Disable settings SPI attribute in enable */ EnUser = TRUE; /* Enable device */ SM1_InpLen = 0U; /* No char in the receive buffer */ InpIndexR = 0x00U; /* Set index on the first item in the receive buffer */ InpIndexW = 0x00U; SM1_OutLen = 0U; /* No char in the transmit buffer */ OutIndexR = 0x00U; /* Set index on the first item in the transmit buffer */ OutIndexW = 0x00U; SMasterLdd1_DeviceDataPtr = SMasterLdd1_Init(NULL); /* Calling init method of the inherited component */ HWEnDi(); /* Enable/disable device according to the status flags */ }
/* ** =================================================================== ** Method : SM1_SetShiftClockPolarity (component SynchroMaster) ** Description : ** Sets the shift clock polarity at runtime. Output data will ** be shifted on the selected edge polarity. The method will ** disable communication (if enabled), change the shift clock ** polarity end re-enable the communication (if it was enabled ** before). ** Parameters : ** NAME - DESCRIPTION ** Edge - Edge polarity. ** 0-falling edge ** 1-rising edge ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** ERR_RANGE - Parameter out of range ** ** [ Version specific information neither for ** Freescale HC08 derivatives ] ** [ERR_DISABLED] - Obsolete, this error code ** is not used. ** =================================================================== */ byte SM1_SetShiftClockPolarity(byte Edge) { if (Edge > 1U) { return ERR_RANGE; } if (Edge != 0U) { SpiClockfeatures &= 0xFDU; /* Set rising edge polarity */ } else { SpiClockfeatures |= 0x02U; /* Set falling edge polarity */ } EnterCritical(); /* Disable global interrupts */ (void)SMasterLdd1_Disable(SMasterLdd1_DeviceDataPtr); /* Disable device */ (void)SMasterLdd1_Enable(SMasterLdd1_DeviceDataPtr); /* Enable device and cancel receive data request */ (void)SMasterLdd1_SelectConfiguration(SMasterLdd1_DeviceDataPtr, 0x00U, SpiClockfeatures); HWEnDi(); /* Enable/Disable device */ ExitCritical(); /* Enable global interrupts */ return ERR_OK; }
/* ** =================================================================== ** Method : UART_SetClockConfiguration (component Serial_LDD) ** ** Description : ** This method changes the clock configuration. During a clock ** configuration change the component changes it`s setting ** immediately upon a request. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void UART_SetClockConfiguration(LDD_TDeviceData *DeviceDataPtr, LDD_TClockConfiguration ClockConfiguration) { UART_TDeviceDataPtr DeviceDataPrv = (UART_TDeviceDataPtr)DeviceDataPtr; switch (ClockConfiguration) { case CPU_CLOCK_CONFIG_0: SIM_PDD_SetClockSourceUART0(SIM_BASE_PTR, SIM_PDD_UART0_PLL_FLL_CLOCK); UART0_PDD_SetBaudRate(UART0_BASE_PTR, 52U); /* Set the baud rate register. */ UART0_PDD_SetOversamplingRatio(UART0_BASE_PTR, 3U); UART0_PDD_EnableSamplingOnBothEdges(UART0_BASE_PTR, PDD_ENABLE); DeviceDataPrv->EnMode = TRUE; /* Set the flag "device enabled" in the actual speed CPU mode */ break; default: DeviceDataPrv->EnMode = FALSE; /* Set the flag "device disabled" in the actual speed CPU mode */ break; } HWEnDi(DeviceDataPtr); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : Inhr1_Init (component AsynchroSerial) ** ** Description : ** Initializes the associated peripheral(s) and the bean internal ** variables. The method is called automatically as a part of the ** application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void Inhr1_Init(void) { SerFlag = 0x00U; /* Reset flags */ ASerialLdd2_DeviceDataPtr = ASerialLdd2_Init(NULL); /* Calling init method of the inherited component */ HWEnDi(); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : PIT_1ms_Enable (component TimerInt) ** Description : ** This method enables the component - it starts the timer. ** Events may be generated (<DisableEvent>/<EnableEvent>). ** Parameters : None ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** =================================================================== */ byte PIT_1ms_Enable(void) { HWEnDi(); /* Enable the device */ return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : hwI2c_SetSlow (bean InternalI2C) ** ** Description : ** The method reconfigures the bean and its selected peripheral(s) ** when the CPU is switched to the Slow speed mode. The method is ** called automatically as a part of the CPU SetSlowSpeed method. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void hwI2c_SetSlow(void) { EnMode = FALSE; /* Set the flag "device disabled" in the actual speed CPU mode */ HWEnDi(); /* Enable/disable device according to the status flags */ }
/* ** =================================================================== ** Method : hwI2c_SetHigh (bean InternalI2C) ** ** Description : ** The method reconfigures the bean and its selected peripheral(s) ** when the CPU is switched to the High speed mode. The method is ** called automatically as s part of the CPU SetHighSpeed method. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void hwI2c_SetHigh(void) { EnMode = TRUE; /* Set the flag "device enabled" in the actual speed CPU mode */ HWEnDi(); /* Enable/disable device according to the status flags */ }
/* ** =================================================================== ** Method : TickTimer_Enable (bean TimerInt) ** ** Description : ** Enable the bean - it starts the timer. Events may be ** generated ("DisableEvent"/"EnableEvent"). ** Parameters : None ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** =================================================================== */ byte TickTimer_Enable(void) { HWEnDi(); /* Enable the device */ return ERR_OK; /* OK */ }