HWA
Bare metal programming with style
Class _swtwimaster: software-emulated TWI (master only)

Detailed Description

This class implements a software-emulated TWI master.

Attention
This class may not be supported by all devices.

Header file:

Interface




HW_SWTWIMASTER( scl, <scl>, sda, <sda>, bps, <bps> ) defines a SWTWIMASTER object:

Example:

#define TWI HW_SWTWIMASTER( scl, (portc,5),
sda, (portc,4),
bps, 400000 )




HW_DECLARE( TWI ) declares the functions that implement the TWI object:

HW_DECLARE( TWI );




HW_IMPLEMENT( TWI ) declares the functions that implement the TWI object:

HW_IMPLEMENT( TWI );




hw( configure, TWI ) and hwa( configure, TWI ) configure the object:

hw( configure, TWI );
hwa( configure, TWI );




hw( xfr_start, TWI ) sends a start condition on the TWI bus:

hw( xfr_start, TWI );




hw( xfr_slar, TWI, slave_address ) sends slave address + read bit:

hw( xfr_slar, TWI, slave_address );




hw( xfr_slaw, TWI, slave_address ) sends slave address + write bit:

hw( xfr_slaw, TWI, slave_address );




hw( xfr_read, TWI, data, ack|nack ) receive one data byte:

uint8_t r = hw( xfr_read, TWI, ack );




hw( xfr_write, TWI, data ) transmit one data byte:

uint8_t r = hw( xfr_write, TWI, data ); // r = ack|nack




hw( xfr_stop, TWI ) sends a start condition on the TWI bus:

hw( xfr_stop, TWI );




hw( stat, TWI ) get the status byte of the object:

uint8_t st = hw( stat, TWI );

Macros

#define HW_SWTWIMASTER(...)
 
hwa
#define hwa(...)
hwa( action, object [,...] ) stores an action for an object into a HWA context.
Definition: hwa_macros.h:552
HW_DECLARE
#define HW_DECLARE(...)
Declares the functions that implement an object.
Definition: hwa_1.h:526
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523
swtwimaster.h
Software-emulated TWI master.
HW_IMPLEMENT
#define HW_IMPLEMENT(...)
Defines the functions that implement an object.
Definition: hwa_1.h:548