Browse Source

i2c: added transmit without stop

cli_test
Franz Levin 3 months ago
parent
commit
8a86c7420d
2 changed files with 13 additions and 1 deletions
  1. +2
    -0
      cubemx/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_i2c.h
  2. +11
    -1
      cubemx/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c

+ 2
- 0
cubemx/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_i2c.h View File

@@ -43,6 +43,7 @@ extern "C" {
/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx_hal_def.h"
#include <stdbool.h>
/** @addtogroup STM32F0xx_HAL_Driver
* @{
@@ -537,6 +538,7 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c);
*/
/* IO operation functions ****************************************************/
/******* Blocking mode: Polling */
HAL_StatusTypeDef HAL_I2C_Master_Transmit_2(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout, bool send_stop);
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);

+ 11
- 1
cubemx/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c View File

@@ -624,7 +624,7 @@ __weak void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
* @param Timeout Timeout duration
* @retval HAL status
*/
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
HAL_StatusTypeDef HAL_I2C_Master_Transmit_2(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout, bool send_stop)
{
uint32_t tickstart = 0U;
@@ -695,6 +695,11 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevA
hi2c->XferSize = MAX_NBYTE_SIZE;
I2C_TransferConfig(hi2c, DevAddress, hi2c->XferSize, I2C_RELOAD_MODE, I2C_NO_STARTSTOP);
}
else if (!send_stop)
{
hi2c->XferSize = hi2c->XferCount;
I2C_TransferConfig(hi2c, DevAddress, hi2c->XferSize, I2C_RELOAD_MODE, I2C_NO_STARTSTOP);
}
else
{
hi2c->XferSize = hi2c->XferCount;
@@ -737,6 +742,11 @@ HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevA
}
}
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
{
return HAL_I2C_Master_Transmit_2(hi2c, DevAddress, pData, Size, Timeout, true);
}
/**
* @brief Receives in master mode an amount of data in blocking mode.
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains

Loading…
Cancel
Save