Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #define BAUD_RATE (int)100e3 // the standard baud rate
  2. ...
  3. void initIR(){
  4. bcm2835_init();
  5. bcm2835_i2c_begin();
  6. bcm2835_i2c_set_baudrate((int)BAUD_RATE);
  7. bcm2835_i2c_setSlaveAddress(0x5a);
  8. }
  9. void writeConfig(){
  10. unsigned char comm = 0x25; // the command to send. access EEPROM
  11. unsigned char * write = (unsigned char *)malloc(sizeof(unsigned char) * 9);
  12. unsigned char * clear = (unsigned char *)malloc(sizeof(unsigned char) * 9);
  13.  
  14. write[0] = 0x25; write[1] = 0x74; write[2] = 0xb4; write[3] = 0x70;
  15. clear[0] = 0x25; clear[1] = 0x00; clear[2] = 0x00; clear[3] = 0x83;
  16.  
  17. /*bcm2835_i2c_begin();*/
  18. int c = bcm2835_i2c_write(clear, 3);
  19. waitMillis(100);
  20. int w = bcm2835_i2c_write(write, 3);
  21. waitMillis(100);
  22.  
  23.  
  24. printf("c: %d, w: %dn", c, w);
  25. free(clear);
  26. free(write);
  27. }
  28.  
  29. | Return value | Message |
  30. |:------------:|:------------------------------:|
  31. | 0 | Message received OK |
  32. | 1 | Received NACK |
  33. | 2 | Received clock stretch timeout |
  34. | 3 | Not all data sent/received |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement