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

lib/rf_test/pn9.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: 5717 $
00012  */
00013 
00022 #include "pn9.h"
00023 
00024 #define pn9_bit5 0x08
00025 #define pn9_bit9 0x80
00026 
00028 static uint8_t bits_9_to_2;
00030 static bit bit_1;
00031 
00032 void pn9_init(void)
00033 {
00034     bits_9_to_2 = 0xFF;
00035     bit_1 = 1;
00036 }
00037 
00038 uint8_t pn9_get_byte(void)
00039 {
00040     bit feedback;
00041     uint8_t i, out_value;
00042 
00043     out_value = bits_9_to_2;
00044     
00045     for (i = 0; i < 8; i++)
00046     {
00047         // Tap the register
00048         feedback =  
00049             ((((bits_9_to_2 & pn9_bit9)>>4) ^ (bits_9_to_2 & pn9_bit5)) == 0) ? 0 : 1;
00050         // Shift
00051         bits_9_to_2<<=1;
00052         bits_9_to_2 |= (uint8_t) bit_1;
00053         // Enter feedback
00054         bit_1 = feedback;
00055     } 
00056 
00057     return out_value;
00058 }

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