UoS³ Flight Computer Firmware
 All Data Structures Files Functions Groups Pages
pn9.c
1 
9 #include "../firmware.h"
10 
11 void Util_pn9(uint8_t *buffer, uint32_t preroll, uint32_t length)
12 {
13  /* Uses CC1120 PN9 Sequence */
14  uint16_t state;
15  uint16_t j;
16 
17  if(length == 0)
18  return;
19 
20  state = 0x01FF;
21 
22  if(preroll == 0)
23  {
24  *buffer++ ^= 0xFF;
25  length--;
26  }
27  else
28  {
29  while(preroll--)
30  {
31  for(j=0; j<8; j++)
32  {
33  state = (uint16_t)((state >> 1) + ((((state & 0x01) ^ (state >> 5)) & 0x01) << 8));
34  }
35  }
36  *buffer++ ^= (uint8_t)state;
37  length--;
38  }
39 
40  while(length--)
41  {
42  for(j=0; j<8; j++)
43  {
44  state = (uint16_t)((state >> 1) + ((((state & 0x01) ^ (state >> 5)) & 0x01) << 8));
45  }
46 
47  *buffer++ ^= (uint8_t)state;
48  }
49 }
50 
void Util_pn9(uint8_t *buffer, uint32_t preroll, uint32_t length)
Definition: pn9.c:11