From e380aa537a65ea86c98888519132724b9c0492b6 Mon Sep 17 00:00:00 2001 From: Leo C Date: Fri, 21 Apr 2017 17:15:38 +0200 Subject: [PATCH] Rename TIM_IRMP --> IRMP_TIMER --- .gitmodules | 3 ++- Makefile | 1 + irmp | 2 +- irmp-main.c | 57 +++++++++++++++++++++------------------------ libopencm3.rules.mk | 7 +++--- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.gitmodules b/.gitmodules index 4dd8d13..98382bf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,5 @@ url = https://github.com/libopencm3/libopencm3.git [submodule "irmp"] path = irmp - url = http://cloudbase.mooo.com/git/irmp + url = cu.loc:git/irmp + diff --git a/Makefile b/Makefile index 7de5646..19cbdb7 100644 --- a/Makefile +++ b/Makefile @@ -30,5 +30,6 @@ DEFS += -DF_INTERRUPTS=15000 -DIRMP_PROTOCOL_NAMES=1 DEVICE = stm32f103c8t6 OPENCM3_DIR = libopencm3 +LDFLAGS += --specs=nano.specs include libopencm3.target.mk diff --git a/irmp b/irmp index 85fbd0c..13c2473 160000 --- a/irmp +++ b/irmp @@ -1 +1 @@ -Subproject commit 85fbd0c57a5f553cb22cfdec2daaf8c70afdbe96 +Subproject commit 13c24737d1698d551d20baa74681021dc2c0c359 diff --git a/irmp-main.c b/irmp-main.c index f7d213d..6c8fd53 100644 --- a/irmp-main.c +++ b/irmp-main.c @@ -70,13 +70,13 @@ static void setup_clock_and_gpios(void) /* IRMP */ /*--------------------------------------------------------------------------*/ -#define TIM_IRMP_CR1 TIM_CR1(TIM_IRMP) -#define TIM_IRMP_DIER TIM_DIER(TIM_IRMP) -#define TIM_IRMP_SR TIM_SR(TIM_IRMP) -#define TIM_IRMP_ARR TIM_ARR(TIM_IRMP) -#define RCC_TIM_IRMP CONCAT(RCC_TIM, IRMP_TIMER) -#define NVIC_TIM_IRMP_IRQ CONCAT(CONCAT(NVIC_TIM, IRMP_TIMER), _IRQ) -#define IRMP_TIMER_ISR CONCAT(CONCAT(tim, IRMP_TIMER), _isr) +#define IRMP_TIMER_CR1 TIM_CR1(IRMP_TIMER) +#define IRMP_TIMER_DIER TIM_DIER(IRMP_TIMER) +#define IRMP_TIMER_SR TIM_SR(IRMP_TIMER) +#define IRMP_TIMER_ARR TIM_ARR(IRMP_TIMER) +#define RCC_IRMP_TIMER CONCAT(RCC_TIM, IRMP_TIMER_NUMBER) +#define NVIC_IRMP_TIMER_IRQ CONCAT(CONCAT(NVIC_TIM, IRMP_TIMER_NUMBER), _IRQ) +#define IRMP_TIMER_ISR CONCAT(CONCAT(tim, IRMP_TIMER_NUMBER), _isr) /** Retrieve the actual input clock of a timer @@ -87,20 +87,17 @@ static void setup_clock_and_gpios(void) uint32_t timer_internal_clock_get(uint32_t timer_peripheral) { uint32_t timer_frequency; - uint32_t ppre; /* Get preripheral bus frequency and prescaler mask */ - if (timer_peripheral == TIM1 || timer_peripheral == TIM8) { - /* Advanced timers TIM1 and TIM8 are on APB2 */ - ppre = RCC_CFGR_PPRE2; - timer_frequency = rcc_apb2_frequency; - } else { - /* Other timers are on APB1 */ - ppre = RCC_CFGR_PPRE1; + if ((timer_peripheral >= TIM2 && timer_peripheral <= TIM5) + || (timer_peripheral >= TIM12 && timer_peripheral <= TIM14)) + { timer_frequency = rcc_apb1_frequency; + } else { + timer_frequency = rcc_apb2_frequency; } /* Timer clock is doubled, if the APB prescaler is greater than 1 */ - if ((RCC_CFGR & ppre) != 0) + if (timer_frequency != rcc_ahb_frequency) timer_frequency *= 2; return timer_frequency; @@ -118,9 +115,9 @@ void irmp_timer_init (void) GPIO_CNF_OUTPUT_PUSHPULL, GPIO2); #endif /* Enable timer clock. */ - rcc_periph_clock_enable(RCC_TIM_IRMP); - nvic_set_priority(NVIC_TIM_IRMP_IRQ, 4*16); - nvic_enable_irq(NVIC_TIM_IRMP_IRQ); + rcc_periph_clock_enable(RCC_IRMP_TIMER); + nvic_set_priority(NVIC_IRMP_TIMER_IRQ, 4*16); + nvic_enable_irq(NVIC_IRMP_TIMER_IRQ); #if USE_OPENCM3_API /* Using API functions: */ @@ -131,22 +128,22 @@ void irmp_timer_init (void) * (These are actually default values after reset, so this call * is strictly unnecessary, but demos the api for alternative settings) */ - timer_set_mode(TIM_IRMP, TIM_CR1_CKD_CK_INT, + timer_set_mode(IRMP_TIMER, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); - timer_set_period(TIM_IRMP, timer_internal_clock_get(TIM_IRMP) / F_INTERRUPTS); + timer_set_period(IRMP_TIMER, timer_internal_clock_get(IRMP_TIMER) / F_INTERRUPTS - 1); /* Enable Channel 1 compare interrupt to recalculate compare values */ - timer_enable_irq(TIM_IRMP, TIM_DIER_UIE); + timer_enable_irq(IRMP_TIMER, TIM_DIER_UIE); /* Counter enable. */ - timer_enable_counter(TIM_IRMP); + timer_enable_counter(IRMP_TIMER); #else /* Manually */ - TIM_IRMP_CR1 = TIM_CR1_CKD_CK_INT | TIM_CR1_CMS_EDGE | TIM_CR1_DIR_UP; - TIM_IRMP_ARR = timer_internal_clock_get(TIM_IRMP) / F_INTERRUPTS; + IRMP_TIMER_CR1 = TIM_CR1_CKD_CK_INT | TIM_CR1_CMS_EDGE | TIM_CR1_DIR_UP; + IRMP_TIMER_ARR = timer_internal_clock_get(IRMP_TIMER) / F_INTERRUPTS - 1; /* Enable Timer interrupt and timer */ - TIM_IRMP_DIER = TIM_DIER_UIE; - TIM_IRMP_CR1 |= TIM_CR1_CEN; + IRMP_TIMER_DIER = TIM_DIER_UIE; + IRMP_TIMER_CR1 |= TIM_CR1_CEN; #endif } @@ -158,13 +155,13 @@ void IRMP_TIMER_ISR(void) gpio_clear(GPIOA, GPIO2); /* Clear update interrupt flag. */ - timer_clear_flag(TIM_IRMP, TIM_SR_UIF); + timer_clear_flag(IRMP_TIMER, TIM_SR_UIF); # else /* Manually */ GPIO_BRR(GPIOA) = GPIO2; # endif #endif /* Clear update interrupt flag. */ - TIM_IRMP_SR = ~TIM_SR_UIF; + IRMP_TIMER_SR = ~TIM_SR_UIF; (void) irmp_ISR(); // call irmp ISR @@ -380,7 +377,7 @@ int main (void) " System frequency: %luHz\n" "IRMP timer input frequency (CK_INT): %luHz\n" " IRMP interrupt frequency: %uHz\n", - rcc_ahb_frequency, timer_internal_clock_get(TIM_IRMP), F_INTERRUPTS); + rcc_ahb_frequency, timer_internal_clock_get(IRMP_TIMER), F_INTERRUPTS); systick_setup(); irmp_timer_init(); // initialize timer for irmp diff --git a/libopencm3.rules.mk b/libopencm3.rules.mk index 0a6171a..037c9ab 100644 --- a/libopencm3.rules.mk +++ b/libopencm3.rules.mk @@ -122,7 +122,7 @@ TGT_CPPFLAGS += $(DEFS) ############################################################################### # Linker flags -TGT_LDFLAGS += --static -nostartfiles --specs=nano.specs +TGT_LDFLAGS += --static -nostartfiles TGT_LDFLAGS += -T$(LDSCRIPT) TGT_LDFLAGS += $(ARCH_FLAGS) TGT_LDFLAGS += -Wl,-Map=$(*).map @@ -153,8 +153,9 @@ srec: $(BINARY).srec list: $(BINARY).list size: $(BINARY).size -images: $(BINARY).images -flash: $(BINARY).stlink-flash +images: $(BINARY).images +flash: $(BINARY).flash +stflash: $(BINARY).stlink-flash # Either verify the user provided LDSCRIPT exists, or generate it. ifeq ($(strip $(DEVICE)),) -- 2.39.2