Firmware SDK
twr_module_relay

Driver for HARDWARIO Relay Module. More...

Typedefs

typedef struct twr_module_relay_t twr_module_relay_t
 HARDWARIO Relay Module instance.
 

Enumerations

enum  twr_module_relay_state_t {
  TWR_MODULE_RELAY_STATE_UNKNOWN = -1 ,
  TWR_MODULE_RELAY_STATE_FALSE = 0 ,
  TWR_MODULE_RELAY_STATE_TRUE = 1
}
 Reported relay states. More...
 

Functions

bool twr_module_relay_init (twr_module_relay_t *self, uint8_t i2c_address)
 Initialize HARDWARIO Relay Module. More...
 
void twr_module_relay_set_state (twr_module_relay_t *self, bool state)
 Set relay to specified state. More...
 
twr_module_relay_state_t twr_module_relay_get_state (twr_module_relay_t *self)
 Get current relay state. More...
 
void twr_module_relay_pulse (twr_module_relay_t *self, bool direction, twr_tick_t duration)
 Generate pulse to specified state for given duration. More...
 
void twr_module_relay_toggle (twr_module_relay_t *self)
 Toggle relay to opposite state. More...
 

Detailed Description

Driver for HARDWARIO Relay Module.

Example: Blink with on-board LED

#include <twr_module_relay.h>
void application_init(void)
{
}
// If you want to set relay to TRUE state...
twr_module_relay_set(&relay, true);
// If you want to toggle relay...
// If you want to make 1 second pulse to TRUE state...
twr_module_relay_pulse(&relay, true, 1000);
struct twr_module_relay_t twr_module_relay_t
HARDWARIO Relay Module instance.
void twr_module_relay_toggle(twr_module_relay_t *self)
Toggle relay to opposite state.
void twr_module_relay_pulse(twr_module_relay_t *self, bool direction, twr_tick_t duration)
Generate pulse to specified state for given duration.
bool twr_module_relay_init(twr_module_relay_t *self, uint8_t i2c_address)
Initialize HARDWARIO Relay Module.

Enumeration Type Documentation

◆ twr_module_relay_state_t

Reported relay states.

Enumerator
TWR_MODULE_RELAY_STATE_UNKNOWN 

State is unknown.

TWR_MODULE_RELAY_STATE_FALSE 

State is false.

TWR_MODULE_RELAY_STATE_TRUE 

State is true.

Definition at line 36 of file twr_module_relay.h.

Function Documentation

◆ twr_module_relay_get_state()

twr_module_relay_state_t twr_module_relay_get_state ( twr_module_relay_t self)

Get current relay state.

Parameters
[in]selfInstance
Returns
Relay state

Definition at line 221 of file twr_module_relay.c.

◆ twr_module_relay_init()

bool twr_module_relay_init ( twr_module_relay_t self,
uint8_t  i2c_address 
)

Initialize HARDWARIO Relay Module.

Parameters
[in]selfInstance

Definition at line 28 of file twr_module_relay.c.

◆ twr_module_relay_pulse()

void twr_module_relay_pulse ( twr_module_relay_t self,
bool  direction,
twr_tick_t  duration 
)

Generate pulse to specified state for given duration.

Parameters
[in]selfInstance
[in]directionDesired pulse state
[in]durationDesired pulse duration

Definition at line 211 of file twr_module_relay.c.

◆ twr_module_relay_set_state()

void twr_module_relay_set_state ( twr_module_relay_t self,
bool  state 
)

Set relay to specified state.

Parameters
[in]selfInstance
[in]stateDesired relay state

Definition at line 190 of file twr_module_relay.c.

Referenced by twr_module_relay_toggle().

Here is the caller graph for this function:

◆ twr_module_relay_toggle()

void twr_module_relay_toggle ( twr_module_relay_t self)

Toggle relay to opposite state.

Parameters
[in]selfInstance

Definition at line 199 of file twr_module_relay.c.

Here is the call graph for this function: