paul@0 | 1 | /* |
paul@0 | 2 | * Ben NanoNote I2C communication. |
paul@0 | 3 | * |
paul@0 | 4 | * Copyright (C) 2013 Paul Boddie |
paul@0 | 5 | * |
paul@0 | 6 | * This program is free software; you can redistribute it and/or modify |
paul@0 | 7 | * it under the terms of the GNU General Public License as published by |
paul@0 | 8 | * the Free Software Foundation; either version 2 of the License, or |
paul@0 | 9 | * (at your option) any later version. |
paul@0 | 10 | */ |
paul@0 | 11 | |
paul@0 | 12 | #ifndef __I2C_H__ |
paul@0 | 13 | #define __I2C_H__ |
paul@0 | 14 | |
paul@0 | 15 | #include <ubb/ubb.h> |
paul@0 | 16 | #include "bool.h" |
paul@0 | 17 | |
paul@0 | 18 | /* I2C modifiers. */ |
paul@0 | 19 | |
paul@0 | 20 | #define I2C_READ 1 |
paul@0 | 21 | #define I2C_WRITE 0 |
paul@0 | 22 | |
paul@0 | 23 | /* Functions. */ |
paul@0 | 24 | |
paul@0 | 25 | void i2c_init(); |
paul@0 | 26 | void i2c_start(); |
paul@0 | 27 | void i2c_stop(); |
paul@0 | 28 | void i2c_ack(bool ack); |
paul@0 | 29 | uint8_t i2c_recv(); |
paul@0 | 30 | void i2c_recvmany(uint8_t *data, uint8_t len); |
paul@0 | 31 | void i2c_wait(); |
paul@0 | 32 | bool i2c_send(uint8_t data); |
paul@0 | 33 | bool i2c_sendmany(uint8_t *data, uint8_t len); |
paul@0 | 34 | |
paul@0 | 35 | /* Function aliases. */ |
paul@0 | 36 | |
paul@0 | 37 | #define i2c_repeated_start i2c_start |
paul@0 | 38 | |
paul@0 | 39 | #endif /* __I2C_H__ */ |