|
首先给IAR安装F450的支持文件。最近安装了IAR8,界面比之前的清爽多了。
F450基本的芯片结构和F103还是很像的,就是外设库的风格简直不像是出自同一家公司
下面先来点灯- #define BITMEM_BASE 0x20000000UL
- #define BITBAND_BASE 0x22000000UL
- #define BITPHMEM_BASE 0x40000000UL
- #define BITPHBAND_BASE 0x42000000UL
- #define MEM32(addr) (*(uint32_t *)(uint32_t)(addr))
- #define AliasAddr(addr,bitnum) (BITBAND_BASE + (addr-BITMEM_BASE)*32+ bitnum*4)
- #define PhAliasAddr(addr,bitnum) (BITPHBAND_BASE + (addr-BITPHMEM_BASE)*32+ bitnum*4)
- #define PAOout(n) MEM32(PhAliasAddr(GPIOA+0x14,n)) //Output
- #define PAIn(n) MEM32(PhAliasAddr(GPIOA+0x10,n) //Input
- #define PBOut(n) MEM32(PhAliasAddr(GPIOB+0x14,n)) //Output
- #define PBIn(n) MEM32(PhAliasAddr(GPIOB+0x10,n) //Input
- #define PCOut(n) MEM32(PhAliasAddr(GPIOC+0x14,n)) //Output
- #define PCIn(n) MEM32(PhAliasAddr(GPIOC+0x10,n) //Input
- #define PDOut(n) MEM32(PhAliasAddr(GPIOD+0x14,n)) //Output
- #define PDIn(n) MEM32(PhAliasAddr(GPIOD+0x10,n) //Input
- #define PEOut(n) MEM32(PhAliasAddr(GPIOE+0x14,n)) //Output
- #define PEIn(n) MEM32(PhAliasAddr(GPIOE+0x10,n) //Input
- #define PFOut(n) MEM32(PhAliasAddr(GPIOF+0x14,n)) //Output
- #define PFIn(n) MEM32(PhAliasAddr(GPIOF+0x10,n) //Input
- #define PGOut(n) MEM32(PhAliasAddr(GPIOG+0x14,n)) //Output
- #define PGIn(n) MEM32(PhAliasAddr(GPIOG+0x10,n) //Input
- #define Led1() PBOut(4)
- #define Led2() PBOut(3)
- #define Led3() PDOut(7)
- #define KeyB2St() PAIn(0)
- #define KeyB3St() PEIn(0)
- #define KeyB4St() PEIn(1)
- /*****************************************************************************//*!
- * @brief port init.
- *
- * @param none
- *
- * @return none
- *
- * @ Pass/ Fail criteria: none
- *****************************************************************************/
- void PortInit()
- {
- rcu_periph_clock_enable(RCU_GPIOA);
- rcu_periph_reset_enable(RCU_GPIOARST);
- rcu_periph_reset_disable(RCU_GPIOARST);
-
- rcu_periph_clock_enable(RCU_GPIOB);
- rcu_periph_reset_enable(RCU_GPIOBRST);
- rcu_periph_reset_disable(RCU_GPIOBRST);
-
- rcu_periph_clock_enable(RCU_GPIOC);
- rcu_periph_reset_enable(RCU_GPIOCRST);
- rcu_periph_reset_disable(RCU_GPIOCRST);
-
- rcu_periph_clock_enable(RCU_GPIOD);
- rcu_periph_reset_enable(RCU_GPIODRST);
- rcu_periph_reset_disable(RCU_GPIODRST);
-
- rcu_periph_clock_enable(RCU_GPIOE);
- rcu_periph_reset_enable(RCU_GPIOERST);
- rcu_periph_reset_disable(RCU_GPIOERST);
-
- rcu_periph_clock_enable(RCU_GPIOF);
- rcu_periph_reset_enable(RCU_GPIOFRST);
- rcu_periph_reset_disable(RCU_GPIOFRST);
-
- rcu_periph_clock_enable(RCU_GPIOG);
- rcu_periph_reset_enable(RCU_GPIOGRST);
- rcu_periph_reset_disable(RCU_GPIOGRST);
-
- rcu_periph_clock_enable(RCU_GPIOH);
- rcu_periph_reset_enable(RCU_GPIOHRST);
- rcu_periph_reset_disable(RCU_GPIOHRST);
-
- rcu_periph_clock_enable(RCU_GPIOI);
- rcu_periph_reset_enable(RCU_GPIOIRST);
- rcu_periph_reset_disable(RCU_GPIOIRST);
-
- //LED
- gpio_mode_set(GPIOB,GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, GPIO_PIN_3 | GPIO_PIN_4);
- gpio_output_options_set(GPIOB,GPIO_OTYPE_PP,GPIO_OSPEED_2MHZ,GPIO_PIN_3 | GPIO_PIN_4);
- //LED
- gpio_mode_set(GPIOD,GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, GPIO_PIN_7);
- gpio_output_options_set(GPIOD,GPIO_OTYPE_PP,GPIO_OSPEED_2MHZ,GPIO_PIN_7);
- //KEY
- gpio_mode_set(GPIOA,GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO_PIN_0);
- gpio_output_options_set(GPIOA,GPIO_OTYPE_PP,GPIO_OSPEED_2MHZ,GPIO_PIN_0);
- gpio_mode_set(GPIOE,GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO_PIN_0 | GPIO_PIN_1);
- gpio_output_options_set(GPIOE,GPIO_OTYPE_PP,GPIO_OSPEED_2MHZ,GPIO_PIN_0 | GPIO_PIN_1);
- }
- //点灯任务
- if(bPulse_1s){
- TimeRun();
- Led1() = !Led1();
- }
-
- if(bPulse_250ms){
- Led2() = !Led2();
- }
-
- if(bPulse_125ms){
- if( Led1())
- Led3() = !Led3();
- }
复制代码 |
-
F450IAR
-
IarCof450
|