|
主要代码:
#include "pbdata.h"
char j = 5;
char k = 5;
void RGB_io_init(void)
{
P0CON = 0xFF; //设置P0高阻模式
P0PH = 0x00;
P1CON = 0xFF; //设置P1为强推挽模式
P1PH = 0x00;
P2CON = 0xFF; //设置P2为强推挽模式
P2PH = 0x00;
SC93F8332_IO_Init() ; //未引出IO口配置
}
void RGB_output_1()//RGB 数据输出1
{
j = 1;
P00 = 1;
while(j--);
P00 = 0;
}
void RGB_output_0()//RGB 数据输出0
{
j = 1;
P00 = 1;
P00 = 0;
while(j--);
}
void RGB_Set(unsigned long int G8R8B8)
{
int i;
char byte = 0;
for(i = 23;i>=0;i--)
{
byte = ((G8R8B8>>i)&0x1);
if(byte == 1)
{
RGB_output_1();
}
else
{
RGB_output_0();
}
}
}
#define RED 0xFF00//红光
#define GREEN 0xFF0000//绿光
#define BLUE 0xFF//蓝光
#define WHITE 0xFFFFFF//白光
#define CUTOUT 0x000000//不亮
unsigned long int color = 0xFFFFFF;//白光
void main (void)
{
unsigned int i ;
RGB_io_init();//初始化RGB IO
P00=0;
while(1)
{
delay_us(100);
RGB_Set(GREEN);//1
RGB_Set(RED);//2
RGB_Set(GREEN);//3
RGB_Set(BLUE);//4
RGB_Set(GREEN);//5
RGB_Set(WHITE);//6
RGB_Set(BLUE);//7
RGB_Set(RED);//8
delay_ms(100);
for(i = 10000;i>0;i--)
{
RGB_Set(color++);//1
RGB_Set(color++);//2
RGB_Set(color++);//3
RGB_Set(color++);//4
RGB_Set(color++);//5
RGB_Set(color++);//6
RGB_Set(color++);//7
RGB_Set(color++);//8
delay_ms(1);
}
}
}
|
评分
-
查看全部评分
|