summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cc-bitbang.c5
-rw-r--r--lib/cc-usb.c13
-rw-r--r--lib/ccdbg-command.c3
-rw-r--r--lib/ccdbg-flash.c26
-rw-r--r--lib/ccdbg-hex.c4
-rw-r--r--lib/ccdbg-memory.c4
-rw-r--r--lib/ccdbg-rom.c2
-rw-r--r--lib/ccdbg.h4
-rw-r--r--lib/cp-usb-async.c4
-rw-r--r--lib/cp-usb.c4
10 files changed, 33 insertions, 36 deletions
diff --git a/lib/cc-bitbang.c b/lib/cc-bitbang.c
index a5d2d369..1d3ba476 100644
--- a/lib/cc-bitbang.c
+++ b/lib/cc-bitbang.c
@@ -60,13 +60,13 @@ void
cc_bitbang_wait_reset(struct cc_bitbang *bb)
{
struct timespec req, rem;
-
+
cc_bitbang_sync(bb);
req.tv_sec = (cc_reset_us) / 1000000;
req.tv_nsec = ((cc_reset_us) % 1000000) * 1000;
nanosleep(&req, &rem);
}
-
+
struct cc_bitbang *
cc_bitbang_open(void)
{
@@ -267,4 +267,3 @@ cc_bitbang_recv_bytes(struct cc_bitbang *bb, uint8_t *bytes, int nbytes)
first = 0;
}
}
-
diff --git a/lib/cc-usb.c b/lib/cc-usb.c
index 2efe572e..dc764c24 100644
--- a/lib/cc-usb.c
+++ b/lib/cc-usb.c
@@ -77,14 +77,14 @@ cc_handle_in(struct cc_usb *cc)
uint8_t h, l;
int in_pos;
int read_pos;
-
+
in_pos = 0;
read_pos = 0;
while (read_pos < cc->read_count && in_pos < cc->in_count) {
/*
* Skip to next hex character
*/
- while (in_pos < cc->in_count &&
+ while (in_pos < cc->in_count &&
cc_hex_nibble(cc->in_buf[in_pos]) == NOT_HEX)
in_pos++;
/*
@@ -109,7 +109,7 @@ cc_handle_in(struct cc_usb *cc)
if (--cc->read_buf[read_pos].len <= 0)
read_pos++;
}
-
+
/* Move remaining bytes to the start of the input buffer */
if (in_pos) {
memmove(cc->in_buf, cc->in_buf + in_pos,
@@ -213,7 +213,7 @@ cc_usb_printf(struct cc_usb *cc, char *format, ...)
char buf[1024], *b;
va_list ap;
int ret, this_time;
-
+
/* sprintf to a local buffer */
va_start(ap, format);
ret = vsnprintf(buf, sizeof(buf), format, ap);
@@ -243,7 +243,7 @@ cc_usb_send_bytes(struct cc_usb *cc, uint8_t *bytes, int len)
{
int this_len;
int ret = len;
-
+
while (len) {
this_len = len;
if (this_len > 8)
@@ -327,7 +327,7 @@ cc_usb_open(char *tty)
{
struct cc_usb *cc;
struct termios termios;
-
+
if (!tty)
tty = DEFAULT_TTY;
cc = calloc (sizeof (struct cc_usb), 1);
@@ -357,4 +357,3 @@ cc_usb_close(struct cc_usb *cc)
close (cc->fd);
free (cc);
}
-
diff --git a/lib/ccdbg-command.c b/lib/ccdbg-command.c
index 7d1ae067..a1002879 100644
--- a/lib/ccdbg-command.c
+++ b/lib/ccdbg-command.c
@@ -161,7 +161,7 @@ ccdbg_execute_hex_image(struct ccdbg *dbg, struct hex_image *image)
{
uint16_t pc;
uint8_t status;
-
+
if (image->address < 0xf000) {
fprintf(stderr, "Cannot execute program starting at 0x%04x\n", image->address);
return -1;
@@ -174,4 +174,3 @@ ccdbg_execute_hex_image(struct ccdbg *dbg, struct hex_image *image)
ccdbg_debug(CC_DEBUG_EXECUTE, "resume status: 0x%02x\n", status);
return 0;
}
-
diff --git a/lib/ccdbg-flash.c b/lib/ccdbg-flash.c
index 8a586a21..3e672985 100644
--- a/lib/ccdbg-flash.c
+++ b/lib/ccdbg-flash.c
@@ -37,10 +37,10 @@ static uint8_t flash_page[] = {
MOV_Rn_data(7), 0,
#define FLASH_WORDS_HIGH 16
-
+
MOV_Rn_data(6), 0,
#define FLASH_WORDS_LOW 18
-
+
MOV_direct_data, FWT, 0x20,
#define FLASH_TIMING 21
@@ -76,7 +76,7 @@ static uint8_t flash_page[] = {
static uint8_t flash_erase_page[] = {
3, MOV_direct_data, FADDRH, 0,
#define ERASE_PAGE_HIGH 3
-
+
3, MOV_direct_data, FADDRL, 0,
#define ERASE_PAGE_LOW 7
@@ -107,7 +107,7 @@ ccdbg_flash_erase_page(struct ccdbg *dbg, uint16_t addr)
uint8_t status;
uint8_t old[0x10], new[0x10];
int i;
-
+
ccdbg_read_memory(dbg, addr, old, 0x10);
flash_erase_page[ERASE_PAGE_HIGH] = page_addr >> 8;
flash_erase_page[ERASE_PAGE_LOW] = page_addr & 0xff;
@@ -130,7 +130,7 @@ ccdbg_flash_erase_page(struct ccdbg *dbg, uint16_t addr)
static uint8_t flash_write[] = {
MOV_direct_data, P1DIR, 0x02,
MOV_direct_data, P1, 0xFD,
-
+
MOV_A_direct, FCTL,
JB, ACC(FCTL_BUSY_BIT), 0xf1,
@@ -138,10 +138,10 @@ static uint8_t flash_write[] = {
MOV_direct_data, FADDRH, 0,
#define WRITE_PAGE_HIGH 16
-
+
MOV_direct_data, FADDRL, 0,
#define WRITE_PAGE_LOW 19
-
+
MOV_direct_data, FCTL, FCTL_WRITE,
MOV_direct_data, FWDATA, 0,
#define WRITE_BYTE_0 25
@@ -267,7 +267,7 @@ ccdbg_flash_hex_image(struct ccdbg *dbg, struct hex_image *image)
}
ram_addr = 0xf000;
-
+
flash_prog = 0xf400;
fwt = 0x20;
@@ -276,7 +276,7 @@ ccdbg_flash_hex_image(struct ccdbg *dbg, struct hex_image *image)
ccdbg_debug(CC_DEBUG_FLASH, "Upload %d flash program bytes to 0x%04x\n",
sizeof (flash_page), flash_prog);
ccdbg_write_memory(dbg, flash_prog, flash_page, sizeof(flash_page));
-
+
remain = image->length;
start = 0;
while (remain) {
@@ -296,7 +296,7 @@ ccdbg_flash_hex_image(struct ccdbg *dbg, struct hex_image *image)
return 1;
}
#endif
-
+
flash_addr = image->address + start;
flash_word_addr = flash_addr >> 1;
flash_len = this_time + (this_time & 1);
@@ -304,11 +304,11 @@ ccdbg_flash_hex_image(struct ccdbg *dbg, struct hex_image *image)
flash_words_low = flash_words & 0xff;
flash_words_high = flash_words >> 8;
-
+
/* The flash code above is lame */
if (flash_words_low)
flash_words_high++;
-
+
ccdbg_write_uint8(dbg, flash_prog + FLASH_ADDR_HIGH, flash_word_addr >> 8);
ccdbg_write_uint8(dbg, flash_prog + FLASH_ADDR_LOW, flash_word_addr & 0xff);
@@ -336,7 +336,7 @@ ccdbg_flash_hex_image(struct ccdbg *dbg, struct hex_image *image)
fprintf(stderr, "flash page timed out\n");
return 1;
}
-
+
ccdbg_debug(CC_DEBUG_FLASH, "Verify %d bytes in flash\n", this_time);
ccdbg_read_memory(dbg, flash_addr, verify, this_time);
if (memcmp (image->data + start, verify, this_time) != 0) {
diff --git a/lib/ccdbg-hex.c b/lib/ccdbg-hex.c
index 86478da0..dfea9156 100644
--- a/lib/ccdbg-hex.c
+++ b/lib/ccdbg-hex.c
@@ -147,7 +147,7 @@ ccdbg_hex_read_record(struct hex_input *input)
--nhexbytes;
if (nhexbytes != 0)
break;
-
+
switch (state) {
case read_length:
record = ccdbg_hex_alloc(hex);
@@ -261,7 +261,7 @@ ccdbg_hex_file_read(FILE *file, char *name)
goto bail;
if (hex->nrecord == srecord) {
srecord *= 2;
- newhex = realloc(hex,
+ newhex = realloc(hex,
sizeof (struct hex_file) +
srecord * sizeof (struct hex_record *));
if (!newhex)
diff --git a/lib/ccdbg-memory.c b/lib/ccdbg-memory.c
index 878c5f97..554ac637 100644
--- a/lib/ccdbg-memory.c
+++ b/lib/ccdbg-memory.c
@@ -127,7 +127,7 @@ struct hex_image *
ccdbg_read_hex_image(struct ccdbg *dbg, uint16_t address, uint16_t length)
{
struct hex_image *image;
-
+
image = calloc(sizeof(struct hex_image) + length, 1);
image->address = address;
image->length = length;
@@ -169,7 +169,7 @@ uint8_t
ccdbg_write_sfr(struct ccdbg *dbg, uint8_t addr, uint8_t *bytes, int nbytes)
{
int i;
-
+
for (i = 0; i < nbytes; i++) {
sfr_write[SFR_WRITE_ADDR] = addr + i;
sfr_write[SFR_WRITE_DATA] = *bytes++;
diff --git a/lib/ccdbg-rom.c b/lib/ccdbg-rom.c
index 4559b4e7..71bed220 100644
--- a/lib/ccdbg-rom.c
+++ b/lib/ccdbg-rom.c
@@ -45,7 +45,7 @@ ccdbg_rom_replace_xmem(struct ccdbg *dbg,
struct hex_image *rom = dbg->rom;
if (!rom)
return 0;
-
+
if (rom->address < addr + nbytes && addr < rom->address + rom->length) {
int start, stop;
diff --git a/lib/ccdbg.h b/lib/ccdbg.h
index fe0ea3a0..4a2e3b9f 100644
--- a/lib/ccdbg.h
+++ b/lib/ccdbg.h
@@ -229,10 +229,10 @@ ccdbg_get_chip_id(struct ccdbg *dbg);
uint8_t
ccdbg_execute(struct ccdbg *dbg, uint8_t *inst);
-
+
uint8_t
ccdbg_set_pc(struct ccdbg *dbg, uint16_t pc);
-
+
uint8_t
ccdbg_execute_hex_image(struct ccdbg *dbg, struct hex_image *image);
diff --git a/lib/cp-usb-async.c b/lib/cp-usb-async.c
index 1fe09aad..6539394b 100644
--- a/lib/cp-usb-async.c
+++ b/lib/cp-usb-async.c
@@ -130,7 +130,7 @@ cp_usb_async_write(struct cp_usb_async *cp, uint8_t mask, uint8_t value)
0x37e1, /* value */
gpio_set, /* index */
0); /* length */
-
+
libusb_fill_control_transfer(cp->packet[p].transfer,
cp->handle,
cp->packet[p].data,
@@ -163,7 +163,7 @@ cp_usb_async_read(struct cp_usb_async *cp, uint8_t *valuep)
0x00c2, /* value */
0, /* index */
1); /* length */
-
+
libusb_fill_control_transfer(cp->packet[p].transfer,
cp->handle,
cp->packet[p].data,
diff --git a/lib/cp-usb.c b/lib/cp-usb.c
index d227b78c..530848db 100644
--- a/lib/cp-usb.c
+++ b/lib/cp-usb.c
@@ -89,11 +89,11 @@ cp_usb_open(void)
int interface;
int ret;
uint8_t gpio;
-
+
usb_init();
usb_find_busses();
usb_find_devices();
-
+
busses = usb_get_busses();
for (bus = busses; bus; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next) {