mikroSDK Reference Manual
drv_i2c_master.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2024 MikroElektronika d.o.o.
4** Contact: https://www.mikroe.com/contact
5**
6** This file is part of the mikroSDK package
7**
8** Commercial License Usage
9**
10** Licensees holding valid commercial NECTO compilers AI licenses may use this
11** file in accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The MikroElektronika Company.
14** For licensing terms and conditions see
15** https://www.mikroe.com/legal/software-license-agreement.
16** For further information use the contact form at
17** https://www.mikroe.com/contact.
18**
19**
20** GNU Lesser General Public License Usage
21**
22** Alternatively, this file may be used for
23** non-commercial projects under the terms of the GNU Lesser
24** General Public License version 3 as published by the Free Software
25** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26**
27** The above copyright notice and this permission notice shall be
28** included in all copies or substantial portions of the Software.
29**
30** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37**
38****************************************************************************/
44#ifndef _DRV_I2C_MASTER_H_
45#define _DRV_I2C_MASTER_H_
46
47#ifdef __cplusplus
48extern "C"{
49#endif
50
51#include "drv_name.h"
52#include "hal_i2c_master.h"
53
62
72
96typedef struct
97{
98 uint8_t addr;
103 uint32_t speed;
106
120typedef struct
121{
122 handle_t handle;
125
172
207
233
260err_t i2c_master_set_timeout( i2c_master_t *obj, uint16_t timeout_pass_count );
261
288
321err_t i2c_master_write( i2c_master_t *obj, uint8_t *write_data_buf, size_t len_write_data );
322
355err_t i2c_master_read( i2c_master_t *obj, uint8_t *read_data_buf, size_t len_read_data );
356
394err_t i2c_master_write_then_read( i2c_master_t *obj, uint8_t *write_data_buf, size_t len_write_data, uint8_t *read_data_buf, size_t len_read_data );
395
421
422 // drvi2cgroup
423 // drvgroup
424 // pergroup
425
426#ifdef __cplusplus
427}
428#endif
429
430#endif // _DRV_I2C_MASTER_H_
431// ------------------------------------------------------------------------- END
i2c_master_err_t
Definition drv_i2c_master.h:58
@ I2C_MASTER_SUCCESS
Definition drv_i2c_master.h:59
@ I2C_MASTER_ERROR
Definition drv_i2c_master.h:60
i2c_master_speed_t
Definition drv_i2c_master.h:67
@ I2C_MASTER_SPEED_FULL
Definition drv_i2c_master.h:69
@ I2C_MASTER_SPEED_STANDARD
Definition drv_i2c_master.h:68
@ I2C_MASTER_SPEED_FAST
Definition drv_i2c_master.h:70
Pin and port name type definitions.
hal_pin_name_t pin_name_t
Definition drv_name.h:74
err_t i2c_master_read(i2c_master_t *obj, uint8_t *read_data_buf, size_t len_read_data)
Read data from the I2C bus.
err_t i2c_master_set_slave_address(i2c_master_t *obj, uint8_t address)
Set I2C Slave address.
err_t i2c_master_set_speed(i2c_master_t *obj, uint32_t speed)
Set I2C Master module speed.
err_t i2c_master_write_then_read(i2c_master_t *obj, uint8_t *write_data_buf, size_t len_write_data, uint8_t *read_data_buf, size_t len_read_data)
Write data to I2C bus followed by read.
err_t i2c_master_set_timeout(i2c_master_t *obj, uint16_t timeout_pass_count)
Set I2C Master timeout value.
void i2c_master_configure_default(i2c_master_config_t *config)
Configure I2C Master configuration structure.
err_t i2c_master_close(i2c_master_t *obj)
Close I2C Master driver object.
err_t i2c_master_write(i2c_master_t *obj, uint8_t *write_data_buf, size_t len_write_data)
Write data to the I2C bus.
err_t i2c_master_open(i2c_master_t *obj, i2c_master_config_t *config)
Open the I2C Master driver object.
API for I2C master HAL layer.
int32_t err_t
Definition hal_target.h:64
I2C Master initialization configuration structure, consisted of the following fields :
Definition drv_i2c_master.h:97
uint16_t timeout_pass_count
Definition drv_i2c_master.h:104
pin_name_t scl
Definition drv_i2c_master.h:101
pin_name_t sda
Definition drv_i2c_master.h:100
uint8_t addr
Definition drv_i2c_master.h:98
uint32_t speed
Definition drv_i2c_master.h:103
I2C Master driver context structure, consisted of the following fields :
Definition drv_i2c_master.h:121
i2c_master_config_t config
Definition drv_i2c_master.h:123
handle_t handle
Definition drv_i2c_master.h:122