1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| #include "stm32f10x.h"
void Delay(unsigned int count) { unsigned int i; for (; count != 0; count--) { i = 5000; while (i--); } }
void SMG_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC, ENABLE); GPIO_InitStructure.GPIO_Pin = 0x00ff; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = 0x003f; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure); }
uint16_t table[] = {0xc8,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; uint16_t wei[] = {0x0fe,0x0fd,0x0fb,0x0f7,0x0ef,0x0df,0xff,0xff}; uint8_t i;
void main(void) { SMG_Init(); while (1) { for(i=1;i<7;i++) { GPIO_Write(GPIOB,wei[i-1]); GPIO_Write(GPIOC,table[i]); Delay(50); GPIO_Write(GPIOB,0x0ff); Delay(50); } } }
|