mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
[Horus] Haptic now OK
This commit is contained in:
parent
c51a85f376
commit
c9ae964428
8 changed files with 22 additions and 15 deletions
|
@ -83,7 +83,7 @@ if(PCB STREQUAL HORUS)
|
||||||
lcd_driver.cpp
|
lcd_driver.cpp
|
||||||
delays.c
|
delays.c
|
||||||
usb_driver.c
|
usb_driver.c
|
||||||
pwr_driver.c
|
pwr_driver.cpp
|
||||||
sdram_driver.c
|
sdram_driver.c
|
||||||
led_driver.cpp
|
led_driver.cpp
|
||||||
)
|
)
|
||||||
|
|
|
@ -55,7 +55,7 @@ enum AudioBufferState
|
||||||
typedef uint16_t audio_data_t;
|
typedef uint16_t audio_data_t;
|
||||||
#define AUDIO_DATA_SILENCE 0x8000
|
#define AUDIO_DATA_SILENCE 0x8000
|
||||||
#define AUDIO_DATA_MIN 0
|
#define AUDIO_DATA_MIN 0
|
||||||
#define AUDIO_DATA_MAX UINT16_MAX
|
#define AUDIO_DATA_MAX 0xffff
|
||||||
#define AUDIO_BITS_PER_SAMPLE 16
|
#define AUDIO_BITS_PER_SAMPLE 16
|
||||||
#elif defined(PCBHORUS)
|
#elif defined(PCBHORUS)
|
||||||
typedef int16_t audio_data_t;
|
typedef int16_t audio_data_t;
|
||||||
|
|
|
@ -1996,7 +1996,7 @@ void opentxClose()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(PCBTARANIS)
|
#if !defined(PCBTARANIS) && !defined(COLORLCD)
|
||||||
if (storageDirtyMsk & EE_MODEL) {
|
if (storageDirtyMsk & EE_MODEL) {
|
||||||
displayPopup(STR_SAVEMODEL);
|
displayPopup(STR_SAVEMODEL);
|
||||||
}
|
}
|
||||||
|
@ -2021,8 +2021,6 @@ void opentxClose()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(NAVIGATION_STICKS)
|
#if defined(NAVIGATION_STICKS)
|
||||||
uint8_t getSticksNavigationEvent()
|
uint8_t getSticksNavigationEvent()
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
#define SWITCH_SIMU(a, b) (a)
|
#define SWITCH_SIMU(a, b) (a)
|
||||||
|
|
|
@ -291,6 +291,7 @@ void sportSendBuffer(uint8_t *buffer, uint32_t count);
|
||||||
|
|
||||||
// Haptic driver
|
// Haptic driver
|
||||||
void hapticInit(void);
|
void hapticInit(void);
|
||||||
|
void hapticDone(void);
|
||||||
void hapticOff(void);
|
void hapticOff(void);
|
||||||
#define HAPTIC_OFF() hapticOff()
|
#define HAPTIC_OFF() hapticOff()
|
||||||
void hapticOn(uint32_t pwmPercent);
|
void hapticOn(uint32_t pwmPercent);
|
||||||
|
|
|
@ -245,11 +245,11 @@
|
||||||
|
|
||||||
// Haptic
|
// Haptic
|
||||||
#define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
#define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
||||||
#define HAPTIC_RCC_APB2Periph RCC_APB2ENR_TIM11EN
|
#define HAPTIC_RCC_APB2Periph RCC_APB2ENR_TIM9EN
|
||||||
#define HAPTIC_GPIO GPIOA
|
#define HAPTIC_GPIO GPIOA
|
||||||
#define HAPTIC_GPIO_PIN GPIO_Pin_2
|
#define HAPTIC_GPIO_PIN GPIO_Pin_2
|
||||||
#define HAPTIC_GPIO_TIMER TIM11
|
#define HAPTIC_GPIO_TIMER TIM9
|
||||||
#define HAPTIC_GPIO_AF GPIO_AF_TIM11
|
#define HAPTIC_GPIO_AF GPIO_AF_TIM9
|
||||||
#define HAPTIC_GPIO_PinSource GPIO_PinSource2
|
#define HAPTIC_GPIO_PinSource GPIO_PinSource2
|
||||||
|
|
||||||
// Internal Module
|
// Internal Module
|
||||||
|
|
|
@ -45,12 +45,18 @@ void hapticInit(void)
|
||||||
|
|
||||||
GPIO_PinAFConfig(HAPTIC_GPIO, HAPTIC_GPIO_PinSource, HAPTIC_GPIO_AF);
|
GPIO_PinAFConfig(HAPTIC_GPIO, HAPTIC_GPIO_PinSource, HAPTIC_GPIO_AF);
|
||||||
|
|
||||||
HAPTIC_GPIO_TIMER->ARR = 100 ;
|
HAPTIC_GPIO_TIMER->ARR = 100;
|
||||||
HAPTIC_GPIO_TIMER->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
|
HAPTIC_GPIO_TIMER->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
|
||||||
HAPTIC_GPIO_TIMER->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 ; // PWM
|
HAPTIC_GPIO_TIMER->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2; // PWM
|
||||||
HAPTIC_GPIO_TIMER->CCER = TIM_CCER_CC1E ;
|
HAPTIC_GPIO_TIMER->CCER = TIM_CCER_CC1E;
|
||||||
|
|
||||||
HAPTIC_GPIO_TIMER->CCR1 = 0 ;
|
HAPTIC_GPIO_TIMER->CCR1 = 0;
|
||||||
HAPTIC_GPIO_TIMER->EGR = 0 ;
|
HAPTIC_GPIO_TIMER->EGR = 0;
|
||||||
HAPTIC_GPIO_TIMER->CR1 = TIM_CR1_CEN ; // Counter enable
|
HAPTIC_GPIO_TIMER->CR1 = TIM_CR1_CEN; // counter enable
|
||||||
|
}
|
||||||
|
|
||||||
|
void hapticDone(void)
|
||||||
|
{
|
||||||
|
hapticOff();
|
||||||
|
RCC_AHB1PeriphClockCmd(HAPTIC_RCC_AHB1Periph, DISABLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,9 @@ void pwrOff()
|
||||||
GPIO_Init(AUDIO_SHUTDOWN_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_SHUTDOWN_GPIO, &GPIO_InitStructure);
|
||||||
GPIO_ResetBits(AUDIO_SHUTDOWN_GPIO, AUDIO_SHUTDOWN_GPIO_PIN);
|
GPIO_ResetBits(AUDIO_SHUTDOWN_GPIO, AUDIO_SHUTDOWN_GPIO_PIN);
|
||||||
|
|
||||||
|
// Shutdown the Haptic
|
||||||
|
hapticDone();
|
||||||
|
|
||||||
GPIO_ResetBits(PWR_GPIO, PWR_GPIO_PIN_ON);
|
GPIO_ResetBits(PWR_GPIO, PWR_GPIO_PIN_ON);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue