-
Notifications
You must be signed in to change notification settings - Fork 1
/
lpccmd.c
34 lines (32 loc) · 829 Bytes
/
lpccmd.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
#include "lpc.h"
int main(int argc, char* argv[])
{
uint8_t addr;
uint8_t val;
if (argc < 2)
{
// No arguments.
printf("To read LPC: %s [addr]\n", argv[0]);
printf("To write LPC: %s [addr] [value]\n", argv[0]);
printf("NOTE: Specify all input arguments in hexadecimal.\n");
return 1;
}
else if (argc < 3)
{
// One argument.
// Read from LPC.
addr = (uint8_t)strtoul(argv[1], NULL, 16);
val = LPC_Read(addr);
printf("%02X\n", val);
return 0;
}
else
{
// More than one argument. The first two will be used.
// Write to LPC.
addr = (uint8_t)strtoul(argv[1], NULL, 16);
val = (uint8_t)strtoul(argv[2], NULL, 16);
LPC_Write(addr, val);
return 0;
}
}