Skip to content

Latest I2C fix raised some warnings #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fpistm opened this issue Sep 19, 2018 · 2 comments
Closed

Latest I2C fix raised some warnings #332

fpistm opened this issue Sep 19, 2018 · 2 comments
Assignees
Milestone

Comments

@fpistm
Copy link
Member

fpistm commented Sep 19, 2018

Since #306:

hardware/STM32/stm32/cores/arduino/stm32/twi.c: In function 'HAL_I2C_AddrCallback':
hardware/STM32/stm32/cores/arduino/stm32/twi.c:551:50: warning: passing argument 2 of 'HAL_I2C_Slave_Sequential_Transmit_IT' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
       HAL_I2C_Slave_Sequential_Transmit_IT(hi2c, obj->i2cTxRxBuffer,
                                                  ^~~
In file included from hardware/STM32/stm32/variants/DISCO_F746NG/stm32f7xx_hal_conf.h:330:0,
                 from hardware/STM32/stm32/system/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal.h:46,
                 from hardware/STM32/stm32/system/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f7xx.h:219,
                 from hardware/STM32/stm32/cores/arduino/stm32/stm32_def.h:18,
                 from hardware/STM32/stm32/cores/arduino/stm32/twi.c:51:
hardware/STM32/stm32/system/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_i2c.h:559:19: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'volatile uint8_t * {aka volatile unsigned char *}'
 HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);

                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hardware/STM32/stm32/cores/arduino/stm32/twi.c:558:49: warning: passing argument 2 of 'HAL_I2C_Slave_Sequential_Receive_IT' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
       HAL_I2C_Slave_Sequential_Receive_IT(hi2c, &(obj->i2cTxRxBuffer[obj->slaveRxNbData]),
                                                 ^
In file included from hardware/STM32/stm32/variants/DISCO_F746NG/stm32f7xx_hal_conf.h:330:0,
                 from hardware/STM32/stm32/system/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal.h:46,
                 from hardware/STM32/stm32/system/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f7xx.h:219,
                 from hardware/STM32/stm32/cores/arduino/stm32/stm32_def.h:18,
                 from hardware/STM32/stm32/cores/arduino/stm32/twi.c:51:
hardware/STM32/stm32/system/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_i2c.h:560:19: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'volatile uint8_t * {aka volatile unsigned char *}'
 HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);

                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hardware/STM32/stm32/cores/arduino/stm32/twi.c: In function 'HAL_I2C_ListenCpltCallback':
hardware/STM32/stm32/cores/arduino/stm32/twi.c:579:31: warning: passing argument 1 of 'obj->i2c_onSlaveReceive' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
       obj->i2c_onSlaveReceive(obj->i2cTxRxBuffer, obj->slaveRxNbData);
                               ^~~
hardware/STM32/stm32/cores/arduino/stm32/twi.c:579:31: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'volatile uint8_t * {aka volatile unsigned char *}'
hardware/STM32/stm32/cores/arduino/stm32/twi.c: In function 'HAL_I2C_SlaveRxCpltCallback':
hardware/STM32/stm32/cores/arduino/stm32/twi.c:604:49: warning: passing argument 2 of 'HAL_I2C_Slave_Sequential_Receive_IT' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
       HAL_I2C_Slave_Sequential_Receive_IT(hi2c, &(obj->i2cTxRxBuffer[obj->slaveRxNbData]),
                                                 ^
In file included from hardware/STM32/stm32/variants/DISCO_F746NG/stm32f7xx_hal_conf.h:330:0,
                 from hardware/STM32/stm32/system/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal.h:46,
                 from hardware/STM32/stm32/system/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f7xx.h:219,
                 from hardware/STM32/stm32/cores/arduino/stm32/stm32_def.h:18,
                 from hardware/STM32/stm32/cores/arduino/stm32/twi.c:51:
hardware/STM32/stm32/system/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_i2c.h:560:19: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'volatile uint8_t * {aka volatile unsigned char *}'
 HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);

                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@fpistm fpistm added this to the 1.3.1 milestone Sep 20, 2018
@LMESTM
Copy link
Member

LMESTM commented Oct 11, 2018

@fpistm I think it would be ok to cast it. I added volatile to make sure that the buffer being filled in in the function i2c_slave_write_IT will not be optimized out by the compiler.
// Check the communication status
for(i = 0; i < size; i++) {
obj->i2cTxRxBuffer[i] = *(data+i);
}

@fpistm
Copy link
Member Author

fpistm commented Oct 12, 2018

PR #355 merged

@fpistm fpistm closed this as completed Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants