aboutsummaryrefslogtreecommitdiff
path: root/src/platforms/stm32
diff options
context:
space:
mode:
authorGareth McMullin2014-10-16 13:19:34 -0700
committerGareth McMullin2014-10-16 13:50:56 -0700
commita5549d630c3c261e7d52cb245d945e54f011a3e7 (patch)
tree3dafd4329c35dc8420e90b1a0c890f94660ee7e1 /src/platforms/stm32
parent60626e5bbe8761544cb195ceb3ec7c85ff1e246e (diff)
Whitespace cleanup.
Diffstat (limited to 'src/platforms/stm32')
-rw-r--r--src/platforms/stm32/cdcacm.c52
-rw-r--r--src/platforms/stm32/dfu_f4.c27
-rw-r--r--src/platforms/stm32/dfucore.c73
-rw-r--r--src/platforms/stm32/gdb_if.c44
4 files changed, 99 insertions, 97 deletions
diff --git a/src/platforms/stm32/cdcacm.c b/src/platforms/stm32/cdcacm.c
index 010117f..ef7ff3b 100644
--- a/src/platforms/stm32/cdcacm.c
+++ b/src/platforms/stm32/cdcacm.c
@@ -51,20 +51,20 @@ static int cdcacm_gdb_dtr = 1;
static const struct usb_device_descriptor dev = {
- .bLength = USB_DT_DEVICE_SIZE,
- .bDescriptorType = USB_DT_DEVICE,
- .bcdUSB = 0x0200,
- .bDeviceClass = 0xEF, /* Miscellaneous Device */
- .bDeviceSubClass = 2, /* Common Class */
- .bDeviceProtocol = 1, /* Interface Association */
- .bMaxPacketSize0 = 64,
- .idVendor = 0x1D50,
- .idProduct = 0x6018,
- .bcdDevice = 0x0100,
- .iManufacturer = 1,
- .iProduct = 2,
- .iSerialNumber = 3,
- .bNumConfigurations = 1,
+ .bLength = USB_DT_DEVICE_SIZE,
+ .bDescriptorType = USB_DT_DEVICE,
+ .bcdUSB = 0x0200,
+ .bDeviceClass = 0xEF, /* Miscellaneous Device */
+ .bDeviceSubClass = 2, /* Common Class */
+ .bDeviceProtocol = 1, /* Interface Association */
+ .bMaxPacketSize0 = 64,
+ .idVendor = 0x1D50,
+ .idProduct = 0x6018,
+ .bcdDevice = 0x0100,
+ .iManufacturer = 1,
+ .iProduct = 2,
+ .iSerialNumber = 3,
+ .bNumConfigurations = 1,
};
/* This notification endpoint isn't implemented. According to CDC spec its
@@ -412,7 +412,7 @@ static void dfu_detach_complete(usbd_device *dev, struct usb_setup_data *req)
disconnect_usb();
/* Assert boot-request pin */
- assert_boot_pin();
+ assert_boot_pin();
/* Reset core to enter bootloader */
scb_reset_core();
@@ -555,22 +555,22 @@ void USB_ISR(void)
static char *get_dev_unique_id(char *s)
{
#if defined(STM32F4)
- volatile uint32_t *unique_id_p = (volatile uint32_t *)0x1FFF7A10;
+ volatile uint32_t *unique_id_p = (volatile uint32_t *)0x1FFF7A10;
#else
- volatile uint32_t *unique_id_p = (volatile uint32_t *)0x1FFFF7E8;
+ volatile uint32_t *unique_id_p = (volatile uint32_t *)0x1FFFF7E8;
#endif
uint32_t unique_id = *unique_id_p +
*(unique_id_p + 1) +
*(unique_id_p + 2);
- int i;
-
- /* Fetch serial number from chip's unique ID */
- for(i = 0; i < 8; i++) {
- s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
- }
- for(i = 0; i < 8; i++)
- if(s[i] > '9')
- s[i] += 'A' - '9' - 1;
+ int i;
+
+ /* Fetch serial number from chip's unique ID */
+ for(i = 0; i < 8; i++) {
+ s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
+ }
+ for(i = 0; i < 8; i++)
+ if(s[i] > '9')
+ s[i] += 'A' - '9' - 1;
s[8] = 0;
return s;
diff --git a/src/platforms/stm32/dfu_f4.c b/src/platforms/stm32/dfu_f4.c
index 3d1e369..1065938 100644
--- a/src/platforms/stm32/dfu_f4.c
+++ b/src/platforms/stm32/dfu_f4.c
@@ -28,13 +28,17 @@
#include "usbdfu.h"
-static uint32_t sector_addr[] = {0x8000000, 0x8004000, 0x8008000, 0x800c000,
- 0x8010000, 0x8020000, 0x8040000, 0x8060000,
- 0x8080000, 0x80a0000, 0x80c0000, 0x80e0000,
- 0x8100000, 0};
-static uint16_t sector_erase_time[12]= {500, 500, 500, 500,
- 1100,
- 2600, 2600, 2600, 2600, 2600, 2600, 2600};
+static uint32_t sector_addr[] = {
+ 0x8000000, 0x8004000, 0x8008000, 0x800c000,
+ 0x8010000, 0x8020000, 0x8040000, 0x8060000,
+ 0x8080000, 0x80a0000, 0x80c0000, 0x80e0000,
+ 0x8100000, 0
+};
+static uint16_t sector_erase_time[12]= {
+ 500, 500, 500, 500,
+ 1100, 2600, 2600, 2600,
+ 2600, 2600, 2600, 2600
+};
static uint8_t sector_num = 0xff;
/* Find the sector number for a given address*/
@@ -45,7 +49,7 @@ static void get_sector_num(uint32_t addr)
if (addr < sector_addr[i+1])
break;
i++;
- }
+ }
if (!sector_addr[i])
return;
sector_num = i;
@@ -61,9 +65,8 @@ void dfu_check_and_do_sector_erase(uint32_t addr)
void dfu_flash_program_buffer(uint32_t baseaddr, void *buf, int len)
{
for(int i = 0; i < len; i += 4)
- flash_program_word(baseaddr + i,
- *(uint32_t*)(buf+i),
- FLASH_PROGRAM_X32);
+ flash_program_word(baseaddr + i, *(uint32_t*)(buf+i),
+ FLASH_PROGRAM_X32);
}
uint32_t dfu_poll_timeout(uint8_t cmd, uint32_t addr, uint16_t blocknum)
@@ -100,7 +103,7 @@ void dfu_jump_app_if_valid(void)
SCB_VTOR = APP_ADDRESS & 0x1FFFFF; /* Max 2 MByte Flash*/
/* Initialise master stack pointer */
asm volatile ("msr msp, %0"::"g"
- (*(volatile uint32_t*)APP_ADDRESS));
+ (*(volatile uint32_t*)APP_ADDRESS));
/* Jump to application */
(*(void(**)())(APP_ADDRESS + 4))();
}
diff --git a/src/platforms/stm32/dfucore.c b/src/platforms/stm32/dfucore.c
index 85e5e87..77cef4e 100644
--- a/src/platforms/stm32/dfucore.c
+++ b/src/platforms/stm32/dfucore.c
@@ -50,20 +50,20 @@ static struct {
} prog;
const struct usb_device_descriptor dev = {
- .bLength = USB_DT_DEVICE_SIZE,
- .bDescriptorType = USB_DT_DEVICE,
- .bcdUSB = 0x0200,
- .bDeviceClass = 0,
- .bDeviceSubClass = 0,
- .bDeviceProtocol = 0,
- .bMaxPacketSize0 = 64,
- .idVendor = 0x1D50,
- .idProduct = 0x6017,
- .bcdDevice = 0x0100,
- .iManufacturer = 1,
- .iProduct = 2,
- .iSerialNumber = 3,
- .bNumConfigurations = 1,
+ .bLength = USB_DT_DEVICE_SIZE,
+ .bDescriptorType = USB_DT_DEVICE,
+ .bcdUSB = 0x0200,
+ .bDeviceClass = 0,
+ .bDeviceSubClass = 0,
+ .bDeviceProtocol = 0,
+ .bMaxPacketSize0 = 64,
+ .idVendor = 0x1D50,
+ .idProduct = 0x6017,
+ .bcdDevice = 0x0100,
+ .iManufacturer = 1,
+ .iProduct = 2,
+ .iSerialNumber = 3,
+ .bNumConfigurations = 1,
};
const struct usb_dfu_descriptor dfu_function = {
@@ -166,8 +166,7 @@ usbdfu_getstatus_complete(usbd_device *dev, struct usb_setup_data *req)
flash_unlock();
if(prog.blocknum == 0) {
uint32_t addr = get_le32(prog.buf + 1);
- if (addr < app_address ||
- (addr >= max_address)) {
+ if ((addr < app_address) || (addr >= max_address)) {
flash_lock();
usbd_ep_stall_set(dev, 0, 1);
return;
@@ -282,34 +281,34 @@ void dfu_main(void)
static char *get_dev_unique_id(char *s)
{
#if defined(STM32F4) || defined(STM32F2)
-#define UNIQUE_SERIAL_R 0x1FFF7A10
-#define FLASH_SIZE_R 0x1fff7A22
+# define UNIQUE_SERIAL_R 0x1FFF7A10
+# define FLASH_SIZE_R 0x1fff7A22
#elif defined(STM32F3)
-#define UNIQUE_SERIAL_R 0x1FFFF7AC
-#define FLASH_SIZE_R 0x1fff77cc
+# define UNIQUE_SERIAL_R 0x1FFFF7AC
+# define FLASH_SIZE_R 0x1fff77cc
#elif defined(STM32L1)
-#define UNIQUE_SERIAL_R 0x1ff80050
-#define FLASH_SIZE_R 0x1FF8004C
+# define UNIQUE_SERIAL_R 0x1ff80050
+# define FLASH_SIZE_R 0x1FF8004C
#else
-#define UNIQUE_SERIAL_R 0x1FFFF7E8;
-#define FLASH_SIZE_R 0x1ffff7e0
+# define UNIQUE_SERIAL_R 0x1FFFF7E8;
+# define FLASH_SIZE_R 0x1ffff7e0
#endif
- volatile uint32_t *unique_id_p = (volatile uint32_t *)UNIQUE_SERIAL_R;
+ volatile uint32_t *unique_id_p = (volatile uint32_t *)UNIQUE_SERIAL_R;
uint32_t unique_id = *unique_id_p +
*(unique_id_p + 1) +
*(unique_id_p + 2);
- int i;
-
- /* Calculated the upper flash limit from the exported data
- in theparameter block*/
- max_address = (*(uint32_t *) FLASH_SIZE_R) <<10;
- /* Fetch serial number from chip's unique ID */
- for(i = 0; i < 8; i++) {
- s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
- }
- for(i = 0; i < 8; i++)
- if(s[i] > '9')
- s[i] += 'A' - '9' - 1;
+ int i;
+
+ /* Calculated the upper flash limit from the exported data
+ in theparameter block*/
+ max_address = (*(uint32_t *) FLASH_SIZE_R) <<10;
+ /* Fetch serial number from chip's unique ID */
+ for(i = 0; i < 8; i++) {
+ s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
+ }
+ for(i = 0; i < 8; i++)
+ if(s[i] > '9')
+ s[i] += 'A' - '9' - 1;
s[8] = 0;
return s;
diff --git a/src/platforms/stm32/gdb_if.c b/src/platforms/stm32/gdb_if.c
index 28bc4c8..482effe 100644
--- a/src/platforms/stm32/gdb_if.c
+++ b/src/platforms/stm32/gdb_if.c
@@ -67,8 +67,8 @@ void gdb_usb_out_cb(usbd_device *dev, uint8_t ep)
{
(void)ep;
usbd_ep_nak_set(dev, CDCACM_GDB_ENDPOINT, 1);
- count_new = usbd_ep_read_packet(dev, CDCACM_GDB_ENDPOINT,
- double_buffer_out, CDCACM_PACKET_SIZE);
+ count_new = usbd_ep_read_packet(dev, CDCACM_GDB_ENDPOINT,
+ double_buffer_out, CDCACM_PACKET_SIZE);
if(!count_new) {
usbd_ep_nak_set(dev, CDCACM_GDB_ENDPOINT, 0);
}
@@ -77,19 +77,19 @@ void gdb_usb_out_cb(usbd_device *dev, uint8_t ep)
unsigned char gdb_if_getchar(void)
{
- while(!(out_ptr < count_out)) {
+ while (!(out_ptr < count_out)) {
/* Detach if port closed */
- if(!cdcacm_get_dtr())
+ if (!cdcacm_get_dtr())
return 0x04;
- while(cdcacm_get_config() != 1);
- if (count_new) {
- memcpy(buffer_out, double_buffer_out,count_new);
- count_out = count_new;
- count_new = 0;
- out_ptr = 0;
- usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
- }
+ while (cdcacm_get_config() != 1);
+ if (count_new) {
+ memcpy(buffer_out, double_buffer_out,count_new);
+ count_out = count_new;
+ count_new = 0;
+ out_ptr = 0;
+ usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
+ }
}
return buffer_out[out_ptr++];
@@ -99,19 +99,19 @@ unsigned char gdb_if_getchar_to(int timeout)
{
timeout_counter = timeout/100;
- if(!(out_ptr < count_out)) do {
+ if (!(out_ptr < count_out)) do {
/* Detach if port closed */
- if(!cdcacm_get_dtr())
+ if (!cdcacm_get_dtr())
return 0x04;
- while(cdcacm_get_config() != 1);
- if (count_new) {
- memcpy(buffer_out, double_buffer_out,count_new);
- count_out = count_new;
- count_new = 0;
- out_ptr = 0;
- usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
- }
+ while (cdcacm_get_config() != 1);
+ if (count_new) {
+ memcpy(buffer_out, double_buffer_out,count_new);
+ count_out = count_new;
+ count_new = 0;
+ out_ptr = 0;
+ usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
+ }
} while(timeout_counter && !(out_ptr < count_out));
if(out_ptr < count_out)