From 9358ed084e5a75cf150d057420a33a1fa6ad3175 Mon Sep 17 00:00:00 2001 From: "bernet.andre@gmail.com" Date: Sun, 24 Mar 2013 17:43:10 +0000 Subject: [PATCH] [Taranis] Trainer driver fixed, thanks Mike! --- src/taranis/board_taranis.cpp | 11 ++--------- src/taranis/board_taranis.h | 1 + src/taranis/hal.h | 1 + src/taranis/trainer_driver.cpp | 6 +++--- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/taranis/board_taranis.cpp b/src/taranis/board_taranis.cpp index d70450cc7..93446d7ca 100644 --- a/src/taranis/board_taranis.cpp +++ b/src/taranis/board_taranis.cpp @@ -100,8 +100,8 @@ void configure_pins( uint32_t pins, uint16_t config ) pgpio->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)pos * 2)); pgpio->PUPDR |= ((config & PIN_PULL_MASK) >> 2) << (pos * 2) ; - pgpio->AFR[pos >> 3] &= ~(0x000F << (pos & 7)) ; - pgpio->AFR[pos >> 3] |= ((config & PIN_PERI_MASK) >> 4) << (pos & 7) ; + pgpio->AFR[pos >> 3] &= ~(0x000F << ((pos & 7)*4)) ; + pgpio->AFR[pos >> 3] |= ((config & PIN_PERI_MASK) >> 4) << ((pos & 7)*4) ; } } } @@ -213,18 +213,11 @@ void boardInit() // TODO init_ppm() ; - init_trainer_ppm() ; - init_trainer_capture() ; - init5msTimer(); - __enable_irq() ; - eepromInit(); - sportInit(); - usbInit(); } #endif diff --git a/src/taranis/board_taranis.h b/src/taranis/board_taranis.h index 33916c474..6b88c0ad2 100644 --- a/src/taranis/board_taranis.h +++ b/src/taranis/board_taranis.h @@ -119,6 +119,7 @@ void disable_pxx(); // Trainer driver void init_trainer_ppm(); +void stop_trainer_ppm(); void init_trainer_capture(); // Keys driver diff --git a/src/taranis/hal.h b/src/taranis/hal.h index a53020ea2..017add487 100644 --- a/src/taranis/hal.h +++ b/src/taranis/hal.h @@ -167,6 +167,7 @@ // TODO merge these constants #define PIN_PER_1 0x0010 +#define PIN_PER_2 0x0020 #define PIN_PORTA 0x0000 #define PIN_PER_3 0x0030 #define PIN_PER_5 0x0050 diff --git a/src/taranis/trainer_driver.cpp b/src/taranis/trainer_driver.cpp index 86e2e3227..e1f24c301 100644 --- a/src/taranis/trainer_driver.cpp +++ b/src/taranis/trainer_driver.cpp @@ -143,9 +143,9 @@ extern "C" void TIM8_UP_TIM13_IRQHandler() // Trainer capture, PC8, Timer 3 channel 3 void init_trainer_capture() { - RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN ; // Enable portC clock - configure_pins( 0x0100, PIN_PERIPHERAL | PIN_PORTC | PIN_TR_PPM_IN ) ; - RCC->APB1ENR |= RCC_APB1ENR_TIM3EN ; // Enable clock + RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN ; // Enable portC clock + configure_pins (PIN_TR_PPM_IN, PIN_PERIPHERAL | PIN_PORTC | PIN_PER_2) ; + RCC->APB1ENR |= RCC_APB1ENR_TIM3EN ; // Enable clock TIM3->ARR = 0xFFFF ; TIM3->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 2000000 - 1 ; // 0.5uS