FRDM K64F Metronome

Committer:
ram54288
Date:
Sun May 14 18:37:05 2017 +0000
Revision:
0:dbad57390bd1
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:dbad57390bd1 1 #pragma once
ram54288 0:dbad57390bd1 2
ram54288 0:dbad57390bd1 3 #include "mbed.h"
ram54288 0:dbad57390bd1 4 #include "mbedtls/entropy_poll.h"
ram54288 0:dbad57390bd1 5
ram54288 0:dbad57390bd1 6 namespace utils
ram54288 0:dbad57390bd1 7 {
ram54288 0:dbad57390bd1 8 unsigned entropy_seed()
ram54288 0:dbad57390bd1 9 {
ram54288 0:dbad57390bd1 10 unsigned seed;
ram54288 0:dbad57390bd1 11 size_t length;
ram54288 0:dbad57390bd1 12
ram54288 0:dbad57390bd1 13 unsigned char* seed_bytes = reinterpret_cast<unsigned char*>(&seed);
ram54288 0:dbad57390bd1 14 mbedtls_hardware_poll(NULL, seed_bytes, sizeof(unsigned), &length);
ram54288 0:dbad57390bd1 15
ram54288 0:dbad57390bd1 16 return seed;
ram54288 0:dbad57390bd1 17 }
ram54288 0:dbad57390bd1 18
ram54288 0:dbad57390bd1 19 // Default time of 0.2 seconds is fine for this lab
ram54288 0:dbad57390bd1 20 void pulse(DigitalOut& led, float t = 0.2f)
ram54288 0:dbad57390bd1 21 {
ram54288 0:dbad57390bd1 22 led = false;
ram54288 0:dbad57390bd1 23 wait(t);
ram54288 0:dbad57390bd1 24 led = true;
ram54288 0:dbad57390bd1 25 }
ram54288 0:dbad57390bd1 26 }