- 博客(0)
- 资源 (1)
- 收藏
- 关注
STM32函数指针 数码管显示 寄存器版本
#include "stm32f10x.h"
#include "spi.h"
#include "delay.h"
void Storage_Data()
{
GPIO_ResetBits(GPIOB,GPIO_Pin_10); //ST_CP L
delay_us(1);
GPIO_SetBits(GPIOB,GPIO_Pin_10); //ST_CP H
delay_us(1);
GPIO_ResetBits(GPIOB,GPIO_Pin_10); //ST_CP L
}
u8 Seg_Table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
int main(void)
{
u8 Seg_Index = 0;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE); //使能PB端口时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //ST_CP-->PB.10端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; //IO口速度为2MHz
GPIO_Init(GPIOB, &GPIO_InitStructure); //根据设定参数初始化GPIOB.10
GPIO_SetBits(GPIOB,GPIO_Pin_10); //PB.10 输出高
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; //OE-->PB.11端口配置
GPIO_Init(GPIOB, &GPIO_InitStructure); //推挽输出 ,IO口速度为2MHz
GPIO_ResetBits(GPIOB,GPIO_Pin_11); //PB.10 输出低,使能595输出
delay_init();
SPI2_Init();
while(1)
{
for(Seg_In dex = 0; Seg_Index < 16; Seg_Index++)
{
SPI2_ReadWriteByte(Seg_Table[Seg_Index]); //启动传输
Storage_Data();
delay_ms(500);
}
}
}
2014-06-20
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人