![]() |
|
|||
File indexing completed on 2025-05-11 08:23:04
0001 /** 0002 * @file 0003 * 0004 * @ingroup raspberrypi_i2c 0005 * 0006 * @brief Raspberry Pi specific I2C definitions. 0007 */ 0008 0009 /* 0010 * Copyright (c) 2014-2015 Andre Marques <andre.lousa.marques at gmail.com> 0011 * 0012 * The license and distribution terms for this file may be 0013 * found in the file LICENSE in this distribution or at 0014 * http://www.rtems.org/license/LICENSE. 0015 */ 0016 0017 #ifndef LIBBSP_ARM_RASPBERRYPI_I2C_H 0018 #define LIBBSP_ARM_RASPBERRYPI_I2C_H 0019 0020 #include <dev/i2c/i2c.h> 0021 0022 #ifdef __cplusplus 0023 extern "C" { 0024 #endif /* __cplusplus */ 0025 0026 /** 0027 * @name I2C constants. 0028 * 0029 * @{ 0030 */ 0031 0032 /** 0033 * @brief BSC controller core clock rate in Hz. 0034 * 0035 * This is set to 150 MHz as per the BCM2835 datasheet. 0036 */ 0037 #define BSC_CORE_CLK_HZ 150000000 0038 0039 /** 0040 * @brief Default bus clock. 0041 * 0042 * This sets the bus with a 100 kHz clock speed. 0043 */ 0044 #define DEFAULT_BUS_CLOCK 100000 0045 0046 /** @} */ 0047 0048 /** 0049 * @name I2C directives. 0050 * 0051 * @{ 0052 */ 0053 0054 /** 0055 * @brief Setups the Raspberry Pi GPIO header to activate the BSC I2C bus. 0056 */ 0057 extern void rpi_i2c_init(void); 0058 0059 /** 0060 * @brief Registers the Raspberry Pi BSC I2C bus with the 0061 * Linux I2C User-Space API. 0062 * 0063 * @param[in] bus_path Path to the bus device file. 0064 * @param[in] bus_clock Bus clock in Hz. 0065 * 0066 * @retval 0 Bus registered successfully. 0067 * @retval <0 Could not register the bus. The return value is a negative 0068 * errno code. 0069 */ 0070 extern int rpi_i2c_register_bus( 0071 const char *bus_path, 0072 uint32_t bus_clock 0073 ); 0074 0075 /** 0076 * @brief Setups the Raspberry Pi BSC I2C bus (located on the GPIO header) 0077 * on the "/dev/i2c" device file, using the default bus clock. 0078 * 0079 * @retval 0 Bus configured and registered successfully. 0080 * @retval <0 See @see rpi_i2c_register_bus(). 0081 */ 0082 static inline int rpi_setup_i2c_bus(void) 0083 { 0084 rpi_i2c_init(); 0085 0086 return rpi_i2c_register_bus("/dev/i2c", DEFAULT_BUS_CLOCK); 0087 } 0088 0089 /** @} */ 0090 0091 #ifdef __cplusplus 0092 } 0093 #endif /* __cplusplus */ 0094 0095 #endif /* LIBBSP_ARM_RASPBERRYPI_I2C_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |