TA的每日心情 | 慵懒 2018-11-14 04:19 |
---|
签到天数: 46 天 连续签到: 1 天 [LV.5]常住居民I
|
本帖最后由 crazy78 于 2017-3-8 00:35 编辑
- #include "stm32f4xx.h"
- #include "transceiver_internal.h"
- uint8_t state = 0;
- void TIM1_UP_TIM10_IRQHandler()
- {
- if (TIM10->SR &0x01)
- TIM10->SR &= ~ 0x01;
- {
- switch(state)
- {
- case STATE_IS_0:
- {
- TIM_SetAutoreload(TIM10,500);
- GPIOG->ODR = 0x00006000;
- state = STATE_IS_1;
- }
- break;
- case STATE_IS_1:
- {
- TIM_SetAutoreload(TIM10,500);
- GPIOG->ODR = 0x00000000;
- state = STATE_IS_0;
- }
- break;
- default:
- break;
- }
- }
- }
- int main()
- {
- RCC->AHB1ENR |= 0x00000040;//GPIOG
- RCC->APB2ENR |= 0x00020000; // Timer
- GPIOG->MODER = 0x14000000; //
- GPIOG->OSPEEDR = 0x3C000000; //GPIOG 13,14
- TIM10->CR1=0x0080; //
- TIM10->PSC =42000-1; // prescaler
- TIM10->ARR = 80; //
- TIM10->DIER=0x0001;
- NVIC->ISER[0] = 0x02000000;//
- TIM10->CR1|=0x0001; // Counter Enable
-
- while(1)
- {
- }
- }
复制代码- #ifndef TRANCEIVER_INTERNAL_H_
- #define TRANCEIVER_INTERNAL_H_
- enum{
-
- STATE_IS_0,
- STATE_IS_1,
- STATE_IS_2,
- STATE_IS_3,
- STATE_IS_4,
- STATE_IS_5,
- STATE_IS_6,
- STATE_IS_7,
- STATE_IS_8,
- STATE_IS_9,
- STATE_IS_10,
- STATE_IS_11,
- STATE_IS_12,
- STATE_IS_13,
- STATE_IS_14,
- STATE_IS_15,
- STATE_IS_16,
- STATE_IS_17,
- STATE_IS_18,
- STATE_IS_19,
- STATE_IS_20,
- STATE_IS_21,
- STATE_IS_22,
- STATE_IS_23,
- STATE_IS_24,
- STATE_IS_25,
- STATE_IS_26,
- };
- #endif
复制代码 |
|