📄 random.c
字号:
/******************************************************************************
Filename: random.c
Target: cc2430
Revised: 16/12-2005
Revision: 1.0
Description:
This application shows how to create a random sequence of bytes. The sequence
is displayed on the LCD and used to toggle the green and yellow LEDs.
******************************************************************************/
#include <string.h>
#include "RF04EB.h"
#include "app_ex.h"
#include "menu.h"
#include "lcd128_64.h"
#include "hal.h"
void initRandom(void);
void random_main(void);
/******************************************************************************
* @fn initRandom
*
* @brief
* Initializes the components for the random generator application example.
*
* Parameters:
*
* @param void
*
* @return void
*
******************************************************************************/
void initRandom(void)
{
DISABLE_ALL_INTERRUPTS();
halInitRandomGenerator();
INIT_GLED();
INIT_YLED();
}
/******************************************************************************
* @fn random_main
*
* @brief
* Main function.
*
* Parameters:
*
* @param void
*
* @return void
*
******************************************************************************/
#ifdef COMPLETE_APPLICATION
void random_main(void){
#else
void main(void){
#endif
UINT8 i, rand;
UINT8 arr[13] = {0};
TopDisp = 8;
initRandom();
ClearScreen();
Print(0,5,"--RANDOM TEST--",1);
Rectangle(10 , 3 , 100 , 5);
//read random register
for(i = 0; (i < 12); i++)
{
GET_RANDOM_BYTE(rand);
SET_LED_MASK( rand );
// randChar is equal a random value between 'A' and 'Z'
// in the ascii table
arr[i] = 'A' + (rand % ('z' - 'a')) ;
Print6(4,20, arr,1);
Print6(7,13,"<CANCEL TO ESC>",1);
halWait(0x0F);
}
while (K_CANCEL != ScanKey());
while(ScanKey() != 0Xff);
halWait(5);
GLED = YLED = LED_OFF;
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -