- Timestamp:
- 06/05/17 12:49:49 (5 years ago)
- Branches:
- 5, master
- Children:
- 8f550d2
- Parents:
- fd10817
- git-author:
- Sichen Zhao <1473996754@…> (06/05/17 12:49:49)
- git-committer:
- Joel Sherrill <joel@…> (06/14/17 16:47:58)
- Location:
- c/src/lib/libbsp/arm/beagle
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/arm/beagle/Makefile.am
rfd10817 r7741545b 115 115 116 116 # I2C 117 libbsp_a_SOURCES += misc/i2c.c118 117 119 118 # GPIO -
c/src/lib/libbsp/arm/beagle/include/i2c.h
rfd10817 r7741545b 181 181 }; 182 182 183 static unsigned short wait_for_pin( void );184 185 static void wait_for_bb( void );186 187 static void flush_fifo( void );188 189 void i2c_init( int speed, int slaveadd );190 191 static int i2c_read_byte(192 unsigned char devaddr,193 unsigned char regoffset,194 unsigned char *value195 );196 197 int i2c_write(198 unsigned char chip,199 unsigned int addr,200 int alen,201 unsigned char *buffer,202 int len203 );204 205 int i2c_read(206 unsigned char chip,207 uint addr,208 int alen,209 unsigned char *buffer,210 int len211 );212 213 static int imw ( unsigned char chip, unsigned long addr, unsigned char byte );214 215 static int imd( unsigned char chip, unsigned int addr, unsigned int length );216 217 /**218 * @brief Initializes the I2C module @a i2c.219 *220 * Valid @a clock_in_hz values are 100000 and 400000.221 *222 * @retval RTEMS_SUCCESSFUL Successful operation.223 * @retval RTEMS_INVALID_ID Invalid @a i2c value.224 * @retval RTEMS_INVALID_CLOCK Invalid @a clock_in_hz value.225 */226 rtems_status_code beagle_i2c_init(227 volatile beagle_i2c *i2c,228 unsigned clock_in_hz229 );230 231 /**232 * @brief Resets the I2C module @a i2c.233 */234 void beagle_i2c_reset(volatile beagle_i2c *i2c);235 236 /**237 * @brief Sets the I2C module @a i2c clock.238 *239 * Valid @a clock_in_hz values are 100000 and 400000.240 *241 * @retval RTEMS_SUCCESSFUL Successful operation.242 * @retval RTEMS_INVALID_CLOCK Invalid @a clock_in_hz value.243 */244 rtems_status_code beagle_i2c_clock(245 volatile beagle_i2c *i2c,246 unsigned clock_in_hz247 );248 249 /**250 * @brief Starts a write transaction on the I2C module @a i2c.251 *252 * The address parameter @a addr must not contain the read/write bit.253 *254 * The error status may be delayed to the next255 * beagle_i2c_write_with_optional_stop() due to controller flaws.256 *257 * @retval RTEMS_SUCCESSFUL Successful operation.258 * @retval RTEMS_IO_ERROR Received a NACK from the slave.259 */260 rtems_status_code beagle_i2c_write_start(261 volatile beagle_i2c *i2c,262 unsigned addr263 );264 265 /**266 * @brief Writes data via the I2C module @a i2c with optional stop.267 *268 * The error status may be delayed to the next269 * beagle_i2c_write_with_optional_stop() due to controller flaws.270 *271 * @retval RTEMS_SUCCESSFUL Successful operation.272 * @retval RTEMS_IO_ERROR Received a NACK from the slave.273 */274 rtems_status_code beagle_i2c_write_with_optional_stop(275 volatile beagle_i2c *i2c,276 const uint8_t *out,277 size_t n,278 bool stop279 );280 281 /**282 * @brief Starts a read transaction on the I2C module @a i2c.283 *284 * The address parameter @a addr must not contain the read/write bit.285 *286 * The error status may be delayed to the next287 * beagle_i2c_read_with_optional_stop() due to controller flaws.288 *289 * @retval RTEMS_SUCCESSFUL Successful operation.290 * @retval RTEMS_IO_ERROR Received a NACK from the slave.291 */292 rtems_status_code beagle_i2c_read_start(293 volatile beagle_i2c *i2c,294 unsigned addr295 );296 297 /**298 * @brief Reads data via the I2C module @a i2c with optional stop.299 *300 * @retval RTEMS_SUCCESSFUL Successful operation.301 * @retval RTEMS_IO_ERROR Received a NACK from the slave.302 * @retval RTEMS_NOT_IMPLEMENTED Stop is @a false.303 */304 rtems_status_code beagle_i2c_read_with_optional_stop(305 volatile beagle_i2c *i2c,306 uint8_t *in,307 size_t n,308 bool stop309 );310 311 /**312 * @brief Writes and reads data via the I2C module @a i2c.313 *314 * This will be one bus transaction.315 *316 * @retval RTEMS_SUCCESSFUL Successful operation.317 * @retval RTEMS_IO_ERROR Received a NACK from the slave.318 */319 rtems_status_code beagle_i2c_write_and_read(320 volatile beagle_i2c *i2c,321 unsigned addr,322 const uint8_t *out,323 size_t out_size,324 uint8_t *in,325 size_t in_size326 );327 328 /**329 * @brief Writes data via the I2C module @a i2c.330 *331 * This will be one bus transaction.332 *333 * @retval RTEMS_SUCCESSFUL Successful operation.334 * @retval RTEMS_IO_ERROR Received a NACK from the slave.335 */336 static inline rtems_status_code beagle_i2c_write(337 volatile beagle_i2c *i2c,338 unsigned addr,339 const uint8_t *out,340 size_t out_size341 )342 {343 return beagle_i2c_write_and_read(i2c, addr, out, out_size, NULL, 0);344 }345 346 /**347 * @brief Reads data via the I2C module @a i2c.348 *349 * This will be one bus transaction.350 *351 * @retval RTEMS_SUCCESSFUL Successful operation.352 * @retval RTEMS_IO_ERROR Received a NACK from the slave.353 */354 static inline rtems_status_code beagle_i2c_read(355 volatile beagle_i2c *i2c,356 unsigned addr,357 uint8_t *in,358 size_t in_size359 )360 {361 return beagle_i2c_write_and_read(i2c, addr, NULL, 0, in, in_size);362 }363 364 183 #ifdef __cplusplus 365 184 }
Note: See TracChangeset
for help on using the changeset viewer.