fine GPIOA_PUPDR *(volatile unsigned long *)0x4002000C
#define RCC_AHB1ENR *(volatile unsigned long *)0x40023830
#define GPIOA_BSRR *(volatile unsigned long *)0x40020018
//typedef struct
//{
// __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */
// __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */
// __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */
// __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */
// __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */
// __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */
// __IO uint16_t BSRRL; /*!< GPIO port bit set/reset low register, Address offset: 0x18 */
// __IO uint16_t BSRRH; /*!< GPIO port bit set/reset high register, Address offset: 0x1A */
// __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */
// __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */
//} GPIO_TypeDef;
void delay_ms(int time)
{
int i=8000*time;
while(i--);
}
int main(void)
{
// delay_init(168);
int i = 0, j = 0, k = 0;
RCC_AHB1ENR |= 0x00000001;
GPIOA_MODER &= ~((3<<(6*2))|(3<<(7*2)));
GPIOA_MODER |= (1<< (6*2))|(1<<(7*2));
GPIOA_BSRR &= 0x0; //clear
/* Speed mode configuration */
// GPIOA_OSPEEDR &= ~((3<<(6*2))|(3<<(7*2)));
// GPIOA_OSPEEDR |= (3 << (6 * 2))|(3 << (7 * 2));
/* Output mode configuration*/
// GPIOA_OTYPER &= ~((3<<6)|(3<<7)) ;
// GPIOA_OTYPER |= (0 << 6)|(0 << 7);
/* Pull-up Pull down resistor configuration*/
// GPIOA_PUPDR &= ~((3<<(6*2))|(3<<(7*2)));
// GPIOA_PUPDR |= (1<< (6*2))|(1<<(7*2));
// GPIOA_BSRRL = 0x0040|0x0080;
while(1)
{
GPIOA_BSRR = (0x0040|0x0080)<<16; //reset
delay_ms(1000);
GPIOA_BSRR = 0x0040|0x0080; //set
delay_ms(1000);
}
}
void SystemInit()
{
;
}
以上代码便可以实现流水灯例子。
|