[M2561] Audio added
[Taranis/sky9x] Code cleaning
This commit is contained in:
+4
-9
@@ -3789,10 +3789,10 @@ uint16_t getTmr16KHz()
|
|||||||
|
|
||||||
#if defined(PCBSTD) && (defined(AUDIO) || defined(VOICE))
|
#if defined(PCBSTD) && (defined(AUDIO) || defined(VOICE))
|
||||||
// Clocks every 128 uS
|
// Clocks every 128 uS
|
||||||
ISR(TIMER2_OVF_vect, ISR_NOBLOCK)
|
ISR(TIMER_AUDIO_VECT, ISR_NOBLOCK)
|
||||||
{
|
{
|
||||||
cli();
|
cli();
|
||||||
TIMSK &= ~(1<<TOIE2) ; // stop reentrance
|
PAUSE_AUDIO_INTERRUPT(); // stop reentrance
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
#if defined(AUDIO)
|
#if defined(AUDIO)
|
||||||
@@ -3804,7 +3804,7 @@ ISR(TIMER2_OVF_vect, ISR_NOBLOCK)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
cli();
|
cli();
|
||||||
TIMSK |= (1<<TOIE2) ;
|
RESUME_AUDIO_INTERRUPT();
|
||||||
sei();
|
sei();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -4204,15 +4204,10 @@ inline void opentxInit(OPENTX_INIT_ARGS)
|
|||||||
backlightOn();
|
backlightOn();
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
start_ppm_capture();
|
init_trainer_capture();
|
||||||
// TODO inside startPulses?
|
|
||||||
s_pulses_paused = false;
|
|
||||||
// TODO startPulses should be started after the first doMixerCalculations()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(CPUARM)
|
|
||||||
doMixerCalculations();
|
doMixerCalculations();
|
||||||
#endif
|
|
||||||
|
|
||||||
startPulses();
|
startPulses();
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ void Hubsan_Init();
|
|||||||
|
|
||||||
inline void startPulses()
|
inline void startPulses()
|
||||||
{
|
{
|
||||||
|
s_pulses_paused = false;
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
setupPulses(INTERNAL_MODULE);
|
setupPulses(INTERNAL_MODULE);
|
||||||
setupPulses(EXTERNAL_MODULE);
|
setupPulses(EXTERNAL_MODULE);
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ inline void setup_switches()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SIMU
|
#ifdef SIMU
|
||||||
#define end_ppm_capture()
|
#define stop_trainer_capture()
|
||||||
#define rotencEnd()
|
#define rotencEnd()
|
||||||
#define sam_boot()
|
#define sam_boot()
|
||||||
#else
|
#else
|
||||||
@@ -329,13 +329,13 @@ extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
|
|||||||
lastCapt = capture;
|
lastCapt = capture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void start_ppm_capture()
|
void init_trainer_capture()
|
||||||
{
|
{
|
||||||
start_timer4() ;
|
start_timer4() ;
|
||||||
start_timer3() ;
|
start_timer3() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void end_ppm_capture()
|
void stop_trainer_capture()
|
||||||
{
|
{
|
||||||
TC1->TC_CHANNEL[0].TC_IDR = TC_IDR0_LDRAS ;
|
TC1->TC_CHANNEL[0].TC_IDR = TC_IDR0_LDRAS ;
|
||||||
NVIC_DisableIRQ(TC3_IRQn) ;
|
NVIC_DisableIRQ(TC3_IRQn) ;
|
||||||
@@ -744,7 +744,7 @@ void usbBootloader()
|
|||||||
rotencEnd();
|
rotencEnd();
|
||||||
endPdcUsartReceive() ; // Terminate any serial reception
|
endPdcUsartReceive() ; // Terminate any serial reception
|
||||||
end_bt_tx_interrupt() ;
|
end_bt_tx_interrupt() ;
|
||||||
end_ppm_capture() ;
|
stop_trainer_capture() ;
|
||||||
end_spi() ;
|
end_spi() ;
|
||||||
audioEnd() ;
|
audioEnd() ;
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ inline void boardInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(AUDIO) || defined(VOICE)
|
#if defined(AUDIO) || defined(VOICE)
|
||||||
TCCR2 = (0b010 << CS00); // Norm mode, clk/8
|
SET_TIMER_AUDIO_CTRL();
|
||||||
#elif defined(PWM_BACKLIGHT)
|
#elif defined(PWM_BACKLIGHT)
|
||||||
/** Smartieparts LED Backlight is connected to PORTB/pin7, which can be used as pwm output of timer2 **/
|
/** Smartieparts LED Backlight is connected to PORTB/pin7, which can be used as pwm output of timer2 **/
|
||||||
#if defined(SP22)
|
#if defined(SP22)
|
||||||
|
|||||||
@@ -76,6 +76,10 @@
|
|||||||
#define RESUME_10MS_INTERRUPT() TIMSK2 |= (1<<OCIE2A)
|
#define RESUME_10MS_INTERRUPT() TIMSK2 |= (1<<OCIE2A)
|
||||||
#define PAUSE_PPMIN_INTERRUPT() TIMSK3 &= ~(1<<ICIE3)
|
#define PAUSE_PPMIN_INTERRUPT() TIMSK3 &= ~(1<<ICIE3)
|
||||||
#define RESUME_PPMIN_INTERRUPT() TIMSK3 |= (1<<ICIE3)
|
#define RESUME_PPMIN_INTERRUPT() TIMSK3 |= (1<<ICIE3)
|
||||||
|
#define TIMER_AUDIO_VECT TIMER4_OVF_vect
|
||||||
|
#define SET_TIMER_AUDIO_CTRL() TCCR4B = (0b111 << CS20)
|
||||||
|
#define PAUSE_AUDIO_INTERRUPT() TIMSK4 &= ~(1<<OCIE4A)
|
||||||
|
#define RESUME_AUDIO_INTERRUPT() TIMSK4 |= (1<<OCIE4A)
|
||||||
#else
|
#else
|
||||||
#define TIMER_16KHZ_VECT TIMER0_OVF_vect
|
#define TIMER_16KHZ_VECT TIMER0_OVF_vect
|
||||||
#define COUNTER_16KHZ TCNT0
|
#define COUNTER_16KHZ TCNT0
|
||||||
@@ -85,6 +89,10 @@
|
|||||||
#define RESUME_10MS_INTERRUPT() TIMSK |= (1<<OCIE0)
|
#define RESUME_10MS_INTERRUPT() TIMSK |= (1<<OCIE0)
|
||||||
#define PAUSE_PPMIN_INTERRUPT() ETIMSK &= ~(1<<TICIE3)
|
#define PAUSE_PPMIN_INTERRUPT() ETIMSK &= ~(1<<TICIE3)
|
||||||
#define RESUME_PPMIN_INTERRUPT() ETIMSK |= (1<<TICIE3)
|
#define RESUME_PPMIN_INTERRUPT() ETIMSK |= (1<<TICIE3)
|
||||||
|
#define TIMER_AUDIO_VECT TIMER2_OVF_vect
|
||||||
|
#define SET_TIMER_AUDIO_CTRL() TCCR2 = (0b010 << CS00) // Norm mode, clk/8
|
||||||
|
#define PAUSE_AUDIO_INTERRUPT() TIMSK &= ~(1<<TOIE2)
|
||||||
|
#define RESUME_AUDIO_INTERRUPT() TIMSK |= (1<<TOIE2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Power driver (none)
|
// Power driver (none)
|
||||||
|
|||||||
@@ -112,14 +112,10 @@ uint8_t usbPlugged(void)
|
|||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
void debugPutc(const char c)
|
void debugPutc(const char c)
|
||||||
{
|
{
|
||||||
uartPutc(c);
|
uartPutc(c);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void start_ppm_capture()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
USB_OTG_CORE_HANDLE USB_OTG_dev;
|
USB_OTG_CORE_HANDLE USB_OTG_dev;
|
||||||
@@ -202,7 +198,6 @@ void boardInit()
|
|||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
uartInit(DEBUG_UART_BAUDRATE);
|
uartInit(DEBUG_UART_BAUDRATE);
|
||||||
#endif
|
#endif
|
||||||
init_trainer_capture();
|
|
||||||
init5msTimer();
|
init5msTimer();
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
eepromInit();
|
eepromInit();
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ uint8_t usbPlugged(void);
|
|||||||
void delaysInit();
|
void delaysInit();
|
||||||
|
|
||||||
#define DEBUG_UART_BAUDRATE 9600
|
#define DEBUG_UART_BAUDRATE 9600
|
||||||
#define SPORT_BAUDRATE 57600
|
#define SPORT_BAUDRATE 57600
|
||||||
|
|
||||||
void uartInit(uint32_t baudrate);
|
void uartInit(uint32_t baudrate);
|
||||||
void uartPutc(const char c);
|
void uartPutc(const char c);
|
||||||
|
|||||||
Reference in New Issue
Block a user