Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Loading...
Searching...
No Matches
hal_i2c_master.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2022 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 <stdbool.h>
52#include <stdint.h>
53#include "hal_target.h"
54
69
81
94
104
139
158
205err_t hal_i2c_master_open(handle_t *handle, bool hal_obj_open_state);
206
231
259err_t hal_i2c_master_write(handle_t handle, uint8_t *write_data_buf, size_t len_write_data);
260
288err_t hal_i2c_master_read(handle_t handle, uint8_t *read_data_buf, size_t len_read_data);
289
322 uint8_t *write_data_buf,
323 size_t len_write_data,
324 uint8_t *read_data_buf,
325 size_t len_read_data);
326
344
345/*---------------------Unused Functions--------------------------------*/
346
377
401
427
// hali2cgroup // halgroup // pergroup
431#ifdef __cplusplus
432}
433#endif
434
435#endif // _HAL_I2C_MASTER_H_
436// ------------------------------------------------------------------------- END
void hal_i2c_master_configure_default(hal_i2c_master_config_t *config)
Configure I2C Master HAL configuration structure.
Definition hal_i2c_master.c:341
void hal_i2c_master_set_timeout(handle_t *handle, hal_i2c_master_config_t *config)
Set I2C master timeout value.
Definition hal_i2c_master.c:377
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.
Definition hal_i2c_master.c:143
void hal_i2c_master_set_slave_address(handle_t *handle, hal_i2c_master_config_t *config)
Set I2C slave address.
Definition hal_i2c_master.c:138
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.
Definition hal_i2c_master.c:248
err_t hal_i2c_master_set_speed(handle_t *handle, hal_i2c_master_config_t *config)
Set I2C master module speed.
Definition hal_i2c_master.c:352
err_t hal_i2c_master_open(handle_t *handle, bool hal_obj_open_state)
Open the I2C Master HAL object.
Definition hal_i2c_master.c:88
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.
Definition hal_i2c_master.c:189
err_t hal_i2c_master_close(handle_t *handle)
Closes I2C Master HAL object.
Definition hal_i2c_master.c:313
hal_i2c_master_timeout_t
Definition hal_i2c_master.h:86
@ HAL_I2C_MASTER_TIMEOUT_INIT
I2C HW initialization failed.
Definition hal_i2c_master.h:92
@ HAL_I2C_MASTER_ARBITRATION_LOST
I2C Master arbitration lost.
Definition hal_i2c_master.h:91
@ HAL_I2C_MASTER_TIMEOUT_WRITE
I2C bus write failed.
Definition hal_i2c_master.h:89
@ HAL_I2C_MASTER_TIMEOUT_READ
I2C bus read failed.
Definition hal_i2c_master.h:90
@ HAL_I2C_MASTER_TIMEOUT_START
Start signal generation failed.
Definition hal_i2c_master.h:87
@ HAL_I2C_MASTER_TIMEOUT_STOP
Stop signal generation failed.
Definition hal_i2c_master.h:88
hal_i2c_master_err_t
Definition hal_i2c_master.h:74
@ HAL_I2C_MASTER_ERROR
Error.
Definition hal_i2c_master.h:79
@ HAL_I2C_MASTER_MODULE_ERROR
Object wasn't closed.
Definition hal_i2c_master.h:77
@ HAL_I2C_MASTER_SUCCESS
Success.
Definition hal_i2c_master.h:75
@ HAL_I2C_MASTER_WRONG_PINS
Wrong pins selected.
Definition hal_i2c_master.h:76
hal_i2c_master_speed_t
Definition hal_i2c_master.h:99
@ HAL_I2C_MASTER_SPEED_STANDARD
Speed set at 100K.
Definition hal_i2c_master.h:100
@ HAL_I2C_MASTER_SPEED_FAST
Speed set at 1M.
Definition hal_i2c_master.h:102
@ HAL_I2C_MASTER_SPEED_FULL
Speed set at 400K.
Definition hal_i2c_master.h:101
HAL target macros and typedefs.
uintptr_t handle_t
Definition hal_target.h:58
int32_t err_t
General error type.
Definition hal_target.h:77
hal_ll_pin_name_t hal_pin_name_t
Pin type, which is size dependant on the architecture.
Definition hal_target.h:73
I2C Master HAL init configuration structure, consisted of the following fields :
Definition hal_i2c_master.h:129
uint32_t speed
I2C transmission rate.
Definition hal_i2c_master.h:135
uint8_t addr
Slave address.
Definition hal_i2c_master.h:130
hal_pin_name_t sda
SDA pin.
Definition hal_i2c_master.h:132
hal_pin_name_t scl
SCL pin.
Definition hal_i2c_master.h:133
uint16_t timeout_pass_count
I2C timeout value ( number of retries for each operation ).
Definition hal_i2c_master.h:137
Definition hal_i2c_master.h:64
handle_t * hal_i2c_master_handle
I2C Master HAL level handle.
Definition hal_i2c_master.h:65
handle_t * drv_i2c_master_handle
I2C Master DRV level handle.
Definition hal_i2c_master.h:66
bool init_state
I2C Master HAL object init state.
Definition hal_i2c_master.h:67
I2C Master HAL context structure, consisted of the following fields :
Definition hal_i2c_master.h:154
hal_i2c_master_config_t config
I2C Master HAL configuration structure.
Definition hal_i2c_master.h:156
handle_t handle
I2C Master HAL handle.
Definition hal_i2c_master.h:155