From 368e4fc1662c2594b2a0908900713a2555a3ed8e Mon Sep 17 00:00:00 2001 From: Michael Hope Date: Wed, 29 Sep 2010 20:42:18 +1300 Subject: Fixed up the build due to a missing header file. --- wirish/time.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'wirish') diff --git a/wirish/time.h b/wirish/time.h index ad39057..f4612fa 100644 --- a/wirish/time.h +++ b/wirish/time.h @@ -29,14 +29,15 @@ #ifndef _TIME_H #define _TIME_H -#ifdef __cplusplus -extern "C"{ -#endif - +#include "libmaple.h" #include "nvic.h" #include "systick.h" #include "boards.h" +#ifdef __cplusplus +extern "C"{ +#endif + #define US_PER_MS 1000 extern volatile uint32 systick_timer_millis; -- cgit v1.2.3 From 76e8745d80a822d9ae9a017c8f68a2f7f20695fc Mon Sep 17 00:00:00 2001 From: Michael Hope Date: Sun, 10 Oct 2010 19:58:58 +1300 Subject: Make systick.h C++ safe. Expose the sys tick count via systick.h and remove other externs. --- libmaple/systick.c | 5 ++--- libmaple/systick.h | 9 ++++++--- wirish/time.h | 2 -- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'wirish') diff --git a/libmaple/systick.c b/libmaple/systick.c index 12a3e22..2b09a64 100644 --- a/libmaple/systick.c +++ b/libmaple/systick.c @@ -39,7 +39,7 @@ #define SYSTICK_TICKINT BIT(1) // Interrupt on systick countdown #define SYSTICK_ENABLE BIT(0) // Turn on the counter -volatile uint32 systick_timer_millis = 0; +volatile uint32 systick_timer_millis; void systick_init(uint32 reload_val) { /* Set the reload counter to tick every 1ms */ @@ -65,8 +65,7 @@ void systick_resume() { SYSTICK_TICKINT); } +/** SysTick interrupt handler. Bumps up the tick counter. */ void SysTickHandler(void) { systick_timer_millis++; } - - diff --git a/libmaple/systick.h b/libmaple/systick.h index 7ec8497..ae1268a 100644 --- a/libmaple/systick.h +++ b/libmaple/systick.h @@ -33,14 +33,17 @@ #include "libmaple.h" +#ifdef __cplusplus +extern "C"{ +#endif + #define SYSTICK_CSR 0xE000E010 // Control and status register #define SYSTICK_CNT 0xE000E018 // Current value register #define SYSTICK_CSR_COUNTFLAG BIT(16) -#ifdef __cplusplus -extern "C"{ -#endif +/** System elapsed time in milliseconds */ +volatile uint32 systick_timer_millis; void systick_init(uint32 reload_val); void systick_disable(); diff --git a/wirish/time.h b/wirish/time.h index 742f28d..2a561d3 100644 --- a/wirish/time.h +++ b/wirish/time.h @@ -40,8 +40,6 @@ extern "C"{ #define US_PER_MS 1000 -extern volatile uint32 systick_timer_millis; - /* time in milliseconds since boot */ static inline uint32 millis(void) { return systick_timer_millis; -- cgit v1.2.3 From 2e7fa60e435469d102522b0bc490ef4f21bbb989 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Mon, 31 Jan 2011 00:19:36 -0500 Subject: nvic bugfix; removed unnecessary volatile usage --- libmaple/exti.c | 2 +- libmaple/nvic.c | 12 ++++++------ wirish/wirish.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'wirish') diff --git a/libmaple/exti.c b/libmaple/exti.c index e806df9..150dd05 100644 --- a/libmaple/exti.c +++ b/libmaple/exti.c @@ -35,7 +35,7 @@ typedef struct ExtIChannel { uint32 irq_line; } ExtIChannel; -volatile static ExtIChannel exti_channels[] = { +static ExtIChannel exti_channels[] = { { .handler = NULL, .irq_line = NVIC_EXTI0 }, // EXTI0 { .handler = NULL, .irq_line = NVIC_EXTI1 }, // EXTI1 { .handler = NULL, .irq_line = NVIC_EXTI2 }, // EXTI2 diff --git a/libmaple/nvic.c b/libmaple/nvic.c index 155da27..b1da605 100644 --- a/libmaple/nvic.c +++ b/libmaple/nvic.c @@ -39,8 +39,8 @@ void nvic_set_vector_table(uint32 addr, uint32 offset) { * @param n interrupt number */ void nvic_irq_enable(uint32 n) { - /* TODO: test */ - __write(BITBAND_PERI(NVIC_ISER0, n), 1); + uint32 *iser = &((uint32*)NVIC_ISER0)[(n/32)]; + __write(iser, BIT(n % 32)); } /** @@ -48,8 +48,8 @@ void nvic_irq_enable(uint32 n) { * @param n interrupt number */ void nvic_irq_disable(uint32 n) { - /* TODO: test */ - __write(BITBAND_PERI(NVIC_ICER0, n), 1); + uint32 *icer = &((uint32*)NVIC_ICER0)[(n/32)]; + __write(icer, BIT(n % 32)); } void nvic_irq_disable_all(void) { @@ -60,8 +60,8 @@ void nvic_irq_disable_all(void) { 64 interrupts, this suffices. */ /* TODO: fix for connectivity line: __write(NVIC_ICER2,1), requires connectivity line support in libmaple.h */ - __write(NVIC_ICER0, 1); - __write(NVIC_ICER1, 1); + __write(NVIC_ICER0, 0xFFFFFFFF); + __write(NVIC_ICER1, 0xFFFFFFFF); } /** diff --git a/wirish/wirish.c b/wirish/wirish.c index 0abec41..89adc1e 100644 --- a/wirish/wirish.c +++ b/wirish/wirish.c @@ -54,7 +54,7 @@ void init(void) { #if NR_DAC_PINS > 0 dac_init(); #endif - + /* initialize clocks */ rcc_clk_init(RCC_CLKSRC_PLL, RCC_PLLSRC_HSE, RCC_PLLMUL_9); rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_1); -- cgit v1.2.3