File ns_i2c.h
FileList > includes-api > ns_i2c.h
Go to the source code of this file
Generic I2C driver. More...
#include "am_bsp.h"
#include "am_mcu_apollo.h"
#include "am_util.h"
#include "ns_core.h"
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_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. |
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 } |
Detailed Description
Author:
Adam Page
Version:
0.1
Date:
2022-08-26
Copyright:
Copyright (c) 2022
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_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
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 }
The documentation for this class was generated from the following file neuralSPOT/neuralspot/ns-i2c/includes-api/ns_i2c.h