TLx493D 3D Hall Sensor Generic Library  1.3
Generic library for the TLx493D 3D Hall sensor family
i2c_int.h
Go to the documentation of this file.
1 /*
2 *****************************************************************************
3 * Copyright (C) 2019 Infineon Technologies AG. All rights reserved.
4 *
5 * Infineon Technologies AG (INFINEON) is supplying this file for use
6 * exclusively with Infineon's products. This file can be freely
7 * distributed within development tools and software supporting such microcontroller
8 * products.
9 *
10 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
11 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
13 * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR DIRECT, INDIRECT, INCIDENTAL,
14 * ASPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
15 *
16 ******************************************************************************
17 */
18 
19 
24 #ifndef SRC_XMC1100_I2C_INT_I2C_INT_H_
25 #define SRC_XMC1100_I2C_INT_I2C_INT_H_
26 
27 
28 #include <stdint.h>
29 #include <stdbool.h>
30 
31 
33 typedef volatile enum {
34  I2C_INT_SUCCESS,
35  I2C_INT_IN_PROGRESS,
36  I2C_INT_ERR_PROTOCOL,
37  I2C_INT_NACK,
39 
40 
42 void I2C_INT_init(void);
43 
44 
46 bool I2C_INT_write(uint8_t addr, const uint8_t* data, uint8_t count, I2C_INT_state_t* handle);
47 
49 bool I2C_INT_read(uint8_t addr, uint8_t *data, uint8_t count, I2C_INT_state_t* handle);
50 
52 static inline I2C_INT_state_t I2C_INT_write_block(uint8_t addr, const uint8_t* data, uint8_t count)
53 {
54  volatile I2C_INT_state_t state;
55 
56  // attempt to start I2C transfer until successful
57  while (!I2C_INT_write(addr, data, count, &state))
58  ;
59  while (I2C_INT_IN_PROGRESS == state)
60  ; //wait
61 
62  return state;
63 }
64 
66 static inline I2C_INT_state_t I2C_INT_read_block(uint8_t addr, uint8_t *data, uint8_t count)
67 {
68  volatile I2C_INT_state_t state;
69 
70  // attempt to start I2C transfer until successful
71  while (!I2C_INT_read(addr, data, count, &state))
72  ;
73  while (I2C_INT_IN_PROGRESS == state)
74  ; //wait
75 
76  return state;
77 }
78 
79 
81 void I2C_INT_write_reset(void);
82 
83 
85 void I2C_INT_write_recover(void);
86 
87 
88 #endif /* SRC_XMC1100_I2C_INT_I2C_INT_H_ */
void I2C_INT_write_recover(void)
Write Recover address (for TLx493D sensors) on I2C bus (blocking)
Definition: i2c_int.c:350
void I2C_INT_write_reset(void)
Write Reset address (for TLx493D sensors) on I2C bus (blocking)
Definition: i2c_int.c:318
I2C_INT_state_t
Status values returned by the I2C read/write commands.
Definition: i2c_int.h:33
bool I2C_INT_read(uint8_t addr, uint8_t *data, uint8_t count, I2C_INT_state_t *handle)
start asynchronous I2C read
Definition: i2c_int.c:277
bool I2C_INT_write(uint8_t addr, const uint8_t *data, uint8_t count, I2C_INT_state_t *handle)
start asynchronous I2C write
Definition: i2c_int.c:271
void I2C_INT_init(void)
Initialize the I2C interrupt-based peripheral.
Definition: i2c_int.c:162