Menu Toggle
v2.3.1 (RP2350)
Toggle main menu visibility
Loading...
Searching...
No Matches
i2c_slave.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2021 Valentin Milea <valentin.milea@gmail.com>
3
* Copyright (c) 2023 Raspberry Pi (Trading) Ltd.
4
*
5
* SPDX-License-Identifier: BSD-3-Clause
6
*/
7
8
#ifndef _PICO_I2C_SLAVE_H
9
#define _PICO_I2C_SLAVE_H
10
11
#include "
hardware/i2c.h
"
12
13
#ifdef __cplusplus
14
extern
"C"
{
15
#endif
16
28
33
typedef
enum
i2c_slave_event_t
34
{
35
I2C_SLAVE_RECEIVE
,
36
I2C_SLAVE_REQUEST
,
37
I2C_SLAVE_FINISH
,
38
}
i2c_slave_event_t
;
39
52
typedef
void (*
i2c_slave_handler_t
)(i2c_inst_t *i2c,
i2c_slave_event_t
event);
53
62
void
i2c_slave_init
(i2c_inst_t *i2c, uint8_t address,
i2c_slave_handler_t
handler);
63
69
void
i2c_slave_deinit
(i2c_inst_t *i2c);
70
71
#ifdef __cplusplus
72
}
73
#endif
74
75
#endif
// _PICO_I2C_SLAVE_H_
i2c_slave_init
void i2c_slave_init(i2c_inst_t *i2c, uint8_t address, i2c_slave_handler_t handler)
Configure an I2C instance for slave mode.
Definition
i2c_slave.c:56
i2c_slave_event_t
i2c_slave_event_t
I2C slave event types.
Definition
i2c_slave.h:34
i2c_slave_deinit
void i2c_slave_deinit(i2c_inst_t *i2c)
Restore an I2C instance to master mode.
Definition
i2c_slave.c:80
i2c_slave_handler_t
void(* i2c_slave_handler_t)(i2c_inst_t *i2c, i2c_slave_event_t event)
I2C slave event handler.
Definition
i2c_slave.h:52
I2C_SLAVE_REQUEST
@ I2C_SLAVE_REQUEST
Master is requesting data. Slave must write into Tx FIFO.
Definition
i2c_slave.h:36
I2C_SLAVE_RECEIVE
@ I2C_SLAVE_RECEIVE
Data from master is available for reading. Slave must read from Rx FIFO.
Definition
i2c_slave.h:35
I2C_SLAVE_FINISH
@ I2C_SLAVE_FINISH
Master has sent a Stop or Restart signal. Slave may prepare for the next transfer.
Definition
i2c_slave.h:37
i2c.h