Defines | Enumerations

2-Wire (hal_w2)
[nRF24LE1 HAL]

Defines

#define W2CON0_FLAG_X_STOP   0x20
#define W2CON0_FLAG_X_START   0x10
#define W2CON1_FLAG_NACK   0x02
#define W2CON1_FLAG_DATA_READY   0x01
#define HAL_W2_ISSUE_START_COND   (W2CON0 |= W2CON0_FLAG_X_START)
#define HAL_W2_ISSUE_STOP_COND   (W2CON0 |= W2CON0_FLAG_X_STOP)
#define HAL_W2_WAIT_FOR_INTERRUPT   {while(!SPIF); SPIF = 0; }
#define HAL_W2_WRITE(a)   W2DAT = (a)
#define HAL_W2_READ()   W2DAT
#define W2_SOFT_RESET_NOT_AVAILABLE

Enumerations

enum  hal_w2_clk_freq_t { HAL_W2_IDLE = 0x00, HAL_W2_100KHZ = 0x01, HAL_W2_400KHZ = 0x02 }
enum  hal_w2_op_mode_t { HAL_W2_MASTER, HAL_W2_SLAVE }
enum  hal_w2_irq_source_t { HAL_W2_STOP_COND = 0x08, HAL_W2_ADRESS_MATCH = 0x04, HAL_W2_DATA_READY = 0x01 }
enum  hal_w2_direction_t { HAL_W2_DIR_WRITE, HAL_W2_DIR_READ }

SLAVE SPECIFIC FUNCTIONS

void hal_w2_respond_to_gen_adr (_Bool resp_gen)
void hal_w2_alter_clock (_Bool alt_clk)
void hal_w2_irq_stop_cond_enable (_Bool stop_cond)
void hal_w2_irq_adr_match_enable (_Bool addr_match)
void hal_w2_set_slave_address (uint8_t address)

Define Documentation

#define W2CON0_FLAG_X_STOP   0x20

Definition at line 29 of file hal_w2.h.

#define W2CON0_FLAG_X_START   0x10

Definition at line 30 of file hal_w2.h.

#define W2CON1_FLAG_NACK   0x02

Definition at line 32 of file hal_w2.h.

#define W2CON1_FLAG_DATA_READY   0x01

Definition at line 33 of file hal_w2.h.

#define HAL_W2_ISSUE_START_COND   (W2CON0 |= W2CON0_FLAG_X_START)

Definition at line 35 of file hal_w2.h.

#define HAL_W2_ISSUE_STOP_COND   (W2CON0 |= W2CON0_FLAG_X_STOP)

Definition at line 36 of file hal_w2.h.

#define HAL_W2_WAIT_FOR_INTERRUPT   {while(!SPIF); SPIF = 0; }

Definition at line 37 of file hal_w2.h.

#define HAL_W2_WRITE (   a )    W2DAT = (a)

Definition at line 38 of file hal_w2.h.

#define HAL_W2_READ (  )    W2DAT

Definition at line 39 of file hal_w2.h.

#define W2_SOFT_RESET_NOT_AVAILABLE

Definition at line 58 of file hal_w2.h.


Enumeration Type Documentation

An enum describing the clock frequency.

Enumerator:
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.

An enum describing master or slave mode.

Enumerator:
HAL_W2_MASTER 

Master mode

HAL_W2_SLAVE 

Slave mode

Definition at line 73 of file hal_w2.h.

An enum describing the 2-wire's irq sources.

Enumerator:
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.

An enum describing master transfer direction.

Enumerator:
HAL_W2_DIR_WRITE 

Transfer direction: write

HAL_W2_DIR_READ 

Transfer direction: read

Definition at line 90 of file hal_w2.h.


Function Documentation

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 --

Parameters:
resp_genTrue 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 --

Parameters:
stop_condTrue to enable, false to disable irq when stop condition is detected

Definition at line 63 of file hal_w2.c.

{ 
  if(stop_cond)
  {                                                                  
    W2CON0 = W2CON0 & ~(1 << X_STOP);         // Clear "xStop" bit
  }
  else
  {
    W2CON0 = W2CON0 | (1 << X_STOP);          // Set "xStop" bit
  }
}
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 --

Parameters:
addr_matchTrue to enable, false to disable the irq on address match

Definition at line 75 of file hal_w2.c.

{
  if(addr_match)
  {
    W2CON0 = W2CON0 & ~(1 << X_START);        // Clear "xStart" bit
  }
  else
  {
    W2CON0 = W2CON0 | (1 << X_START);         // Set "xStart" bit
  }
}
void hal_w2_set_slave_address ( uint8_t  address )

Function to set the slave address. Use this function to set the 7-bit address for slave mode.

Parameters:
address7-bit slave address

Definition at line 87 of file hal_w2.c.

{
  W2SADR = (address & 0x7F);                  // Set 7 bit adress of the slave
}