Solution for Bluetooth SIG hands-on training course
Dependencies: BLE_API mbed-dev-bin nRF51822-bluetooth-mdw
Fork of microbit-dal-bluetooth-mdw_starter by
MicroBitI2C Class Reference
Class definition for MicroBitI2C. More...
#include <MicroBitI2C.h>
Public Member Functions | |
MicroBitI2C (PinName sda, PinName scl) | |
Constructor. | |
int | read (int address, char *data, int length, bool repeated=false) |
Performs a complete read transaction. | |
int | write (int address, const char *data, int length, bool repeated=false) |
Performs a complete write transaction. |
Detailed Description
Class definition for MicroBitI2C.
Presents a wrapped mbed call to capture failed I2C operations caused by a known silicon bug in the nrf51822. Attempts to automatically reset and restart the I2C hardware if this case is detected.
For reference see PAN56 in:
https://www.nordicsemi.com/eng/nordic/Products/nRF51822/PAN-nRF51822/24634
v2.0 through to v2.4
Definition at line 46 of file MicroBitI2C.h.
Constructor & Destructor Documentation
MicroBitI2C | ( | PinName | sda, |
PinName | scl | ||
) |
Constructor.
Create an instance of MicroBitI2C for I2C communication.
- Parameters:
-
sda the Pin to be used for SDA scl the Pin to be used for SCL
MicroBitI2C i2c(I2C_SDA0, I2C_SCL0);
- Note:
- This class presents a wrapped mbed call to capture failed I2C operations caused by a known silicon bug in the nrf51822. Attempts to automatically reset and restart the I2C hardware if this case is detected.
- For reference see PAN56 in:
- v2.0 through to v2.4
Definition at line 54 of file MicroBitI2C.cpp.
Member Function Documentation
int read | ( | int | address, |
char * | data, | ||
int | length, | ||
bool | repeated = false |
||
) |
Performs a complete read transaction.
The bottom bit of the address is forced to 1 to indicate a read.
- Parameters:
-
address 8-bit I2C slave address [ addr | 1 ] data A pointer to a byte buffer used for storing retrieved data. length Number of bytes to read. repeated if true, stop is not sent at the end. Defaults to false.
- Returns:
- MICROBIT_OK on success, MICROBIT_I2C_ERROR if an unresolved read failure is detected.
Definition at line 72 of file MicroBitI2C.cpp.
int write | ( | int | address, |
const char * | data, | ||
int | length, | ||
bool | repeated = false |
||
) |
Performs a complete write transaction.
The bottom bit of the address is forced to 0 to indicate a write.
- Parameters:
-
address 8-bit I2C slave address [ addr | 0 ] data A pointer to a byte buffer containing the data to write. length Number of bytes to write repeated if true, stop is not sent at the end. Defaults to false.
- Returns:
- MICROBIT_OK on success, MICROBIT_I2C_ERROR if an unresolved write failure is detected.
Definition at line 110 of file MicroBitI2C.cpp.
Generated on Tue Jul 12 2022 20:39:14 by 1.7.2