Skip to content

Commit

Permalink
use IRQ mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralim committed Jan 30, 2022
1 parent d6b6549 commit 6b25e60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions source/Core/BSP/Miniware/I2C_Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pDat
bool FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
if (!lock())
return false;
if (HAL_I2C_Master_Transmit_DMA(&hi2c1, DevAddress, pData, Size) != HAL_OK) {
if (HAL_I2C_Master_Transmit_IT(&hi2c1, DevAddress, pData, Size) != HAL_OK) {
I2C_Unstick();
unlock();
return false;
Expand All @@ -77,7 +77,7 @@ void FRToSI2C::I2C_Unstick() { unstick_I2C(); }

void FRToSI2C::unlock() { xSemaphoreGive(I2CSemaphore); }

bool FRToSI2C::lock() { return xSemaphoreTake(I2CSemaphore, (TickType_t)500) == pdTRUE; }
bool FRToSI2C::lock() { return xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE; }

bool FRToSI2C::writeRegistersBulk(const uint8_t address, const I2C_REG *registers, const uint8_t registersLength) {
for (int index = 0; index < registersLength; index++) {
Expand Down
2 changes: 1 addition & 1 deletion source/Core/BSP/Miniware/stm32f1xx_hal_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c) {
GPIO_InitStruct.Pin = SCL_Pin | SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/* Peripheral clock enable */
Expand Down

0 comments on commit 6b25e60

Please sign in to comment.