From 8dec0d95fb6f86474d8fd54878d486041e62966a Mon Sep 17 00:00:00 2001 From: Leo C Date: Mon, 1 May 2017 13:54:38 +0200 Subject: [PATCH] Small changes. Convert TABs to spaces. --- irmp | 2 +- irsnd-main.c | 61 +++++++++++++++++++++++++--------------------------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/irmp b/irmp index 54cbcce..f850d9d 160000 --- a/irmp +++ b/irmp @@ -1 +1 @@ -Subproject commit 54cbcce61b31454cc76ad2a75d4d5e479d896345 +Subproject commit f850d9dc0310997bbcfa076b113ac06765a18bfc diff --git a/irsnd-main.c b/irsnd-main.c index 3387439..903312c 100644 --- a/irsnd-main.c +++ b/irsnd-main.c @@ -85,7 +85,7 @@ static void led_off(void) static void debug_led_on(void) { #if DEBUG_IRMP_TIMER_INT -# if USE_OPENCM3_API /* Using API functions: */ +# if USE_OPENCM3_API /* Using API functions: */ gpio_clear(DEBUG_LED_PORT, DEBUG_LED_PIN); #else GPIO_BRR(GPIOA) = GPIO2; @@ -96,7 +96,7 @@ static void debug_led_on(void) static void debug_led_off(void) { #if DEBUG_IRMP_TIMER_INT -# if USE_OPENCM3_API /* Using API functions: */ +# if USE_OPENCM3_API /* Using API functions: */ gpio_set(DEBUG_LED_PORT, DEBUG_LED_PIN); #else GPIO_BSRR(GPIOA) = GPIO2; @@ -133,10 +133,10 @@ uint32_t timer_internal_clock_get(uint32_t timer_peripheral) #ifdef STM32F0 timer_frequency = rcc_apb1_frequency; #else - if (timer_peripheral < PERIPH_BASE_APB2) + if (timer_peripheral < PERIPH_BASE_APB2) { timer_frequency = rcc_apb1_frequency; - } else { + } else { timer_frequency = rcc_apb2_frequency; } #endif /* STM32F0 */ @@ -144,7 +144,7 @@ uint32_t timer_internal_clock_get(uint32_t timer_peripheral) if (timer_frequency != rcc_ahb_frequency) timer_frequency *= 2; - return timer_frequency; + return timer_frequency; } /** @@ -155,30 +155,31 @@ void irsnd_tick_timer_init(void) #if DEBUG_IRMP_TIMER_INT /* Output pin for debugging */ rcc_periph_clock_enable(DEBUG_LED_PORT_RCC); + gpio_set(DEBUG_LED_PORT, DEBUG_LED_PIN); gpio_set_mode(DEBUG_LED_PORT, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, DEBUG_LED_PIN); #endif - /* Enable timer clock. */ + /* Enable timer clock. */ rcc_periph_clock_enable(IRSND_TICK_TIMER_RCC); nvic_set_priority(NVIC_IRSND_TICK_TIMER_IRQ, 4*16); - nvic_enable_irq(NVIC_IRSND_TICK_TIMER_IRQ); - -#if USE_OPENCM3_API /* Using API functions: */ - - /* Timer global mode: - * - No divider - * - Alignment edge - * - Direction up - * (These are actually default values after reset, so this call - * is strictly unnecessary, but demos the api for alternative settings) - */ - timer_set_mode(IRSND_TICK_TIMER, TIM_CR1_CKD_CK_INT, + nvic_enable_irq(NVIC_IRSND_TICK_TIMER_IRQ); + +#if USE_OPENCM3_API /* Using API functions: */ + + /* Timer global mode: + * - No divider + * - Alignment edge + * - Direction up + * (These are actually default values after reset, so this call + * is strictly unnecessary, but demos the api for alternative settings) + */ + timer_set_mode(IRSND_TICK_TIMER, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); - timer_set_period(IRSND_TICK_TIMER, timer_internal_clock_get(IRSND_TICK_TIMER) / F_INTERRUPTS - 1); + timer_set_period(IRSND_TICK_TIMER, timer_internal_clock_get(IRSND_TICK_TIMER) / F_INTERRUPTS - 1); /* Enable timer update interrupt */ - timer_enable_irq(IRSND_TICK_TIMER, TIM_DIER_UIE); - /* Counter enable. */ - timer_enable_counter(IRSND_TICK_TIMER); + timer_enable_irq(IRSND_TICK_TIMER, TIM_DIER_UIE); + /* Counter enable. */ + timer_enable_counter(IRSND_TICK_TIMER); #else /* Manually */ @@ -198,7 +199,7 @@ void IRSND_TICK_TIMER_ISR(void) debug_led_on(); /* Clear update interrupt flag. */ -#if USE_OPENCM3_API /* Using API functions: */ +#if USE_OPENCM3_API /* Using API functions: */ timer_clear_flag(IRSND_TICK_TIMER, TIM_SR_UIF); #else IRSND_TICK_TIMER_SR = ~TIM_SR_UIF; @@ -225,25 +226,21 @@ main (void) irsnd_init(); // initialize irsnd irsnd_tick_timer_init(); // initialize timer - ts = get_timer(0); - while (get_timer(ts) < 200) - ; - for (;;) { irmp_data.protocol = IRMP_NEC_PROTOCOL; // use NEC protocol - irmp_data.address = 0x4eb1; // set address to 0x00FF - irmp_data.command = 0x001e; // set command to 0x0001 + irmp_data.address = 0x4eb1; // Marantz RMC-12 + irmp_data.command = 0x001e; // SYSTEM 1 POWER irmp_data.flags = 0; // don't repeat frame ts = get_timer(0); led_on(); irsnd_send_data (&irmp_data, TRUE); // send frame, wait for completion - while (irsnd_is_busy()) - ; + while (irsnd_is_busy()) // wait till frame is + ; // completely sent led_off(); - while (get_timer(ts) < 2000) + while (get_timer(ts) < 1000) ; } } -- 2.39.2