From 6da5515e1cd5d28ad2d2f2b3946ba0dbedf9e9a0 Mon Sep 17 00:00:00 2001 From: 0xc0170 Date: Fri, 16 Sep 2016 10:58:04 +0100 Subject: [PATCH] HAL: add RGN API Provides init, free and get numbers functions. --- hal/hal/rng_api.h | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 hal/hal/rng_api.h diff --git a/hal/hal/rng_api.h b/hal/hal/rng_api.h new file mode 100644 index 0000000000..6937955faa --- /dev/null +++ b/hal/hal/rng_api.h @@ -0,0 +1,67 @@ +/* mbed Microcontroller Library + * Copyright (c) 2016 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MBED_RNG_API_H +#define MBED_RNG_API_H + +#include +#include "device.h" + +#if DEVICE_RNG + +/** RNG HAL structure. rng_s is declared in the target's HAL + */ +typedef struct rng_s rng_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup hal_rng RNG hal functions + * @{ + */ + +/** Initialize the RNG peripheral + * + * @param obj The RNG object + */ +void rng_init(rng_t *obj); + +/** Deinitialize the RNG peripheral + * + * @param obj The RNG object + */ +void rng_free(rng_t *obj); + +/** Get random data from RNG peripheral + * + * @param obj The RNG object + * @param output The pointer to an output array + * @param length The length of output data + * @param output_length The length of generated data + * @return 0 success, -1 fail + */ +int rng_get_numbers(rng_t *obj, uint8_t *output, size_t length, size_t *output_length); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif + +#endif