libpynq  (release 5EID0-2023 version 0.3.0 of 2024-04-25 09:42 )
iic.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2023 Eindhoven University of Technology
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22 #ifndef IIC_H
23 #define IIC_H
24 #include <stdbool.h>
25 #include <stdint.h>
26 
114 typedef enum { IIC0 = 0, IIC1 = 1, NUM_IICS = 2 } iic_index_t;
115 
123 extern void iic_init(const iic_index_t iic);
124 
130 extern void iic_destroy(const iic_index_t iic);
131 
143 extern bool iic_read_register(const iic_index_t iic, const uint8_t addr,
144  const uint8_t reg, uint8_t *data,
145  uint16_t length);
146 
158 extern bool iic_write_register(const iic_index_t iic, const uint8_t addr,
159  const uint8_t reg, uint8_t *data,
160  uint16_t length);
161 
162 extern bool iic_set_slave_mode(const iic_index_t iic, const uint8_t addr,
163  uint32_t *register_map,
164  const uint32_t rm_length);
165 
172 extern void iic_slave_mode_handler(const iic_index_t iic);
173 
179 extern void iic_reset(const iic_index_t iic);
183 #endif
iic_init
void iic_init(const iic_index_t iic)
Initialize the IIC specified by the index with a shared memory handle and a buffer size of 4096 bytes...
Definition: iic.c:2
iic_set_slave_mode
bool iic_set_slave_mode(const iic_index_t iic, const uint8_t addr, uint32_t *register_map, const uint32_t rm_length)
Definition: iic.c:4
IIC1
@ IIC1
Definition: iic.h:114
iic_index_t
iic_index_t
Enum of IICs. Functions use a switch numbered from 0..NUM_IICS-1.
Definition: iic.h:114
iic_destroy
void iic_destroy(const iic_index_t iic)
Close the shared memory handle for the specified IIC index.
Definition: iic.c:3
iic_reset
void iic_reset(const iic_index_t iic)
Definition: iic.c:6
iic_slave_mode_handler
void iic_slave_mode_handler(const iic_index_t iic)
Definition: iic.c:302
IIC0
@ IIC0
Definition: iic.h:114
iic_read_register
bool iic_read_register(const iic_index_t iic, const uint8_t addr, const uint8_t reg, uint8_t *data, uint16_t length)
Definition: iic.c:7
NUM_IICS
@ NUM_IICS
Definition: iic.h:114
iic_write_register
bool iic_write_register(const iic_index_t iic, const uint8_t addr, const uint8_t reg, uint8_t *data, uint16_t length)
Definition: iic.c:10