• Main Page
  • Modules
  • Index
  • File List
  • Globals

hal/nrf24lu1p/cklf.c

Go to the documentation of this file.
00001 /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is confidential property of Nordic 
00004  * Semiconductor ASA.Terms and conditions of usage are described in detail 
00005  * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 
00006  *
00007  * Licensees are granted free, non-transferable use of the information. NO
00008  * WARRENTY of ANY KIND is provided. This heading must NOT be removed from
00009  * the file.
00010  *              
00011  * $LastChangedRevision: 133 $
00012  */
00013 
00018 #include "nrf24lu1p.h"
00019 #include "cklf.h"
00020 
00021 static uint16_t wd_cnt;
00022 
00023 void cklf_regxc_write(uint8_t addr, uint16_t val)
00024 {
00025   REGXH = val >> 8;
00026   REGXL = val & 0xff;
00027   REGXC = addr;
00028 }
00029 
00030 uint16_t cklf_regxc_read(uint8_t addr)
00031 {
00032   uint16_t val;
00033 
00034   REGXC = addr;
00035   val = (uint16_t)REGXH;
00036   val <<= 8;
00037   val |= (uint16_t)REGXL;
00038   return val;
00039 }
00040 
00041 void cklf_rtc_disable(void)
00042 {
00043   cklf_regxc_write(WRTCDIS, 0);
00044 }
00045 
00046 void cklf_rtc_init(uint8_t cnt_h, uint16_t cnt_l)
00047 {
00048   cklf_regxc_write(WRTCDIS, 0);                // Disable RTC timer before updating latch
00049   WUF = 0;                                     // Clear any pending interrupts
00050   cklf_regxc_write(WGTIMER, (uint16_t)cnt_h);  // Program MS part first
00051   cklf_regxc_write(WRTCLAT, cnt_l);            // Write LS part and enable RTC
00052 }
00053 
00054 uint16_t cklf_rtc_read_lsw(void)
00055 {
00056   return cklf_regxc_read(RRTC);
00057 }
00058 
00059 uint8_t cklf_rtc_read_msb(void)
00060 {
00061   return (uint8_t)(cklf_regxc_read(RGTIMER) >> 8);
00062 }
00063 
00064 void cklf_rtc_wait(void)
00065 {
00066   while(WUF == 0)                         // Wait until IEX6 is set
00067     ;
00068   WUF = 0;
00069 }
00070 
00071 void cklf_wdog_init(uint16_t cnt)
00072 {
00073   wd_cnt = cnt;
00074   cklf_regxc_write(WWD, wd_cnt);
00075 }
00076 
00077 void cklf_wdog_feed(void)
00078 {
00079   cklf_regxc_write(WWD, wd_cnt);
00080 }
00081 
00082 void cklf_gpio_wakeup(uint16_t wcon1, uint16_t wcon0)
00083 {
00084   cklf_regxc_write(WWCON1, wcon1);
00085   cklf_regxc_write(WWCON0, wcon0);
00086 }

Generated on Fri Apr 20 2012 14:11:45 for nRFGo SDK by  doxygen 1.7.2