RTEMS | Add the support for i2c driver in the aarch64/raspberrypi bsp (!363)
Kinsey Moore (@opticron)
gitlab at rtems.org
Sat Apr 26 18:54:34 UTC 2025
Kinsey Moore commented on a discussion on bsps/aarch64/raspberrypi/i2c/raspberrypi-i2c.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/363#note_122272
> + ++divider;
> + clock_rate = BSC_CORE_CLK_HZ / divider;
> + }
> +
> + BCM2835_REG(bus->base_address + BCM2711_I2C_DIV) = divider;
> +
> + bus->input_clock = clock_rate;
> +
> + return 0;
> +}
> +
> +static int rpi_i2c_setup_transfer(raspberrypi_i2c_bus *bus)
> +{
> + int rv;
> + while(bus->remaining_transfers > 0){
> + bus->remaining_bytes = bus->remaining_transfers > 1 ? 0xFFFF : (bus->current_buffer_size & 0xFFFF);
This could be broken apart and explained with a comment in the code. It seems like there might also be an off-by-one error here. Magic numbers sprinkled in the code are discouraged, so I've :
```
/* I would expect the correct value here to be 0x10000 instead of 0xFFFF */
/* Full transfer size is 0xFFFF bytes */
#define I2C_TRANSFER_SIZE 0xFFFF
bus->remaining_bytes = I2C_TRANSFER_SIZE;
/* If there is only 1 transfer remaining, consume the remainder of the data */
if (bus->remaining_transfers == 1) {
bus->remaining_bytes = bus->current_buffer_size % I2C_TRANSFER_SIZE;
}
```
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/363#note_122272
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250426/1d949773/attachment-0001.htm>
More information about the bugs
mailing list