1 /****************************************************************************** 2 * 3 * Copyright (C) 2023-2025 Analog Devices, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 #ifndef LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_TRNG_H_ 20 #define LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_TRNG_H_ 21 22 /***** Includes *****/ 23 #include <trng.h> 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /* 30 * MAX32665, MAX32666 related mapping 31 */ 32 #if defined(CONFIG_SOC_MAX32665) || (CONFIG_SOC_MAX32666) 33 Wrap_MXC_TRNG_RandomInt_NonBlocking(uint32_t * data)34static inline int Wrap_MXC_TRNG_RandomInt_NonBlocking(uint32_t *data) 35 { 36 if ((MXC_TRNG->st & MXC_F_TRNG_ST_RND_RDY) == 0) { 37 return -1; /* Not ready */ 38 } 39 *data = MXC_TRNG->data; 40 41 return 0; 42 } 43 44 /* 45 * MAX32690, MAX32655 related mapping 46 */ 47 #elif defined(CONFIG_SOC_MAX32690) || defined(CONFIG_SOC_MAX32655) || \ 48 defined(CONFIG_SOC_MAX32670) || defined(CONFIG_SOC_MAX32672) || \ 49 defined(CONFIG_SOC_MAX32662) || defined(CONFIG_SOC_MAX32675) || \ 50 defined(CONFIG_SOC_MAX32680) || defined(CONFIG_SOC_MAX78002) || \ 51 defined(CONFIG_SOC_MAX78000) 52 53 static inline int Wrap_MXC_TRNG_RandomInt_NonBlocking(uint32_t *data) 54 { 55 if ((MXC_TRNG->status & MXC_F_TRNG_STATUS_RDY) == 0) { 56 return -1; /* Not ready */ 57 } 58 *data = MXC_TRNG->data; 59 60 return 0; 61 } 62 #endif // part number 63 64 #ifdef __cplusplus 65 } 66 #endif 67 68 #endif // LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_TRNG_H_ 69