Changeset 55a685b in rtems for cpukit/libi2c/libi2c.h


Ignore:
Timestamp:
Oct 25, 2007, 4:17:56 PM (12 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, 4.9, master
Children:
abe0cdb1
Parents:
0a23c714
Message:

added SPI support to libi2c
added IRQ support to MPC83xx i2c driver
added mpc83xx spi driver

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libi2c/libi2c.h

    r0a23c714 r55a685b  
    4747 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
    4848 */
     49
    4950#include <rtems.h>
    5051
     
    102103  int (*write_bytes) (rtems_libi2c_bus_t * bushdl, unsigned char *bytes,
    103104                      int nbytes);
     105  /* ioctl misc functions */
     106  int (*ioctl) (rtems_libi2c_bus_t * bushdl,
     107                int   cmd,
     108                void *buffer;
     109                );
    104110} rtems_libi2c_bus_ops_t;
    105111
     
    266272/* Send start, send address and read bytes */
    267273int
    268 rtems_libi2c_start_read_bytes (uint32_t minor, unsigned char *bytes,
     274rtems_libi2c_start_read_bytes (rtems_device_minor_number minor,
     275                               unsigned char *bytes,
    269276                               int nbytes);
    270277
    271278/* Send start, send address and write bytes */
    272279int
    273 rtems_libi2c_start_write_bytes (uint32_t minor, unsigned char *bytes,
     280rtems_libi2c_start_write_bytes (rtems_device_minor_number minor,
     281                                unsigned char *bytes,
    274282                                int nbytes);
     283
     284
     285/* call misc iocontrol function */
     286int
     287rtems_libi2c_ioctl (rtems_device_minor_number minor,
     288                    int cmd,
     289                    ...);
     290/*
     291 * NOTE: any low-level driver ioctl returning a negative
     292 * result for release the bus (perform a STOP condition)
     293 */
     294/*******************************
     295 * defined IOCTLs:
     296 *******************************/
     297#define RTEMS_LIBI2C_IOCTL_READ_WRITE  1
     298/*
     299 * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor,
     300 *                             RTEMS_LIBI2C_IOCTL_READ_WRITE,
     301 *                              rtems_libi2c_read_write_t *arg);
     302 *
     303 * This call performs a simultanous read/write transfer,
     304 * which is possible (and sometimes needed) for SPI devices
     305 *
     306 *   arg is a pointer to a rd_wr info data structure
     307 *
     308 * This call is only needed for SPI devices
     309 */
     310#define RTEMS_LIBI2C_IOCTL_START_TFM_READ_WRITE  2
     311/*
     312 * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor,
     313 *                             RTEMS_LIBI2C_IOCTL_START_READ_WRITE,
     314 *                             unsigned char *rd_buffer,
     315 *                             const unsigned char *wr_buffer,
     316 *                             int byte_cnt,
     317 *                             const rtems_libi2c_tfr_mode_t *tfr_mode_ptr);
     318 *
     319 * This call addresses a slave and then:
     320 * - sets the proper transfer mode,
     321 *  - performs a simultanous  read/write transfer,
     322 *    (which is possible and sometimes needed for SPI devices)
     323 *    NOTE: - if rd_buffer is NULL, receive data will be dropped
     324 *          - if wr_buffer is NULL, bytes with content 0 will transmitted
     325 *
     326 *   rd_buffer is a pointer to a receive buffer (or NULL)
     327 *   wr_buffer is a pointer to the data to be sent (or NULL)
     328 *
     329 * This call is only needed for SPI devices
     330 */
     331
     332#define RTEMS_LIBI2C_IOCTL_SET_TFRMODE 3
     333/*
     334 * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor,
     335 *                             RTEMS_LIBI2C_IOCTL_SET_TFRMODE,
     336 *                             const rtems_libi2c_tfr_mode_t *tfr_mode_ptr);
     337 *
     338 * This call sets an SPI device to the transfer mode needed (baudrate etc.)
     339 *
     340 *   tfr_mode is a pointer to a structure defining the SPI transfer mode needed
     341 *   (see below).
     342 *
     343 * This call is only needed for SPI devices
     344 */
     345
     346/*
     347 * arguemtn data structures for IOCTLs defined above
     348 */
     349typedef struct {
     350  unsigned char       *rd_buf;
     351  const unsigned char *wr_buf;
     352  int                  byte_cnt;
     353} rtems_libi2c_read_write_t;
     354
     355typedef struct {
     356  uint32_t baudrate;       /* maximum bits per second               */
     357                           /* only valid for SPI drivers:           */
     358  uint8_t  bits_per_char;  /* how many bits per byte/word/longword? */
     359  boolean  lsb_first;      /* TRUE: send LSB first                  */
     360  boolean  clock_inv;      /* TRUE: inverted clock (high active)    */
     361  boolean  clock_phs;      /* TRUE: clock starts toggling at start of data tfr */
     362} rtems_libi2c_tfr_mode_t;
     363
     364typedef struct {
     365  rtems_libi2c_tfr_mode_t   tfr_mode;
     366  rtems_libi2c_read_write_t rd_wr;
     367} rtems_libi2c_tfm_read_write_t;
     368
    275369
    276370#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.