main.c
#include "stm32f10x.h"
#include "smg.h"
uint8_t table[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delays(int t){
int i,j;
for(i=0;i<t;i++)
{
for( j = 0 ; j < t ; j++);
}
}
int main(){
uint16_t temp =0;
SMG_Init();
int a=0;
while(1){
for(a=99;a>=0;a--)
{
temp =(table[a/10]<<8) | table[a%10];
GPIO_Write(GPIOC,temp);
delays(500);
}
}
}
smg.c
#include "stm32f10x.h"
#include "smg.h"
void SMG_Init(){
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
smg.h
#ifndef __SMG_H
#define __SMG_H
void SMG_Init(void);
#endif