diff options
author | Perry Hung <iperry@alum.mit.edu> | 2010-03-30 22:50:18 -0400 |
---|---|---|
committer | Perry Hung <iperry@alum.mit.edu> | 2010-03-30 22:51:28 -0400 |
commit | 869ed39e4c28ebb9813a8b28192d4ca92f72bf22 (patch) | |
tree | 6293c34e1dc96ae3f7c0bfdd926a714c03062ae2 /libmaple | |
parent | 2c33d55bae8f9e0e009634072ab05302fc734a65 (diff) | |
download | librambutan-869ed39e4c28ebb9813a8b28192d4ca92f72bf22.tar.gz librambutan-869ed39e4c28ebb9813a8b28192d4ca92f72bf22.zip |
Removed STM32 flash code, replaced with barebones hacks for now.
At this point, there shouldn't be any STM code being compiled and linked
against. There are still a bunch of STM header includes, though.
Diffstat (limited to 'libmaple')
-rw-r--r-- | libmaple/flash.c | 29 | ||||
-rw-r--r-- | libmaple/flash.h | 16 | ||||
-rw-r--r-- | libmaple/nvic.c | 4 | ||||
-rw-r--r-- | libmaple/nvic.h | 2 | ||||
-rw-r--r-- | libmaple/rcc.c | 6 | ||||
-rw-r--r-- | libmaple/usb.h | 1 |
6 files changed, 51 insertions, 7 deletions
diff --git a/libmaple/flash.c b/libmaple/flash.c new file mode 100644 index 0000000..a3ee26b --- /dev/null +++ b/libmaple/flash.c @@ -0,0 +1,29 @@ +#include "libmaple.h" +#include "flash.h" + +#define ACR_PRFTBE ((uint32)0xFFFFFFEF) +#define ACR_PRFTBE_ENABLE ((uint32)0x00000010) /* FLASH Prefetch Buffer Enable */ +#define ACR_PRFTBE_DISABLE ((uint32)0x00000000) /* FLASH Prefetch Buffer Disable */ + +#define ACR_LATENCY ((uint32)0x00000038) +#define ACR_LATENCY_0 ((uint32)0x00000000) /* FLASH Zero Latency cycle */ +#define ACR_LATENCY_1 ((uint32)0x00000001) /* FLASH One Latency cycle */ +#define ACR_LATENCY_2 ((uint32)0x00000002) /* FLASH Two Latency cycles */ + +void flash_enable_prefetch(void) { + uint32 acr = __read(FLASH_ACR); + + acr &= ACR_PRFTBE; + acr |= ACR_PRFTBE_ENABLE; + + __write(FLASH_ACR, acr); +} + +void flash_set_latency(void) { + uint32 acr = __read(FLASH_ACR); + + acr &= ACR_LATENCY; + acr |= ACR_LATENCY_2; + + __write(FLASH_ACR, acr); +} diff --git a/libmaple/flash.h b/libmaple/flash.h new file mode 100644 index 0000000..741a444 --- /dev/null +++ b/libmaple/flash.h @@ -0,0 +1,16 @@ +/** + * @brief + */ + +#ifndef _FLASH_H_ +#define _FLASH_H_ + +#define FLASH_BASE 0x40022000 +#define FLASH_ACR FLASH_BASE + +void flash_enable_prefetch(void); +void flash_set_latency(void); + +#endif + + diff --git a/libmaple/nvic.c b/libmaple/nvic.c index 9b8c84f..45c1902 100644 --- a/libmaple/nvic.c +++ b/libmaple/nvic.c @@ -38,7 +38,7 @@ void nvic_disable_interrupts(void) { void nvic_set_vector_table(uint32_t *addr, uint32_t offset) { -// SCB->VTOR = NVIC_VectTab | (Offset & (u32)0x1FFFFF80); + __write(SCB_VTOR, (uint32_t)addr | (offset & 0x1FFFFF80)); } @@ -57,3 +57,5 @@ void nvic_enable_interrupt(uint32 n) { REG_SET_BIT(NVIC_ISER1, n - 32); } } + + diff --git a/libmaple/nvic.h b/libmaple/nvic.h index 5908e9c..89b66fc 100644 --- a/libmaple/nvic.h +++ b/libmaple/nvic.h @@ -18,8 +18,6 @@ * ****************************************************************************/ /** - * @file nvic.h - * * @brief Nested interrupt controller defines and prototypes */ diff --git a/libmaple/rcc.c b/libmaple/rcc.c index bf76eb0..98b115a 100644 --- a/libmaple/rcc.c +++ b/libmaple/rcc.c @@ -6,8 +6,8 @@ */ #include "libmaple.h" +#include "flash.h" #include "rcc.h" -#include "stm32f10x_flash.h" static void set_ahb_prescaler(uint32_t divider) { uint32_t cfgr = __read(RCC_CFGR); @@ -95,10 +95,10 @@ void rcc_init(void) { /* Leave this here for now... */ /* Enable Prefetch Buffer */ - FLASH_PrefetchBufferCmd( (u32)FLASH_PrefetchBuffer_Enable); + flash_enable_prefetch(); /* Flash 2 wait state */ - FLASH_SetLatency(FLASH_Latency_2); + flash_set_latency(); set_ahb_prescaler(SYSCLK_DIV_1); set_apb1_prescaler(HCLK_DIV_2); diff --git a/libmaple/usb.h b/libmaple/usb.h index 3b7a971..960e1f4 100644 --- a/libmaple/usb.h +++ b/libmaple/usb.h @@ -3,7 +3,6 @@ #include <inttypes.h> #include "util.h" -#include "cortexm3_macro.h" #include "usb_regs.h" #include "bootVect.h" |