📄 random1.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 "app_ex.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();
// initLcd();
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
BYTE randomChar;
UINT8 i, rand;
UINT8 arr[15];
initRandom();
ClearScreen();
Print6(0,10," --Random text--",1);
Rectangle(2 , 3 , 108 , 6);
while( !stopApplication() ){
//read random register
for(i = 0; (i < 15); i++)
{
GET_RANDOM_BYTE(rand);
SET_LED_MASK( rand );
// randChar is equal a random value between 'a' and 'z'
// in the ascii table
randomChar = 'a' + (rand % ('z' - 'a')) ;
Print6(0,10," --Random text--",1);
// lcdUpdateChar(LINE2, i, randomChar);
halWait(0x0F);
}
LED1 = LED3 = LED_OFF;
}
return;
}
/******************************************************************************
* @fn clockmodes_init
*
* @brief
* Initializes the random generator application example.
*
* Parameters:
*
* @param APPLICATION *a
* Main application
*
* @return void
*
******************************************************************************/
#ifdef COMPLETE_APPLICATION
void random_init(APPLICATION *a){
a->menuText = (char*)"Random";
a->description = (char*)"Sequence";
a->main_func = random_main;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -