Functions

Low frequency clock (cklf)
[nRF24LU1+ HAL]


in the nRF24LU1

Functions

void cklf_regxc_write (uint8_t addr, uint16_t val)
uint16_t cklf_regxc_read (uint8_t addr)
void cklf_rtc_disable (void)
void cklf_rtc_init (uint8_t cnt_h, uint16_t cnt_l)
uint16_t cklf_rtc_read_lsw (void)
uint8_t cklf_rtc_read_msb (void)
void cklf_rtc_wait (void)
void cklf_wdog_init (uint16_t cnt)
void cklf_wdog_feed (void)
void cklf_gpio_wakeup (uint16_t wcon1, uint16_t wcon0)

Function Documentation

void cklf_regxc_write ( uint8_t  addr,
uint16_t  val 
)

Function to write to the low frequency clock interface (CKLF) in nRF24LU1.

Parameters:
addrthe address of the register to write
valthe value to write to the register

Definition at line 23 of file cklf.c.

{
  REGXH = val >> 8;
  REGXL = val & 0xff;
  REGXC = addr;
}
uint16_t cklf_regxc_read ( uint8_t  addr )

Function to read the low frequency clock interface (CKLF) in nRF24LU1.

Parameters:
addrthe address of the register to read
Returns:
the value read

Definition at line 30 of file cklf.c.

{
  uint16_t val;

  REGXC = addr;
  val = (uint16_t)REGXH;
  val <<= 8;
  val |= (uint16_t)REGXL;
  return val;
}
void cklf_rtc_disable ( void   )

Function to disable the RTC. This function should be called before reading values from the RTC counter.

Definition at line 41 of file cklf.c.

void cklf_rtc_init ( uint8_t  cnt_h,
uint16_t  cnt_l 
)

Function to initialize the RTC.

Parameters:
cnt_hThe upper 8 bits of the 24 bit value to load into the RTC latch
cnt_lThe lower 16 bits of the 24 bit value to load into the RTC latch

Definition at line 46 of file cklf.c.

{
  cklf_regxc_write(WRTCDIS, 0);                // Disable RTC timer before updating latch
  WUF = 0;                                     // Clear any pending interrupts
  cklf_regxc_write(WGTIMER, (uint16_t)cnt_h);  // Program MS part first
  cklf_regxc_write(WRTCLAT, cnt_l);            // Write LS part and enable RTC
}
uint16_t cklf_rtc_read_lsw ( void   )

Function to read the lower 16 bits of the RTC counter. To ensure consistency between the return value of this function and cklf_rtc_read_msb the RTC should be disabled before calling these functions.

Returns:
The lower 16 bits of the RTC counter.

Definition at line 54 of file cklf.c.

{
  return cklf_regxc_read(RRTC);
}
uint8_t cklf_rtc_read_msb ( void   )

Function to read the upper 8 bits of the RTC counter. To ensure consistency between the return value of this function and cklf_rtc_read_lsw the RTC should be disabled before calling these functions.

Returns:
The upper 8 bits of the RTC counter.

Definition at line 59 of file cklf.c.

{
  return (uint8_t)(cklf_regxc_read(RGTIMER) >> 8);
}
void cklf_rtc_wait ( void   )

Function to wait for the RTC counter to reach 0. This function enters an infinite loop polling the RTC interrupt flag. When the flag is set the flag is cleared and the function returns.

Definition at line 64 of file cklf.c.

{
  while(WUF == 0)                         // Wait until IEX6 is set
    ;
  WUF = 0;
}
void cklf_wdog_init ( uint16_t  cnt )

Function to initialize and enable the watchdog.

Parameters:
cntThe value to load into the watchdog counter.

Definition at line 71 of file cklf.c.

{
  wd_cnt = cnt;
  cklf_regxc_write(WWD, wd_cnt);
}
void cklf_wdog_feed ( void   )

Function to reload the watchdog. This function reloads the watchdog counter with the parameter given in the hal_wdog_init function.

Definition at line 77 of file cklf.c.

{
  cklf_regxc_write(WWD, wd_cnt);
}
void cklf_gpio_wakeup ( uint16_t  wcon1,
uint16_t  wcon0 
)

Function to program the GPIO wakeup functionality

Parameters:
wcon0Value of WCON0 register (P00 - P03)
wcon1Value of WCON1 register (P04 - P07)

Definition at line 82 of file cklf.c.