modify I2C HAL

don't treat incomplete data as an error
allow customizing the I2C address
This commit is contained in:
Samuel Sadok
2018-04-24 18:07:51 -07:00
parent 38998416fc
commit 78ae8fcd27
3 changed files with 5 additions and 5 deletions
@@ -4458,7 +4458,7 @@ static HAL_StatusTypeDef I2C_Slave_STOPF(I2C_HandleTypeDef *hi2c)
}
/* Set ErrorCode corresponding to a Non-Acknowledge */
hi2c->ErrorCode |= HAL_I2C_ERROR_AF;
//hi2c->ErrorCode |= HAL_I2C_ERROR_AF;
}
if(hi2c->ErrorCode != HAL_I2C_ERROR_NONE)
+1 -1
View File
@@ -69,7 +69,7 @@ extern I2C_HandleTypeDef hi2c1;
extern void _Error_Handler(char *, int);
void MX_I2C1_Init(void);
void MX_I2C1_Init(uint8_t addr);
/* USER CODE BEGIN Prototypes */
+3 -3
View File
@@ -62,13 +62,13 @@ DMA_HandleTypeDef hdma_i2c1_rx;
DMA_HandleTypeDef hdma_i2c1_tx;
/* I2C1 init function */
void MX_I2C1_Init(void)
void MX_I2C1_Init(uint8_t addr)
{
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 100000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 24;
hi2c1.Init.OwnAddress1 = addr << 1;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
@@ -114,7 +114,7 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
hdma_i2c1_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_i2c1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_i2c1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_i2c1_rx.Init.Mode = DMA_NORMAL;
hdma_i2c1_rx.Init.Mode = DMA_CIRCULAR;
hdma_i2c1_rx.Init.Priority = DMA_PRIORITY_LOW;
hdma_i2c1_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_i2c1_rx) != HAL_OK)