RTEMS CPU Kit with SuperCore  4.11.3
Data Structures | Macros | Functions | Variables
libi2c.c File Reference
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include <stdarg.h>
#include <rtems.h>
#include <rtems/error.h>
#include <rtems/bspIo.h>
#include <rtems/libio.h>
#include <rtems/score/sysstate.h>
#include <rtems/libi2c.h>
Include dependency graph for libi2c.c:

Data Structures

struct  i2cbus
 

Macros

#define DRVNM   "libi2c: "
 
#define MAX_NO_BUSSES   8 /* Also limited by the macro building minor numbers */
 
#define MAX_NO_DRIVERS   16 /* Number of high level drivers we support */
 
#define MINOR2ADDR(minor)   ((minor)&((1<<10)-1))
 
#define MINOR2BUS(minor)   (((minor)>>10)&7)
 
#define MINOR2DRV(minor)   ((minor)>>13)
 
#define DECL_CHECKED_BH(b, bh, m, s)
 
#define DECL_CHECKED_DRV(d, b, m)
 
#define DISPATCH(rval, entry, dflt)
 
#define LOCK(m)   assert(!rtems_semaphore_obtain((m), RTEMS_WAIT, RTEMS_NO_TIMEOUT))
 
#define UNLOCK(m)   rtems_semaphore_release((m))
 
#define LIBLOCK()   LOCK(libmutex)
 
#define LIBUNLOCK()   UNLOCK(libmutex)
 
#define MUTEX_ATTS
 

Functions

rtems_status_code rtems_i2c_init (rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
 
rtems_status_code rtems_i2c_open (rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
 
rtems_status_code rtems_i2c_close (rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
 
rtems_status_code rtems_i2c_read (rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
 
rtems_status_code rtems_i2c_write (rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
 
rtems_status_code rtems_i2c_ioctl (rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
 
int rtems_libi2c_initialize (void)
 
int rtems_libi2c_register_bus (const char *name, rtems_libi2c_bus_t *bus)
 
rtems_status_code rtems_libi2c_send_start (rtems_device_minor_number minor)
 
rtems_status_code rtems_libi2c_send_stop (rtems_device_minor_number minor)
 
rtems_status_code rtems_libi2c_send_addr (rtems_device_minor_number minor, int rw)
 
int rtems_libi2c_read_bytes (rtems_device_minor_number minor, unsigned char *bytes, int nbytes)
 
int rtems_libi2c_write_bytes (rtems_device_minor_number minor, const unsigned char *bytes, int nbytes)
 
int rtems_libi2c_ioctl (rtems_device_minor_number minor, int cmd,...)
 
int rtems_libi2c_start_read_bytes (rtems_device_minor_number minor, unsigned char *bytes, int nbytes)
 
int rtems_libi2c_start_write_bytes (rtems_device_minor_number minor, const unsigned char *bytes, int nbytes)
 
int rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t *drvtbl, unsigned busno, unsigned i2caddr)
 

Variables

rtems_device_major_number rtems_libi2c_major
 
const rtems_driver_address_table rtems_libi2c_io_ops
 

Macro Definition Documentation

◆ DECL_CHECKED_BH

#define DECL_CHECKED_BH (   b,
  bh,
  m,
 
)
Value:
unsigned b = MINOR2BUS(m); \
rtems_libi2c_bus_t *bh; \
if ( b >= MAX_NO_BUSSES || 0 == (bh=busses[b].bush) ) { \
}
This is the status to indicate that the specified number was invalid.
Definition: status.h:92

◆ DECL_CHECKED_DRV

#define DECL_CHECKED_DRV (   d,
  b,
 
)
Value:
unsigned d = MINOR2DRV(m); \
unsigned b = MINOR2BUS(m); \
if ( b >= MAX_NO_BUSSES || 0 == busses[b].bush \
|| d > MAX_NO_DRIVERS || (d && 0 == drvs[d-1].drv )) {\
}
This is the status to indicate that the specified number was invalid.
Definition: status.h:92

◆ DISPATCH

#define DISPATCH (   rval,
  entry,
  dflt 
)
Value:
do { \
const rtems_driver_address_table *ops = drvs[--drv].drv->ops; \
rval = ops->entry ? ops->entry(major,minor,arg) : dflt; \
} while (0)
Definition: io.h:52

◆ MUTEX_ATTS

#define MUTEX_ATTS
Value:
#define RTEMS_BINARY_SEMAPHORE
This attribute constant indicates that the Classic API Semaphore instance created will be a proper bi...
Definition: attr.h:106
#define RTEMS_PRIORITY
This is the attribute constant which reflects that blocking tasks will be managed using task priority...
Definition: attr.h:70
#define RTEMS_NO_PRIORITY_CEILING
This attribute constant indicates that the Classic API Semaphore instance created will NOT use the Pr...
Definition: attr.h:132
#define RTEMS_INHERIT_PRIORITY
This attribute constant indicates that the Classic API Semaphore instance created will use the Priori...
Definition: attr.h:126
#define RTEMS_LOCAL
This is the attribute constant to indicate local resource.
Definition: attr.h:53