40 printf(
"BCM libray error.\n");
46 bcm2835_i2c_setClockDivider(BCM2835_I2C_CLOCK_DIVIDER_2500);
47 bcm2835_i2c_setSlaveAddress(address);
57 bcm2835_i2c_write(&data, 1);
68 unsigned char wr_buf[2];
73 bcm2835_i2c_write((
const char *)wr_buf, 2);
84 unsigned char wr_buf[3];
90 bcm2835_i2c_write((
const char *)wr_buf, 3);
102 char* wr_buf = (
char*) malloc(
sizeof(
char) * length);
105 printf(
"Error allocating memory!\n");
109 for(
unsigned int i = 1;i<length;i++)
114 bcm2835_i2c_write((
const char *)wr_buf, length);
126 bcm2835_i2c_read_register_rs(®,&val,1);
140 bcm2835_i2c_read_register_rs(®,buffer,length);
151 char receive[2] = {0};
152 bcm2835_i2c_write_read_rs(cmd,1,receive,2);
154 return (receive[0]<<8)|receive[1];
164 bcm2835_i2c_read(val,2);
165 unsigned int data = (val[0] << 8)|val[1];
unsigned char buffer[256]
void I2C_WriteByte(char bdata)
Writes a byte value to the I2C bus. This assumes the register pointer is preset.
void I2C_Close(void)
Closes the I2C peripheral.
void I2C_WriteByteArray(char reg, char *data, unsigned int length)
Writes a buffer array to the registers.
void I2C_WriteByteRegister(unsigned char reg, unsigned char data)
Writes a byte value to a register address.
void I2C_Initialize(unsigned char address)
Initializes the I2C peripheral.
unsigned int I2C_ReadWordPresetPointer(void)
Read the value of a register that has already been select via the address pointer.
void I2C_WriteWordRegister(unsigned char reg, unsigned char *data)
Writes a word value (16 bit) to a register address.
unsigned char I2C_ReadByteRegister(char reg)
Reads a byte from a register.
unsigned int I2C_ReadWordRegisterRS(char reg)
Readm result from a word length register.
void I2C_ReadByteArray(char reg, char *buffer, unsigned int length)
Initializes the I2C peripheral.