Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_module_relay

Driver for BigClown Relay Module. More...

Typedefs

typedef struct bc_module_relay_t bc_module_relay_t
 BigClown Relay Module instance.
 

Enumerations

enum  bc_module_relay_state_t {
  BC_MODULE_RELAY_STATE_UNKNOWN = -1,
  BC_MODULE_RELAY_STATE_FALSE = 0,
  BC_MODULE_RELAY_STATE_TRUE = 1
}
 Reported relay states. More...
 

Functions

bool bc_module_relay_init (bc_module_relay_t *self, uint8_t i2c_address)
 Initialize BigClown Relay Module. More...
 
void bc_module_relay_set_state (bc_module_relay_t *self, bool state)
 Set relay to specified state. More...
 
bc_module_relay_state_t bc_module_relay_get_state (bc_module_relay_t *self)
 Get current relay state. More...
 
void bc_module_relay_pulse (bc_module_relay_t *self, bool direction, bc_tick_t duration)
 Generate pulse to specified state for given duration. More...
 
void bc_module_relay_toggle (bc_module_relay_t *self)
 Toggle relay to opposite state. More...
 

Detailed Description

Driver for BigClown Relay Module.

How to use this driver

#include <bc_module_relay.h>
void application_init(void)
{
}
// If you want to set relay to TRUE state...
bc_module_relay_set(&relay, true);
// If you want to toggle relay...
// If you want to make 1 second pulse to TRUE state...
bc_module_relay_pulse(&relay, true, 1000);

Enumeration Type Documentation

Reported relay states.

Enumerator
BC_MODULE_RELAY_STATE_UNKNOWN 

State is unknown.

BC_MODULE_RELAY_STATE_FALSE 

State is false.

BC_MODULE_RELAY_STATE_TRUE 

State is true.

Definition at line 36 of file bc_module_relay.h.

Function Documentation

bc_module_relay_state_t bc_module_relay_get_state ( bc_module_relay_t self)

Get current relay state.

Parameters
[in]selfInstance
Returns
Relay state

Definition at line 221 of file bc_module_relay.c.

bool bc_module_relay_init ( bc_module_relay_t self,
uint8_t  i2c_address 
)

Initialize BigClown Relay Module.

Parameters
[in]selfInstance

Definition at line 27 of file bc_module_relay.c.

void bc_module_relay_pulse ( bc_module_relay_t self,
bool  direction,
bc_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 bc_module_relay.c.

void bc_module_relay_set_state ( bc_module_relay_t self,
bool  state 
)

Set relay to specified state.

Parameters
[in]selfInstance
[in]stateDesired relay state

Definition at line 190 of file bc_module_relay.c.

Referenced by bc_module_relay_toggle().

Here is the caller graph for this function:

void bc_module_relay_toggle ( bc_module_relay_t self)

Toggle relay to opposite state.

Parameters
[in]selfInstance

Definition at line 199 of file bc_module_relay.c.

Here is the call graph for this function: