libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
i2c.c
Go to the documentation of this file.
1/** @addtogroup i2c_file I2C peripheral API
2 */
3
4/*
5 * This file is part of the libopencm3 project.
6 *
7 * Copyright (C) 2022 Eduard Drusa <ventyl86(at)netkosice(dot)sk>
8 *
9 * This library is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22
24
25/**@{*/
26
27/** Configure I2C transmit buffer properties
28 *
29 * Configures transmit buffer for EasyDMA transaction. This API
30 * is only available if @ref I2C_MODE_MASTER mode is activated.
31 *
32 * Configures linear TX buffer for EasyDMA transmission.
33 * @param[in] i2c i2c peripheral base, see @ref i2c_block
34 * @param[in] buffer address of buffer start
35 * @param[in] len length of data in the buffer
36 */
37void i2c_set_tx_buffer(uint32_t i2c, const uint8_t *buffer, uint8_t len)
38{
39 I2C_TXDPTR(i2c) = (uint32_t) buffer;
40 I2C_TXDMAXCNT(i2c) = len;
41 I2C_TXDLIST(i2c) = 0;
42}
43
44/** Configure I2C receive buffer properties
45 *
46 * Configures receive buffer for EasyDMA transaction. This API
47 * is only available if @ref I2C_MODE_MASTER mode is activated.
48 *
49 * Configures linear RX buffer for EasyDMA transmission.
50 * @param[in] i2c i2c peripheral base, see @ref i2c_block
51 * @param[in] buffer address of buffer start
52 * @param[in] len length of the buffer
53 */
54void i2c_set_rx_buffer(uint32_t i2c, uint8_t *buffer, uint8_t len)
55{
56 I2C_RXDPTR(i2c) = (uint32_t) buffer;
57 I2C_RXDMAXCNT(i2c) = len;
58 I2C_RXDLIST(i2c) = 0;
59}
60
61
62/** @} */
#define I2C_TXDLIST(i2c)
Definition: 52/i2c.h:54
#define I2C_TXDMAXCNT(i2c)
Definition: 52/i2c.h:52
#define I2C_RXDLIST(i2c)
Definition: 52/i2c.h:50
#define I2C_RXDMAXCNT(i2c)
Definition: 52/i2c.h:48
#define I2C_RXDPTR(i2c)
Definition: 52/i2c.h:47
#define I2C_TXDPTR(i2c)
Definition: 52/i2c.h:51
void i2c_set_rx_buffer(uint32_t i2c, uint8_t *buffer, uint8_t len)
Configure I2C receive buffer properties.
Definition: i2c.c:54
void i2c_set_tx_buffer(uint32_t i2c, const uint8_t *buffer, uint8_t len)
Configure I2C transmit buffer properties.
Definition: i2c.c:37