完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
|
相关推荐
1个回答
|
|
整个keil工程下载 https://download.csdn.net/download/qq_20490553/12918735
#ifndef _LED_H #define _LED_H /* 包含的头文件 --------------------------------------------------------------*/ #include "stm32f10x.h" /* 宏定义 --------------------------------------------------------------------*/ #define HUB08_LA GPIO_Pin_7 #define HUB08_LB GPIO_Pin_8 #define HUB08_LC GPIO_Pin_9 #define HUB08_LD GPIO_Pin_10 #define HUB08_G1 GPIO_Pin_11 #define HUB08_G2 GPIO_Pin_12 #define HUB08_LT GPIO_Pin_13 #define HUB08_SK GPIO_Pin_14 #define HUB08_EN GPIO_Pin_15 #define HUB08_R1 GPIO_Pin_8 #define HUB08_R2 GPIO_Pin_9 #define HUB08_GPIO_PORT GPIOB #define HUB08_GPIO_CLK RCC_APB2Periph_GPIOB #define HUB08_GPIO_PORTA GPIOA #define HUB08_GPIO_CLKA RCC_APB2Periph_GPIOA #define HUB08_LA_1 GPIO_SetBits(HUB08_GPIO_PORT, HUB08_LA) #define HUB08_LA_0 GPIO_ResetBits(HUB08_GPIO_PORT, HUB08_LA) #define HUB08_LB_1 GPIO_SetBits(HUB08_GPIO_PORT, HUB08_LB) #define HUB08_LB_0 GPIO_ResetBits(HUB08_GPIO_PORT, HUB08_LB) #define HUB08_LC_1 GPIO_SetBits(HUB08_GPIO_PORT, HUB08_LC) #define HUB08_LC_0 GPIO_ResetBits(HUB08_GPIO_PORT, HUB08_LC) #define HUB08_LD_1 GPIO_SetBits(HUB08_GPIO_PORT, HUB08_LD) #define HUB08_LD_0 GPIO_ResetBits(HUB08_GPIO_PORT, HUB08_LD) #define HUB08_G1_1 GPIO_SetBits(HUB08_GPIO_PORT, HUB08_G1) #define HUB08_G1_0 GPIO_ResetBits(HUB08_GPIO_PORT, HUB08_G1) #define HUB08_G2_1 GPIO_SetBits(HUB08_GPIO_PORT, HUB08_G2) #define HUB08_G2_0 GPIO_ResetBits(HUB08_GPIO_PORT, HUB08_G2) #define HUB08_R1_1 GPIO_SetBits(HUB08_GPIO_PORTA, HUB08_R1) #define HUB08_R1_0 GPIO_ResetBits(HUB08_GPIO_PORTA, HUB08_R1) #define HUB08_R2_1 GPIO_SetBits(HUB08_GPIO_PORTA, HUB08_R2) #define HUB08_R2_0 GPIO_ResetBits(HUB08_GPIO_PORTA, HUB08_R2) #define HUB08_EN_1 GPIO_SetBits(HUB08_GPIO_PORT, HUB08_EN) #define HUB08_EN_0 GPIO_ResetBits(HUB08_GPIO_PORT, HUB08_EN) #define HUB08_LT_1 GPIO_SetBits(HUB08_GPIO_PORT, HUB08_LT) #define HUB08_LT_0 GPIO_ResetBits(HUB08_GPIO_PORT, HUB08_LT) #define HUB08_SK_1 GPIO_SetBits(HUB08_GPIO_PORT, HUB08_SK) #define HUB08_SK_0 GPIO_ResetBits(HUB08_GPIO_PORT, HUB08_SK) void LED_Show_Update(void) ; void write_595(uint8_t DR1,uint8_t DG1,uint8_t DR2,uint8_t DG2); void HUB08_GPIO_Init(void); #endif /* _LED_H */ #include "bsp.h" uint8_t disp_table[][48]= { {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEF,0xFF,0x0F,0xFC,0x0F,0xFC,0x1F,0xFE,0x3F,0xFF,0xFF,0xFF,0x27,0xFF,0x03,0xFC,0x1F,0xF8,0x3F,0xFB,0x3F}, {0xFF,0x3F,0xFE,0x1F,0xFE,0xDF,0xFE,0xEF,0xFC,0xE7,0xFD,0xF3,0xFB,0xF0,0xE3,0xF0,0xF7,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},/*"天",0*/ {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFB,0xFF,0xF3,0xFF,0x37,0xFF,0x6F,0xFF,0x63,0xF7,0xC1,0xE7,0x1F,0xF4,0x1F,0xFF,0xA7,0xFF,0x87,0xFF,0x37,0xE7,0x17,0xF7,0x17}, {0xF7,0x77,0xF7,0x17,0xF7,0x77,0xF7,0x57,0xFB,0x17,0xFB,0x67,0xF1,0xF7,0xC0,0x7F,0xFF,0x9F,0xFF,0xE0,0xFF,0xF0,0xFF,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},/*"道",1*/ {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF3,0xFF,0xF3,0xFF,0xF7,0xFB,0x77,0xC1,0x77,0x83,0x57,0x87,0x57,0xB7,0x57,0xC3,0x57,0x83,0x57,0xAA,0x07}, {0xA9,0x17,0xA1,0x57,0xA3,0x57,0xB2,0xD7,0xBA,0xD7,0x8A,0xD7,0xBA,0xD7,0xA8,0xF7,0x88,0xF7,0xB1,0xF7,0xFB,0xF7,0xFF,0xF7,0xFF,0xF3,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},/*"酬",2*/ {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xFF,0xFC,0xFF,0xED,0xFF,0xED,0xFF,0xEC,0xFF,0xE0,0xFF,0xC9,0xFF,0xC3,0xEF,0xE3,0xEF,0xF7,0xEF,0xF0,0xC7,0xE4,0x03,0xD4,0x49}, {0xD1,0xC9,0xC1,0xDB,0xE1,0xDB,0xF1,0x9B,0xE1,0xBB,0xF1,0xB3,0xE3,0x33,0xF1,0x77,0xF2,0x37,0xE6,0xC7,0x8F,0xC7,0xFF,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},/*"勤",3*/ }; /************************************************ 函数名称 : HUB08_GPIO_Init 功 能 : LED端口初始化 参 数 : 无 返 回 值 : 无 作 者 : LXP *************************************************/ void HUB08_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; /* 使能RCC */ RCC_APB2PeriphClockCmd(HUB08_GPIO_CLK|HUB08_GPIO_CLKA , ENABLE); GPIO_InitStructure.GPIO_Pin = HUB08_LA|HUB08_LB|HUB08_LC|HUB08_LD|HUB08_G1|HUB08_G2|HUB08_LT|HUB08_SK|HUB08_EN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(HUB08_GPIO_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = HUB08_R1|HUB08_R2; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(HUB08_GPIO_PORTA, &GPIO_InitStructure); HUB08_EN_0; HUB08_G1_0; HUB08_G2_0; HUB08_R1_0; HUB08_R2_0; } /***************************************************** 函数名称:void write_595() 功能说明:给595写数据 参数: DR1、DG1-上半屏 DR2、DG2-下半屏 返回值: 无 ****************************************************/ void write_595(uint8_t DR1,uint8_t DG1,uint8_t DR2,uint8_t DG2) { uint8_t i; for(i=0;i<8;i++) { if(DR1&0x80) HUB08_R1_1; else HUB08_R1_0; if(DR2&0x80) HUB08_R2_1; else HUB08_R2_0; if(DG1&0x80) HUB08_G1_1; else HUB08_G1_0; if(DG2&0x80) HUB08_G2_1; else HUB08_G2_0; HUB08_SK_0; HUB08_SK_1; DR1<<=1; DR2<<=1; DG1<<=1; DG2<<=1; } } /***************************************************** 函数名称:void LED_Show_Update(void) 功能说明:LED 刷新显示 参数: DR1、DG1-上半屏 DR2、DG2-下半屏 返回值: 无 ****************************************************/ void LED_Show_Update(void) { uint8_t num = 0; uint8_t temp = 0; uint8_t number = 2; for(num=0;num<16;num++) { temp=0; write_595(0xff,disp_table[0+temp][num*number+0],disp_table[1+temp][num*number+0],0xff); write_595(0xff,disp_table[0+temp][num*number+1],disp_table[1+temp][num*number+1],0xff); write_595(0xff,disp_table[2+temp][num*number+0],disp_table[3+temp][num*number+0],0xff); write_595(0xff,disp_table[2+temp][num*number+1],disp_table[3+temp][num*number+1],0xff); write_595(disp_table[4+temp][num*number+0],disp_table[4+temp][num*number+0],0xff,disp_table[5+temp][num*number+0]); write_595(disp_table[4+temp][num*number+1],disp_table[4+temp][num*number+1],0xff,disp_table[5+temp][num*number+1]); write_595(disp_table[6+temp][num*number+0],disp_table[6+temp][num*number+0],0xff,disp_table[7+temp][num*number+0]); write_595(disp_table[6+temp][num*number+1],disp_table[6+temp][num*number+1],0xff,disp_table[7+temp][num*number+1]); GPIOB->ODR = GPIOB->ODR & 0xF87F; GPIOB->ODR |= (num<<7) ; HUB08_LT_1; HUB08_LT_0; HUB08_EN_0; delay_us(100);//调节亮度 HUB08_EN_1; } } 完事后,直接在main.c 调用 LED_Show_Update();即可 int main(void) { SysInit(); delay_init(); while(1) { LED_Show_Update(); } } 来个效果图,及单元板照片 |
|
|
|
只有小组成员才能发言,加入小组>>
3319 浏览 9 评论
2997 浏览 16 评论
3495 浏览 1 评论
9065 浏览 16 评论
4088 浏览 18 评论
1186浏览 3评论
612浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
602浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2338浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1899浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 01:49 , Processed in 1.037644 second(s), Total 76, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号