31 #define CORE_CLK_HZ 250000000 37 ERROR(ERROR_DEFAULT) \ 38 ERROR(ERROR_INVALID_PIN_NUMBER) \ 41 ERROR(ERROR_EXTERNAL) \ 42 ERROR(ERROR_NOT_INITIALISED) \ 43 ERROR(ERROR_ALREADY_INITIALISED) \ 44 ERROR(ERROR_I2C_NACK) \ 46 ERROR(ERROR_I2C_CLK_TIMEOUT) \ 47 ERROR(ERROR_INVALID_BSC) \ 56 #define I2C_CLOCK_FREQ_MIN 10000 59 #define I2C_CLOCK_FREQ_MAX 400000 115 int dbgPrint(FILE * stream,
const char * file,
int line,
const char * format, ...);
118 #define DBG_INFO stderr,__FILE__,__LINE__ 124 #define REV1_PINCNT 17 126 #define REV2_PINCNT 17 129 #define REV1_PINS {0, 1, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 21, 22, 23, 24, 25} 131 #define REV2_PINS {2, 3, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 22, 23, 24, 25, 27}
errStatus gpioGetI2cPins(int *gpioNumberScl, int *gpioNumberSda)
Get the correct I2C pins.
errStatus gpioSetup(void)
Maps the memory used for GPIO access. This function must be called prior to any of the other GPIO cal...
errStatus
The enum of possible errors returned from gpio functions. Errors themselves are defined in the macro ...
errStatus gpioI2cSetup(void)
Initial setup of I2C functionality.
errStatus gpioSetPullResistor(int gpioNumber, eResistor resistor)
Allows configuration of the internal resistor at a GPIO pin.
errStatus gpioI2cReadData(uint8_t *buffer, uint16_t bytesToRead)
Read a number of bytes from I2C. The slave address should have been previously set with gpioI2cSet7Bi...
errStatus gpioReadPin(int gpioNumber, eState *state)
Reads the current state of a gpio pin.
eResistor
The enum for possible pull resistors.
errStatus gpioI2cWriteData(const uint8_t *data, uint16_t dataLength)
Writes data to the address previously specified by gpioI2cSet7BitSlave().
errStatus gpioSetFunction(int gpioNumber, eFunction function)
Sets the functionality of the desired pin.
eState
The enum of possible pin states in input/output modes.
errStatus gpioI2cSet7BitSlave(uint8_t slaveAddress)
Sets the 7-bit slave address to communicate with.
tPcbRev
valid PCB revision values
errStatus gpioCleanup(void)
Unmaps the memory used for the gpio pins. This function should be called when finished with the GPIO ...
#define ERRORS
The list of errors which may be returned from gpio functions.
eFunction
The enum of pin functions available.
Header file for BCM2835 GPIO registers.
errStatus gpioSetPin(int gpioNumber, eState state)
Sets a pin to high or low.
errStatus gpioI2cCleanup(void)
Disables the I2C controller and unmaps the memory used for the i2c functionality. This function shoul...
const char * gpioErrToString(errStatus error)
Debug function which converts an error from errStatus to a string.
int dbgPrint(FILE *stream, const char *file, int line, const char *format,...)
Debug function wrapper for fprintf().
errStatus gpioI2cSetClock(int frequency)
Sets the I2C Clock Frequency.