Skip to content

File ns_i2c.c

FileList > neuralSPOT > neuralspot > ns-i2c > src > ns_i2c.c

Go to the source code of this file

Generic i2c driver. More...

  • #include "ns_i2c.h"
  • #include "am_bsp.h"
  • #include "am_mcu_apollo.h"
  • #include "am_util.h"
  • #include "ns_core.h"

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.

Detailed Description

Author:

Adam Page

Version:

0.1

Date:

2022-08-26

Copyright:

Copyright (c) 2022

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 configuration
  • speed 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 configuration
  • buf Buffer to store read bytes
  • size Number of bytes to read
  • addr 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 configuration
  • msgs I2C messages to transfer
  • numMsgs 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 configuration
  • buf Buffer of bytes to write
  • size Number of bytes to write
  • addr 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 configuration
  • writeBuf Write buffer
  • numWrite Number of bytes to write
  • readBuf Read buffer
  • numRead Number of bytes to read
  • addr I2C device address

The documentation for this class was generated from the following file neuralSPOT/neuralspot/ns-i2c/src/ns_i2c.c