[SKY9X] Audio fix - Tested on 9XR-PRO (#4088)

* [SKY9X] Audio fix - Tested on 9XR-PRO

* [X7D] Bootloader fixes
This commit is contained in:
Bertrand Songis
2016-12-02 18:50:23 +01:00
committed by GitHub
parent 705823a9a6
commit 9b3cd8eeff
4 changed files with 97 additions and 39 deletions
+20 -10
View File
@@ -19,7 +19,8 @@
*/
#include "opentx.h"
const AudioBuffer * nextBuffer = 0;
volatile uint8_t dacStarted = false;
const int8_t volumeScale[VOLUME_LEVEL_MAX+1] =
{
@@ -94,13 +95,23 @@ void dacInit()
NVIC_EnableIRQ(DACC_IRQn) ;
}
inline void dacStart()
{
PMC->PMC_PCER0 |= 0x40000000L ; // Enable peripheral clock to DAC
DACC->DACC_IER = DACC_IER_ENDTX ;
dacStarted = true;
}
inline void dacStop()
{
DACC->DACC_IDR = DACC_IDR_ENDTX ; // Disable interrupt
dacStarted = false;
}
void audioConsumeCurrentBuffer()
{
if (nextBuffer == 0) {
nextBuffer = audioQueue.buffersFifo.getNextFilledBuffer();
if (nextBuffer) {
dacStart();
}
if (!dacStarted) {
dacStart();
}
}
@@ -109,9 +120,8 @@ extern "C" void DAC_IRQHandler()
{
uint32_t sr = DACC->DACC_ISR;
if (sr & DACC_ISR_ENDTX) {
if (nextBuffer) audioQueue.buffersFifo.freeNextFilledBuffer();
nextBuffer = audioQueue.buffersFifo.getNextFilledBuffer();
audioQueue.buffersFifo.freeNextFilledBuffer();
const AudioBuffer * nextBuffer = audioQueue.buffersFifo.getNextFilledBuffer();
if (nextBuffer) {
// Try the first PDC buffer
if ((DACC->DACC_TCR == 0) && (DACC->DACC_TNCR == 0)) {
@@ -137,7 +147,7 @@ extern "C" void DAC_IRQHandler()
// Sound routines
void audioInit()
{
Pio *pioptr ;
Pio * pioptr ;
dacInit() ;
-11
View File
@@ -29,17 +29,6 @@ void audioConsumeCurrentBuffer();
void setSampleRate( uint32_t frequency ) ;
inline void dacStart()
{
PMC->PMC_PCER0 |= 0x40000000L ; // Enable peripheral clock to DAC
DACC->DACC_IER = DACC_IER_ENDTX ;
}
inline void dacStop()
{
DACC->DACC_IDR = DACC_IDR_ENDTX ; // Disable interrupt
}
#define VOLUME_LEVEL_MAX 23
#define VOLUME_LEVEL_DEF 12
+28 -13
View File
@@ -21,19 +21,34 @@
#include "opentx.h"
#include "stamp.h"
#define BOOTLOADER_TITLE " Taranis BootLoader - " VERSION
#if defined(PCBX9E) || defined(PCBX7D)
#define BOOT_KEY_UP KEY_MINUS
#define BOOT_KEY_DOWN KEY_PLUS
#if defined(PCBX7D)
#define BOOTLOADER_TITLE " X7 Bootloader - " VERSION
#elif defined(PCBTARANIS)
#define BOOTLOADER_TITLE " Taranis Bootloader - " VERSION
#else
#define BOOT_KEY_UP KEY_PLUS
#define BOOT_KEY_DOWN KEY_MINUS
#error "Not implemented"
#endif
#if defined(PCBX9E) || defined(PCBX7D)
#define BOOT_KEY_UP KEY_MINUS
#define BOOT_KEY_DOWN KEY_PLUS
#else
#define BOOT_KEY_UP KEY_PLUS
#define BOOT_KEY_DOWN KEY_MINUS
#endif
#define BOOT_KEY_LEFT KEY_MENU
#define BOOT_KEY_RIGHT KEY_PAGE
#define BOOT_KEY_MENU KEY_ENTER
#define BOOT_KEY_EXIT KEY_EXIT
#define DISPLAY_CHAR_WIDTH 35
#if LCD_W >= 212
#define STR_OR_PLUGIN_USB_CABLE INDENT "Or plug in a USB cable for mass storage"
#define STR_USB_CONNECTED "\026USB Connected"
#else
#define STR_OR_PLUGIN_USB_CABLE INDENT "Or plug in a USB cable"
#define STR_USB_CONNECTED "\012USB Connected "
#endif
#define BOOT_KEY_LEFT KEY_MENU
#define BOOT_KEY_RIGHT KEY_PAGE
#define BOOT_KEY_MENU KEY_ENTER
#define BOOT_KEY_EXIT KEY_EXIT
#define DISPLAY_CHAR_WIDTH 35
const uint8_t bootloaderVersion[] __attribute__ ((section(".version"), used)) =
{
@@ -377,7 +392,7 @@ int main()
lcdDrawTextAlignedLeft(3*FH, "\010Restore EEPROM");
lcdDrawTextAlignedLeft(4*FH, "\010Exit");
lcdInvertLine(2+vpos);
lcdDrawTextAlignedLeft(7*FH, INDENT "Or plug in a USB cable for mass storage");
lcdDrawTextAlignedLeft(7*FH, STR_OR_PLUGIN_USB_CABLE);
if (event == EVT_KEY_FIRST(BOOT_KEY_DOWN)) {
vpos == 2 ? vpos = 0 : vpos = vpos+1;
}
@@ -399,7 +414,7 @@ int main()
}
if (state == ST_USB) {
lcdDrawTextAlignedLeft(4*FH, "\026USB Connected");
lcdDrawTextAlignedLeft(4*FH, STR_USB_CONNECTED);
if (usbPlugged() == 0) {
vpos = 0;
if (unlocked) {