[X9D] I2C eeprom driver fix

This commit is contained in:
bernet.andre@gmail.com
2013-01-06 15:15:06 +00:00
parent 8f5aaad3d6
commit 6b3836e9a2
2 changed files with 12 additions and 7 deletions
+4 -1
View File
@@ -36,6 +36,10 @@ static void I2C_GPIO_Configuration(void)
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(I2C_EE_GPIO, &GPIO_InitStructure);
//Set Idle levels
SDA_H;
SCL_H;
}
short I2C_START()
@@ -209,7 +213,6 @@ void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRe
I2C_SEND_DATA((uint8_t)(ReadAddr & 0x00FF));
I2C_WAIT_ACK();
#endif
I2C_STOP();
I2C_START();
I2C_SEND_DATA(I2C_EEPROM_ADDRESS|EE_CMD_READ);
+8 -6
View File
@@ -26,12 +26,14 @@
#define EE_CMD_READ (1)
#define I2C_delay() do { delayUsec(5); } while(0)
#define SCL_H do{GPIOB->BSRRL = I2C_EE_SCL;}while(0)
#define SCL_L do{GPIOB->BSRRH = I2C_EE_SCL;}while(0)
#define SDA_H do{GPIOB->BSRRL = I2C_EE_SDA;}while(0)
#define SDA_L do{GPIOB->BSRRH = I2C_EE_SDA;}while(0)
#define SCL_read (GPIOB->IDR & I2C_EE_SCL)
#define SDA_read (GPIOB->IDR & I2C_EE_SDA)
#define SCL_H do{I2C_EE_GPIO->BSRRL = I2C_EE_SCL;}while(0)
#define SCL_L do{I2C_EE_GPIO->BSRRH = I2C_EE_SCL;}while(0)
#define SDA_H do{I2C_EE_GPIO->BSRRL = I2C_EE_SDA;}while(0)
#define SDA_L do{I2C_EE_GPIO->BSRRH = I2C_EE_SDA;}while(0)
#define SCL_read (I2C_EE_GPIO->IDR & I2C_EE_SCL)
#define SDA_read (I2C_EE_GPIO->IDR & I2C_EE_SDA)
#define WP_H do{I2C_EE_WP_GPIO->BSRRL = I2C_EE_WP;}while(0)
#define WP_L do{I2C_EE_WP_GPIO->BSRRH = I2C_EE_WP;}while(0)
/* Exported functions ------------------------------------------------------- */
void I2C_EE_Init(void);