Style fixes.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@77 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
c4c6988306
commit
fa67482972
56
avr.c
56
avr.c
|
@ -89,7 +89,7 @@ struct avrpart parts[] = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int avr_list_parts ( FILE * f, char * prefix )
|
int avr_list_parts(FILE * f, char * prefix)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ int avr_list_parts ( FILE * f, char * prefix )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct avrpart * avr_find_part ( char * p )
|
struct avrpart * avr_find_part(char * p)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ struct avrpart * avr_find_part ( char * p )
|
||||||
/*
|
/*
|
||||||
* transmit and receive a bit of data to/from the AVR device
|
* transmit and receive a bit of data to/from the AVR device
|
||||||
*/
|
*/
|
||||||
int avr_txrx_bit ( int fd, int bit )
|
int avr_txrx_bit(int fd, int bit)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ int avr_txrx_bit ( int fd, int bit )
|
||||||
/*
|
/*
|
||||||
* transmit and receive a byte of data to/from the AVR device
|
* transmit and receive a byte of data to/from the AVR device
|
||||||
*/
|
*/
|
||||||
unsigned char avr_txrx ( int fd, unsigned char byte )
|
unsigned char avr_txrx(int fd, unsigned char byte)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned char r, b, rbyte;
|
unsigned char r, b, rbyte;
|
||||||
|
@ -153,7 +153,7 @@ unsigned char avr_txrx ( int fd, unsigned char byte )
|
||||||
rbyte = 0;
|
rbyte = 0;
|
||||||
for (i=0; i<8; i++) {
|
for (i=0; i<8; i++) {
|
||||||
b = (byte >> (7-i)) & 0x01;
|
b = (byte >> (7-i)) & 0x01;
|
||||||
r = avr_txrx_bit ( fd, b );
|
r = avr_txrx_bit(fd, b);
|
||||||
rbyte = rbyte | (r << (7-i));
|
rbyte = rbyte | (r << (7-i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ unsigned char avr_txrx ( int fd, unsigned char byte )
|
||||||
* transmit an AVR device command and return the results; 'cmd' and
|
* transmit an AVR device command and return the results; 'cmd' and
|
||||||
* 'res' must point to at least a 4 byte data buffer
|
* 'res' must point to at least a 4 byte data buffer
|
||||||
*/
|
*/
|
||||||
int avr_cmd ( int fd, unsigned char cmd[4], unsigned char res[4] )
|
int avr_cmd(int fd, unsigned char cmd[4], unsigned char res[4])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -180,8 +180,8 @@ int avr_cmd ( int fd, unsigned char cmd[4], unsigned char res[4] )
|
||||||
/*
|
/*
|
||||||
* read a byte of data from the indicated memory region
|
* read a byte of data from the indicated memory region
|
||||||
*/
|
*/
|
||||||
unsigned char avr_read_byte ( int fd, struct avrpart * p,
|
unsigned char avr_read_byte(int fd, struct avrpart * p,
|
||||||
int memtype, unsigned short addr )
|
int memtype, unsigned short addr)
|
||||||
{
|
{
|
||||||
unsigned short offset;
|
unsigned short offset;
|
||||||
unsigned char cmd[4];
|
unsigned char cmd[4];
|
||||||
|
@ -218,7 +218,7 @@ unsigned char avr_read_byte ( int fd, struct avrpart * p,
|
||||||
*
|
*
|
||||||
* Return the number of bytes read, or -1 if an error occurs.
|
* Return the number of bytes read, or -1 if an error occurs.
|
||||||
*/
|
*/
|
||||||
int avr_read ( int fd, struct avrpart * p, int memtype )
|
int avr_read(int fd, struct avrpart * p, int memtype)
|
||||||
{
|
{
|
||||||
unsigned char rbyte;
|
unsigned char rbyte;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
|
@ -230,11 +230,11 @@ int avr_read ( int fd, struct avrpart * p, int memtype )
|
||||||
|
|
||||||
for (i=0; i<size; i++) {
|
for (i=0; i<size; i++) {
|
||||||
rbyte = avr_read_byte(fd, p, memtype, i);
|
rbyte = avr_read_byte(fd, p, memtype, i);
|
||||||
fprintf ( stderr, " \r%4u 0x%02x", i, rbyte );
|
fprintf(stderr, " \r%4u 0x%02x", i, rbyte);
|
||||||
buf[i] = rbyte;
|
buf[i] = rbyte;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf ( stderr, "\n" );
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -243,8 +243,8 @@ int avr_read ( int fd, struct avrpart * p, int memtype )
|
||||||
/*
|
/*
|
||||||
* write a byte of data to the indicated memory region
|
* write a byte of data to the indicated memory region
|
||||||
*/
|
*/
|
||||||
int avr_write_byte ( int fd, struct avrpart * p, int memtype,
|
int avr_write_byte(int fd, struct avrpart * p, int memtype,
|
||||||
unsigned short addr, unsigned char data )
|
unsigned short addr, unsigned char data)
|
||||||
{
|
{
|
||||||
unsigned char cmd[4];
|
unsigned char cmd[4];
|
||||||
unsigned char res[4];
|
unsigned char res[4];
|
||||||
|
@ -331,7 +331,7 @@ int avr_write_byte ( int fd, struct avrpart * p, int memtype,
|
||||||
*
|
*
|
||||||
* Return the number of bytes written, or -1 if an error occurs.
|
* Return the number of bytes written, or -1 if an error occurs.
|
||||||
*/
|
*/
|
||||||
int avr_write ( int fd, struct avrpart * p, int memtype, int size )
|
int avr_write(int fd, struct avrpart * p, int memtype, int size)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int wsize;
|
int wsize;
|
||||||
|
@ -360,7 +360,7 @@ int avr_write ( int fd, struct avrpart * p, int memtype, int size )
|
||||||
for (i=0; i<wsize; i++) {
|
for (i=0; i<wsize; i++) {
|
||||||
/* eeprom or low byte of flash */
|
/* eeprom or low byte of flash */
|
||||||
data = buf[i];
|
data = buf[i];
|
||||||
rc = avr_write_byte(fd, p, memtype, i, data );
|
rc = avr_write_byte(fd, p, memtype, i, data);
|
||||||
fprintf(stderr, " \r%4u 0x%02x", i, data);
|
fprintf(stderr, " \r%4u 0x%02x", i, data);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr, " ***failed; ");
|
fprintf(stderr, " ***failed; ");
|
||||||
|
@ -377,7 +377,7 @@ int avr_write ( int fd, struct avrpart * p, int memtype, int size )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf ( stderr, "\n" );
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ int avr_write ( int fd, struct avrpart * p, int memtype, int size )
|
||||||
/*
|
/*
|
||||||
* issue the 'program enable' command to the AVR device
|
* issue the 'program enable' command to the AVR device
|
||||||
*/
|
*/
|
||||||
int avr_program_enable ( int fd )
|
int avr_program_enable(int fd)
|
||||||
{
|
{
|
||||||
unsigned char cmd[4] = {0xac, 0x53, 0x00, 0x00};
|
unsigned char cmd[4] = {0xac, 0x53, 0x00, 0x00};
|
||||||
unsigned char res[4];
|
unsigned char res[4];
|
||||||
|
@ -403,7 +403,7 @@ int avr_program_enable ( int fd )
|
||||||
/*
|
/*
|
||||||
* issue the 'chip erase' command to the AVR device
|
* issue the 'chip erase' command to the AVR device
|
||||||
*/
|
*/
|
||||||
int avr_chip_erase ( int fd, struct avrpart * p )
|
int avr_chip_erase(int fd, struct avrpart * p)
|
||||||
{
|
{
|
||||||
unsigned char data[4] = {0xac, 0x80, 0x00, 0x00};
|
unsigned char data[4] = {0xac, 0x80, 0x00, 0x00};
|
||||||
unsigned char res[4];
|
unsigned char res[4];
|
||||||
|
@ -423,7 +423,7 @@ int avr_chip_erase ( int fd, struct avrpart * p )
|
||||||
/*
|
/*
|
||||||
* read the AVR device's signature bytes
|
* read the AVR device's signature bytes
|
||||||
*/
|
*/
|
||||||
int avr_signature ( int fd, unsigned char sig[4] )
|
int avr_signature(int fd, unsigned char sig[4])
|
||||||
{
|
{
|
||||||
unsigned char cmd[4] = {0x30, 0x00, 0x00, 0x00};
|
unsigned char cmd[4] = {0x30, 0x00, 0x00, 0x00};
|
||||||
unsigned char res[4];
|
unsigned char res[4];
|
||||||
|
@ -442,7 +442,7 @@ int avr_signature ( int fd, unsigned char sig[4] )
|
||||||
/*
|
/*
|
||||||
* apply power to the AVR processor
|
* apply power to the AVR processor
|
||||||
*/
|
*/
|
||||||
void avr_powerup ( int fd )
|
void avr_powerup(int fd)
|
||||||
{
|
{
|
||||||
ppi_set(fd, PPIDATA, PPI_AVR_VCC); /* power up */
|
ppi_set(fd, PPIDATA, PPI_AVR_VCC); /* power up */
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
|
@ -452,7 +452,7 @@ void avr_powerup ( int fd )
|
||||||
/*
|
/*
|
||||||
* remove power from the AVR processor
|
* remove power from the AVR processor
|
||||||
*/
|
*/
|
||||||
void avr_powerdown ( int fd )
|
void avr_powerdown(int fd)
|
||||||
{
|
{
|
||||||
ppi_clr(fd, PPIDATA, PPI_AVR_VCC); /* power down */
|
ppi_clr(fd, PPIDATA, PPI_AVR_VCC); /* power down */
|
||||||
}
|
}
|
||||||
|
@ -461,7 +461,7 @@ void avr_powerdown ( int fd )
|
||||||
/*
|
/*
|
||||||
* initialize the AVR device and prepare it to accept commands
|
* initialize the AVR device and prepare it to accept commands
|
||||||
*/
|
*/
|
||||||
int avr_initialize ( int fd, struct avrpart * p )
|
int avr_initialize(int fd, struct avrpart * p)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int tries;
|
int tries;
|
||||||
|
@ -484,12 +484,12 @@ int avr_initialize ( int fd, struct avrpart * p )
|
||||||
* of sync.
|
* of sync.
|
||||||
*/
|
*/
|
||||||
if (strcmp(p->partdesc, "AT90S1200")==0) {
|
if (strcmp(p->partdesc, "AT90S1200")==0) {
|
||||||
avr_program_enable ( fd );
|
avr_program_enable(fd);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tries = 0;
|
tries = 0;
|
||||||
do {
|
do {
|
||||||
rc = avr_program_enable ( fd );
|
rc = avr_program_enable(fd);
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
break;
|
break;
|
||||||
ppi_pulsepin(fd, pinno[PIN_AVR_SCK]);
|
ppi_pulsepin(fd, pinno[PIN_AVR_SCK]);
|
||||||
|
@ -500,7 +500,7 @@ int avr_initialize ( int fd, struct avrpart * p )
|
||||||
* can't sync with the device, maybe it's not attached?
|
* can't sync with the device, maybe it's not attached?
|
||||||
*/
|
*/
|
||||||
if (tries == 32) {
|
if (tries == 32) {
|
||||||
fprintf ( stderr, "%s: AVR device not responding\n", progname );
|
fprintf(stderr, "%s: AVR device not responding\n", progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -510,7 +510,7 @@ int avr_initialize ( int fd, struct avrpart * p )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char * avr_memtstr ( int memtype )
|
char * avr_memtstr(int memtype)
|
||||||
{
|
{
|
||||||
switch (memtype) {
|
switch (memtype) {
|
||||||
case AVR_M_EEPROM : return "eeprom"; break;
|
case AVR_M_EEPROM : return "eeprom"; break;
|
||||||
|
@ -520,7 +520,7 @@ char * avr_memtstr ( int memtype )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int avr_initmem ( struct avrpart * p )
|
int avr_initmem(struct avrpart * p)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ void avr_mem_display(char * prefix, FILE * f, AVRMEM * m, int type)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void avr_display ( FILE * f, struct avrpart * p, char * prefix )
|
void avr_display(FILE * f, struct avrpart * p, char * prefix)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char * buf;
|
char * buf;
|
||||||
|
|
40
avr.h
40
avr.h
|
@ -99,46 +99,46 @@ extern struct avrpart parts[];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int avr_list_parts ( FILE * f, char * prefix );
|
int avr_list_parts(FILE * f, char * prefix);
|
||||||
|
|
||||||
struct avrpart * avr_find_part ( char * p );
|
struct avrpart * avr_find_part(char * p);
|
||||||
|
|
||||||
int avr_txrx_bit ( int fd, int bit );
|
int avr_txrx_bit(int fd, int bit);
|
||||||
|
|
||||||
unsigned char avr_txrx ( int fd, unsigned char byte );
|
unsigned char avr_txrx(int fd, unsigned char byte);
|
||||||
|
|
||||||
int avr_cmd ( int fd, unsigned char cmd[4], unsigned char res[4] );
|
int avr_cmd(int fd, unsigned char cmd[4], unsigned char res[4]);
|
||||||
|
|
||||||
unsigned char avr_read_byte ( int fd, struct avrpart * p,
|
unsigned char avr_read_byte(int fd, struct avrpart * p,
|
||||||
int memtype, unsigned short addr );
|
int memtype, unsigned short addr);
|
||||||
|
|
||||||
int avr_read ( int fd, struct avrpart * p, int memtype );
|
int avr_read(int fd, struct avrpart * p, int memtype);
|
||||||
|
|
||||||
int avr_write_byte ( int fd, struct avrpart * p, int memtype,
|
int avr_write_byte(int fd, struct avrpart * p, int memtype,
|
||||||
unsigned short addr, unsigned char data );
|
unsigned short addr, unsigned char data);
|
||||||
|
|
||||||
int avr_write ( int fd, struct avrpart * p, int memtype, int size );
|
int avr_write(int fd, struct avrpart * p, int memtype, int size);
|
||||||
|
|
||||||
int avr_program_enable ( int fd );
|
int avr_program_enable(int fd);
|
||||||
|
|
||||||
int avr_chip_erase ( int fd, struct avrpart * p );
|
int avr_chip_erase(int fd, struct avrpart * p);
|
||||||
|
|
||||||
int avr_signature ( int fd, unsigned char sig[4] );
|
int avr_signature(int fd, unsigned char sig[4]);
|
||||||
|
|
||||||
void avr_powerup ( int fd );
|
void avr_powerup(int fd);
|
||||||
|
|
||||||
void avr_powerdown ( int fd );
|
void avr_powerdown(int fd);
|
||||||
|
|
||||||
int avr_initialize ( int fd, struct avrpart * p );
|
int avr_initialize(int fd, struct avrpart * p);
|
||||||
|
|
||||||
char * avr_memtstr ( int memtype );
|
char * avr_memtstr(int memtype);
|
||||||
|
|
||||||
int avr_initmem ( struct avrpart * p );
|
int avr_initmem(struct avrpart * p);
|
||||||
|
|
||||||
int avr_verify(struct avrpart * p, struct avrpart * v, int memtype,
|
int avr_verify(struct avrpart * p, struct avrpart * v, int memtype,
|
||||||
int size);
|
int size);
|
||||||
|
|
||||||
void avr_display ( FILE * f, struct avrpart * p, char * prefix );
|
void avr_display(FILE * f, struct avrpart * p, char * prefix);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
70
fileio.c
70
fileio.c
|
@ -59,27 +59,27 @@ extern char progbuf[];
|
||||||
|
|
||||||
char * fileio_version = "$Id$";
|
char * fileio_version = "$Id$";
|
||||||
|
|
||||||
int b2ihex ( unsigned char * inbuf, int bufsize,
|
int b2ihex(unsigned char * inbuf, int bufsize,
|
||||||
int recsize, int startaddr,
|
int recsize, int startaddr,
|
||||||
char * outfile, FILE * outf );
|
char * outfile, FILE * outf);
|
||||||
|
|
||||||
int ihex2b ( char * infile, FILE * inf,
|
int ihex2b(char * infile, FILE * inf,
|
||||||
unsigned char * outbuf, int bufsize );
|
unsigned char * outbuf, int bufsize);
|
||||||
|
|
||||||
int fileio_rbin ( struct fioparms * fio,
|
int fileio_rbin(struct fioparms * fio,
|
||||||
char * filename, FILE * f, unsigned char * buf, int size );
|
char * filename, FILE * f, unsigned char * buf, int size);
|
||||||
|
|
||||||
int fileio_ihex ( struct fioparms * fio,
|
int fileio_ihex(struct fioparms * fio,
|
||||||
char * filename, FILE * f, unsigned char * buf, int size );
|
char * filename, FILE * f, unsigned char * buf, int size);
|
||||||
|
|
||||||
int fileio_srec ( struct fioparms * fio,
|
int fileio_srec(struct fioparms * fio,
|
||||||
char * filename, FILE * f, unsigned char * buf, int size );
|
char * filename, FILE * f, unsigned char * buf, int size);
|
||||||
|
|
||||||
int fmt_autodetect ( char * fname );
|
int fmt_autodetect(char * fname);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char * fmtstr ( FILEFMT format )
|
char * fmtstr(FILEFMT format)
|
||||||
{
|
{
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case FMT_AUTO : return "auto-detect"; break;
|
case FMT_AUTO : return "auto-detect"; break;
|
||||||
|
@ -92,9 +92,9 @@ char * fmtstr ( FILEFMT format )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int b2ihex ( unsigned char * inbuf, int bufsize,
|
int b2ihex(unsigned char * inbuf, int bufsize,
|
||||||
int recsize, int startaddr,
|
int recsize, int startaddr,
|
||||||
char * outfile, FILE * outf )
|
char * outfile, FILE * outf)
|
||||||
{
|
{
|
||||||
unsigned char * buf;
|
unsigned char * buf;
|
||||||
unsigned int nextaddr;
|
unsigned int nextaddr;
|
||||||
|
@ -103,8 +103,8 @@ int b2ihex ( unsigned char * inbuf, int bufsize,
|
||||||
unsigned char cksum;
|
unsigned char cksum;
|
||||||
|
|
||||||
if (recsize > 255) {
|
if (recsize > 255) {
|
||||||
fprintf ( stderr, "%s: recsize=%d, must be < 256\n",
|
fprintf(stderr, "%s: recsize=%d, must be < 256\n",
|
||||||
progname, recsize );
|
progname, recsize);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,14 +119,14 @@ int b2ihex ( unsigned char * inbuf, int bufsize,
|
||||||
|
|
||||||
if (n) {
|
if (n) {
|
||||||
cksum = 0;
|
cksum = 0;
|
||||||
fprintf ( outf, ":%02X%04X00", n, nextaddr );
|
fprintf(outf, ":%02X%04X00", n, nextaddr);
|
||||||
cksum += n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff);
|
cksum += n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff);
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
fprintf ( outf, "%02X", buf[i] );
|
fprintf(outf, "%02X", buf[i]);
|
||||||
cksum += buf[i];
|
cksum += buf[i];
|
||||||
}
|
}
|
||||||
cksum = -cksum;
|
cksum = -cksum;
|
||||||
fprintf ( outf, "%02X\n", cksum );
|
fprintf(outf, "%02X\n", cksum);
|
||||||
|
|
||||||
nextaddr += n;
|
nextaddr += n;
|
||||||
nbytes += n;
|
nbytes += n;
|
||||||
|
@ -143,16 +143,16 @@ int b2ihex ( unsigned char * inbuf, int bufsize,
|
||||||
cksum = 0;
|
cksum = 0;
|
||||||
n = 0;
|
n = 0;
|
||||||
nextaddr = 0;
|
nextaddr = 0;
|
||||||
fprintf ( outf, ":%02X%04X01", n, nextaddr );
|
fprintf(outf, ":%02X%04X01", n, nextaddr);
|
||||||
cksum += n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff) + 1;
|
cksum += n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff) + 1;
|
||||||
cksum = -cksum;
|
cksum = -cksum;
|
||||||
fprintf ( outf, "%02X\n", cksum );
|
fprintf(outf, "%02X\n", cksum);
|
||||||
|
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ihex_readrec ( struct ihexrec * ihex, char * rec )
|
int ihex_readrec(struct ihexrec * ihex, char * rec)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
char buf[8];
|
char buf[8];
|
||||||
|
@ -195,7 +195,7 @@ int ihex_readrec ( struct ihexrec * ihex, char * rec )
|
||||||
if (e == buf || *e != 0)
|
if (e == buf || *e != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
cksum = ihex->reclen + ((ihex->loadofs >> 8 ) & 0x0ff) +
|
cksum = ihex->reclen + ((ihex->loadofs >> 8) & 0x0ff) +
|
||||||
(ihex->loadofs & 0x0ff) + ihex->rectyp;
|
(ihex->loadofs & 0x0ff) + ihex->rectyp;
|
||||||
|
|
||||||
/* data */
|
/* data */
|
||||||
|
@ -241,8 +241,8 @@ int ihex_readrec ( struct ihexrec * ihex, char * rec )
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
|
|
||||||
int ihex2b ( char * infile, FILE * inf,
|
int ihex2b(char * infile, FILE * inf,
|
||||||
unsigned char * outbuf, int bufsize )
|
unsigned char * outbuf, int bufsize)
|
||||||
{
|
{
|
||||||
char buffer [ MAX_LINE_LEN ];
|
char buffer [ MAX_LINE_LEN ];
|
||||||
unsigned char * buf;
|
unsigned char * buf;
|
||||||
|
@ -337,8 +337,8 @@ int ihex2b ( char * infile, FILE * inf,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int fileio_rbin ( struct fioparms * fio,
|
int fileio_rbin(struct fioparms * fio,
|
||||||
char * filename, FILE * f, unsigned char * buf, int size )
|
char * filename, FILE * f, unsigned char * buf, int size)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -367,8 +367,8 @@ int fileio_rbin ( struct fioparms * fio,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int fileio_ihex ( struct fioparms * fio,
|
int fileio_ihex(struct fioparms * fio,
|
||||||
char * filename, FILE * f, unsigned char * buf, int size )
|
char * filename, FILE * f, unsigned char * buf, int size)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -397,8 +397,8 @@ int fileio_ihex ( struct fioparms * fio,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int fileio_srec ( struct fioparms * fio,
|
int fileio_srec(struct fioparms * fio,
|
||||||
char * filename, FILE * f, unsigned char * buf, int size )
|
char * filename, FILE * f, unsigned char * buf, int size)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: Motorola S-Record %s format not yet supported\n",
|
fprintf(stderr, "%s: Motorola S-Record %s format not yet supported\n",
|
||||||
progname, fio->iodesc);
|
progname, fio->iodesc);
|
||||||
|
@ -406,7 +406,7 @@ int fileio_srec ( struct fioparms * fio,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int fileio_setparms ( int op, struct fioparms * fp )
|
int fileio_setparms(int op, struct fioparms * fp)
|
||||||
{
|
{
|
||||||
fp->op = op;
|
fp->op = op;
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ int fileio_setparms ( int op, struct fioparms * fp )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int fmt_autodetect ( char * fname )
|
int fmt_autodetect(char * fname)
|
||||||
{
|
{
|
||||||
FILE * f;
|
FILE * f;
|
||||||
unsigned char buf[MAX_LINE_LEN];
|
unsigned char buf[MAX_LINE_LEN];
|
||||||
|
@ -501,8 +501,8 @@ int fmt_autodetect ( char * fname )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int fileio ( int op, char * filename, FILEFMT format,
|
int fileio(int op, char * filename, FILEFMT format,
|
||||||
struct avrpart * p, int memtype, int size )
|
struct avrpart * p, int memtype, int size)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
FILE * f;
|
FILE * f;
|
||||||
|
|
8
fileio.h
8
fileio.h
|
@ -52,11 +52,11 @@ enum {
|
||||||
FIO_WRITE
|
FIO_WRITE
|
||||||
};
|
};
|
||||||
|
|
||||||
char * fmtstr ( FILEFMT format );
|
char * fmtstr(FILEFMT format);
|
||||||
|
|
||||||
int fileio_setparms ( int op, struct fioparms * fp );
|
int fileio_setparms(int op, struct fioparms * fp);
|
||||||
|
|
||||||
int fileio ( int op, char * filename, FILEFMT format,
|
int fileio(int op, char * filename, FILEFMT format,
|
||||||
struct avrpart * p, int memtype, int size );
|
struct avrpart * p, int memtype, int size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
44
main.c
44
main.c
|
@ -124,7 +124,7 @@ unsigned int pinno[N_PINS];
|
||||||
/*
|
/*
|
||||||
* usage message
|
* usage message
|
||||||
*/
|
*/
|
||||||
void usage ( void )
|
void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Usage: %s -p partno [-e] [-E exitspec[,exitspec]] [-f format] "
|
"Usage: %s -p partno [-e] [-E exitspec[,exitspec]] [-f format] "
|
||||||
|
@ -139,7 +139,7 @@ void usage ( void )
|
||||||
/*
|
/*
|
||||||
* parse the -E string
|
* parse the -E string
|
||||||
*/
|
*/
|
||||||
int getexitspecs ( char *s, int *set, int *clr )
|
int getexitspecs(char *s, int *set, int *clr)
|
||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ int getexitspecs ( char *s, int *set, int *clr )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int parse_cvsid ( char * cvsid, char * name, char * rev, char * datetime )
|
int parse_cvsid(char * cvsid, char * name, char * rev, char * datetime)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ int parse_cvsid ( char * cvsid, char * name, char * rev, char * datetime )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int print_module_versions ( FILE * outf, char * timestamp )
|
int print_module_versions(FILE * outf, char * timestamp)
|
||||||
{
|
{
|
||||||
char name[64], rev[16], datetime[64];
|
char name[64], rev[16], datetime[64];
|
||||||
int y, m, d, h, min, s;
|
int y, m, d, h, min, s;
|
||||||
|
@ -664,7 +664,7 @@ void verify_pin_assigned(int pin, char * desc)
|
||||||
/*
|
/*
|
||||||
* main routine
|
* main routine
|
||||||
*/
|
*/
|
||||||
int main ( int argc, char * argv [] )
|
int main(int argc, char * argv [])
|
||||||
{
|
{
|
||||||
int fd; /* file descriptor for parallel port */
|
int fd; /* file descriptor for parallel port */
|
||||||
int rc; /* general return code checking */
|
int rc; /* general return code checking */
|
||||||
|
@ -824,7 +824,7 @@ int main ( int argc, char * argv [] )
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: AVR Part \"%s\" not found. Valid parts are:\n\n",
|
"%s: AVR Part \"%s\" not found. Valid parts are:\n\n",
|
||||||
progname, optarg );
|
progname, optarg);
|
||||||
avr_list_parts(stderr," ");
|
avr_list_parts(stderr," ");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -925,7 +925,7 @@ int main ( int argc, char * argv [] )
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: No AVR part has been specified, use \"-p Part\"\n\n"
|
"%s: No AVR part has been specified, use \"-p Part\"\n\n"
|
||||||
" Valid Parts are:\n\n",
|
" Valid Parts are:\n\n",
|
||||||
progname );
|
progname);
|
||||||
avr_list_parts(stderr, " ");
|
avr_list_parts(stderr, " ");
|
||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -981,10 +981,10 @@ int main ( int argc, char * argv [] )
|
||||||
/*
|
/*
|
||||||
* open the parallel port
|
* open the parallel port
|
||||||
*/
|
*/
|
||||||
fd = open ( parallel, O_RDWR );
|
fd = open(parallel, O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf ( stderr, "%s: can't open device \"%s\": %s\n\n",
|
fprintf(stderr, "%s: can't open device \"%s\": %s\n\n",
|
||||||
progname, parallel, strerror(errno) );
|
progname, parallel, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,7 +996,7 @@ int main ( int argc, char * argv [] )
|
||||||
|
|
||||||
ppidata = ppi_getall(fd, PPIDATA);
|
ppidata = ppi_getall(fd, PPIDATA);
|
||||||
if (ppidata < 0) {
|
if (ppidata < 0) {
|
||||||
fprintf ( stderr, "%s: error reading status of ppi data port\n", progname);
|
fprintf(stderr, "%s: error reading status of ppi data port\n", progname);
|
||||||
exitrc = 1;
|
exitrc = 1;
|
||||||
ppidata = 0; /* clear all bits at exit */
|
ppidata = 0; /* clear all bits at exit */
|
||||||
goto main_exit;
|
goto main_exit;
|
||||||
|
@ -1023,7 +1023,7 @@ int main ( int argc, char * argv [] )
|
||||||
*/
|
*/
|
||||||
rc = avr_initialize(fd,p);
|
rc = avr_initialize(fd,p);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf ( stderr, "%s: initialization failed, rc=%d\n", progname, rc );
|
fprintf(stderr, "%s: initialization failed, rc=%d\n", progname, rc);
|
||||||
exitrc = 1;
|
exitrc = 1;
|
||||||
goto main_exit;
|
goto main_exit;
|
||||||
}
|
}
|
||||||
|
@ -1031,9 +1031,9 @@ int main ( int argc, char * argv [] )
|
||||||
/* indicate ready */
|
/* indicate ready */
|
||||||
LED_ON(fd, pinno[PIN_LED_RDY]);
|
LED_ON(fd, pinno[PIN_LED_RDY]);
|
||||||
|
|
||||||
fprintf ( stderr,
|
fprintf(stderr,
|
||||||
"%s: AVR device initialized and ready to accept instructions\n",
|
"%s: AVR device initialized and ready to accept instructions\n",
|
||||||
progname );
|
progname);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Let's read the signature bytes to make sure there is at least a
|
* Let's read the signature bytes to make sure there is at least a
|
||||||
|
@ -1055,7 +1055,7 @@ int main ( int argc, char * argv [] )
|
||||||
fprintf(stderr, "%sDouble check connections and try again, "
|
fprintf(stderr, "%sDouble check connections and try again, "
|
||||||
"or use -F to override\n"
|
"or use -F to override\n"
|
||||||
"%sthis check.\n\n",
|
"%sthis check.\n\n",
|
||||||
progbuf, progbuf );
|
progbuf, progbuf);
|
||||||
exitrc = 1;
|
exitrc = 1;
|
||||||
goto main_exit;
|
goto main_exit;
|
||||||
}
|
}
|
||||||
|
@ -1068,9 +1068,9 @@ int main ( int argc, char * argv [] )
|
||||||
* erase the chip's flash and eeprom memories, this is required
|
* erase the chip's flash and eeprom memories, this is required
|
||||||
* before the chip can accept new programming
|
* before the chip can accept new programming
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "%s: erasing chip\n", progname );
|
fprintf(stderr, "%s: erasing chip\n", progname);
|
||||||
avr_chip_erase(fd,p);
|
avr_chip_erase(fd,p);
|
||||||
fprintf(stderr, "%s: done.\n", progname );
|
fprintf(stderr, "%s: done.\n", progname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1101,7 +1101,7 @@ int main ( int argc, char * argv [] )
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "%s: reading %s memory:\n",
|
fprintf(stderr, "%s: reading %s memory:\n",
|
||||||
progname, avr_memtstr(memtype));
|
progname, avr_memtstr(memtype));
|
||||||
rc = avr_read ( fd, p, memtype );
|
rc = avr_read(fd, p, memtype);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf(stderr, "%s: failed to read all of %s memory, rc=%d\n",
|
fprintf(stderr, "%s: failed to read all of %s memory, rc=%d\n",
|
||||||
progname, avr_memtstr(memtype), rc);
|
progname, avr_memtstr(memtype), rc);
|
||||||
|
@ -1142,7 +1142,7 @@ int main ( int argc, char * argv [] )
|
||||||
progname, avr_memtstr(memtype));
|
progname, avr_memtstr(memtype));
|
||||||
|
|
||||||
if (!nowrite) {
|
if (!nowrite) {
|
||||||
rc = avr_write ( fd, p, memtype, size );
|
rc = avr_write(fd, p, memtype, size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/*
|
/*
|
||||||
|
@ -1153,8 +1153,8 @@ int main ( int argc, char * argv [] )
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf ( stderr, "%s: failed to write flash memory, rc=%d\n",
|
fprintf(stderr, "%s: failed to write flash memory, rc=%d\n",
|
||||||
progname, rc );
|
progname, rc);
|
||||||
exitrc = 1;
|
exitrc = 1;
|
||||||
goto main_exit;
|
goto main_exit;
|
||||||
}
|
}
|
||||||
|
@ -1177,7 +1177,7 @@ int main ( int argc, char * argv [] )
|
||||||
progname, avr_memtstr(memtype), inputf);
|
progname, avr_memtstr(memtype), inputf);
|
||||||
fprintf(stderr, "%s: reading on-chip %s data:\n",
|
fprintf(stderr, "%s: reading on-chip %s data:\n",
|
||||||
progname, avr_memtstr(memtype));
|
progname, avr_memtstr(memtype));
|
||||||
rc = avr_read ( fd, v, memtype );
|
rc = avr_read(fd, v, memtype);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf(stderr, "%s: failed to read all of %s memory, rc=%d\n",
|
fprintf(stderr, "%s: failed to read all of %s memory, rc=%d\n",
|
||||||
progname, avr_memtstr(memtype), rc);
|
progname, avr_memtstr(memtype), rc);
|
||||||
|
|
46
ppi.c
46
ppi.c
|
@ -73,7 +73,7 @@ char * ppi_version = "$Id$";
|
||||||
* set 'get' and 'set' appropriately for subsequent passage to ioctl()
|
* set 'get' and 'set' appropriately for subsequent passage to ioctl()
|
||||||
* to get/set the specified PPI registers.
|
* to get/set the specified PPI registers.
|
||||||
*/
|
*/
|
||||||
int ppi_getops ( int reg, unsigned long * get, unsigned long * set )
|
int ppi_getops(int reg, unsigned long * get, unsigned long * set)
|
||||||
{
|
{
|
||||||
switch (reg) {
|
switch (reg) {
|
||||||
case PPIDATA:
|
case PPIDATA:
|
||||||
|
@ -90,7 +90,7 @@ int ppi_getops ( int reg, unsigned long * get, unsigned long * set )
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: avr_set(): invalid register=%d\n",
|
fprintf(stderr, "%s: avr_set(): invalid register=%d\n",
|
||||||
progname, reg );
|
progname, reg);
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -102,13 +102,13 @@ int ppi_getops ( int reg, unsigned long * get, unsigned long * set )
|
||||||
/*
|
/*
|
||||||
* set the indicated bit of the specified register.
|
* set the indicated bit of the specified register.
|
||||||
*/
|
*/
|
||||||
int ppi_set ( int fd, int reg, int bit )
|
int ppi_set(int fd, int reg, int bit)
|
||||||
{
|
{
|
||||||
unsigned char v;
|
unsigned char v;
|
||||||
unsigned long get, set;
|
unsigned long get, set;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ppi_getops ( reg, &get, &set );
|
rc = ppi_getops(reg, &get, &set);
|
||||||
if (rc)
|
if (rc)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -123,13 +123,13 @@ int ppi_set ( int fd, int reg, int bit )
|
||||||
/*
|
/*
|
||||||
* clear the indicated bit of the specified register.
|
* clear the indicated bit of the specified register.
|
||||||
*/
|
*/
|
||||||
int ppi_clr ( int fd, int reg, int bit )
|
int ppi_clr(int fd, int reg, int bit)
|
||||||
{
|
{
|
||||||
unsigned char v;
|
unsigned char v;
|
||||||
unsigned long get, set;
|
unsigned long get, set;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ppi_getops ( reg, &get, &set );
|
rc = ppi_getops(reg, &get, &set);
|
||||||
if (rc)
|
if (rc)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -144,13 +144,13 @@ int ppi_clr ( int fd, int reg, int bit )
|
||||||
/*
|
/*
|
||||||
* get the indicated bit of the specified register.
|
* get the indicated bit of the specified register.
|
||||||
*/
|
*/
|
||||||
int ppi_get ( int fd, int reg, int bit )
|
int ppi_get(int fd, int reg, int bit)
|
||||||
{
|
{
|
||||||
unsigned char v;
|
unsigned char v;
|
||||||
unsigned long get, set;
|
unsigned long get, set;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ppi_getops ( reg, &get, &set );
|
rc = ppi_getops(reg, &get, &set);
|
||||||
if (rc)
|
if (rc)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -163,13 +163,13 @@ int ppi_get ( int fd, int reg, int bit )
|
||||||
/*
|
/*
|
||||||
* toggle the indicated bit of the specified register.
|
* toggle the indicated bit of the specified register.
|
||||||
*/
|
*/
|
||||||
int ppi_toggle ( int fd, int reg, int bit )
|
int ppi_toggle(int fd, int reg, int bit)
|
||||||
{
|
{
|
||||||
unsigned char v;
|
unsigned char v;
|
||||||
unsigned long get, set;
|
unsigned long get, set;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ppi_getops ( reg, &get, &set );
|
rc = ppi_getops(reg, &get, &set);
|
||||||
if (rc)
|
if (rc)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -184,13 +184,13 @@ int ppi_toggle ( int fd, int reg, int bit )
|
||||||
/*
|
/*
|
||||||
* get all bits of the specified register.
|
* get all bits of the specified register.
|
||||||
*/
|
*/
|
||||||
int ppi_getall ( int fd, int reg )
|
int ppi_getall(int fd, int reg)
|
||||||
{
|
{
|
||||||
unsigned char v;
|
unsigned char v;
|
||||||
unsigned long get, set;
|
unsigned long get, set;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ppi_getops ( reg, &get, &set );
|
rc = ppi_getops(reg, &get, &set);
|
||||||
if (rc)
|
if (rc)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -202,13 +202,13 @@ int ppi_getall ( int fd, int reg )
|
||||||
/*
|
/*
|
||||||
* set all bits of the specified register to val.
|
* set all bits of the specified register to val.
|
||||||
*/
|
*/
|
||||||
int ppi_setall ( int fd, int reg, int val )
|
int ppi_setall(int fd, int reg, int val)
|
||||||
{
|
{
|
||||||
unsigned char v;
|
unsigned char v;
|
||||||
unsigned long get, set;
|
unsigned long get, set;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ppi_getops ( reg, &get, &set );
|
rc = ppi_getops(reg, &get, &set);
|
||||||
if (rc)
|
if (rc)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ int ppi_setall ( int fd, int reg, int val )
|
||||||
/*
|
/*
|
||||||
* pulse the indicated bit of the specified register.
|
* pulse the indicated bit of the specified register.
|
||||||
*/
|
*/
|
||||||
int ppi_pulse ( int fd, int reg, int bit )
|
int ppi_pulse(int fd, int reg, int bit)
|
||||||
{
|
{
|
||||||
ppi_toggle(fd, reg, bit);
|
ppi_toggle(fd, reg, bit);
|
||||||
ppi_toggle(fd, reg, bit);
|
ppi_toggle(fd, reg, bit);
|
||||||
|
@ -230,7 +230,7 @@ int ppi_pulse ( int fd, int reg, int bit )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ppi_setpin ( int fd, int pin, int value )
|
int ppi_setpin(int fd, int pin, int value)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (pin < 1 || pin > 17)
|
if (pin < 1 || pin > 17)
|
||||||
|
@ -250,7 +250,7 @@ int ppi_setpin ( int fd, int pin, int value )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ppi_getpin ( int fd, int pin )
|
int ppi_getpin(int fd, int pin)
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ int ppi_getpin ( int fd, int pin )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ppi_pulsepin ( int fd, int pin )
|
int ppi_pulsepin(int fd, int pin)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (pin < 1 || pin > 17)
|
if (pin < 1 || pin > 17)
|
||||||
|
@ -286,7 +286,7 @@ int ppi_pulsepin ( int fd, int pin )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ppi_getpinmask ( int pin )
|
int ppi_getpinmask(int pin)
|
||||||
{
|
{
|
||||||
if (pin < 1 || pin > 17)
|
if (pin < 1 || pin > 17)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -295,7 +295,7 @@ int ppi_getpinmask ( int pin )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ppi_getpinreg ( int pin )
|
int ppi_getpinreg(int pin)
|
||||||
{
|
{
|
||||||
if (pin < 1 || pin > 17)
|
if (pin < 1 || pin > 17)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -310,7 +310,7 @@ int ppi_getpinreg ( int pin )
|
||||||
* function in 'main()' and can use it to determine whether your sense
|
* function in 'main()' and can use it to determine whether your sense
|
||||||
* pin is actually sensing.
|
* pin is actually sensing.
|
||||||
*/
|
*/
|
||||||
int ppi_sense ( int fd )
|
int ppi_sense(int fd)
|
||||||
{
|
{
|
||||||
unsigned int pr;
|
unsigned int pr;
|
||||||
int count;
|
int count;
|
||||||
|
@ -319,10 +319,10 @@ int ppi_sense ( int fd )
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
fprintf ( stderr,
|
fprintf(stderr,
|
||||||
"parallel port data:\n"
|
"parallel port data:\n"
|
||||||
" 111111111\n"
|
" 111111111\n"
|
||||||
"123456789012345678\n" );
|
"123456789012345678\n");
|
||||||
|
|
||||||
buf[17] = 0;
|
buf[17] = 0;
|
||||||
pr = 1;
|
pr = 1;
|
||||||
|
|
28
ppi.h
28
ppi.h
|
@ -41,33 +41,33 @@ enum {
|
||||||
PPISTATUS
|
PPISTATUS
|
||||||
};
|
};
|
||||||
|
|
||||||
int ppi_getops ( int reg, unsigned long * get, unsigned long * set );
|
int ppi_getops (int reg, unsigned long * get, unsigned long * set);
|
||||||
|
|
||||||
int ppi_set ( int fd, int reg, int bit );
|
int ppi_set (int fd, int reg, int bit);
|
||||||
|
|
||||||
int ppi_clr ( int fd, int reg, int bit );
|
int ppi_clr (int fd, int reg, int bit);
|
||||||
|
|
||||||
int ppi_get ( int fd, int reg, int bit );
|
int ppi_get (int fd, int reg, int bit);
|
||||||
|
|
||||||
int ppi_toggle ( int fd, int reg, int bit );
|
int ppi_toggle (int fd, int reg, int bit);
|
||||||
|
|
||||||
int ppi_getall ( int fd, int reg );
|
int ppi_getall (int fd, int reg);
|
||||||
|
|
||||||
int ppi_setall ( int fd, int reg, int val );
|
int ppi_setall (int fd, int reg, int val);
|
||||||
|
|
||||||
int ppi_pulse ( int fd, int reg, int bit );
|
int ppi_pulse (int fd, int reg, int bit);
|
||||||
|
|
||||||
int ppi_setpin ( int fd, int pin, int value );
|
int ppi_setpin (int fd, int pin, int value);
|
||||||
|
|
||||||
int ppi_getpin ( int fd, int pin );
|
int ppi_getpin (int fd, int pin);
|
||||||
|
|
||||||
int ppi_pulsepin ( int fd, int pin );
|
int ppi_pulsepin (int fd, int pin);
|
||||||
|
|
||||||
int ppi_getpinmask ( int pin );
|
int ppi_getpinmask(int pin);
|
||||||
|
|
||||||
int ppi_getpinreg ( int pin );
|
int ppi_getpinreg (int pin);
|
||||||
|
|
||||||
int ppi_sense ( int fd );
|
int ppi_sense (int fd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
36
term.c
36
term.c
|
@ -87,7 +87,7 @@ struct command cmd[] = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int nexttok ( char * buf, char ** tok, char ** next )
|
int nexttok(char * buf, char ** tok, char ** next)
|
||||||
{
|
{
|
||||||
char * q, * n;
|
char * q, * n;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ int nexttok ( char * buf, char ** tok, char ** next )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int hexdump_line ( char * buffer, unsigned char * p, int n, int pad )
|
int hexdump_line(char * buffer, unsigned char * p, int n, int pad)
|
||||||
{
|
{
|
||||||
char * hexdata = "0123456789abcdef";
|
char * hexdata = "0123456789abcdef";
|
||||||
char * b;
|
char * b;
|
||||||
|
@ -148,13 +148,13 @@ int hexdump_line ( char * buffer, unsigned char * p, int n, int pad )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int chardump_line ( char * buffer, unsigned char * p, int n, int pad )
|
int chardump_line(char * buffer, unsigned char * p, int n, int pad)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char b [ 128 ];
|
char b [ 128 ];
|
||||||
|
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
memcpy ( b, p, n );
|
memcpy(b, p, n);
|
||||||
buffer[i] = '.';
|
buffer[i] = '.';
|
||||||
if (isalpha(b[i]) || isdigit(b[i]) || ispunct(b[i]))
|
if (isalpha(b[i]) || isdigit(b[i]) || ispunct(b[i]))
|
||||||
buffer[i] = b[i];
|
buffer[i] = b[i];
|
||||||
|
@ -171,7 +171,7 @@ int chardump_line ( char * buffer, unsigned char * p, int n, int pad )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int hexdump_buf ( FILE * f, int startaddr, char * buf, int len )
|
int hexdump_buf(FILE * f, int startaddr, char * buf, int len)
|
||||||
{
|
{
|
||||||
int addr;
|
int addr;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
@ -198,7 +198,7 @@ int hexdump_buf ( FILE * f, int startaddr, char * buf, int len )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
|
int cmd_dump(int fd, struct avrpart * p, int argc, char * argv[])
|
||||||
{
|
{
|
||||||
char * e;
|
char * e;
|
||||||
int i, l;
|
int i, l;
|
||||||
|
@ -283,7 +283,7 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] )
|
int cmd_write(int fd, struct avrpart * p, int argc, char * argv[])
|
||||||
{
|
{
|
||||||
char * e;
|
char * e;
|
||||||
int i, l;
|
int i, l;
|
||||||
|
@ -376,15 +376,15 @@ int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cmd_erase ( int fd, struct avrpart * p, int argc, char * argv[] )
|
int cmd_erase(int fd, struct avrpart * p, int argc, char * argv[])
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: erasing chip\n", progname );
|
fprintf(stderr, "%s: erasing chip\n", progname);
|
||||||
avr_chip_erase(fd,p);
|
avr_chip_erase(fd,p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cmd_part ( int fd, struct avrpart * p, int argc, char * argv[] )
|
int cmd_part(int fd, struct avrpart * p, int argc, char * argv[])
|
||||||
{
|
{
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
avr_display(stdout, p, "");
|
avr_display(stdout, p, "");
|
||||||
|
@ -394,7 +394,7 @@ int cmd_part ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cmd_sig ( int fd, struct avrpart * p, int argc, char * argv[] )
|
int cmd_sig(int fd, struct avrpart * p, int argc, char * argv[])
|
||||||
{
|
{
|
||||||
unsigned char sig[4]; /* AVR signature bytes */
|
unsigned char sig[4]; /* AVR signature bytes */
|
||||||
int i;
|
int i;
|
||||||
|
@ -409,19 +409,19 @@ int cmd_sig ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cmd_quit ( int fd, struct avrpart * p, int argc, char * argv[] )
|
int cmd_quit(int fd, struct avrpart * p, int argc, char * argv[])
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cmd_help ( int fd, struct avrpart * p, int argc, char * argv[] )
|
int cmd_help(int fd, struct avrpart * p, int argc, char * argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fprintf(stdout, "Valid commands:\n\n" );
|
fprintf(stdout, "Valid commands:\n\n");
|
||||||
for (i=0; i<NCMDS; i++) {
|
for (i=0; i<NCMDS; i++) {
|
||||||
fprintf(stdout, " %-6s : ", cmd[i].name );
|
fprintf(stdout, " %-6s : ", cmd[i].name);
|
||||||
fprintf(stdout, cmd[i].desc, cmd[i].name);
|
fprintf(stdout, cmd[i].desc, cmd[i].name);
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,7 @@ int cmd_help ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int tokenize ( char * s, char *** argv )
|
int tokenize(char * s, char *** argv)
|
||||||
{
|
{
|
||||||
int i, n, l, nargs, offset;
|
int i, n, l, nargs, offset;
|
||||||
int len, slen;
|
int len, slen;
|
||||||
|
@ -508,7 +508,7 @@ int tokenize ( char * s, char *** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int do_cmd ( int fd, struct avrpart * p, int argc, char * argv[] )
|
int do_cmd(int fd, struct avrpart * p, int argc, char * argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int hold;
|
int hold;
|
||||||
|
@ -540,7 +540,7 @@ int do_cmd ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int terminal_mode ( int fd, struct avrpart * p )
|
int terminal_mode(int fd, struct avrpart * p)
|
||||||
{
|
{
|
||||||
char * cmdbuf;
|
char * cmdbuf;
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
Loading…
Reference in New Issue