summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@ka-ata-killa.ourano.james.local>2021-03-06 18:19:33 +0000
committerroot <root@ka-ata-killa.ourano.james.local>2021-03-06 18:23:04 +0000
commit03486e52a2dde8ade759f36fea8b403b6524451c (patch)
treedc54d6ff9797340d83e159b596fd80cc1f2826c6
parentf519bbe55f6917d86af6bb4946dfef073175d8f3 (diff)
downloadclock-03486e52a2dde8ade759f36fea8b403b6524451c.tar.gz
clock-03486e52a2dde8ade759f36fea8b403b6524451c.tar.bz2
clock-03486e52a2dde8ade759f36fea8b403b6524451c.zip
pull a new libopencm3 in the hope it fixes tim's usb problems
-rw-r--r--app/adc.c4
-rw-r--r--app/cdcacm.c23
-rw-r--r--app/dfu.c24
-rw-r--r--app/gdbfl.script2
-rw-r--r--app/main.c176
-rw-r--r--app/project.h6
-rw-r--r--app/prototypes.h6
-rw-r--r--app/sysclk.c2
-rw-r--r--app/ticker.c2
-rw-r--r--app/usb.c25
-rw-r--r--boot/bootloader.c79
-rw-r--r--boot/dfu.c30
-rw-r--r--boot/project.h6
-rw-r--r--boot/prototypes.h2
m---------libopencm30
15 files changed, 111 insertions, 276 deletions
diff --git a/app/adc.c b/app/adc.c
index 821bac9..8825c71 100644
--- a/app/adc.c
+++ b/app/adc.c
@@ -69,7 +69,7 @@ void adc_dispatch (void)
ago = now - adc_stamp;
if (ago > ADC_TIMEOUT) {
- adc_off (ADC1);
+ adc_power_off (ADC1);
adc_power_on (ADC1);
state = WAIT_VREF;
start_conversion (VREF_CHANNEL);
@@ -116,7 +116,7 @@ void adc_init (void)
MAP_ANALOG_INPUT (POT);
- adc_off (ADC1);
+ adc_power_off (ADC1);
adc_disable_scan_mode (ADC1);
adc_enable_temperature_sensor();
diff --git a/app/cdcacm.c b/app/cdcacm.c
index af45ac6..5327c0a 100644
--- a/app/cdcacm.c
+++ b/app/cdcacm.c
@@ -122,35 +122,36 @@ const struct usb_iface_assoc_descriptor cdc_iface_assoc = {
-int cdcacm_control_request (usbd_device *usbd_dev,
- struct usb_setup_data *req,
- uint8_t **buf,
- uint16_t *len,
- usbd_control_complete_callback *complete)
-{
+enum usbd_request_return_codes
+cdcacm_control_request (usbd_device *usbd_dev,
+ struct usb_setup_data *req,
+ uint8_t **buf,
+ uint16_t *len,
+ usbd_control_complete_callback *complete) {
(void) complete;
(void) buf;
(void) usbd_dev;
- switch (req->bRequest) {
+ switch (req->bRequest)
+ {
case USB_CDC_REQ_SET_CONTROL_LINE_STATE: {
/*
* This Linux cdc_acm driver requires this to be implemented
* even though it's optional in the CDC spec, and we don't
* advertise it in the ACM functional descriptor.
*/
- return 1;
+ return USBD_REQ_HANDLED;
}
case USB_CDC_REQ_SET_LINE_CODING:
if (*len < sizeof (struct usb_cdc_line_coding))
- return 0;
+ return USBD_REQ_NOTSUPP;
- return 1;
+ return USBD_REQ_HANDLED;
}
- return 0;
+ return USBD_REQ_NEXT_CALLBACK;
}
diff --git a/app/dfu.c b/app/dfu.c
index 08e3bf9..8e72e3f 100644
--- a/app/dfu.c
+++ b/app/dfu.c
@@ -36,7 +36,7 @@ const struct usb_iface_assoc_descriptor dfu_iface_assoc = {
};
-static int
+static void
dfu_detach_complete (usbd_device *usbd_dev, struct usb_setup_data *req)
{
(void) req;
@@ -48,23 +48,21 @@ dfu_detach_complete (usbd_device *usbd_dev, struct usb_setup_data *req)
//SCB_AIRCR= SCB_AIRCR_SYSRESETREQ;
scb_reset_core();
- return 1;
}
-int
+enum usbd_request_return_codes
dfu_control_request (usbd_device *usbd_dev, struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
- usbd_control_complete_callback *complete)
-{
+ usbd_control_complete_callback *complete) {
(void) buf;
(void) len;
(void) usbd_dev;
- if ((req->bmRequestType & 0x7F) != 0x21) {
- return 0; /* Only accept class request. */
- }
+ if ((req->bmRequestType & 0x7F) != 0x21)
+ return USBD_REQ_NEXT_CALLBACK;
- switch (req->bRequest) {
+ switch (req->bRequest)
+ {
case DFU_GETSTATUS: {
(*buf) [0] = DFU_STATUS_OK;
(*buf) [1] = 0;
@@ -73,20 +71,20 @@ dfu_control_request (usbd_device *usbd_dev, struct usb_setup_data *req,
(*buf) [4] = STATE_APP_IDLE;
(*buf) [5] = 0; /* iString not used here */
*len = 6;
- return 1;
+ return USBD_REQ_HANDLED;
}
case DFU_GETSTATE:
/* Return state with no state transision. */
*buf[0] = STATE_APP_IDLE;
*len = 1;
- return 1;
+ return USBD_REQ_HANDLED;
case DFU_DETACH:
*complete = dfu_detach_complete;
- return 1;
+ return USBD_REQ_HANDLED;
}
- return 0;
+ return USBD_REQ_NEXT_CALLBACK;
}
diff --git a/app/gdbfl.script b/app/gdbfl.script
new file mode 100644
index 0000000..11f7bc5
--- /dev/null
+++ b/app/gdbfl.script
@@ -0,0 +1,2 @@
+target remote tick:3333
+cont
diff --git a/app/main.c b/app/main.c
index da5ffb8..18baed1 100644
--- a/app/main.c
+++ b/app/main.c
@@ -84,160 +84,25 @@ static void cmd_dispatch (void)
}
-#if 0
-static void pd_port (uint32_t p)
-{
- unsigned c;
-
- for (c = 0; c < 32; ++c) {
-
- if ((p == GPIOA) && ((c == 13) || (c == 14))) continue;
-
- gpio_mode_setup (p, GPIO_MODE_INPUT, GPIO_PUPD_NONE, 1UL << c);
- }
-}
-
-
-static void pd_clear (uint32_t g, uint32_t b)
-{
- gpio_mode_setup (g, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, b);
- gpio_set_output_options (g, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, b);
- gpio_clear (g, b);
-}
-
-
-static void pd_set (uint32_t g, uint32_t b)
-{
- gpio_mode_setup (g, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, b);
- gpio_set_output_options (g, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, b);
- gpio_set (g, b);
-}
-
-
-static void pd (void)
-{
- pd_port (GPIOA);
- pd_port (GPIOB);
- pd_port (GPIOC);
- pd_port (GPIOD);
- pd_port (GPIOE);
- pd_port (GPIOF);
- pd_port (GPIOG);
-
-
- pd_set (GPIOB, GPIO10);
-
- pd_set (GPIOG, GPIO4);
- pd_set (GPIOD, GPIO10);
-
- pd_set (GPIOD, GPIO1);
- pd_set (GPIOB, GPIO13);
-
- pd_set (GPIOE, GPIO3);
- pd_set (GPIOE, GPIO4);
-
-
- rcc_periph_clock_disable (RCC_ETHMACPTP);
- rcc_periph_clock_disable (RCC_ETHMACRX);
- rcc_periph_clock_disable (RCC_ETHMACTX);
- rcc_periph_clock_disable (RCC_ETHMAC);
- rcc_periph_clock_disable (RCC_USART2);
- rcc_periph_clock_disable (RCC_USART1);
- rcc_periph_clock_disable (RCC_GPIOG);
- rcc_periph_clock_disable (RCC_GPIOF);
- rcc_periph_clock_disable (RCC_GPIOE);
- rcc_periph_clock_disable (RCC_GPIOD);
- rcc_periph_clock_disable (RCC_GPIOC);
- rcc_periph_clock_disable (RCC_GPIOB);
- rcc_periph_clock_disable (RCC_GPIOA);
- rcc_periph_clock_disable (RCC_SYSCFG);
-
-
-
- for (;;);
-}
-#endif
-
-
-static const clock_scale_t hse_10mhz_3v3_168 = {
- /* 168MHz */
+const struct rcc_clock_scale hse_10mhz_3v3_168 = {
.pllm = 10,
.plln = 336,
.pllp = 2,
.pllq = 7,
- .hpre = RCC_CFGR_HPRE_DIV_NONE,
- .ppre1 = RCC_CFGR_PPRE_DIV_4,
- .ppre2 = RCC_CFGR_PPRE_DIV_2,
- .flash_config = FLASH_ACR_ICE | FLASH_ACR_DCE |
+ .pllr = 0,
+ .pll_source = RCC_CFGR_PLLSRC_HSE_CLK,
+ .hpre = RCC_CFGR_HPRE_NODIV,
+ .ppre1 = RCC_CFGR_PPRE_DIV4,
+ .ppre2 = RCC_CFGR_PPRE_DIV2,
+ .voltage_scale = PWR_SCALE1,
+ .flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_5WS,
+ .ahb_frequency = 168000000,
.apb1_frequency = 42000000,
.apb2_frequency = 84000000,
};
-#if 0
-static const clock_scale_t hse_10mhz_3v3_120 = {
- /* 120 */
- .pllm = 10,
- .plln = 240,
- .pllp = 2,
- .pllq = 5,
- .hpre = RCC_CFGR_HPRE_DIV_NONE,
- .ppre1 = RCC_CFGR_PPRE_DIV_4,
- .ppre2 = RCC_CFGR_PPRE_DIV_2,
- .power_save = 1,
- .flash_config = FLASH_ACR_ICE | FLASH_ACR_DCE |
- FLASH_ACR_LATENCY_3WS,
- .apb1_frequency = 30000000,
- .apb2_frequency = 60000000,
-};
-
-static const clock_scale_t hse_10mhz_3v3_84 = {
- .pllm = 10,
- .plln = 336,
- .pllp = 4,
- .pllq = 7,
- .hpre = RCC_CFGR_HPRE_DIV_NONE,
- .ppre1 = RCC_CFGR_PPRE_DIV_2,
- .ppre2 = RCC_CFGR_PPRE_DIV_NONE,
- .flash_config = FLASH_ACR_ICE | FLASH_ACR_DCE |
- FLASH_ACR_LATENCY_2WS,
- .apb1_frequency = 42000000,
- .apb2_frequency = 84000000,
-};
-
-
-static const clock_scale_t hse_10mhz_3v3_48 = {
- .pllm = 10,
- .plln = 96,
- .pllp = 2,
- .pllq = 2,
- .hpre = RCC_CFGR_HPRE_DIV_NONE,
- .ppre1 = RCC_CFGR_PPRE_DIV_4,
- .ppre2 = RCC_CFGR_PPRE_DIV_2,
- .power_save = 1,
- .flash_config = FLASH_ACR_ICE | FLASH_ACR_DCE |
- FLASH_ACR_LATENCY_3WS,
- .apb1_frequency = 12000000,
- .apb2_frequency = 24000000,
-};
-
-static const clock_scale_t hse_10mhz_3v3_10 = {
- /* 10 */
- .pllm = 10,
- .plln = 336,
- .pllp = 2,
- .pllq = 7,
- .hpre = RCC_CFGR_HPRE_DIV_NONE,
- .ppre1 = RCC_CFGR_PPRE_DIV_NONE,
- .ppre2 = RCC_CFGR_PPRE_DIV_NONE,
- .flash_config = FLASH_ACR_ICE | FLASH_ACR_DCE | FLASH_ACR_LATENCY_0WS,
- // .ahb_frequency = 10000000,
- .apb1_frequency = 10000000,
- .apb2_frequency = 10000000,
-};
-
-#endif
static void ptp_clock_start (void)
{
@@ -268,23 +133,23 @@ static void clock_setup (void)
*/
/*Get us up and running on the 16MHz RC clock */
- rcc_osc_on (HSI);
- rcc_wait_for_osc_ready (HSI);
+ rcc_osc_on (RCC_HSI);
+ rcc_wait_for_osc_ready (RCC_HSI);
/* Select HSI as SYSCLK source. */
rcc_set_sysclk_source (RCC_CFGR_SW_HSI);
/* confiure HSE as input not oscillator */
- rcc_osc_bypass_enable (HSE);
- rcc_osc_on (HSE);
+ rcc_osc_bypass_enable (RCC_HSE);
+ rcc_osc_on (RCC_HSE);
while ((RCC_CR & RCC_CR_HSERDY) == 0) {
if (fail++ == 4000000) {
/*No external clock, try seeing if we have a crystal */
- rcc_osc_off (HSE);
- rcc_osc_bypass_disable (HSE);
- rcc_osc_on (HSE);
+ rcc_osc_off (RCC_HSE);
+ rcc_osc_bypass_disable (RCC_HSE);
+ rcc_osc_on (RCC_HSE);
}
}
@@ -299,8 +164,7 @@ static void clock_setup (void)
RCC_CFGR &= ~ (RCC_CFGR_MCOPRE_DIV_5 << RCC_CFGR_MCO1PRE_SHIFT);
RCC_CFGR |= RCC_CFGR_MCOPRE_DIV_NONE << RCC_CFGR_MCO1PRE_SHIFT;
- rcc_clock_setup_hse_3v3 (&hse_10mhz_3v3_168);
- /* rcc_clock_setup_hse_3v3_no_pll (&hse_10mhz_3v3_10); */
+ rcc_clock_setup_pll (&hse_10mhz_3v3_168);
}
@@ -340,7 +204,7 @@ static void timer_setup (void)
*/
- timer_reset (TIM1);
+ rcc_periph_reset_pulse (RST_TIM1);
timer_set_mode (TIM1, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); /* meh */
timer_slave_set_filter (TIM1, TIM_SMCR_ETF_OFF); /* No filter */
timer_slave_set_prescaler (TIM1, TIM_SMCR_ETPS_OFF); /* no prescaler */
@@ -349,7 +213,7 @@ static void timer_setup (void)
timer_set_master_mode (TIM1, TIM_CR2_MMS_RESET); /* output reset on TRGO */
timer_enable_counter (TIM1); /* go */
- timer_reset (TIM2);
+ rcc_periph_reset_pulse (RST_TIM2);
timer_set_mode (TIM2, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); /* count up with clock*/
timer_slave_set_filter (TIM2, TIM_SMCR_ETF_OFF); /*no filter*/
timer_slave_set_prescaler (TIM2, TIM_SMCR_ETPS_OFF); /*no prescaler */
@@ -367,7 +231,7 @@ static void timer_setup (void)
MAP_AF (REFCLK_IN, GPIO_AF1);
- timer_reset (TIM2);
+ rcc_periph_reset_pulse (RST_TIM2);
timer_set_mode (TIM2, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); /* count up with clock*/
timer_slave_set_filter (TIM2, TIM_SMCR_ETF_OFF); /*no filter*/
timer_slave_set_prescaler (TIM2, TIM_SMCR_ETPS_OFF); /*no prescaler */
diff --git a/app/project.h b/app/project.h
index fcf16ce..cfa58a4 100644
--- a/app/project.h
+++ b/app/project.h
@@ -10,6 +10,7 @@
#include <libopencm3/cm3/systick.h>
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/cm3/cortex.h>
+#include <libopencm3/cm3/dwt.h>
#include <libopencm3/cm3/scs.h>
#include <libopencm3/cm3/scb.h>
/* SoC */
@@ -23,10 +24,11 @@
#include <libopencm3/stm32/adc.h>
#include <libopencm3/stm32/exti.h>
#include <libopencm3/stm32/pwr.h>
+#include <libopencm3/stm32/common/timer_common_all.h>
#include <libopencm3/stm32/timer.h>
#include <libopencm3/stm32/syscfg.h>
-#include <libopencm3/stm32/otg_common.h>
-#include <libopencm3/stm32/otg_fs.h>
+#include <libopencm3/usb/dwc/otg_common.h>
+#include <libopencm3/usb/dwc/otg_fs.h>
#include <libopencm3/stm32/desig.h>
/* Drivers */
#include <libopencm3/ethernet/mac_stm32fxx7.h>
diff --git a/app/prototypes.h b/app/prototypes.h
index e6b631b..d6ce3ad 100644
--- a/app/prototypes.h
+++ b/app/prototypes.h
@@ -68,6 +68,7 @@ extern void pll_dispatch(uint64_t happy, uint64_t edge, uint64_t ptp_edge, const
extern void pll_check(void);
/* main.c */
extern int time_known;
+extern const struct rcc_clock_scale hse_10mhz_3v3_168;
extern int main(void);
/* time_fn.c */
extern UTC time_epoch_to_utc(EPOCH epoch);
@@ -130,7 +131,7 @@ extern ring_t cdcacm_tx_ring;
extern const struct usb_interface_descriptor comm_iface;
extern const struct usb_interface_descriptor data_iface;
extern const struct usb_iface_assoc_descriptor cdc_iface_assoc;
-extern int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, usbd_control_complete_callback *complete);
+extern enum usbd_request_return_codes cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, usbd_control_complete_callback *complete);
extern void cdcacm_tick(void);
extern int cdcacm_write(char *ptr, int len, int blocking);
extern void cdcacm_set_config(usbd_device *usbd_dev, uint16_t wValue);
@@ -139,12 +140,13 @@ extern void cdcacm_rings_init(void);
extern uint8_t usbd_control_buffer[128];
extern usbd_device *usb_device;
extern void otg_fs_isr(void);
+extern enum usbd_request_return_codes usbdfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, usbd_control_complete_callback *complete);
extern void usb_init(void);
/* dfu.c */
extern const struct usb_dfu_descriptor dfu_function;
extern const struct usb_interface_descriptor dfu_iface;
extern const struct usb_iface_assoc_descriptor dfu_iface_assoc;
-extern int dfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, usbd_control_complete_callback *complete);
+extern enum usbd_request_return_codes dfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, usbd_control_complete_callback *complete);
/* adc.c */
extern uint8_t pot_brightness;
extern void adc_dispatch(void);
diff --git a/app/sysclk.c b/app/sysclk.c
index 98b5ed8..d61ab22 100644
--- a/app/sysclk.c
+++ b/app/sysclk.c
@@ -7,7 +7,7 @@ static Event_ring sysclk_ring;
void sysclk_event (void)
{
uint32_t refclk_now = HW_CLOCK_REG;
- uint32_t sysclk_now = SCS_DWT_CYCCNT;
+ uint32_t sysclk_now = DWT_CYCCNT;
sysclk_ring.events[sysclk_ring.tx_ptr].when = refclk_now;
diff --git a/app/ticker.c b/app/ticker.c
index 791839e..4df9806 100644
--- a/app/ticker.c
+++ b/app/ticker.c
@@ -80,6 +80,6 @@ ticker_init (void)
} while (w);
SCS_DEMCR |= SCS_DEMCR_TRCENA;
- SCS_DWT_CTRL |= SCS_DWT_CTRL_CYCCNTENA;
+ DWT_CTRL |= DWT_CTRL_CYCCNTENA;
}
diff --git a/app/usb.c b/app/usb.c
index fc9e6ea..d1fb625 100644
--- a/app/usb.c
+++ b/app/usb.c
@@ -77,16 +77,25 @@ void otg_fs_isr (void)
}
-static int control_request (usbd_device *usbd_dev,
- struct usb_setup_data *req,
- uint8_t **buf,
- uint16_t *len,
- usbd_control_complete_callback *complete)
+static enum usbd_request_return_codes control_request (usbd_device *usbd_dev,
+ struct usb_setup_data *req,
+ uint8_t **buf,
+ uint16_t *len,
+ usbd_control_complete_callback *complete)
{
- if (dfu_control_request (usbd_dev, req, buf, len, complete))
- return 1;
+ enum usbd_request_return_codes ret;
- return cdcacm_control_request (usbd_dev, req, buf, len, complete);
+ ret = dfu_control_request (usbd_dev, req, buf, len, complete);
+
+ if (ret != USBD_REQ_NEXT_CALLBACK)
+ return ret;
+
+ ret = cdcacm_control_request (usbd_dev, req, buf, len, complete);
+
+ if (ret != USBD_REQ_NEXT_CALLBACK)
+ return ret;
+
+ return USBD_REQ_NOTSUPP;
}
static void set_config (usbd_device *usbd_dev, uint16_t wValue)
diff --git a/boot/bootloader.c b/boot/bootloader.c
index a5932f0..3bc7344 100644
--- a/boot/bootloader.c
+++ b/boot/bootloader.c
@@ -25,69 +25,23 @@
static const clock_scale_t hsi_16mhz_3v3_48 = {
- /* 48MHz */
- .pllm = 16,
- .plln = 96,
- .pllp = 2,
- .pllq = 2,
- .hpre = RCC_CFGR_HPRE_DIV_NONE,
- .ppre1 = RCC_CFGR_PPRE_DIV_4,
- .ppre2 = RCC_CFGR_PPRE_DIV_2,
- .power_save = 1,
- .flash_config = FLASH_ACR_ICE | FLASH_ACR_DCE |
- FLASH_ACR_LATENCY_3WS,
- .apb1_frequency = 12000000,
- .apb2_frequency = 24000000,
+ .pllm = 16,
+ .plln = 96,
+ .pllp = 2,
+ .pllq = 2,
+ .pllr = 0,
+ .pll_source = RCC_CFGR_PLLSRC_HSI_CLK,
+ .hpre = RCC_CFGR_HPRE_NODIV,
+ .ppre1 = RCC_CFGR_PPRE_DIV4,
+ .ppre2 = RCC_CFGR_PPRE_DIV2,
+ .voltage_scale = PWR_SCALE1,
+ .flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
+ FLASH_ACR_LATENCY_3WS,
+ .ahb_frequency = 48000000,
+ .apb1_frequency = 12000000,
+ .apb2_frequency = 24000000,
};
-static void rcc_clock_setup_hsi_3v3 (const clock_scale_t *clock)
-{
-
- /* Enable internal high-speed oscillator. */
- rcc_osc_on (HSI);
- rcc_wait_for_osc_ready (HSI);
-
- /* Select HSI as SYSCLK source. */
- rcc_set_sysclk_source (RCC_CFGR_SW_HSI);
- rcc_wait_for_sysclk_status (HSI);
-
- rcc_osc_off (PLL);
-
- while (RCC_CR & RCC_CR_PLLRDY);
-
- pwr_set_vos_scale (SCALE1);
-
- /*
- * Set prescalers for AHB, ADC, ABP1, ABP2.
- * Do this before touching the PLL (TODO: why?).
- */
- rcc_set_hpre (clock->hpre);
- rcc_set_ppre1 (clock->ppre1);
- rcc_set_ppre2 (clock->ppre2);
-
- rcc_set_main_pll_hsi (clock->pllm, clock->plln,
- clock->pllp, clock->pllq);
-
- /* Enable PLL oscillator and wait for it to stabilize. */
- rcc_osc_on (PLL);
- rcc_wait_for_osc_ready (PLL);
-
- /* Configure flash settings. */
- flash_set_ws (clock->flash_config);
-
- /* Select PLL as SYSCLK source. */
- rcc_set_sysclk_source (RCC_CFGR_SW_PLL);
-
- /* Wait for PLL clock to be selected. */
- rcc_wait_for_sysclk_status (PLL);
-
- /* Set the peripheral clock frequencies used. */
- rcc_apb1_frequency = clock->apb1_frequency;
- rcc_apb2_frequency = clock->apb2_frequency;
-
-}
-
-
int main (void)
{
@@ -126,7 +80,8 @@ int main (void)
rcc_periph_clock_enable (RCC_SYSCFG);
- rcc_clock_setup_hsi_3v3 (&hsi_16mhz_3v3_48);
+
+ rcc_clock_setup_pll (&hsi_16mhz_3v3_48);
RCC_AHB1RSTR |= RCC_AHB1RSTR_ETHMACRST;
RCC_AHB2RSTR |= RCC_AHB2RSTR_OTGFSRST;
diff --git a/boot/dfu.c b/boot/dfu.c
index 4054520..138c6f8 100644
--- a/boot/dfu.c
+++ b/boot/dfu.c
@@ -80,7 +80,7 @@ static uint8_t usbdfu_getstatus (usbd_device *usbd_dev, uint32_t *bwPollTimeout)
}
}
-static int usbdfu_getstatus_complete (usbd_device *usbd_dev, struct usb_setup_data *req)
+static void usbdfu_getstatus_complete (usbd_device *usbd_dev, struct usb_setup_data *req)
{
unsigned i;
(void)req;
@@ -123,37 +123,37 @@ static int usbdfu_getstatus_complete (usbd_device *usbd_dev, struct usb_setup_da
/* Jump straight to dfuDNLOAD-IDLE, skipping dfuDNLOAD-SYNC. */
usbdfu_state = STATE_DFU_DNLOAD_IDLE;
- return 0;
+ return ;
case STATE_DFU_MANIFEST:
/* USB device must detach, we just reset... */
scb_reset_system();
- return 0; /* Will never return. */
+ return ; /* Will never return. */
default:
- return 0;
+ ;
}
}
-int usbdfu_control_request (usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf,
- uint16_t *len, int (**complete) (usbd_device *usbd_dev, struct usb_setup_data *req))
+enum usbd_request_return_codes usbdfu_control_request (usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf,
+ uint16_t *len, usbd_control_complete_callback *complete)
{
if ((req->bmRequestType & 0x7F) != 0x21)
- return 0; /* Only accept class request. */
+ return USBD_REQ_NEXT_CALLBACK; /* Only accept class request. */
switch (req->bRequest) {
case DFU_DNLOAD:
if ((len == NULL) || (*len == 0)) {
usbdfu_state = STATE_DFU_MANIFEST_SYNC;
- return 1;
+ return USBD_REQ_HANDLED;
} else {
/* Copy download data for use on GET_STATUS. */
prog.blocknum = req->wValue;
prog.len = *len;
memcpy (prog.buf, *buf, *len);
usbdfu_state = STATE_DFU_DNLOAD_SYNC;
- return 1;
+ return USBD_REQ_HANDLED;
}
case DFU_CLRSTATUS:
@@ -162,16 +162,16 @@ int usbdfu_control_request (usbd_device *usbd_dev, struct usb_setup_data *req, u
if (usbdfu_state == STATE_DFU_ERROR)
usbdfu_state = STATE_DFU_IDLE;
- return 1;
+ return USBD_REQ_HANDLED;
case DFU_ABORT:
/* Abort returns to dfuIDLE state. */
usbdfu_state = STATE_DFU_IDLE;
- return 1;
+ return USBD_REQ_HANDLED;
case DFU_UPLOAD:
/* Upload not supported for now. */
- return 0;
+ return USBD_REQ_NOTSUPP;
case DFU_GETSTATUS: {
uint32_t bwPollTimeout = 0; /* 24-bit integer in DFU class spec */
@@ -183,17 +183,17 @@ int usbdfu_control_request (usbd_device *usbd_dev, struct usb_setup_data *req, u
(*buf)[5] = 0; /* iString not used here */
*len = 6;
*complete = usbdfu_getstatus_complete;
- return 1;
+ return USBD_REQ_HANDLED;
}
case DFU_GETSTATE:
/* Return state with no state transision. */
*buf[0] = usbdfu_state;
*len = 1;
- return 1;
+ return USBD_REQ_HANDLED;
}
- return 0;
+ return USBD_REQ_NEXT_CALLBACK;
}
diff --git a/boot/project.h b/boot/project.h
index 5699389..4c3a92c 100644
--- a/boot/project.h
+++ b/boot/project.h
@@ -2,8 +2,8 @@
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/flash.h>
-#include <libopencm3/stm32/otg_common.h>
-#include <libopencm3/stm32/otg_fs.h>
+#include <libopencm3/usb/dwc/otg_common.h>
+#include <libopencm3/usb/dwc/otg_fs.h>
#include <libopencm3/stm32/pwr.h>
#include <libopencm3/stm32/syscfg.h>
#include <libopencm3/stm32/usart.h>
@@ -27,3 +27,5 @@ extern uint32_t dfu_flag;
#define APP_ADDRESS 0x08004000
+
+typedef struct rcc_clock_scale clock_scale_t;
diff --git a/boot/prototypes.h b/boot/prototypes.h
index 74f6b60..40ae6c5 100644
--- a/boot/prototypes.h
+++ b/boot/prototypes.h
@@ -10,7 +10,7 @@ extern void usb(void);
/* dfu.c */
extern const struct usb_dfu_descriptor dfu_function;
extern const struct usb_interface_descriptor dfu_iface;
-extern int usbdfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, int (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req));
+extern enum usbd_request_return_codes usbdfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req));
/* delay.c */
extern void sys_tick_handler(void);
extern void ticker_on(void);
diff --git a/libopencm3 b/libopencm3
-Subproject 5c73d601763dd140bff020be8d6d06f03c2bea7
+Subproject a9cc6953817e0de1cad06662ce58a81607cd796