HRI board firmware v2.1 Microcontroller firmware of the board used during the HRI labs.

i2c.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2017 EPFL-LSRO (Laboratoire de Systemes Robotiques).
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef __I2C_H
18 #define __I2C_H
19
20 #include "../main.h"
21
22 #define I2C_SDA_Pin GPIO_Pin_9
23 #define I2C_SDA_PinSource GPIO_PinSource9
24 #define I2C_SDA_Port GPIOB
25 #define I2C_SCL_Pin GPIO_Pin_8
26 #define I2C_SCL_PinSource GPIO_PinSource8
27 #define I2C_SCL_Port GPIOB
28
29 #define I2C_PERIPH I2C1
30 #define I2C_GPIO_AF GPIO_AF_I2C1
31
47 void i2c_Init(void);
48 void i2c_WriteRegister(uint8_t slaveAddress, uint8_t registerAddress,
49 uint8_t registerValue, bool *ok);
50 void i2c_WriteMultiBytesRegister(uint8_t slaveAddress, uint8_t registerAddress,
51 uint8_t const *registerValue,
52 uint8_t registerSize, bool *ok);
53 uint8_t i2c_ReadRegister(uint8_t slaveAddress, uint8_t registerAddress,
54 bool *ok);
55 void i2c_ReadMultiBytesRegister(uint8_t slaveAddress, uint8_t registerAddress,
56 uint8_t *readData, uint8_t registerSize,
57 bool *ok);
58
63 #endif
i2c_ReadMultiBytesRegister
void i2c_ReadMultiBytesRegister(uint8_t slaveAddress, uint8_t registerAddress, uint8_t *readData, uint8_t registerSize, bool *ok)
Reads a multi bytes value from a register.
Definition: i2c.c:201
i2c_Init
void i2c_Init(void)
Initializes the I2C bus.
Definition: i2c.c:47
i2c_WriteMultiBytesRegister
void i2c_WriteMultiBytesRegister(uint8_t slaveAddress, uint8_t registerAddress, uint8_t const *registerValue, uint8_t registerSize, bool *ok)
Writes several bytes to a register.
Definition: i2c.c:132
i2c_ReadRegister
uint8_t i2c_ReadRegister(uint8_t slaveAddress, uint8_t registerAddress, bool *ok)
Reads a 8-bit value from a register.
Definition: i2c.c:179
i2c_WriteRegister
void i2c_WriteRegister(uint8_t slaveAddress, uint8_t registerAddress, uint8_t registerValue, bool *ok)
Writes a 8-bit value to a register.
Definition: i2c.c:115