summaryrefslogtreecommitdiff
path: root/ucoo
diff options
context:
space:
mode:
Diffstat (limited to 'ucoo')
-rw-r--r--ucoo/arch/arch.stm32.cc2
-rw-r--r--ucoo/hal/adc/adc_hard.stm32f4.cc4
-rw-r--r--ucoo/hal/adc/test/test_adc.cc2
-rw-r--r--ucoo/hal/gpio/gpio.stm32f4.hh2
-rw-r--r--ucoo/hal/gpio/test/test_gpio.cc2
-rw-r--r--ucoo/hal/i2c/i2c_hard.stm32.cc4
-rw-r--r--ucoo/hal/i2c/test/test_i2c.cc2
-rw-r--r--ucoo/hal/spi/test/test_spi.cc2
-rw-r--r--ucoo/hal/uart/test/test_uart.cc2
-rw-r--r--ucoo/hal/uart/test/test_uart_disc.cc2
-rw-r--r--ucoo/hal/uart/uart.stm32.cc8
-rw-r--r--ucoo/hal/usb/usb.stm32.cc10
-rw-r--r--ucoo/utils/delay.arm.cc30
-rw-r--r--ucoo/utils/test/test_delay.cc4
14 files changed, 40 insertions, 36 deletions
diff --git a/ucoo/arch/arch.stm32.cc b/ucoo/arch/arch.stm32.cc
index 649091d..e5d5669 100644
--- a/ucoo/arch/arch.stm32.cc
+++ b/ucoo/arch/arch.stm32.cc
@@ -24,7 +24,7 @@
#include "ucoo/arch/arch.hh"
#include "ucoo/common.hh"
-#include <libopencm3/stm32/f4/rcc.h>
+#include <libopencm3/stm32/rcc.h>
#include <libopencm3/cm3/scb.h>
namespace ucoo {
diff --git a/ucoo/hal/adc/adc_hard.stm32f4.cc b/ucoo/hal/adc/adc_hard.stm32f4.cc
index 38661e3..444117f 100644
--- a/ucoo/hal/adc/adc_hard.stm32f4.cc
+++ b/ucoo/hal/adc/adc_hard.stm32f4.cc
@@ -23,8 +23,8 @@
// }}}
#include "adc_hard.stm32f4.hh"
-#include <libopencm3/stm32/f4/adc.h>
-#include <libopencm3/stm32/f4/rcc.h>
+#include <libopencm3/stm32/adc.h>
+#include <libopencm3/stm32/rcc.h>
namespace ucoo {
diff --git a/ucoo/hal/adc/test/test_adc.cc b/ucoo/hal/adc/test/test_adc.cc
index eaaf44e..58cca96 100644
--- a/ucoo/hal/adc/test/test_adc.cc
+++ b/ucoo/hal/adc/test/test_adc.cc
@@ -27,7 +27,7 @@
#include "ucoo/base/test/test.hh"
#include "ucoo/utils/delay.hh"
-#include <libopencm3/stm32/f4/adc.h>
+#include <libopencm3/stm32/adc.h>
#include "ucoo/hal/gpio/gpio.hh"
#include <cstdio>
diff --git a/ucoo/hal/gpio/gpio.stm32f4.hh b/ucoo/hal/gpio/gpio.stm32f4.hh
index b2dfb16..325511e 100644
--- a/ucoo/hal/gpio/gpio.stm32f4.hh
+++ b/ucoo/hal/gpio/gpio.stm32f4.hh
@@ -25,7 +25,7 @@
// }}}
#include "ucoo/intf/io.hh"
-#include <libopencm3/stm32/f4/gpio.h>
+#include <libopencm3/stm32/gpio.h>
namespace ucoo {
diff --git a/ucoo/hal/gpio/test/test_gpio.cc b/ucoo/hal/gpio/test/test_gpio.cc
index a953505..8d70814 100644
--- a/ucoo/hal/gpio/test/test_gpio.cc
+++ b/ucoo/hal/gpio/test/test_gpio.cc
@@ -25,7 +25,7 @@
#include "ucoo/hal/gpio/gpio.hh"
#include "ucoo/utils/delay.hh"
-#include <libopencm3/stm32/f4/rcc.h>
+#include <libopencm3/stm32/rcc.h>
void
test (ucoo::Io &loop_out, ucoo::Io &loop_in, ucoo::Io &led3, ucoo::Io &led4,
diff --git a/ucoo/hal/i2c/i2c_hard.stm32.cc b/ucoo/hal/i2c/i2c_hard.stm32.cc
index 8122d15..a9e8f00 100644
--- a/ucoo/hal/i2c/i2c_hard.stm32.cc
+++ b/ucoo/hal/i2c/i2c_hard.stm32.cc
@@ -24,7 +24,7 @@
#include "i2c_hard.stm32.hh"
#include <libopencm3/stm32/i2c.h>
-#include <libopencm3/stm32/f4/rcc.h>
+#include <libopencm3/stm32/rcc.h>
#include <libopencm3/cm3/nvic.h>
#include "ucoo/utils/trace.hh"
@@ -105,7 +105,7 @@ I2cHard::enable (int speed)
// TODO: make sure the bus is free!!! How!
I2C_CR1 (base) = 0;
// Compute clock parameters.
- int pclk = rcc_ppre1_frequency;
+ int pclk = rcc_apb1_frequency;
int pclk_mhz = pclk / 1000000;
uint16_t ccr, tris;
if (speed <= 100000)
diff --git a/ucoo/hal/i2c/test/test_i2c.cc b/ucoo/hal/i2c/test/test_i2c.cc
index 9f619c2..440edea 100644
--- a/ucoo/hal/i2c/test/test_i2c.cc
+++ b/ucoo/hal/i2c/test/test_i2c.cc
@@ -27,7 +27,7 @@
#include "ucoo/base/test/test.hh"
#ifdef TARGET_stm32
-# include <libopencm3/stm32/f4/rcc.h>
+# include <libopencm3/stm32/rcc.h>
# include "ucoo/hal/gpio/gpio.hh"
#endif
diff --git a/ucoo/hal/spi/test/test_spi.cc b/ucoo/hal/spi/test/test_spi.cc
index 27ca659..188ff40 100644
--- a/ucoo/hal/spi/test/test_spi.cc
+++ b/ucoo/hal/spi/test/test_spi.cc
@@ -28,7 +28,7 @@
#include "ucoo/arch/arch.hh"
#include "ucoo/base/test/test.hh"
-#include <libopencm3/stm32/f4/rcc.h>
+#include <libopencm3/stm32/rcc.h>
#include <algorithm>
#include <cstdio>
diff --git a/ucoo/hal/uart/test/test_uart.cc b/ucoo/hal/uart/test/test_uart.cc
index 2c326f3..785d9f1 100644
--- a/ucoo/hal/uart/test/test_uart.cc
+++ b/ucoo/hal/uart/test/test_uart.cc
@@ -26,7 +26,7 @@
#include "ucoo/arch/arch.hh"
#if defined (TARGET_stm32)
-# include <libopencm3/stm32/f4/rcc.h>
+# include <libopencm3/stm32/rcc.h>
# include "ucoo/hal/gpio/gpio.hh"
#endif
diff --git a/ucoo/hal/uart/test/test_uart_disc.cc b/ucoo/hal/uart/test/test_uart_disc.cc
index e2d307a..b67894b 100644
--- a/ucoo/hal/uart/test/test_uart_disc.cc
+++ b/ucoo/hal/uart/test/test_uart_disc.cc
@@ -27,7 +27,7 @@
#include "ucoo/hal/gpio/gpio.hh"
#include "ucoo/base/test/test.hh"
-#include <libopencm3/stm32/f4/rcc.h>
+#include <libopencm3/stm32/rcc.h>
static void
check_act (ucoo::Stream &ts, ucoo::Stream &u, char n)
diff --git a/ucoo/hal/uart/uart.stm32.cc b/ucoo/hal/uart/uart.stm32.cc
index 14dc849..c62ccac 100644
--- a/ucoo/hal/uart/uart.stm32.cc
+++ b/ucoo/hal/uart/uart.stm32.cc
@@ -23,8 +23,8 @@
// }}}
#include "uart.stm32.hh"
-#include <libopencm3/stm32/f4/usart.h>
-#include <libopencm3/stm32/f4/rcc.h>
+#include <libopencm3/stm32/usart.h>
+#include <libopencm3/stm32/rcc.h>
#include <libopencm3/cm3/nvic.h>
#ifndef TARGET_stm32f4
@@ -107,8 +107,8 @@ Uart::enable (int speed, Parity parity, int stop_bits)
(uart_hardware[n_].apb == 1 ? &RCC_APB1ENR : &RCC_APB2ENR,
uart_hardware[n_].rcc_en);
// Set speed, rounded to nearest.
- int apb_freq = uart_hardware[n_].apb == 1 ? rcc_ppre1_frequency
- : rcc_ppre2_frequency;
+ int apb_freq = uart_hardware[n_].apb == 1 ? rcc_apb1_frequency
+ : rcc_apb2_frequency;
USART_BRR (base) = (2 * apb_freq + speed) / (2 * speed);
// Set parameters and enable.
if (stop_bits == 1)
diff --git a/ucoo/hal/usb/usb.stm32.cc b/ucoo/hal/usb/usb.stm32.cc
index 0410df5..70db92b 100644
--- a/ucoo/hal/usb/usb.stm32.cc
+++ b/ucoo/hal/usb/usb.stm32.cc
@@ -24,14 +24,17 @@
#include "usb.stm32.hh"
#include <algorithm>
-#include <libopencm3/stm32/f4/rcc.h>
-#include <libopencm3/stm32/f4/gpio.h>
+#include <libopencm3/stm32/rcc.h>
+#include <libopencm3/stm32/gpio.h>
#include <libopencm3/cm3/nvic.h>
#include "usb_desc.stm32.h"
static usbd_device *usbdev;
+// Buffer for control requests.
+static uint8_t usb_control_buffer[128];
+
extern "C" {
void
@@ -69,7 +72,8 @@ UsbStreamControl::UsbStreamControl (const char *vendor, const char *product)
GPIO9 | GPIO11 | GPIO12);
gpio_set_af (GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12);
usbdev = usbd_init (&otgfs_usb_driver, &usb_desc_dev, &usb_desc_config,
- strings, lengthof (strings));
+ strings, lengthof (strings),
+ usb_control_buffer, sizeof (usb_control_buffer));
usbd_register_set_config_callback (usbdev, set_config);
nvic_enable_irq (NVIC_OTG_FS_IRQ);
}
diff --git a/ucoo/utils/delay.arm.cc b/ucoo/utils/delay.arm.cc
index 294f5ea..3c66d0d 100644
--- a/ucoo/utils/delay.arm.cc
+++ b/ucoo/utils/delay.arm.cc
@@ -26,7 +26,7 @@
#include <algorithm>
#include <libopencm3/cm3/systick.h>
-#include <libopencm3/stm32/f4/rcc.h>
+#include <libopencm3/stm32/rcc.h>
namespace ucoo {
@@ -36,21 +36,21 @@ delay_us (int us)
// Horrible hack: there is no record of the current systick speed, make
// guesses based on APB2 clock. Also, suppose that frequency is a multiple
// of 1 MHz (to avoid 64 bit division).
- int systick_mhz = rcc_ppre2_frequency / (4 * 1000000);
+ int systick_mhz = rcc_apb2_frequency / (4 * 1000000);
int cycles = systick_mhz * us;
- STK_CTRL = 0;
+ STK_CSR = 0;
// Loop several times if cycles is too big for the systick timer. Some
// nanoseconds are lost every second, I can live with that, it simplifies
// code.
while (cycles)
{
int loop_cycles = std::min (1 << 24, cycles);
- STK_LOAD = loop_cycles - 1;
- STK_VAL = 0;
- STK_CTRL = STK_CTRL_ENABLE;
- while (!(STK_CTRL & STK_CTRL_COUNTFLAG))
+ STK_RVR = loop_cycles - 1;
+ STK_CVR = 0;
+ STK_CSR = STK_CSR_ENABLE;
+ while (!(STK_CSR & STK_CSR_COUNTFLAG))
;
- STK_CTRL = 0;
+ STK_CSR = 0;
cycles -= loop_cycles;
}
}
@@ -61,16 +61,16 @@ delay_ns (int ns)
// Horrible hack: there is no record of the current hclock speed, make
// guesses based on APB2 clock. Also, suppose that frequency is a multiple
// of 1 MHz (to avoid 64 bit division).
- int hclock_mhz = rcc_ppre2_frequency / (1000000 / 2);
+ int hclock_mhz = rcc_apb2_frequency / (1000000 / 2);
int cycles = (hclock_mhz * ns + 999) / 1000;
- STK_CTRL = 0;
+ STK_CSR = 0;
// Loop once, ns is supposed to be small.
- STK_LOAD = cycles - 1;
- STK_VAL = 0;
- STK_CTRL = STK_CTRL_CLKSOURCE_AHB | STK_CTRL_ENABLE;
- while (!(STK_CTRL & STK_CTRL_COUNTFLAG))
+ STK_RVR = cycles - 1;
+ STK_CVR = 0;
+ STK_CSR = STK_CSR_CLKSOURCE_AHB | STK_CSR_ENABLE;
+ while (!(STK_CSR & STK_CSR_COUNTFLAG))
;
- STK_CTRL = 0;
+ STK_CSR = 0;
}
} // namespace ucoo
diff --git a/ucoo/utils/test/test_delay.cc b/ucoo/utils/test/test_delay.cc
index 90a53e5..0894d79 100644
--- a/ucoo/utils/test/test_delay.cc
+++ b/ucoo/utils/test/test_delay.cc
@@ -24,8 +24,8 @@
#include "ucoo/utils/delay.hh"
#include "ucoo/arch/arch.hh"
-#include <libopencm3/stm32/f4/rcc.h>
-#include <libopencm3/stm32/f4/gpio.h>
+#include <libopencm3/stm32/rcc.h>
+#include <libopencm3/stm32/gpio.h>
int
main (int argc, const char **argv)