Home

L9952GXP software driver user manual

image

Contents

1. 45 3 46 www BDTIC com ST List of figures UM0563 List of figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 Figure 10 Figure 11 Figure 12 4 46 Release names of the software driver 5 Block diagram of the L9952GXP software driver and the L9952GXP device with its associated microcontroller and peripherals 6 Top level architecture of the L9952GXP software driver and the L9952GXP device with its associated microcontroller and peripherals 7 Software driver file structure 8 Error detection flowchart of the software driver 9 L9952drv_Init function 36 L9952drv_WdgTrigger function 37 L9952drv_SetStandbyMode L9952DRV_STANDBYMODE_V1 function 38 L9952drv_ClearStatusRegister function 38 Group of L9952GXP software driver functions with similar behavior 39 L9952drv_ReadStatusx function 40 L9952drv_GetGlobalErrorStatus function 40 ky www BDTIC com ST UM0563 Naming different releases of th
2. 14 L9952drv_SetVoltageReg2Mode 15 L9952drv_SetTimer1 IIIA IA Aa kaa aa 15 L9O952drv_SetTimer2 16 L9952drv SetDigOutput 16 L9952drv_SetWUInputMode 17 L9952drv_DisableWakeupSource 18 L9952drv SetResetThresholdLevel 19 L9952drv_SetInputFilterMode 20 L9952drv_SetOutOLThresholdLevel 21 L9952drv_ LinSetup II aa KIA 22 L9952drv ClearStatusRegisters 22 L9952drv_SetVsLockoutMode 23 L9952drv_WdgTrigger AI EIA IA Wa 24 L9952drv SetRelayShutidownMode 25 L9952drv_GetGlobalErrorStatus 26 L9952drv_GetStatusO AI a WA AAA AA 27 L9952drv_ReadStatusO 27 L9952drv GetStatusi 28 L9952drv_ReadStatus1 28 L9952drv SetVRegiCurrentMonitorOn 29 L9952drv_SetIntMode
3. 29 L9952drv StandbyModeType 30 L9952drv_OutModeType 30 L9952drv OutHSAutorecoveryType 30 L9952drv RelayOutputType 31 L9952drv VoltageReg2ModeType 31 L9952drv TimeriPeriodlype 32 L9952drv_Timer1ONTimeType 32 L9952drv_Timer2ONTimeType 32 L9952drv_DigOutputModeType 33 L9952drv_WUInputModeType sanaansannn 33 L9952drv_InputFilterModeType 33 L9952drv ResetThresholdLevelType 34 L9952drv OutOLThresholdLevelType 34 L9952drv LinSetupType 34 L9952drv VsLockoutModeType 35 L9952drv RelayShutdownModeType 35 L9952drv_IntModeType WIKI tees 35 L9952drv_StatusRegType 35 L9952drv_ReportError IIIA AA IIIA 41 Memory mappingekamples aann 42 Document revision history
4. 42 7 3 Memory mapping 42 8 Using the L9952GXP software driver 43 8 1 MAN ii WE WA aa WA 43 8 2 L9952drv C file AA IIIA KI kale aaa 43 8 3 NII IA Aa Kaa 43 84 Sid Types hfile 43 8 5 Platform Types hfile 43 8 6 Compiler hfile 44 8 7 L9952drv_AL c and L9952drv AL hfiles 44 9 Revision history 45 2 46 ky www BDTIC com ST UM0563 List of tables List of tables Table 1 Table 2 Table 3 Table 4 Table 5 Table 6 Table 7 Table 8 Table 9 Table 10 Table 11 Table 12 Table 13 Table 14 Table 15 Table 16 Table 17 Table 18 Table 19 Table 20 Table 21 Table 22 Table 23 Table 24 Table 25 Table 26 Table 27 Table 28 Table 29 Table 30 Table 31 Table 32 Table 33 Table 34 Table 35 Table 36 Table 37 Table 38 Table 39 Table 40 Table 41 Table 42 Table 43 Table 44 Table 45 Table 46 Table 47 L9952drv AA bea bed ade ees coed wha ed ote heed eed 11 L9952drv SetStandbyMode 12 L9952drv SetOutMode nn 13 L9952drv SetOutHSAutorecovery 14 L9952drv SetRelayOutput
5. Caveats This function waits until the data are completely transferred to the L9952GXP via the SPI Configuration None Table 16 This function updates the software driver s internal copy of control register 2 and sends it immediately to the L9952GXP via the SPI SPI This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the L9952drv_ClearStatusRegisters Service name L9952drv_ClearStatusRegisters Void L9952drv_ClearStatusRegisters Syntax Jdid Service ID 15 Sync async Asynchronous Reentrancy Non reentrant Parameters in None Return value None Description This function clears the content of both L9952GXP status registers The register affected is the CR1 21 1 Caveats This function waits until the data are completely transferred to the L9952GXP via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 1 and sends it immediately to the L9952GXP via the SPI It then changes the internal copy of control register 1 and sends it again to the L9952GXP via the SPI SPI This function refreshes the software driver s internal copy of status 1 register from the L9952GXP via the ky www BDTIC com ST UM0563 L9952GXP software driver functions Table 17 L9952drv_SetVsLockoutMode Service name L9952drv_SetVsLockoutMode
6. lt 7 UM0563 YA User manual L9952GXP software driver user manual Introduction The L9952GXP is a complex device described in the L9952GXP datasheet and the L9952GXP power management system IC application note AN2751 For further information on these documents please contact STMicroelectronics To simplify use of L9952GXP device an associated software driver has been developed This document decribes how to use the software driver to control the L9952GXP device July 2008 Rev 1 1 46 www st com www BDTIC com ST Contents UM0563 Contents 1 Naming different releases of the L9952GXP software driver 5 2 Purpose of the L9952GXP software driver 6 3 Architecture of the L9952GXP software driver 7 3 1 L9952GXP software driver file structure 8 3 2 L9952GXP software driver error detection 9 3 3 L9952GXP low level peripheral drivers 10 4 L9952GXP software driverfunctions 11 5 L9952GXP software driver platform types 30 6 Dynamic view of the L9952GXP software driver functions 36 6 1 L9952GXP software driver error handling function 41 7 L9952GXP software driver system requirements 42 7 1 Operating system compiler andinterrupts 42 7 2 Hardware requirements
7. Void L9952drv_SetVsLockoutMode pyle L9952drv_VsLockoutModeType mode Service ID 16 Sync async Asynchronous Reentrancy Non reentrant Parameter mode selects the behavior of the L9952GXP after Vs power supply Parameters in voltage recovery Return value None This function enables automatic recovery of outputs after Vs over under voltage Description recovery of the L9952GXP The register affected is the CR2 4 1 This function waits until the data are completely transferred to the L9952GXP Caveats via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 2 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the SPI 4 23 46 www BDTIC com ST L9952GXP software driver functions UM0563 24 46 Table 18 L9952drv_WdgTrigger Service name L9952drv_WdgTrigger Void L9952drv_WdgTrigger Syntax Void Service ID 17 Sync async Synchronous Reentrancy Non reentrant Parameters in None Return value None This function triggers the watchdog hardware It is called cyclically by the upper layer function usually the watchdog manager to prevent the watchdog hardware from expiring Right timing is essential For more details see the Description L9952GXP datasheet The regi
8. 1 register Return value None Pea This function files data structure with the most recent software driver internal Description copy of status 1 data Caveats This function returns the internal copy of the data The status 1 register is not refreshed by reading its status from the L9952GXP via the SPI Configuration None 1 Use the L9952drv_GetStatus1 function to get actual refreshed data via the SPI 4 28 46 www BDTIC com ST UM0563 L9952GXP software driver functions Table 25 L9952drv_SetVReg1CurrentMonitorOn Service name L9952drv_SetVReg1CurrentMonitorOn Void L9952drv_SetVReg1CurrentMonitorOn Syntax Void Service ID 24 Sync async Asynchronous Reentrancy Non reentrant Parameters in None Return value None This function switches on voltage regulator 1 of the L9952GXP in stand by Description mode The register affected is the CR2 20 1 This function waits until the data are completely transferred to the L9952GXP Caveats via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 2 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the SPI Table 26 L9952drv_SetintMode Service name L9952drv_SetintMode Void L9952drv_SetIntMode ayntax L9952drv_IntMo
9. Caveats via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 2 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the SPI Table 5 L9952drv_SetRelayOutput Service name L9952drv_SetRelayOutput Void L9952drv_SetRelayOutput umes L9952drv_RelayOutputType value Service ID 4 Sync Async Asynchronous Reentrancy Non reentrant Parameters in Parameter value describes the state a relay is set to or not set to Return value None Description This function controls the low side LS relay outputs of the L9952GXP The registers affected are the CRO 15 16 1 Caveats This function waits until the data are completely transferred to the L9952GXP via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 0 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the SPI ky www BDTIC com ST UM0563 L9952GXP software driver functions Table 6 L9952drv_SetVoltageReg2Mode Service name L9952drv_SetVoltageReg2Mode Void L9952drv_SetVoltageReg2Mode Syntax L9952dr
10. define L9952DRV_MASK_WU1 0x01 define L9952DRV_MASK_WU2 0x02 define L9952DRV_MASK_WU3 0x04 define L9952DRV_MASK_WU4 0x08 Example L9952DRV_MASK_WU2 L9952DRV_MASK_WUS mask is active for WU2 and WU3 Parameter mode describes the modes current source current sink of the digital WU inputs Return value None This function sets the mode current source or current sink for the digital Description wakeup inputs WU1 WU2 WU3 and WU4 of the L9952GXP The registers affected are the CR1 8 11 This function waits until the data are completely transferred to the L9952GXP Caveats via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 1 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 1 register from the L9952GXP via the SPI JI 17 46 www BDTIC com ST L9952GXP software driver functions UM0563 18 46 Table 11 L9952drv_DisableWakeupSource Service name L9952drv_DisableWakeupSource Void L9952drv_DisableWakeupSource Syntax uint8 mask uint8 bitpattern Service ID 10 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter mask sets the wakeup source It disables the wakeup source from OUT1 and WU2 and enables the wakeup source from OUT2 Address range 0x00 OxFF Bit 0 1 Mask a
11. in Following constants are defined in L9952drv h file define L9952DRV_MASK_OUT1 0x10 define L9952DRV_MASK_OUT2 0x20 define L9952DRV_MASK_OUT3 0x40 define L9952DRV_MASK_OUT4 0x80 Example L9952DRV_MASK_OUT1 L9952DRV_MASK_OUT 4 mask is active for OUT1 and OUT4 Parameter level defines level for open load detection for related HS outputs Return value None This function sets the openload detection level for selected HS outputs 1 4 of Description the L9952GXP The registers affected are the CR2 0 3 1 2 This function waits until the data are completely transferred to the L9952GXP Caveats 3 via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 2 and sends it immediately to the L9952GXP via the SPI 2 ue function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the PI ky 21 46 www BDTIC com ST L9952GXP software driver functions UM0563 22 46 Table 15 L9952drv_LinSetup Service name L9952drv_LinSetup Void L9952drv_LinSetup Syna L9952drv_LinSetupType value Service ID 14 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter value LIN setup values for pull up on bits 0 2 which enables dominant TxD timeout and LIN slope Return value None Description This function sets the LIN configuration The registers affected are the CR2 6 2 7 2 1802
12. Dig_Out3 and Dig_Out4 of the L9952GXP Return value None This function controls digital outputs 3 and 4 of the L9952GXP Description The registers affected are the CR1 12 142 The modes of digital outputs 3 and 4 are coupled due to the internal construction of the L9952GXP Caveats This function waits until the data are completely transferred to the L9952GXP via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 1 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 1 register from the L9952GXP via the ky www BDTIC com ST UM0563 L9952GXP software driver functions Table 10 L9952drv_SetWUInputMode Service name L9952drv_SetWUInputMode Void L9952drv_SetWUInputMode Syntax uint8 mask L9952drv_WUInputModeType mode Service ID 9 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter mask sets the wakeup WU input mode as current source active or current sink not active Address range 0x00 OxOF Bit 0 1 Mask active for WU1 0 Mask not active for WU1 Bit 1 1 Mask active for WU2 0 Mask not active for WU2 Bit 2 1 Mask active for WU3 0 Mask not active for WU3 Bit 3 1 Mask active for WU4 0 Mask not active for WU4 The following constants are defined in the L9952drv h file
13. Std_Types h file contains the standard platform types of the L9952GXP software driver functions Platform_Types h file contains the standard platform types for an 8 bit microcontroller platform Arbitrary_microcontroller_reg h file contains the microcontroller dependent definitions This is not necessary for the L9952GXP driver itself which is hardware independent This file is useful when the Std_Types h Compiler h file is shared with other modules 8 L9952drv_AL c and L9952drv_AL h files adapt the L9952GXP software driver to the low level SPI driver which allows the software driver to control the L9952GXP device 4 www BDTIC com ST UM0563 Architecture of the L9952GXP software driver 3 2 L9952GXP software driver error detection Errors are detected in the software driver by checking library usage at runtime see flowchart in Figure 5 When the L9952DRV_DEV_ERROR_DETECT preprocessor switch is defined the L9952GXP software driver function checks the initialization status of the library and the value range of the input parameters at runtime If an error is detected the L9952drv_ReportError function is called Inside the L9952drv_ReportError function the L9952DRV_DEV_ERROR_DETECT_EXEC_CONTINUE switch allows the user to define the behavior of the library function If the L9952DRV_DEV_ERROR_DETECT_EXEC_CONTINUE switch is not activated the library function is terminated immediately If
14. changes are essential for example see Section 8 7 L9952drv_AL c and L9952drv_AL h files below Main c file Before beginning this file is empty because it exists to compile the software driver for the L9952GXP device The user must regularly service the L9952GXP device watchdog L9952drv C file The L9952_drv c file contains all functionality of the L9952GXP software driver It is recommended to change nothing in this file except the L9952drv_ReportError function The L9952drv_ReportError function is called from the L9952GXP software driver function if the L9952DRV_DEV_ERROR_DETECT switch is active This function is originally implemented as a dummy function It allows the user to implement the required functionality for example error logging settings of some user global error variables for detailed error localization and so on See Section 3 2 L9952GXP software driver error detection on page 9 L9952_Cfg file The source file L9952_Cfg h is a dedicated area where L9952GXP software driver configuration items are placed Before the L9952GXP is configured two preprocessor switches allow the user to tune driver behavior No changes are required but it is possible to make them For more details about preprocessor switches see Section 3 2 L9952GXP software driver error detection on page 9 Std_Types h file The Std_Types h file is an Autosar compliant file It defines standard platform types of the L9952GXP software driver fun
15. driver s internal copy of control register 2 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the SPI 25 46 www BDTIC com ST L9952GXP software driver functions UM0563 26 46 Table 20 L9952drv_GetGlobalErrorStatus Service name L9952drv_GetGlobalErrorStatus Bool L9952drv_GetGlobalErrorStatus Syntax Void Service ID 19 Sync async Synchronous Reentrancy Non reentrant Parameters in None Return value True Global error status is set at least one error flag is set False Global error status is reset no error This function gets the status of the cumulative error bit of the L9952GXP It is Description implemented using the L9952drv_GetStatus0 function Reading the DO bit of the SPI while the chip select CS pin is active is not standard SPI operation The microcontroller related SPI driver may not support Caveats such functionality and problems may arise in the SPI adaptation layer This function waits until the data are completely transferred to the L9952GXP via the SPI Configuration None 1 It is possible to get the status of the cumulative error bit by regularly reading status register 0 1 or by reading the first byte of either register An alternative and quicker method is to read the DO bit of the SPI while the SPI is not c
16. error detection on page 9 The error handling function does not care about the arbitrary SPI communication driver All SPI errors and timeouts must be solved inside the SPI driver Note If there is an error lock and the the watchdog expires the microcontroller may be reset by the L9952GXP device Table 45 L9952drv_ReportError Service name L9952drv_ReportError Bool L9952drv_ReportError Syntax uint8 Serviceld uint8 Errorld Service ID Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter Serviceld defines the ID of the failing function service Parameter Errorld defines ID of the error True The software driver continues in an interrupted function in run mode without the L9952DRV_DEV_ERROR_DETECT Return value s False The software driver stops execution of the interrupted function by returning avoiding any communication with the L9952GXP device Description Service for reporting errors especially during the development phase This function is originally implemented as a dummy function It allows the user Caveats to implement the required functionality for example error logging setting of some user global error variables for detailed error localization and so on Configuration None 1 The return value is driven in the L9952drv_Cfg h file by DEFINE L9952DRV_DEV_ERROR_DETECT_EXEC_CONTINUE ky 41 46 www BDTIC com ST L9952GXP software driver system requirements UM0563 7 L9952GXP software driv
17. the L9952DRV_DEV_ERROR_DETECT_EXEC_CONTINUE switch is defined the function body of the library function is executed after exiting the L9952drv_ReportError function Figure 5 Error detection flowchart of the software driver Start of L9952GXP function L9952DRV_DEV_ ERROR_DETECT parameters defined lt gt Yes KI Error AA DETECT EKEC CONTINUE defined Function body ky 9 46 www BDTIC com ST Architecture of the L9952GXP software driver UM0563 3 3 10 46 L9952GXP low level peripheral drivers Hardware of the low level peripheral drivers depend on the microcontroller being used together with the L9952GXP device Functionality of the peripherals lies outside the scope of the software driver being described in this document However an example of low level ST7 peripheral driver implementation with the software driver for the L9952GXP and an ST7 microcontroller was developed This example is delivered with the L9952GXP software driver www BDTIC com ST UM0563 L9952GXP software driver functions 4 L9952GXP software driver functions The L9952GXP sofware driver mainly carries out simple functions It does not perform its own timing or processes However it must service the watchdog trigger in the correct time window of the L9952GXP device Other timing functions are checked by the user application The following tables summarize the main functions of the L9952GXP software driver Table 1 L9952d
18. 52DRV_MASK_OUT1 0x10 define L9952DRV_MASK_OUT2 0x20 define L9952DRV_MASK_OUTS3 0x40 define L9952DRV_MASK_OUT4 0x80 Example OUT MODE_MASK_OUT1 OUT_MODE_MASK_OUT2 mask is active for OUT1 and OUT2 Parameter mode sets the mode for selected outputs Return value None Description This function controls high side HS outputs of the L9952GKP P The registers affected are the CR0 0 14 2 This function waits until the data are completely transferred to the L9952GXP Caveats via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 0 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the SPI ky 13 46 www BDTIC com ST L9952GXP software driver functions UM0563 Table 4 L9952drv_SetOutHSAutorecovery Service name L9952drv_SetOutHSAutorecovery Void L9952drv_SetOutHSAutorecovery Symes L9952drv_OutHSAutorecoveryType mode Service ID 3 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter mode sets the autorecovery functionality of the OUT HS output Return value None This function enables disables the autorecovery functionality of the OUT HS Description outputs of the L9952GXP The register affected is the CR2 5 This function waits until the data are completely transferred to the L9952GXP
19. GE_REG2_OFF Switches voltage regulator 2 off L9952DRV_VOLTAGE_REG2_ON_ACT Switches voltage regulator 2 on when IVE the L9952GXP is in active mode Range Switches voltage regulator 2 on when L9952DRV_VOLTAGE_REG2_ON_V1_ the L9952GXP is in active or V1 standby mode L9952DRV_VOLTAGE_REG2_ON Switches voltage regulator 2 on Description Defines the voltage regulator 2 modes of the L9952GXP ky 31 46 www BDTIC com ST L9952GXP software driver platform types UM0563 32 46 Table 32 L9952drv_Timer1PeriodType Type enum L9952DRV_TIMER1PERIOD_500 Sets timer 1 period to 0 5 s L9952DRV_TIMER1PERIOD_1000 Sets timer 1 period to 1s L9952DRV_TIMER1PERIOD_1500 Sets timer 1 period to 1 5 s L9952DRV_TIMER1PERIOD_2000 Sets timer 1 period to 2 s Range L9952DRV_TIMER1PERIOD_2500 Sets timer 1 period to 2 5 s L9952DRV_TIMER1PERIOD_3000 Sets timer 1 period to 3 s L9952DRV_TIMER1PERIOD_3500 Sets timer 1 period to 3 5 s L9952DRV_TIMER1PERIOD_4000 Sets timer 1 period to 4 s Description Defines the timer 1 period of the L9952GXP Table 33 L9952drv_Timer1ONTimeType Type enum 4 L9952DRV_TIMER1ONTIME_10 Defines the on time value as 10 ms ange a L9952DRV_TIMER1ONTIME_20 Defines on time value as 20 ms Description Defines the on time of timer 1 of the L9952GXP Table 34 L9952drv_Timer2ONTimeType Type enum L9952DRV_TIMER2ONTIME_01 Defines the on time value as 100 us Range a L9952DRV_
20. GXP software driver functions The L9952drv_SetStandbyMode L9952DRV_STANDBYMODE_VBAT is one of a group of functions of the L9952GXP which have the same behavior Other functions in this group include e L9952drv_SetOutMode L9952drv_SetRelayOutput L9952drv_SetVoltageReg2Mode L9952drv_SetOutHSAutorecovery L9952drv_SetTimer1 L9952drv_SetTimer2 L9952drv_SetDigOutput L9952drv_SetWUInputMode L9952drv_DisableWakeupSource L9952drv_SetResetThresholdLevel L9952drv_SetlnputFilterMode L9952drv_SetOutOLThresholdLevel L9952drv_LinSetup L9952drv_SetVsLockoutMode L9952drv_SetRelayShutdownMode L9952drv_GetStatus0 L9952drv_GetStatus1 L9952drv_SetVReg1CurrentMonitorOn L9952drv_SetIntMode Figure 10 Group of L9952GXP software driver functions with similar behavior L9952GXP L9952GXP s w L9952GXP s w SPI adaptation SPI driver L9952GXP driver user driver device layer l l l l I L9952drv_Func i i tionGroup1 p10 L9952DRV_AL_ SPI 24 bit SPI_LWR communication TE transfer repens 1 The hardware layer is depicted with a grey background and the software layer is depicted with a white background LI 39 46 www BDTIC com ST Dynamic view of the L9952GXP software driver functions UM0563 The ReadStatusx function is comprised of two similarly behaved functions e L9952drv_ReadStatus0 e L9952drv_ReadStatus1 Figure 11 L9952drv_ReadStatusx function L9952GXP L9952GXP s
21. L9952drv_WdgTrigger This function waits until both control registers are completely transferred to the L9952GXP device via the SPI Configuration None 1 The L9952drv_SetVReg1CurrentMonitorOn function is called before control register 0 is modified prior to entering standby mode This is for security reasons This function updates the software driver s internal copy of control register 0 and sends it immediately to the L9952GXP via the SPI via the SPI This function refreshes the software driver s internal copy of status 0 register from the L9952GXP device 4 www BDTIC com ST UM0563 L9952GXP software driver functions Table 3 L9952drv_SetOutMode Service name L9952drv_SetOutMode Void L9952drv_SetOutMode Syntax uint8 mask L9952drv_OutModeType mode Service ID 2 Sync async Asynchronous Reentrancy Non reentrant Parameter mask defines the outputs which should be configured Address range 0x00 OxF 1 Bit 0 1 Mask is active for OUTHS 0 Mask is not active for OUTHS Bit 4 1 Mask is active for OUT1 0 Mask is not active for OUT1 Bit 5 1 Mask is active for OUT2 0 Mask is not active for OUT2 Bit 6 1 Mask is active for OUTS 0 Mask is not active for OUT3 Bit 7 1 Mask is active for OUT4 0 Mask is not active for OUT4 Parameters in The following constants are defined in L9952drv h file define L9952DRV_MASK_OUTHS 0x01 define L99
22. MASK_WU1 L9952DRV_MASK_WU4 mask is active for WU1 and WU4 Parameter mode sets filter timing for related WU inputs Return value None This function controls the filter timing for digital wakeup inputs WU1 WU2 WU3 Description and WU4 of the L9952GXP The registers affected are the CR2 10 17 This function waits until the data are completely transferred to the L9952GXP Caveats via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 2 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the SPI 20 46 4 www BDTIC com ST UM0563 L9952GXP software driver functions Table 14 L9952drv_SetOutOLThresholdLevel Service name L9952drv_SetOutOLThresholdLevel Void L9952drv_SetOutOLThresholdLevel Syntax uint8 mask L9952drv_OutOLThresholdLevelType level Service ID 13 Sync async Asynchronous Reentrancy Non reentrant Parameter mask sets the openload detection level OLT for related HS outputs Address range 0x00 OxFO Bit 4 1 Mask active for OUT 1 0 Mask not active for OUT 1 Bit 5 1 Mask active for OUT 2 0 Mask not active for OUT 2 Bit 6 1 Mask active for OUT 3 0 Mask not active for OUT 3 Bit 7 1 Mask active for OUT 4 0 Mask not active for OUT 4 Parameters
23. P software driver functions JI Table 11 L9952drv DisableWakeupSource continued Service name Parameters in cont d L9952drv_DisableWakeupSource Example L9952drv_DisableWakeupSource 0x32 0x12 A better method is to use the predefined constants below L9952drv_DisableWakeupSource L9952DRV_MASK_OUT1 L9952DRV_MASK_OUT2 L9952DRV_MASK_WLU2 L9952DRV_MASK_OUT1 L9952DRV_MASK_WU2 This example disables the wakeup source from OUT1 and WU2 and enables wakeup source from OUT2 The rest reminds unchanged Return value None This function enables disables wakeup functionality separately for each wakeup Description source defined by mask The registers affected are the CR1 0 7 0 This function waits until the data are completely transferred to the L9952GXP Caveats via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 1 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 1 register from the L9952GXP via the SPI Table 12 L9952drv_SetResetThresholdLevel Service name L9952drv_SetResetThresholdLevel Void L9952drv_SetResetThresholdLevel Syntax L9952drv_ResetThresholdLevelType level Service ID 11 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter level defines the reset t
24. TIMER2ONTIME_1 Defines the on time value as 1 ms Description Defines the on time of timer 2 of the L9952GXP X www BDTIC com ST UM0563 L9952GXP software driver platform types JI Table 35 L9952drv DigOutputModeType Type Range L9952DRV DO WU3 WU4 enum Sets Dig_Out3 to loopback of WU3 Sets Dig_Dut4 to loopback of WU4 L9952DRV_DO_HIZ_WU4 Sets Dig_Out3 to high impedance Sets Dig_Dut4 to loopback of WU4 L9952DRV_DO_WU3_HIZ Sets Dig_Out3 to loopback of WU3 Sets Dig_Dut4 to high impedance L9952DRV_DO_WU3_OLHS 2 Sets Dig_Out3 to loopback of WU3 Sets Dig_Out4 to loopback of open load state of OUT2 L9952DRV_DO_OLHS1_WU 4 Sets Dig_Out3 to loopback of open load state of OUT1 Sets Dig_Out4 to loopback of WU4 L9952DRV_DO_OLHS1_OL HS2 Sets Dig_Out3 to loopback of open load state of OUT1 Sets Dig_Out4 to loopback of open load state of OUT2 L9952DRV_DO_OLHS1_HIZ Sets Dig_Out3 to loopback of open load state of OUT1 Sets Dig_Out4 to high impedance L9952DRV_DO_HIZ_OLHS2 Sets Dig_Out3 to high impedance Sets Dig_Out4 to loopback of open load state of OUT2 Description Defines which signals are looped to digital outputs Dig_Out3 and Dig_Out4 Table 36 L9952drv_WUInputModeType Type Range L9952DRV_WU_INPUT_MODE_CUR_SINK enum Defines the current sink pull down mode for related WU inputs L9952DRV_WU_INPU
25. T_MODE_CUR_SOURCE Defines the current source pull up mode for related WU inputs Description Defines current source current sink modes for related WU inputs Table 37 L9952drv_InputFilterModeType Type Range L9952DRV_IN_FILTER_64 enum Defines the input filter time value as 64 us and leaves it unsynchronized L9952DRV_IN_FILTER_80_TIMER2 Defines the input filter time value as 80 us and synchronizes it with timer 2 L9952DRV_IN_FILTER_800_TIMER2 Defines the input filter time value as 800 us and synchronizes it with timer 2 L9952DRV_IN_FILTER_800_TIMER1 Defines the input filter time value as 800 us and synchronizes it with timer 1 Description Defines the input filter configuration for related WU inputs 33 46 www BDTIC com ST L9952GXP software driver platform types UM0563 34 46 Table 38 L9952drv_ResetThresholdLevelType Type enum L9952DRV_RESET THRESHOLD 4650 Defines the reset threshold level as 4 65 V Range L9952DRV_RESET THRESHOLD 4350 rene the reset threshold level as Description Defines the reset threshold level value Table 39 L9952drv_OutOLThresholdLevelType Type enum Defines the output openload threshold L9952DRV_OUT_OLTHRESHOLD_2 level value as 2 mA Range L9952DRV_OUT OLTHRESHOLD 8 Defines the output openload threshold level value as 8 mA Description Defines the output openload threshold
26. ble 41 L9952drv_VsLockoutModeType Type enum Disables Vs lockout after a Vs over under L9952DRV_VS_LOCKOUT DISABLE voltage condition has disappeared Outputs automatically recover according to the output settings in the CRO register Range Enables Vs lockout After a Vs over under voltage recovery outputs remain off until the L9952DRV_VS_LOCKOUT_ENABLE status register 1 bits O and 1 are cleared by the CLR command using bit 21 of control regsiter 1 Description Defines Vs lockout modes for controlling automatic recovery after Vs over under P voltage recovery of the L9952GXP Table 42 L9952drv_RelayShutdownModeType Type enum Enables shutdown of relay outputs during Vs L9952DRV_RELAY_SHUTDOWN_EN over under voltage of the L9952GXP ABLE REL1 2 turned off in case of Vs over under voltage Range Disables shutdown of relay outputs during L9952DRV_RELAY_SHUTDOWN_DIS Vs over under voltage of the L9952GXP ABLE REL1 2 remain on in case of Vs over under voltage PE Defines modes which control Vs over under voltage shutdown of REL1 2 low side Description drivers Table 43 L9952drv_IntModeType Type enum L9952DRV_INT_DISABLE Disables interrupt mode ange L9952DRV_INT_ENABLE Enables interrupt mode Description Defines modes which control the interrupt mode of the L9952GXP Table 44 L9952drv_StatusRegType Type uint32 Range 0 0xOOFFFFFF The L9952drv_StatusRegType defines global data types for access to a complete Description local copy of t
27. ctions No user changes are necessary Platform_Types h file File Platform_Types h is an Autosar compliant file which defines global symbols depending on the microcontroller platform 8 bit 16 bit or 32 bit By default this file contains values for an 8 bit microcontroller platform for which no user changes are necessary 43 46 www BDTIC com ST Using the L9952GXP software driver UM0563 8 6 Compiler h file File Compiler h is an Autosar compliant file which defines compiler types Currently this file contains values for the Cosmic C compiler The L9952GXP software driver is hardware independent therefore the Compiler h file does not include any microcontroller dependent file No user changes are necessary 8 7 L9952drv_AL c and L9952drv_AL h files These files adapt the L9952GXP software driver to the low level SPI driver which allows the software driver to control the L9952GXP device see Section 3 The L9952drv_AL h file contains the macro define L9952DRV_AL SPI WR SPI Send This macro assigns a function SPI_Send to transfer the SPI driver to the L9952GXP device SPI_Send replaces the general function L9952DRV_AL_SPI_WR By default SPI_Send exists as a dummy function which needs to be updated or replaced If it does not exist it must be created in the L9952drv_AL c file The SPI_Send prototype is extern void SPI Send uint8 DataTX uint8 DataRX A description of SPI_Send is as follows e Da
28. ctive for WU1 0 Mask not active for WU1 Bit 1 1 Mask active for WU2 0 Mask not active for WU2 Bit 2 1 Mask active for WU3 0 Mask not active for WU3 Bit 3 1 Mask active for WU4 0 Mask not active for WU4 Bit 4 1 Mask active for openload of OUT1 wakeup source 0 Mask not active for openload of OUT1 wakeup source Bit 5 1 Mask active for openload of OUT2 wakeup source 0 Mask not active for openload of OUT2 wakeup source Bit 6 1 Mask active for openload of OUT3 wakeup source 0 Mask not active for openload of OUT3 wakeup source Bit 7 1 Mask active for openload of OUT4 wakeup source 0 Mask not active for openload of OUT4 wakeup source The following constants are defined in the L9952drv h file define L9952DRV_MASK_WU1 0x01 define L9952DRV_MASK_WU2 0x02 define L9952DRV_MASK_WU3 0x04 define L9952DRV_MASK_WU4 0x08 define L9952DRV_MASK_OUT1 0x10 define L9952DRV_MASK_OUT2 0x20 define L9952DRV_MASK_OUTS3 0x40 define L9952DRV_MASK_OUT4 0x80 Example L9952DRV_MASK_OUT1 L9952DRV_MASK_WU4 mask is active for WU1 and openload of OUT4 Parameter bitpattern disables enables wakeup functionality separately for each wakeup source Particular bits correspond with specifice wakeup sources in the same order as defined by mask see above Bits with a value of 1 disable a corresponding wakeup source Bits with a value of 0 enable a corresponding wakeup source X www BDTIC com ST UM0563 L9952GX
29. deType mode Service ID 25 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter mode selects the interrupt mode of L9952GXP Return value None Description Une ial as selects the interrupt MA of L9952GKP gister affected is the CR1 20 Caveats This function waits until the data are completely transferred to the L9952GKP via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 1 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 1 register from the L9952GXP via the SPI 4 29 46 www BDTIC com ST L9952GXP software driver platform types UM0563 5 30 46 L9952GXP software driver platform types The following tables summarize the L9952GXP software driver platform types Table 27 L9952drv_StandbyModeType Type enum L9952DRV_STANDBYMODE_V1 L9952GXP to V1 standby Range L9952DRV_STANDBYMODE_VBAT ae a EP sae nPop Vipat stama by Description Defines the standby modes of the L9952GXP Table 28 L9952drv_OutModeType Type enum L9952DRV_OUT_MODE_OFF Driver is off in all modes L9952DRV_OUT MODE_ON Driver is on in active mode and off in standby mode L9952DRV_OUT MODE TIMERI Driver is cyclic It is on when Timer is in active or standby mode Range AT L9952DRV OUT MODE TIMER Driver is cyclic It is on w
30. e L9952GXP software driver 1 Naming different releases of the L9952GXP software driver A standardized naming system exists for naming different releases of the software driver for the L9952GXP device The name includes all relevant information such as project name functionality patch version and release type An example of a release name is the L9952drv_1 0 0_RC1 which is explained in Figure 1 Figure 1 Release names of the software driver L9952drv 1 0J 0 RC1 L p Release gt Patch version gt Minor version gt Major version gt Name Name Project name 2 Major version Major functionality Minor version Minor functionality Odd numbers indicate the driver is still in development Even numbers indicate the driver is mature and a public version is available Patch version No additional functionality permitted except bug fixing 5 Release Type of release Official release contains no additional marking Release candidate contains additional marking 4 5 46 www BDTIC com ST Purpose of the L9952GKP software driver UM0563 2 Purpose of the L9952GXP software driver The L9952GXP device is generally used with a microcontroller The microcontroller is supplied from the device and the two communicate via a standard SPI interface The software driver for the L9952GXP is used to control the device see Figure 2 Please refer t
31. egister 1 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 1 register from the L9952GXP via the SPI JI 15 46 www BDTIC com ST L9952GXP software driver functions UM0563 Table 8 L9952drv_SetTimer2 Service name L9952drv_SetTimer2 Void L9952drv_SetTimer2 Syntax L9952drv_Timer2ONTimeType ontime Service ID 7 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter ontime defines the part of the timing period in which the L9952GXP timer 2 output is set to 1 Return value None Description This function controls timer2 of the L9952GXP The register affected is the CR1 19 1 2 Caveats This function waits until the data are completely transferred to the L9952GXP via the SPI Configuration None 1 This function updates the software driver s internal copy of the control register 1 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of the status 1 register from the L9952GXP via the SPI Table 9 L9952drv_SetDigOutput Service name L9952drv_SetDigOutput Void L9952drv_SetDigOutput Syme L9952drv_DigOutputModeType mode Service ID 8 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter mode describes the modes for digital outputs
32. er system requirements 7 1 Operating system compiler and interrupts The L9952GXP driver is written in ANSI C and is MISRA II compliant No operating system is required or directly supported No interrupts are used or required The compiler depends on the microcontroller being used 7 2 Hardware requirements There are no special hardware requirements for the L9952GXP software driver For hardware details please refer to the L9952GXP datasheet 7 3 Memory mapping Memory mapping depends on the microcontroller being used and the setup of the compiler Table 46 gives two setups of the ST7L3 microcontroller which is compiled by Cosmic C version 4 5 5 Table 46 Memory mapping examples Map file items Setup 1 Setup 2 Microcontroller ST7L3 ST7L3 Memory model Compact memory Long stack oe model short mod mode Version Run Debug Version note Not defined Defined L9952DRV DEV ERROR DETECT L9952DRV_DEV_ERROR_DETECT Filename 19952drv T5 1 R c map 19952drv T5 1 D si map Map file items Result Text ROM 1445 3183 Const ROM 4 4 Ubsct RAM 23 8 Share RAM 15 0 Data RAM 0 1 Bss RAM stack 0 15 42 46 ky www BDTIC com ST UM0563 Using the L9952GXP software driver 8 8 1 Note 8 2 8 3 8 4 8 5 Using the L9952GXP software driver The L9952GXP software driver includes a set of source files which can be modified by the user if necessary to customize the driver Some
33. he L9952GXP status registers 0 and 1 Access to the internal structure P and particular bit variables of each status register is provided by a set of masks related to each bit variable inside the status register ky 35 46 www BDTIC com ST Dynamic view of the L9952GXP software driver functions UM0563 6 36 46 Dynamic view of the L9952GXP software driver functions The following figures give a dynamic overview of the L9952GXP software driver functions Figure 6 L9952drv_Init function L9952GXP s w L9952GXP s w driver user driver l l L9952drv_Init L9952GXP SPI adaptation layer SPI driver UREA device 1 The hardware layer is depicted with a grey background and the software layer is depicted with a white background www BDTIC com ST UM0563 Dynamic view of the L9952GXP software driver functions Figure 7 L9952drv_WdgTrigger function L9952GXP ne 19992GXP SPI adaptation SPI driver TERRIER s w driver user s w driver device layer l L9952drv_Wdg Trigger L9952DRV_AL_ SPI_WR SPI 24 bit communication data transfer SPI_WR Right time window is mandatory L9952drv_Wdg Trigger L9952DRV_AL_ SPI_WR SPI 24 bit communication data transfer SPI_WR l l Right time window i is mandatory I L9952drv_Wdg Trigger L9952DRV_AL_ SPI_WR SPI 24 bit SPI_WR commu
34. hen Timer2 is in active or standby mode Driver is controlled by the pulse width L9952DRV_OUT_MODE_PWM1 modulation 1 PWM1 input L9952DRV_OUT_MODE_PWM2 Driver is controlled by the PWM2 input Description Defines the output modes of the HS outputs Table 29 L9952drv_OutHSAutorecoveryType Type enum L9952DRV_OUTHS_AUTORECOvERY sables the autorecovery OFF F functionality for the OUT HS outputs of the L9952GXP Range esi nables the autorecovery er ees functionality for the OUT HS outputs T of the L9952GXP nae Defines the states for the OUT HS outputs which control autorecovery Description functionality www BDTIC com ST UM0563 L9952GXP software driver platform types Table 30 L9952drv_RelayOutputType Type enum RELAYOUTPUT_OFF_OFF Switches both relays off RELAYOUTPUT_ON_OFF Switches relay REL1 on and REL2 off RELAYOUTPUT_OFF_ON Switches relay REL1 off and REL2 on RELAYOUTPUT_ON_ON Switches both relays on RELAYOUTPUT_OFF_X Switches relay REL1 off and refreshes Range the previous state of REL2 Switches relay REL1 on and refreshes RELAYOUTPUT_ON_X the previous state of REL2 RELAYOUTPUT_X_OFF Switches relay REL2 off and refreshes the previous state of REL1 RELAYOUTPUT_X_ON Switches relay REL2 on and refreshes the previous state of REL1 Description Defines the states to control the relay outputs Table 31 L9952drv_VoltageReg2ModeType Type enum L9952DRV_VOLTA
35. hreshold level value Return value None Description This function sets the reset threshold level of the L9952GXP The registers affected are the CR2 8 90 Caveats This function waits until the data are completely transferred to the L9952GXP via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 2 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the SPI 19 46 www BDTIC com ST L9952GXP software driver functions UM0563 Table 13 L9952drv_SetinputFilterMode Service name L9952drv_SetInpuiFilterMode Void L9952drv_SetInputFilterMode Syntax uint8 mask L9952drv_InputFilterModeType mode Service ID 12 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter mask sets the filter timing of the wakeup inputs Address range 0x00 OxOF Bit 0 1 Mask active for WU1 0 Mask not active for WU1 Bit 1 1 Mask active for WU2 0 Mask not active for WU2 Bit 2 1 Mask active for WU3 0 Mask not active for WU3 Bit 3 1 Mask active for WU4 0 Mask not active for WU4 The following constants are defined in the L9952drv h file define L9952DRV_MASK_WU1 0x01 define L9952DRV_MASK_WU2 0x02 define L9952DRV_MASK_WU3 0x04 define L9952DRV_MASK_WU4 0x08 Example L9952DRV_
36. ion layer 3 L9952GXP SPI adaptation layer A thin layer which adapts the software driver SPI interface to the microcontroller dependent SPI driver 4 Low level peripheral drivers Provide the user application layer with all the functions necessary to control the L9952GXP device They control the peripherals of the microncontroller at the lowest power level 7 46 www BDTIC com ST Architecture of the L9952GXP software driver UM0563 3 1 8 46 L9952GXP software driver file structure The L9952GXP sofware driver includes a set of source files which are shown in Figure 4 These files are described in more detail in Section 8 Using the L9952GXP software driver on page 43 Figure 4 Software driver file structure L9952drv Cfg h L9952drv_AL c 8 Arbitrary micro controller_reg h 7 L9952drv_AL h Include Include L9952drv c 1 L9952drv h Include 4 Include 5 gt Std Types h Platform Types h Include Include optionally Compiler h H gt Include Include NOP ON Re Or Compiler h File contains the compiler dependent definitions L9952drv c file contains all functionality of the L9952GXP software driver L9952drv h file contains the headers of the L9952GXP software driver functions L9952drv_Cfg h file contains the configuration of the L9952GXP software driver functions
37. level value for related outputs Table 40 L9952drv_LinSetupType Type enum Enables master pullup LINPU and L9952DRV_LIN_SL_DI_TIM_EN_PUP_EN TxD dominant timeout for LIN disables alternative LIN slope Disbles master pullup LINPU and L9952DRV_LIN_SL_DI_TIM_EN_PUP_DI alternative LIN slope enables TxD dominant timeout for LIN Enables master pullup LINPU L9952DRV LIN SL DI TIM DI PUP EN disables TxD dominant timeout for LIN and alternative LIN slope Disbles master pullup LINPU TxD L9952DRV LIN SL DI TIM DI PUP DI dominant timeout for LIN and alternative LIN slope Enables master pullup LINPU TxD L9952DRV_LIN_SL_EN_TIM_EN_PUP_EN dominant timeout for LIN and alternative LIN slope Range Disbles master pullup LINPU enables L9952DRV_LIN_SL_EN_TIM_EN_PUP_DI TxD dominant timeout for LIN and alternative LIN slope Enables master pullup LINPU and L9952DRV_LIN_SL_EN_TIM_DI_PUP_EN alternative LIN slope disables TxD dominant timeout for LIN Disbles master pullup LINPU and TxD L9952DRV_LIN_SL_EN_TIM_DI_PUP_DI dominant timeout for LIN enables alternative LIN slope Defines all possible configurations related to the L9952GXP LIN interface One Description configuration must be chosen 4 www BDTIC com ST UM0563 L9952GXP software driver platform types Ta
38. locked and the chipselect CS pin is active The SPI must not be communicating during this procedure 4 www BDTIC com ST UM0563 L9952GXP software driver functions Table 21 L9952drv_GetStatusO Service name L9952drv_GetStatus0O Void L9952drv_GetStatusO Syna L9952drv_StatusRegType DataPtr Service ID 20 Sync async Asynchronous Reentrancy Non reentrant A Parameter DataPtr points to variables which are filled with data from the status Parameters in 0 register Return value None Descfiption This function reads the current status from the L9952GXP via the SPI and then P files the data structure in the staus 0 register This function waits until the data are completely transferred to the L9952GKP Caveats via the SPI Configuration None 1 Control register 2 is refreshed to the L9952GXP via the SPI using the software driver s interanl copy of it Table 22 L9952drv_ReadStatusO Service name L9952drv_ReadStatusO Void L9952drv_ReadStatusO SUNDS L9952drv_StatusRegType DataPtr Service ID 21 Sync async Asynchronous Reentrancy Non reentrant f Parameter DataPtr points to variables which are filled with data from the status Parameters in 0 register Return value None Pee This function files data structure with the most recent software driver internal Description copy of status 0 data Caveats This function returns the internal co
39. nication data transfer 1 The hardware layer is depicted with a grey background and the software layer is depicted with a white background 37 46 4 www BDTIC com ST Dynamic view of the L9952GXP software driver functions UM0563 Figure 8 L9952drv_SetStandbyMode L9952DRV_STANDBYMODE_V1 function L9952GXP L9952GXP L9952GXP A L9952GXP cca Ai wre layer l l T L9952drv_Wdg Trigger L9952DRV_AL_ SPILWR SPI 24 bit communication data transfer Should be close to l watchdog triggering l EOE l L9952DRV_AL_ SPI_WR SPI 24 bit communication data transfer L9952DRV_AL_ SPI_WR SPI 24 bit communication data transfer SPI_WR Microcontroller should go to halt mode now T ey panes eet 1 The hardware layer is depicted with a grey background and the software layer is depicted with a white background Figure 9 L9952drv_ClearStatusRegister function L9952GXP L9952GXP L9952GXP L9952GXP ae zi DS layer l l l l 1 L9952drv_Clear StatusRegisters L9952DRV_AL_ SPI_WR SPI 24 bit communication data transfer SPI_WR L9952DRV_AL_ SPI_WR SPI 24 bit communication data transfer SPI_WR 1 The hardware layer is depicted with a grey background and the software layer is depicted with a white background 38 46 4 www BDTIC com ST UM0563 Dynamic view of the L9952
40. nty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other names are the property of their respective owners 2008 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Singapore Spain Sweden Switzerland United Kingdom United States of America www st com X 46 46 www BDTIC com ST
41. o any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED OR WARRANTED FOR USE IN MILITARY AIR CRAFT SPACE LIFE SAVING OR LIFE SUSTAINING APPLICATIONS NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY DEATH OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE ST PRODUCTS WHICH ARE NOT SPECIFIED AS AUTOMOTIVE GRADE MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK Resale of ST products with provisions different from the statements and or technical features set forth in this document shall immediately void any warra
42. o the L9952GXP datasheet for further details Note The source code of the software driver is MISRA II compliant and follows Autosar requirements Figure 2 Block diagram of the L9952GXP software driver and the L9952GXP device with its associated microcontroller and peripherals fs Voltage Regulator 2 gt w Low Side g wate Up iN Voltage Regulator PEA Voltage Montor Microcontroller J N LED val Sensor 12 0 e g LED SAEJ2602 l j Hall Sensor n7 High Side os gt ci or sonl iii fags Out4 DLIN15248J Jr Cyclic Contact Monitoring vaseupin fag WU al La wake UpIN beg P safe Logic 6 46 KI www BDTIC com ST UM0563 Architecture of the L9952GXP software driver 3 Architecture of the L9952GXP software driver The software driver for the L9952GXP is independent from the microcontroller which physically controls the device It is controlled by the user application layer of the software driver See Figure 3 The glue layer between the software driver and the low level peripheral drivers of the microcontroller is the L9952GXP SPI adaptation laye
43. py of the data The status 0 register is not refreshed by reading its status from the L9952GXP via the SPI Configuration None 1 The internal copy of the status 0 register is refreshed at every watchdog trigger every 10 ms by calling the L9952drv_WdgTrigger function JI 27 46 www BDTIC com ST L9952GXP software driver functions UM0563 Table 23 L9952drv_GetStatus1 Service name L9952drv_GetStatus1 Void L9952drv_GetStatus1 Syna L9952drv_StatusRegType DataPtr Service ID 22 Sync async Asynchronous Reentrancy Non reentrant Parameter DataPtr points to variables which are filled with data from the status Parameters in 1 register Return value None This function reads the current status from the L9952GXP via the SPI and then Description files the data structure in the staus 1 register This function waits until the data are completely transferred to the L9952GKP Caveats via the SPI Configuration None 1 Control register 1 is refreshed to the L9952GXP via the SPI using the software driver s interanl copy of it Table 24 L9952drv_ReadStatus1 Service name L9952drv_ReadStatus1 Void L9952drv_ReadStatus1 SUNDS L9952drv_StatusRegType DataPtr Service ID 23 Sync async Asynchronous Reentrancy Non reentrant f Parameter DataPtr points to variables which are filled with data from the status Parameters in
44. r This layer adapts the SPI interface of the software driver to the microcontroller dependent SPI driver Such a mechanism decouples the software driver and makes its hardware independent see Figure 3 A detailed description of the low level peripheral drivers is ouside the scope of this document They are dependent on the microcontroller in question but decouple the user application layer making it hardware indpendent see Figure 3 They provide the user application layer with all the functions necessary to control the L9952GXP device A detailed description of the user application layer is also outside the scope of this user manual Please refer to the AN2751 L9952GXP power management system IC application note for further details Figure 3 Top level architecture of the L9952GXP software driver and the L9952GXP device with its associated microcontroller and peripherals User application layer 1 L9952GXP software driver sw L9952GXP SPI adaptation layer 3 Low level peripheral drivers ports timers SPI Microcontroller HW t SPI Tresor free 5 V Aux L9952GXP 1 User application layer User software which uses the application programming interface API of the software driver to control the device Such software is ouside the scope of this document 2 Software driver for the L9952GXP The software driver for the L9952GXP which interfaces the user applicat
45. rv_Init Service name L9952drv_Init Void L9952drv_Init Syntax Void Service ID 0 Sync async Synchronous Reentrancy Non reentrant Parameters in None Return value None This function initializes the software driver It has no affect on the device the Description L9952GXP SPI adaptation layer or the SPI interface However The SPI must be initialized prior to the function being used aves L9952drv controlsonly one L9952 device This function should not be called when an operation is running Configuration None 11 46 www BDTIC com ST L9952GXP software driver functions UM0563 12 46 Table 2 L9952drv_SetStandbyMode Service name L9952drv_SetStandbyMode Void L9952drv_SetStandbyMode Symes L9952drv_StandbyModeType mode Service ID 1 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter mode defines the type of standby mode to be set Return value None This module sets selected standby modes of the L9952GXP device Description The registers affected are the CRO 20 21 CR2 20 by L9952drv_SetVReg1CurrentMonitorOn 1 2 3 Power consumption of all components connected to the V1 voltage regulator must be decreased after standby mode V1 is set This is done by setting halt re mode in the microcontroller The watchdog should be set in its regular watchdog time window to avoid triggering it by calling
46. ster affected is the CR0 19029 This function ensures the user pays attention to special conditions such as watchdog handling after wakeup from standby mode This function waits until the data are completely transferred to the L9952GXP Caveats via the SPI Configuration None 1 For security reasons this function periodically refreshes dedicated bit positions of the main internal variables This function writes internal copies of control register 0 to the L9952GXP device via the SPI 3 This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the 4 www BDTIC com ST UM0563 L9952GXP software driver functions 4 Table 19 L9952drv_SetRelayShutdownMode Service name L9952drv_SetRelayShutdownMode Void L9952drv_SetRelayShutdownMode Syna L9952drv_RelayShutdownModeType mode Service ID 18 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter mode selects the behavior of the relay output of the L9952GXP after under over voltage Return value None This function enables automatic shutdown of the relay outputs during Vs Description over under voltage of the L9952GXP The register affected is the CR2 19 2 This function waits until the data are completely transferred to the L9952GXP Caveats via the SPI Configuration None 1 This function updates the software
47. taTX defines a pointer to 3 bytes of data to be transmitted via the SPI eo DataRX defines a pointer to 3 bytes of data to be received via the SPI Data transmitted via the SPI are 3 bytes 24 bits in length They are transmitted in the order byte 1 byte 2 and byte 3 The MSB is always transmitted as the first bit from the byte Data are received in the same order as those transmitted Note The SPI driver must be initialized before the L9952GXP software driver is used for the first time 44 46 ky www BDTIC com ST UM0563 Revision history 9 Revision history Table 47 Document revision history Date 08 Jul 2008 Revision 1 Initial release Changes 45 46 www BDTIC com ST UM0563 Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All ST products are sold pursuant to ST s terms and conditions of sale Purchasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and services described herein No license express or implied by estoppel or otherwise t
48. v_VoltageReg2ModeType mode Service ID 5 Sync async Asynchronous Reentrancy Non reentrant Parameters in Parameter mode defines the voltage regulator 2 mode to be set Return value None Description This function controls the voltage regulator 2 mode of the L9952GXP P The registers affected are the CR0 17 182 This function waits until the data are completely transferred to the L9952GXP Caveats i via the SPI Configuration None 1 This function updates the software driver s internal copy of control register 0 and sends it immediately to the L9952GXP via the SPI 2 This function refreshes the software driver s internal copy of status 0 register from the L9952GXP via the SPI Table 7 L9952drv_SetTimer1 Service name L9952drv_SetTimer1 Void L9952drv_SetTimer1 Syntax L9952drv_Timer1PeriodType period L9952drv_Timer1ONTimeType ontime Service ID 6 Sync async Asynchronous Reentrancy Non reentrant Parameter period defines the timer 1 period of the L9952GXP Parameters in Parameter ontime defines the period where the L9952GXP timer 1 output is set to 1 Return value None This function controls timer1 of the L9952GXP Description The registers affected are the CR1 15 18 1 This function waits until the data are completely transferred to the L9952GXP Caveats via the SPI Configuration None 1 This function updates the software driver s internal copy of control r
49. w L9952GXP s w SPI adaptation SPI driver L9952GXP driver user driver device layer l L9952drv_Read StatusX I X lt 0 1 gt 1 The hardware layer is depicted with a grey background and the software layer is depicted with a white background Figure 12 L9952drv_GetGlobalErrorStatus function L9952GXP L9952GXP s w L9952GXP s w SPI adaptation SPI driver L9952GXP driver user driver device layer l l l l T L9952drv Getei l l l obalErrorStatus L9952DRV_AL_ SPI_WR sPLWR SPI communication 1 The hardware layer is depicted with a grey background and the software layer is depicted with a white background X 40 46 www BDTIC com ST UM0563 Dynamic view of the L9952GXP software driver functions 6 1 L9952GXP software driver error handling function Runtime error handling is supported via the L9952drv_ReportError function This function is called from any of the L9952GXP driver functions when an error is detected It is originally implemented as a dummy function Runtime error handling allows the user to implement the required functionality for example error logging setting some user global error variables or flags for detailed error localization and so on The function is available only if the preprocessor switch L9952DRV_DEV_ERROR_DETECT is set For further details please refer to Section 3 2 L9952GXP software driver

Download Pdf Manuals

image

Related Search

Related Contents

JVC MC-R433U User's Manual  Add New Account  プライマーミックス/テストストリップ ≪取扱説明書≫  Trust 18728  FILTROS MODULARES DE TIERRA DE DIATOMEAS (DE)  Kompact 18 Manual    User Manual - Westinghouse  VT857_minitrix_12841  Emerson LR125 Data Sheet  

Copyright © All rights reserved.
Failed to retrieve file