00001 /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 00002 * 00003 * The information contained herein is confidential property of Nordic 00004 * Semiconductor ASA.Terms and conditions of usage are described in detail 00005 * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 00006 * 00007 * Licensees are granted free, non-transferable use of the information. NO 00008 * WARRENTY of ANY KIND is provided. This heading must NOT be removed from 00009 * the file. 00010 * 00011 * $LastChangedRevision: 133 $ 00012 */ 00013 00018 #include <stdint.h> 00019 #include <stdbool.h> 00020 00021 #include "nrf24le1.h" 00022 #include "nordic_common.h" 00023 #include "hal_rng.h" 00024 00025 void hal_rng_power_up(bool pwr_up) 00026 { 00027 if(pwr_up) 00028 { 00029 RNGCTL = (RNGCTL | BIT_7); // powerUp bit = 1, power up the RNG 00030 } 00031 else 00032 { 00033 RNGCTL = (RNGCTL & ~(BIT_7)); // powerUp bit = 0, turn off the RNG 00034 } 00035 } 00036 00037 void hal_rng_bias_corr_enable(bool en) 00038 { 00039 if(en) 00040 { 00041 RNGCTL = (RNGCTL | BIT_6); // correctorEn bit = 1, turn on corrector 00042 } 00043 else 00044 { 00045 RNGCTL = (RNGCTL & ~(BIT_6)); // correctorEn bit = 0, turn off corrector 00046 } 00047 } 00048 00049 uint8_t hal_rng_read(void) 00050 { 00051 return RNGDAT; // Return data stored in RNGDAT register 00052 } 00053 00054 bool hal_rng_data_ready(void) 00055 { 00056 return((RNGCTL & BIT_5) > 0); // Return true if data ready bit is 1 00057 }