libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
52/i2c.h
Go to the documentation of this file.
1/** @defgroup i2c_defines I2C Defines
2 *
3 * @brief <b>Defined Constants and Types for the NRF52xx I2C</b>
4 *
5 * @ingroup NRF52xx_defines
6 *
7 * @version 1.0.0
8 *
9 * @date Nov 2021
10 *
11 *LGPL License Terms @ref lgpl_license
12 */
13/*
14 * This file is part of the libopencm3 project.
15 *
16 * Copyright (C) 2017-2018 Unicore MX project<dev(at)lists(dot)unicore-mx(dot)org>
17 * Copyright (C) 2021 Eduard Drusa <ventyl86(at)netkosice(dot)sk>
18 *
19 * This library is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU Lesser General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
22 * (at your option) any later version.
23 *
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU Lesser General Public License for more details.
28 *
29 * You should have received a copy of the GNU Lesser General Public License
30 * along with this library. If not, see <http://www.gnu.org/licenses/>.
31 */
32
33#pragma once
34
39
40/**@{*/
41
42#define I2C_EVENT_RXSTARTED(i2c) MMIO32((i2c) + 0x14C)
43#define I2C_EVENT_TXSTARTED(i2c) MMIO32((i2c) + 0x150)
44#define I2C_EVENT_LASTRX(i2c) MMIO32((i2c) + 0x15C)
45#define I2C_EVENT_LASTTX(i2c) MMIO32((i2c) + 0x160)
46
47#define I2C_RXDPTR(i2c) MMIO32((i2c) + 0x534)
48#define I2C_RXDMAXCNT(i2c) MMIO32((i2c) + 0x538)
49#define I2C_RXDAMOUNT(i2c) MMIO32((i2c) + 0x53C)
50#define I2C_RXDLIST(i2c) MMIO32((i2c) + 0x540)
51#define I2C_TXDPTR(i2c) MMIO32((i2c) + 0x544)
52#define I2C_TXDMAXCNT(i2c) MMIO32((i2c) + 0x548)
53#define I2C_TXDAMOUNT(i2c) MMIO32((i2c) + 0x54C)
54#define I2C_TXDLIST(i2c) MMIO32((i2c) + 0x550)
55
56/** @addtogroup i2c_shorts
57 * @{
58 */
59
60/** On start of last byte transmission, activate start of reception task */
61#define I2C_SHORTS_LASTTX_STARTRX (1 << 7)
62
63/** On start of last byte transmission, activate suspend task */
64#define I2C_SHORTS_LASTTX_SUSPEND (1 << 8)
65
66/** On start of last byte transmission, activate stop task */
67#define I2C_SHORTS_LASTTX_STOP (1 << 9)
68
69/** On start of last byte reception, activate start of transmission task */
70#define I2C_SHORTS_LASTRX_STARTTX (1 << 10)
71
72/** On start of last byte reception, activate stop task */
73#define I2C_SHORTS_LASTRX_STOP (1 << 12)
74/** @} */
75
76/** @addtogroup i2c_inten I2C interrupt enable flags
77 * @{ */
78
79#define I2C_INTEN_SUSPENDED (1 << 18)
80#define I2C_INTEN_RXSTARTED (1 << 19)
81#define I2C_INTEN_TXSTARTED (1 << 20)
82#define I2C_INTEN_LASTRX (1 << 23)
83#define I2C_INTEN_LASTTX (1 << 24)
84
85/** @} */
86
87/** @addtogroup i2c_mode I2C peripheral mode
88 * @{
89 */
90
91/** NRF52 I2C Master mode with EasyDMA support */
92#define I2C_MODE_MASTER (6)
93/**@}*/
94
95
97
98void i2c_set_tx_buffer(uint32_t i2c, const uint8_t * buffer, uint8_t len);
99void i2c_set_rx_buffer(uint32_t i2c, uint8_t * buffer, uint8_t len);
100
102
103/** @} */
104
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
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