FreeCalypso > hg > freecalypso-hwlab
annotate fteeprom/fteeprom-erase.c @ 116:c8685074c845
fc-simtool command parser: fancier handling of quoted strings
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 28 Jan 2021 03:14:32 +0000 |
parents | 4d77c191c034 |
children |
rev | line source |
---|---|
37
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <sys/types.h> |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <stdio.h> |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <stdlib.h> |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 #include <unistd.h> |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <ftdi.h> |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 main(argc, argv) |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 char **argv; |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 { |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 struct ftdi_context ftdi; |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 if (argc != 2) { |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 fprintf(stderr, "usage: %s device-selector\n"); |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 exit(1); |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 } |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 ftdi_init(&ftdi); |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 if (ftdi_usb_open_string(&ftdi, argv[1]) < 0) { |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 fprintf(stderr, "FTDI USB open failed: %s\n", ftdi.error_str); |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 exit(1); |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 } |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 if (ftdi_erase_eeprom(&ftdi) < 0) { |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 fprintf(stderr, "EEPROM write error: %s\n", ftdi.error_str); |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 exit(1); |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ftdi_usb_close(&ftdi); |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 exit(0); |
4d77c191c034
fteeprom-erase program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |