работа с регистрами перенесена в hal, новые функции типа inline
This commit is contained in:
1 parent
46f68aef2f
commit
670c48acab
5 files changed
+105
-66
No files matched your search
@@ -380,9 +380,6 @@ typedef struct
|
||||
|
||||
|
||||
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c);
|
||||
void HAL_I2C_Disable(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_Reset(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_Enable(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_AnalogFilterInit(I2C_HandleTypeDef *hi2c, HAL_I2C_AnalogFilterTypeDef AnalogFilter);
|
||||
void HAL_I2C_DigitalFilterInit(I2C_HandleTypeDef *hi2c, HAL_I2C_DigitalFilterTypeDef DigitalFilter);
|
||||
void HAL_I2C_SetClockSpeed(I2C_HandleTypeDef *hi2c);
|
||||
@@ -394,6 +391,7 @@ void HAL_I2C_SBCMode(I2C_HandleTypeDef *hi2c, HAL_I2C_SBCModeTypeDef SBCMode);
|
||||
void HAL_I2C_SlaveInit(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_MasterInit(I2C_HandleTypeDef *hi2c);
|
||||
HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c);
|
||||
HAL_StatusTypeDef HAL_I2C_Deinit(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_AutoEnd(I2C_HandleTypeDef *hi2c, HAL_I2C_AutoEndModeTypeDef AutoEnd);
|
||||
HAL_StatusTypeDef HAL_I2C_Master_WaitTXIS(I2C_HandleTypeDef *hi2c, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_I2C_Master_WaitRXNE(I2C_HandleTypeDef *hi2c, uint32_t Timeout);
|
||||
@@ -427,6 +425,60 @@ HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pDa
|
||||
HAL_StatusTypeDef HAL_I2C_Slave_Receive_NOSTRETCH_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t DataSize);
|
||||
HAL_StatusTypeDef HAL_I2C_Slave_ReceiveSBC_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t DataSize);
|
||||
|
||||
|
||||
static inline __attribute__((always_inline)) void HAL_I2C_Disable(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
hi2c->Instance->CR1 &= ~I2C_CR1_PE_M;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void HAL_I2C_Reset(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
hi2c->ErrorCode = I2C_ERROR_NONE;
|
||||
|
||||
hi2c->Instance->CR1 &= ~I2C_CR1_PE_M;
|
||||
hi2c->Instance->CR1 |= I2C_CR1_PE_M;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void HAL_I2C_Enable(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
hi2c->Instance->CR1 |= I2C_CR1_PE_M;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void HAL_I2C_Reset_Interrupt_Flag(I2C_HandleTypeDef *hi2c, uint32_t mask)
|
||||
{
|
||||
hi2c->Instance->ICR |= mask;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void HAL_I2C_Reset_TXDR_Content(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
hi2c->Instance->ISR |= I2C_ISR_TXE_M;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) uint32_t HAL_I2C_Get_Interrupts_Status(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
return hi2c->Instance->ISR;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) uint32_t HAL_I2C_Get_CR1_Content(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
return hi2c->Instance->CR1;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void HAL_I2C_Write_TXDR(I2C_HandleTypeDef *hi2c, uint8_t value)
|
||||
{
|
||||
hi2c->Instance->TXDR = value;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) uint8_t HAL_I2C_Get_RXDR(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
return hi2c->Instance->RXDR;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void HAL_I2C_Clear_Reload(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
hi2c->Instance->CR2 &= ~I2C_CR2_RELOAD_M;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void HAL_I2C_ADDR_IRQ(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
if (hi2c->Instance->CR1 & I2C_CR1_SBC_M)
|
||||
|
||||
@@ -26,24 +26,6 @@ __attribute__((weak)) void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
|
||||
|
||||
}
|
||||
|
||||
void HAL_I2C_Disable(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
hi2c->Instance->CR1 &= ~I2C_CR1_PE_M;
|
||||
}
|
||||
|
||||
void HAL_I2C_Reset(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
hi2c->ErrorCode = I2C_ERROR_NONE;
|
||||
|
||||
hi2c->Instance->CR1 &= ~I2C_CR1_PE_M;
|
||||
hi2c->Instance->CR1 |= I2C_CR1_PE_M;
|
||||
}
|
||||
|
||||
void HAL_I2C_Enable(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
hi2c->Instance->CR1 |= I2C_CR1_PE_M;
|
||||
}
|
||||
|
||||
void HAL_I2C_AnalogFilterInit(I2C_HandleTypeDef *hi2c, HAL_I2C_AnalogFilterTypeDef AnalogFilter)
|
||||
{
|
||||
hi2c->Init.AnalogFilter = AnalogFilter;
|
||||
@@ -244,6 +226,24 @@ HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c)
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef HAL_I2C_Deinit(I2C_HandleTypeDef *hi2c)
|
||||
{
|
||||
HAL_I2C_Disable(hi2c);
|
||||
|
||||
if (hi2c->Instance == I2C_0)
|
||||
{
|
||||
__HAL_PCC_I2C_0_CLK_DISABLE();
|
||||
HAL_GPIO_PinConfig(GPIO_0, GPIO_PIN_9 | GPIO_PIN_10, HAL_GPIO_MODE_GPIO_INPUT, HAL_GPIO_PULL_NONE, HAL_GPIO_DS_2MA);
|
||||
}
|
||||
else if(hi2c->Instance == I2C_1)
|
||||
{
|
||||
__HAL_PCC_I2C_1_CLK_DISABLE();
|
||||
HAL_GPIO_PinConfig(GPIO_1, GPIO_PIN_12 | GPIO_PIN_13, HAL_GPIO_MODE_GPIO_INPUT, HAL_GPIO_PULL_NONE, HAL_GPIO_DS_2MA);
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
void HAL_I2C_AutoEnd(I2C_HandleTypeDef *hi2c, HAL_I2C_AutoEndModeTypeDef AutoEnd)
|
||||
{
|
||||
hi2c->Instance->CR2 &= ~I2C_CR2_AUTOEND_M;
|
||||
|
||||
Reference in new issue
Block a user