mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers trng_api.h Source File

trng_api.h

00001 
00002 /** \addtogroup hal */
00003 /** @{*/
00004 /* mbed Microcontroller Library
00005  * Copyright (c) 2016 ARM Limited
00006  * SPDX-License-Identifier: Apache-2.0
00007  *
00008  * Licensed under the Apache License, Version 2.0 (the "License");
00009  * you may not use this file except in compliance with the License.
00010  * You may obtain a copy of the License at
00011  *
00012  *     http://www.apache.org/licenses/LICENSE-2.0
00013  *
00014  * Unless required by applicable law or agreed to in writing, software
00015  * distributed under the License is distributed on an "AS IS" BASIS,
00016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017  * See the License for the specific language governing permissions and
00018  * limitations under the License.
00019  */
00020 #ifndef MBED_TRNG_API_H
00021 #define MBED_TRNG_API_H
00022 
00023 #include <stddef.h>
00024 #include "device.h"
00025 
00026 #if DEVICE_TRNG
00027 
00028 /** TRNG HAL structure. trng_s is declared in the target's HAL
00029  */
00030 typedef struct trng_s trng_t;
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 /**
00037  * \defgroup hal_trng TRNG hal functions
00038  * @{
00039  */
00040 
00041 /** Initialize the TRNG peripheral
00042  *
00043  * @param obj The TRNG object
00044  */
00045 void trng_init(trng_t *obj);
00046 
00047 /** Deinitialize the TRNG peripheral
00048  *
00049  * @param obj The TRNG object
00050  */
00051 void trng_free(trng_t *obj);
00052 
00053 /** Get random data from TRNG peripheral
00054  *
00055  * @param obj The TRNG object
00056  * @param output The pointer to an output array
00057  * @param length The size of output data, to avoid buffer overwrite
00058  * @param output_length The length of generated data
00059  * @return 0 success, -1 fail
00060  */
00061 int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length);
00062 
00063 /**@}*/
00064 
00065 #ifdef __cplusplus
00066 }
00067 #endif
00068 
00069 #endif
00070 
00071 #endif
00072 
00073 /** @}*/