UoS³ Flight Computer Firmware
 All Data Structures Files Functions Groups Pages
i2c.h
1 
2 // i2c base functions, built over TI library functions - produce drivers for higher level functionality
3 //
4 // Suzanna Lucarotti (c) 31/8/2017
5 //
6 // for use with the UoS3 Cubesat
7 //
8 // hacked together from the various datasheets
9 
10 
11 #ifndef __I2C_H__
12 #define __I2C_H__
13 
14 #include <stdint.h>
15 #include <stdbool.h>
16 
17 void I2C_init(uint8_t i2c_num);
18 
19 // Get a byte from reg
20 uint8_t I2CReceive(uint8_t i2c_num, uint8_t slave_addr, uint8_t reg);
21 
22 // lets get 2 byte value
23 uint16_t I2CReceive16(uint8_t i2c_num, uint8_t slave_addr,uint8_t reg);
24 
25 // lets get 2 byte value reversed (for other endian words)
26 uint16_t I2CReceive16r(uint8_t i2c_num, uint8_t slave_addr,uint8_t reg);
27 
28 //sends an array of data via I2C to the specified slave, zero terminated as a string.
29 void I2CSendString(uint8_t i2c_num, uint8_t slave_addr, uint8_t array[]);
30 
31 // this is the guts of the read function, called by intermediate functions to get around C's lack of function overloading
32 // returns zero pointer if an error...
33 uint8_t *I2CReceiveGP(uint8_t i2c_num, uint8_t slave_addr, uint8_t reg,uint8_t strlen, bool reverse);
34 
35 #endif // __I2C_H__