这是霍尔运转定义,标红处的定义是啥意思

2019-03-23 17:29发布

#include "stm8s.h"  

#define H1_PORT GPIOD->IDR
#define H1_PIN  BIT4

#define H2_PORT GPIOD->IDR
#define H2_PIN  BIT3

#define H3_PORT GPIOD->IDR
#define H3_PIN  BIT2

extern unsigned char St_F;
extern unsigned char FaultF;//故障标志
extern unsigned char Run_dir;
extern unsigned int OutPwmValue;
extern unsigned char bHallStartStep;

#define BIT0 0x01
#define BIT1 0x02
#define BIT2 0x04
#define BIT3 0x08
#define BIT4 0x10
#define BIT5 0x20
#define BIT6 0x40
#define BIT7 0x80

//下桥臂开关控制端口定义
#define MCO0_PORT GPIOB
#define MCO0_PIN        GPIO_PIN_0
#define MCO2_PORT GPIOB
#define MCO2_PIN        GPIO_PIN_1
#define MCO4_PORT GPIOB
#define MCO4_PIN        GPIO_PIN_2

#define PWM_A_ON MCO0_PORT->ODR |= (u8)MCO0_PIN;
#define PWM_B_ON MCO2_PORT->ODR |= (u8)MCO2_PIN;
#define PWM_C_ON MCO4_PORT->ODR |= (u8)MCO4_PIN;

#define PWM_A_OFF MCO0_PORT->ODR &= (u8)(~MCO0_PIN);
#define PWM_B_OFF MCO2_PORT->ODR &= (u8)(~MCO2_PIN);
#define PWM_C_OFF MCO2_PORT->ODR &= (u8)(~MCO4_PIN);

void Init_TIM2(void);
void TIM2_InitCapturePolarity(void);
void ComHandler(void);       


此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
fxyc87
1楼-- · 2019-03-24 00:04
/ 红线处的很好理解啊,
BIT0 =1<<0
BIT1 =1<<1
BIT8 =1<<8

理解了吧?
szc5b
2楼-- · 2019-03-24 06:03
宏定义  方便进行位操作。。这样写出来得代码更直观一点

一周热门 更多>