📄 t1_ledio.c
字号:
/*
** t1_ledio.c
** Displays a list of patterns with reasonable
** interval. Don't make it too quick or else
** you will only see them being 'n' all the
** time.
*/
#include <stdio.h>
#include <stdlib.h>
#include _SFR_H_
/* IMPORT functions */
extern void wait_ms( int );
/* LOCAL functions */
static void enable_led( void );
static void set_led( unsigned char );
/* LOCAL data */
static const unsigned char patterns[] =
{
0xFF,
0xE7, 0xC3, 0x81, 0x00,
0x18, 0x3C, 0x7E, 0xFF,
0xE7, 0xC3, 0x81, 0x00,
0x18, 0x3C, 0x7E, 0xFF,
0xE7, 0xC3, 0x81, 0x00,
0x18, 0x3C, 0x7E, 0xFF,
0xE7, 0xC3, 0x81, 0x00,
0x18, 0x3C, 0x7E, 0xFF,
0xE7, 0xC3, 0x81, 0x00,
0x18, 0x3C, 0x7E, 0xFF,
0xE7, 0xC3, 0x81, 0x00,
0x18, 0x3C, 0x7E, 0xFF,
0xFE, 0xFC, 0xF8, 0xF0,
0xE0, 0xC0, 0x80, 0x00,
0x01, 0x03, 0x07, 0x0E,
0x1C, 0x38, 0x70, 0xE0,
0xC0, 0x80, 0x00,
0x01, 0x03, 0x07, 0x0F,
0x1F, 0x3F, 0x7F, 0xFF
};
void main(void)
{
unsigned int i;
int j;
set_led( 0 ); /* Clear the LEDs before enabling. */
enable_led();
while ( 1 )
for ( j = 0; j < sizeof( patterns); j++ )
{
set_led( patterns[j] );
wait_ms( 100 );
}
}
/* LED I/O is connect to Port 1 */
static void enable_led( void )
{
/* Set all pins of port1 to open-drain output (external pull-up). */
asm stb 0,p1_dir;
}
static void set_led( register unsigned char b )
{
/* Each bit is a LED in the LED array. */
/* Note that there are ten LEDs,
one is unused,
one is for power-on indication. */
asm stb b,p1_reg;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -