Advertisement
phillip_bourdon234

I2C_Driver.h

Feb 28th, 2021
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. //THIS LIBRARY USES THE I2C BUS LOCATED ON PINS B10 AND B11
  2.  
  3. #ifndef I2C_Driver
  4. #define I2C_Driver
  5.  
  6. #include "stm32f10x.h"
  7. #include <stdint.h>
  8.  
  9.  
  10. //the i2c_init function writes the required bits to set up the I2C mode 2 with
  11. //a 100Khz frequency and enables clock stretching
  12. void i2c_init(void);
  13.  
  14.  
  15. //i2c_write takes in the device address, the memory address of said device,
  16. //and the data that the user wants to write to said memory address.
  17. void i2c_write(uint8_t device_address, uint8_t mem_address, uint8_t data);
  18.  
  19. //i2c_write_2 writes to devices that have a high and low address width, such as EEPROM.
  20. void i2c_write_2(uint8_t device_address, uint8_t mem_address_hi, uint8_t mem_address_lo, uint8_t data);
  21.  
  22. //i2c_read takes in the device address and the memory address of said device and
  23. //returns the data that is stored in said memory address
  24. uint8_t i2c_read(uint8_t device_address, uint8_t mem_address);
  25.  
  26.  
  27. #endif
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement