-
Notifications
You must be signed in to change notification settings - Fork 2
/
sub_nvsettings.c
115 lines (80 loc) · 2.42 KB
/
sub_nvsettings.c
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
////////////////////////////////////////////////////////////////////////////////////////
// The 303 Defcon Badge Project for 2012
//
// This is a hardware and software platform that can be used to make a cool badge
// It includes lightshow, sound DAC, and chiptunes subsystem
// Alcohol sensor, and an RF communciation system.
// The software includes the ability to access functions locally, and remotely given
// sufficient badge privilege, it also has an STD simulator that probabalistically
// causes badges to infect other badges through the beacon subsystem.
////////////////////////////////////////////////////////////////////////////////////////
//
// Please see general credits and information in the main.c file
//
// (c) 2012, Don Kark (Th3D0n)
//
////////////////////////////////////////////////////////////////////////////////////////
#include <system.h>
#include <flash.h>
#include "Badge.h"
unsigned char nvolbuf[64];
#define NVBASE 0x1ac00 // Base of the 64 byte configuration
#define NVBASE2 (NVBASE+64)
#define NVBADGEID_IX 0x00 // 8 bit badge address
#define NVBPERM_IX 0x02 // Badge control permission
#define NVBTYPE_IX 0x01 // Badget Type
#define SOCVEC1_IX 0x03 // Social Vector 1
#pragma DATA NVBASE,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
void nvreadbuf()
{
unsigned char i;
flash_read((unsigned long)NVBASE, nvolbuf);
//if(nvolbuf[1] = 0xff) {
// for(i=1;i<64;i++){
// nvolbuf[i] = 0;
// }
//}
}
void nvsavebuf()
{
flash_erase((unsigned long)NVBASE);
delay_100us(2);
flash_write((unsigned long)NVBASE, nvolbuf);
delay_100us(2);
}
unsigned char nvget_badgeid()
{
return(nvolbuf[NVBADGEID_IX]);
}
void nvset_badgeid(unsigned char num)
{
nvolbuf[NVBADGEID_IX] = num;
}
unsigned char nvget_badgetype()
{
return(nvolbuf[NVBTYPE_IX]);
}
void nvset_badgetype(unsigned char num)
{
nvolbuf[NVBTYPE_IX] = num;
}
unsigned char nvget_badgeperm()
{
return(nvolbuf[NVBPERM_IX]);
}
void nvset_badgeperm(unsigned char num)
{
nvolbuf[NVBPERM_IX] = num;
}
unsigned char nvget_socvec1()
{
return(nvolbuf[SOCVEC1_IX]);
}
void nvset_socvec1(unsigned char num)
{
nvolbuf[SOCVEC1_IX] = num;
}