KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pca9548.h
Go to the documentation of this file.
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2013 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : pca9548.h
11  * Created : 21 mrt. 2013
12  * Author : Vincent van Beveren
13  */
14 
15 
16 #ifndef PCA9548_H_
17 #define PCA9548_H_
18 
19 #include <assert.h>
20 
21 #include "drv/wb/i2c.h"
22 
23 /**
24  * @file
25  *
26  * @ingroup drivers
27  *
28  * PCA9548 I2C mux driver.
29  */
30 
31 
32 /**
33  * Select a specific channel on the PCA9548.
34  *
35  * @param addr The I2C address of the PCA9548
36  * @param ch The channel 0-7, or -1 to disable.
37  *
38  * @return true if succesful, false if an error
39  */
40 static inline bool pca9548_select(I2C_Device * dev, int addr, int ch)
41 {
42  assert((ch >= -1) && (ch < 8));
43 
44  uint8_t b = ch == -1 ? 0 : 1 << ch;
45  return i2cWrite(dev, addr, &b, 1);
46 }
47 
48 #endif /* PCA9548_H_ */
bool i2cWrite(I2C_Device *dev, i2cAddr addr, uint8_t *bytes, int len)
Writes to the I2C device.
Definition: i2c.c:219
Structure defines OpenCores I2C Device.
Definition: dev_i2c.h:55
static bool pca9548_select(I2C_Device *dev, int addr, int ch)
Select a specific channel on the PCA9548.
Definition: pca9548.h:40
OpenCores I2C device driver.