10#define _FSL_SNVS_LP_H_
12#include "fsl_common.h"
25#define FSL_SNVS_LP_DRIVER_VERSION (MAKE_VERSION(2, 4, 4))
29#define SNVS_ZMK_REG_COUNT 8U
43#if defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 0)
46typedef enum _snvs_lp_external_tamper
48 kSNVS_ExternalTamper1 = 1U,
49#if defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 1)
50 kSNVS_ExternalTamper2 = 2U,
51 kSNVS_ExternalTamper3 = 3U,
52 kSNVS_ExternalTamper4 = 4U,
53 kSNVS_ExternalTamper5 = 5U,
54 kSNVS_ExternalTamper6 = 6U,
55 kSNVS_ExternalTamper7 = 7U,
56 kSNVS_ExternalTamper8 = 8U,
57 kSNVS_ExternalTamper9 = 9U,
58 kSNVS_ExternalTamper10 = 10U
60} snvs_lp_external_tamper_t;
64#if defined(FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS) && (FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS > 0)
66typedef enum _snvs_lp_active_tamper
68 kSNVS_ActiveTamper1 = 1U,
69 kSNVS_ActiveTamper2 = 2U,
70 kSNVS_ActiveTamper3 = 3U,
71 kSNVS_ActiveTamper4 = 4U,
72 kSNVS_ActiveTamper5 = 5U,
73} snvs_lp_active_tx_tamper_t;
76typedef enum _snvs_lp_active_clock
78 kSNVS_ActiveTamper16HZ = 0U,
79 kSNVS_ActiveTamper8HZ = 1U,
80 kSNVS_ActiveTamper4HZ = 2U,
81 kSNVS_ActiveTamper2HZ = 3U
82} snvs_lp_active_clock_t;
89 snvs_lp_active_clock_t clock;
90} tamper_active_tx_config_t;
95 uint16_t filterenable;
97 snvs_lp_active_tx_tamper_t activeTamper;
98} tamper_active_rx_config_t;
106#if defined(FSL_FEATURE_SNVS_PASSIVE_TAMPER_FILTER) && (FSL_FEATURE_SNVS_PASSIVE_TAMPER_FILTER > 0)
107 uint8_t filterenable;
114#if defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 1)
115#define SNVS_LP_MAX_TAMPER kSNVS_ExternalTamper10
117#define SNVS_LP_MAX_TAMPER kSNVS_ExternalTamper1
123 kSNVS_TamperNotDetected = 0U,
124 kSNVS_TamperDetected = 1U
130 kSNVS_ExternalTamperActiveLow = 0U,
131 kSNVS_ExternalTamperActiveHigh = 1U
185#if defined(__cplusplus)
307static inline void SNVS_LP_SRTC_EnableInterrupts(
SNVS_Type *base, uint32_t mask)
319static inline void SNVS_LP_SRTC_DisableInterrupts(
SNVS_Type *base, uint32_t mask)
358static inline void SNVS_LP_SRTC_ClearStatusFlags(
SNVS_Type *base, uint32_t mask)
375static inline void SNVS_LP_SRTC_StartTimer(
SNVS_Type *base)
377 base->LPCR |= SNVS_LPCR_SRTC_ENV_MASK;
378 while ((0U == (base->LPCR & SNVS_LPCR_SRTC_ENV_MASK)))
388static inline void SNVS_LP_SRTC_StopTimer(
SNVS_Type *base)
390 base->LPCR &= ~SNVS_LPCR_SRTC_ENV_MASK;
391 while ((base->LPCR & SNVS_LPCR_SRTC_ENV_MASK) != 0U)
403#if defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 0)
416#if defined(FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS) && (FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS > 0)
425 snvs_lp_active_tx_tamper_t pin,
426 tamper_active_tx_config_t
config);
435status_t SNVS_LP_EnableRxActiveTamper(
SNVS_Type *base, snvs_lp_external_tamper_t rx, tamper_active_rx_config_t
config);
493void SNVS_LP_TamperPinTx_GetDefaultConfig(tamper_active_tx_config_t *
config);
506void SNVS_LP_TamperPinRx_GetDefaultConfig(tamper_active_rx_config_t *
config);
522#if defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 0)
530void SNVS_LP_DisableExternalTamper(
SNVS_Type *base, snvs_lp_external_tamper_t pin);
537void SNVS_LP_DisableAllExternalTamper(
SNVS_Type *base);
555void SNVS_LP_ClearExternalTamperStatus(
SNVS_Type *base, snvs_lp_external_tamper_t pin);
562void SNVS_LP_ClearAllExternalTamperStatus(
SNVS_Type *base);
579static inline void SNVS_LP_EnableMonotonicCounter(
SNVS_Type *base,
bool enable)
583 base->LPCR |= SNVS_LPCR_MC_ENV_MASK;
587 base->LPCR &= (~SNVS_LPCR_MC_ENV_MASK);
606static inline void SNVS_LP_IncreaseMonotonicCounter(
SNVS_Type *base)
609 *((
volatile uint32_t *)(uint32_t)(&(base->LPSMCLR))) = 0xFFFFFFFFU;
637static inline void SNVS_LP_SetZeroizableMasterKeyValid(
SNVS_Type *base,
bool valid)
641 base->LPMKCR |= SNVS_LPMKCR_ZMK_VAL_MASK;
645 base->LPMKCR &= (~SNVS_LPMKCR_ZMK_VAL_MASK);
657static inline bool SNVS_LP_GetZeroizableMasterKeyValid(
SNVS_Type *base)
659 return (SNVS_LPMKCR_ZMK_VAL_MASK == (base->LPMKCR & SNVS_LPMKCR_ZMK_VAL_MASK));
672 base->LPMKCR &= (~SNVS_LPMKCR_ZMK_HWP_MASK);
676 base->LPMKCR |= SNVS_LPMKCR_ZMK_HWP_MASK;
686static inline void SNVS_LP_EnableZeroizableMasterKeyECC(
SNVS_Type *base,
bool enable)
690 base->LPMKCR |= SNVS_LPMKCR_ZMK_ECC_EN_MASK;
694 base->LPMKCR &= (~SNVS_LPMKCR_ZMK_ECC_EN_MASK);
708 uint32_t lpmkcr = base->LPMKCR;
710 base->LPMKCR = lpmkcr;
713#if defined(FSL_FEATURE_SNVS_HAS_STATE_TRANSITION) && (FSL_FEATURE_SNVS_HAS_STATE_TRANSITION > 0)
727#if defined(__cplusplus)
#define SNVS_LPMKCR_MASTER_KEY_SEL(x)
Definition: MIMXRT1052.h:41897
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
_snvs_lp_external_tamper_status
List of SNVS_LP external tampers status.
Definition: fsl_snvs_lp.h:122
#define SNVS_ZMK_REG_COUNT
Define of SNVS_LP Zeroizable Master Key registers.
Definition: fsl_snvs_lp.h:29
void SNVS_LP_WriteZeroizableMasterKey(SNVS_Type *base, uint32_t ZMKey[SNVS_ZMK_REG_COUNT])
Write Zeroizable Master Key (ZMK) to the SNVS registers.
Definition: fsl_snvs_lp.c:1307
struct _snvs_lp_srtc_datetime snvs_lp_srtc_datetime_t
Structure is used to hold the date and time.
status_t SNVS_LP_SRTC_SetDatetime(SNVS_Type *base, const snvs_lp_srtc_datetime_t *datetime)
Sets the SNVS SRTC date and time according to the given time structure.
Definition: fsl_snvs_lp.c:366
enum _snvs_lp_srtc_interrupts snvs_lp_srtc_interrupts_t
List of SNVS_LP interrupts.
enum _snvs_lp_srtc_status_flags snvs_lp_srtc_status_flags_t
List of SNVS_LP flags.
uint64_t SNVS_LP_GetMonotonicCounter(SNVS_Type *base)
Get the current Monotonic Counter.
Definition: fsl_snvs_lp.c:1291
void SNVS_LP_PassiveTamperPin_GetDefaultConfig(snvs_lp_passive_tamper_t *config)
Fills in the SNVS tamper pin config struct with the default settings.
Definition: fsl_snvs_lp.c:535
void SNVS_LP_SRTC_Deinit(SNVS_Type *base)
Stops the SRTC timer.
Definition: fsl_snvs_lp.c:313
_snvs_lp_srtc_interrupts
List of SNVS_LP interrupts.
Definition: fsl_snvs_lp.h:33
struct _snvs_lp_srtc_config snvs_lp_srtc_config_t
SNVS_LP config structure.
void SNVS_LP_Init(SNVS_Type *base)
Ungates the SNVS clock and configures the peripheral for basic operation.
Definition: fsl_snvs_lp.c:242
_snvs_lp_master_key_mode
SNVS_LP Master Key mode.
Definition: fsl_snvs_lp.h:175
_snvs_lp_zmk_program_mode
SNVS_LP Zeroizable Master Key programming mode.
Definition: fsl_snvs_lp.h:166
uint32_t SNVS_LP_SRTC_GetStatusFlags(SNVS_Type *base)
Gets the SNVS status flags.
Definition: fsl_snvs_lp.c:492
_snvs_lp_srtc_status_flags
List of SNVS_LP flags.
Definition: fsl_snvs_lp.h:39
enum _snvs_lp_external_tamper_polarity snvs_lp_external_tamper_polarity_t
SNVS_LP external tamper polarity.
enum _snvs_lp_zmk_program_mode snvs_lp_zmk_program_mode_t
SNVS_LP Zeroizable Master Key programming mode.
void SNVS_LP_SRTC_GetDefaultConfig(snvs_lp_srtc_config_t *config)
Fills in the SNVS_LP config struct with the default settings.
Definition: fsl_snvs_lp.c:330
void SNVS_LP_SRTC_GetAlarm(SNVS_Type *base, snvs_lp_srtc_datetime_t *datetime)
Returns the SNVS SRTC alarm time.
Definition: fsl_snvs_lp.c:472
enum _snvs_lp_external_tamper_status snvs_lp_external_tamper_status_t
List of SNVS_LP external tampers status.
void SNVS_LP_SRTC_Init(SNVS_Type *base, const snvs_lp_srtc_config_t *config)
Ungates the SNVS clock and configures the peripheral for basic operation.
Definition: fsl_snvs_lp.c:284
uint32_t SNVS_LP_SRTC_GetEnabledInterrupts(SNVS_Type *base)
Gets the enabled SNVS interrupts.
Definition: fsl_snvs_lp.c:512
status_t SNVS_LP_SRTC_SetAlarm(SNVS_Type *base, const snvs_lp_srtc_datetime_t *alarmTime)
Sets the SNVS SRTC alarm time.
Definition: fsl_snvs_lp.c:428
enum _snvs_lp_master_key_mode snvs_lp_master_key_mode_t
SNVS_LP Master Key mode.
_snvs_lp_external_tamper_polarity
SNVS_LP external tamper polarity.
Definition: fsl_snvs_lp.h:129
void SNVS_LP_Deinit(SNVS_Type *base)
Deinit the SNVS LP section.
Definition: fsl_snvs_lp.c:267
void SNVS_LP_SRTC_GetDatetime(SNVS_Type *base, snvs_lp_srtc_datetime_t *datetime)
Gets the SNVS SRTC time and stores it in the given time structure.
Definition: fsl_snvs_lp.c:403
@ kSNVS_SRTC_AlarmInterrupt
Definition: fsl_snvs_lp.h:34
@ kSNVS_OTPMK
Definition: fsl_snvs_lp.h:176
@ kSNVS_ZMK
Definition: fsl_snvs_lp.h:177
@ kSNVS_CMK
Definition: fsl_snvs_lp.h:178
@ kSNVS_ZMKSoftwareProgram
Definition: fsl_snvs_lp.h:167
@ kSNVS_ZMKHardwareProgram
Definition: fsl_snvs_lp.h:168
@ kSNVS_SRTC_AlarmInterruptFlag
Definition: fsl_snvs_lp.h:40
Definition: MIMXRT1052.h:41032
SNVS_LP config structure.
Definition: fsl_snvs_lp.h:155
bool srtcCalEnable
Definition: fsl_snvs_lp.h:156
uint32_t srtcCalValue
Definition: fsl_snvs_lp.h:158
Structure is used to hold the date and time.
Definition: fsl_snvs_lp.h:136
uint8_t month
Definition: fsl_snvs_lp.h:138
uint8_t day
Definition: fsl_snvs_lp.h:139
uint8_t minute
Definition: fsl_snvs_lp.h:141
uint16_t year
Definition: fsl_snvs_lp.h:137
uint8_t second
Definition: fsl_snvs_lp.h:142
uint8_t hour
Definition: fsl_snvs_lp.h:140
Definition: deflate.c:114
Structure is used to configure SNVS LP passive tamper pins.
Definition: fsl_snvs_lp.h:104