|
Raspberry Pi GPIO Library
0.3
Library allowing for control of the Raspberry Pi's GPIO pins.
|
Contains C source for the I2C functionality. More...
#include "i2c.h"Go to the source code of this file.
Functions | |
| errStatus | gpioI2cSetup (void) |
| Initial setup of I2C functionality. More... | |
| errStatus | gpioI2cCleanup (void) |
| Disables the I2C controller and unmaps the memory used for the i2c functionality. This function should be called when finished with the I2C module. More... | |
| errStatus | gpioI2cSet7BitSlave (uint8_t slaveAddress) |
| Sets the 7-bit slave address to communicate with. More... | |
| errStatus | gpioI2cWriteData (const uint8_t *data, uint16_t dataLength) |
Writes data to the address previously specified by gpioI2cSet7BitSlave(). More... | |
| errStatus | gpioI2cReadData (uint8_t *buffer, uint16_t bytesToRead) |
| Read a number of bytes from I2C. The slave address should have been previously set with gpioI2cSet7BitSlave(). More... | |
| errStatus | gpioI2cSetClock (int frequency) |
| Sets the I2C Clock Frequency. More... | |
Variables | |
| static volatile uint32_t * | gI2cMap = NULL |
| Pointer which will be mmap'd to the I2C memory in /dev/mem. | |
| static int | i2cByteTxTime_ns |
| The time it takes ideally transmit 1 byte with current I2C clock. | |
Contains C source for the I2C functionality.
This is is part of https://github.com/alanbarr/RaspberryPi-GPIO a C library for basic control of the Raspberry Pi's GPIO pins. Copyright (C) Alan Barr 2012
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file i2c.c.
| errStatus gpioI2cCleanup | ( | void | ) |
Disables the I2C controller and unmaps the memory used for the i2c functionality. This function should be called when finished with the I2C module.
| errStatus gpioI2cReadData | ( | uint8_t * | buffer, |
| uint16_t | bytesToRead | ||
| ) |
Read a number of bytes from I2C. The slave address should have been previously set with gpioI2cSet7BitSlave().
| [out] | buffer | A pointer to a user defined buffer which will store the bytes. |
| bytesToRead | The number of bytes to read. |
| errStatus gpioI2cSet7BitSlave | ( | uint8_t | slaveAddress | ) |
Sets the 7-bit slave address to communicate with.
This value can be set once and left if communicating with the same device.
| slaveAddress | 7-bit slave address. |
| errStatus gpioI2cSetClock | ( | int | frequency | ) |
Sets the I2C Clock Frequency.
frequency <= I2C_CLOCK_FREQ_MAX. | frequency | Desired frequency in Hertz. |
| errStatus gpioI2cSetup | ( | void | ) |
Initial setup of I2C functionality.
gpioSetup() should be called prior to this.
| errStatus gpioI2cWriteData | ( | const uint8_t * | data, |
| uint16_t | dataLength | ||
| ) |
Writes data to the address previously specified by gpioI2cSet7BitSlave().
| [in] | data | Pointer to the start of data to transmit. |
| dataLength | The length of data. |
1.8.13