Basic SW Drivers for MPC5744P User's Guide Document Number: KTMPC5744DBSWUG Rev 1.0 Basic SW Drivers for MPC5744P, Rev. 1.0 2 Freescale Semiconductor, Inc. Contents Section number Title Page Chapter 1 Introduction 1.1 Overview.......................................................................................................................................................................9 1.2 About this Manual.........................................................................................................................................................9 1.3 Acronyms and Definitions............................................................................................................................................9 1.4 Reference List...............................................................................................................................................................10 Chapter 2 ADC driver 2.1 Function ADC_IsNormalConvRunning.......................................................................................................................11 2.2 Function ADC_IsInjectedConvAborted.......................................................................................................................11 2.3 Function ADC_IsInjectedConvRunning.......................................................................................................................12 2.4 Function ADC_IsCTUconvRunning............................................................................................................................13 2.5 Function ADC_GetCurrentChannelAddress................................................................................................................13 2.6 Function ADC_GetAutoClockOffState........................................................................................................................14 2.7 Function ADC_GetStatus.............................................................................................................................................15 2.8 Function ADC_Init.......................................................................................................................................................15 2.9 Function ADC_StartNormalConversion.......................................................................................................................17 2.10 Function ADC_StopConversion...................................................................................................................................17 2.11 Function ADC_StartInjectedConversion......................................................................................................................18 2.12 Function ADC_SetOneShotMode................................................................................................................................18 2.13 Function ADC_SetScanMode.......................................................................................................................................19 2.14 Function ADC_AutoClockOffEnable...........................................................................................................................19 2.15 Function ADC_AutoClockOffDisable..........................................................................................................................20 2.16 Function ADC_GetChannelValue................................................................................................................................20 2.17 Function ADC_SetInt...................................................................................................................................................21 2.18 Function ADC_ClearEOCflag......................................................................................................................................22 2.19 Function ADC_ClearAllEOCflags...............................................................................................................................23 2.20 Function ADC_ClearEOCTUflag.................................................................................................................................24 Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 3 Section number Title Page 2.21 Function ADC_ClearJEOCflag....................................................................................................................................24 2.22 Function ADC_ClearJECHflag....................................................................................................................................25 2.23 Function ADC_ClearECHflag......................................................................................................................................25 2.24 Function ADC_SetThldRegister...................................................................................................................................26 2.25 Function ADC_SetThldForChannel.............................................................................................................................27 2.26 Function ADC_ClearThldFlags....................................................................................................................................27 2.27 Function ADC_SetVDDforPresampling......................................................................................................................28 2.28 Function ADC_SetVSSforPresampling........................................................................................................................29 2.29 Function ADC_DisableSampleBypass.........................................................................................................................30 2.30 Function ADC_EnableSampleBypass..........................................................................................................................30 2.31 Function ADC_SetSamplingTime................................................................................................................................31 Chapter 3 CAN driver 3.1 Function CAN_ConfigurePads.....................................................................................................................................33 3.2 Function CAN_Init.......................................................................................................................................................33 3.3 Function CAN_Send.....................................................................................................................................................34 3.4 Function CAN_Stop.....................................................................................................................................................35 Chapter 4 DSPI driver 4.1 Function DSPI_Init.......................................................................................................................................................37 4.2 Function DSPI_Send.....................................................................................................................................................38 4.3 Function DSPI_Read....................................................................................................................................................39 4.4 Function DSPI_RoundBaudRate..................................................................................................................................40 4.5 Function DSPI_Enable..................................................................................................................................................40 4.6 Function DSPI_Disable................................................................................................................................................41 4.7 Function DSPI_ChangeBaudRateType........................................................................................................................41 4.8 Function DSPI_ChangeFrameSize...............................................................................................................................42 4.9 Function DSPI_SetPhase..............................................................................................................................................43 4.10 Function DSPI_SetPolarity...........................................................................................................................................43 Basic SW Drivers for MPC5744P, Rev. 1.0 4 Freescale Semiconductor, Inc. Section number Title Page 4.11 Function DSPI_EnableTxFIFO....................................................................................................................................44 4.12 Function DSPI_DisableTxFIFO...................................................................................................................................44 4.13 Function DSPI_EnableRxFIFO....................................................................................................................................45 4.14 Function DSPI_DisableRxFIFO...................................................................................................................................45 4.15 Function DSPI_SendWithInt........................................................................................................................................46 4.16 Function DSPI_ReadWithInt........................................................................................................................................47 4.17 Function DSPI_ClearRFDF..........................................................................................................................................47 Chapter 5 FCCU driver 5.1 Function FCCU_SetProtocol........................................................................................................................................49 Chapter 6 INTC driver 6.1 Function INTC_InstallINTCInterruptHandler..............................................................................................................51 6.2 Function INTC_Init......................................................................................................................................................51 Chapter 7 LINFLEX driver 7.1 Function LINFLEX_ChangeBaudRate.........................................................................................................................53 7.2 Function LINFLEX_ConfigurePads.............................................................................................................................54 7.3 Function LINFLEX_Sleep............................................................................................................................................54 7.4 Function LINFLEX_WakeUp......................................................................................................................................55 7.5 Function LINFLEX_DisableTxUART.........................................................................................................................55 7.6 Function LINFLEX_DisableRxUART.........................................................................................................................56 7.7 Function LINFLEX_EnableTxUART..........................................................................................................................57 7.8 Function LINFLEX_EnableRxUART..........................................................................................................................57 7.9 Function LINFLEX_EnableInt.....................................................................................................................................58 7.10 Function LINFLEX_InitUART....................................................................................................................................58 7.11 Function LINFLEX_InitRxBuffer................................................................................................................................59 7.12 Function LINFLEX_SendUART..................................................................................................................................59 7.13 Function LINFLEX_ReadUART..................................................................................................................................60 7.14 Function LINFLEX_GetReceiveFlagUART................................................................................................................61 Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 5 Section number Title Page 7.15 Function LINFLEX_ClearReceiveFlagUART.............................................................................................................62 7.16 Function LINFLEX_EnableDRFint..............................................................................................................................63 7.17 Function LINFLEX_GetParityErrorUART..................................................................................................................63 7.18 Function LINFLEX_ClearParityError..........................................................................................................................64 7.19 Function LINFLEX_IsIdle............................................................................................................................................64 7.20 Function LINFLEX_InitLIN........................................................................................................................................65 7.21 Function LINFLEX_SendFrameLIN............................................................................................................................66 7.22 Function LINFLEX_SendHeaderLIN..........................................................................................................................67 7.23 Function LINFLEX_SendWordUART.........................................................................................................................68 7.24 Function LINFLEX_ReadLIN......................................................................................................................................68 7.25 Function LINFLEX_GetReceiveFlagLIN....................................................................................................................69 7.26 Function LINFLEX_ClearReceiveFlagLIN.................................................................................................................69 7.27 Function LINFLEX_GetHeaderFlagLIN......................................................................................................................70 7.28 Function LINFLEX_ClearHeaderFlagLIN...................................................................................................................70 7.29 Function LINFLEX_ReadLINid...................................................................................................................................71 7.30 Function LINFLEX_SetReceptionParamLIN..............................................................................................................71 Chapter 8 ME driver 8.1 Function MC_MODE_INIT.........................................................................................................................................73 Chapter 9 PIT driver 9.1 Function PIT_Init..........................................................................................................................................................75 9.2 Function PIT_Setup......................................................................................................................................................75 9.3 Function PIT_EnableInt................................................................................................................................................76 9.4 Function PIT_EnableChannel.......................................................................................................................................76 9.5 Function PIT_Disable...................................................................................................................................................77 9.6 Function PIT_GetFlag..................................................................................................................................................77 9.7 Function PIT_ClearFlag................................................................................................................................................78 9.8 Function PIT_DisableChannel......................................................................................................................................78 Basic SW Drivers for MPC5744P, Rev. 1.0 6 Freescale Semiconductor, Inc. Section number 9.9 Title Page Function PIT_IsChannelEnabled..................................................................................................................................79 Chapter 10 SIUL driver 10.1 Function SIUL_DigitalInput.........................................................................................................................................81 10.2 Function SIUL_DigitalInputSimple.............................................................................................................................83 10.3 Function SIUL_AnalogInput........................................................................................................................................84 10.4 Function SIUL_DigitalOutput......................................................................................................................................84 10.5 Function SIUL_DigitalIO.............................................................................................................................................85 10.6 Function SIUL_ToggleIO.............................................................................................................................................85 10.7 Function SIUL_EnableExtInt.......................................................................................................................................86 10.8 Function SIUL_EnableExtIntRisingEdge.....................................................................................................................87 10.9 Function SIUL_EnableExtIntFallingEdge....................................................................................................................87 10.10 Function SIUL_GetExtIntFlag......................................................................................................................................88 10.11 Function SIUL_ClearExtIntFlag...................................................................................................................................88 10.12 Function SIUL_SetPad.................................................................................................................................................89 10.13 Function SIUL_ClearPad..............................................................................................................................................90 10.14 Function SIUL_GetPadState.........................................................................................................................................90 Chapter 11 Integration 11.1 Compiler Options..........................................................................................................................................................93 11.2 Assembler Options........................................................................................................................................................94 11.3 Linker Options..............................................................................................................................................................96 Chapter 12 Revision History 12.1 Revision History...........................................................................................................................................................99 Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 7 Basic SW Drivers for MPC5744P, Rev. 1.0 8 Freescale Semiconductor, Inc. Chapter 1 Introduction Basic software drivers were created for evaluation and demonstration purposes. The library consists of drivers for basic modules included in the Qorivva MPC5744P microcontroller (for each module a .c and .h files are included). 1.1 Overview The Basic Software driver package was created as a part of demo software for KITMPC5643DBEVM Daughter Board (EVM). This package was developped for the Freescale's MCU MPC5744P, which is populated on the EVM. Purpose of this software package is not to cover all modules included in the MPC5744P MCU, but to enable our customers to start their development rapidly and easily. 1.2 About this Manual This User Guide employs the following typographical conventions: • Boldface type: Bold is used for important terms, notes and warnings. • Courier font: Courier typeface is used for code snippets in the text. Note that C language modifiers such "const" or "volatile" are sometimes omitted to improve readability of the presented code. • Italics type: Italics is used for configuration items names. • CAPS type: Capital letters are used for microcontroller module names. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 9 Reference List 1.3 Acronyms and Definitions This table provides acronyms and definitions used within this document. The table does not contain all acronyms that are names of the microcontroller's registers and modules. These acronyms can be found in the MPC5744P Microcontroller Reference Manual. Table 1-1. Acronyms and Definitions Term Definition API Application Programming Interface ADC Analog-to-Digital Converter module CAN Controller Area Network DSPI Deserial Serial Peripheral Interface FCCU Fault Collection and Control Unit INTC Interrupt Controller LINFLEX Serial communication interface module ME Mode Entry module PIT Periodic Interrupt Timer SIUL System Integration Unit Lite INT Interrupt IO Input/Output IDE Integrated Development Environment EVM Enhanced Evaluation Board KITMPC5643DBEVM Evaluation Board Including the MPC5643L KITMPC5744DBEVM Evaluation Board Including the MPC5744P GHS Greenhills 1.4 Reference List Doc. Number MPC5744PRM Table 1-2. Reference List Description MPC5744P Microcontroller Reference Manual Version (http://www.freescale.com/docs/pcn_attachments/ 15818_MPC5744PRM.pdf) Basic SW Drivers for MPC5744P, Rev. 1.0 10 Freescale Semiconductor, Inc. Chapter 2 ADC driver The ADC driver provides functions to process simple analog to digital operations such as initialization, conversion either in Normal or Injected mode etc. 2.1 Function ADC_IsNormalConvRunning The function ADC_IsNormalConvRunning indicates whether the Normal conversion of the ADCx is in process. Prototype: uint8_t ADC_IsNormalConvRunning(uint8_t nbADC); Table 2-1. ADC_IsNormalConvRunning Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Return: • "1" - if normal conversion is in process • "0" - if normal conversion has stopped Include : ADC.h Description: This function returns a 1 if the normal conversion is in process (if NSTART bit is set); otherwise it returns 0. Remark: ADCx must be initialized before using of this function using of this function (see ADC_Init function for details). Code sample: ADC_IsNormalConvRunning(1); • Command returns NSTART status bit of ADC1. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 11 Function ADC_IsInjectedConvRunning 2.2 Function ADC_IsInjectedConvAborted The function ADC_IsInjectedConvAborted indicates whether the Injected conversion of the ADCx was aborted. Prototype: uint8_t ADC_IsInjectedConvAborted(uint8_t nbADC); Table 2-2. ADC_IsInjectedConvAborted Arguments Type uint8_t Name Direction input nbADC Description Number of ADC module (0 or 1). Return: • "1" - if injected conversion was aborted • "0" - if injected conversion was not aborted Include : ADC.h Description : This function returns JABORT status bit. This status bit is used to signal that an injected conversion has been aborted. This bit is reset when a new injected conversion starts. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_IsInjectedConvAborted(0); • Command returns JABORT status bit of ADC0. 2.3 Function ADC_IsInjectedConvRunning The function ADC_IsInjectedConvRunning indicates whether the Injected conversion of the ADCx is in process. Prototype: uint8_t ADC_IsInjectedConvRunning(uint8_t nbADC); Table 2-3. ADC_IsInjectedConvRunning Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Return: - "1" - if injected conversion is in process • "0" - if injected conversion has stopped Include : ADC.h Basic SW Drivers for MPC5744P, Rev. 1.0 12 Freescale Semiconductor, Inc. Chapter 2 ADC driver Description : This function returns 1 if injected conversion is in process (if JSTART bit is set), otherwise it returns 0. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_IsInjectedConvRunning(1); • Command returns JSTART status bit of ADC1. 2.4 Function ADC_IsCTUconvRunning The function ADC_IsCTUconvRunning indicates an ongoing CTU conversion for ADC. Prototype: uint8_t ADC_IsCTUconvRunning(uint8_t nbADC); Table 2-4. ADC_IsCTUconvRunning Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Return: • "1" - if CTU conversion is ongoing • "0" - if CTU conversion has stopped Include : ADC.h Description : This function returns the CTUSTART status bit. It is used to signal a CTU conversion is ongoing, and is set when a CTU trigger pulse is received and the CTU conversion starts. This bit automatically resets when the conversion is completed and the CTU trigger mode is enabled. Otherwise, if the Control mode is enabled, it resets when the CTU is disabled (CTUEN set to 0). Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_IsCTUconvRunning(0); • Command returns CTUSTART status bit of ADC0. 2.5 Function ADC_GetCurrentChannelAddress The function ADC_GetCurrentChannelAddress returns a number of ADC channels that are currently in the conversion. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 13 Function ADC_GetAutoClockOffState Prototype: uint8_t ADC_GetCurrentChannelAddress(uint8_t nbADC); Table 2-5. ADC_GetCurrentChannelAddress Arguments Type uint8_t Name Direction input nbADC Description Number of ADC module (0 or 1). Return: Number of the channel currently in conversion (from 0 till 15) Include : ADC.h Description : This function returns address (number) of the channel, which is actually being converted. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_GetCurrentChannelAddress(1); • Command returns number of the channel currently being converted in ADC1. 2.6 Function ADC_GetAutoClockOffState The function ADC_GetAutoClockOffState returns status of the Auto clock off state bit for ADC. Prototype: uint8_t ADC_GetAutoClockOffState(uint8_t nbADC); Table 2-6. ADC_GetAutoClockOffState Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Return: • "1" - if auto-clock-off feature is disabled • "0" - if auto-clock-off feature is enabled Include : ADC.h Description : This function returns status of the auto-clock-off feature (ACK0 status bit). Remark: Auto-clock-off feature allows processor to switch off CLK for ADC automatically if no conversion is ongoing. This reduces power consumption without switching to the power down mode. ADCx must be initialized before using of this function (see ADC_Init function for details). Basic SW Drivers for MPC5744P, Rev. 1.0 14 Freescale Semiconductor, Inc. Chapter 2 ADC driver Code sample: ADC_GetAutoClockOffState(0); • Command returns ACK0 status bit of ADC0. 2.7 Function ADC_GetStatus The function ADC_GetStatus returns the current status of ADC. Prototype: uint8_t ADC_GetStatus(uint8_t nbADC); Table 2-7. ADC_GetStatus Arguments Type uint8_t Name Direction input nbADC Description Number of ADC module (0 or 1). Return: • "000" - Idle • "001" - Power-down • "010" - Wait state • "011" - X • "100" - Sample • "101" - X • "110" - Conversion • "111" - X Include : ADC.h Description : This function returns status of the specified ADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_GetStatus(1); • Command returns status of ADC1. 2.8 Function ADC_Init The function ADC_Init initializes registers of ADC. Prototype: void ADC_Init(uint8_t nbADC, uint64_t chMaskNormal, uint64_t chMaskInjected, uint32_t config); Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 15 Function ADC_Init Table 2-8. ADC_Init Arguments Type Name Direction Description uint8_t nbADC input Number of ADC module (0 or 1). uint64_t chMaskInjected input Mask of channels for injected conversion. Predefined values: • CHSmask - Mask for ALL standard channels • CH0Smask - Mask for standard channel no.0 • CH1Smask - Mask for standard channel no.1 • CH2Smask - Mask for standard channel no.2 • CH3Smask - Mask for standard channel no.3 • CH4Smask - Mask for standard channel no.4 • CH5Smask - Mask for standard channel no.5 • CH6Smask - Mask for standard channel no.6 • CH7Smask - Mask for standard channel no.7 • CH8Smask - Mask for standard channel no.8 • ch.9 - DO NOT USE - internally connected • ch.10 - DO NOT USE - internally connected • CH11Smask - Mask for standard channel no.11 • CH12Smask - Mask for standard channel no.12 • CH13Smask - Mask for standard channel no.13 • CH14Smask - Mask for standard channel no.14 • ch.15 - DO NOT USE - internally connected to TSENS_0 uint64_t chMaskNormal input Mask of channels for normal conversion. Predefined values are the same as for injected conversion. uint32_t config input Configuration setting for the Main Control Register (MCR). • OWRITE_DIS - Prevents overwrite of unread converted data. New result is discarded. • OWRITE_EN - Enables converted data to be overwritten by a new conversion. • ALIGN_R - The conversion data is written right-aligned. • ALIGN_L - Data is left-aligned (from 15 to (15 resolution + 1)). • ONE_SHOT - One Shot Mode - Configures the normal conversion of one chain. • SCAN - Scan Mode - Configures continuous chain conversion mode. When the programmed chain conversion is finished it restarts immediately. • PWDN_DIS - ADC is in normal mode. • PWDN_EN - ADC has been requested to power down. • ACKO_EN - Auto clock off is enabled. • ACKO_DIS - Auto clock off is disabled. • DEFAULT_ADC - Default configuration defined as follows: Include : ADC.h Description : This function initializes registers of the ADCx and activates channels, which are masked in function parameters. Configuration of the registers can be changed through the config parameter. Initialization of ADC registers. Remark: Configuration parameters (instead of DEFAULT_ADC) as well as channel masks should be combined arbitrarily using logical OR (|) operator, please do not use DEFAULT_ADC with other parameters. Basic SW Drivers for MPC5744P, Rev. 1.0 16 Freescale Semiconductor, Inc. Chapter 2 ADC driver Code sample1: ADC_Init(0, CH0Smask | CH5Smask, 0, DEFAULT_ADC); • Command will initialize channels 0 and 5 of ADC0 in injected mode with DEFAULT configuration. Code sample2: ADC_Init(1, CH0Smask, CH2Smask | CH4Smask, OWRITE_DIS | ONE_SHOT | PWDN_DIS | ALIGN_R | ACKO_DIS); • This command initializes the channels of the ADC1 (channel 0 in injected mode, channels 2 and 4 in normal mode) with the specified parameters (overwrite disabled, one shot mode, power down disabled, result right aligned, auto clock off disabled). 2.9 Function ADC_StartNormalConversion The function ADC_StartNormalConversion starts conversion of ADC in a Normal mode. Prototype: void ADC_StartNormalConversion(uint8_t nbADC, uint32_t chMaskNormal); Table 2-9. ADC_StartNormalConversion Arguments Type Name Direction Description uint8_t nbADC input Number of ADC module (0 or 1). uint32_t chMaskNormal input Mask with channels used for Normal conversion. Include : ADC.h Description : This function starts normal conversion ofthe ADC specified by the nbADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_StartNormalConversion(0); • Command starts normal conversion of ADC0. 2.10 Function ADC_StopConversion The function ADC_StopConversion stops all on-going conversions of ADC immediately. Prototype: void ADC_StopConversion(uint8_t nbADC); Table 2-10. ADC_StopConversion Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 17 Function ADC_StartInjectedConversion Include : ADC.h Description : This function stops all conversions (injected as well as normal) of ADC specified by the nbADC number immediately. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_StopConversion(1); • Command stops all conversions of ADC1. 2.11 Function ADC_StartInjectedConversion The function ADC_StartInjectedConversion starts conversion of ADC in the Injected mode. Prototype: void ADC_StartInjectedConversion(uint8_t nbADC, uint64_t chMaskInjected); Table 2-11. ADC_StartInjectedConversion Arguments Type Name Direction Description uint8_t nbADC input Number of ADC module (0 or 1). uint64_t chMaskInjected input Mask with channels used for Injected conversion. Include : ADC.h Description : This function starts injected conversion of ADC specified by the nbADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_StartInjectedConversion(0); • Command starts injected conversion of ADC0. 2.12 Function ADC_SetOneShotMode The function ADC_SetOneShotMode sets a One Shot conversion mode for the ADCx. Prototype: void ADC_SetOneShotMode(uint8_t nbADC); Basic SW Drivers for MPC5744P, Rev. 1.0 18 Freescale Semiconductor, Inc. Chapter 2 ADC driver Table 2-12. ADC_SetOneShotMode Arguments Type uint8_t Name Direction input nbADC Description Number of ADC module (0 or 1). Include : ADC.h Description : This function sets one shot mode for ADC specified by the nbADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_SetOneShotMode(1); • Command sets one shot mode for ADC1. 2.13 Function ADC_SetScanMode The function ADC_SetScanMode sets a Cyclic conversion chain mode (Scan mode) for ADC. Prototype: void ADC_SetScanMode(uint8_t nbADC); Table 2-13. ADC_SetScanMode Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Include : ADC.h Description : This function sets cyclic conversion chain (scan mode) for ADC specified by the nbADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_SetScanMode(1); • Command sets one scan mode for ADC1. 2.14 Function ADC_AutoClockOffEnable The function ADC_AutoClockOffEnable enables Auto clock off feature for the ADCx. Prototype: void ADC_AutoClockOffEnable(uint8_t nbADC); Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 19 Function ADC_AutoClockOffDisable Table 2-14. ADC_AutoClockOffEnable Arguments Type uint8_t Name Direction input nbADC Description Number of ADC module (0 or 1). Include : ADC.h Description : This function enables AutoClockOff feature for ADC specified by the nbADC. Remark: The AutoClockOff feature allows the processor to switch off CLK for ADC automatically, if no conversion is ongoing. This reduces power consumption without switching to the power down mode. ADCx must be initialized beforehand (see ADC_Init function for details). Code sample: ADC_AutoClockOffEnable(0); • Command enables the AutoClockOff feature for ADC0. 2.15 Function ADC_AutoClockOffDisable The function ADC_AutoClockOffDisable disables AutoClockOff feature for the ADCx. Prototype: void ADC_AutoClockOffDisable(uint8_t nbADC); Table 2-15. ADC_AutoClockOffDisable Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Include : ADC.h Description : This function disables the AutoClockOff feature for ADC specified by the nbADC. Remark: The AutoClockOff feature allows processor to switch off CLK for ADC automatically if no conversion is ongoing. This reduces power consumption without switching to the power down mode. the ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_AutoClockOffDisable(1); • Command disables AutoClockOff feature for ADC1. Basic SW Drivers for MPC5744P, Rev. 1.0 20 Freescale Semiconductor, Inc. Chapter 2 ADC driver 2.16 Function ADC_GetChannelValue The function ADC_GetChannelValue returns the value converted by the ADCx from the specified channel. Prototype: uint16_t ADC_GetChannelValue(uint8_t nbADC, uint32_t nbCH); Table 2-16. ADC_GetChannelValue Arguments Type Name Direction Description uint8_t nbADC input Number of ADC module (0 or 1). uint32_t nbCH input Number of the channel to be read. Include : ADC.h Description : This function waits until data of the specified channel is valid (conversion has been finished). Then it reads the 12-bit CDATA result and returns it. Remark: The function returns only right aligned data from the CDATA register. If the ADC is configured to be left aligned, this function will return only the eight lower bits shifted by four to the left. Code sample: ADC_GetChannelValue(1, 0); • Command returns result of the conversion for ADC1, channel 0. 2.17 Function ADC_SetInt The function ADC_SetInt sets interrupt masks for specified channels and flags for the ADCx. Prototype: void ADC_SetInt(uint8_t nbADC, uint32_t intFlagMask, uint32_t intChannelMask); Table 2-17. ADC_SetInt Arguments Type Name Direction Description uint8_t nbADC input Number of ADC module (0 or 1). uint32_t intFlagMask input Mask to enable different interrupt flags. Predefined values: • EOCTU_FLAG - End of CTU Conversion interrupt enable • JEOC_FLAG - End of Injected Channel Conversion interrupt enable • JECH_FLAG - End of Injected Chain Conversion interrupt enable • EOC_FLAG - End of Channel Conversion interrupt enable • ECH_FLAG - End of Chain Conversion interrupt enable Table continues on the next page... Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 21 Function ADC_ClearEOCflag Table 2-17. ADC_SetInt Arguments (continued) Type uint32_t Name intChannelMask Direction input Description Interrupt mask for channels. Predefined values: • CHSmask - Mask for ALL standard channels • CH0Smask - Mask for standard channel no.0 • CH1Smask - Mask for standard channel no.1 • CH2Smask - Mask for standard channel no.2 • CH3Smask - Mask for standard channel no.3 • CH4Smask - Mask for standard channel no.4 • CH5Smask - Mask for standard channel no.5 • CH6Smask - Mask for standard channel no.6 • CH7Smask - Mask for standard channel no.7 • CH8Smask - Mask for standard channel no.8 • ch.9 - DO NOT USE - internally connected • ch.10 - DO NOT USE - internally connected • CH11Smask - Mask for standard channel no.11 • CH12Smask - Mask for standard channel no.12 • CH13Smask - Mask for standard channel no.13 • CH14Smask - Mask for standard channel no.14 • ch.15 - DO NOT USE - internally connected to TSENS_0 Include : ADC.h Description : This function initializes interruption for specified ADC (nbADC) with masked flags (intFlagMask) for masked channels (intChannelMask). Remark: Interrupt masks as well as channel interrupt masks should be combined arbitrarily using logical OR (|) operator. ADCx has to be initialized before (see ADC_Init function for details). Code sample: ADC_SetInt(1, ECH_FLAG | EOC_FLAG, CH1Smask | CH2Smask | CH3Smask); • Command sets ECH and EOC interrupts for channels 1, 2 and 3 in ADC1. 2.18 Function ADC_ClearEOCflag The function ADC_ClearEOCflag clears End of Channel conversion flag for specified channels of the ADCx. Prototype: void ADC_ClearEOCflag(uint8_t nbADC, uint32_t intFlagClearMask); Table 2-18. ADC_ClearEOCflag Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Table continues on the next page... Basic SW Drivers for MPC5744P, Rev. 1.0 22 Freescale Semiconductor, Inc. Chapter 2 ADC driver Table 2-18. ADC_ClearEOCflag Arguments (continued) Type uint32_t Name intFlagClearMask Direction input Description The higher 16 bits (16 till 31) correspond to interrupt flags of 16 channels. Predefined values: • CHSmask - Mask for ALL standard channels • CH0Smask - Mask for standard channel no.0 • CH1Smask - Mask for standard channel no.1 • CH2Smask - Mask for standard channel no.2 • CH3Smask - Mask for standard channel no.3 • CH4Smask - Mask for standard channel no.4 • CH5Smask - Mask for standard channel no.5 • CH6Smask - Mask for standard channel no.6 • CH7Smask - Mask for standard channel no.7 • CH8Smask - Mask for standard channel no.8 • ch.9 - DO NOT USE - internally connected • ch.10 - DO NOT USE - internally connected • CH11Smask - Mask for standard channel no.11 • CH12Smask - Mask for standard channel no.12 • CH13Smask - Mask for standard channel no.13 • CH14Smask - Mask for standard channel no.14 • ch.15 - DO NOT USE - internally connected to TSENS_0 Include : ADC.h Description : This function clears the End of Channel Conversion (EOC) flags, which are specified by the intFlagClearMask. Remark: As a mask we can use directly 16-bit binary value (logical 1 will clear the flag, logical 0 will not make any influence) or predefined masks like in the previous cases. Each bit corresponds to 1 channel (bit no.16 corresponds to channel no.15, bit 31 to channel 0). Code sample: void ADC_ClearEOCflag(0, 0b101); • Command clears EOC flags of channels no.2 and 0 in ADC0 2.19 Function ADC_ClearAllEOCflags The function ADC_ClearAllEOCflags clears End of Channel conversion flag for all channels of the ADCx. Prototype: void ADC_ClearAllEOCflags(uint8_t nbADC); Table 2-19. ADC_ClearAllEOCflags Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 23 Function ADC_ClearEOCTUflag Include : ADC.h Description : This function clears the End of Channel (EOC) conversion flags for all channels of the specified ADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: void ADC_ClearAllEOCflags(1); • Command clears EOC flags of all channels as well as the common EOC flag of ADC1. 2.20 Function ADC_ClearEOCTUflag The function ADC_ClearEOCTUflag clears End of CTU conversion flag for the ADCx. Prototype: void ADC_ClearEOCTUflag(uint8_t nbADC); Table 2-20. ADC_ClearEOCTUflag Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Include : ADC.h Description : This function clears the End of CTU conversion flag for the specified ADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: void ADC_ClearEOCTUflag(0); • Command clears EOCTU interrupt flag of ADC0. 2.21 Function ADC_ClearJEOCflag The function ADC_ClearJEOCflag clears End of Injected Channel conversion flag for the ADCx. Prototype: void ADC_ClearJEOCflag(uint8_t nbADC); Basic SW Drivers for MPC5744P, Rev. 1.0 24 Freescale Semiconductor, Inc. Chapter 2 ADC driver Table 2-21. ADC_ClearJEOCflag Arguments Type uint8_t Name Direction input nbADC Description Number of ADC module (0 or 1). Include : ADC.h Description : This function clears the End of Injected Channel (JEOC) conversion flag for the specified ADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: void ADC_ClearJEOCflag(1); • Command clears JEOC interrupt flag of ADC1. 2.22 Function ADC_ClearJECHflag The function ADC_ClearJECHflag clears End of Injected Chain conversion flag for the ADCx. Prototype: void ADC_ClearJECHflag(uint8_t nbADC); Table 2-22. ADC_ClearJECHflag Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Include : ADC.h Description : This function clears the End of Injected Chain (JECH) conversion flag for the specified ADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: void ADC_ClearJECHflag(0); • Command clears JECH interrupt flag of ADC0. 2.23 Function ADC_ClearECHflag The function ADC_ClearECHflag clears End of Chain conversion flag for the ADCx. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 25 Function ADC_SetThldRegister Prototype: void ADC_ClearECHflag(uint8_t nbADC); Table 2-23. ADC_ClearECHflag Arguments Type uint8_t Name Direction input nbADC Description Number of ADC module (0 or 1). Include : ADC.h Description : This function clears the End of Chain (ECH) conversion interrupt flag for the specified ADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: void ADC_ClearECHflag(1); • Command clears ECH interrupt flag of ADC1. 2.24 Function ADC_SetThldRegister The function ADC_SetThldRegister initializes of the Thresholdx registers for the ADCx. Prototype: void ADC_SetThldRegister(uint8_t nbADC, uint8_t nbThld, uint16_t valueL, uint16_t valueH, uint32_t intMask); Table 2-24. ADC_SetThldRegister Arguments Type Name Direction Description uint8_t nbADC input Number of ADC module (0 or 1). uint8_t nbThld input Number of threshold to be initialized (from 0 till 3). uint16_t valueL input 12bit low value of the threshold (from 0 till 4095) uint16_t valueH input 12bit high value of the threshold (from 0 till 4095). uint32_t intMask input Interruption mask where each ADC channel has 2 maskable bits corresponding to high and low (higher than valueH and lower than valueL) interruption. Include : ADC.h Description : This function initializes thresholdx (specified by nbThld) with low and high limit (valueL, valueH). For each channel we can explicitly enable or disable interrupts corresponding to the set range. These interrupts are maskable using the intMask parameter, where each channel has two bits to mask high and low (higher than valueH and lower than valueL) interruption independently. Basic SW Drivers for MPC5744P, Rev. 1.0 26 Freescale Semiconductor, Inc. Chapter 2 ADC driver Remark: Interruption mask should be done with respect to the bit distribution (see img for details). ADCx must be initialized before (see ADC_Init function for details). Code sample: ADC_SetThldRegister(0, 2, 100, 400, 0x00000003); • Command sets threshold register no.2 in ADC0 with the threshold range between 100 and 400. Interruption will be called if conversion of channel no.0 will be out of range (lower or higher than the set values). 2.25 Function ADC_SetThldForChannel The function assigns Thresholdx to specified channel of the ADCx. Prototype: void ADC_SetThldForChannel(uint8_t nbADC, uint32_t nbCH, uint8_t nbThld); Table 2-25. ADC_SetThldForChannel Arguments Type Name Direction Description uint8_t nbADC input Number of ADC module (0 or 1). uint32_t nbCH input Number of channel (from 0 till 15). uint8_t nbThld input Number of threshold (from 0 till 3). Include : ADC.h Description : This function assigns threshold (nbThld) to the specified channel (nbCH). Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_SetThldForChannel(1, 4, 2); • Command assigns threshold no.2 to channel no.4 of ADC1. 2.26 Function ADC_ClearThldFlags The function clears Threshold flags of the ADCx. Prototype: void ADC_ClearThldFlags(uint8_t nbADC); Table 2-26. ADC_ClearThldFlags Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Include : ADC.h Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 27 Function ADC_SetVDDforPresampling Description : This function clears all threshold interrupt flags of specified ADC. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_ClearThldFlags(0); • Command clears all threshold interrupt flags for ADC0. 2.27 Function ADC_SetVDDforPresampling The function ADC_SetVDDforPresampling sets a positive power supply for the presampling of the ADCx. Prototype: void ADC_SetVDDforPresampling(uint8_t nbADC, vuint32_t channelMask); Table 2-27. ADC_SetVDDforPresampling Arguments Type Name Direction Description uint8_t nbADC input Number of ADC module (0 or 1). vuint32_t channelMask input Mask indicates which channels will use presampling with Vdd. Predefined values: • CHSmask - Mask for ALL standard channels • CH0Smask - Mask for standard channel no.0 • CH1Smask - Mask for standard channel no.1 • CH2Smask - Mask for standard channel no.2 • CH3Smask - Mask for standard channel no.3 • CH4Smask - Mask for standard channel no.4 • CH5Smask - Mask for standard channel no.5 • CH6Smask - Mask for standard channel no.6 • CH7Smask - Mask for standard channel no.7 • CH8Smask - Mask for standard channel no.8 • ch.9 - DO NOT USE - internally connected • ch.10 - DO NOT USE - internally connected • CH11Smask - Mask for standard channel no.11 • CH12Smask - Mask for standard channel no.12 • CH13Smask - Mask for standard channel no.13 • CH14Smask - Mask for standard channel no.14 • ch.15 - DO NOT USE - internally connected to TSENS_0 Include : ADC.h Description : This function sets the positive power supply for the presampling period of the ADC conversion. Basic SW Drivers for MPC5744P, Rev. 1.0 28 Freescale Semiconductor, Inc. Chapter 2 ADC driver Remark: Function in the same time enables presampling phase for the specified channels. Presampling values cannot be set separately for different channels so the presampling voltage should be either positive or negative (ground). Channel masks should be combined arbitrarily using logical OR (|) operator. ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_SetVDDforPresampling(1, CH2Smask | CH3Smask); • Command enables presampling for channels 2 and 3 of the ADC1 and sets Vdd as the presampling voltage at the same time. 2.28 Function ADC_SetVSSforPresampling The function ADC_SetVSSforPresampling sets a negative power supply for presampling of the ADCx. Prototype: void ADC_SetVSSforPresampling(uint8_t nbADC, vuint32_t channelMask); Table 2-28. ADC_SetVSSforPresampling Arguments Type Name Direction Description uint8_t nbADC input Number of ADC module (0 or 1). vuint32_t channelMask input Mask Indicates which channels will use presampling with Vdd. Predefined values: • CHSmask - Mask for ALL standard channels • CH0Smask - Mask for standard channel no.0 • CH1Smask - Mask for standard channel no.1 • CH2Smask - Mask for standard channel no.2 • CH3Smask - Mask for standard channel no.3 • CH4Smask - Mask for standard channel no.4 • CH5Smask - Mask for standard channel no.5 • CH6Smask - Mask for standard channel no.6 • CH7Smask - Mask for standard channel no.7 • CH8Smask - Mask for standard channel no.8 • ch.9 - DO NOT USE - internally connected • ch.10 - DO NOT USE - internally connected • CH11Smask - Mask for standard channel no.11 • CH12Smask - Mask for standard channel no.12 • CH13Smask - Mask for standard channel no.13 • CH14Smask - Mask for standard channel no.14 • ch.15 - DO NOT USE - internally connected to TSENS_0 Include : ADC.h Description : This function sets the negative power supply for the presampling period of the ADC conversion. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 29 Function ADC_DisableSampleBypass Remark: Function in the same time enables presampling phase for the specified channels. Presampling values cannot be set separately for different channels so the presampling voltage should be either positive or negative (ground). Channel masks should be combined arbitrarily using logical OR (|) operator. ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_SetVSSforPresampling(0, CH2Smask | CH3Smask); • Command enables presampling for channels 2 and 3 of the ADC0 and sets Vss as the presampling voltage at the same time. 2.29 Function ADC_DisableSampleBypass The function ADC_DisableSampleBypass enables the sample phase for the ADCx => presampling + sampling + conversion. Prototype: void ADC_DisableSampleBypass(uint8_t nbADC); Table 2-29. ADC_DisableSampleBypass Arguments Type uint8_t Name nbADC Direction input Description Number of ADC module (0 or 1). Include : ADC.h Description : This function disables bypassing of the sampling phase so the s conversion consists of the following phases: (presampling) + sampling + conversion. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_DisableSampleBypass(1); • Command enables sampling phase (disables sampling bypass) for the ADC1 conversions. 2.30 Function ADC_EnableSampleBypass The function ADC_EnableSampleBypass bypasses the sample phase of the ADCx => presampling + conversion. Prototype: void ADC_EnableSampleBypass(uint8_t nbADC); Basic SW Drivers for MPC5744P, Rev. 1.0 30 Freescale Semiconductor, Inc. Chapter 2 ADC driver Table 2-30. ADC_EnableSampleBypass Arguments Type uint8_t Name Direction input nbADC Description Number of ADC module (0 or 1). Include : ADC.h Description : This function enables bypassing of the sampling phase so the conversion consists of the following phases: (presampling) + conversion. Remark: ADCx must be initialized before using of this function (see ADC_Init function for details). Code sample: ADC_EnableSampleBypass(0); • Command enables sampling phase for the ADC0 conversions. 2.31 Function ADC_SetSamplingTime Computes/sets register for sampling phase duration of ADCx. Prototype: void ADC_SetSamplingTime(uint8_t nbADC, uint32_t sysClk, float samplingTime); Table 2-31. ADC_SetSamplingTime Arguments Type Name Direction Description uint8_t nbADC input - Number of ADC module (0 or 1). uint32_t sysClk input - Frequency of the system clock. float samplingTime input - Desired sampling time. Time is limited by its maximal and minimal values depending on the clock frequency and ADCLKSEL bit (ADCLKSEL = 0 by default). Include: : ADC.h Description: : Function computes register (INPSAMP) setting depending on the module clock frequency (sysClk) and on the desired sampling phase duration. Remark: Values of the frequency should be added in basic units [Hz] as well as in their multiples, but everytime with respect to the units of sampling time. The ratio of their multiples has to be everytime equal to 1. E.g. [Hz]/[s], [kHz]/[ms], [MHz]/[us] etc. Minimal and maximal time possible to set depend on the clock frequency and on the ADCLKSEL bit setting (see external Excel file for these values). Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 31 Function ADC_SetSamplingTime Basic SW Drivers for MPC5744P, Rev. 1.0 32 Freescale Semiconductor, Inc. Chapter 3 CAN driver CAN driver enables to initialize CAN module and to send basic CAN frames. 3.1 Function CAN_ConfigurePads The function CAN_ConfigurePads configures pads of the CANx module. Prototype: void CAN_ConfigurePads(uint8_t nbModule); Table 3-1. CAN_ConfigurePads Arguments Type uint8_t Name Direction input nbModule Description Number of the CAN module (0 or 1). Include : CAN.h Description : This function configures pads (Tx/Rx) for CAN module specified by nbModule. Remark: This function is used by the CAN_Init function. Code sample: CAN_ConfigurePads(0); • Function configures pads for transmission and reception for the CAN module number 0. 3.2 Function CAN_Init The function CAN_Init initializes CANx registers. Prototype: void CAN_Init(uint8_t nbModule); Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 33 Function CAN_Send Table 3-2. CAN_Init Arguments Type uint8_t Name Direction input nbModule Description Number of the CAN module (0 or 1). Include : CAN.h Description : This function initializes specified CAN module with the following parameters: • Number of message buffers - 32. • Crystal oscillator is used as a clock source. • CAN bus speed - 500 kBd (if a 40-MHz crystal is populated). Remark: Clock source from CAN module is configured to be derived directly from the crystal resonator. Code sample: CAN_Init(1); • Function initializes CAN module number 1. 3.3 Function CAN_Send The function CAN_Send sends a frame via CAN bus. Prototype: void CAN_Send(uint8_t nbModule, uint8_t nbBuffer, uint64_t message, uint32_t id); Table 3-3. CAN_Send Arguments Type Name Direction Description uint8_t nbModule input Number of the CAN module (0 or 1). uint8_t nbBuffer input Number of the CAN message buffer (from 0 till 31). uint64_t message input 64-bit message to be sent through CAN bus. uint32_t id input CAN message identifier - 32-bit number that contains standard (11 bits) and extended (18 bits) identifier. Local priority number is placed on the 3 most significant bits in the same register as the IDs. Include : CAN.h Description : This function sends a CAN frame with the specified ID and 8-Byte message. Message can be sent using one of the 32 Message buffers. Remark: CAN module shall be initialized before (see CAN_Init function for details). Code sample: CAN_Send (0,31,0xA0A0A0A0A0A0A0A0, 0x15555555); Basic SW Drivers for MPC5744P, Rev. 1.0 34 Freescale Semiconductor, Inc. Chapter 3 CAN driver • Function sends message 0xA0A0A0A0A0A0A0A0 via CAN module number 0 using 31st message buffer with the following parameters: Local priority: 0 / Standard ID: 0x555 / Extended ID: 0x15555 3.4 Function CAN_Stop The function CAN_Stop disables the CAN message buffer. Prototype: void CAN_Stop(uint8_t nbModule, uint8_t nbBuffer); Table 3-4. CAN_Stop Arguments Type Name Direction Description uint8_t nbModule input Number of the CAN module (0 or 1). uint8_t nbBuffer input Number of the CAN message buffer (from 0 till 31). Include : CAN.h Description : This function clears last transmission flag in the IFLAG1 register and puts the specified message buffer into an Inactive mode. Remark: CAN module shall be initialized before using of this function (see CAN_Init function for details). Code sample: CAN_Stop(0, 31); • Function clears last transmission flag and puts message buffer number 31 of the CAN module number 0 into the Inactive state. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 35 Function CAN_Stop Basic SW Drivers for MPC5744P, Rev. 1.0 36 Freescale Semiconductor, Inc. Chapter 4 DSPI driver DSPI driver provides functions for DSPI module initialization, transmission and reception. 4.1 Function DSPI_Init The function DSPI_Init computes register contents and initializes the DSPIx. Prototype: void DSPI_Init(uint8_t DspiNumber, uint8_t mode, uint32_t sysClk, uint32_t baudRate, uint32_t intMask); Table 4-1. DSPI_Init Arguments Type Name Direction Description uint8_t DspiNumber input - Number of DSPI module (0 or 1 or 2). uint8_t mode input - DSPIx mode configuration (Master or Slave). Predefined values: • MASTER DSPIx will handle communication as a Master. • SLAVE DSPIx will listen to the incoming commands as a Slave. uint32_t sysClk input System clock frequency [Hz]. uint32_t baudRate input Desired baud rate [b/s]. Maximal and minimal Baud rate depends on the actual system clock frequency and on the limits of the PBR and BR registers. Maximal and minimal values for fsys = 16 MHz are shown in the table below, for other frequencies see the external excel file. Predefined values: • min baudRate = 70 b/s for fsys = 16 MHz • max baudRate = 4 000 000 b/s for fsys = 16MHz uint32_t intMask input 32-bit mask allowing us to choose which interruption we want to activate. If no interruption is necessary, please add simply 0 instead of the whole mask. Predefined iterruption masks can be combined arbitrarily using logical OR (|) operator. Predefined value: • TCFRE - Transmission Complete Request Enable flag mask • EOQFRE - Finished Request Enable flag mask Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 37 Function DSPI_Send Table 4-1. DSPI_Init Arguments Type Name Direction Description • TFUFRE - Transmit FIFO Underflow Request Enable flag mask • TFFFRE - Transmit FIFO Fill Request Enable flag mask • RFOFRE - Receive FIFO Overflow Request Enable flag mask • RFDFRE - Receive FIFO Drain Request Enable flag mask Include : DSPI.h Description : This function initializes the DSPIx in specified mode (Master or Slave), computes register configuration to achieve the desired baud rate (if possible) and sets interruption mask. By default, data is changed on a leading edge of DSPI clock and captured on a falling edge (CPHA=1). Inactive state of DSPI clock is set to low by default (CPOL=0). Both parameters are changeable after the init phase using other functions (see setPhaseSPIx and setPolaritySPIx functions for additional information). Remark: System clock frequency should be added in multiples of the basic units (e.g. in kHz, MHz), with respect to the units of a baud rate. Code sample1: DSPI_Init(0, MASTER, 16000000, 4000000, TCFRE); • Command initializes DSPI no. 0 in Master mode with desired baud rate 4 Mbit/s (more exactly 3.81Mbit/s, because 1 Mb/s = 1 048 576 b/s) and activated interruption when transmission is completed. System clock frequency is 16 MHz. Code sample2: DSPI_Init(2, SLAVE, 16, 4, TCFRE | EOQFRE); • Command initializes DSPI no. 2 in Slave mode with desired baud rate 4 Mb/s and activated interruption when transmission is completed and when request is finished. 4.2 Function DSPI_Send The function DSPI_Send sends a 16-bit word through the DSPIx. Prototype: void DSPI_Send(uint8_t DspiNumber, uint8_t CSmask, uint16_t Word); Table 4-2. DSPI_Send Arguments Type Name Direction Description uint8_t DspiNumber input Number of DSPI module (0 or 1 or 2). uint8_t CSmask input Chip Select mask allows us to send a data word only to the specified devices. If a corresponding bit is set, the affected chip select will be used and data will be send to the device Table continues on the next page... Basic SW Drivers for MPC5744P, Rev. 1.0 38 Freescale Semiconductor, Inc. Chapter 4 DSPI driver Table 4-2. DSPI_Send Arguments (continued) Type Name Direction Description activated by this chip select. For details see img. Number of available chip selects differs by module (see table below for details). • DSPI0 can use 6 different chip selects (from PCS0 till PCS5) • DSPI1 can use 5 different chip selects (from PCS0 till PCS4) • DSPI2 can use 4 different chip selects (from PCS0 till PCS3) uint16_t input Word 6bit data word to be send via DSPI. Include : DSPI.h Description : This function sends a Word (16-bit) via DSPIx (DspiNumber) to the device/devices specified by a chip select (CSmask). Remark: In Slave mode chip select mask has no effect. DSPI in a Slave mode listens everytime to the Chip Select no. 0 (communication is controlled by a Master). Function waits until the end of transmission and then clears the Transfer Complete Flag (TCF). DSPI module must be previously initialized (see DSPI_Init function for details). Code sample1: DSPI_Send(0, 0b111111, 0xABBA); • Command sends 16-bit word (0xABBA) via DSPI0 (must be previously configured as a Master) to the Slaves connected on the 6 Chip Selects (no. 0 - 5). Code sample2: DSPI_Send(1, 0, 0xABBA); • Command sends 16-bit word (0xABBA) via DSPI no. 1 (must be previously configured as a Slave). 4.3 Function DSPI_Read The function DSPI_Read reads the incoming 16-bit word from the DSPIx. Prototype: uint32_t DSPI_Read(uint8_t DspiNumber); Table 4-3. DSPI_Read Arguments Type uint8_t Name Direction input DspiNumber Description Number of DSPI module (0 or 1 or 2). Return: 32-bit received data. Include : DSPI.h Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 39 Function DSPI_RoundBaudRate Description : This function waits for incoming data on a specified DSPI (DspiNumber), then clears Receive FIFO Drain Flag (RFDF), Transfer Complete Flag (TCF) and returns received data. Remark: This function waits in a loop until data arrives (indicated by the RFDF flag). The DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_Read(2); • Command reads and returns incoming data from DSPI2, when they are ready. 4.4 Function DSPI_RoundBaudRate The function DSPI_RoundBaudRate is used by the DSPIx Init during the baud rate setting. Prototype: uint32_t DSPI_RoundBaudRate(uint32_t pureBR); Table 4-4. DSPI_RoundBaudRate Arguments Type uint32_t Name Direction input pureBR Description Baud rate to be rounded. Return: Rounded baud rate. Include : DSPI.h Description : This function rounds baud rate. Remark: This function is used during DSPI initialization (DSPI_Init) to compute register setting for the desired baud rate. Code sample: roundedBR= DSPI_RoundBaudRate(pureBR); • Command rounds baud rate that is given through the variable pureBR and returns the new value through the roundedBR variable. 4.5 Function DSPI_Enable The function DSPI_Enable enables transfers in the DSPIx module. Prototype: void DSPI_Enable(uint8_t DspiNumber); Basic SW Drivers for MPC5744P, Rev. 1.0 40 Freescale Semiconductor, Inc. Chapter 4 DSPI driver Table 4-5. DSPI_Enable Arguments Type uint8_t Name Direction input DspiNumber Description Number of DSPI module (0 or 1 or 2). Include : DSPI.h Description : This function starts transfers (HALT bit equals to 0) of the specified DSPI module. Remark: Transfers are enabled by default. DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_Enable(2); • Command starts transfers of DSPI2. 4.6 Function DSPI_Disable The function disables the DSPIx transfer. Prototype: void DSPI_Disable(uint8_t DspiNumber); Table 4-6. DSPI_Disable Arguments Type uint8_t Name DspiNumber Direction input Description Number of DSPI module (0 or 1 or 2). Include : DSPI.h Description : This function stops transfers (HALT bit equals to 1) of the specified DSPI module. Remark: Transfers are enabled by default. DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_Disable(0); • Command stops transfers of DSPI0. 4.7 Function DSPI_ChangeBaudRateType The function DSPI_ChangeBaudRateType changes type of the baud rate for the DSPIx. Prototype: void DSPI_ChangeBaudRateType(uint8_t DspiNumber, uint8_t typeBR); Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 41 Function DSPI_ChangeFrameSize Table 4-7. DSPI_ChangeBaudRateType Arguments Type Name Direction Description uint8_t DspiNumber input Number of DSPI module (0 or 1 or 2). uint8_t typeBR input Setting for the DBR bit: • "0" - The baud rate is computed normally with a 50/50 duty cycle. • "1" - The baud rate is doubled with the duty cycle depending on the Baud Rate Prescaler. Include : DSPI.h Description : This function changes Double Baud Rate (DBR) parameter setting for the DSPIx. Remark: DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_ChangeBaudRateType(0, 1); • Baud rate of the DSPI0 will be doubled with the duty cycle depending on the baud rate prescaler. 4.8 Function DSPI_ChangeFrameSize the function DSPI_ChangeFrameSize changes a frame size for the DSPIx. Prototype: void DSPI_ChangeFrameSize(uint8_t DspiNumber, uint8_t frameSize); Table 4-8. DSPI_ChangeFrameSize Arguments Type Name Direction Description uint8_t DspiNumber input Number of DSPI module (0 or 1 or 2). uint8_t frameSize input Desired frame size in bits (min. 4, max. 16). Include : DSPI.h Description : This function changes frame size for the DSPIx. Remark: DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_ChangeFrameSize(1, 16); • Changes frame size for DSPI1 module to 16 bits. Basic SW Drivers for MPC5744P, Rev. 1.0 42 Freescale Semiconductor, Inc. Chapter 4 DSPI driver 4.9 Function DSPI_SetPhase The function DSPI_SetPhase changes phase of the DSPIx clock. Prototype: void DSPI_SetPhase(uint8_t DspiNumber, uint8_t phase); Table 4-9. DSPI_SetPhase Arguments Type Name Direction Description uint8_t DspiNumber input Number of DSPI module (0 or 1 or 2). uint8_t phase input Number to be written to the CPHA (Clock Phase) bit. Predefined values: • CAPTURE_RISING - data will be captured on a rising edge and changed on a falling edge of the DSPI clock • CAPTURE_FALLING - data will be captured on a falling edge and captured on a rising edge of the DSPI clock Include : DSPI.h Description : This function changes clock phase for the DSPI module (DspiNumber). Remark: DSPI is configured by default with the following parameters: data is changed on a rising edge and captured on a falling edge (CPHA=1) of the DSPI clock . Code sample: DSPI_SetPhase(0, CAPTURE_RISING); • Command sets CPHA bit to 0 for DSPI0 (data will be captured on a rising edge and changed on a falling edge of the DSPI0 clock). 4.10 Function DSPI_SetPolarity The function DSPI_SetPolarity changes polarity of the DSPIx clock. Prototype: void DSPI_SetPolarity(uint8_t DspiNumber, uint8_t polarity); Table 4-10. DSPI_SetPolarity Arguments Type Name Direction Description uint8_t DspiNumber input Number of DSPI module (0 or 1 or 2). uint8_t polarity input Number to be written to the CPOL (Clock Polarity) bit. Predefined values: • DSPI_SetPhase(0, CAPTURE_RISING); • Command sets CPHA bit to 0 for DSPI0 (data will be captured on a rising edge and changed on a falling edge of the DSPI0 clock). Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 43 Function DSPI_EnableTxFIFO Include : DSPI.h Description : This function changes clock polarity for the DSPI module (DspiNumber). Remark: Inactive state of the DSPI clock is set to low by default (CPOL=0). Phase and clock polarity must be set in the same way in both Master and Slave devices. DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_SetPolarity(1, HIGH_SCK); • Command sets CPOL bit to 1 (inactive state of SCK will be high). 4.11 Function DSPI_EnableTxFIFO The function DSPI_EnableTxFIFO enables FIFO for the transmitter of the DSPIx. Prototype: void DSPI_EnableTxFIFO(uint8_t DspiNumber); Table 4-11. DSPI_EnableTxFIFO Arguments Type uint8_t Name Direction input DspiNumber Description Number of DSPI module (0 or 1 or 2). Include : DSPI.h Description : This function changes clock polarity for the DSPI module (DspiNumber). Remark: Tx FIFO is disabled by default. DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_EnableTxFIFO(1); • Command enables FIFO for the transmitter of DSPI1. 4.12 Function DSPI_DisableTxFIFO The function DSPI_DisableTxFIFO disables FIFO for the DSPIx transmitter. Prototype: void DSPI_DisableTxFIFO(uint8_t DspiNumber); Table 4-12. DSPI_DisableTxFIFO Arguments Type uint8_t Name DspiNumber Direction input Description Number of DSPI module (0 or 1 or 2). Basic SW Drivers for MPC5744P, Rev. 1.0 44 Freescale Semiconductor, Inc. Chapter 4 DSPI driver Include : DSPI.h Description : This function disables FIFO for transmitter of the specified DSPI module. Remark: Tx FIFO is disabled by default. DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_DisableTxFIFO(2); • Command disables FIFO for the transmitter of DSPI2. 4.13 Function DSPI_EnableRxFIFO The function DSPI_EnableRxFIFO enables FIFO for the DSPIx receiver. Prototype: void DSPI_EnableRxFIFO(uint8_t DspiNumber); Table 4-13. DSPI_EnableRxFIFO Arguments Type uint8_t Name Direction input DspiNumber Description Number of DSPI module (0 or 1 or 2). Include : DSPI.h Description : This function enables FIFO for receiver of the specified DSPI module. Remark: Rx FIFO is disabled by default. DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_EnableRxFIFO(0); • Command enables FIFO for the receiver of DSPI0. 4.14 Function DSPI_DisableRxFIFO The function DSPI_DisableRxFIFO disables FIFO for the DSPIx receiver. Prototype: void DSPI_DisableRxFIFO(uint8_t DspiNumber); Table 4-14. DSPI_DisableRxFIFO Arguments Type uint8_t Name DspiNumber Direction input Description Number of DSPI module (0 or 1 or 2). Include : DSPI.h Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 45 Function DSPI_SendWithInt Description : This function disables FIFO for receiver of the specified DSPI module. Remark: Rx FIFO is disabled by default. DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_EnableRxFIFO(0); • Command enables FIFO for the receiver of DSPI0. 4.15 Function DSPI_SendWithInt The function DSPI_SendWithInt sends a 16-bit word through the DSPIx (used with interrupt service routine). Prototype: void DSPI_SendWithInt(uint8_t DspiNumber, uint8_t CSmask, uint16_t Word); Table 4-15. DSPI_SendWithInt Arguments Type Name Direction Description uint8_t DspiNumber input Number of DSPI module (0 or 1 or 2). uint8_t CSmask input Chip Select mask allows us to send a data word only to the specified devices. If a corresponding bit is set, the affected chip select will be used and data will be send to the device activated by this chip select. For details see img. Number of available chip selects differs by module (see table below for details). • DSPI0 can use 6 different chip selects (from PCS0 till PCS5) • DSPI1 can use 5 different chip selects (from PCS0 till PCS4) • DSPI2 can use 4 different chip selects (from PCS0 till PCS3) uint16_t Word input 16bit data word to be send via DSPI. 19072011 new functions added -> NOT tested___________________________________________________________________ ____________ Include : DSPI.h Description : This function sends a Word (16-bit) via DSPIx (DspiNumber) to the device/devices specified by a chip select (CSmask). Function shall be used when an interrupt service routine launched by the Transfer Complete Flag (TCF) is configured. Basic SW Drivers for MPC5744P, Rev. 1.0 46 Freescale Semiconductor, Inc. Chapter 4 DSPI driver Remark: In the Slave mode, the chip select mask has no effect. DSPI in a Slave mode listens to the Chip Select no. 0 (communication is controlled by a Master). Function does not wait for the end of transmission -> the TCF flag should be cleared in its interrupt service routine. DSPI module must be previously initialized (see DSPI_Init function for details). (see DSPI_Init function for details). Code sample1: DSPI_SendWithInt(0, 0b111111, 0xABBA); • Command sends 16-bit word (0xABBA) via DSPI0 (must be previously configured as a Master) to the Slaves connected on the 6 Chip Selects (no. 0 - 5). Code sample2: DSPI_SendWithInt(1, 0, 0xABBA); • Command sends 16-bit word (0xABBA) via DSPI no. 1 (must be previously configured as a Slave). 4.16 Function DSPI_ReadWithInt The function DSPI_ReadWithInt reads the incoming 16-bit word from DSPI (used with interrupt service routine). Prototype: uint32_t DSPI_ReadWithInt(uint8_t DspiNumber); Table 4-16. DSPI_ReadWithInt Arguments Type uint8_t Name Direction input DspiNumber Description Number of DSPI module (0 or 1 or 2). Return: 32-bit received data. Include : DSPI.h Description : This function waits for incoming data on a specified DSPI (DspiNumber), then clears Transfer Complete Flag (TCF) and returns received data. Function does not clear Receive FIFO Drain Flag (RFDF). This function shall be used in the RFDF interrupt service routine. Remark: Function waits at first for the data (RFDF flag), so the function will be waiting in a loop until the data will arrive. DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_ReadWithInt(2); • Command reads and return incoming data from DSPI2, when they are ready. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 47 Function DSPI_ClearRFDF 4.17 Function DSPI_ClearRFDF The function DSPI_ClearRFDF clears RFDF flag of the DSPIx. Prototype: void DSPI_ClearRFDF(uint8_t DspiNumber); Table 4-17. DSPI_ClearRFDF Arguments Type uint8_t Name Direction input DspiNumber Description Number of DSPI module (0 or 1 or 2). Return: 32-bit received data. Include : DSPI.h Description : This function clears Receive FIFO Drain Flag (RFDF). This function should be used in the end of the RFDF interrupt routine. Remark: DSPI module must be previously initialized (see DSPI_Init function for details). Code sample: DSPI_ClearRFDF(0); • Command clears RFDF flag in the DSPI0 module. Basic SW Drivers for MPC5744P, Rev. 1.0 48 Freescale Semiconductor, Inc. Chapter 5 FCCU driver Fault Collection and Control Unit (FCCU) driver enables to configure protocol of the FCCU module and to generate fake faults for FCCU testing. 5.1 Function FCCU_SetProtocol The function FCCU_SetProtocol sets protocol for the FCCU's safety output pins. Prototype: void FCCU_SetProtocol(uint32_t protocol); Table 5-1. FCCU_SetProtocol Arguments Type uint32_t Name protocol Direction input Description Protocol that will be used by the FCCU_F pins. Predefined values: • FCCU_RAIL 0b000 • FCCU_TIME_SWITCHING 0b001 • FCCU_BI_STABLE 0b010 • FCCU_TEST0 0b101 • FCCU_TEST1 0b110 • FCCU_TEST2 0b111 Include : FCCU.h Description : This function sets protocol that will be used to signal actual state of the FCCU via FCCU_F0 and FCCU_F1 pins. Remark: Execution of this function should not be interrupt by any event (e.g. break point). Function must be executed in the real time in one sequence, otherwise time delays for using access keys will be applied and protocol will not be changed. Code sample: FCCU_SetProtocol(FCCU_BI_STABLE); • Command sets bistable protocol for the FCCU_Fx pins. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 49 Function FCCU_SetProtocol Basic SW Drivers for MPC5744P, Rev. 1.0 50 Freescale Semiconductor, Inc. Chapter 6 INTC driver INTC driver enables to initialize the interrupt controller. 6.1 Function INTC_InstallINTCInterruptHandler The function INTC_InstallINTCInterruptHandler installs an interrupt handler into the vector table. Prototype: void INTC_InstallINTCInterruptHandler(INTCInterruptFn handlerFn, unsigned short vectorNum, unsigned char psrPriority); Include: : INTC.h Description: : This function installs interrupt handler into the vector table and sets its priority. Remark: 6.2 Function INTC_Init The function INTC_Init initializes Interrupt Controller (INTC). Prototype: void INTC_Init(void); Include : INTC.h Description : This function initializes interrupts in the core, in the Interrupt Controller (INTC) and registers interrupt service routines for PIT, SIUL, ADC and LINFLEX_UART modules. Remark: Interrupt vector for each module is chosen depending on the actual setting that is made in external files. Code sample: INTC_Init(); Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 51 Function INTC_Init • Command initializes interrupt controller and registers interrupt service routines. Basic SW Drivers for MPC5744P, Rev. 1.0 52 Freescale Semiconductor, Inc. Chapter 7 LINFLEX driver LINFLEX driver covers functionality of UART and LIN interfaces that are both implemented in this module. Only one of these interfaces can be used in one time. 7.1 Function LINFLEX_ChangeBaudRate The function LINFLEX_ChangeBaudRate changes a baud rate to the desired one (if the value is in the specified range). Prototype: void LINFLEX_ChangeBaudRate(vuint8_t nbLINFlex, double sysClk, uint32_t baudRate); Table 7-1. LINFLEX_ChangeBaudRate Arguments Type Name Direction Description vuint8_t nbLINFlex input Number of LINFlex module (0 or 1). double sysClk input System clock frequency [Hz]. uint32_t baudRate input Desired baud rate [b/s]. Maximal and minimal baud rate depend on the actual system clock frequency and on the limits of LINIBRR and LINFBRR registers. * Include : DSPI.h Description : This function computes settings of LINIBRR and LINFBRR registers for a specified LINFlex module (nbLINFlex) with respect to a system clock (sysClk) and desired baud rate (baudRate). Remark: If an internal RC oscillator is used as a system clock, then its calibration is recommended before use of LINFlex module (see calibrateRC function for details). Value obtained from the calibration should be directly added in the floating point format as a parameter to the LINFLEX_InitUART function. If the calibration will not be done, bus timing with RC oscillator should not be exact and communication shall generate errors. LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 53 Function LINFLEX_ConfigurePads Code sample1: LINFLEX_ChangeBaudRate(1, 40000000.0, 600); • Command changes content of the LINFlex1 registers (LINIBRR, LINFBRR) to set up baud rate 600 b/s with respect to the 40 MHz clock frequency. In this case an XTAL oscillator is used. Code sample2 : LINFLEX_ChangeBaudRate(1, RCfrequency, 19200); • Command changes content of the LINFlex1 registers (LINIBRR, LINFBRR) to set up baud rate 19200 b/s with respect to the real frequency of RC oscillator. RCfrequency parameter is a real frequency of RC oscillator obtained from its previous calibration. 7.2 Function LINFLEX_ConfigurePads The function LINFLEX_ConfigurePads configures the I/O pads used for communication. Prototype: void LINFLEX_ConfigurePads(vuint8_t nbLINFlex); Table 7-2. LINFLEX_ConfigurePads Arguments Type vuint8_t Name nbLINFlex Direction input Description Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function is used by the init function to configure LINFLex I/O pins (Rx and Tx). Default pin mapping is used, but can be changed directly in the function. Default pin mapping: • LINFLEX0 TxD = PB2 / RxD = PB7 • LINFLEX1 TxD = PD9 / RxD = PB13 Remark: This function is used only once by the initialization function (LINFLEX_InitUART) so in standard operation user does not need to use it directly. LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: LINFLEX_ConfigurePads(0); • Command configures I/O pads as Rx/Tx for LINFLex0. 7.3 Function LINFLEX_Sleep The function LINFLEX_Sleep requests the sleep mode for the LINFlex module. Basic SW Drivers for MPC5744P, Rev. 1.0 54 Freescale Semiconductor, Inc. Chapter 7 LINFLEX driver Prototype: void LINFLEX_Sleep(vuint8_t nbLINFlex); Table 7-3. LINFLEX_Sleep Arguments Type vuint8_t Name Direction input nbLINFlex Description Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function requests Sleep mode by setting SLEEP bit in the LINCR1 register. Remark: Sleep mode should be activated when LINFlex module is not currently in use to decrease consumption. LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: LINFLEX_Sleep(1); • Requests Sleep mode for LINFlex1. 7.4 Function LINFLEX_WakeUp The function LINFLEX_WakeUp wakes-up the LINFlex module from the Sleep mode. Prototype: void LINFLEX_WakeUp(vuint8_t nbLINFlex); Table 7-4. LINFLEX_WakeUp Arguments Type vuint8_t Name nbLINFlex Direction input Description - Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function wakes up specified LINFlex module from Sleep mode by clearing SLEEP bit in LINCR1 register. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: LINFLEX_WakeUp(0); • Wakes up LINFlex0 from Sleep mode. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 55 Function LINFLEX_DisableRxUART 7.5 Function LINFLEX_DisableTxUART The function LINFLEX_DisableTxUART disables UART's transmitter. Prototype: void LINFLEX_DisableTxUART(vuint8_t nbLINFlex); Table 7-5. LINFLEX_DisableTxUART Arguments Type vuint8_t Name Direction input nbLINFlex Description Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function disables UART transmitter for specified LINFlex module by clearing TXEN bit in UARTCR register. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: LINFLEX_DisableTxUART(1); • Command disables UART transmitter of LINFlex1. 7.6 Function LINFLEX_DisableRxUART The function LINFLEX_DisableRxUART disables UART's receiver. Prototype: void LINFLEX_DisableRxUART(vuint8_t nbLINFlex); Table 7-6. LINFLEX_DisableRxUART Arguments Type vuint8_t Name nbLINFlex Direction input Description Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function disables UART receiver for specified LINFlex module by clearing RXEN bit in UARTCR register. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: LINFLEX_DisableRxUART(0); • Command disables UART receiver of LINFlex0. Basic SW Drivers for MPC5744P, Rev. 1.0 56 Freescale Semiconductor, Inc. Chapter 7 LINFLEX driver 7.7 Function LINFLEX_EnableTxUART The function LINFLEX_EnableTxUART enables UART's transmitter. Prototype: void LINFLEX_EnableTxUART(vuint8_t nbLINFlex); Table 7-7. LINFLEX_EnableTxUART Arguments Type vuint8_t Name Direction input nbLINFlex Description Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function enables UART transmitter for specified LINFlex module by setting TXEN bit in UARTCR register. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: LINFLEX_EnableTxUART(1); • Command enables UART transmitter of LINFlex1. 7.8 Function LINFLEX_EnableRxUART The function LINFLEX_EnableRxUART enables UART's receiver. Prototype: void LINFLEX_EnableRxUART(vuint8_t nbLINFlex); Table 7-8. LINFLEX_EnableRxUART Arguments Type vuint8_t Name nbLINFlex Direction input Description Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function enables UART receiver for specified LINFlex module by setting RXEN bit in UARTCR register. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: LINFLEX_EnableRxUART(0); • Command enables UART receiver of LINFlex0. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 57 Function LINFLEX_EnableInt 7.9 Function LINFLEX_EnableInt The function LINFLEX_EnableInt enables LINFlex interruptions. Prototype: void LINFLEX_EnableInt(vuint8_t nbLINFlex); Table 7-9. LINFLEX_EnableInt Arguments Type vuint8_t Name Direction input nbLINFlex Description Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function enables all interrupt flags (in the LINIER register) associated with the specified LINFlex module. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: LINFLEX_EnableInt(1); • Command enables all interrupts for LINFlex1. 7.10 Function LINFLEX_InitUART The function LINFLEX_InitUART initializes the UART module. Prototype: void LINFLEX_InitUART(vuint8_t nbLINFlex, double sysClk, uint32_t baudRate); Table 7-10. LINFLEX_InitUART Arguments Type Name Direction Description vuint8_t nbLINFlex input Number of LINFlex module (0 or 1). double sysClk input System clock sysClk [Hz]. uint32_t baudRate input Desired baud rate [b/s]. Maximal and minimal baud rate depends on the actual system clock sysClk and on the limits of the LINIBRR and LINFBRR registers (for additional information see LINFlex_ChangeBaudRate function). Include : DSPI.h Description : This function initializes the LINFlex module specified by the index (nbLINFlex) for UART communication. On the beginning, the input and output pins are initialized (using configurePadsLINFlex function), then the main LINFlex registers are Basic SW Drivers for MPC5744P, Rev. 1.0 58 Freescale Semiconductor, Inc. Chapter 7 LINFLEX driver configured, the baud rate is computed and set (using changeBaudRateLINFlex function), and the input (receiver) buffer is initialized to the size of four bytes. Communication has the following parameters by default: no parity, one stop bit, and 8-bit data word. Remark: Calibration is recommended if an internal RC oscillator is used as a system clock. Code sample1: LINFLEX_UART_Init(1, 40000000.0, 600); • Command initializes UART module no. 1 with respect to the 40 MHz system clock sysClk and the desired baud rate 600 b/s. Code sample2: LINFLEX_UART_Init(0, 40000000.0, 115200); • Command initializes UART module no. 0 with respect to the 40 MHz system clock sysClk and the desired baud rate 115 200 b/s. 7.11 Function LINFLEX_InitRxBuffer The function LINFLEX_InitRxBuffer initializes and changes size of the input buffer. Prototype: void LINFLEX_InitRxBuffer(vuint8_t nbLINFlex, int8_t nbBytes); Table 7-11. LINFLEX_InitRxBuffer Arguments Type Name Direction Description vuint8_t nbLINFlex input Number of LINFlex module (0 or 1). int8_t nbBytes input Preferred size of reception buffer in Bytes. In UART mode minimal size of the buffer is 1, maximal 4 Bytes. Include : DSPI.h Description : This function initializes size of the input (reception) buffer. By default this function is used during init phase, where the buffer is initialized to a size of 4 Bytes (32 bits). Remark: The size of the input buffer affirms when a Data Reception Completed Flag (DRF) sets. The flag sets only when the input buffer is full (received data is equal to its size). The LINFlex module should be activated before using this function (see LINFLEX_InitUART function for details). Code sample: LINFLEX_InitRxBuffer(0, 4); • Size of input buffer of the LINFlex0 module will be set to 4 Bytes. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 59 Function LINFLEX_ReadUART 7.12 Function LINFLEX_SendUART The function LINFLEX_SendUART sends a data packet through the UART. Prototype: void LINFLEX_SendUART(vuint8_t nbLINFlex, uint8_t *p_tx, uint8_t nbBytes); Table 7-12. LINFLEX_SendUART Arguments Type Name Direction Description vuint8_t nbLINFlex input Number of LINFlex module (0 or 1). uint8_t * p_tx input Pointer to the data to be sent. uint8_t nbBytes input Defines how many Bytes of data are given to be sent. Include : DSPI.h Description : This function sends n data Bytes through the specified LINFLex UART module. It sets the output buffer size, reads the data from the location specified by a pointer (p_tx), and then waits for the end of transmission (indicated by a DTF - Data Transmission Completed Flag). The DTF flag is cleared to prepare for the next operation. Remark: Data should be organized e.g. in an array of Bytes and p_tx should contain address of the first item. Data Bytes will be sent in the same order as they are stocked in the memory. LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample : uint8_t data[4]; data[0] = 'E'; data[1] = 'a'; data[2] = 's'; data[3] = 'y'; LINFLEX_InitUART(1, 40000000.0, 600); LINFLEX_SendUART (1, &data[0], 4); • This sample of code will send a word ("Easy") via LINFlex1 UART. Data bytes will be sent in the same order as they are in the memory (first sent will be letter "E"). 7.13 Function LINFLEX_ReadUART The function LINFLEX_ReadUART reads the received data from the UART buffer. Basic SW Drivers for MPC5744P, Rev. 1.0 60 Freescale Semiconductor, Inc. Chapter 7 LINFLEX driver Prototype: void LINFLEX_ReadUART(vuint8_t nbLINFlex, int8_t nbBytes, uint8_t *response); Table 7-13. LINFLEX_ReadUART Arguments Type Name Direction Description vuint8_t nbLINFlex input Number of LINFlex module (0 or 1). int8_t nbBytes input Length of data to be read from input buffer. uint8_t * response output Pointer to the beginning of data block, where received data will be stored. Data block must be allocated before (e.g. Byte array should be used). Include : DSPI.h Description : This function reads specified length of received data from input buffer and stores them in memory allocated by a user. Memory must be accessible using a pointer (response). Remark: Function should be used when the data is available e.g. in an interruption routine or just simply by testing a flag as shown in the example below. Data will be stored in the memory in the same order as they arrived. LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: uint8_t data[4]; LINFLEX_InitUART(1, 40000000.0, 600); while(LINFLEX_GetReceiveFlagUART(1)==0); LINFLEX_ReadUART (1, 4, &data[0]); LINFLEX_ClearReceiveFlagUART(1); • This sample of code will wait for input data (4 Bytes). When data arrives (indicated by Data Reception Completed Flag - DRF), data will be read, stored in data array and receive flag will be cleared. 7.14 Function LINFLEX_GetReceiveFlagUART The function LINFLEX_GetReceiveFlagUART returns the UART's reception flag. Prototype: uint32_t LINFLEX_GetReceiveFlagUART(vuint8_t nbLINFlex); Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 61 Function LINFLEX_ClearReceiveFlagUART Table 7-14. LINFLEX_GetReceiveFlagUART Arguments Type vuint8_t Name Direction input nbLINFlex Description Number of LINFlex module (0 or 1). Return: Function returns DRF - Data Reception Completed Flag. Include : DSPI.h Description : This function returns DRF - Data Reception Completed Flag from UARTSR register. This should be e.g. used simply in while cycle to wait for available data. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: while(LINFLEX_GetReceiveFlagUART(1)==0); • Command simply waits for received data on LINFlex1. If the data arrives program will continue in its execution. 7.15 Function LINFLEX_ClearReceiveFlagUART The function LINFLEX_ClearReceiveFlagUART clears the UART's reception flag. Prototype: void LINFLEX_ClearReceiveFlagUART(vuint8_t nbLINFlex); Table 7-15. LINFLEX_ClearReceiveFlagUART Arguments Type vuint8_t Name nbLINFlex Direction input Description Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function clears DRF (Data Reception Completed Flag) and RMB (Release Message Buffer) in UARTSR register. Remark: Function should be used everytime after data read (after LINFLEX_GetReceiveFlagUART function) to clear input buffer and to prepare receiver for new data. LINFlex module should be activated before use of this function (see LINFLEX_InitUART function for details). Code sample: LINFLEX_ClearReceiveFlagUART(0); • Command clears DRF and RMB flag bits for LINFlex0. Basic SW Drivers for MPC5744P, Rev. 1.0 62 Freescale Semiconductor, Inc. Chapter 7 LINFLEX driver 7.16 Function LINFLEX_EnableDRFint The function LINFLEX_EnableDRFint enables an interrupt activated when the data is received. Prototype: void LINFLEX_EnableDRFint(vuint8_t nbLINFlex); Table 7-16. LINFLEX_EnableDRFint Arguments Type vuint8_t Name Direction input nbLINFlex Description Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function enables interrupt on the reception (DRIE - Data Reception Complete Interrupt Enable). Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). Code sample: LINFLEX_EnableDRFint(0); • Command enables interrupt on the reception for the LINFLEX no. 0. 7.17 Function LINFLEX_GetParityErrorUART The function LINFLEX_GetParityErrorUART checks if an error in the parity has been detected. Prototype: uint32_t LINFLEX_GetParityErrorUART(vuint8_t nbLINFlex); Table 7-17. LINFLEX_GetParityErrorUART Arguments Type vuint8_t Name nbLINFlex Direction input Description Number of LINFlex module (0 or 1). Return: Function returns four parity error flags in one register. Include : DSPI.h Description : This function returns PE - Parity Error Flags Rx. Remark: All four Parity Error flags PE3, PE2, PE1, PE0 are returned in one register. PE0 is placed on the least significant bit. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 63 Function LINFLEX_ClearParityError Code sample: error = LINFLEX_GetParityErrorUART(1); • Command returns state of parity bits for all received Bytes in the LINFLEX module no. 1 and stores it in the error variable. 7.18 Function LINFLEX_ClearParityError The function LINFLEX_ClearParityError clears the parity error flag. Prototype: void LINFLEX_ClearParityError(vuint8_t nbLINFlex); Table 7-18. LINFLEX_ClearParityError Arguments Type vuint8_t Name Direction input nbLINFlex Description Number of LINFlex module (0 or 1). Include : DSPI.h Description : This function clears all PE - Parity Error Flags. Remark: All four Parity Error flags PE0, PE1, PE2, PE3 are cleared in the same time. Code sample: LINFLEX_ClearParityError(0); • Command clears all parity flags in the PE register for module no.0. 7.19 Function LINFLEX_IsIdle The function LINFLEX_IsIdle checks whether module is in the IDLE state or not. Prototype: uint32_t LINFLEX_IsIdle(vuint8_t nbLINFlex); Table 7-19. LINFLEX_IsIdle Arguments Type vuint8_t Name nbLINFlex Direction input Description Number of LINFlex module (0 or 1). Return: Returns 1 if the LINFlex module is id IDLE state, otherwise 0. Include : DSPI.h Description : This function checks if the LINFlex module is in IDLE state. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). Basic SW Drivers for MPC5744P, Rev. 1.0 64 Freescale Semiconductor, Inc. Chapter 7 LINFLEX driver Code sample: LINFLEX_IsIdle(1); • Command returns 1 if the UART of the LINFLEX1 is in the IDLE state. 7.20 Function LINFLEX_InitLIN The function LINFLEX_InitLIN initializes the LIN module. Prototype: void LINFLEX_InitLIN(vuint8_t nbLINFlex, double sysClk, uint32_t baudRate, uint8_t mode); Table 7-20. LINFLEX_InitLIN Arguments Type Name Direction Description vuint8_t nbLINFlex input Number of LINFlex module (0 or 1). double sysClk input System clock sysClk [Hz]. uint32_t baudRate input Desired baud rate [b/s]. Maximal and minimal baud rate depends on the actual system clock sysClk and on the limits of the LINIBRR and LINFBRR registers (for additional information see LINFlex_ChangeBaudRate function). uint8_t mode input Desired mode - Master or Slave. Predefined values: • "MASTER" - LIN will be a Master • "SLAVE" - LIN will be a Slave Include : DSPI.h Description : This function initializes LINFlex module specified by index (nbLINFlex) for LIN communication. On the beginning input and output pins are initialized (using LINFLEX_ConfigurePads function), then main LINFlex registers are configured, baud rate is computed and set (using LINFLEX_ChangeBaudRate function). Module will be set into a Master or Slave mode (mode parameter). Remark: If internal RC oscillator is used as a system clock, then its calibration is recommended (see calibrateRC function for details). Then the value obtained from the calibration should be directly added in the floating point format as a parameter of the LINFLEX_UART_Init function. This will allow init function to compute baud rate registers more precisely. Code sample1: LINFLEX_InitLIN(1, 40000000.0, 600, MASTER); Command initializes LIN module no. 1 as a Master with respect to the 40 MHz system clock sysClk and the desired baud rate 600 b/s. Code sample2: LINFLEX_InitLIN(0, 40000000.0, 115200, SLAVE); Command initializes LIN module no. 0 as a Slave with respect to the 40 MHz system clock sysClk and the desired baud rate 115 200 b/s. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 65 Function LINFLEX_SendFrameLIN 7.21 Function LINFLEX_SendFrameLIN The function LINFLEX_SendFrameLIN sends a full LIN frame (header + data). Prototype: void LINFLEX_SendFrameLIN(vuint8_t nbLINFlex, uint8_t *p_tx, uint8_t nbBytes, uint8_t ID); Table 7-21. LINFLEX_SendFrameLIN Arguments Type Name Direction Description vuint8_t nbLINFlex input Number of LINFlex module (0 or 1). uint8_t * p_tx input Pointer to the data to be sent. uint8_t nbBytes input Defines how many Bytes of data are given to be sent. uint8_t ID input Header frame identifier (from 0 up to 15). Header frame is normally coded on 6 bits, which means 64 possible combinations divided into 4 classes. Then 4 bits mean identifier number and 2 bits number of data Bytes (see the image above). Exceptional are identifiers from 0x3C till 0x3F (see LIN specification for details). Include : DSPI.h Description : LINFLEX_SendFrameLIN sends a full LIN frame (header + data) via the LIN if configured as a Master. Two associated registers (BDRL and BDRM) are fed from the memory (beginning specified by p_tx pointer). The ID is modified with the data length (coded on two bits as shown below) and BIDR register is set. Next, the frame is sent by setting the HTRQ bit in the LINCR2 register (up to 8 data Bytes should be sent in a one frame). The function waits for the end of data transmission (DTF flag in LINSR register), then clears the flag and returns. Depending on bit2 and 3, the data frame length is defined as follows: • "00" - 1 Byte • "01" - 2 Bytes • "10" - 4 Bytes • "11" - 8 Bytes Remark: Data should be organized e.g. in an array of Bytes and p_tx should contain address of the first item. Data Bytes will be sent in the same order as they are stocked in the memory. Sending a full frame is possible only if LINFlex module is configured as a Master. LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). Code sample: uint8_t p_array[8]; Basic SW Drivers for MPC5744P, Rev. 1.0 66 Freescale Semiconductor, Inc. Chapter 7 LINFLEX driver p_array[0] = 'H'; p_array[1] = 'e'; p_array[2] = 'l'; p_array[3] = 'l'; p_array[4] = 'o'; p_array[5] = '!'; p_array[6] = '!'; p_array[7] = '!'; LINFLEX_InitLIN(0,40000000,19200,MASTER); LINFLEX_SendFrameLIN (0, (uint8_t*)&p_array, 0x08, 0x02); This sample of code will send a word ("Hello!!!") via LIN bus connected to LINFlex0 module. Data bytes will be sent in the same order as they are in the memory (first sent will be letter "H"). 7.22 Function LINFLEX_SendHeaderLIN The function LINFLEX_SendHeaderLIN sends a LIN header. Prototype: void LINFLEX_SendHeaderLIN(vuint8_t nbLINFlex, uint8_t nbBytes, uint8_t ID); Table 7-22. LINFLEX_SendHeaderLIN Arguments Type Name Direction Description vuint8_t nbLINFlex input Number of LINFlex module (0 or 1). uint8_t nbBytes input Defines how many Bytes of data are given to be sent. uint8_t ID input Header frame identifier (from 0 up to 15). Header frame is normally coded on 6 bits, which means 64 possible combinations divided into 4 classes. Then 4 bits mean identifier number and 2 bits number of data Bytes (see the image above). Exceptional are identifiers from 0x3C till 0x3F (see LIN specification for details). Include : DSPI.h Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 67 Function LINFLEX_SendWordUART Description : This function sends LIN frame header if configured as a Master. At first ID is modified to take into account number of data Bytes that will follow in the frame (coded on two bits, see the previous LINFLEX_SendFrameLIN function for details). Then BIDR register is fed up with the transfer parameters/ID and Header Transmission is requested (HTRQ bit in LINCR2 register). Remark: Sending a full frame is possible only if LINFlex module is configured as a Master. LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). Code sample: LINFLEX_InitLIN(0,40000000,19200,MASTER); LINFLEX_SendHeaderLIN(0, 0x08, 0x02); • This sample of code will send a header with ID 0x02 via the LINFlex0 module. 7.23 Function LINFLEX_SendWordUART The function LINFLEX_SendWordUART sends a word via UART. Prototype: void LINFLEX_SendWordUART(vuint8_t nbLINFlex, uint8_t *p_string, uint8_t length); Table 7-23. LINFLEX_SendWordUART Arguments Type Name Direction Description vuint8_t nbLINFlex input - Number of LINFlex module (0 or 1). uint8_t * p_string input - Pointer to the array of Bytes to be sent. uint8_t length input - Number of Bytes to be sent. Include: : LINFLEX.h Description: : This function sends a word consisted of several Bytes via UART. Remark: Function blocks UART as a resource, this could block execution of the main routines if longer frames are sent. 7.24 Function LINFLEX_ReadLIN The function LINFLEX_ReadLIN reads data previously received via LIN. Basic SW Drivers for MPC5744P, Rev. 1.0 68 Freescale Semiconductor, Inc. Chapter 7 LINFLEX driver Prototype: void LINFLEX_ReadLIN(vuint8_t nbLINFlex, int8_t nbBytes, uint8_t *response); Table 7-24. LINFLEX_ReadLIN Arguments Type Name Direction Description vuint8_t nbLINFlex input - Number of LINFlex module (0 or 1). int8_t nbBytes input - Defines how many Bytes of data are given to be read. uint8_t * response output - Pointer to data memory, where the result will be stored. Data memory has to be allocated before use of this function. Include: : DSPI.h Description: : This function reads data previously received via LIN. Remark: Function should be used only if data is available in the input buffer (see LINFLEX_GetReceiveFlagLIN function). LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). 7.25 Function LINFLEX_GetReceiveFlagLIN The function LINFLEX_GetReceiveFlagLIN returns the DRF flag. Prototype: uint32_t LINFLEX_GetReceiveFlagLIN(vuint8_t nbLINFlex); Table 7-25. LINFLEX_GetReceiveFlagLIN Arguments Type vuint8_t Name Direction input nbLINFlex Description - Number of LINFlex module (0 or 1). Return: Function returns DRF - Data Reception Completed Flag. Include: : DSPI.h Description: : This function returns theDRF - Data Reception Completed Flag from the LINSR register. This should be e.g. used simply in while cycle to wait for available data if configured as a Master or a Slave. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). 7.26 Function LINFLEX_ClearReceiveFlagLIN The function clears the DRF flag. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 69 Function LINFLEX_GetHeaderFlagLIN Prototype: void LINFLEX_ClearReceiveFlagLIN(vuint8_t nbLINFlex); Table 7-26. LINFLEX_ClearReceiveFlagLIN Arguments Type vuint8_t Name Direction input nbLINFlex Description - Number of LINFlex module (0 or 1). Include: : DSPI.h Description: : This function clears DRF (Data Reception Completed Flag) in LINSR register. Remark: Function should be used everytime after data read (after LINFLEX_GetReceiveFlagLIN function) to clear input buffer and to prepare receiver for new data. LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). 7.27 Function LINFLEX_GetHeaderFlagLIN The function returns the HRF flag. Prototype: uint32_t LINFLEX_GetHeaderFlagLIN(vuint8_t nbLINFlex); Table 7-27. LINFLEX_GetHeaderFlagLIN Arguments Type vuint8_t Name Direction input nbLINFlex Description - Number of LINFlex module (0 or 1). Return: Function returns HRF - Header Reception Flag. Include: : DSPI.h Description: : This function returns HRF - Header Reception Flag from LINSR register. Function should be used if configured as a Slave to wait for a header. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). 7.28 Function LINFLEX_ClearHeaderFlagLIN The function clears the HRF flag. Prototype: void LINFLEX_ClearHeaderFlagLIN(vuint8_t nbLINFlex); Basic SW Drivers for MPC5744P, Rev. 1.0 70 Freescale Semiconductor, Inc. Chapter 7 LINFLEX driver Table 7-28. LINFLEX_ClearHeaderFlagLIN Arguments Type vuint8_t Name Direction input nbLINFlex Description - Number of LINFlex module (0 or 1). Include: : DSPI.h Description: : This function clears HRF (Header Reception Flag) in LINSR register. Remark: Function should be used everytime when a header has been received and processed (LINFLEX_ReadLINid and LINFLEX_SetReceptionParamLIN functions). In the case when Slave task works as a publisher (will send data Bytes), flag should be cleared after the whole frame (see LIN code examples for details). LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). 7.29 Function LINFLEX_ReadLINid The function reads the received LIN identifier. Prototype: uint32_t LINFLEX_ReadLINid(vuint8_t nbLINFlex); Table 7-29. LINFLEX_ReadLINid Arguments Type vuint8_t Name nbLINFlex Direction input Description - Number of LINFlex module (0 or 1). Return: Returns identifier (ID) of the received frame. Include: : DSPI.h Description: : This function reads identifier (ID) of the received LIN frame. Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). 7.30 Function LINFLEX_SetReceptionParamLIN The function LINFLEX_SetReceptionParamLIN sets parameters of the LINFlex module. Prototype: void LINFLEX_SetReceptionParamLIN(vuint8_t nbLINFlex, uint8_t nbBytes); Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 71 Function LINFLEX_SetReceptionParamLIN Table 7-30. LINFLEX_SetReceptionParamLIN Arguments Type Name Direction Description vuint8_t nbLINFlex input - Number of LINFlex module (0 or 1). uint8_t nbBytes input - Number of data bytes in the LIN frame. Number from 1 till 8 with respect to the LIN specification 2.0). Include: : DSPI.h Description: : This function sets parameters for the LIN receiver as follows: • Enhanced checksum CCS = 0 • Direction - receive DIR = 0 • Data bytes DFL = nbBytes Remark: LINFlex module should be activated before use of this function (see LINFLEX_InitLIN function for details). Basic SW Drivers for MPC5744P, Rev. 1.0 72 Freescale Semiconductor, Inc. Chapter 8 ME driver ME driver enables to configure Mode Entry module of the MCU and to set current mode. 8.1 Function MC_MODE_INIT The function MC_MODE_INIT initializes Mode Entry Module (ME). Prototype: void MC_MODE_INIT(void); Include: : ME.h Description: : This function makes a basic initialization of oscillators and peripherals. After the necessary initialization, the MCU goes into the DRUN mode. Remark: Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 73 Function MC_MODE_INIT Basic SW Drivers for MPC5744P, Rev. 1.0 74 Freescale Semiconductor, Inc. Chapter 9 PIT driver PIT driver covers functionality of the Periodic Interrupt Timer enabling to generate interrupts with precise time period. 9.1 Function PIT_Init The function PIT_Init initializes the Periodic Interrupt Timer. Prototype: void PIT_Init(void); Include : PIT.h Description : This function turns on clock for the PIT module. Remark: In debug mode is the PIT module frozen by default. Code sample: PIT_Init(); • Command activates clock for the PIT module. 9.2 Function PIT_Setup The function PIT_Setup computes and sets up a period for the specified channel. Prototype: void PIT_Setup(int8_t Channel, uint32_t Clock_Freq, double ExpectedTimeBase); Table 9-1. PIT_Setup Arguments Type Name Direction Description int8_t Channel input Number of the PIT's channel (from 0 till 3). uint32_t Clock_Freq input System clock frequency. double ExpectedTimeBase input Desired time period for the specified channel. Include : PIT.h Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 75 Function PIT_EnableInt Description : This function computes register settings from clock frequency and expected time base. Remark: Maximal setable time is given by the maximal value of the 32-bit LDVAL register divided by system the clock frequency ((2^32)/fsys). PIT module should be initialized before (see PIT_Init function). Code sample: PIT_Setup(0, 16000000, 0.010); • Command sets up channel no. 0 of the timer with expected time base 10 ms assuming clock frequency 16 MHz. 9.3 Function PIT_EnableInt The function PIT_EnableInt enables an interrupt for a specified channel. Prototype: void PIT_EnableInt(int8_t Channel); Table 9-2. PIT_EnableInt Arguments Type int8_t Name Direction input Channel Description Number of the PIT's channel (from 0 till 3). Include : PIT.h Description : This function enables an interrupt for a specified channel (sets TIE bit) and clears interrupt flag (TIF) in the same time. Remark: PIT module should be initialized before (see PIT_Init function). Code sample: PIT_EnableInt(1); • Command enables interruption for the first channel of the PIT. 9.4 Function PIT_EnableChannel The function PIT_EnableChannel enables a channel of the PIT. Prototype: void PIT_EnableChannel(int8_t Channel); Table 9-3. PIT_EnableChannel Arguments Type int8_t Name Channel Direction input Description Number of the PIT's channel (from 0 till 3). Basic SW Drivers for MPC5744P, Rev. 1.0 76 Freescale Semiconductor, Inc. Chapter 9 PIT driver Include : PIT.h Description : This function enables specified channel by setting TEN bit. Remark: PIT module should be initialized before (see PIT_Init function). Code sample: PIT_EnableInt(2); • Command enables second channel of the PIT. 9.5 Function PIT_Disable The function PIT_Disable disables a channel of the PIT (including interrupts). Prototype: void PIT_Disable(int8_t Channel); Table 9-4. PIT_Disable Arguments Type int8_t Name Direction input Channel Description Number of the PIT's channel (from 0 till 3). Include : PIT.h Description : This function disables the whole PIT channel. The associated interrupt flag is cleared and the interrupt deisabled in the same time. Remark: PIT module should be initialized before (see PIT_Init function). Code sample: PIT_Disable(3); • Command disables channel no. 3 of the PIT. 9.6 Function PIT_GetFlag The function PIT_GetFlag returns an interrupt flag. Prototype: int8_t PIT_GetFlag(int8_t Channel); Table 9-5. PIT_GetFlag Arguments Type int8_t Name Direction input Channel Description Number of the PIT's channel (from 0 till 3). Return: Time Interrupt Flag. Include : PIT.h Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 77 Function PIT_ClearFlag Description : This function returns the interrupt flag (TIF) of the specified channel. Remark: PIT module should be initialized before (see PIT_Init function). Code sample: while(PIT_GetFlag(3)==0); • Command waits until the PIT channel no. 3 will overflow (Simple waiting without any interruption). 9.7 Function PIT_ClearFlag The function PIT_ClearFlag clears an interrupt flag. Prototype: void PIT_ClearFlag(int8_t Channel); Table 9-6. PIT_ClearFlag Arguments Type int8_t Name Direction input Channel Description Number of the PIT's channel (from 0 till 3). Include : PIT.h Description : This function clears Time Interrupt Flag (TIF) for the specified channel. Remark: PIT module should be initialized before (see PIT_Init function). Code sample: PIT_ClearFlag(0); • Command clears TIF flag of the channel no. 0. 9.8 Function PIT_DisableChannel The function PIT_DisableChannel disables a PIT channel. Prototype: void PIT_DisableChannel(int8_t Channel); Table 9-7. PIT_DisableChannel Arguments Type int8_t Name Channel Direction input Description Number of the PIT's channel (from 0 till 3). Include : PIT.h Description : This function clears Timer Enable Bit (TEN) for the specified PIT channel. Remark: PIT module should be initialized before (see PIT_Init function). Basic SW Drivers for MPC5744P, Rev. 1.0 78 Freescale Semiconductor, Inc. Chapter 9 PIT driver Code sample: PIT_DisableChannel(1); • Command disables first PIT channel. 9.9 Function PIT_IsChannelEnabled The function PIT_IsChannelEnabled checks if a specified PIT channel is enabled. Prototype: uint32_t PIT_IsChannelEnabled(int8_t Channel); Table 9-8. PIT_IsChannelEnabled Arguments Type int8_t Name Channel Direction input Description Number of the PIT's channel (from 0 till 3). Return: Number of the PIT's channel (from 0 till 3). Include : PIT.h Description : This function returns content of the Timer Enable Bit (TEN) for the specified PIT channel. Remark: PIT module should be initialized before (see PIT_Init function). Code sample: res = PIT_IsChannelEnabled(0); • Command returns state of PIT channel number 0. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 79 Function PIT_IsChannelEnabled Basic SW Drivers for MPC5744P, Rev. 1.0 80 Freescale Semiconductor, Inc. Chapter 10 SIUL driver SIUL driver covers functionality of the I/O ports of the MCU. Module enables to configure input and output buffers of the MCU and to control/monitor current state of the specified port. 10.1 Function SIUL_DigitalInput The function SIUL_DigitalInput configures a GPIO pin as a digital input. Prototype: void SIUL_DigitalInput(uint8_t pad, uint8_t pad_in, uint32_t config, uint32_t config_in); Table 10-1. SIUL_DigitalInput Arguments Type uint8_t Name pad Direction input Description Pad to be configured - use either PCR pad number or some predefined name. Predefined values: • "SIUL_PA0" "SIUL_PA1" "SIUL_PA2" • "SIUL_PA3""SIUL_PA4""SIUL_PA5" • "SIUL_PA6""SIUL_PA7""SIUL_PA8" • "SIUL_PA9""SIUL_PA10""SIUL_PA11" • "SIUL_PA12""SIUL_PA13""SIUL_PA14" • "SIUL_PA15" "SIUL_PB0""SIUL_PB1" • "SIUL_PB2" "SIUL_PB3" "SIUL_PB4" • "SIUL_PB5" "SIUL_PB6" "SIUL_PB7" • "SIUL_PB8" "SIUL_PB9" "SIUL_PB10" • "SIUL_PB11" "SIUL_PB12" "SIUL_PB13" • "SIUL_PB14" "SIUL_PB15" "SIUL_PC0" • "SIUL_PC1" "SIUL_PC2" "SIUL_PC3" • "SIUL_PC4" "SIUL_PC5" "SIUL_PC6" • "SIUL_PC7" "SIUL_PC8" "SIUL_PC9" • "SIUL_PC10" "SIUL_PC11" "SIUL_PC12" • "SIUL_PC13" "SIUL_PC14" "SIUL_PC15" • "SIUL_PD0" "SIUL_PD1" "SIUL_PD2" • "SIUL_PD3" "SIUL_PD4" "SIUL_PD5" • "SIUL_PD6" "SIUL_PD7" "SIUL_PD8" • "SIUL_PD9" "SIUL_PD10" "SIUL_PD11" • "SIUL_PD12" "SIUL_PD13" "SIUL_PD14" • "SIUL_PD15" "SIUL_PE0" "SIUL_PE1" Table continues on the next page... Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 81 Function SIUL_DigitalInput Table 10-1. SIUL_DigitalInput Arguments (continued) Type Name Direction Description • • • • • • • • • • • • • • • • • • • • • • • • • • • • "SIUL_PE2" "SIUL_PE3" "SIUL_PE4" "SIUL_PE5" "SIUL_PE6" "SIUL_PE7" "SIUL_PE8" "SIUL_PE9" "SIUL_PE10" "SIUL_PE11" "SIUL_PE12" "SIUL_PE13" "SIUL_PE14" "SIUL_PE15" "SIUL_PF0" "SIUL_PF1" "SIUL_PF2" "SIUL_PF3" "SIUL_PF4" "SIUL_PF5" "SIUL_PF6" "SIUL_PF7" "SIUL_PF8" "SIUL_PF9" "SIUL_PF10" "SIUL_PF11" "SIUL_PF12" "SIUL_PF13" "SIUL_PF14" "SIUL_PF15" "SIUL_PG0" "SIUL_PG1" "SIUL_PG2" "SIUL_PG3" "SIUL_PG4" "SIUL_PG5" "SIUL_PG6" "SIUL_PG7" "SIUL_PG8" "SIUL_PG9" "SIUL_PG10" "SIUL_PG11" "SIUL_PG12" "SIUL_PG13" "SIUL_PG14" "SIUL_PG15" "SIUL_PH0" "SIUL_PH1" "SIUL_PH2" "SIUL_PH3" "SIUL_PH4" "SIUL_PH5" "SIUL_PH6" "SIUL_PH7" "SIUL_PH8" "SIUL_PH9" "SIUL_PH10" "SIUL_PH11" "SIUL_PH12" "SIUL_PH13" "SIUL_PH14" "SIUL_PH15" "SIUL_PI0" "SIUL_PI1" "SIUL_PI2" "SIUL_PI3" "SIUL_PI4" "SIUL_PI5" "SIUL_PI6" "SIUL_PI7" "SIUL_PI8" "SIUL_PI9" "SIUL_PI10" "SIUL_PI11" "SIUL_PI12" "SIUL_PI13" "SIUL_PI14" "SIUL_PI15" "SIUL_PJ0" "SIUL_PJ1" "SIUL_PJ2" "SIUL_PJ3" "SIUL_PJ4" Commented parameter padIn padIn does not exist in function . input Defines number of the IMCR multiplexing register for the used pad. uint32_t input Additional configuration of the specified pad. Use number 0 if no additional configuration is desired. Predefined values: config Include : SIUL.h Description : This function configures specified IO pin as a digital input with different multiplexing options. Pad pull-up/Down resistors • "SIUL_PULL_UP" - Internal pull-up resistor will be used. • "SIUL_PULL_DOWN" - Internal pull-down resistor will be used. • "SIUL_PULL_DIS" - Internal pull-up/down resistors will be disabled. Pad direction • "SIUL_INPUT" - Input buffer will be activated. • "SIUL_OUTPUT" - Output buffer will be activated. • "SIUL_BIDIR" - Input and output buffers will be activated (0x0300). Pad function Basic SW Drivers for MPC5744P, Rev. 1.0 82 Freescale Semiconductor, Inc. Chapter 10 SIUL driver • • • • "SIUL_GPIO" - Pad will be used as an General IO pin. "SIUL_ALT1" - Alternate function no.1 will be used on this pin. "SIUL_ALT2" - Alternate function no.2 will be used on this pin. "SIUL_ALT3" - Alternate function no.3 will be used on this pin. Safe mode control • "SIUL_SMC" 0x4000 Pad type • "SIUL_DIGITAL" - Pin will be configured as a digital one. • "SIUL_ANALOG" - Pin will be configured as an analog one (to be used as an input for ADC). Pad slew rate • "SIUL_SLOW" - Slow slew rate will be used. • "SIUL_FAST" - Fast slew rate will be used. Output type • "SIUL_NORMAL" - Output will be in a Normal (push-pull) configuration. • "SIUL_OPEND" - Output will be in an Open-Drain configuration. Remark: Predefined values can be combined using logical | operator. Code sample: SIUL_DigitalInput(SIUL_PC7, 41, SIUL_PULL_UP | SIUL_SLEW_ENB, SIUL_ALT1); Command sets PC7 pad to be a digital input used as a serial input for the SPI module. Pad is using an internal pull-up resistor. 10.2 Function SIUL_DigitalInputSimple The function SIUL_DigitalInputSimple configures GPIO pin as a digital input. Prototype: void SIUL_DigitalInputSimple(uint8_t pad, uint32_t config); Table 10-2. SIUL_DigitalInputSimple Arguments Type Name Direction Description uint8_t pad input - Pad to be configured - use either MSCR pad number or some predefined name. For predefined values, see the SIUL_DigitalInput function. uint32_t config input - Additional configuration of the specified pad. Use number 0 if no additional configuration is desired. For predefined values, see the SIUL_DigitalInput function. Include: : SIUL.h Description: : This function configures specified IO pin as a digital input. Remark: Predefined values can be combined using logical | operator. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 83 Function SIUL_AnalogInput 10.3 Function SIUL_AnalogInput The function SIUL_AnalogInput configures a GPIO pin as an analog input. Prototype: void SIUL_AnalogInput(uint8_t pad, uint32_t config); Table 10-3. SIUL_AnalogInput Arguments Type Name Direction Description uint8_t pad input Pad to be configured - use either PCR pad number or some predefined name. uint32_t config input Additional configuration of the specified pad. Use number 0 if no additional configuration is desired. Include : SIUL.h Description : This function configures specified IO pin as an analog input. Remark: Predefined values can be combined using logical | operator. Code sample: SIUL_AnalogInput(SIUL_PB7, 0); • Command sets PB7 pin as an analog input with no additional configuration. 10.4 Function SIUL_DigitalOutput The function SIUL_DigitalOutput configures a GPIO pin as a digital output. Prototype: void SIUL_DigitalOutput(uint8_t pad, uint32_t config); Table 10-4. SIUL_DigitalOutput Arguments Type Name Direction Description uint8_t pad input Pad to be configured - use either PCR pad number or some predefined name. uint32_t config input Additional configuration of the specified pad. Use number 0 if no additional configuration is desired. Include : SIUL.h Description : This function configures specified IO pin as a digital output. Remark: Predefined values can be combined using logical | operator. Code sample: SIUL_DigitalOutput(SIUL_PD8, SIUL_ALT1); Basic SW Drivers for MPC5744P, Rev. 1.0 84 Freescale Semiconductor, Inc. Chapter 10 SIUL driver • Command sets pad PD8 as a digital output with its first alternate function. 10.5 Function SIUL_DigitalIO The function SIUL_DigitalIO configures a GPIO pin as an Input/Output. Prototype: void SIUL_DigitalIO(uint8_t pad, uint32_t config); Table 10-5. SIUL_DigitalIO Arguments Type Name Direction Description uint8_t pad input Pad to be configured - use either PCR pad number or some predefined name. uint32_t config input Additional configuration of the specified pad. Use number 0 if no additional configuration is desired. Include : SIUL.h Description : This function configures specified IO pin as a digital Input/Output. Remark: Predefined values can be combined using logical | operator. Code sample: SIUL_DigitalIO(SIUL_PD2,0); • Command sets pad PD2 as a digital Input/Output (both input and output buffers are enabled). 10.6 Function SIUL_ToggleIO The function SIUL_ToggleIO toggles a GPIO pin. Prototype: void SIUL_ToggleIO(uint8_t pad); Table 10-6. SIUL_ToggleIO Arguments Type uint8_t Name pad Direction input Description Pad to be toggled - use either PCR pad number or some predefined name. Include : SIUL.h Description : This function toggles actual state of the specified pad. Remark: Predefined values can be combined using logical | operator. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 85 Function SIUL_EnableExtInt Code sample: SIUL_DigitalIO(SIUL_PD2,0); SIUL_ToggleIO(SIUL_PD2); • First command sets pad PD2 as a digital Input/Output. Second command inverts actual state of the PD2 pad. 10.7 Function SIUL_EnableExtInt The function SIUL_EnableExtInt enables an interrupt for a GPIO pin. Prototype: void SIUL_EnableExtInt(uint32_t maskEIRQ); Table 10-7. SIUL_EnableExtInt Arguments Type uint32_t Name maskEIRQ Direction input Description Mask to specify which EIRQs will be activated. Predefined values: • "SIUL_EIRQ0" • "SIUL_EIRQ1" • "SIUL_EIRQ2" • "SIUL_EIRQ3" • "SIUL_EIRQ4" • "SIUL_EIRQ5" • "SIUL_EIRQ6" • "SIUL_EIRQ7" • "SIUL_EIRQ8" • "SIUL_EIRQ9" • "SIUL_EIRQ10" • "SIUL_EIRQ11" • "SIUL_EIRQ12" • "SIUL_EIRQ13" • "SIUL_EIRQ14" • "SIUL_EIRQ15" • "SIUL_EIRQ16" • "SIUL_EIRQ17" • "SIUL_EIRQ18" • "SIUL_EIRQ19" • "SIUL_EIRQ20" • "SIUL_EIRQ21" • "SIUL_EIRQ22" • "SIUL_EIRQ23" • "SIUL_EIRQ24" • "SIUL_EIRQ25" • "SIUL_EIRQ26" • "SIUL_EIRQ27" • "SIUL_EIRQ28" • "SIUL_EIRQ29" • "SIUL_EIRQ30" • "SIUL_EIRQ31" Basic SW Drivers for MPC5744P, Rev. 1.0 86 Freescale Semiconductor, Inc. Chapter 10 SIUL driver Include : SIUL.h Description : This function enables external interrupt for the specified EIRQ - External Interrupt Request Input specified by its mask. This is done in the IRER - Interrupt Request Enable Register. Remark: Predefined values can be combined using logical | operator. Code sample: SIUL_EnableExtInt(SIUL_EIRQ31); • Command enables external interrupt for the PF13 pad. 10.8 Function SIUL_EnableExtIntRisingEdge The function SIUL_EnableExtIntRisingEdge enables an interrupt on a rising edge. Prototype: void SIUL_EnableExtIntRisingEdge(uint32_t maskEIRQ); Table 10-8. SIUL_EnableExtIntRisingEdge Arguments Type uint32_t Name maskEIRQ Direction input Description Mask to specify for which EIRQs the filter and interrupt will be enabled. Include : SIUL.h Description : This function enables an input filter and interrupt launched on the rising edge. Filter enables e.g. to filter out switching noise, when a button is connected directly to the input without using any special external circuitry. Remark: Predefined values can be combined using logical | operator. Code sample: SIUL_EnableExtIntRisingEdge(64); • Command enables filter and an interrupt on the rising edge for the EIRQ6 - pad PA6. 10.9 Function SIUL_EnableExtIntFallingEdge The function SIUL_EnableExtIntFallingEdge enables an interrupt on a falling edge. Prototype: void SIUL_EnableExtIntFallingEdge(uint32_t maskEIRQ); Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 87 Function SIUL_GetExtIntFlag Table 10-9. SIUL_EnableExtIntFallingEdge Arguments Type uint32_t Name Direction input maskEIRQ Description Mask to specify for which EIRQs the filter and interrupt will be enabled. Include : SIUL.h Description : This function enables an input filter and interrupt launched on the falling edge. Filter enables e.g. to filter out switching noise, when a button is connected directly to the input without using any special external circuitry. Remark: Predefined values can be combined using logical | operator. Code sample: SIUL_EnableExtIntFallingEdge(64); • Command enables filter and an interrupt on the falling edge for the EIRQ6 - pad PA6. 10.10 Function SIUL_GetExtIntFlag The function SIUL_GetExtIntFlag returns the interrupt flag. Prototype: uint32_t SIUL_GetExtIntFlag(uint32_t maskEIRQ); Table 10-10. SIUL_GetExtIntFlag Arguments Type uint32_t Name maskEIRQ Direction input Description Mask to specify for which EIRQs the filter and interrupt will be enabled. Return: Returns interrupt flag from the ISR - Interrupt Status Flag Register. Include : SIUL.h Description : This function returns interrupt flag for the specified EIRQ External Interrupt Request Input. Remark: Predefined values can be combined using logical | operator. Code sample: int_flag = SIUL_GetExtIntFlag(SIUL_EIRQ31); • Command returns and stores interrupt flag for EIRQ31 - pad PF13. Basic SW Drivers for MPC5744P, Rev. 1.0 88 Freescale Semiconductor, Inc. Chapter 10 SIUL driver 10.11 Function SIUL_ClearExtIntFlag The function SIUL_ClearExtIntFlag clears the interrupt flag. Prototype: void SIUL_ClearExtIntFlag(uint32_t maskEIRQ); Table 10-11. SIUL_ClearExtIntFlag Arguments Type uint32_t Name Direction input maskEIRQ Description Mask to specify which EIRQ's flag will be cleared. Include : SIUL.h Description : This function clears interrupt flag in the Interrupt Status Register (ISR) for the specified External Interrupt Request Input (EIRQ). Remark: Predefined values can be combined using logical | operator. Code sample: SIUL_ClearExtIntFlag(SIUL_EIRQ31); • Command clears interrupt flag for EIRQ31 - pad PF13. 10.12 Function SIUL_SetPad The function SIUL_SetPad sets the GPIO pin state (logical HIGH). Prototype: void SIUL_SetPad(uint8_t pad); Table 10-12. SIUL_SetPad Arguments Type uint8_t Name Direction input pad Description Pad to be set - use either PCR pad number or some predefined name. Include : SIUL.h Description : This function sets state of the specified pad to the logical HIGH state. Remark: Pad should be previously configured as a digital output (see SIUL_DigitalOutput function). Code sample: SIUL_DigitalOutput(SIUL_PD8); SIUL_SetPad(SIUL_PD8); Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 89 Function SIUL_ClearPad • First command configures pad PD8 as a digital output and the second command sets its state to logical HIGH. 10.13 Function SIUL_ClearPad The function SIUL_ClearPad clears the GPIO pin state (logical LOW). Prototype: void SIUL_ClearPad(uint8_t pad); Table 10-13. SIUL_ClearPad Arguments Type uint8_t Name Direction input pad Description Pad to be cleared - use either PCR pad number or some predefined name. Include : SIUL.h Description : This function clears state of the specified pad (logical LOW state). Remark: Predefined values can be combined using logical | operator. Code sample: SIUL_DigitalOutput(SIUL_PD8); SIUL_ClearPad(SIUL_PD8); • First command configures pad PD8 as a digital output and the second command clears its state (logical LOW). 10.14 Function SIUL_GetPadState The function SIUL_GetPadState gets states of the GPIO pin. Prototype: uint32_t SIUL_GetPadState(uint32_t pad); Table 10-14. SIUL_GetPadState Arguments Type uint32_t Name pad Direction input Description Pad that will be read. Include : SIUL.h Description : This function gets state of the specified pad. Basic SW Drivers for MPC5744P, Rev. 1.0 90 Freescale Semiconductor, Inc. Chapter 10 SIUL driver Remark: The specified pad has to be configured as input (its input buffer has to be previously enabled). Code sample: SIUL_GetPadState(SIUL_PD8); • Command gets and returns actual state of the pin PD8. Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 91 Function SIUL_GetPadState Basic SW Drivers for MPC5744P, Rev. 1.0 92 Freescale Semiconductor, Inc. Chapter 11 Integration Integration is a necessary step of the software development. This chapter provides information on how the drivers were compiled and linked. This information is important to prevent any unsuccesful compilation and linking due to special dependecies. The drivers were compiled and linked using Freescale's CodeWarrior Development Studio for MPC55xx/MPC56xx (Classic IDE) vs. 2.8 (exact versions of the compiler, debugger and linker are shown in the table). Integration of the basic drivers using different toolset is possible, but it is not covered by this project. Table 11-1. Used Tools Tool Version Freescale C/C++ Compiler for Embedded PowerPC Version 4.3 build 209 Freescale Linker for Embedded PowerPC Version 4.3 build 209 Freescale Assembler for Embedded PowerPC Version 4.3 build 209 11.1 Compiler Options This chapter describes in detail all parameters that were used to compile these drivers. A list of all compiler parameters is shown in the table below. Configuration of these parameters can be modified in the Build Options project menu (see Figure 11-1). Table 11-2. Compiler Options Compiler Option Parameter Description C Language Dialect -C99,-c99,ANSI,-ansi,gcc,-k+r Controls the version of C to be accepted by the compiler. C Japanese Automotive Extensions Controls support for the Japanese Automotive C extensions. japanese_aut omotive_c,no_japanese_ automotive_c Table continues on the next page... Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 93 Assembler Options Table 11-2. Compiler Options (continued) Compiler Option Parameter Description C++ Language Dialect --STD,--std,-arm,--g++,-ee,--e Specifies the version of C++ to be accepted by the compiler. C++ Libraries --stdl,--stdle,-- Specifies the type of C++ libraries to use. eel,--eele,-el,--ele C++ Exception Handling --exceptions,-- Controls support for exception handling. no_exceptions Allow C++ Style Slash Comments in C -Controls treatment of C++ style // comments. slash_comme nt,-no_slash_com ment ANSI Aliasing Rules -ansi_alias,Controls assumptions based on ANSI aliasing rules in the no_ansi_alias compiler. Figure 11-1. GHS - Compiler Options Basic SW Drivers for MPC5744P, Rev. 1.0 94 Freescale Semiconductor, Inc. Chapter 11 Integration 11.2 Assembler Options Configuration of the GHS assembler is shown in the table below. These parameters are hidden by default and can be modified in the assembler settings window (see Figure 11-2). Table 11-3. Assembler Options Assembler Option Checked Parameter Source Listing Generation -list,-list,no_list Controls the generation of a source listing. Source Listing Generation Output Directory -list_dir Outputs assembly listing files in the specified directory. Preprocess Assembly Files Controls whether assembly files with standard preprocess extensions such as .s and .asm are _assembly preprocessed. _files,no_preproc ess_assem bly_files Preprocess Special Assembly Files Controls whether assembly files with a .ppc preprocess extension are preprocessed. _special_a ssembly_fil es,no_preproc ess_specia l_assembly _files Interleaved Source and Assembly Controls the interleaving of your original source passsourc code with the generated assembly code. e,nopasssou rce Additional Assembler Options -asm Passes the specified assembler options to the asppc assembler command line. Assembler Command File -asmcmd Passes the options specified in file directly to the assembler. Support for C Type Information in Assembly -asm3g,noasm3g Controls assembler support for the .inspect and directive, and the offsetof() and sizeof() operators. Description Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 95 Linker Options Figure 11-2. GHS - Assembler Options 11.3 Linker Options For linking this project, the GHS linker was used. A list of linker parameters is shown in the table below. Parameters can be accessed in the linker options (see Figure 11-3. Table 11-4. Linker Options Linker Option Parameter Description Output File Type Controls the version of C to be accepted by the compiler. locatedprogra m,-relobj,relprog Generate Additional Output -memory,memory,srec,-srec,hex,-hex,-no_additional _output Controls support for the Japanese Automotive C extensions. Executable Stripping -strip,-nostrip Specifies the version of C++ to be accepted by the compiler. Start Address Symbol -e,-noentry Specifies the type of C++ libraries to use. Table continues on the next page... Basic SW Drivers for MPC5744P, Rev. 1.0 96 Freescale Semiconductor, Inc. Chapter 11 Integration Table 11-4. Linker Options (continued) Linker Option Parameter Description Append Comment Section with Link-Time Information -Qy,-Qn Controls support for exception handling. Preprocess Linker Directives Files -Controls treatment of C++ style // comments. preprocess_li nker_directive _full,-preprocess_li nker_directive ,-no_preproces s_linker_direct ive Linker Warnings Controls assumptions based on ANSI aliasing rules in the linker_warning compiler. s,no_linker_war nings Raw Import Files -rawimport Controls the version of C to be accepted by the compiler. Linker Directive Files with Non-standard Extensions -T Controls support for the Japanese Automotive C extensions. Additional Linker Options (beginning of link line) -lnk0 Specifies the version of C++ to be accepted by the compiler. Additional Linker Options (before start file) -lnk Specifies the type of C++ libraries to use. Additional Linker Options (among object files) -Wl Controls support for exception handling. Linker Command File Controls treatment of C++ style // comments. -lnkcmd Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 97 Linker Options Figure 11-3. GHS - Linker Options Basic SW Drivers for MPC5744P, Rev. 1.0 98 Freescale Semiconductor, Inc. C hapter 12 R evis ion His tory 12.1 R evis ion His tory T able 12-1. R evis ion His tory R evis ion 1.0 Date 9/2014 Des c ription of C hanges Initial R eleas e Basic SW Drivers for MPC5744P, Rev. 1.0 Freescale Semiconductor, Inc. 99 How to Reach Us: Information in this document is provided solely to enable system and software implementers to use Freescale products. Home Page: freescale.com on the information in this document. Web Support: freescale.com/support warranty, representation, or guarantee regarding the suitability of its products for any particular purpose, nor does There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits based Freescale reserves the right to make changes without further notice to any products herein. Freescale makes no Freescale assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters that may be provided in Freescale data sheets and/or specifications can and do vary in different applications, and actual performance may vary over time. All operating parameters, including “typicals,” must be validated for each customer application by customer’s technical experts. Freescale does not convey any license under its patent rights nor the rights of others. Freescale sells products pursuant to standard terms and conditions of sale, which can be found at the following address: freescale.com/SalesTermsandConditions. Freescale and the Freescale logo, SafeAssure, Qorivva and CodeWarrior are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other product or service names are the property of their respective owners. © 2014 Freescale Semiconductor, Inc. Document Number:KTMPC5744DBSWUG Rev. 1.0 /2014