Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages

Macros

#define TWI_BAUD(F_SYS, F_TWI)   (((F_SYS / (2 * F_TWI)) - 5)+1)
 
#define TWI_SUCCESS   (STATUS_OK)
 Error Codes for the Module. More...
 

Functions

static void twi_master_disable (TWI_t *twi)
 Disable Master Mode of the TWI. More...
 
static void twi_master_enable (TWI_t *twi)
 Enable Master Mode of the TWI. More...
 
status_code_t twi_master_init (TWI_t *twi, const twi_options_t *opt)
 Initialize the twi master module. More...
 
static status_code_t twi_master_read (TWI_t *twi, const twi_package_t *package)
 Read multiple bytes from a TWI compatible slave device. More...
 
status_code_t twi_master_transfer (TWI_t *twi, const twi_package_t *package, bool read)
 Perform a TWI master write or read transfer. More...
 
static status_code_t twi_master_write (TWI_t *twi, const twi_package_t *package)
 Write multiple bytes to a TWI compatible slave device. More...
 

#define TWI_BAUD (   F_SYS,
  F_TWI 
)    (((F_SYS / (2 * F_TWI)) - 5)+1)

Baud register setting calculation. Formula described in datasheet.

Referenced by run_twi_master_recv_test(), run_twi_master_send_test(), run_twi_slave_recv_test(), twi_master_setup(), and twi_slave_setup().

#define TWI_SUCCESS   (STATUS_OK)

Error Codes for the Module.

Deprecated:
This definition is provided for compatibility with existing ASF example applications. This module uses the status_code_t values that will replace module-specific error codes in ASF drivers.

Referenced by check_NVRBSY(), main(), mxt_probe_device(), read_temperature(), ts75_copy_nonvol_vol_register(), ts75_copy_vol_nonvol_register(), ts75_probe_nonvol_register(), ts_ack_polling(), ts_read_eeprom(), ts_read_register(), ts_write_eeprom(), ts_write_memory(), and ts_write_register().

static void twi_master_disable ( TWI_t *  twi)
inlinestatic

Disable Master Mode of the TWI.

Parameters
twiBase address of the TWI instance.

Referenced by sha204p_wakeup().

static void twi_master_enable ( TWI_t *  twi)
inlinestatic

Enable Master Mode of the TWI.

Parameters
twiBase address of the TWI instance.

Referenced by run_twi_master_recv_test(), run_twi_master_send_test(), run_twi_slave_recv_test(), and sha204p_wakeup().

status_code_t twi_master_init ( TWI_t *  twi,
const twi_options_t opt 
)

Initialize the twi master module.

Parameters
twiBase address of the TWI (i.e. &TWIC).
*optOptions for initializing the twi module (see twi_options_t)
Return values
STATUS_OKTransaction is successful
ERR_INVALID_ARGInvalid arguments in opt.

References cpu_irq_enable, twi_options_t::speed_reg, STATUS_OK, and transfer.

Referenced by run_twi_master_recv_test(), run_twi_master_send_test(), run_twi_slave_recv_test(), and twi_master_setup().

static status_code_t twi_master_read ( TWI_t *  twi,
const twi_package_t package 
)
inlinestatic

Read multiple bytes from a TWI compatible slave device.

Parameters
twiBase address of the TWI (i.e. &TWI_t).
packagePackage information and data (see twi_package_t)
Returns
STATUS_OK If all bytes were read, error code otherwise

References twi_master_transfer().

Referenced by main(), mxt_get_crc_value(), mxt_get_message_count(), mxt_probe_device(), mxt_read_config_object(), mxt_read_config_reg(), mxt_read_id_block(), mxt_read_message(), mxt_read_object_table(), qt_read_regs(), run_twi_master_recv_test(), sha204p_receive_response(), sha204p_resync(), and twi_read().

status_code_t twi_master_transfer ( TWI_t *  twi,
const twi_package_t package,
bool  read 
)

Perform a TWI master write or read transfer.

This function is a TWI Master write or read transaction.

Parameters
twiBase address of the TWI (i.e. &TWI_t).
packagePackage information and data (see twi_package_t)
readSelects the transfer direction
Returns
status_code_t
  • STATUS_OK if the transfer completes
  • ERR_BUSY to indicate an unavailable bus
  • ERR_IO_ERROR to indicate a bus transaction error
  • ERR_NO_MEMORY to indicate buffer errors
  • ERR_PROTOCOL to indicate an unexpected bus state
  • ERR_INVALID_ARG to indicate invalid arguments.

References twi_package_t::addr_length, twi_package_t::chip, ERR_INVALID_ARG, twi_package_t::no_wait, read, status, STATUS_OK, transfer, twim_acquire(), and twim_release().

Referenced by twi_master_read(), and twi_master_write().

static status_code_t twi_master_write ( TWI_t *  twi,
const twi_package_t package 
)
inlinestatic

Write multiple bytes to a TWI compatible slave device.

Parameters
twiBase address of the TWI (i.e. &TWI_t).
packagePackage information and data (see twi_package_t)
Returns
STATUS_OK If all bytes were written, error code otherwise

References twi_master_transfer().

Referenced by main(), mxt_write_config_object(), mxt_write_config_reg(), qt_read_regs(), qt_write_regs(), run_twi_master_send_test(), run_twi_slave_recv_test(), sha204p_send(), sha204p_wakeup(), twi_probe_device(), and twi_write().