libpynq (release 5EWC0-2023 version 0.2.4 of 2023-10-07 15:07)
Loading...
Searching...
No Matches
iic.h
Go to the documentation of this file.
1/*
2Copyright (c) 2023 Eindhoven University of Technology
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
21*/
22#ifndef IIC_H
23#define IIC_H
24#include <stdbool.h>
25#include <stdint.h>
26
42typedef enum { IIC0 = 0, IIC1 = 1, NUM_IICS = 2 } iic_index_t;
43
51extern void iic_init(const iic_index_t iic);
52
58extern void iic_destroy(const iic_index_t iic);
59
71extern bool iic_read_register(const iic_index_t iic, const uint8_t addr,
72 const uint8_t reg, uint8_t *data,
73 uint16_t length);
74
86extern bool iic_write_register(const iic_index_t iic, const uint8_t addr,
87 const uint8_t reg, uint8_t *data,
88 uint16_t length);
89
90extern bool iic_set_slave_mode(const iic_index_t iic, const uint8_t addr,
91 uint32_t *register_map,
92 const uint32_t rm_length);
93
100extern void iic_slave_mode_handler(const iic_index_t iic);
101
107extern void iic_reset(const iic_index_t iic);
111#endif
iic_index_t
Enum of IICs. Functions use a switch numbered from 0..NUM_IICS-1.
Definition iic.h:42
void iic_destroy(const iic_index_t iic)
Close the shared memory handle for the specified IIC index.
Definition iic.c:124
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:135
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:344
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:327
void iic_reset(const iic_index_t iic)
Definition iic.c:314
void iic_slave_mode_handler(const iic_index_t iic)
Definition iic.c:302
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:108
@ IIC1
Definition iic.h:42
@ IIC0
Definition iic.h:42
@ NUM_IICS
Definition iic.h:42