mikroSDK Reference Manual
hal_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 _HAL_I2C_MASTER_H_
45#define _HAL_I2C_MASTER_H_
46
47#ifdef __cplusplus
48extern "C"{
49#endif
50
51#include "hal_target.h"
52
66
78
91
101
135
154
201
231err_t hal_i2c_master_open( handle_t *handle, bool hal_obj_open_state );
232
256
281void hal_i2c_master_set_timeout( handle_t *handle, hal_i2c_master_config_t *config );
282
307
335err_t hal_i2c_master_write( handle_t handle, uint8_t *write_data_buf, size_t len_write_data );
336
364err_t hal_i2c_master_read( handle_t handle, uint8_t *read_data_buf, size_t len_read_data );
365
397err_t hal_i2c_master_write_then_read( handle_t handle, uint8_t *write_data_buf, size_t len_write_data, uint8_t *read_data_buf, size_t len_read_data );
398
415err_t hal_i2c_master_close( handle_t *handle );
416
417 // hali2cgroup
418 // halgroup
419 // pergroup
420
421#ifdef __cplusplus
422}
423#endif
424
425#endif // _HAL_I2C_MASTER_H_
426// ------------------------------------------------------------------------- END
void hal_i2c_master_configure_default(hal_i2c_master_config_t *config)
Configure I2C Master HAL configuration structure.
void hal_i2c_master_set_timeout(handle_t *handle, hal_i2c_master_config_t *config)
Set I2C master timeout value.
err_t hal_i2c_master_read(handle_t handle, uint8_t *read_data_buf, size_t len_read_data)
Read data from the I2C bus.
void hal_i2c_master_set_slave_address(handle_t *handle, hal_i2c_master_config_t *config)
Set I2C slave address.
err_t hal_i2c_master_write_then_read(handle_t handle, uint8_t *write_data_buf, size_t len_write_data, uint8_t *read_data_buf, size_t len_read_data)
Write data followed by read.
err_t hal_i2c_master_set_speed(handle_t *handle, hal_i2c_master_config_t *config)
Set I2C master module speed.
err_t hal_i2c_master_open(handle_t *handle, bool hal_obj_open_state)
Open the I2C Master HAL object.
err_t hal_i2c_master_write(handle_t handle, uint8_t *write_data_buf, size_t len_write_data)
Write data to the I2C bus.
err_t hal_i2c_master_close(handle_t *handle)
Closes I2C Master HAL object.
hal_i2c_master_timeout_t
Definition hal_i2c_master.h:83
@ HAL_I2C_MASTER_TIMEOUT_INIT
Definition hal_i2c_master.h:89
@ HAL_I2C_MASTER_ARBITRATION_LOST
Definition hal_i2c_master.h:88
@ HAL_I2C_MASTER_TIMEOUT_WRITE
Definition hal_i2c_master.h:86
@ HAL_I2C_MASTER_TIMEOUT_READ
Definition hal_i2c_master.h:87
@ HAL_I2C_MASTER_TIMEOUT_START
Definition hal_i2c_master.h:84
@ HAL_I2C_MASTER_TIMEOUT_STOP
Definition hal_i2c_master.h:85
hal_i2c_master_err_t
Definition hal_i2c_master.h:71
@ HAL_I2C_MASTER_ERROR
Definition hal_i2c_master.h:76
@ HAL_I2C_MASTER_MODULE_ERROR
Definition hal_i2c_master.h:74
@ HAL_I2C_MASTER_SUCCESS
Definition hal_i2c_master.h:72
@ HAL_I2C_MASTER_WRONG_PINS
Definition hal_i2c_master.h:73
hal_i2c_master_speed_t
Definition hal_i2c_master.h:96
@ HAL_I2C_MASTER_SPEED_STANDARD
Definition hal_i2c_master.h:97
@ HAL_I2C_MASTER_SPEED_FAST
Definition hal_i2c_master.h:99
@ HAL_I2C_MASTER_SPEED_FULL
Definition hal_i2c_master.h:98
HAL target macros and typedefs.
int32_t err_t
Definition hal_target.h:64
hal_ll_pin_name_t hal_pin_name_t
Definition hal_target.h:60
I2C Master HAL init configuration structure, consisted of the following fields :
Definition hal_i2c_master.h:126
uint32_t speed
Definition hal_i2c_master.h:132
uint8_t addr
Definition hal_i2c_master.h:127
hal_pin_name_t sda
Definition hal_i2c_master.h:129
hal_pin_name_t scl
Definition hal_i2c_master.h:130
uint16_t timeout_pass_count
Definition hal_i2c_master.h:133
Definition hal_i2c_master.h:61
handle_t * hal_i2c_master_handle
Definition hal_i2c_master.h:62
handle_t * drv_i2c_master_handle
Definition hal_i2c_master.h:63
bool init_state
Definition hal_i2c_master.h:64
I2C Master HAL context structure, consisted of the following fields :
Definition hal_i2c_master.h:150
hal_i2c_master_config_t config
Definition hal_i2c_master.h:152
handle_t handle
Definition hal_i2c_master.h:151