![]() |
|
|||
File indexing completed on 2025-05-11 08:23:01
0001 /* 0002 * Copyright (c) 2016, Freescale Semiconductor, Inc. 0003 * Copyright 2017-2022, NXP 0004 * All rights reserved. 0005 * 0006 * SPDX-License-Identifier: BSD-3-Clause 0007 */ 0008 0009 #ifndef _FSL_SNVS_LP_H_ 0010 #define _FSL_SNVS_LP_H_ 0011 0012 #include "fsl_common.h" 0013 0014 /*! 0015 * @addtogroup snvs_lp 0016 * @{ 0017 */ 0018 0019 /******************************************************************************* 0020 * Definitions 0021 ******************************************************************************/ 0022 0023 /*! @name Driver version */ 0024 /*@{*/ 0025 #define FSL_SNVS_LP_DRIVER_VERSION (MAKE_VERSION(2, 4, 4)) /*!< Version 2.4.4 */ 0026 /*@}*/ 0027 0028 /*! @brief Define of SNVS_LP Zeroizable Master Key registers */ 0029 #define SNVS_ZMK_REG_COUNT 8U /* 8 Zeroizable Master Key registers. */ 0030 0031 /*! @brief List of SNVS_LP interrupts */ 0032 typedef enum _snvs_lp_srtc_interrupts 0033 { 0034 kSNVS_SRTC_AlarmInterrupt = SNVS_LPCR_LPTA_EN_MASK, /*!< SRTC time alarm.*/ 0035 } snvs_lp_srtc_interrupts_t; 0036 0037 /*! @brief List of SNVS_LP flags */ 0038 typedef enum _snvs_lp_srtc_status_flags 0039 { 0040 kSNVS_SRTC_AlarmInterruptFlag = SNVS_LPSR_LPTA_MASK, /*!< SRTC time alarm flag */ 0041 } snvs_lp_srtc_status_flags_t; 0042 0043 #if defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 0) 0044 0045 /*! @brief List of SNVS_LP external tampers */ 0046 typedef enum _snvs_lp_external_tamper 0047 { 0048 kSNVS_ExternalTamper1 = 1U, 0049 #if defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 1) 0050 kSNVS_ExternalTamper2 = 2U, 0051 kSNVS_ExternalTamper3 = 3U, 0052 kSNVS_ExternalTamper4 = 4U, 0053 kSNVS_ExternalTamper5 = 5U, 0054 kSNVS_ExternalTamper6 = 6U, 0055 kSNVS_ExternalTamper7 = 7U, 0056 kSNVS_ExternalTamper8 = 8U, 0057 kSNVS_ExternalTamper9 = 9U, 0058 kSNVS_ExternalTamper10 = 10U 0059 #endif /* defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 1) */ 0060 } snvs_lp_external_tamper_t; 0061 0062 #endif /* defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 0) */ 0063 0064 #if defined(FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS) && (FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS > 0) 0065 /*! @brief List of SNVS_LP active tampers */ 0066 typedef enum _snvs_lp_active_tamper 0067 { 0068 kSNVS_ActiveTamper1 = 1U, 0069 kSNVS_ActiveTamper2 = 2U, 0070 kSNVS_ActiveTamper3 = 3U, 0071 kSNVS_ActiveTamper4 = 4U, 0072 kSNVS_ActiveTamper5 = 5U, 0073 } snvs_lp_active_tx_tamper_t; 0074 0075 /*! @brief List of SNVS_LP external tampers */ 0076 typedef enum _snvs_lp_active_clock 0077 { 0078 kSNVS_ActiveTamper16HZ = 0U, 0079 kSNVS_ActiveTamper8HZ = 1U, 0080 kSNVS_ActiveTamper4HZ = 2U, 0081 kSNVS_ActiveTamper2HZ = 3U 0082 } snvs_lp_active_clock_t; 0083 0084 /*! @brief Structure is used to configure SNVS LP active TX tamper pins */ 0085 typedef struct 0086 { 0087 uint16_t polynomial; 0088 uint16_t seed; 0089 snvs_lp_active_clock_t clock; 0090 } tamper_active_tx_config_t; 0091 0092 /*! @brief Structure is used to configure SNVS LP active RX tamper pins */ 0093 typedef struct 0094 { 0095 uint16_t filterenable; 0096 uint8_t filter; 0097 snvs_lp_active_tx_tamper_t activeTamper; 0098 } tamper_active_rx_config_t; 0099 0100 #endif /* FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS */ 0101 0102 /*! @brief Structure is used to configure SNVS LP passive tamper pins */ 0103 typedef struct 0104 { 0105 uint8_t polarity; 0106 #if defined(FSL_FEATURE_SNVS_PASSIVE_TAMPER_FILTER) && (FSL_FEATURE_SNVS_PASSIVE_TAMPER_FILTER > 0) 0107 uint8_t filterenable; 0108 uint8_t filter; 0109 #endif /* FSL_FEATURE_SNVS_PASSIVE_TAMPER_FILTER */ 0110 } snvs_lp_passive_tamper_t; 0111 0112 /* define max possible tamper present */ 0113 /*! @brief Define of SNVS_LP Max possible tamper */ 0114 #if defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 1) 0115 #define SNVS_LP_MAX_TAMPER kSNVS_ExternalTamper10 0116 #else 0117 #define SNVS_LP_MAX_TAMPER kSNVS_ExternalTamper1 0118 #endif 0119 0120 /*! @brief List of SNVS_LP external tampers status */ 0121 typedef enum _snvs_lp_external_tamper_status 0122 { 0123 kSNVS_TamperNotDetected = 0U, 0124 kSNVS_TamperDetected = 1U 0125 } snvs_lp_external_tamper_status_t; 0126 0127 /*! @brief SNVS_LP external tamper polarity */ 0128 typedef enum _snvs_lp_external_tamper_polarity 0129 { 0130 kSNVS_ExternalTamperActiveLow = 0U, 0131 kSNVS_ExternalTamperActiveHigh = 1U 0132 } snvs_lp_external_tamper_polarity_t; 0133 0134 /*! @brief Structure is used to hold the date and time */ 0135 typedef struct _snvs_lp_srtc_datetime 0136 { 0137 uint16_t year; /*!< Range from 1970 to 2099.*/ 0138 uint8_t month; /*!< Range from 1 to 12.*/ 0139 uint8_t day; /*!< Range from 1 to 31 (depending on month).*/ 0140 uint8_t hour; /*!< Range from 0 to 23.*/ 0141 uint8_t minute; /*!< Range from 0 to 59.*/ 0142 uint8_t second; /*!< Range from 0 to 59.*/ 0143 } snvs_lp_srtc_datetime_t; 0144 0145 /*! 0146 * @brief SNVS_LP config structure 0147 * 0148 * This structure holds the configuration settings for the SNVS_LP peripheral. To initialize this 0149 * structure to reasonable defaults, call the SNVS_LP_GetDefaultConfig() function and pass a 0150 * pointer to your config structure instance. 0151 * 0152 * The config struct can be made const so it resides in flash 0153 */ 0154 typedef struct _snvs_lp_srtc_config 0155 { 0156 bool srtcCalEnable; /*!< true: SRTC calibration mechanism is enabled; 0157 false: No calibration is used */ 0158 uint32_t srtcCalValue; /*!< Defines signed calibration value for SRTC; 0159 This is a 5-bit 2's complement value, range from -16 to +15 */ 0160 } snvs_lp_srtc_config_t; 0161 0162 /*! 0163 * @brief SNVS_LP Zeroizable Master Key programming mode. 0164 */ 0165 typedef enum _snvs_lp_zmk_program_mode 0166 { 0167 kSNVS_ZMKSoftwareProgram, /*!< Software programming mode. */ 0168 kSNVS_ZMKHardwareProgram, /*!< Hardware programming mode. */ 0169 } snvs_lp_zmk_program_mode_t; 0170 0171 /*! 0172 * @brief SNVS_LP Master Key mode. 0173 */ 0174 typedef enum _snvs_lp_master_key_mode 0175 { 0176 kSNVS_OTPMK = 0, /*!< One Time Programmable Master Key. */ 0177 kSNVS_ZMK = 2, /*!< Zeroizable Master Key. */ 0178 kSNVS_CMK = 3, /*!< Combined Master Key, it is XOR of OPTMK and ZMK. */ 0179 } snvs_lp_master_key_mode_t; 0180 0181 /******************************************************************************* 0182 * API 0183 ******************************************************************************/ 0184 0185 #if defined(__cplusplus) 0186 extern "C" { 0187 #endif 0188 0189 /*! 0190 * @name Initialization and deinitialization 0191 * @{ 0192 */ 0193 0194 /*! 0195 * @brief Ungates the SNVS clock and configures the peripheral for basic operation. 0196 * 0197 * @note This API should be called at the beginning of the application using the SNVS driver. 0198 * 0199 * @param base SNVS peripheral base address 0200 */ 0201 void SNVS_LP_Init(SNVS_Type *base); 0202 0203 /*! 0204 * @brief Deinit the SNVS LP section. 0205 * 0206 * @param base SNVS peripheral base address 0207 */ 0208 void SNVS_LP_Deinit(SNVS_Type *base); 0209 0210 /*! @}*/ 0211 0212 /*! 0213 * @brief Ungates the SNVS clock and configures the peripheral for basic operation. 0214 * 0215 * @note This API should be called at the beginning of the application using the SNVS driver. 0216 * 0217 * @param base SNVS peripheral base address 0218 * @param config Pointer to the user's SNVS configuration structure. 0219 */ 0220 void SNVS_LP_SRTC_Init(SNVS_Type *base, const snvs_lp_srtc_config_t *config); 0221 0222 /*! 0223 * @brief Stops the SRTC timer. 0224 * 0225 * @param base SNVS peripheral base address 0226 */ 0227 void SNVS_LP_SRTC_Deinit(SNVS_Type *base); 0228 0229 /*! 0230 * @brief Fills in the SNVS_LP config struct with the default settings. 0231 * 0232 * The default values are as follows. 0233 * @code 0234 * config->srtccalenable = false; 0235 * config->srtccalvalue = 0U; 0236 * @endcode 0237 * @param config Pointer to the user's SNVS configuration structure. 0238 */ 0239 void SNVS_LP_SRTC_GetDefaultConfig(snvs_lp_srtc_config_t *config); 0240 0241 /*! 0242 * @name Secure RTC (SRTC) current Time & Alarm 0243 * @{ 0244 */ 0245 0246 /*! 0247 * @brief Sets the SNVS SRTC date and time according to the given time structure. 0248 * 0249 * @param base SNVS peripheral base address 0250 * @param datetime Pointer to the structure where the date and time details are stored. 0251 * 0252 * @return kStatus_Success: Success in setting the time and starting the SNVS SRTC 0253 * kStatus_InvalidArgument: Error because the datetime format is incorrect 0254 */ 0255 status_t SNVS_LP_SRTC_SetDatetime(SNVS_Type *base, const snvs_lp_srtc_datetime_t *datetime); 0256 0257 /*! 0258 * @brief Gets the SNVS SRTC time and stores it in the given time structure. 0259 * 0260 * @param base SNVS peripheral base address 0261 * @param datetime Pointer to the structure where the date and time details are stored. 0262 */ 0263 void SNVS_LP_SRTC_GetDatetime(SNVS_Type *base, snvs_lp_srtc_datetime_t *datetime); 0264 0265 /*! 0266 * @brief Sets the SNVS SRTC alarm time. 0267 * 0268 * The function sets the SRTC alarm. It also checks whether the specified alarm 0269 * time is greater than the present time. If not, the function does not set the alarm 0270 * and returns an error. 0271 * Please note, that SRTC alarm has limited resolution because only 32 most 0272 * significant bits of SRTC counter are compared to SRTC Alarm register. 0273 * If the alarm time is beyond SRTC resolution, the function does not set the alarm 0274 * and returns an error. 0275 * 0276 * @param base SNVS peripheral base address 0277 * @param alarmTime Pointer to the structure where the alarm time is stored. 0278 * 0279 * @return kStatus_Success: success in setting the SNVS SRTC alarm 0280 * kStatus_InvalidArgument: Error because the alarm datetime format is incorrect 0281 * kStatus_Fail: Error because the alarm time has already passed or is beyond resolution 0282 */ 0283 status_t SNVS_LP_SRTC_SetAlarm(SNVS_Type *base, const snvs_lp_srtc_datetime_t *alarmTime); 0284 0285 /*! 0286 * @brief Returns the SNVS SRTC alarm time. 0287 * 0288 * @param base SNVS peripheral base address 0289 * @param datetime Pointer to the structure where the alarm date and time details are stored. 0290 */ 0291 void SNVS_LP_SRTC_GetAlarm(SNVS_Type *base, snvs_lp_srtc_datetime_t *datetime); 0292 0293 /*! @}*/ 0294 0295 /*! 0296 * @name Interrupt Interface 0297 * @{ 0298 */ 0299 0300 /*! 0301 * @brief Enables the selected SNVS interrupts. 0302 * 0303 * @param base SNVS peripheral base address 0304 * @param mask The interrupts to enable. This is a logical OR of members of the 0305 * enumeration :: _snvs_lp_srtc_interrupts 0306 */ 0307 static inline void SNVS_LP_SRTC_EnableInterrupts(SNVS_Type *base, uint32_t mask) 0308 { 0309 base->LPCR |= mask; 0310 } 0311 0312 /*! 0313 * @brief Disables the selected SNVS interrupts. 0314 * 0315 * @param base SNVS peripheral base address 0316 * @param mask The interrupts to enable. This is a logical OR of members of the 0317 * enumeration :: _snvs_lp_srtc_interrupts 0318 */ 0319 static inline void SNVS_LP_SRTC_DisableInterrupts(SNVS_Type *base, uint32_t mask) 0320 { 0321 base->LPCR &= ~mask; 0322 } 0323 0324 /*! 0325 * @brief Gets the enabled SNVS interrupts. 0326 * 0327 * @param base SNVS peripheral base address 0328 * 0329 * @return The enabled interrupts. This is the logical OR of members of the 0330 * enumeration :: _snvs_lp_srtc_interrupts 0331 */ 0332 uint32_t SNVS_LP_SRTC_GetEnabledInterrupts(SNVS_Type *base); 0333 0334 /*! @}*/ 0335 0336 /*! 0337 * @name Status Interface 0338 * @{ 0339 */ 0340 0341 /*! 0342 * @brief Gets the SNVS status flags. 0343 * 0344 * @param base SNVS peripheral base address 0345 * 0346 * @return The status flags. This is the logical OR of members of the 0347 * enumeration :: _snvs_lp_srtc_status_flags 0348 */ 0349 uint32_t SNVS_LP_SRTC_GetStatusFlags(SNVS_Type *base); 0350 0351 /*! 0352 * @brief Clears the SNVS status flags. 0353 * 0354 * @param base SNVS peripheral base address 0355 * @param mask The status flags to clear. This is a logical OR of members of the 0356 * enumeration :: _snvs_lp_srtc_status_flags 0357 */ 0358 static inline void SNVS_LP_SRTC_ClearStatusFlags(SNVS_Type *base, uint32_t mask) 0359 { 0360 base->LPSR |= mask; 0361 } 0362 0363 /*! @}*/ 0364 0365 /*! 0366 * @name Timer Start and Stop 0367 * @{ 0368 */ 0369 0370 /*! 0371 * @brief Starts the SNVS SRTC time counter. 0372 * 0373 * @param base SNVS peripheral base address 0374 */ 0375 static inline void SNVS_LP_SRTC_StartTimer(SNVS_Type *base) 0376 { 0377 base->LPCR |= SNVS_LPCR_SRTC_ENV_MASK; 0378 while ((0U == (base->LPCR & SNVS_LPCR_SRTC_ENV_MASK))) 0379 { 0380 } 0381 } 0382 0383 /*! 0384 * @brief Stops the SNVS SRTC time counter. 0385 * 0386 * @param base SNVS peripheral base address 0387 */ 0388 static inline void SNVS_LP_SRTC_StopTimer(SNVS_Type *base) 0389 { 0390 base->LPCR &= ~SNVS_LPCR_SRTC_ENV_MASK; 0391 while ((base->LPCR & SNVS_LPCR_SRTC_ENV_MASK) != 0U) 0392 { 0393 } 0394 } 0395 0396 /*! @}*/ 0397 0398 /*! 0399 * @name External tampering 0400 * @{ 0401 */ 0402 0403 #if defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 0) 0404 0405 /*! 0406 * @brief Enables the specified SNVS external tamper. 0407 * 0408 * @param base SNVS peripheral base address 0409 * @param pin SNVS external tamper pin 0410 * @param config Configuration structure of external passive tamper 0411 */ 0412 void SNVS_LP_EnablePassiveTamper(SNVS_Type *base, snvs_lp_external_tamper_t pin, snvs_lp_passive_tamper_t config); 0413 0414 #endif /* defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 0) */ 0415 0416 #if defined(FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS) && (FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS > 0) 0417 /*! 0418 * @brief Enable active tamper tx external pad 0419 * 0420 * @param base SNVS peripheral base address 0421 * @param pin SNVS active tamper pin 0422 * @param config Configuration structure of external active tamper 0423 */ 0424 status_t SNVS_LP_EnableTxActiveTamper(SNVS_Type *base, 0425 snvs_lp_active_tx_tamper_t pin, 0426 tamper_active_tx_config_t config); 0427 0428 /*! 0429 * @brief Enable active tamper rx external pad 0430 * 0431 * @param base SNVS peripheral base address 0432 * @param rx SNVS external RX tamper pin 0433 * @param config SNVS RX tamper config structure 0434 */ 0435 status_t SNVS_LP_EnableRxActiveTamper(SNVS_Type *base, snvs_lp_external_tamper_t rx, tamper_active_rx_config_t config); 0436 0437 /*! 0438 * @brief Sets voltage tamper detect 0439 * 0440 * @param base SNVS peripheral base address 0441 * @param enable True if enable false if disable 0442 */ 0443 status_t SNVS_LP_SetVoltageTamper(SNVS_Type *base, bool enable); 0444 0445 /*! 0446 * @brief Sets temperature tamper detect 0447 * 0448 * @param base SNVS peripheral base address 0449 * @param enable True if enable false if disable 0450 */ 0451 status_t SNVS_LP_SetTemperatureTamper(SNVS_Type *base, bool enable); 0452 0453 /*! 0454 * @brief Sets clock tamper detect 0455 * 0456 * @param base SNVS peripheral base address 0457 * @param enable True if enable false if disable 0458 */ 0459 status_t SNVS_LP_SetClockTamper(SNVS_Type *base, bool enable); 0460 0461 /*! 0462 * brief Check voltage tamper 0463 * 0464 * param base SNVS peripheral base address 0465 */ 0466 snvs_lp_external_tamper_status_t SNVS_LP_CheckVoltageTamper(SNVS_Type *base); 0467 0468 /*! 0469 * @brief Check temperature tamper 0470 * 0471 * @param base SNVS peripheral base address 0472 */ 0473 snvs_lp_external_tamper_status_t SNVS_LP_CheckTemperatureTamper(SNVS_Type *base); 0474 0475 /*! 0476 * brief Check clock tamper 0477 * 0478 * param base SNVS peripheral base address 0479 */ 0480 snvs_lp_external_tamper_status_t SNVS_LP_CheckClockTamper(SNVS_Type *base); 0481 0482 /*! 0483 * @brief Fills in the SNVS tamper pin config struct with the default settings. 0484 * 0485 * The default values are as follows. 0486 * code 0487 * config->clock = kSNVS_ActiveTamper16HZ; 0488 * config->seed = 0U; 0489 * config->polynomial = 0U; 0490 * endcode 0491 * @param config Pointer to the user's SNVS configuration structure. 0492 */ 0493 void SNVS_LP_TamperPinTx_GetDefaultConfig(tamper_active_tx_config_t *config); 0494 0495 /*! 0496 * brief Fills in the SNVS tamper pin config struct with the default settings. 0497 * 0498 * The default values are as follows. 0499 * code 0500 * config->filterenable = 0U; 0501 * config->filter = 0U; 0502 * config->tx = kSNVS_ActiveTamper1; 0503 * endcode 0504 * param config Pointer to the user's SNVS configuration structure. 0505 */ 0506 void SNVS_LP_TamperPinRx_GetDefaultConfig(tamper_active_rx_config_t *config); 0507 #endif /* defined(FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS) && (FSL_FEATURE_SNVS_HAS_ACTIVE_TAMPERS > 0) */ 0508 0509 /*! 0510 * @brief Fills in the SNVS tamper pin config struct with the default settings. 0511 * 0512 * The default values are as follows. 0513 * code 0514 * config->polarity = 0U; 0515 * config->filterenable = 0U; if available on SoC 0516 * config->filter = 0U; if available on SoC 0517 * endcode 0518 * @param config Pointer to the user's SNVS configuration structure. 0519 */ 0520 void SNVS_LP_PassiveTamperPin_GetDefaultConfig(snvs_lp_passive_tamper_t *config); 0521 0522 #if defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 0) 0523 0524 /*! 0525 * @brief Disables the specified SNVS external tamper. 0526 * 0527 * @param base SNVS peripheral base address 0528 * @param pin SNVS external tamper pin 0529 */ 0530 void SNVS_LP_DisableExternalTamper(SNVS_Type *base, snvs_lp_external_tamper_t pin); 0531 0532 /*! 0533 * @brief Disable all external tamper. 0534 * 0535 * @param base SNVS peripheral base address 0536 */ 0537 void SNVS_LP_DisableAllExternalTamper(SNVS_Type *base); 0538 0539 /*! 0540 * @brief Returns status of the specified external tamper. 0541 * 0542 * @param base SNVS peripheral base address 0543 * @param pin SNVS external tamper pin 0544 * 0545 * @return The status flag. This is the enumeration :: _snvs_lp_external_tamper_status 0546 */ 0547 snvs_lp_external_tamper_status_t SNVS_LP_GetExternalTamperStatus(SNVS_Type *base, snvs_lp_external_tamper_t pin); 0548 0549 /*! 0550 * @brief Clears status of the specified external tamper. 0551 * 0552 * @param base SNVS peripheral base address 0553 * @param pin SNVS external tamper pin 0554 */ 0555 void SNVS_LP_ClearExternalTamperStatus(SNVS_Type *base, snvs_lp_external_tamper_t pin); 0556 0557 /*! 0558 * @brief Clears status of the all external tamper. 0559 * 0560 * @param base SNVS peripheral base address 0561 */ 0562 void SNVS_LP_ClearAllExternalTamperStatus(SNVS_Type *base); 0563 0564 #endif /* defined(FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER) && (FSL_FEATURE_SNVS_HAS_MULTIPLE_TAMPER > 0) */ 0565 0566 /*! @}*/ 0567 0568 /*! 0569 * @name Monotonic Counter (MC) 0570 * @{ 0571 */ 0572 0573 /*! 0574 * @brief Enable or disable the Monotonic Counter. 0575 * 0576 * @param base SNVS peripheral base address 0577 * @param enable Pass true to enable, false to disable. 0578 */ 0579 static inline void SNVS_LP_EnableMonotonicCounter(SNVS_Type *base, bool enable) 0580 { 0581 if (enable) 0582 { 0583 base->LPCR |= SNVS_LPCR_MC_ENV_MASK; 0584 } 0585 else 0586 { 0587 base->LPCR &= (~SNVS_LPCR_MC_ENV_MASK); 0588 } 0589 } 0590 0591 /*! 0592 * @brief Get the current Monotonic Counter. 0593 * 0594 * @param base SNVS peripheral base address 0595 * @return Current Monotonic Counter value. 0596 */ 0597 uint64_t SNVS_LP_GetMonotonicCounter(SNVS_Type *base); 0598 0599 /*! 0600 * @brief Increase the Monotonic Counter. 0601 * 0602 * Increase the Monotonic Counter by 1. 0603 * 0604 * @param base SNVS peripheral base address 0605 */ 0606 static inline void SNVS_LP_IncreaseMonotonicCounter(SNVS_Type *base) 0607 { 0608 /* Write to the LPSMCLR or LPSMCLR, the counter increases. */ 0609 *((volatile uint32_t *)(uint32_t)(&(base->LPSMCLR))) = 0xFFFFFFFFU; 0610 } 0611 0612 /*! @}*/ 0613 0614 /*! 0615 * @name Zeroizable Master Key (ZMK) 0616 * @{ 0617 */ 0618 0619 /*! 0620 * @brief Write Zeroizable Master Key (ZMK) to the SNVS registers. 0621 * 0622 * @param base SNVS peripheral base address 0623 * @param ZMKey The ZMK write to the SNVS register. 0624 */ 0625 void SNVS_LP_WriteZeroizableMasterKey(SNVS_Type *base, uint32_t ZMKey[SNVS_ZMK_REG_COUNT]); 0626 0627 /*! 0628 * @brief Set Zeroizable Master Key valid. 0629 * 0630 * This API could only be called when using software programming mode. After writing 0631 * ZMK using @ref SNVS_LP_WriteZeroizableMasterKey, call this API to make the ZMK 0632 * valid. 0633 * 0634 * @param base SNVS peripheral base address 0635 * @param valid Pass true to set valid, false to set invalid. 0636 */ 0637 static inline void SNVS_LP_SetZeroizableMasterKeyValid(SNVS_Type *base, bool valid) 0638 { 0639 if (valid) 0640 { 0641 base->LPMKCR |= SNVS_LPMKCR_ZMK_VAL_MASK; 0642 } 0643 else 0644 { 0645 base->LPMKCR &= (~SNVS_LPMKCR_ZMK_VAL_MASK); 0646 } 0647 } 0648 0649 /*! 0650 * @brief Get Zeroizable Master Key valid status. 0651 * 0652 * In hardware programming mode, call this API to check whether the ZMK is valid. 0653 * 0654 * @param base SNVS peripheral base address 0655 * @return true if valid, false if invalid. 0656 */ 0657 static inline bool SNVS_LP_GetZeroizableMasterKeyValid(SNVS_Type *base) 0658 { 0659 return (SNVS_LPMKCR_ZMK_VAL_MASK == (base->LPMKCR & SNVS_LPMKCR_ZMK_VAL_MASK)); 0660 } 0661 0662 /*! 0663 * @brief Set Zeroizable Master Key programming mode. 0664 * 0665 * @param base SNVS peripheral base address 0666 * @param mode ZMK programming mode. 0667 */ 0668 static inline void SNVS_LP_SetZeroizableMasterKeyProgramMode(SNVS_Type *base, snvs_lp_zmk_program_mode_t mode) 0669 { 0670 if (kSNVS_ZMKSoftwareProgram == mode) 0671 { 0672 base->LPMKCR &= (~SNVS_LPMKCR_ZMK_HWP_MASK); 0673 } 0674 else 0675 { 0676 base->LPMKCR |= SNVS_LPMKCR_ZMK_HWP_MASK; 0677 } 0678 } 0679 0680 /*! 0681 * @brief Enable or disable Zeroizable Master Key ECC. 0682 * 0683 * @param base SNVS peripheral base address 0684 * @param enable Pass true to enable, false to disable. 0685 */ 0686 static inline void SNVS_LP_EnableZeroizableMasterKeyECC(SNVS_Type *base, bool enable) 0687 { 0688 if (enable) 0689 { 0690 base->LPMKCR |= SNVS_LPMKCR_ZMK_ECC_EN_MASK; 0691 } 0692 else 0693 { 0694 base->LPMKCR &= (~SNVS_LPMKCR_ZMK_ECC_EN_MASK); 0695 } 0696 } 0697 0698 /*! 0699 * @brief Set SNVS Master Key mode. 0700 * 0701 * @param base SNVS peripheral base address 0702 * @param mode Master Key mode. 0703 * @note When @ref kSNVS_ZMK or @ref kSNVS_CMK used, the SNVS_HP must be configured 0704 * to enable the master key selection. 0705 */ 0706 static inline void SNVS_LP_SetMasterKeyMode(SNVS_Type *base, snvs_lp_master_key_mode_t mode) 0707 { 0708 uint32_t lpmkcr = base->LPMKCR; 0709 lpmkcr = (lpmkcr & (~SNVS_LPMKCR_MASTER_KEY_SEL_MASK)) | SNVS_LPMKCR_MASTER_KEY_SEL(mode); 0710 base->LPMKCR = lpmkcr; 0711 } 0712 0713 #if defined(FSL_FEATURE_SNVS_HAS_STATE_TRANSITION) && (FSL_FEATURE_SNVS_HAS_STATE_TRANSITION > 0) 0714 /*! 0715 * brief Transition SNVS SSM state to Trusted/Non-secure from Check state 0716 * 0717 * param base SNVS peripheral base address 0718 * 0719 * return kStatus_Success: Success in transitioning SSM State 0720 * kStatus_Fail: SSM State transition failed 0721 */ 0722 status_t SNVS_LP_SSM_State_Transition(SNVS_Type *base); 0723 #endif /* FSL_FEATURE_SNVS_HAS_STATE_TRANSITION */ 0724 0725 /*! @}*/ 0726 0727 #if defined(__cplusplus) 0728 } 0729 #endif 0730 0731 /*! @}*/ 0732 0733 #endif /* _FSL_SNVS_LP_H_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |