S32 SDK
lpi2c_hal.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 - 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016 NXP
4  * All rights reserved.
5  *
6  * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
7  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
9  * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
10  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
11  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
12  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
14  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
15  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
16  * THE POSSIBILITY OF SUCH DAMAGE.
17  */
18 
45 #include "lpi2c_hal.h"
46 
47 /*******************************************************************************
48  * Code
49  ******************************************************************************/
50 
51 /*FUNCTION**********************************************************************
52  *
53  * Function Name : LPI2C_HAL_Init
54  * Description : This function initializes the LPI2C module to a known
55  * state (use software reset bit to reset the module).
56  *
57  * Implements : LPI2C_HAL_Init_Activity
58  *END**************************************************************************/
59 void LPI2C_HAL_Init(LPI2C_Type *baseAddr)
60 {
61  /*
62  * The MCR[RST] will reset all master logic and registers to their default state,
63  * except for the MCR itself. The SCR[RST] will reset all slave logic and registers
64  * to their default state, except for the SCR itself. So we must reset the control
65  * registers manually;
66  */
67  LPI2C_HAL_MasterSetSoftwareReset(baseAddr, true);
68  LPI2C_HAL_SlaveSetSoftwareReset(baseAddr, true);
69 
70  baseAddr->MCR = 0x0U;
71  baseAddr->SCR = 0x0U;
72 }
73 /*******************************************************************************
74  * EOF
75  ******************************************************************************/
static void LPI2C_HAL_MasterSetSoftwareReset(LPI2C_Type *baseAddr, bool enable)
Set/clear the master reset command.
Definition: lpi2c_hal.h:429
static void LPI2C_HAL_SlaveSetSoftwareReset(LPI2C_Type *baseAddr, bool enable)
Set/clear the slave reset command.
Definition: lpi2c_hal.h:2165
__IO uint32_t SCR
Definition: S32K144.h:5353
__IO uint32_t MCR
Definition: S32K144.h:5332
void LPI2C_HAL_Init(LPI2C_Type *baseAddr)
Initializes the LPI2C module to a known state.
Definition: lpi2c_hal.c:59