aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32/f1/stm32-h103
diff options
context:
space:
mode:
Diffstat (limited to 'examples/stm32/f1/stm32-h103')
-rw-r--r--examples/stm32/f1/stm32-h103/button/button.c6
-rw-r--r--examples/stm32/f1/stm32-h103/exti_both/exti_both.c6
-rw-r--r--examples/stm32/f1/stm32-h103/exti_rising_falling/exti_rising_falling.c6
-rw-r--r--examples/stm32/f1/stm32-h103/fancyblink/fancyblink.c4
-rw-r--r--examples/stm32/f1/stm32-h103/led_stripe/led_stripe.c12
-rw-r--r--examples/stm32/f1/stm32-h103/miniblink/miniblink.c2
-rw-r--r--examples/stm32/f1/stm32-h103/pwm_6step/pwm_6step.c8
-rw-r--r--examples/stm32/f1/stm32-h103/spi/spi.c6
-rw-r--r--examples/stm32/f1/stm32-h103/timer/timer.c6
-rw-r--r--examples/stm32/f1/stm32-h103/traceswo/traceswo.c8
-rw-r--r--examples/stm32/f1/stm32-h103/usart/usart.c6
-rw-r--r--examples/stm32/f1/stm32-h103/usart_irq/usart_irq.c6
-rw-r--r--examples/stm32/f1/stm32-h103/usart_irq_printf/usart_irq_printf.c22
-rw-r--r--examples/stm32/f1/stm32-h103/usart_printf/usart_printf.c8
-rw-r--r--examples/stm32/f1/stm32-h103/usb_cdcacm/cdcacm.c8
-rw-r--r--examples/stm32/f1/stm32-h103/usb_dfu/usbdfu.c16
-rw-r--r--examples/stm32/f1/stm32-h103/usb_iap/usbiap.c16
17 files changed, 84 insertions, 62 deletions
diff --git a/examples/stm32/f1/stm32-h103/button/button.c b/examples/stm32/f1/stm32-h103/button/button.c
index 9d9a5e9..927dd71 100644
--- a/examples/stm32/f1/stm32-h103/button/button.c
+++ b/examples/stm32/f1/stm32-h103/button/button.c
@@ -26,12 +26,12 @@
u16 exti_line_state;
/* Set STM32 to 72 MHz. */
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@@ -41,7 +41,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
-void button_setup(void)
+static void button_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
diff --git a/examples/stm32/f1/stm32-h103/exti_both/exti_both.c b/examples/stm32/f1/stm32-h103/exti_both/exti_both.c
index c871c35..2a086f8 100644
--- a/examples/stm32/f1/stm32-h103/exti_both/exti_both.c
+++ b/examples/stm32/f1/stm32-h103/exti_both/exti_both.c
@@ -26,12 +26,12 @@
u16 exti_line_state;
/* Set STM32 to 72 MHz. */
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@@ -41,7 +41,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
-void exti_setup(void)
+static void exti_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
diff --git a/examples/stm32/f1/stm32-h103/exti_rising_falling/exti_rising_falling.c b/examples/stm32/f1/stm32-h103/exti_rising_falling/exti_rising_falling.c
index f847847..76db50f 100644
--- a/examples/stm32/f1/stm32-h103/exti_rising_falling/exti_rising_falling.c
+++ b/examples/stm32/f1/stm32-h103/exti_rising_falling/exti_rising_falling.c
@@ -29,12 +29,12 @@
u16 exti_direction = FALLING;
/* Set STM32 to 72 MHz. */
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@@ -44,7 +44,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
-void exti_setup(void)
+static void exti_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
diff --git a/examples/stm32/f1/stm32-h103/fancyblink/fancyblink.c b/examples/stm32/f1/stm32-h103/fancyblink/fancyblink.c
index b023180..f3a4624 100644
--- a/examples/stm32/f1/stm32-h103/fancyblink/fancyblink.c
+++ b/examples/stm32/f1/stm32-h103/fancyblink/fancyblink.c
@@ -21,7 +21,7 @@
#include <libopencm3/stm32/f1/gpio.h>
/* Set STM32 to 72 MHz. */
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@@ -29,7 +29,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* Set GPIO12 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ,
diff --git a/examples/stm32/f1/stm32-h103/led_stripe/led_stripe.c b/examples/stm32/f1/stm32-h103/led_stripe/led_stripe.c
index 5b555e5..4407c66 100644
--- a/examples/stm32/f1/stm32-h103/led_stripe/led_stripe.c
+++ b/examples/stm32/f1/stm32-h103/led_stripe/led_stripe.c
@@ -63,7 +63,7 @@ struct color {
};
/* Set STM32 to 72 MHz. */
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@@ -72,7 +72,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* Set GPIO12 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ,
@@ -87,7 +87,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO15);
}
-void send_colors(struct color *colors, int count)
+static void send_colors(struct color *colors, int count)
{
int i, k;
@@ -148,7 +148,7 @@ void send_colors(struct color *colors, int count)
}
}
-void reset_colors(struct color *colors, int count)
+static void reset_colors(struct color *colors, int count)
{
int i;
@@ -159,7 +159,7 @@ void reset_colors(struct color *colors, int count)
}
}
-void init_colors(struct color *colors, int count)
+static void init_colors(struct color *colors, int count)
{
colors[0].r = 0x1F;
colors[0].g = 0;
@@ -174,7 +174,7 @@ void init_colors(struct color *colors, int count)
count = count;
}
-void step_colors(struct color *colors, int count)
+static void step_colors(struct color *colors, int count)
{
int i;
struct color tmp_color1;
diff --git a/examples/stm32/f1/stm32-h103/miniblink/miniblink.c b/examples/stm32/f1/stm32-h103/miniblink/miniblink.c
index ede12f9..af8d4fd 100644
--- a/examples/stm32/f1/stm32-h103/miniblink/miniblink.c
+++ b/examples/stm32/f1/stm32-h103/miniblink/miniblink.c
@@ -20,7 +20,7 @@
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/f1/gpio.h>
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* Enable GPIOC clock. */
/* Manually: */
diff --git a/examples/stm32/f1/stm32-h103/pwm_6step/pwm_6step.c b/examples/stm32/f1/stm32-h103/pwm_6step/pwm_6step.c
index deb0ff0..b0efdde 100644
--- a/examples/stm32/f1/stm32-h103/pwm_6step/pwm_6step.c
+++ b/examples/stm32/f1/stm32-h103/pwm_6step/pwm_6step.c
@@ -28,12 +28,12 @@
u16 exti_direction = FALLING;
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@@ -43,7 +43,7 @@ void gpio_setup(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
-void exti_setup(void)
+static void exti_setup(void)
{
/* Enable GPIOA clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@@ -80,7 +80,7 @@ void exti0_isr(void)
}
}
-void tim_setup(void)
+static void tim_setup(void)
{
/* Enable TIM1 clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_TIM1EN);
diff --git a/examples/stm32/f1/stm32-h103/spi/spi.c b/examples/stm32/f1/stm32-h103/spi/spi.c
index 0b06fc4..09344da 100644
--- a/examples/stm32/f1/stm32-h103/spi/spi.c
+++ b/examples/stm32/f1/stm32-h103/spi/spi.c
@@ -20,17 +20,17 @@
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/spi.h>
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
-void spi_setup(void)
+static void spi_setup(void)
{
/* TODO */
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* TODO */
}
diff --git a/examples/stm32/f1/stm32-h103/timer/timer.c b/examples/stm32/f1/stm32-h103/timer/timer.c
index 210e592..ed157ef 100644
--- a/examples/stm32/f1/stm32-h103/timer/timer.c
+++ b/examples/stm32/f1/stm32-h103/timer/timer.c
@@ -51,12 +51,12 @@ u16 new_time;
u16 frequency;
int debug = 0;
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* Enable GPIOC clock. */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
@@ -68,7 +68,7 @@ void gpio_setup(void)
gpio_set(GPIOC, GPIO12);
}
-void tim_setup(void)
+static void tim_setup(void)
{
/* Enable TIM2 clock. */
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM2EN);
diff --git a/examples/stm32/f1/stm32-h103/traceswo/traceswo.c b/examples/stm32/f1/stm32-h103/traceswo/traceswo.c
index 7c0f505..b29b9a7 100644
--- a/examples/stm32/f1/stm32-h103/traceswo/traceswo.c
+++ b/examples/stm32/f1/stm32-h103/traceswo/traceswo.c
@@ -25,7 +25,7 @@
#include <libopencm3/cm3/tpiu.h>
#include <libopencm3/cm3/itm.h>
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@@ -33,7 +33,7 @@ void clock_setup(void)
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
}
-void trace_setup(void)
+static void trace_setup(void)
{
/* Enable trace subsystem (we'll use ITM and TPIU). */
SCS_DEMCR |= SCS_DEMCR_TRCENA;
@@ -61,14 +61,14 @@ void trace_setup(void)
ITM_TER[0] = 1;
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* Set GPIO12 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
}
-void trace_send_blocking(char c)
+static void trace_send_blocking(char c)
{
while (!(ITM_STIM[0] & ITM_STIM_FIFOREADY))
;
diff --git a/examples/stm32/f1/stm32-h103/usart/usart.c b/examples/stm32/f1/stm32-h103/usart/usart.c
index dcb7908..846b69b 100644
--- a/examples/stm32/f1/stm32-h103/usart/usart.c
+++ b/examples/stm32/f1/stm32-h103/usart/usart.c
@@ -21,7 +21,7 @@
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/usart.h>
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@@ -37,7 +37,7 @@ void clock_setup(void)
RCC_APB1ENR_USART3EN);
}
-void usart_setup(void)
+static void usart_setup(void)
{
/* Setup GPIO pin GPIO_USART1_TX. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@@ -85,7 +85,7 @@ void usart_setup(void)
usart_enable(USART3);
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
/* Set GPIO12 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ,
diff --git a/examples/stm32/f1/stm32-h103/usart_irq/usart_irq.c b/examples/stm32/f1/stm32-h103/usart_irq/usart_irq.c
index ae95df8..7ab4b53 100644
--- a/examples/stm32/f1/stm32-h103/usart_irq/usart_irq.c
+++ b/examples/stm32/f1/stm32-h103/usart_irq/usart_irq.c
@@ -22,7 +22,7 @@
#include <libopencm3/stm32/usart.h>
#include <libopencm3/cm3/nvic.h>
-void clock_setup(void)
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@@ -34,7 +34,7 @@ void clock_setup(void)
RCC_APB2ENR_AFIOEN | RCC_APB2ENR_USART1EN);
}
-void usart_setup(void)
+static void usart_setup(void)
{
/* Enable the USART1 interrupt. */
nvic_enable_irq(NVIC_USART1_IRQ);
@@ -62,7 +62,7 @@ void usart_setup(void)
usart_enable(USART1);
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
gpio_set(GPIOC, GPIO12);
diff --git a/examples/stm32/f1/stm32-h103/usart_irq_printf/usart_irq_printf.c b/examples/stm32/f1/stm32-h103/usart_irq_printf/usart_irq_printf.c
index c61349c..e0cc1fd 100644
--- a/examples/stm32/f1/stm32-h103/usart_irq_printf/usart_irq_printf.c
+++ b/examples/stm32/f1/stm32-h103/usart_irq_printf/usart_irq_printf.c
@@ -45,7 +45,7 @@ struct ring {
#define RING_DATA(RING) (RING)->data
#define RING_EMPTY(RING) ((RING)->begin == (RING)->end)
-void ring_init(struct ring *ring, u8 *buf, ring_size_t size)
+static void ring_init(struct ring *ring, u8 *buf, ring_size_t size)
{
ring->data = buf;
ring->size = size;
@@ -53,7 +53,7 @@ void ring_init(struct ring *ring, u8 *buf, ring_size_t size)
ring->end = 0;
}
-s32 ring_write_ch(struct ring *ring, u8 ch)
+static s32 ring_write_ch(struct ring *ring, u8 ch)
{
if (((ring->end + 1) % ring->size) != ring->begin) {
ring->data[ring->end++] = ch;
@@ -64,7 +64,7 @@ s32 ring_write_ch(struct ring *ring, u8 ch)
return -1;
}
-s32 ring_write(struct ring *ring, u8 *data, ring_size_t size)
+static s32 ring_write(struct ring *ring, u8 *data, ring_size_t size)
{
s32 i;
@@ -76,7 +76,7 @@ s32 ring_write(struct ring *ring, u8 *data, ring_size_t size)
return i;
}
-s32 ring_read_ch(struct ring *ring, u8 *ch)
+static s32 ring_read_ch(struct ring *ring, u8 *ch)
{
s32 ret = -1;
@@ -90,7 +90,8 @@ s32 ring_read_ch(struct ring *ring, u8 *ch)
return ret;
}
-s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
+/* Not used!
+static s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
{
s32 i;
@@ -101,6 +102,7 @@ s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
return -i;
}
+*/
/******************************************************************************
* The example implementation
@@ -111,7 +113,9 @@ s32 ring_read(struct ring *ring, u8 *data, ring_size_t size)
struct ring output_ring;
u8 output_ring_buffer[BUFFER_SIZE];
-void clock_setup(void)
+int _write(int file, char *ptr, int len);
+
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@@ -123,7 +127,7 @@ void clock_setup(void)
RCC_APB2ENR_AFIOEN | RCC_APB2ENR_USART1EN);
}
-void usart_setup(void)
+static void usart_setup(void)
{
/* Initialize output ring buffer. */
ring_init(&output_ring, output_ring_buffer, BUFFER_SIZE);
@@ -154,7 +158,7 @@ void usart_setup(void)
usart_enable(USART1);
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
gpio_set(GPIOC, GPIO12);
@@ -216,7 +220,7 @@ int _write(int file, char *ptr, int len)
return -1;
}
-void systick_setup(void)
+static void systick_setup(void)
{
/* 72MHz / 8 => 9000000 counts per second. */
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
diff --git a/examples/stm32/f1/stm32-h103/usart_printf/usart_printf.c b/examples/stm32/f1/stm32-h103/usart_printf/usart_printf.c
index a275d83..40ac7a5 100644
--- a/examples/stm32/f1/stm32-h103/usart_printf/usart_printf.c
+++ b/examples/stm32/f1/stm32-h103/usart_printf/usart_printf.c
@@ -25,7 +25,9 @@
#include <stdio.h>
#include <errno.h>
-void clock_setup(void)
+int _write(int file, char *ptr, int len);
+
+static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
@@ -37,7 +39,7 @@ void clock_setup(void)
RCC_APB2ENR_AFIOEN | RCC_APB2ENR_USART1EN);
}
-void usart_setup(void)
+static void usart_setup(void)
{
/* Setup GPIO pin GPIO_USART1_RE_TX on GPIO port B for transmit. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
@@ -55,7 +57,7 @@ void usart_setup(void)
usart_enable(USART1);
}
-void gpio_setup(void)
+static void gpio_setup(void)
{
gpio_set(GPIOC, GPIO12);
diff --git a/examples/stm32/f1/stm32-h103/usb_cdcacm/cdcacm.c b/examples/stm32/f1/stm32-h103/usb_cdcacm/cdcacm.c
index 1dd47c0..3ed519f 100644
--- a/examples/stm32/f1/stm32-h103/usb_cdcacm/cdcacm.c
+++ b/examples/stm32/f1/stm32-h103/usb_cdcacm/cdcacm.c
@@ -177,8 +177,8 @@ static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *
* even though it's optional in the CDC spec, and we don't
* advertise it in the ACM functional descriptor.
*/
- char buf[10];
- struct usb_cdc_notification *notif = (void *)buf;
+ char local_buf[10];
+ struct usb_cdc_notification *notif = (void *)local_buf;
/* We echo signals back to host as notification. */
notif->bmRequestType = 0xA1;
@@ -186,8 +186,8 @@ static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *
notif->wValue = 0;
notif->wIndex = 0;
notif->wLength = 2;
- buf[8] = req->wValue & 3;
- buf[9] = 0;
+ local_buf[8] = req->wValue & 3;
+ local_buf[9] = 0;
// usbd_ep_write_packet(0x83, buf, 10);
return 1;
}
diff --git a/examples/stm32/f1/stm32-h103/usb_dfu/usbdfu.c b/examples/stm32/f1/stm32-h103/usb_dfu/usbdfu.c
index 95c51cb..20853c1 100644
--- a/examples/stm32/f1/stm32-h103/usb_dfu/usbdfu.c
+++ b/examples/stm32/f1/stm32-h103/usb_dfu/usbdfu.c
@@ -143,16 +143,24 @@ static void usbdfu_getstatus_complete(usbd_device *usbd_dev, struct usb_setup_da
if (prog.blocknum == 0) {
switch (prog.buf[0]) {
case CMD_ERASE:
- flash_erase_page(*(u32 *)(prog.buf + 1));
+ {
+ u32 *dat = (u32 *)(prog.buf + 1);
+ flash_erase_page(*dat);
+ }
case CMD_SETADDR:
- prog.addr = *(u32 *)(prog.buf + 1);
+ {
+ u32 *dat = (u32 *)(prog.buf + 1);
+ prog.addr = *dat;
+ }
}
} else {
u32 baseaddr = prog.addr + ((prog.blocknum - 2) *
dfu_function.wTransferSize);
- for (i = 0; i < prog.len; i += 2)
+ for (i = 0; i < prog.len; i += 2) {
+ u16 *dat = (u16 *)(prog.buf + i);
flash_program_half_word(baseaddr + i,
- *(u16 *)(prog.buf + i));
+ *dat);
+ }
}
flash_lock();
diff --git a/examples/stm32/f1/stm32-h103/usb_iap/usbiap.c b/examples/stm32/f1/stm32-h103/usb_iap/usbiap.c
index 4db224c..fb3bdb9 100644
--- a/examples/stm32/f1/stm32-h103/usb_iap/usbiap.c
+++ b/examples/stm32/f1/stm32-h103/usb_iap/usbiap.c
@@ -143,16 +143,24 @@ static void usbdfu_getstatus_complete(usbd_device *usbd_dev, struct usb_setup_da
if (prog.blocknum == 0) {
switch (prog.buf[0]) {
case CMD_ERASE:
- flash_erase_page(*(u32 *)(prog.buf + 1));
+ {
+ u32 *dat = (u32 *)(prog.buf + 1);
+ flash_erase_page(*dat);
+ }
case CMD_SETADDR:
- prog.addr = *(u32 *)(prog.buf + 1);
+ {
+ u32 *dat = (u32 *)(prog.buf + 1);
+ prog.addr = *dat;
+ }
}
} else {
u32 baseaddr = prog.addr + ((prog.blocknum - 2) *
dfu_function.wTransferSize);
- for (i = 0; i < prog.len; i += 2)
+ for (i = 0; i < prog.len; i += 2) {
+ u16 *dat = (u16 *)(prog.buf + i);
flash_program_half_word(baseaddr + i,
- *(u16 *)(prog.buf + i));
+ *dat);
+ }
}
flash_lock();