From f36652689fd4cd5acc03b653175cc81c5e758baa Mon Sep 17 00:00:00 2001 From: Roland Lutz Date: Wed, 28 Jun 2017 16:57:45 +0200 Subject: iceprog: Break overlong lines --- iceprog/iceprog.c | 58 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 18 deletions(-) (limited to 'iceprog/iceprog.c') diff --git a/iceprog/iceprog.c b/iceprog/iceprog.c index ec71fd0..8321a3d 100644 --- a/iceprog/iceprog.c +++ b/iceprog/iceprog.c @@ -87,7 +87,8 @@ void send_byte(uint8_t data) { int rc = ftdi_write_data(&ftdic, &data, 1); if (rc != 1) { - fprintf(stderr, "Write error (single byte, rc=%d, expected %d).\n", rc, 1); + fprintf(stderr, "Write error (single byte, " + "rc=%d, expected %d).\n", rc, 1); error(2); } } @@ -103,7 +104,8 @@ void send_spi(uint8_t *data, int n) int rc = ftdi_write_data(&ftdic, data, n); if (rc != n) { - fprintf(stderr, "Write error (chunk, rc=%d, expected %d).\n", rc, n); + fprintf(stderr, "Write error (chunk, " + "rc=%d, expected %d).\n", rc, n); error(2); } } @@ -119,7 +121,8 @@ void xfer_spi(uint8_t *data, int n) int rc = ftdi_write_data(&ftdic, data, n); if (rc != n) { - fprintf(stderr, "Write error (chunk, rc=%d, expected %d).\n", rc, n); + fprintf(stderr, "Write error (chunk, " + "rc=%d, expected %d).\n", rc, n); error(2); } @@ -211,7 +214,9 @@ void flash_64kB_sector_erase(int addr) { fprintf(stderr, "erase 64kB sector at 0x%06X..\n", addr); - uint8_t command[4] = { 0xd8, (uint8_t)(addr >> 16), (uint8_t)(addr >> 8), (uint8_t)addr }; + uint8_t command[4] = { 0xd8, (uint8_t)(addr >> 16), + (uint8_t)(addr >> 8), + (uint8_t)addr }; set_gpio(0, 0); send_spi(command, 4); set_gpio(1, 0); @@ -222,7 +227,9 @@ void flash_prog(int addr, uint8_t *data, int n) if (verbose) fprintf(stderr, "prog 0x%06X +0x%03X..\n", addr, n); - uint8_t command[4] = { 0x02, (uint8_t)(addr >> 16), (uint8_t)(addr >> 8), (uint8_t)addr }; + uint8_t command[4] = { 0x02, (uint8_t)(addr >> 16), + (uint8_t)(addr >> 8), + (uint8_t)addr }; set_gpio(0, 0); send_spi(command, 4); send_spi(data, n); @@ -230,7 +237,8 @@ void flash_prog(int addr, uint8_t *data, int n) if (verbose) for (int i = 0; i < n; i++) - fprintf(stderr, "%02x%c", data[i], i == n - 1 || i % 32 == 31 ? '\n' : ' '); + fprintf(stderr, "%02x%c", data[i], + i == n - 1 || i % 32 == 31 ? '\n' : ' '); } void flash_read(int addr, uint8_t *data, int n) @@ -238,7 +246,9 @@ void flash_read(int addr, uint8_t *data, int n) if (verbose) fprintf(stderr, "read 0x%06X +0x%03X..\n", addr, n); - uint8_t command[4] = { 0x03, (uint8_t)(addr >> 16), (uint8_t)(addr >> 8), (uint8_t)addr }; + uint8_t command[4] = { 0x03, (uint8_t)(addr >> 16), + (uint8_t)(addr >> 8), + (uint8_t)addr }; set_gpio(0, 0); send_spi(command, 4); memset(data, 0, n); @@ -247,7 +257,8 @@ void flash_read(int addr, uint8_t *data, int n) if (verbose) for (int i = 0; i < n; i++) - fprintf(stderr, "%02x%c", data[i], i == n - 1 || i % 32 == 31 ? '\n' : ' '); + fprintf(stderr, "%02x%c", data[i], + i == n - 1 || i % 32 == 31 ? '\n' : ' '); } void flash_wait() @@ -567,12 +578,15 @@ int main(int argc, char **argv) if (devstr != NULL) { if (ftdi_usb_open_string(&ftdic, devstr)) { - fprintf(stderr, "Can't find iCE FTDI USB device (device string %s).\n", devstr); + fprintf(stderr, "Can't find iCE FTDI USB device " + "(device string %s).\n", devstr); error(2); } } else { if (ftdi_usb_open(&ftdic, 0x0403, 0x6010)) { - fprintf(stderr, "Can't find iCE FTDI USB device (vendor_id 0x0403, device_id 0x6010).\n"); + fprintf(stderr, "Can't find iCE FTDI USB device " + "(vendor_id 0x0403, " + "device_id 0x6010).\n"); error(2); } } @@ -585,25 +599,29 @@ int main(int argc, char **argv) } if (ftdi_usb_purge_buffers(&ftdic)) { - fprintf(stderr, "Failed to purge buffers on iCE FTDI USB device.\n"); + fprintf(stderr, "Failed to purge buffers " + "on iCE FTDI USB device.\n"); error(2); } if (ftdi_get_latency_timer(&ftdic, &ftdi_latency) < 0) { - fprintf(stderr, "Failed to get latency timer (%s).\n", ftdi_get_error_string(&ftdic)); + fprintf(stderr, "Failed to get latency timer (%s).\n", + ftdi_get_error_string(&ftdic)); error(2); } /* 1 is the fastest polling, it means 1 kHz polling */ if (ftdi_set_latency_timer(&ftdic, 1) < 0) { - fprintf(stderr, "Failed to set latency timer (%s).\n", ftdi_get_error_string(&ftdic)); + fprintf(stderr, "Failed to set latency timer (%s).\n", + ftdi_get_error_string(&ftdic)); error(2); } ftdic_latency_set = true; if (ftdi_set_bitmode(&ftdic, 0xff, BITMODE_MPSSE) < 0) { - fprintf(stderr, "Failed to set BITMODE_MPSSE on iCE FTDI USB device.\n"); + fprintf(stderr, "Failed to set BITMODE_MPSSE " + "on iCE FTDI USB device.\n"); error(2); } @@ -708,12 +726,15 @@ int main(int argc, char **argv) flash_bulk_erase(); flash_wait(); } else { - fprintf(stderr, "file size: %ld\n", file_size); + fprintf(stderr, "file size: %ld\n", + file_size); int begin_addr = rw_offset & ~0xffff; - int end_addr = (rw_offset + file_size + 0xffff) & ~0xffff; + int end_addr = (rw_offset + file_size + + 0xffff) & ~0xffff; - for (int addr = begin_addr; addr < end_addr; addr += 0x10000) { + for (int addr = begin_addr; + addr < end_addr; addr += 0x10000) { flash_write_enable(); flash_64kB_sector_erase(addr); flash_wait(); @@ -759,7 +780,8 @@ int main(int argc, char **argv) break; flash_read(rw_offset + addr, buffer_flash, rc); if (memcmp(buffer_file, buffer_flash, rc)) { - fprintf(stderr, "Found difference between flash and file!\n"); + fprintf(stderr, "Found difference " + "between flash and file!\n"); error(3); } } -- cgit v1.2.3