⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lights.c

📁 intel 196ea 例程
💻 C
字号:
/*
** This example is designed to use with the 196EA evalution board.
** It displays different patterns using vertical windowing.
*/

/* Include the model dependent SFR include file */
#include _SFR_H_

#define TIME            300

#pragma windowram(0x100-0x17F)

struct pattern
{
    int size;
    unsigned char *array;
};


/* IMPORT functions */
extern void             wait_ms( int );

/* LOCAL functions */
static  void            enable_led( void );
static  void            set_led( register unsigned char );
static  void            show_pat(struct pattern *_win);

/* Define three different patterns to display. */
unsigned char arr1[]=
{
    0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80,
    0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f
};
_reg struct pattern pat1={16, arr1};

unsigned char arr2[]=
{
    0x11, 0x22, 0x44, 0x88
};
_reg struct pattern pat2={4, arr2};

unsigned char arr3[]=
{
    1, 2, 4, 8, 16, 32, 64, 128
};
_reg struct pattern pat3={8, arr3};

void main(void)
{
    int i;


    enable_led();
	
    while(1)
    {
	/* Show each pattern 16 times, using vertical windowing. */	
        for(i=0;i<16;i++)	
        {
            show_pat(&pat1);
        }
		
        for(i=0;i<16;i++)	
        {
            show_pat(&pat2);
        }
        
        for(i=0;i<16;i++)	
        {
            show_pat(&pat3);
        }
    }
}

volatile struct pattern test;

/* Show a pattern on the leds.
** This pattern is accessed through vertical windowing.
*/
static void show_pat(struct pattern *_win display)
{
    int	i;

    test.size=display->size;
    test.array[0]=display->array[0];

    for ( i=0; i < display->size; i++ )
    {
        set_led( (display->array)[i] );
        wait_ms(TIME);
    }
}

/* LED I/O is connect to Port 1 */
static void enable_led( void )
{
    /* Clear leds before enable */
    p11_reg=0;
    /* Set all pins of port1 to open-drain output (external pull-up). */
    p11_dir=0;
}

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. */
    p11_reg=b;
}

⌨️ 快捷键说明

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