LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_i2c.c File Reference
#include "lms2012.h"
#include "c_com.h"
#include "c_bt.h"
#include "c_i2c.h"
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <sys/mman.h>
#include <time.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <pthread.h>

Go to the source code of this file.

Data Structures

struct  MODE2BUF
 

Macros

#define I2CBUF_SIZE   150
 
#define APPDATABUF_SIZE   150
 
#define MODE2BUF_SIZE   1024
 
#define MIN_MSG_LEN   6
 
#define SLEEPuS   ((ULONG)(1000))
 
#define SEC_1   (((ULONG)(1000000))/SLEEPuS)
 
#define BUFBytesFree   (((Mode2InBuf.OutPtr - Mode2InBuf.InPtr) - 1) & ((UWORD)(MODE2BUF_SIZE - 1)))
 
#define BUFBytesAvail   ((Mode2InBuf.InPtr - Mode2InBuf.OutPtr) & ((UWORD)(MODE2BUF_SIZE - 1)))
 
#define BUFAddInPtr(Val)   (Mode2InBuf.InPtr = ((Mode2InBuf.InPtr + Val) & ((UWORD)(MODE2BUF_SIZE - 1))))
 
#define BUFAddOutPtr(Val)   (Mode2InBuf.OutPtr = ((Mode2InBuf.OutPtr + Val) & ((UWORD)(MODE2BUF_SIZE - 1))))
 
#define DISCONNDueToErr
 

Enumerations

enum  { WRITE_DATA = 0x2A, READ_STATUS = 0x2A, WRITE_RAW = 0x2B, READ_DATA = 0x2B }
 
enum  { CTS_PIC, PIC_RST, PIC_EN, BLUETOOTH_PINS }
 
enum  { SET = 0, CLEAR = 1, HIIMP = 2 }
 
enum  {
  OVERRUN_ERROR = 0x01, CRC_ERROR = 0x02, INCORRECT_ACTION = 0x03, UNEXPECTED_ERROR = 0x04,
  RAW_OVERRUN_ERROR = 0x05
}
 

Functions

UBYTE I2cReadStatus (UBYTE *pBuf)
 
UBYTE I2cReadCts (void)
 
int I2cRead (int fd, unsigned int addr, char *buf, unsigned char len)
 
int I2cWrite (int fd, unsigned int addr, char *buf, unsigned char len)
 
void * I2cCtrl (void *ptr)
 
void I2cSetPIC_RST (void)
 
void I2cClearPIC_RST (void)
 
void I2cSetPIC_EN (void)
 
void I2cClearPIC_EN (void)
 
void I2cHiImpPIC_EN (void)
 
RESULT I2cInit (READBUF *pBuf, WRITEBUF *pWriteBuf, char *pBundleId, char *pBundleSeedId)
 
void I2cExit (void)
 
void I2cStart (void)
 
void I2cStop (void)
 
UWORD DataToMode2Decoding (UBYTE *pBuf, UWORD Length)
 
UBYTE I2cGetBootStatus (void)
 

Variables

char * RtnMsg = "I2c Func thread end"
 

Macro Definition Documentation

#define APPDATABUF_SIZE   150

Definition at line 111 of file c_i2c.c.

#define BUFAddInPtr (   Val)    (Mode2InBuf.InPtr = ((Mode2InBuf.InPtr + Val) & ((UWORD)(MODE2BUF_SIZE - 1))))

Definition at line 159 of file c_i2c.c.

#define BUFAddOutPtr (   Val)    (Mode2InBuf.OutPtr = ((Mode2InBuf.OutPtr + Val) & ((UWORD)(MODE2BUF_SIZE - 1))))

Definition at line 160 of file c_i2c.c.

#define BUFBytesAvail   ((Mode2InBuf.InPtr - Mode2InBuf.OutPtr) & ((UWORD)(MODE2BUF_SIZE - 1)))

Definition at line 158 of file c_i2c.c.

#define BUFBytesFree   (((Mode2InBuf.OutPtr - Mode2InBuf.InPtr) - 1) & ((UWORD)(MODE2BUF_SIZE - 1)))

Definition at line 157 of file c_i2c.c.

#define DISCONNDueToErr
Value:
{\
ThreadRunState = 0;\
}
UBYTE cBtDiscChNo(UBYTE ChNo)
Definition: c_bt.c:2396

Definition at line 162 of file c_i2c.c.

#define I2CBUF_SIZE   150

Definition at line 110 of file c_i2c.c.

#define MIN_MSG_LEN   6

Definition at line 113 of file c_i2c.c.

#define MODE2BUF_SIZE   1024

Definition at line 112 of file c_i2c.c.

#define SEC_1   (((ULONG)(1000000))/SLEEPuS)

Definition at line 115 of file c_i2c.c.

#define SLEEPuS   ((ULONG)(1000))

Definition at line 114 of file c_i2c.c.

Enumeration Type Documentation

anonymous enum
Enumerator
WRITE_DATA 
READ_STATUS 
WRITE_RAW 
READ_DATA 

Definition at line 76 of file c_i2c.c.

anonymous enum
Enumerator
CTS_PIC 
PIC_RST 
PIC_EN 
BLUETOOTH_PINS 

Definition at line 85 of file c_i2c.c.

anonymous enum
Enumerator
SET 
CLEAR 
HIIMP 

Definition at line 93 of file c_i2c.c.

anonymous enum
Enumerator
OVERRUN_ERROR 
CRC_ERROR 
INCORRECT_ACTION 
UNEXPECTED_ERROR 
RAW_OVERRUN_ERROR 

Definition at line 100 of file c_i2c.c.

Function Documentation

UWORD DataToMode2Decoding ( UBYTE pBuf,
UWORD  Length 
)

Definition at line 776 of file c_i2c.c.

void I2cClearPIC_EN ( void  )

Definition at line 680 of file c_i2c.c.

void I2cClearPIC_RST ( void  )

Definition at line 652 of file c_i2c.c.

void * I2cCtrl ( void *  ptr)

Definition at line 219 of file c_i2c.c.

void I2cExit ( void  )

Definition at line 188 of file c_i2c.c.

UBYTE I2cGetBootStatus ( void  )

Definition at line 809 of file c_i2c.c.

void I2cHiImpPIC_EN ( void  )

Definition at line 694 of file c_i2c.c.

RESULT I2cInit ( READBUF pBuf,
WRITEBUF pWriteBuf,
char *  pBundleId,
char *  pBundleSeedId 
)

Definition at line 168 of file c_i2c.c.

int I2cRead ( int  fd,
unsigned int  addr,
char *  buf,
unsigned char  len 
)

Definition at line 716 of file c_i2c.c.

UBYTE I2cReadCts ( void  )

Definition at line 619 of file c_i2c.c.

UBYTE I2cReadStatus ( UBYTE pBuf)

Definition at line 708 of file c_i2c.c.

void I2cSetPIC_EN ( void  )

Definition at line 666 of file c_i2c.c.

void I2cSetPIC_RST ( void  )

Definition at line 638 of file c_i2c.c.

void I2cStart ( void  )

Definition at line 198 of file c_i2c.c.

void I2cStop ( void  )

Definition at line 213 of file c_i2c.c.

int I2cWrite ( int  fd,
unsigned int  addr,
char *  buf,
unsigned char  len 
)

Definition at line 750 of file c_i2c.c.

Variable Documentation

char* RtnMsg = "I2c Func thread end"

Definition at line 129 of file c_i2c.c.