#define HAL_W2_ISSUE_START_COND (W2CON0 |= W2CON0_FLAG_X_START) |
#define HAL_W2_ISSUE_STOP_COND (W2CON0 |= W2CON0_FLAG_X_STOP) |
enum hal_w2_clk_freq_t |
An enum describing the clock frequency.
HAL_W2_IDLE |
Idle |
HAL_W2_100KHZ |
100 KHz (Standard mode) |
HAL_W2_400KHZ |
400 KHz (Fast mode) |
Definition at line 64 of file hal_w2.h.
{ HAL_W2_IDLE = 0x00, HAL_W2_100KHZ = 0x01, HAL_W2_400KHZ = 0x02 } hal_w2_clk_freq_t;
enum hal_w2_op_mode_t |
An enum describing master or slave mode.
enum hal_w2_irq_source_t |
An enum describing the 2-wire's irq sources.
HAL_W2_STOP_COND |
Interrupt caused by stop condition |
HAL_W2_ADRESS_MATCH |
Interrupt caused by address match |
HAL_W2_DATA_READY |
Interrupt caused by byte transmitted/received |
Definition at line 81 of file hal_w2.h.
{ HAL_W2_STOP_COND = 0x08, HAL_W2_ADRESS_MATCH = 0x04, HAL_W2_DATA_READY = 0x01 } hal_w2_irq_source_t;
enum hal_w2_direction_t |
An enum describing master transfer direction.
void hal_w2_respond_to_gen_adr | ( | _Bool | resp_gen ) |
Function to set the slave to respond to a general call address. Use this function set the slave to respond to a general call address (0x00) as well as the defined address -- Slave only --
resp_gen | True if the slave shall respond to general call adress |
Definition at line 39 of file hal_w2.c.
{ if(resp_gen) { W2CON0 = W2CON0 | (1 << BROADCAST_ENABLE); // Set "broadcastEnable" bit } else { W2CON0 = W2CON0 & ~(1 << BROADCAST_ENABLE); // Clear "broadcastEnable" bit } }
void hal_w2_alter_clock | ( | _Bool | alt_clk ) |
Function to control clockStop mode. Use this function to control clockStop mode -- Slave only --
Definition at line 51 of file hal_w2.c.
{ if(alt_clk) { W2CON0 = W2CON0 | (1 << CLOCK_STOP); // Set "clockStop" bit } else { W2CON0 = W2CON0 & ~(1 << CLOCK_STOP); // Clear "clockStop" bit } }
void hal_w2_irq_stop_cond_enable | ( | _Bool | stop_cond ) |
Function to enable irq when stop condition is detected. Use this function enable irq when stop condition is detected -- Slave only --
stop_cond | True to enable, false to disable irq when stop condition is detected |
void hal_w2_irq_adr_match_enable | ( | _Bool | addr_match ) |
Function to enable the irq on address match. Use this function enable the irq on address match -- Slave only --
addr_match | True to enable, false to disable the irq on address match |