clapperboard/lib/i2c_master.h

46 lines
1.9 KiB
C
Raw Permalink Normal View History

2017-02-08 17:22:47 +01:00
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
2017-04-01 13:52:33 +02:00
/** library to communicate using I2C as master (API)
* @file i2c_master.h
2017-02-08 17:22:47 +01:00
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2017
2017-04-01 13:52:33 +02:00
* @note peripherals used: I2C @ref i2c_master_i2c, timer @ref i2c_master_timer
2017-02-08 17:22:47 +01:00
*/
#pragma once
/** setup I2C peripheral
* @param[in] fast use standard (100 kHz) or fast (400 kHz) mode
*/
2017-04-01 13:52:33 +02:00
void i2c_master_setup(bool fast);
2017-02-08 17:22:47 +01:00
/** read from I2C slave
* @param[in] slave 7-bit I2C salve device address to read from
* @param[in] address memory address of slave to read from
* @param[in] address_size address size in bytes
* @param[out] data array to store bytes read
2017-02-09 12:34:59 +01:00
* @param[in] data_size number of bytes to read
2017-02-08 17:22:47 +01:00
* @return if read succeeded
*/
2017-04-01 13:52:33 +02:00
bool i2c_master_read(uint8_t slave, const uint8_t* address, size_t address_size, uint8_t* data, size_t data_size);
2017-02-08 17:22:47 +01:00
/** write to I2C slave
* @param[in] slave 7-bit I2C salve device address to write to
* @param[in] address memory address of slave to write to
* @param[in] address_size address size in bytes
* @param[in] data array of byte to write to slave
2017-02-09 12:34:59 +01:00
* @param[in] data_size number of bytes to write
2017-02-08 17:22:47 +01:00
* @return if write succeeded
*/
2017-04-01 13:52:33 +02:00
bool i2c_master_write(uint8_t slave, const uint8_t* address, size_t address_size, const uint8_t* data, size_t data_size);
2017-02-08 17:22:47 +01:00