![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/trng_api.c@3:f3764f852aa8, 2018-10-11 (annotated)
- Committer:
- kadonotakashi
- Date:
- Thu Oct 11 02:27:46 2018 +0000
- Revision:
- 3:f3764f852aa8
- Parent:
- 0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | /* |
kadonotakashi | 0:8fdf9a60065b | 2 | * Hardware entropy collector for the K66F, using Freescale's RNGA |
kadonotakashi | 0:8fdf9a60065b | 3 | * |
kadonotakashi | 0:8fdf9a60065b | 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
kadonotakashi | 0:8fdf9a60065b | 5 | * SPDX-License-Identifier: Apache-2.0 |
kadonotakashi | 0:8fdf9a60065b | 6 | * |
kadonotakashi | 0:8fdf9a60065b | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
kadonotakashi | 0:8fdf9a60065b | 8 | * not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 9 | * You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 10 | * |
kadonotakashi | 0:8fdf9a60065b | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 12 | * |
kadonotakashi | 0:8fdf9a60065b | 13 | * Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
kadonotakashi | 0:8fdf9a60065b | 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 16 | * See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 17 | * limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 18 | * |
kadonotakashi | 0:8fdf9a60065b | 19 | */ |
kadonotakashi | 0:8fdf9a60065b | 20 | |
kadonotakashi | 0:8fdf9a60065b | 21 | /* |
kadonotakashi | 0:8fdf9a60065b | 22 | * Reference: "K66 Sub-Family Reference Manual, Rev. 2", chapter 38 |
kadonotakashi | 0:8fdf9a60065b | 23 | */ |
kadonotakashi | 0:8fdf9a60065b | 24 | |
kadonotakashi | 0:8fdf9a60065b | 25 | #include <stdlib.h> |
kadonotakashi | 0:8fdf9a60065b | 26 | #include "cmsis.h" |
kadonotakashi | 0:8fdf9a60065b | 27 | #include "fsl_trng.h" |
kadonotakashi | 0:8fdf9a60065b | 28 | #include "trng_api.h" |
kadonotakashi | 0:8fdf9a60065b | 29 | |
kadonotakashi | 0:8fdf9a60065b | 30 | void trng_init(trng_t *obj) |
kadonotakashi | 0:8fdf9a60065b | 31 | { |
kadonotakashi | 0:8fdf9a60065b | 32 | (void)obj; |
kadonotakashi | 0:8fdf9a60065b | 33 | trng_config_t trngConfig; |
kadonotakashi | 0:8fdf9a60065b | 34 | TRNG_GetDefaultConfig(&trngConfig); |
kadonotakashi | 0:8fdf9a60065b | 35 | TRNG_Init(TRNG0, &trngConfig); |
kadonotakashi | 0:8fdf9a60065b | 36 | } |
kadonotakashi | 0:8fdf9a60065b | 37 | |
kadonotakashi | 0:8fdf9a60065b | 38 | void trng_free(trng_t *obj) |
kadonotakashi | 0:8fdf9a60065b | 39 | { |
kadonotakashi | 0:8fdf9a60065b | 40 | (void)obj; |
kadonotakashi | 0:8fdf9a60065b | 41 | TRNG_Deinit(TRNG0); |
kadonotakashi | 0:8fdf9a60065b | 42 | } |
kadonotakashi | 0:8fdf9a60065b | 43 | |
kadonotakashi | 0:8fdf9a60065b | 44 | int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length) |
kadonotakashi | 0:8fdf9a60065b | 45 | { |
kadonotakashi | 0:8fdf9a60065b | 46 | (void)obj; |
kadonotakashi | 0:8fdf9a60065b | 47 | |
kadonotakashi | 0:8fdf9a60065b | 48 | if(TRNG_GetRandomData(TRNG0, output, length) != kStatus_Success) return -1; |
kadonotakashi | 0:8fdf9a60065b | 49 | *output_length = length; |
kadonotakashi | 0:8fdf9a60065b | 50 | |
kadonotakashi | 0:8fdf9a60065b | 51 | return 0; |
kadonotakashi | 0:8fdf9a60065b | 52 | } |