在线时间3 小时
UID3291012
ST金币0
蝴蝶豆7
注册时间2016-6-20
新手上路
- 最后登录
- 2019-3-24
|
发表于 2018-7-6 11:41:34
|
显示全部楼层
a0a.1 32b0c
我用F334的想要GPIO位操作一直不成功,楼主可以帮忙看看吗?
#define EEPROM_SCL_Pin GPIO_Pin_0 /* PB.00 */
#define EEPROM_SCL_GPIOx GPIOB
#define EEPROM_SDA_Pin GPIO_Pin_1 /* PB.01 */
#define EEPROM_SDA_GPIOx GPIOB
/* IIC×ÜÏߣ¬SDAÊý¾ÝÏßµÄÊä³ö·½ÏòÉèÖà */
#define IIC_SDA_IN() {EEPROM_SDA_GPIOx->MODER&=~(3 << (1*2));EEPROM_SDA_GPIOx->MODER|=0 << (1*2);}
#define IIC_SDA_OUT() {EEPROM_SDA_GPIOx->MODER&=~(3 << (1*2));EEPROM_SDA_GPIOx->MODER|=1 << (1*2);}
#define EEPROM_GPIOB_Pin EEPROM_SCL_Pin|EEPROM_SDA_Pin
#define EEPROM_RCC_GPIOx RCC_AHBPeriph_GPIOB
/* IO¿Ú²Ù×÷ºê¶¨Òå */
#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
#define MEM_ADDR(addr) *((volatile unsigned long *)(addr))
#define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum))
/* IO¿ÚµØÖ·Ó³Éä */
#define GPIOA_ODR_Addr (GPIOA_BASE+0x14)
#define GPIOB_ODR_Addr (GPIOB_BASE+0x14)
#define GPIOC_ODR_Addr (GPIOC_BASE+0x14)
#define GPIOD_ODR_Addr (GPIOD_BASE+0x14)
#define GPIOA_IDR_Addr (GPIOA_BASE+0x10)
#define GPIOB_IDR_Addr (GPIOB_BASE+0x10)
#define GPIOC_IDR_Addr (GPIOC_BASE+0x10)
#define GPIOD_IDR_Addr (GPIOD_BASE+0x10)
/* IO¿Ú²Ù×÷£¬Ö»¶Ôµ¥Ò»µÄIO¿Ú */
#define IIC_SCL BIT_ADDR(GPIOB_ODR_Addr,0)
#define IIC_SDA BIT_ADDR(GPIOB_ODR_Addr,1)
#define Read_SDA BIT_ADDR(GPIOB_IDR_Addr,1) |
|