initrandomgenerator.c

来自「zigbee通信系统中使用芯片cc2430实现点对点通信的源码」· C语言 代码 · 共 45 行

C
45
字号
/******************************************************************************
Filename:     initRandomGenerator.c
Target:       cc2430
Revised:      16/12-2005
Revision:     1.0
******************************************************************************/
#include"hal.h"


#ifndef ADCTSTH
// if ADCTSTH not defined in ioCC2430.h, define it
#define  ADCTSTH ((unsigned char volatile __xdata *) 0)[0xDF3A]
#endif
//-----------------------------------------------------------------------------
// See hal.h for a description of this function.
//-----------------------------------------------------------------------------
void halInitRandomGenerator(void)
{
   BYTE i;

   //turning on power to analog part of radio
   RFPWR = 0x04;

   //waiting for voltage regulator.
   while((RFPWR & 0x10)){}

   //Turning on 32 MHz crystal oscillator
   SET_MAIN_CLOCK_SOURCE(CRYSTAL);

   // Turning on receiver to get output from IF-ADC.
   ISRXON;
   halWait(1);

   ENABLE_RANDOM_GENERATOR();

   for(i = 0 ; i < 32 ; i++)
   {
      RNDH = ADCTSTH;
      CLOCK_RANDOM_GENERATOR();
   }

   return;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?