1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Rotary encoders Beep Center should be ok now

More port from ersky9x
Problem in Telemetry labels for french and swedish
This commit is contained in:
bsongis 2012-04-03 18:01:05 +00:00
parent d970ddc9b4
commit 0be7d4a671
13 changed files with 162 additions and 144 deletions

View file

@ -63,38 +63,14 @@ volatile uint32_t Tenms ;
#ifdef REVB #ifdef REVB
inline void init_soft_power() inline void init_soft_power()
{ {
register Pio *pioptr = PIOC ;
// Configure RF_power (PC17) // Configure RF_power (PC17)
pioptr->PIO_PER = PIO_PC17 ; // Enable bit C17 configure_pins( PIO_PC17, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_NO_PULLUP | PIN_PULLDOWN ) ;
pioptr->PIO_ODR = PIO_PC17 ; // Set bit C17 as input configure_pins( PIO_PA8, PIN_ENABLE | PIN_INPUT | PIN_PORTA | PIN_PULLUP ) ; // Enable bit A8 (Soft Power)
pioptr->PIO_PUDR = PIO_PC17; // Disable pullup on bit C17
pioptr->PIO_PPDER = PIO_PC17; // Enable pulldown on bit C17
pioptr = PIOA ;
pioptr->PIO_PER = PIO_PA8 ; // Enable bit A8 (Soft Power)
pioptr->PIO_ODR = PIO_PA8 ; // Set bit A8 as input
pioptr->PIO_PUER = PIO_PA8 ; // Enable PA8 pullup
}
// Returns non-zero if power is switched off
uint32_t check_soft_power()
{
if ( PIOC->PIO_PDSR & PIO_PC17 ) // Power on
{
return 1 ;
}
if ( PIOA->PIO_PDSR & PIO_PA8 ) // Trainer plugged in
{
return 1 ;
}
return 0 ;
} }
#endif #endif
uint32_t check_power() uint32_t check_soft_power()
{ {
if ( PIOC->PIO_PDSR & 0x02000000 ) if ( PIOC->PIO_PDSR & 0x02000000 )
{ {
@ -102,25 +78,25 @@ uint32_t check_power()
} }
#ifdef REVB #ifdef REVB
if ( check_soft_power() == 0 ) // power now off if ( PIOC->PIO_PDSR & PIO_PC17 ) // Power on
{ {
return e_power_off ; return e_power_on ;
}
if ( PIOA->PIO_PDSR & PIO_PA8 ) // Trainer plugged in
{
return e_power_trainer ;
} }
#endif #endif
return e_power_on; return e_power_off;
} }
// turn off soft power // turn off soft power
void soft_power_off() void soft_power_off()
{ {
#ifdef REVB #ifdef REVB
register Pio *pioptr ; configure_pins( PIO_PA8, PIN_ENABLE | PIN_OUTPUT | PIN_LOW | PIN_PORTA | PIN_NO_PULLUP ) ;
pioptr = PIOA ;
pioptr->PIO_PUDR = PIO_PA8 ; // Disble PA8 pullup
pioptr->PIO_OER = PIO_PA8 ; // Set bit A8 as input
pioptr->PIO_CODR = PIO_PA8 ; // Set bit A8 OFF, disables soft power switch
#endif #endif
} }
@ -136,20 +112,11 @@ extern "C" void sam_boot( void ) ;
// PC21, PC19, PC15 (PPM2 output) // PC21, PC19, PC15 (PPM2 output)
inline void config_free_pins() inline void config_free_pins()
{ {
register Pio *pioptr ;
#ifdef REVB #ifdef REVB
pioptr = PIOB ; configure_pins( PIO_PB6 | PIO_PB14, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP ) ;
pioptr->PIO_PER = 0x00004040L ; // Enable bits B14, 6 configure_pins( PIO_PC19 | PIO_PC21, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_PULLUP ) ;
pioptr->PIO_ODR = 0x00004040L ; // Set as input
pioptr->PIO_PUER = 0x00004040L ; // Enable pullups
pioptr = PIOC ;
pioptr->PIO_PER = 0x00280000L ; // Enable bits C21, 19
pioptr->PIO_ODR = 0x00280000L ; // Set as input
pioptr->PIO_PUER = 0x00280000L ; // Enable pullups
#else #else
pioptr = PIOA ; register Pio * pioptr = PIOA ;
pioptr->PIO_PER = 0x03800000L ; // Enable bits A25,24,23 pioptr->PIO_PER = 0x03800000L ; // Enable bits A25,24,23
pioptr->PIO_ODR = 0x03800000L ; // Set as input pioptr->PIO_ODR = 0x03800000L ; // Set as input
pioptr->PIO_PUER = 0x03800000L ; // Enable pullups pioptr->PIO_PUER = 0x03800000L ; // Enable pullups
@ -169,35 +136,28 @@ inline void config_free_pins()
// Assumes PMC has already enabled clocks to ports // Assumes PMC has already enabled clocks to ports
inline void setup_switches() inline void setup_switches()
{ {
register Pio *pioptr ;
pioptr = PIOA ;
#ifdef REVB #ifdef REVB
pioptr->PIO_PER = 0x01808087 ; // Enable bits configure_pins( 0x01808087, PIN_ENABLE | PIN_INPUT | PIN_PORTA | PIN_PULLUP ) ;
pioptr->PIO_ODR = 0x01808087 ; // Set bits input
pioptr->PIO_PUER = 0x01808087 ; // Set bits with pullups
#else #else
register Pio *pioptr = PIOA ;
pioptr->PIO_PER = 0xF8008184 ; // Enable bits pioptr->PIO_PER = 0xF8008184 ; // Enable bits
pioptr->PIO_ODR = 0xF8008184 ; // Set bits input pioptr->PIO_ODR = 0xF8008184 ; // Set bits input
pioptr->PIO_PUER = 0xF8008184 ; // Set bits with pullups pioptr->PIO_PUER = 0xF8008184 ; // Set bits with pullups
#endif #endif
pioptr = PIOB ;
#ifdef REVB #ifdef REVB
pioptr->PIO_PER = 0x00000030 ; // Enable bits configure_pins( 0x00000030, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP ) ;
pioptr->PIO_ODR = 0x00000030 ; // Set bits input
pioptr->PIO_PUER = 0x00000030 ; // Set bits with pullups
#else #else
pioptr = PIOB ;
pioptr->PIO_PER = 0x00000010 ; // Enable bits pioptr->PIO_PER = 0x00000010 ; // Enable bits
pioptr->PIO_ODR = 0x00000010 ; // Set bits input pioptr->PIO_ODR = 0x00000010 ; // Set bits input
pioptr->PIO_PUER = 0x00000010 ; // Set bits with pullups pioptr->PIO_PUER = 0x00000010 ; // Set bits with pullups
#endif #endif
pioptr = PIOC ;
#ifdef REVB #ifdef REVB
pioptr->PIO_PER = 0x91114900 ; // Enable bits configure_pins( 0x91114900, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_PULLUP ) ;
pioptr->PIO_ODR = 0x91114900 ; // Set bits input
pioptr->PIO_PUER = 0x91114900 ; // Set bits with pullups
#else #else
pioptr = PIOC ;
pioptr->PIO_PER = 0x10014900 ; // Enable bits pioptr->PIO_PER = 0x10014900 ; // Enable bits
pioptr->PIO_ODR = 0x10014900 ; // Set bits input pioptr->PIO_ODR = 0x10014900 ; // Set bits input
pioptr->PIO_PUER = 0x10014900 ; // Set bits with pullups pioptr->PIO_PUER = 0x10014900 ; // Set bits with pullups
@ -220,13 +180,9 @@ inline void UART_Configure( uint32_t baudrate, uint32_t masterClock)
{ {
// const Pin pPins[] = CONSOLE_PINS; // const Pin pPins[] = CONSOLE_PINS;
register Uart *pUart = CONSOLE_USART; register Uart *pUart = CONSOLE_USART;
register Pio *pioptr ;
/* Configure PIO */ /* Configure PIO */
pioptr = PIOA ; configure_pins( (PIO_PA9 | PIO_PA10), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ;
pioptr->PIO_ABCDSR[0] &= ~(PIO_PA9 | PIO_PA10) ; // Peripheral A
pioptr->PIO_ABCDSR[1] &= ~(PIO_PA9 | PIO_PA10) ; // Peripheral A
pioptr->PIO_PDR = (PIO_PA9 | PIO_PA10) ; // Assign to peripheral
/* Configure PMC */ /* Configure PMC */
PMC->PMC_PCER0 = 1 << CONSOLE_ID; PMC->PMC_PCER0 = 1 << CONSOLE_ID;
@ -254,13 +210,9 @@ inline void UART3_Configure( uint32_t baudrate, uint32_t masterClock)
{ {
// const Pin pPins[] = CONSOLE_PINS; // const Pin pPins[] = CONSOLE_PINS;
register Uart *pUart = BT_USART; register Uart *pUart = BT_USART;
register Pio *pioptr ;
/* Configure PIO */ /* Configure PIO */
pioptr = PIOB ; configure_pins( (PIO_PB2 | PIO_PB3), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTB | PIN_NO_PULLUP ) ;
pioptr->PIO_ABCDSR[0] &= ~(PIO_PB2 | PIO_PB3) ; // Peripheral A
pioptr->PIO_ABCDSR[1] &= ~(PIO_PB2 | PIO_PB3) ; // Peripheral A
pioptr->PIO_PDR = (PIO_PB2 | PIO_PB3) ; // Assign to peripheral
/* Configure PMC */ /* Configure PMC */
PMC->PMC_PCER0 = 1 << BT_ID; PMC->PMC_PCER0 = 1 << BT_ID;
@ -293,13 +245,9 @@ inline void UART2_Configure( uint32_t baudrate, uint32_t masterClock)
{ {
//// const Pin pPins[] = CONSOLE_PINS; //// const Pin pPins[] = CONSOLE_PINS;
register Usart *pUsart = SECOND_USART; register Usart *pUsart = SECOND_USART;
register Pio *pioptr ;
/* Configure PIO */ /* Configure PIO */
pioptr = PIOA ; configure_pins( (PIO_PA5 | PIO_PA6), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ;
pioptr->PIO_ABCDSR[0] &= ~(PIO_PA5 | PIO_PA6) ; // Peripheral A
pioptr->PIO_ABCDSR[1] &= ~(PIO_PA5 | PIO_PA6) ; // Peripheral A
pioptr->PIO_PDR = (PIO_PA5 | PIO_PA6) ; // Assign to peripheral
// /* Configure PMC */ // /* Configure PMC */
PMC->PMC_PCER0 = 1 << SECOND_ID; PMC->PMC_PCER0 = 1 << SECOND_ID;
@ -371,9 +319,6 @@ inline void start_timer2()
inline void start_timer3() inline void start_timer3()
{ {
register Tc *ptc ; register Tc *ptc ;
register Pio *pioptr ;
pioptr = PIOC ;
// Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28 // Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28
PMC->PMC_PCER0 |= 0x04000000L ; // Enable peripheral clock to TC3 PMC->PMC_PCER0 |= 0x04000000L ; // Enable peripheral clock to TC3
@ -385,9 +330,8 @@ inline void start_timer3()
ptc->TC_CHANNEL[0].TC_CMR = 0x00090005 ; // 0000 0000 0000 1001 0000 0000 0000 0101, XC0, A rise, b fall ptc->TC_CHANNEL[0].TC_CMR = 0x00090005 ; // 0000 0000 0000 1001 0000 0000 0000 0101, XC0, A rise, b fall
ptc->TC_CHANNEL[0].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger) ptc->TC_CHANNEL[0].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
pioptr->PIO_ABCDSR[0] |= 0x00800000 ; // Peripheral B = TIOA3 configure_pins( PIO_PC23, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_PULLUP ) ;
pioptr->PIO_ABCDSR[1] &= ~0x00800000 ; // Peripheral B
pioptr->PIO_PDR = 0x00800000L ; // Disable bit C23 (TIOA3) Assign to peripheral
NVIC_SetPriority( TC3_IRQn, 15 ) ; // Low ppiority interrupt NVIC_SetPriority( TC3_IRQn, 15 ) ; // Low ppiority interrupt
NVIC_EnableIRQ(TC3_IRQn) ; NVIC_EnableIRQ(TC3_IRQn) ;
ptc->TC_CHANNEL[0].TC_IER = TC_IER0_LDRAS ; ptc->TC_CHANNEL[0].TC_IER = TC_IER0_LDRAS ;
@ -547,7 +491,6 @@ inline void init_adc()
// For testing, just drive it out with PWM // For testing, just drive it out with PWM
void init_pwm() void init_pwm()
{ {
register Pio *pioptr ;
register Pwm *pwmptr ; register Pwm *pwmptr ;
register uint32_t timer ; register uint32_t timer ;
@ -556,32 +499,19 @@ void init_pwm()
MATRIX->CCFG_SYSIO |= 0x00000020L ; // Disable TDO let PB5 work! MATRIX->CCFG_SYSIO |= 0x00000020L ; // Disable TDO let PB5 work!
/* Configure PIO */ /* Configure PIO */
#ifndef REVB #ifdef REVB
pioptr = PIOB ; configure_pins( PIO_PA16, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_C | PIN_PORTA | PIN_NO_PULLUP ) ;
#else
register Pio *pioptr = PIOB ;
pioptr->PIO_PER = 0x00000020L ; // Enable bit B5 pioptr->PIO_PER = 0x00000020L ; // Enable bit B5
pioptr->PIO_ODR = 0x00000020L ; // set as input pioptr->PIO_ODR = 0x00000020L ; // set as input
#else
pioptr = PIOA ;
pioptr->PIO_ABCDSR[0] &= ~PIO_PA16 ; // Peripheral C
pioptr->PIO_ABCDSR[1] |= PIO_PA16 ; // Peripheral C
pioptr->PIO_PDR = PIO_PA16 ; // Disable bit A16 Assign to peripheral
#endif #endif
pioptr = PIOC ; configure_pins( PIO_PC18, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP ) ;
pioptr->PIO_ABCDSR[0] |= PIO_PC18 ; // Peripheral B
pioptr->PIO_ABCDSR[1] &= ~PIO_PC18 ; // Peripheral B
pioptr->PIO_PDR = PIO_PC18 ; // Disable bit C18 Assign to peripheral
#ifdef REVB #ifdef REVB
pioptr->PIO_ABCDSR[0] |= PIO_PC15 ; // Peripheral B configure_pins( PIO_PC15, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP ) ;
pioptr->PIO_ABCDSR[1] &= ~PIO_PC15 ; // Peripheral B configure_pins( PIO_PC22, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP ) ;
pioptr->PIO_PDR = PIO_PC15 ; // Disable bit C15 Assign to peripheral
#endif
#ifdef REVB
pioptr->PIO_ABCDSR[0] |= PIO_PC22 ; // Peripheral B
pioptr->PIO_ABCDSR[1] &= ~PIO_PC22 ; // Peripheral B
pioptr->PIO_PDR = PIO_PC22 ; // Disable bit C22 Assign to peripheral
#endif #endif
// Configure clock - depends on MCK frequency // Configure clock - depends on MCK frequency
@ -649,6 +579,77 @@ void init_pwm()
extern void start_sound(); // TODO elsewhere extern void start_sound(); // TODO elsewhere
void configure_pins( uint32_t pins, uint16_t config )
{
register Pio *pioptr ;
pioptr = PIOA + ( ( config & PIN_PORT_MASK ) >> 6) ;
if ( config & PIN_PULLUP )
{
pioptr->PIO_PPDDR = pins ;
pioptr->PIO_PUER = pins ;
}
else
{
pioptr->PIO_PUDR = pins ;
}
if ( config & PIN_PULLDOWN )
{
pioptr->PIO_PUDR = pins ;
pioptr->PIO_PPDER = pins ;
}
else
{
pioptr->PIO_PPDDR = pins ;
}
if ( config & PIN_HIGH )
{
pioptr->PIO_SODR = pins ;
}
else
{
pioptr->PIO_CODR = pins ;
}
if ( config & PIN_INPUT )
{
pioptr->PIO_ODR = pins ;
}
else
{
pioptr->PIO_OER = pins ;
}
if ( config & PIN_PERI_MASK_L )
{
pioptr->PIO_ABCDSR[0] |= pins ;
}
else
{
pioptr->PIO_ABCDSR[0] &= ~pins ;
}
if ( config & PIN_PERI_MASK_H )
{
pioptr->PIO_ABCDSR[1] |= pins ;
}
else
{
pioptr->PIO_ABCDSR[1] &= ~pins ;
}
if ( config & PIN_ENABLE )
{
pioptr->PIO_PER = pins ;
}
else
{
pioptr->PIO_PDR = pins ;
}
}
void board_init() void board_init()
{ {
// register uint32_t goto_usb ; // register uint32_t goto_usb ;

View file

@ -73,13 +73,13 @@ inline void board_init()
} }
#endif #endif
uint8_t check_power() uint8_t check_soft_power()
{ {
#ifndef REV0 #ifndef REV0
if ((PING & 0b00000010) && (~PINL & 0b01000000)) if ((PING & 0b00000010) && (~PINL & 0b01000000))
return 1; return e_power_off;
#endif #endif
return 0; return e_power_on;
} }
void soft_power_off() void soft_power_off()

View file

@ -617,7 +617,6 @@ uint32_t spi_operation( register uint8_t *tx, register uint8_t *rx, register uin
// Set clock to 3 MHz, AT25 device is rated to 70MHz, 18MHz would be better // Set clock to 3 MHz, AT25 device is rated to 70MHz, 18MHz would be better
void init_spi() void init_spi()
{ {
register Pio *pioptr ;
register Spi *spiptr ; register Spi *spiptr ;
register uint32_t timer ; register uint32_t timer ;
register uint8_t *p ; register uint8_t *p ;
@ -625,10 +624,7 @@ void init_spi()
PMC->PMC_PCER0 |= 0x00200000L ; // Enable peripheral clock to SPI PMC->PMC_PCER0 |= 0x00200000L ; // Enable peripheral clock to SPI
/* Configure PIO */ /* Configure PIO */
pioptr = PIOA ; configure_pins( 0x00007800, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ;
pioptr->PIO_ABCDSR[0] &= ~0x00007800 ; // Peripheral A bits 14,13,12,11
pioptr->PIO_ABCDSR[1] &= ~0x00007800 ; // Peripheral A
pioptr->PIO_PDR = 0x00007800 ; // Assign to peripheral
spiptr = SPI ; spiptr = SPI ;
timer = ( Master_frequency / 3000000 ) << 8 ; // Baud rate 3Mb/s timer = ( Master_frequency / 3000000 ) << 8 ; // Baud rate 3Mb/s

View file

@ -681,10 +681,7 @@ void lcd_init()
// ~/txt/flieger/ST7565RV17.pdf from http://www.glyn.de/content.asp?wdid=132&sid= // ~/txt/flieger/ST7565RV17.pdf from http://www.glyn.de/content.asp?wdid=132&sid=
#ifdef REVB #ifdef REVB
pioptr = PIOA ; configure_pins( LCD_A0, PIN_ENABLE | PIN_LOW | PIN_OUTPUT | PIN_PORTA | PIN_NO_PULLUP ) ;
pioptr->PIO_PER = LCD_A0 ; // Enable bit 7 (LCD-A0)
pioptr->PIO_CODR = LCD_A0 ;
pioptr->PIO_OER = LCD_A0 ; // Set bit 7 output
pioptr = PIOC ; pioptr = PIOC ;
pioptr->PIO_PER = 0x0C0030FFL ; // Enable bits 27,26,13,12,7-0 pioptr->PIO_PER = 0x0C0030FFL ; // Enable bits 27,26,13,12,7-0
pioptr->PIO_CODR = LCD_E | LCD_RnW ; pioptr->PIO_CODR = LCD_E | LCD_RnW ;

View file

@ -394,7 +394,7 @@ void menuProcModel(uint8_t event)
lcd_outdezNAtt(7*FW,0,g_eeGeneral.currModel+1,INVERS+LEADING0,2); lcd_outdezNAtt(7*FW,0,g_eeGeneral.currModel+1,INVERS+LEADING0,2);
uint8_t protocol = g_model.protocol; uint8_t protocol = g_model.protocol;
MENU(STR_MENUSETUP, menuTabModel, e_Model, (protocol==PROTO_PPM||protocol==PROTO_FAAST||protocol==PROTO_DSM2||protocol==PROTO_PXX ? 12 : 11), {0,ZCHAR|(sizeof(g_model.name)-1),2,2,0,0,0,0,0,6,2,1}); MENU(STR_MENUSETUP, menuTabModel, e_Model, (protocol==PROTO_PPM||protocol==PROTO_FAAST||protocol==PROTO_DSM2||protocol==PROTO_PXX ? 12 : 11), {0,ZCHAR|(sizeof(g_model.name)-1),2,2,0,0,0,0,0,NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1,2,1});
uint8_t sub = m_posVert; uint8_t sub = m_posVert;
uint8_t y = 1*FH; uint8_t y = 1*FH;
@ -469,7 +469,7 @@ void menuProcModel(uint8_t event)
if(s_pgOfs<subN) { if(s_pgOfs<subN) {
lcd_putsLeft( y, STR_TTRACE); lcd_putsLeft( y, STR_TTRACE);
int8_t idx = 3; int8_t idx = 3;
if (g_model.thrTraceSrc > NUM_POTS) idx = NUM_STICKS+2+3+NUM_PPM+g_model.thrTraceSrc; if (g_model.thrTraceSrc > NUM_POTS) idx = NUM_STICKS+NUM_ROTARY_ENCODERS+2+3+NUM_PPM+g_model.thrTraceSrc;
else if (g_model.thrTraceSrc > 0) idx = NUM_STICKS+g_model.thrTraceSrc; else if (g_model.thrTraceSrc > 0) idx = NUM_STICKS+g_model.thrTraceSrc;
putsChnRaw(PARAM_OFS, y, idx, (sub==subN ? INVERS:0)); putsChnRaw(PARAM_OFS, y, idx, (sub==subN ? INVERS:0));
if (sub==subN) CHECK_INCDEC_MODELVAR(event, g_model.thrTraceSrc, 0, NUM_POTS+NUM_CHNOUT); if (sub==subN) CHECK_INCDEC_MODELVAR(event, g_model.thrTraceSrc, 0, NUM_POTS+NUM_CHNOUT);
@ -485,13 +485,13 @@ void menuProcModel(uint8_t event)
if(s_pgOfs<subN) { if(s_pgOfs<subN) {
lcd_putsLeft( y, STR_BEEPCTR); lcd_putsLeft( y, STR_BEEPCTR);
for (uint8_t i=0;i<NUM_STICKS+NUM_POTS;i++) for (uint8_t i=0;i<NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS;i++)
lcd_putsiAtt(PARAM_OFS+i*FW, y, STR_RETA123, i, ((m_posHorz==i) && (sub==subN)) ? BLINK|INVERS : ((g_model.beepANACenter & (1<<i)) ? INVERS : 0 ) ); lcd_putsiAtt(PARAM_OFS+i*FW, y, STR_RETA123, i, ((m_posHorz==i) && (sub==subN)) ? BLINK|INVERS : ((g_model.beepANACenter & ((BeepANACenter)1<<i)) ? INVERS : 0 ) );
if (sub==subN) { if (sub==subN) {
if((event==EVT_KEY_FIRST(KEY_MENU)) || p1valdiff) { if((event==EVT_KEY_FIRST(KEY_MENU)) || p1valdiff) {
killEvents(event); killEvents(event);
s_editMode = 0; s_editMode = 0;
g_model.beepANACenter ^= (1<<m_posHorz); g_model.beepANACenter ^= ((BeepANACenter)1<<m_posHorz);
STORE_MODELVARS; STORE_MODELVARS;
} }
} }
@ -1767,7 +1767,7 @@ void menuProcFunctionSwitches(uint8_t event)
uint8_t func_displayed; uint8_t func_displayed;
if (sd->func < NUM_CHNOUT) { if (sd->func < NUM_CHNOUT) {
func_displayed = 0; func_displayed = 0;
putsChnRaw(14*FW-2, y, NUM_STICKS+NUM_POTS+2+3+NUM_PPM+sd->func+1, attr); putsChnRaw(14*FW-2, y, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+2+3+NUM_PPM+sd->func+1, attr);
} }
else if (sd->func < NUM_CHNOUT + NUM_STICKS + 1) { else if (sd->func < NUM_CHNOUT + NUM_STICKS + 1) {
func_displayed = 1; func_displayed = 1;

View file

@ -436,6 +436,12 @@ enum Dsm2Variants {
#define EXTDATA FrSkyData frsky #define EXTDATA FrSkyData frsky
#endif #endif
#if defined(PCBV4)
#define BeepANACenter uint16_t
#else
#define BeepANACenter uint8_t
#endif
PACK(typedef struct t_ModelData { PACK(typedef struct t_ModelData {
char name[10]; // 10 must be first for eeLoadModelName char name[10]; // 10 must be first for eeLoadModelName
TimerData timers[MAX_TIMERS]; TimerData timers[MAX_TIMERS];
@ -449,7 +455,7 @@ PACK(typedef struct t_ModelData {
uint8_t extendedTrims:1; uint8_t extendedTrims:1;
uint8_t spare2:1; uint8_t spare2:1;
int8_t ppmDelay; int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7 BeepANACenter beepANACenter; // 1<<0->A1.. 1<<6->A7
MixData mixData[MAX_MIXERS]; MixData mixData[MAX_MIXERS];
LimitData limitData[NUM_CHNOUT]; LimitData limitData[NUM_CHNOUT];
ExpoData expoData[MAX_EXPOS]; ExpoData expoData[MAX_EXPOS];

View file

@ -712,7 +712,7 @@ void doSplash()
if(keyDown() || (tsum!=inacSum)) return; //wait for key release if(keyDown() || (tsum!=inacSum)) return; //wait for key release
if (check_power()) return; // Usb on or power off if (check_soft_power() > e_power_trainer) return; // Usb on or power off
checkBacklight(); checkBacklight();
} }
@ -762,7 +762,7 @@ void checkTHR()
int16_t v = anaIn(thrchn); int16_t v = anaIn(thrchn);
if (g_eeGeneral.throttleReversed) v = - v; if (g_eeGeneral.throttleReversed) v = - v;
if (check_power()) return; // Usb on or power off if (check_soft_power() > e_power_trainer) return; // Usb on or power off
if(v<=lowLim || keyDown()) { if(v<=lowLim || keyDown()) {
clearKeyEvents(); clearKeyEvents();
@ -803,7 +803,7 @@ void checkSwitches()
first = false; first = false;
} }
if (check_power()) return; // Usb on or power off if (check_soft_power() > e_power_trainer) return; // Usb on or power off
checkBacklight(); checkBacklight();
@ -825,7 +825,7 @@ void alert(const pm_char * s)
sleep(1/*ms*/); sleep(1/*ms*/);
#endif #endif
if (check_power()) return; // Usb on or power off if (check_soft_power() > e_power_trainer) return; // Usb on or power off
if (keyDown()) return; // wait for key release if (keyDown()) return; // wait for key release
@ -1981,7 +1981,14 @@ void perMain()
g_menuStack[g_menuStackPtr](evt); g_menuStack[g_menuStackPtr](evt);
refreshDisplay(); refreshDisplay();
#if defined(PCBV4) #if defined(PCBARM)
if ( check_soft_power() == e_power_trainer ) { // On trainer power
PIOC->PIO_PDR = PIO_PC22 ; // Disable bit C22 Assign to peripheral
}
else {
PIOC->PIO_PER = PIO_PC22 ; // Enable bit C22 as input
}
#elif defined(PCBV4)
// PPM signal on phono-jack. In or out? ... // PPM signal on phono-jack. In or out? ...
if(checkSlaveMode()) { if(checkSlaveMode()) {
PORTG |= (1<<OUT_G_SIM_CTL); // 1=ppm out PORTG |= (1<<OUT_G_SIM_CTL); // 1=ppm out
@ -2536,7 +2543,7 @@ int main(void)
startPulses(); startPulses();
if (check_power() != e_power_usb) { if (check_soft_power() <= e_power_trainer) {
wdt_enable(WDTO_500MS); wdt_enable(WDTO_500MS);
} }
@ -2548,7 +2555,7 @@ int main(void)
while(1) { while(1) {
#if defined(PCBARM) || defined(PCBV4) #if defined(PCBARM) || defined(PCBV4)
if ((shutdown_state=check_power())) if ((shutdown_state=check_soft_power()) > e_power_trainer)
break; break;
#endif #endif

View file

@ -47,7 +47,7 @@
#endif #endif
#if defined(PCBARM) #if defined(PCBARM)
#include "ersky9x/AT91SAM3S2.h" #include "board_ersky9x.h"
#endif #endif
#if defined(SIMU) #if defined(SIMU)
@ -470,18 +470,19 @@ uint8_t keyDown();
enum PowerState { enum PowerState {
e_power_on, e_power_on,
e_power_trainer,
e_power_usb, e_power_usb,
e_power_off e_power_off
}; };
#if defined(PCBARM) #if defined(PCBARM)
uint32_t keyState(EnumKeys enuk); uint32_t keyState(EnumKeys enuk);
uint32_t check_power(); uint32_t check_soft_power();
#else #else
#if defined(PCBV4) #if defined(PCBV4)
uint8_t check_power(); uint8_t check_soft_power();
#else #else
#define check_power() (e_power_on) #define check_soft_power() (e_power_on)
#endif #endif
bool keyState(EnumKeys enuk); bool keyState(EnumKeys enuk);

View file

@ -103,14 +103,11 @@ void disable_main_ppm()
// TD is on PA17, peripheral A // TD is on PA17, peripheral A
void init_ssc() void init_ssc()
{ {
register Pio *pioptr ;
register Ssc *sscptr ; register Ssc *sscptr ;
PMC->PMC_PCER0 |= 0x00400000L ; // Enable peripheral clock to SSC PMC->PMC_PCER0 |= 0x00400000L ; // Enable peripheral clock to SSC
pioptr = PIOA ;
pioptr->PIO_ABCDSR[0] &= ~0x00020000 ; // Peripheral A bit 17 configure_pins( PIO_PA17, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ;
pioptr->PIO_ABCDSR[1] &= ~0x00020000 ; // Peripheral A
pioptr->PIO_PDR = 0x00020000 ; // Assign to peripheral
sscptr = SSC ; sscptr = SSC ;
sscptr->SSC_CMR = Master_frequency / (125000*2) ; // 8uS per bit sscptr->SSC_CMR = Master_frequency / (125000*2) ; // 8uS per bit
@ -126,7 +123,7 @@ void disable_ssc()
// Revert back to pwm output // Revert back to pwm output
pioptr = PIOA ; pioptr = PIOA ;
pioptr->PIO_PER = 0x00020000L ; // Assign A17 to PIO pioptr->PIO_PER = PIO_PA17 ; // Assign A17 to PIO
sscptr = SSC ; sscptr = SSC ;
sscptr->SSC_CR = SSC_CR_TXDIS ; sscptr->SSC_CR = SSC_CR_TXDIS ;

View file

@ -333,7 +333,7 @@ void Open9xSim::refreshDiplay()
}; };
static SwitchKey keys3[] = { static SwitchKey keys3[] = {
#if defined(JETI) || defined(FRSKY) || defined(NMEA) || defined(ARDUPILOT) #if defined(PCBV4) || defined(JETI) || defined(FRSKY) || defined(NMEA) || defined(ARDUPILOT)
{ KEY_1, pinc, INP_C_ThrCt, 0 }, { KEY_1, pinc, INP_C_ThrCt, 0 },
{ KEY_6, pinc, INP_C_AileDR, 0 }, { KEY_6, pinc, INP_C_AileDR, 0 },
#else #else

View file

@ -33,7 +33,11 @@
#define TR_VTRIMINC "Exp ""ExFine""Fine ""Medium""Coarse" #define TR_VTRIMINC "Exp ""ExFine""Fine ""Medium""Coarse"
#define LEN_RETA123 "\001" #define LEN_RETA123 "\001"
#if defined(PCBV4)
#define TR_RETA123 "RETA123AB"
#else
#define TR_RETA123 "RETA123" #define TR_RETA123 "RETA123"
#endif
#define LEN_VPROTOS "\005" #define LEN_VPROTOS "\005"
#define TR_VPROTOS "PPM\0 ""PXX\0 ""DSM2\0""PPM16""FUT\0 " #define TR_VPROTOS "PPM\0 ""PXX\0 ""DSM2\0""PPM16""FUT\0 "

View file

@ -33,7 +33,11 @@
#define TR_VTRIMINC "Exp ""ExFin ""Fin ""Moyen ""Gros " #define TR_VTRIMINC "Exp ""ExFin ""Fin ""Moyen ""Gros "
#define LEN_RETA123 "\001" #define LEN_RETA123 "\001"
#if defined(PCBV4)
#define TR_RETA123 "RETA123AB"
#else
#define TR_RETA123 "RETA123" #define TR_RETA123 "RETA123"
#endif
#define LEN_VPROTOS "\005" #define LEN_VPROTOS "\005"
#define TR_VPROTOS "PPM\0 ""PXX\0 ""DSM2\0""PPM16""FUT\0 " #define TR_VPROTOS "PPM\0 ""PXX\0 ""DSM2\0""PPM16""FUT\0 "
@ -97,10 +101,11 @@
#define TR_FUNCSOUNDS "Warn1 ""Warn2 ""Cheep ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""Siren ""AlmClk""Ratata""Tick ""Haptc1""Haptc2""Haptc3" #define TR_FUNCSOUNDS "Warn1 ""Warn2 ""Cheep ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""Siren ""AlmClk""Ratata""Tick ""Haptc1""Haptc2""Haptc3"
#define LEN_VTELEMCHNS "\004" #define LEN_VTELEMCHNS "\004"
#define TR_VTELEMCHNS "---\0""A1\0 ""A2\0 ""Alt\0""Rpm\0""Fuel""t1\0 ""t2\0 ""Spd\0""Dist""Cell""Tx\0 ""Rx\0 ""AccX""AccY""AccZ""Hdg\0""VSpd""a1\0 ""a2\0 ""ALT\0""RPM\0""T1\0 ""T2\0 ""SPD\0""DIST""Tmr1""Tmr2""ACC\0""Time" #define TR_VTELEMCHNS "---\0""Tmr1""Tmr2""A1\0 ""A2\0 ""Tx\0 ""Rx\0 ""Alt\0""Rpm\0""Fuel""T1\0 ""T2\0 ""Spd\0""Dist""Cell""AccX""AccY""AccZ""Hdg\0""VSpd""A1-\0""A2-\0""Alt-""Alt+""Rpm+""T1+\0""T2+\0""Spd+""Dst+""Acc\0""Time"
#define LEN_VTELEMUNIT "\003" #define LEN_VTELEMUNIT "\003"
#define TR_VTELEMUNIT "v\0 ""A\0 ""-\0 ""kts""kmh""M/h""m\0 ""@\0 ""%\0" #define TR_VTELEMUNIT "v\0 ""A\0 ""-\0 ""kts""kmh""M/h""m\0 ""@\0 ""%\0"
#define STR_V (STR_VTELEMUNIT+1) #define STR_V (STR_VTELEMUNIT+1)
#define STR_A (STR_VTELEMUNIT+4) #define STR_A (STR_VTELEMUNIT+4)

View file

@ -33,7 +33,11 @@
#define TR_VTRIMINC "Exp ""xFin ""Fin ""Medium""Grov " #define TR_VTRIMINC "Exp ""xFin ""Fin ""Medium""Grov "
#define LEN_RETA123 "\001" #define LEN_RETA123 "\001"
#if defined(PCBV4)
#define TR_RETA123 "RETA123AB"
#else
#define TR_RETA123 "RETA123" #define TR_RETA123 "RETA123"
#endif
#define LEN_VPROTOS "\005" #define LEN_VPROTOS "\005"
#define TR_VPROTOS "PPM\0 ""PXX\0 ""DSM2\0""PPM16""FUT\0 " #define TR_VPROTOS "PPM\0 ""PXX\0 ""DSM2\0""PPM16""FUT\0 "
@ -97,7 +101,7 @@
#define TR_FUNCSOUNDS "Varn1 ""Varn2 ""F\200r ""Ring ""SciFi ""Robot ""Pip ""Tada ""Syrsa ""Siren ""Alarm ""Ratata""Tick ""Vibr1 ""Vibr2 ""Vibr3 " #define TR_FUNCSOUNDS "Varn1 ""Varn2 ""F\200r ""Ring ""SciFi ""Robot ""Pip ""Tada ""Syrsa ""Siren ""Alarm ""Ratata""Tick ""Vibr1 ""Vibr2 ""Vibr3 "
#define LEN_VTELEMCHNS "\004" #define LEN_VTELEMCHNS "\004"
#define TR_VTELEMCHNS "---\0""A1\0 ""A2\0 ""H\202jd""Varv""Tank""t1\0 ""t2\0 ""Fart""Avst""Batt""Tx\0 ""Rx\0 ""AccX""AccY""AccZ""Hdg\0""VSpd""a1\0 ""a2\0 ""H\205JD""VARV""T1\0 ""T2\0 ""H\205JD""AVST""Tmr1""Tmr2""ACC\0""Tid\0" #define TR_VTELEMCHNS "---\0""Tmr1""Tmr2""A1\0 ""A2\0 ""Tx\0 ""Rx\0 ""Alt\0""Rpm\0""Tank""T1\0 ""T2\0 ""Spd\0""Dist""Cell""AccX""AccY""AccZ""Hdg\0""VSpd""A1-\0""A2-\0""Alt-""Alt+""Rpm+""T1+\0""T2+\0""Spd+""Dst+""Acc\0""Tid\0"
#define LEN_VTELEMUNIT "\003" #define LEN_VTELEMUNIT "\003"
#define TR_VTELEMUNIT "v\0 ""A\0 ""-\0 ""kts""kmh""M/h""m\0 ""@\0 ""%\0" #define TR_VTELEMUNIT "v\0 ""A\0 ""-\0 ""kts""kmh""M/h""m\0 ""@\0 ""%\0"