Style fixes.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@77 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
bsd 2001-10-13 03:13:13 +00:00
parent c4c6988306
commit fa67482972
9 changed files with 165 additions and 165 deletions

56
avr.c
View File

@ -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;
@ -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;
@ -119,7 +119,7 @@ struct avrpart * avr_find_part ( char * p )
/*
* 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;
@ -145,7 +145,7 @@ int avr_txrx_bit ( int fd, int bit )
/*
* 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;
unsigned char r, b, rbyte;
@ -153,7 +153,7 @@ unsigned char avr_txrx ( int fd, unsigned char byte )
rbyte = 0;
for (i=0; i<8; i++) {
b = (byte >> (7-i)) & 0x01;
r = avr_txrx_bit ( fd, b );
r = avr_txrx_bit(fd, b);
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
* '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;
@ -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
*/
unsigned char avr_read_byte ( int fd, struct avrpart * p,
int memtype, unsigned short addr )
unsigned char avr_read_byte(int fd, struct avrpart * p,
int memtype, unsigned short addr)
{
unsigned short offset;
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.
*/
int avr_read ( int fd, struct avrpart * p, int memtype )
int avr_read(int fd, struct avrpart * p, int memtype)
{
unsigned char rbyte;
unsigned short i;
@ -230,11 +230,11 @@ int avr_read ( int fd, struct avrpart * p, int memtype )
for (i=0; i<size; 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;
}
fprintf ( stderr, "\n" );
fprintf(stderr, "\n");
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
*/
int avr_write_byte ( int fd, struct avrpart * p, int memtype,
unsigned short addr, unsigned char data )
int avr_write_byte(int fd, struct avrpart * p, int memtype,
unsigned short addr, unsigned char data)
{
unsigned char cmd[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.
*/
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 wsize;
@ -360,7 +360,7 @@ int avr_write ( int fd, struct avrpart * p, int memtype, int size )
for (i=0; i<wsize; i++) {
/* eeprom or low byte of flash */
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);
if (rc) {
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;
}
@ -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
*/
int avr_program_enable ( int fd )
int avr_program_enable(int fd)
{
unsigned char cmd[4] = {0xac, 0x53, 0x00, 0x00};
unsigned char res[4];
@ -403,7 +403,7 @@ int avr_program_enable ( int fd )
/*
* 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 res[4];
@ -423,7 +423,7 @@ int avr_chip_erase ( int fd, struct avrpart * p )
/*
* 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 res[4];
@ -442,7 +442,7 @@ int avr_signature ( int fd, unsigned char sig[4] )
/*
* 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 */
usleep(100000);
@ -452,7 +452,7 @@ void avr_powerup ( int fd )
/*
* 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 */
}
@ -461,7 +461,7 @@ void avr_powerdown ( int fd )
/*
* 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 tries;
@ -484,12 +484,12 @@ int avr_initialize ( int fd, struct avrpart * p )
* of sync.
*/
if (strcmp(p->partdesc, "AT90S1200")==0) {
avr_program_enable ( fd );
avr_program_enable(fd);
}
else {
tries = 0;
do {
rc = avr_program_enable ( fd );
rc = avr_program_enable(fd);
if (rc == 0)
break;
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?
*/
if (tries == 32) {
fprintf ( stderr, "%s: AVR device not responding\n", progname );
fprintf(stderr, "%s: AVR device not responding\n", progname);
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) {
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;
@ -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;
char * buf;

40
avr.h
View File

@ -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,
int memtype, unsigned short addr );
unsigned char avr_read_byte(int fd, struct avrpart * p,
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,
unsigned short addr, unsigned char data );
int avr_write_byte(int fd, struct avrpart * p, int memtype,
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 size);
void avr_display ( FILE * f, struct avrpart * p, char * prefix );
void avr_display(FILE * f, struct avrpart * p, char * prefix);
#endif

View File

@ -59,27 +59,27 @@ extern char progbuf[];
char * fileio_version = "$Id$";
int b2ihex ( unsigned char * inbuf, int bufsize,
int b2ihex(unsigned char * inbuf, int bufsize,
int recsize, int startaddr,
char * outfile, FILE * outf );
char * outfile, FILE * outf);
int ihex2b ( char * infile, FILE * inf,
unsigned char * outbuf, int bufsize );
int ihex2b(char * infile, FILE * inf,
unsigned char * outbuf, int bufsize);
int fileio_rbin ( struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size );
int fileio_rbin(struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size);
int fileio_ihex ( struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size );
int fileio_ihex(struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size);
int fileio_srec ( struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size );
int fileio_srec(struct fioparms * fio,
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) {
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,
char * outfile, FILE * outf )
char * outfile, FILE * outf)
{
unsigned char * buf;
unsigned int nextaddr;
@ -103,8 +103,8 @@ int b2ihex ( unsigned char * inbuf, int bufsize,
unsigned char cksum;
if (recsize > 255) {
fprintf ( stderr, "%s: recsize=%d, must be < 256\n",
progname, recsize );
fprintf(stderr, "%s: recsize=%d, must be < 256\n",
progname, recsize);
return -1;
}
@ -119,14 +119,14 @@ int b2ihex ( unsigned char * inbuf, int bufsize,
if (n) {
cksum = 0;
fprintf ( outf, ":%02X%04X00", n, nextaddr );
fprintf(outf, ":%02X%04X00", n, nextaddr);
cksum += n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff);
for (i=0; i<n; i++) {
fprintf ( outf, "%02X", buf[i] );
fprintf(outf, "%02X", buf[i]);
cksum += buf[i];
}
cksum = -cksum;
fprintf ( outf, "%02X\n", cksum );
fprintf(outf, "%02X\n", cksum);
nextaddr += n;
nbytes += n;
@ -143,16 +143,16 @@ int b2ihex ( unsigned char * inbuf, int bufsize,
cksum = 0;
n = 0;
nextaddr = 0;
fprintf ( outf, ":%02X%04X01", n, nextaddr );
fprintf(outf, ":%02X%04X01", n, nextaddr);
cksum += n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff) + 1;
cksum = -cksum;
fprintf ( outf, "%02X\n", cksum );
fprintf(outf, "%02X\n", cksum);
return nbytes;
}
int ihex_readrec ( struct ihexrec * ihex, char * rec )
int ihex_readrec(struct ihexrec * ihex, char * rec)
{
int i, j;
char buf[8];
@ -195,7 +195,7 @@ int ihex_readrec ( struct ihexrec * ihex, char * rec )
if (e == buf || *e != 0)
return -1;
cksum = ihex->reclen + ((ihex->loadofs >> 8 ) & 0x0ff) +
cksum = ihex->reclen + ((ihex->loadofs >> 8) & 0x0ff) +
(ihex->loadofs & 0x0ff) + ihex->rectyp;
/* data */
@ -241,8 +241,8 @@ int ihex_readrec ( struct ihexrec * ihex, char * rec )
*
* */
int ihex2b ( char * infile, FILE * inf,
unsigned char * outbuf, int bufsize )
int ihex2b(char * infile, FILE * inf,
unsigned char * outbuf, int bufsize)
{
char buffer [ MAX_LINE_LEN ];
unsigned char * buf;
@ -337,8 +337,8 @@ int ihex2b ( char * infile, FILE * inf,
int fileio_rbin ( struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size )
int fileio_rbin(struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size)
{
int rc;
@ -367,8 +367,8 @@ int fileio_rbin ( struct fioparms * fio,
}
int fileio_ihex ( struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size )
int fileio_ihex(struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size)
{
int rc;
@ -397,8 +397,8 @@ int fileio_ihex ( struct fioparms * fio,
}
int fileio_srec ( struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size )
int fileio_srec(struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size)
{
fprintf(stderr, "%s: Motorola S-Record %s format not yet supported\n",
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;
@ -437,7 +437,7 @@ int fileio_setparms ( int op, struct fioparms * fp )
int fmt_autodetect ( char * fname )
int fmt_autodetect(char * fname)
{
FILE * f;
unsigned char buf[MAX_LINE_LEN];
@ -501,8 +501,8 @@ int fmt_autodetect ( char * fname )
int fileio ( int op, char * filename, FILEFMT format,
struct avrpart * p, int memtype, int size )
int fileio(int op, char * filename, FILEFMT format,
struct avrpart * p, int memtype, int size)
{
int rc;
FILE * f;

View File

@ -52,11 +52,11 @@ enum {
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,
struct avrpart * p, int memtype, int size );
int fileio(int op, char * filename, FILEFMT format,
struct avrpart * p, int memtype, int size);
#endif

44
main.c
View File

@ -124,7 +124,7 @@ unsigned int pinno[N_PINS];
/*
* usage message
*/
void usage ( void )
void usage(void)
{
fprintf(stderr,
"Usage: %s -p partno [-e] [-E exitspec[,exitspec]] [-f format] "
@ -139,7 +139,7 @@ void usage ( void )
/*
* parse the -E string
*/
int getexitspecs ( char *s, int *set, int *clr )
int getexitspecs(char *s, int *set, int *clr)
{
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;
@ -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];
int y, m, d, h, min, s;
@ -664,7 +664,7 @@ void verify_pin_assigned(int pin, char * desc)
/*
* main routine
*/
int main ( int argc, char * argv [] )
int main(int argc, char * argv [])
{
int fd; /* file descriptor for parallel port */
int rc; /* general return code checking */
@ -824,7 +824,7 @@ int main ( int argc, char * argv [] )
if (p == NULL) {
fprintf(stderr,
"%s: AVR Part \"%s\" not found. Valid parts are:\n\n",
progname, optarg );
progname, optarg);
avr_list_parts(stderr," ");
fprintf(stderr, "\n");
return 1;
@ -925,7 +925,7 @@ int main ( int argc, char * argv [] )
fprintf(stderr,
"%s: No AVR part has been specified, use \"-p Part\"\n\n"
" Valid Parts are:\n\n",
progname );
progname);
avr_list_parts(stderr, " ");
fprintf(stderr,"\n");
return 1;
@ -981,10 +981,10 @@ int main ( int argc, char * argv [] )
/*
* open the parallel port
*/
fd = open ( parallel, O_RDWR );
fd = open(parallel, O_RDWR);
if (fd < 0) {
fprintf ( stderr, "%s: can't open device \"%s\": %s\n\n",
progname, parallel, strerror(errno) );
fprintf(stderr, "%s: can't open device \"%s\": %s\n\n",
progname, parallel, strerror(errno));
return 1;
}
@ -996,7 +996,7 @@ int main ( int argc, char * argv [] )
ppidata = ppi_getall(fd, PPIDATA);
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;
ppidata = 0; /* clear all bits at exit */
goto main_exit;
@ -1023,7 +1023,7 @@ int main ( int argc, char * argv [] )
*/
rc = avr_initialize(fd,p);
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;
goto main_exit;
}
@ -1031,9 +1031,9 @@ int main ( int argc, char * argv [] )
/* indicate ready */
LED_ON(fd, pinno[PIN_LED_RDY]);
fprintf ( stderr,
fprintf(stderr,
"%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
@ -1055,7 +1055,7 @@ int main ( int argc, char * argv [] )
fprintf(stderr, "%sDouble check connections and try again, "
"or use -F to override\n"
"%sthis check.\n\n",
progbuf, progbuf );
progbuf, progbuf);
exitrc = 1;
goto main_exit;
}
@ -1068,9 +1068,9 @@ int main ( int argc, char * argv [] )
* erase the chip's flash and eeprom memories, this is required
* 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);
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",
progname, avr_memtstr(memtype));
rc = avr_read ( fd, p, memtype );
rc = avr_read(fd, p, memtype);
if (rc < 0) {
fprintf(stderr, "%s: failed to read all of %s memory, rc=%d\n",
progname, avr_memtstr(memtype), rc);
@ -1142,7 +1142,7 @@ int main ( int argc, char * argv [] )
progname, avr_memtstr(memtype));
if (!nowrite) {
rc = avr_write ( fd, p, memtype, size );
rc = avr_write(fd, p, memtype, size);
}
else {
/*
@ -1153,8 +1153,8 @@ int main ( int argc, char * argv [] )
}
if (rc < 0) {
fprintf ( stderr, "%s: failed to write flash memory, rc=%d\n",
progname, rc );
fprintf(stderr, "%s: failed to write flash memory, rc=%d\n",
progname, rc);
exitrc = 1;
goto main_exit;
}
@ -1177,7 +1177,7 @@ int main ( int argc, char * argv [] )
progname, avr_memtstr(memtype), inputf);
fprintf(stderr, "%s: reading on-chip %s data:\n",
progname, avr_memtstr(memtype));
rc = avr_read ( fd, v, memtype );
rc = avr_read(fd, v, memtype);
if (rc < 0) {
fprintf(stderr, "%s: failed to read all of %s memory, rc=%d\n",
progname, avr_memtstr(memtype), rc);

46
ppi.c
View File

@ -73,7 +73,7 @@ char * ppi_version = "$Id$";
* set 'get' and 'set' appropriately for subsequent passage to ioctl()
* 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) {
case PPIDATA:
@ -90,7 +90,7 @@ int ppi_getops ( int reg, unsigned long * get, unsigned long * set )
break;
default:
fprintf(stderr, "%s: avr_set(): invalid register=%d\n",
progname, reg );
progname, reg);
return -1;
break;
}
@ -102,13 +102,13 @@ int ppi_getops ( int reg, unsigned long * get, unsigned long * set )
/*
* 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 long get, set;
int rc;
rc = ppi_getops ( reg, &get, &set );
rc = ppi_getops(reg, &get, &set);
if (rc)
return -1;
@ -123,13 +123,13 @@ int ppi_set ( int fd, int reg, int bit )
/*
* 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 long get, set;
int rc;
rc = ppi_getops ( reg, &get, &set );
rc = ppi_getops(reg, &get, &set);
if (rc)
return -1;
@ -144,13 +144,13 @@ int ppi_clr ( int fd, int reg, int bit )
/*
* 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 long get, set;
int rc;
rc = ppi_getops ( reg, &get, &set );
rc = ppi_getops(reg, &get, &set);
if (rc)
return -1;
@ -163,13 +163,13 @@ int ppi_get ( int fd, int reg, int bit )
/*
* 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 long get, set;
int rc;
rc = ppi_getops ( reg, &get, &set );
rc = ppi_getops(reg, &get, &set);
if (rc)
return -1;
@ -184,13 +184,13 @@ int ppi_toggle ( int fd, int reg, int bit )
/*
* 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 long get, set;
int rc;
rc = ppi_getops ( reg, &get, &set );
rc = ppi_getops(reg, &get, &set);
if (rc)
return -1;
@ -202,13 +202,13 @@ int ppi_getall ( int fd, int reg )
/*
* 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 long get, set;
int rc;
rc = ppi_getops ( reg, &get, &set );
rc = ppi_getops(reg, &get, &set);
if (rc)
return -1;
@ -221,7 +221,7 @@ int ppi_setall ( int fd, int reg, int val )
/*
* 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);
@ -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)
@ -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;
@ -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)
@ -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)
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)
return -1;
@ -310,7 +310,7 @@ int ppi_getpinreg ( int pin )
* function in 'main()' and can use it to determine whether your sense
* pin is actually sensing.
*/
int ppi_sense ( int fd )
int ppi_sense(int fd)
{
unsigned int pr;
int count;
@ -319,10 +319,10 @@ int ppi_sense ( int fd )
count = 0;
fprintf ( stderr,
fprintf(stderr,
"parallel port data:\n"
" 111111111\n"
"123456789012345678\n" );
"123456789012345678\n");
buf[17] = 0;
pr = 1;

28
ppi.h
View File

@ -41,33 +41,33 @@ enum {
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

36
term.c
View File

@ -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;
@ -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 * 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;
char b [ 128 ];
for (i=0; i<n; i++) {
memcpy ( b, p, n );
memcpy(b, p, n);
buffer[i] = '.';
if (isalpha(b[i]) || isdigit(b[i]) || ispunct(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 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;
int i, l;
@ -283,7 +283,7 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
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;
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);
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");
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 */
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;
}
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;
fprintf(stdout, "Valid commands:\n\n" );
fprintf(stdout, "Valid commands:\n\n");
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, "\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 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 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;
int i, len;

2
term.h
View File

@ -34,6 +34,6 @@
#include "avr.h"
int terminal_mode ( int fd, struct avrpart * p );
int terminal_mode(int fd, struct avrpart * p);
#endif