Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (42 sloc) 1.326 kb
1c8dffc1 »
2012-05-27 add: Basic DCF77 Clock and Weather support
1 #include <dcf77.h>
2 #include <dcf77_keys.h>
3
4 void dcf77_cipher_shift_left(uint8_t round, dcf77_cipherblock_t *buf) {
5 if(!buf) return;
6
7 register uint8_t count;
8 register uint8_t tmp;
9
10 if ((round == 16) || (round == 8) || (round == 7) || (round == 3)) {
11 count = 2;
12 } else {
13 count = 1;
14 }
15
16 while (count--) {
17 tmp = 0;
18
19 if ((buf->data.keyinfo.raw[4] & 0x80) != 0) {
20 tmp = 1;
21 }
22
23 buf->data.keyinfo.raw[4] <<= 1;
24
25 if ((buf->data.keyinfo.raw[3] & 0x80) != 0) {
26 buf->data.keyinfo.raw[4] |= 1;
27 }
28
29 buf->data.keyinfo.raw[3] <<= 1;
30
31 if ((buf->data.keyinfo.raw[2] & 0x80) != 0) {
32 buf->data.keyinfo.raw[3] |= 1;
33 }
34
35 buf->data.keyinfo.raw[2] <<= 1;
36
37 if ((buf->data.keyinfo.raw[1] & 0x80) != 0) {
38 buf->data.keyinfo.raw[2] |= 1;
39 }
40
41 buf->data.keyinfo.raw[1] <<= 1;
42
43 if ((buf->data.keyinfo.raw[0] & 0x80) != 0) {
44 buf->data.keyinfo.raw[1] |= 1;
45 }
46
47 buf->data.keyinfo.raw[0] <<= 1;
48
49 if ((buf->data.keyinfo.raw[2] & 0x10) != 0) {
50 buf->data.keyinfo.raw[0] |= 1;
51 }
52
53 buf->data.keyinfo.raw[2] &= 0xEF;
54
55 if (tmp != 0) {
56 buf->data.keyinfo.raw[2] |= 0x10;
57 }
58 }
59 }
Something went wrong with that request. Please try again.