Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
19269: cpu/gd32v/periph_i2c: interrupt based driver r=gschorcht a=gschorcht ### Contribution description This PR provides an interrupt-driven version of the I2C low-level driver. The existing I2C low-level driver for GDVF103 uses a busy-waiting approach where the status register is continuously polled while waiting for a certain status when sending or receiving. The MCU is thus occupied the whole time during a send or receive operation. The driver provided with this PR uses an interrupt-driven approach. This is, while waiting for a certain status when sending or receiving, the calling thread is suspended and woken up by interrupts. Since the I2C controller allows to receive up to two bytes before the application has to react, receiving a single byte, two bytes or more than two bytes needs a different handling for correct receiption. This requires a tricky implementation which distinguish a number of different case. There the driver requires 860 byte more ROM and 8 byte more RAM. ### Testing procedure The driver should work with any I2C sensor/actuator. It was tested with - `tests/driver_bmp180` <details> ``` main(): This is RIOT! (Version: 2023.04-devel-355-g940c7-cpu/gd32v/periph_i2c_interrupt_driven) BMP180 test application +------------Initializing------------+ Initialization successful +------------Calibration------------+ AC1: 8448 AC2: -1208 AC3: -14907 AC4: 33310 AC5: 24774 AC6: 19213 B1: 6515 B2: 49 MB: -32768 MC: -11786 MD: 2958 +--------Starting Measurements--------+ Temperature [°C]: 22.0 Pressure [hPa]: 1006.49 Pressure at see level [hPa]: 1025.55 Altitude [m]: 157 +-------------------------------------+ Temperature [°C]: 22.0 Pressure [hPa]: 1006.56 Pressure at see level [hPa]: 1025.58 Altitude [m]: 157 +-------------------------------------+ ``` </details> - `tests/driver_ccs811` <details> ``` main(): This is RIOT! (Version: 2023.04-devel-355-g940c7-cpu/gd32v/periph_i2c_interrupt_driven) CCS811 test application +------------Initializing------------+ +--------Starting Measurements--------+ TVOC [ppb]: 0 eCO2 [ppm]: 0 +-------------------------------------+ TVOC [ppb]: 0 eCO2 [ppm]: 0 +-------------------------------------+ TVOC [ppb]: 0 eCO2 [ppm]: 0 +-------------------------------------+ TVOC [ppb]: 0 eCO2 [ppm]: 400 +-------------------------------------+ TVOC [ppb]: 0 eCO2 [ppm]: 400 +-------------------------------------+ TVOC [ppb]: 0 eCO2 [ppm]: 400 +-------------------------------------+ TVOC [ppb]: 7 eCO2 [ppm]: 446 +-------------------------------------+ TVOC [ppb]: 7 eCO2 [ppm]: 446 +-------------------------------------+ TVOC [ppb]: 7 eCO2 [ppm]: 446 +-------------------------------------+ TVOC [ppb]: 7 eCO2 [ppm]: 446 +-------------------------------------+ ``` </details> - `tests/driver_sht3x` <details> ``` main(): This is RIOT! (Version: 2023.04-devel-355-g940c7-cpu/gd32v/periph_i2c_interrupt_driven) SHT3X test application +------------Initializing------------+ Initialization successful +--------Starting Measurements--------+ Temperature [°C]: 21.46 Relative Humidity [%]: 54.50 +-------------------------------------+ Temperature [°C]: 21.47 Relative Humidity [%]: 54.53 +-------------------------------------+ Temperature [°C]: 21.46 Relative Humidity [%]: 54.48 +-------------------------------------+ Temperature [°C]: 21.46 Relative Humidity [%]: 54.47 +-------------------------------------+ ``` </details> - `tests/driver_l3gxxxx` <details> ``` main(): This is RIOT! (Version: 2023.04-devel-375-g75547-cpu/gd32v/periph_i2c_interrupt_driven) L3GXXXX gyroscope driver test application Initializing L3GXXXX sensor [OK] gyro [dps] x: +0, y: -1, z: -2 gyro [dps] x: +0, y: +0, z: +0 gyro [dps] x: +0, y: +0, z: +0 gyro [dps] x: +0, y: +0, z: +0 gyro [dps] x: +0, y: +0, z: +0 gyro [dps] x: +0, y: +0, z: +0 gyro [dps] x: -1, y: +0, z: +4 gyro [dps] x: +0, y: +0, z: -21 gyro [dps] x: +0, y: +0, z: +6 gyro [dps] x: -43, y: +0, z: -13 gyro [dps] x: -21, y: -2, z: +0 gyro [dps] x: +0, y: +1, z: +3 gyro [dps] x: +25, y: +0, z: +0 ``` </details> - `tests/driver_hd44780` with `pcf8574a` I2C interface ### Issues/PRs references Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
- Loading branch information