aboutsummaryrefslogtreecommitdiff
path: root/include/libopenstm32
diff options
context:
space:
mode:
authorUwe Hermann2010-11-02 02:02:21 +0100
committerUwe Hermann2010-11-02 02:02:21 +0100
commit6e090ccee16582f0c152c95238753562732788e3 (patch)
treedc81ec432c2144af3c01803be2c953005048cd36 /include/libopenstm32
parent1621fde1f47c5b5f86942562b955bebfb45683df (diff)
Initial USB device stack for STM32.
Patch provided by Gareth McMullin <gareth@blacksphere.co.nz>, thanks a lot!
Diffstat (limited to 'include/libopenstm32')
-rw-r--r--include/libopenstm32/rcc.h2
-rw-r--r--include/libopenstm32/scb.h3
-rw-r--r--include/libopenstm32/tools.h4
-rw-r--r--include/libopenstm32/usb.h6
4 files changed, 12 insertions, 3 deletions
diff --git a/include/libopenstm32/rcc.h b/include/libopenstm32/rcc.h
index 00ec0ef..c108dd8 100644
--- a/include/libopenstm32/rcc.h
+++ b/include/libopenstm32/rcc.h
@@ -396,8 +396,10 @@ void rcc_set_adcpre(u32 adcpre);
void rcc_set_ppre2(u32 ppre2);
void rcc_set_ppre1(u32 ppre1);
void rcc_set_hpre(u32 hpre);
+void rcc_set_usbpre(u32 usbpre);
u32 rcc_get_system_clock_source(int i);
void rcc_clock_setup_in_hsi_out_64mhz(void);
+void rcc_clock_setup_in_hsi_out_48mhz(void);
void rcc_clock_setup_in_hse_8mhz_out_72mhz(void);
void rcc_clock_setup_in_hse_16mhz_out_72mhz(void);
void rcc_backupdomain_reset(void);
diff --git a/include/libopenstm32/scb.h b/include/libopenstm32/scb.h
index 17d892f..44d7d23 100644
--- a/include/libopenstm32/scb.h
+++ b/include/libopenstm32/scb.h
@@ -122,6 +122,7 @@
/* VECTKEYSTAT[31:16]/ VECTKEY[31:16] Register key */
#define SCB_AIRCR_VECTKEYSTAT_LSB 16
+#define SCB_AIRCR_VECTKEY 0x05FA0000
/* ENDIANESS Data endianness bit */
#define SCB_AIRCR_ENDIANESS (1 << 15)
/* Bits [14:11]: reserved - must be kept cleared */
@@ -291,6 +292,8 @@
/* BFAR [31:0]: Bus fault address */
/* --- SCB functions ------------------------------------------------------- */
+void scb_reset_core(void);
+void scb_reset_system(void);
/* TODO: */
diff --git a/include/libopenstm32/tools.h b/include/libopenstm32/tools.h
index 54c3ce7..2a7a0f1 100644
--- a/include/libopenstm32/tools.h
+++ b/include/libopenstm32/tools.h
@@ -51,7 +51,7 @@
* TODO: We may need a faster implementation of that one?
*/
#define TOG_SET_REG_BIT_MSK(REG, MSK, BIT) \
-{ \
+do { \
register u16 toggle_mask = GET_REG(REG) & MSK; \
register u16 bit_selector; \
for (bit_selector = 1; bit_selector; bit_selector <<= 1) { \
@@ -59,6 +59,6 @@
toggle_mask ^= bit_selector; \
} \
SET_REG(REG, toggle_mask); \
-}
+} while(0)
#endif
diff --git a/include/libopenstm32/usb.h b/include/libopenstm32/usb.h
index 342b9a6..3e0efe9 100644
--- a/include/libopenstm32/usb.h
+++ b/include/libopenstm32/usb.h
@@ -20,6 +20,10 @@
#ifndef LIBOPENSTM32_USB_H
#define LIBOPENSTM32_USB_H
+#include <libopenstm32/memorymap.h>
+#include <libopenstm32/common.h>
+#include <libopenstm32/tools.h>
+
/******************************************************************************
* USB base addresses
******************************************************************************/
@@ -42,7 +46,7 @@
/* USB Buffer table address register */
#define USB_BTABLE_REG ((volatile u32 *)(USB_DEV_FS_BASE + 0x50))
/* USB EP register */
-#define USB_EP_REG(EP) ((volatile u32 *)(USB_DEV_FS_BASE + EP))
+#define USB_EP_REG(EP) ((volatile u32 *)(USB_DEV_FS_BASE) + (EP))
/******************************************************************************
* USB control register masks / bits