Eddystone test using modified DAL

Dependencies:   BLE_API mbed-dev-bin nRF51822

Dependents:   microbit-eddystone

Fork of microbit-dal by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

MicroBitI2C Class Reference

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:
sdathe Pin to be used for SDA
sclthe 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:
https://www.nordicsemi.com/eng/nordic/Products/nRF51822/PAN-nRF51822/24634
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:
address8-bit I2C slave address [ addr | 1 ]
dataA pointer to a byte buffer used for storing retrieved data.
lengthNumber of bytes to read.
repeatedif 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:
address8-bit I2C slave address [ addr | 0 ]
dataA pointer to a byte buffer containing the data to write.
lengthNumber of bytes to write
repeatedif 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.