PIC24 Support Libraries
Files | Macros | Functions
ESOS_I2C_Service

Files

file  esos_pic24_i2c.h
 This file contains routines which configure and use I2C on the Microchip PIC24 MCUs.
 
file  esos_pic24_i2c.c
 

Macros

#define ESOS_TASK_WAIT_ON_WRITE1I2C1(u8_addr, u8_d1)
 
#define ESOS_TASK_WAIT_ON_WRITE2I2C1(u8_addr, u8_d1, u8_d2)
 
#define ESOS_TASK_WAIT_ON_WRITENI2C1(u8_addr, pu8_d, u16_cnt)
 
#define ESOS_TASK_WAIT_ON_READ1I2C1(u8_addr, u8_d1)
 
#define ESOS_TASK_WAIT_ON_READ2I2C1(u8_addr, u8_d1, u8_d2)
 
#define ESOS_TASK_WAIT_ON_READNI2C1(u8_addr, pu8_d, u16_cnt)
 

Functions

void esos_pic24_configI2C1 (uint16_t u16_FkHZ)
 
 ESOS_CHILD_TASK (__esos_pic24_writeNI2C1, uint8_t u8_addr, uint8_t *pu8_d, uint16_t u16_cnt)
 
 ESOS_CHILD_TASK (__esos_pic24_readNI2C1, uint8_t u8_addr, uint8_t *pu8_d, uint16_t u16_cnt)
 

Detailed Description

Macro Definition Documentation

◆ ESOS_TASK_WAIT_ON_READ1I2C1

#define ESOS_TASK_WAIT_ON_READ1I2C1 (   u8_addr,
  u8_d1 
)

Transaction: Read 1 (ONE) byte from I2C slave at address u8_addr, and save to variable u8_d1 As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.

Parameters
u8_addrSlave I2C address
u8_d1variable to hold the read byte
See also
ESOS_TASK_WAIT_ON_READ2I2C1
ESOS_TASK_WAIT_ON_READNI2C1
esos_pic24_configI2C1

Definition at line 163 of file esos_pic24_i2c.h.

◆ ESOS_TASK_WAIT_ON_READ2I2C1

#define ESOS_TASK_WAIT_ON_READ2I2C1 (   u8_addr,
  u8_d1,
  u8_d2 
)

Transaction: Read 2 (TWO) bytes from I2C slave at address u8_addr, save to variables u8_d1 and u8_d2 As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.

Parameters
u8_addrSlave I2C address
u8_d1variable to hold first read byte
u8_d2variable to hold second read byte
See also
ESOS_TASK_WAIT_ON_READ1I2C1
ESOS_TASK_WAIT_ON_READNI2C1
esos_pic24_configI2C1

Definition at line 181 of file esos_pic24_i2c.h.

◆ ESOS_TASK_WAIT_ON_READNI2C1

#define ESOS_TASK_WAIT_ON_READNI2C1 (   u8_addr,
  pu8_d,
  u16_cnt 
)

Transaction: Read u16_cnt bytes from I2C slave at address u8_addr, save to buffer *pu8_d. As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.

Parameters
u8_addrSlave I2C address
pu8_dPointer to buffer for storing bytes read from slave
u16_cntNumber of bytes read from slave.
See also
ESOS_TASK_WAIT_ON_READ1I2C1
ESOS_TASK_WAIT_ON_READ2I2C1
esos_pic24_configI2C1

Definition at line 199 of file esos_pic24_i2c.h.

◆ ESOS_TASK_WAIT_ON_WRITE1I2C1

#define ESOS_TASK_WAIT_ON_WRITE1I2C1 (   u8_addr,
  u8_d1 
)

Transaction: Write 1 (ONE) byte stored in variable u8_d1 to I2C slave at address u8_addr.

Parameters
u8_addrSlave I2C address
u8_d1Variable containing first byte to write
See also
ESOS_TASK_WAIT_ON_WRITE2I2C1
ESOS_TASK_WAIT_ON_WRITENI2C1
esos_pic24_configI2C1

Definition at line 115 of file esos_pic24_i2c.h.

◆ ESOS_TASK_WAIT_ON_WRITE2I2C1

#define ESOS_TASK_WAIT_ON_WRITE2I2C1 (   u8_addr,
  u8_d1,
  u8_d2 
)

Transaction: Write 2 (TWO) bytes stored in variables u8_d1 and u8_d2 to I2C slave at address u8_addr.

Parameters
u8_addrSlave I2C address
u8_d1Variable containing first byte to write
u8_d2Variable containing second byte to write
See also
ESOS_TASK_WAIT_ON_WRITE1I2C1
ESOS_TASK_WAIT_ON_WRITENI2C1

Definition at line 134 of file esos_pic24_i2c.h.

◆ ESOS_TASK_WAIT_ON_WRITENI2C1

#define ESOS_TASK_WAIT_ON_WRITENI2C1 (   u8_addr,
  pu8_d,
  u16_cnt 
)

Transaction: Write u16_cnt bytes stored in buffer *pu8_d to I2C slave at address u8_addr.

Parameters
u8_addrSlave I2C address
pu8_dPointer to buffer containing bytes to send
u16_cntNumber of bytes to send
See also
ESOS_TASK_WAIT_ON_WRITE1I2C1
ESOS_TASK_WAIT_ON_WRITE2I2C1

Definition at line 150 of file esos_pic24_i2c.h.

Function Documentation

◆ ESOS_CHILD_TASK() [1/2]

ESOS_CHILD_TASK ( __esos_pic24_writeNI2C1  ,
uint8_t  u8_addr,
uint8_t pu8_d,
uint16_t  u16_cnt 
)

Transaction: Write u16_cnt bytes stored in buffer *pu8_d to I2C slave at address u8_addr.

Parameters
u8_addrSlave I2C address
pu8_dPointer to buffer containing bytes to send
u16_cntNumber of bytes to send

Definition at line 98 of file esos_pic24_i2c.c.

◆ ESOS_CHILD_TASK() [2/2]

ESOS_CHILD_TASK ( __esos_pic24_readNI2C1  ,
uint8_t  u8_addr,
uint8_t pu8_d,
uint16_t  u16_cnt 
)

Transaction: Read u16_cnt bytes from I2C slave at address u8_addr, save to buffer *pu8_d. As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.

Parameters
u8_addrSlave I2C address
pu8_dPointer to buffer for storing bytes read from slave
u16_cntNumber of bytes read from slave.

Definition at line 124 of file esos_pic24_i2c.c.

◆ esos_pic24_configI2C1()

void esos_pic24_configI2C1 ( uint16_t  u16_fKHz)

Configure and enable the I2C1 module for operation at u16_fKHz KHz clock speed.

Parameters
u16_fKHzspecifies clock speed in KHz
See also
ESOS_TASK_WAIT_ON_WRITENI2C1
ESOS_TASK_WAIT_ON_READNI2C1

Definition at line 65 of file esos_pic24_i2c.c.