S32 SDK
ewm_hal.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 - 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 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 
23 #ifndef EWM_HAL_H
24 #define EWM_HAL_H
25 
26 #include <stdint.h>
27 #include <stdbool.h>
28 #include "device_registers.h"
29 
35  /*******************************************************************************
36  * Definitions
37  ******************************************************************************/
38 
43 typedef enum
44 {
49 
50 
51 /*******************************************************************************
52  * API
53  ******************************************************************************/
59 #if defined(__cplusplus)
60 extern "C" {
61 #endif
62 
74 void EWM_HAL_Init(EWM_Type * const base,
75  bool interruptEnable,
76  ewm_in_assert_logic_t assertLogic,
77  bool enable);
78 
88 
95 static inline void EWM_HAL_Refresh(EWM_Type* const base)
96 {
97  /* Write first byte of the service key */
99  /* Write second byte of the service key */
101 }
102 
111 static inline bool EWM_HAL_IsInterruptEnabled(const EWM_Type * const base)
112 {
113  uint8_t value = (uint8_t)(((base->CTRL) & EWM_CTRL_INTEN_MASK) >> EWM_CTRL_INTEN_SHIFT);
114  return (value == 0U) ? false : true;
115 }
116 
125 static inline bool EWM_HAL_IsEnabled(const EWM_Type * const base)
126 {
127  uint8_t value = (uint8_t)(((base->CTRL) & EWM_CTRL_EWMEN_MASK) >> EWM_CTRL_EWMEN_SHIFT);
128  return (value == 0U) ? false : true;
129 }
130 
137 static inline uint8_t EWM_HAL_GetControl(const EWM_Type* const base)
138 {
139  return base->CTRL;
140 }
141 
150 static inline void EWM_HAL_SetCompareLow(EWM_Type* const base, uint8_t value)
151 {
152  base->CMPL = value;
153 }
154 
161 static inline uint8_t EWM_HAL_GetCompareLow(const EWM_Type* const base)
162 {
163  return base->CMPL;
164 }
165 
175 static inline void EWM_HAL_SetCompareHigh(EWM_Type* const base, uint8_t value)
176 {
177  base->CMPH = value;
178 }
179 
186 static inline uint8_t EWM_HAL_GetCompareHigh(const EWM_Type* const base)
187 {
188  return base->CMPH;
189 }
190 
198 static inline void EWM_HAL_SetPrescaler(EWM_Type* const base, uint8_t value)
199 {
200  base->CLKPRESCALER = value;
201 }
202 
209 static inline uint8_t EWM_HAL_GetPrescaler(const EWM_Type* const base)
210 {
211  return base->CLKPRESCALER;
212 }
213 
215 #if defined(__cplusplus)
216 }
217 #endif
218 
221 #endif /* EWM_HAL_H */
222 /*******************************************************************************
223  * EOF
224  ******************************************************************************/
static void EWM_HAL_SetPrescaler(EWM_Type *const base, uint8_t value)
Set the Clock Prescaler Value. This register can be only written once after a CPU reset and it must b...
Definition: ewm_hal.h:198
#define EWM_CTRL_INTEN_MASK
Definition: S32K144.h:3415
static uint8_t EWM_HAL_GetPrescaler(const EWM_Type *const base)
Get the Clock Prescaler Value.
Definition: ewm_hal.h:209
static bool EWM_HAL_IsEnabled(const EWM_Type *const base)
Get the EWM enable bit.
Definition: ewm_hal.h:125
ewm_in_assert_logic_t EWM_HAL_GetInputPinAssertLogic(const EWM_Type *const base)
Get the Input pin assert logic.
Definition: ewm_hal.c:87
#define FEATURE_EWM_KEY_FIRST_BYTE
ewm_in_assert_logic_t
EWM input pin configuration Configures if the input pin is enabled and when is asserted Implements : ...
Definition: ewm_hal.h:43
static void EWM_HAL_Refresh(EWM_Type *const base)
Refresh EWM. This method needs to be called within the window period specified by the Compare Low and...
Definition: ewm_hal.h:95
static uint8_t EWM_HAL_GetCompareHigh(const EWM_Type *const base)
Get the Compare High Value.
Definition: ewm_hal.h:186
static bool EWM_HAL_IsInterruptEnabled(const EWM_Type *const base)
Get the Interrupt Enable bit.
Definition: ewm_hal.h:111
__IO uint8_t CLKPRESCALER
Definition: S32K144.h:3370
static void EWM_HAL_SetCompareLow(EWM_Type *const base, uint8_t value)
Set the Compare Low Value. This register can be only written once after a CPU reset. The user must make sure that the Compare High is greater than Compare Low value.
Definition: ewm_hal.h:150
#define EWM_CTRL_EWMEN_MASK
Definition: S32K144.h:3403
void EWM_HAL_Init(EWM_Type *const base, bool interruptEnable, ewm_in_assert_logic_t assertLogic, bool enable)
Init EWM. This method configures the EWM instance Control Register fields such as interrupt enable...
Definition: ewm_hal.c:49
__IO uint8_t CMPL
Definition: S32K144.h:3367
__IO uint8_t CMPH
Definition: S32K144.h:3368
__O uint8_t SERV
Definition: S32K144.h:3366
#define EWM_CTRL_EWMEN_SHIFT
Definition: S32K144.h:3404
static uint8_t EWM_HAL_GetCompareLow(const EWM_Type *const base)
Get the Compare Low Value.
Definition: ewm_hal.h:161
static uint8_t EWM_HAL_GetControl(const EWM_Type *const base)
Get the Control register Value.
Definition: ewm_hal.h:137
#define FEATURE_EWM_KEY_SECOND_BYTE
__IO uint8_t CTRL
Definition: S32K144.h:3365
#define EWM_CTRL_INTEN_SHIFT
Definition: S32K144.h:3416
static void EWM_HAL_SetCompareHigh(EWM_Type *const base, uint8_t value)
Set the Compare High Value. This register can be only written once after a CPU reset. The user must make sure that the Compare High is greater than Compare Low value Note: The maximum Compare High value is 0xFE.
Definition: ewm_hal.h:175