Cosmetics: adjust for 8-column hard tabs, remove UTF-8 dashes.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@886 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
b2826052fc
commit
2110c28be5
|
@ -1,3 +1,8 @@
|
||||||
|
2010-01-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||||
|
|
||||||
|
* buspirate.c: Cosmetics: remove UTF-8 dashes, adjust for 8-column
|
||||||
|
hard tabs.
|
||||||
|
|
||||||
2010-01-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
2010-01-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||||
|
|
||||||
* buspirate.c: add $ Id $ line.
|
* buspirate.c: add $ Id $ line.
|
||||||
|
|
64
buspirate.c
64
buspirate.c
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
/* ====== Private data structure ====== */
|
/* ====== Private data structure ====== */
|
||||||
/* CS and AUX pin bitmasks in
|
/* CS and AUX pin bitmasks in
|
||||||
* 0100wxyz – Configure peripherals command */
|
* 0100wxyz - Configure peripherals command */
|
||||||
#define BP_RESET_CS 0x01
|
#define BP_RESET_CS 0x01
|
||||||
#define BP_RESET_AUX 0x02
|
#define BP_RESET_AUX 0x02
|
||||||
#define BP_RESET_AUX2 0x04
|
#define BP_RESET_AUX2 0x04
|
||||||
|
@ -62,12 +62,12 @@
|
||||||
struct pdata
|
struct pdata
|
||||||
{
|
{
|
||||||
char hw_version[10];
|
char hw_version[10];
|
||||||
int fw_version; /* = 100*fw_major + fw_minor */
|
int fw_version; /* = 100*fw_major + fw_minor */
|
||||||
int binmode_version;
|
int binmode_version;
|
||||||
int bin_spi_version;
|
int bin_spi_version;
|
||||||
int current_peripherals_config;
|
int current_peripherals_config;
|
||||||
int spifreq; /* 0..7 - see buspirate manual for what freq each value means */
|
int spifreq; /* 0..7 - see buspirate manual for what freq each value means */
|
||||||
int reset; /* See BP_RESET_* above */
|
int reset; /* See BP_RESET_* above */
|
||||||
};
|
};
|
||||||
#define PDATA(pgm) ((struct pdata *)(pgm->cookie))
|
#define PDATA(pgm) ((struct pdata *)(pgm->cookie))
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ static inline int
|
||||||
buspirate_has_aux2(struct programmer_t *pgm)
|
buspirate_has_aux2(struct programmer_t *pgm)
|
||||||
{
|
{
|
||||||
return ((PDATA(pgm)->fw_version >= 300) &&
|
return ((PDATA(pgm)->fw_version >= 300) &&
|
||||||
strcmp(PDATA(pgm)->hw_version, "v1a") == 0);
|
strcmp(PDATA(pgm)->hw_version, "v1a") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
@ -138,8 +138,8 @@ static int buspirate_recv_bin(struct programmer_t *pgm, char *buf, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_expect_bin(struct programmer_t *pgm,
|
static int buspirate_expect_bin(struct programmer_t *pgm,
|
||||||
char *send_data, size_t send_len,
|
char *send_data, size_t send_len,
|
||||||
char *expect_data, size_t expect_len)
|
char *expect_data, size_t expect_len)
|
||||||
{
|
{
|
||||||
char *recv_buf = alloca(expect_len);
|
char *recv_buf = alloca(expect_len);
|
||||||
if (!pgm->flag & BP_FLAG_IN_BINMODE) {
|
if (!pgm->flag & BP_FLAG_IN_BINMODE) {
|
||||||
|
@ -155,7 +155,7 @@ static int buspirate_expect_bin(struct programmer_t *pgm,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_expect_bin_byte(struct programmer_t *pgm,
|
static int buspirate_expect_bin_byte(struct programmer_t *pgm,
|
||||||
char send_byte, char expect_byte)
|
char send_byte, char expect_byte)
|
||||||
{
|
{
|
||||||
return buspirate_expect_bin(pgm, &send_byte, 1, &expect_byte, 1);
|
return buspirate_expect_bin(pgm, &send_byte, 1, &expect_byte, 1);
|
||||||
}
|
}
|
||||||
|
@ -208,12 +208,12 @@ static char *buspirate_readline(struct programmer_t *pgm, char *buf, size_t len)
|
||||||
serial_recv_timeout = orig_serial_recv_timeout;
|
serial_recv_timeout = orig_serial_recv_timeout;
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, "%s: buspirate_readline(): %s%s",
|
fprintf(stderr, "%s: buspirate_readline(): %s%s",
|
||||||
progname, buf,
|
progname, buf,
|
||||||
buf[strlen(buf) - 1] == '\n' ? "" : "\n");
|
buf[strlen(buf) - 1] == '\n' ? "" : "\n");
|
||||||
if (! buf[0]) {
|
if (! buf[0]) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: buspirate_readline(): programmer is not responding\n",
|
"%s: buspirate_readline(): programmer is not responding\n",
|
||||||
progname);
|
progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -248,7 +248,7 @@ static int buspirate_is_prompt(char *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_expect(struct programmer_t *pgm, char *send,
|
static int buspirate_expect(struct programmer_t *pgm, char *send,
|
||||||
char *expect, int wait_for_prompt)
|
char *expect, int wait_for_prompt)
|
||||||
{
|
{
|
||||||
int got_it = 0;
|
int got_it = 0;
|
||||||
size_t expect_len = strlen(expect);
|
size_t expect_len = strlen(expect);
|
||||||
|
@ -427,7 +427,7 @@ static int buspirate_start_spi_mode_bin(struct programmer_t *pgm)
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("BusPirate SPI version: %d\n", PDATA(pgm)->bin_spi_version);
|
printf("BusPirate SPI version: %d\n", PDATA(pgm)->bin_spi_version);
|
||||||
|
|
||||||
/* 0b0100wxyz – Configure peripherals w=power, x=pull-ups/aux2, y=AUX, z=CS
|
/* 0b0100wxyz - Configure peripherals w=power, x=pull-ups/aux2, y=AUX, z=CS
|
||||||
* we want power (0x48) and all reset pins high. */
|
* we want power (0x48) and all reset pins high. */
|
||||||
PDATA(pgm)->current_peripherals_config = 0x48;
|
PDATA(pgm)->current_peripherals_config = 0x48;
|
||||||
PDATA(pgm)->current_peripherals_config |= BP_RESET_CS;
|
PDATA(pgm)->current_peripherals_config |= BP_RESET_CS;
|
||||||
|
@ -443,7 +443,7 @@ static int buspirate_start_spi_mode_bin(struct programmer_t *pgm)
|
||||||
* use 30kHz = 0x60 */
|
* use 30kHz = 0x60 */
|
||||||
buspirate_expect_bin_byte(pgm, 0x60 | PDATA(pgm)->spifreq, 0x01);
|
buspirate_expect_bin_byte(pgm, 0x60 | PDATA(pgm)->spifreq, 0x01);
|
||||||
|
|
||||||
/* 1000wxyz – SPI config, w=HiZ(0)/3.3v(1), x=CLK idle, y=CLK edge, z=SMP sample
|
/* 1000wxyz - SPI config, w=HiZ(0)/3.3v(1), x=CLK idle, y=CLK edge, z=SMP sample
|
||||||
* we want: 3.3V(1), idle low(0), data change on trailing edge (1),
|
* we want: 3.3V(1), idle low(0), data change on trailing edge (1),
|
||||||
* sample in the middle of the pulse (0)
|
* sample in the middle of the pulse (0)
|
||||||
* => 0b10001010 = 0x8a */
|
* => 0b10001010 = 0x8a */
|
||||||
|
@ -578,7 +578,7 @@ static void buspirate_powerup(struct programmer_t *pgm)
|
||||||
static void buspirate_powerdown(struct programmer_t *pgm)
|
static void buspirate_powerdown(struct programmer_t *pgm)
|
||||||
{
|
{
|
||||||
if (pgm->flag & BP_FLAG_IN_BINMODE) {
|
if (pgm->flag & BP_FLAG_IN_BINMODE) {
|
||||||
/* 0b0100wxyz – Configure peripherals w=power, x=pull-ups, y=AUX, z=CS
|
/* 0b0100wxyz - Configure peripherals w=power, x=pull-ups, y=AUX, z=CS
|
||||||
* we want everything off -- 0b01000000 = 0x40 */
|
* we want everything off -- 0b01000000 = 0x40 */
|
||||||
if (buspirate_expect_bin_byte(pgm, 0x40, 0x01))
|
if (buspirate_expect_bin_byte(pgm, 0x40, 0x01))
|
||||||
return;
|
return;
|
||||||
|
@ -590,10 +590,10 @@ static void buspirate_powerdown(struct programmer_t *pgm)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_cmd_bin(struct programmer_t *pgm,
|
static int buspirate_cmd_bin(struct programmer_t *pgm,
|
||||||
unsigned char cmd[4],
|
unsigned char cmd[4],
|
||||||
unsigned char res[4])
|
unsigned char res[4])
|
||||||
{
|
{
|
||||||
/* 0001xxxx – Bulk SPI transfer, send/read 1-16 bytes (0=1byte!)
|
/* 0001xxxx - Bulk SPI transfer, send/read 1-16 bytes (0=1byte!)
|
||||||
* we are sending 4 bytes -> 0x13 */
|
* we are sending 4 bytes -> 0x13 */
|
||||||
if (!buspirate_expect_bin_byte(pgm, 0x13, 0x01))
|
if (!buspirate_expect_bin_byte(pgm, 0x13, 0x01))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -605,15 +605,15 @@ static int buspirate_cmd_bin(struct programmer_t *pgm,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_cmd_ascii(struct programmer_t *pgm,
|
static int buspirate_cmd_ascii(struct programmer_t *pgm,
|
||||||
unsigned char cmd[4],
|
unsigned char cmd[4],
|
||||||
unsigned char res[4])
|
unsigned char res[4])
|
||||||
{
|
{
|
||||||
char buf[25];
|
char buf[25];
|
||||||
char *rcvd;
|
char *rcvd;
|
||||||
int spi_write, spi_read, i = 0;
|
int spi_write, spi_read, i = 0;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "0x%02x 0x%02x 0x%02x 0x%02x\n",
|
snprintf(buf, sizeof(buf), "0x%02x 0x%02x 0x%02x 0x%02x\n",
|
||||||
cmd[0], cmd[1], cmd[2], cmd[3]);
|
cmd[0], cmd[1], cmd[2], cmd[3]);
|
||||||
buspirate_send(pgm, buf);
|
buspirate_send(pgm, buf);
|
||||||
while (i < 4) {
|
while (i < 4) {
|
||||||
rcvd = buspirate_readline(pgm, NULL, 0);
|
rcvd = buspirate_readline(pgm, NULL, 0);
|
||||||
|
@ -638,8 +638,8 @@ static int buspirate_cmd_ascii(struct programmer_t *pgm,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buspirate_cmd(struct programmer_t *pgm,
|
static int buspirate_cmd(struct programmer_t *pgm,
|
||||||
unsigned char cmd[4],
|
unsigned char cmd[4],
|
||||||
unsigned char res[4])
|
unsigned char res[4])
|
||||||
{
|
{
|
||||||
if (pgm->flag & BP_FLAG_IN_BINMODE)
|
if (pgm->flag & BP_FLAG_IN_BINMODE)
|
||||||
return buspirate_cmd_bin(pgm, cmd, res);
|
return buspirate_cmd_bin(pgm, cmd, res);
|
||||||
|
@ -662,8 +662,8 @@ static int buspirate_program_enable(struct programmer_t *pgm, AVRPART * p)
|
||||||
|
|
||||||
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
|
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"program enable instruction not defined for part \"%s\"\n",
|
"program enable instruction not defined for part \"%s\"\n",
|
||||||
p->desc);
|
p->desc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,8 +684,8 @@ static int buspirate_chip_erase(struct programmer_t *pgm, AVRPART * p)
|
||||||
|
|
||||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"chip erase instruction not defined for part \"%s\"\n",
|
"chip erase instruction not defined for part \"%s\"\n",
|
||||||
p->desc);
|
p->desc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,7 +731,7 @@ void buspirate_initpgm(struct programmer_t *pgm)
|
||||||
/* Allocate private data */
|
/* Allocate private data */
|
||||||
if ((pgm->cookie = calloc(1, sizeof(struct pdata))) == 0) {
|
if ((pgm->cookie = calloc(1, sizeof(struct pdata))) == 0) {
|
||||||
fprintf(stderr, "%s: buspirate_initpgm(): Out of memory allocating private data\n",
|
fprintf(stderr, "%s: buspirate_initpgm(): Out of memory allocating private data\n",
|
||||||
progname);
|
progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue