unsignedchardisp[38][8]=
{
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C},//0
{0x10,0x30,0x50,0x10,0x10,0x10,0x10,0x10},//1
{0x7E,0x02,0x02,0x7E,0x40,0x40,0x40,0x7E},//2
...
{0x8,0x14,0x22,0x3E,0x22,0x22,0x22,0x22},//A
{0x3C,0x22,0x22,0x3E,0x22,0x22,0x3C,0x0},//B
{0x3C,0x40,0x40,0x40,0x40,0x40,0x3C,0x0},//C
...
{0x8,0x7F,0x49,0x49,0x7F,0x08,0x08,0x08},//中
{0xFE,0xBA,0x92,0xBA,0x92,0x9A,0xBA,0xFE},//国
};
void delay(i16 del)
{
for (u32 i = 0; i < del; ++i) {
for (u32var = 0; var< 5000; ++var) {
NOP();
}
}
}
voidWrite_Max7219_byte(unsignedchar DATA)
{
unsigned char i;
GPIO_SET_OUTPUT_PIN_TO_0(GPIOA_BASE_ADDR,GPIO_PIN0);
for(i=8;i>=1;i--)
{
GPIO_SET_OUTPUT_PIN_TO_0(GPIOA_BASE_ADDR,GPIO_PIN2);
if(DATA&0x80) GPIO_SET_OUTPUT_PIN_TO_1(GPIOA_BASE_ADDR,GPIO_PIN1);
else GPIO_SET_OUTPUT_PIN_TO_0(GPIOA_BASE_ADDR,GPIO_PIN1);
delay(1);
DATA=DATA<<1;
GPIO_SET_OUTPUT_PIN_TO_1(GPIOA_BASE_ADDR,GPIO_PIN2);
delay(1);
}
}
void Write_Max7219(char address,char dat)
{
GPIO_SET_OUTPUT_PIN_TO_0(GPIOA_BASE_ADDR,GPIO_PIN0);
Write_Max7219_byte(address);
Write_Max7219_byte(dat);
GPIO_SET_OUTPUT_PIN_TO_1(GPIOA_BASE_ADDR,GPIO_PIN0);
}
voidInit_MAX7219(void)
{
Write_Max7219(0x0b, 0x07);
Write_Max7219(0x0c, 0x01);
Write_Max7219(0x0f, 0x00);
}
void thread0_main(void){//使能了GPIOA的时钟INTDEV_SET_CLK_RST(GPIOA_BASE_ADDR,(INTDEV_RUN|INTDEV_IS_GROUP0|INTDEV_CLK_IS_CORECLK_DIV2));//将PA0设置为输出模式GPIO_SET_OUTPUT_EN_VALUE(GPIOA_BASE_ADDR,(GPIO_PIN0),GPIO_SET_ENABLE);GPIO_SET_OUTPUT_EN_VALUE(GPIOA_BASE_ADDR,(GPIO_PIN1),GPIO_SET_ENABLE);GPIO_SET_OUTPUT_EN_VALUE(GPIOA_BASE_ADDR,(GPIO_PIN2),GPIO_SET_ENABLE);Init_MAX7219();delay(100);while(1){for(u32 j=0;j<38;j++){for(u32 i=1;i<9;i++)Write_Max7219(i,disp[j][i-1]);delay(100);}}thread_end();}
作者:jinglixixi_457498010
来源:面包板社区
链接:https://mbb.eet-china.com/blog/467667-436229.html
版权声明:本文为博主原创,未经本人允许,禁止转载!
☝长按图片,扫码申请☝