summaryrefslogtreecommitdiffstats
path: root/msf.c
blob: 47e5188be9a2b42fac19c553e563d24fdccf0365 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "project.h"




static void msf_set_ident (uint8_t *i)
{
  i[0] = 0;
  i[1] = 1;
  i[2] = 1;
  i[3] = 1;
  i[4] = 1;
  i[5] = 1;
  i[6] = 1;
  i[7] = 0;
}





void msf_make_bits (UTC u, uint8_t *a, uint8_t *b)
{

  bzero (a, 60);
  bzero (b, 60);


  a[0] = 1;
  b[0] = 1;


  bcd_set (a, 17, 24, u.year % 100);
  bcd_set (a, 25, 29, u.month);
  bcd_set (a, 30, 35, u.mday);
  bcd_set (a, 36, 38, u.wday - 1);
  bcd_set (a, 39, 44, u.hour);
  bcd_set (a, 45, 51, u.minute);

  msf_set_ident (&a[52]);


  b[53] = 0; /* about to be BST */

  b[54] = set_parity (a, 17, 24);
  b[55] = set_parity (a, 25, 35);
  b[56] = set_parity (a, 36, 38);
  b[57] = set_parity (a, 39, 51);

  b[58] = 0; /*BST vs GMT */

}



void msf_make_stream (uint8_t *v, uint8_t *a, uint8_t *b)
{
  unsigned s;
  bzero (v, 600);

  for (s = 0; s < 60; ++s, v += 10, ++a, ++b) {

    if (!s)
      memset (v, 1, 5);


    v[0] = 1;
    v[1] = *a;
    v[2] = *b;
  }
}