#include<stm32f10x_lib.h>
#define SH_CPL GPIOD->ODR|=0<<15
#define SH_CPH GPIOD->ODR|=1<<15
#define ST_CPL GPIOB->ODR|=0<<15
#define ST_CPH GPIOB->ODR|=1<<15
#define DSGPIO GPIOC
#define DSPIN 9
#define GNDP7 GPIOD->ODR|=0<<13
#define GNDP8 GPIOB->ODR|=0<<13
#define VCCP8 GPIOD->ODR|=1<<11
const u8 table[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
void hc595(u8 x){
int i;
for(i=0;i<8;i++){
//DSGPIO->ODR|=((table[x]>>i)&0x01)<<DSPIN;
DSGPIO->ODR|=((table[x]>>(7-i))&0x01)<<DSPIN;
SH_CPL;
SH_CPH;
}
ST_CPL;
ST_CPH;
}
void GPIO_Config(){
RCC->APB2ENR|=1<<(2+1);
RCC->APB2ENR|=1<<(2+2);
RCC->APB2ENR|=1<<(2+3);
GPIOB->CRH&=0x0F0FFFFF;
GPIOB->CRH|=0x30300000;
GPIOC->CRL&=0x0FFFFFFF;
GPIOC->CRL|=0x30000000;
GPIOC->CRH&=0xFFFFFF0F;
GPIOC->CRH|=0x00000030;
GPIOD->CRH&=0x0F0F0F0F;
GPIOD->CRH|=0x30303030;
GNDP7;
GNDP8;
VCCP8;
}
int main(){
int i;
GPIO_Config();
hc595(3);
while(1){
}
}
|