Group ns-i2c
Modules
Type | Name |
---|---|
module | Ns-MAX86150 |
module | Ns-MPU6050 |
Classes
Type | Name |
---|---|
struct | ns_i2c_config_t i2c configuration |
struct | ns_i2c_msg_t |
Public Types
Type | Name |
---|---|
enum | ns_i2c_status_e |
enum | ns_i2c_xfer_flag_e |
Public Attributes
Type | Name |
---|---|
const ns_core_api_t | ns_i2c_V0_0_1 |
const ns_core_api_t | ns_i2c_V1_0_0 |
const ns_core_api_t | ns_i2c_current_version |
const ns_core_api_t | ns_i2c_oldest_supported_version |
Public Functions
Type | Name |
---|---|
uint32_t | ns_i2c_interface_init (ns_i2c_config_t * cfg, uint32_t speed) Initialize I2C on one of the IOM (IO managers) |
uint32_t | ns_i2c_read (ns_i2c_config_t * cfg, const void * buf, uint32_t size, uint16_t addr) Perform low-level I2C read using IOM transfer. |
uint32_t | ns_i2c_read_reg (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t regAddr, uint8_t * value, uint8_t mask) Read 8-bit register over I2C. |
uint32_t | ns_i2c_read_sequential_regs (ns_i2c_config_t * cfg, uint32_t devAddr, uint32_t regAddr, void * buf, uint32_t size) Read sequential 8-bit registers over I2C. |
uint32_t | ns_i2c_transfer (ns_i2c_config_t * cfg, ns_i2c_msg_t * msgs, size_t numMsgs) Perform sequence of low-level I2C transfers (similar to Linux) |
uint32_t | ns_i2c_write (ns_i2c_config_t * cfg, const void * buf, uint32_t size, uint16_t addr) Perform low-level I2C write using IOM transfer. |
uint32_t | ns_i2c_write_read (ns_i2c_config_t * cfg, uint16_t addr, const void * writeBuf, size_t numWrite, void * readBuf, size_t numRead) Perform low-level I2C write followed by immediate read. |
uint32_t | ns_i2c_write_reg (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t regAddr, uint8_t value, uint8_t mask) Write 8-bit register over I2C. |
uint32_t | ns_i2c_write_sequential_regs (ns_i2c_config_t * cfg, uint32_t devAddr, uint32_t regAddr, void * buf, uint32_t size) Write sequential 8-bit registers over I2C. |
Macros
Type | Name |
---|---|
define | NS_I2C_API_ID 0xCA0004 |
define | NS_I2C_CURRENT_VERSION NS_I2C_V1_0_0 |
define | NS_I2C_OLDEST_SUPPORTED_VERSION NS_I2C_V0_0_1 |
define | NS_I2C_V0_0_1 { .major = 0, .minor = 0, .revision = 1 } |
define | NS_I2C_V1_0_0 { .major = 1, .minor = 0, .revision = 0 } |
Public Types Documentation
enum ns_i2c_status_e
enum ns_i2c_status_e {
NS_I2C_STATUS_SUCCESS = 0,
NS_I2C_STATUS_ERROR = 1
};
enum ns_i2c_xfer_flag_e
enum ns_i2c_xfer_flag_e {
NS_I2C_XFER_WR = 0,
NS_I2C_XFER_RD = (1u << 0)
};
Public Attributes Documentation
variable ns_i2c_V0_0_1
const ns_core_api_t ns_i2c_V0_0_1;
variable ns_i2c_V1_0_0
const ns_core_api_t ns_i2c_V1_0_0;
variable ns_i2c_current_version
const ns_core_api_t ns_i2c_current_version;
variable ns_i2c_oldest_supported_version
const ns_core_api_t ns_i2c_oldest_supported_version;
Public Functions Documentation
function ns_i2c_interface_init
Initialize I2C on one of the IOM (IO managers)
uint32_t ns_i2c_interface_init (
ns_i2c_config_t * cfg,
uint32_t speed
)
Parameters:
cfg
I2C configurationspeed
I2C speed in Hz
Returns:
uint32_t status
function ns_i2c_read
Perform low-level I2C read using IOM transfer.
uint32_t ns_i2c_read (
ns_i2c_config_t * cfg,
const void * buf,
uint32_t size,
uint16_t addr
)
Parameters:
cfg
I2C configurationbuf
Buffer to store read bytessize
Number of bytes to readaddr
I2C device address
function ns_i2c_read_reg
Read 8-bit register over I2C.
uint32_t ns_i2c_read_reg (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t regAddr,
uint8_t * value,
uint8_t mask
)
Parameters:
cfg
I2C configurationdevAddr
Device addressregAddr
Register addressvalue
Register Valuemask
Read mask
Returns:
uint32_t status
Parameters:
cfg
Handle obtained from ns_i2c_interface_initdevAddr
Device addressregAddr
8-bit register addressvalue
Register valuemask
Read mask
Returns:
uint32_t status
function ns_i2c_read_sequential_regs
Read sequential 8-bit registers over I2C.
uint32_t ns_i2c_read_sequential_regs (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint32_t regAddr,
void * buf,
uint32_t size
)
Parameters:
cfg
I2C configurationdevAddr
Device addressregAddr
First register addressbuf
Buffer to store register valuessize
Number of registers to read
Returns:
uint32_t status
Parameters:
cfg
I2C configurationdevAddr
Device addressregAddr
First 8-bit register addressbuf
Buffer to store register valuessize
Number of registers to read
Returns:
uint32_t status
function ns_i2c_transfer
Perform sequence of low-level I2C transfers (similar to Linux)
uint32_t ns_i2c_transfer (
ns_i2c_config_t * cfg,
ns_i2c_msg_t * msgs,
size_t numMsgs
)
Parameters:
cfg
I2C configurationmsgs
I2C messages to transfernumMsgs
Number of I2C messsages
function ns_i2c_write
Perform low-level I2C write using IOM transfer.
uint32_t ns_i2c_write (
ns_i2c_config_t * cfg,
const void * buf,
uint32_t size,
uint16_t addr
)
Parameters:
cfg
I2C configurationbuf
Buffer of bytes to writesize
Number of bytes to writeaddr
I2C device address
function ns_i2c_write_read
Perform low-level I2C write followed by immediate read.
uint32_t ns_i2c_write_read (
ns_i2c_config_t * cfg,
uint16_t addr,
const void * writeBuf,
size_t numWrite,
void * readBuf,
size_t numRead
)
Parameters:
cfg
I2C configurationwriteBuf
Write buffernumWrite
Number of bytes to writereadBuf
Read buffernumRead
Number of bytes to readaddr
I2C device address
function ns_i2c_write_reg
Write 8-bit register over I2C.
uint32_t ns_i2c_write_reg (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t regAddr,
uint8_t value,
uint8_t mask
)
Parameters:
cfg
I2C configurationdevAddr
Device addressregAddr
Register addressvalue
Register Valuemask
Write mask
Returns:
uint32_t status
Parameters:
cfg
Handle obtained from ns_i2c_interface_initdevAddr
Device addressregAddr
8-bit register addressvalue
Register valuemask
Write mask
Returns:
uint32_t status
function ns_i2c_write_sequential_regs
Write sequential 8-bit registers over I2C.
uint32_t ns_i2c_write_sequential_regs (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint32_t regAddr,
void * buf,
uint32_t size
)
Parameters:
cfg
I2C configurationdevAddr
Device addressregAddr
First register addressbuf
Pointer to buffer of values to be writtensize
Number of bytes to write
Returns:
uint32_t status
Parameters:
cfg
I2C configurationdevAddr
Device addressregAddr
First 8-bit register addressbuf
Pointer to buffer of values to be writtensize
Number of bytes to write
Returns:
uint32_t status
Macro Definition Documentation
define NS_I2C_API_ID
#define NS_I2C_API_ID 0xCA0004
define NS_I2C_CURRENT_VERSION
#define NS_I2C_CURRENT_VERSION NS_I2C_V1_0_0
define NS_I2C_OLDEST_SUPPORTED_VERSION
#define NS_I2C_OLDEST_SUPPORTED_VERSION NS_I2C_V0_0_1
define NS_I2C_V0_0_1
#define NS_I2C_V0_0_1 { .major = 0, .minor = 0, .revision = 1 }
define NS_I2C_V1_0_0
#define NS_I2C_V1_0_0 { .major = 1, .minor = 0, .revision = 0 }