[sky9x] REVC support

This commit is contained in:
bsongis
2012-12-10 08:11:05 +00:00
parent 7e75360ef3
commit fb7525e42d
12 changed files with 200 additions and 180 deletions
+5 -2
View File
@@ -55,7 +55,7 @@ PCB = STD
# PCB revision
# Values: REVA, REVB
PCBREV = REVB
PCBREV =
# Enable JETI-Telemetry or FrSky Telemetry reception on UART0
# For this option you need to modify your hardware!
@@ -245,9 +245,12 @@ ifeq ($(PCB), SKY9X)
ifeq ($(PCBREV), REVA)
CPPDEFS += -DREVA
LDSCRIPT = sky9x/sam3s2c_flash.ld
else
else ifeq ($(PCBREV), REVB)
CPPDEFS += -DREVB
LDSCRIPT = sky9x/sam3s4c_flash.ld
else
CPPDEFS += -DREVC
LDSCRIPT = sky9x/sam3s4c_flash.ld
endif
TRGT = arm-none-eabi-
MCU = cortex-m3
+83 -76
View File
@@ -60,14 +60,17 @@ volatile uint32_t lcdInputs;
#define CPU_INT int32_t
#define CPU_UINT uint32_t
#ifdef REVB
#if !defined(REVA)
inline void init_soft_power()
{
// Configure RF_power (PC17)
configure_pins( PIO_PC17, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_NO_PULLUP | PIN_PULLDOWN ) ;
configure_pins( PIO_PA8, PIN_ENABLE | PIN_INPUT | PIN_PORTA | PIN_PULLUP ) ; // Enable bit A8 (Soft Power)
}
#endif
#if defined(REVC)
bool bootloader_allowed = true;
#endif
uint32_t check_soft_power()
@@ -76,7 +79,17 @@ uint32_t check_soft_power()
return e_power_on;
#endif
#ifdef REVB
#if defined(REVC)
if ( PIOC->PIO_PDSR & PIO_PC17 ) // Power on
{
return e_power_on ;
}
if ( PIOA->PIO_PDSR & PIO_PA8 ) // Trainer plugged in
{
return e_power_trainer ;
}
#elif defined(REVB)
if ( PIOC->PIO_PDSR & PIO_PC17 ) // Power on
{
return e_power_on ;
@@ -111,7 +124,7 @@ uint32_t check_soft_power()
// turn off soft power
void soft_power_off()
{
#ifdef REVB
#if !defined(REVA)
configure_pins( PIO_PA8, PIN_ENABLE | PIN_OUTPUT | PIN_LOW | PIN_PORTA | PIN_NO_PULLUP ) ;
#endif
}
@@ -128,9 +141,7 @@ extern "C" void sam_boot( void ) ;
// PC21, PC19, PC15 (PPM2 output)
inline void config_free_pins()
{
#ifdef REVB
configure_pins( PIO_PB14, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP ) ;
#else
#if defined(REVA)
register Pio * pioptr = PIOA ;
pioptr->PIO_PER = 0x03800000L ; // Enable bits A25,24,23
pioptr->PIO_ODR = 0x03800000L ; // Set as input
@@ -145,37 +156,33 @@ inline void config_free_pins()
pioptr->PIO_PER = 0x01700000L ; // Enable bits C24,22,21,20
pioptr->PIO_ODR = 0x01700000L ; // Set as input
pioptr->PIO_PUER = 0x01700000L ; // Enable pullups
#else
configure_pins( PIO_PB14, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP ) ;
#endif
}
// Assumes PMC has already enabled clocks to ports
inline void setup_switches()
{
#ifdef REVB
configure_pins( 0x01808087, PIN_ENABLE | PIN_INPUT | PIN_PORTA | PIN_PULLUP ) ;
#else
#if defined(REVA)
register Pio *pioptr = PIOA ;
pioptr->PIO_PER = 0xF8008184 ; // Enable bits
pioptr->PIO_ODR = 0xF8008184 ; // Set bits input
pioptr->PIO_PUER = 0xF8008184 ; // Set bits with pullups
#endif
#ifdef REVB
configure_pins( 0x00000030, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP ) ;
#else
pioptr = PIOB ;
pioptr->PIO_PER = 0x00000010 ; // Enable bits
pioptr->PIO_ODR = 0x00000010 ; // Set bits input
pioptr->PIO_PUER = 0x00000010 ; // Set bits with pullups
#endif
#ifdef REVB
configure_pins( 0x91114900, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_PULLUP ) ;
#else
pioptr = PIOC ;
pioptr->PIO_PER = 0x10014900 ; // Enable bits
pioptr->PIO_ODR = 0x10014900 ; // Set bits input
pioptr->PIO_PUER = 0x10014900 ; // Set bits with pullups
#else
configure_pins( 0x01808087, PIN_ENABLE | PIN_INPUT | PIN_PORTA | PIN_PULLUP ) ;
configure_pins( 0x00000030, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP ) ;
configure_pins( 0x91114900, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_PULLUP ) ;
#endif
}
@@ -484,10 +491,10 @@ inline void init_adc()
padc = ADC ;
padc->ADC_MR = 0x14110000 | timer ; // 0001 0100 0001 0001 xxxx xxxx 0000 0000
padc->ADC_ACR = ADC_ACR_TSON ; // Turn on temp sensor
#ifdef REVB
padc->ADC_CHER = 0x0000E33E ; // channels 1,2,3,4,5,8,9,13,14,15
#else
#if defined(REVA)
padc->ADC_CHER = 0x0000E23E ; // channels 1,2,3,4,5,9,13,14,15
#else
padc->ADC_CHER = 0x0000E33E ; // channels 1,2,3,4,5,8,9,13,14,15
#endif
padc->ADC_CGR = 0 ; // Gain = 1, all channels
padc->ADC_COR = 0 ; // Single ended, 0 offset, all channels
@@ -517,17 +524,17 @@ void init_pwm()
MATRIX->CCFG_SYSIO |= 0x00000020L ; // Disable TDO let PB5 work!
/* Configure PIO */
#ifdef REVB
configure_pins( PIO_PA16, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_C | PIN_PORTA | PIN_NO_PULLUP ) ;
#else
#if defined(REVA)
register Pio *pioptr = PIOB ;
pioptr->PIO_PER = 0x00000020L ; // Enable bit B5
pioptr->PIO_ODR = 0x00000020L ; // set as input
#else
configure_pins( PIO_PA16, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_C | PIN_PORTA | PIN_NO_PULLUP ) ;
#endif
configure_pins( PIO_PC18, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP ) ;
#ifdef REVB
#if !defined(REVA)
configure_pins( PIO_PC15, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP ) ;
configure_pins( PIO_PC22, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP ) ;
#endif
@@ -548,7 +555,7 @@ void init_pwm()
pwmptr->PWM_CH_NUM[0].PWM_CDTYUPD = 40 ; // Duty
pwmptr->PWM_ENA = PWM_ENA_CHID0 ; // Enable channel 0
#ifdef REVB
#if !defined(REVA)
// PWM1 for PPM2 output 100Hz test
pwmptr->PWM_CH_NUM[1].PWM_CMR = 0x0000000C ; // CLKB
pwmptr->PWM_CH_NUM[1].PWM_CPDR = 100 ; // Period
@@ -558,7 +565,7 @@ void init_pwm()
pwmptr->PWM_ENA = PWM_ENA_CHID1 ; // Enable channel 1
#endif
#ifdef REVB
#if !defined(REVA)
// PWM2 for HAPTIC drive 100Hz test
pwmptr->PWM_CH_NUM[2].PWM_CMR = 0x0000000C ; // CLKB
pwmptr->PWM_CH_NUM[2].PWM_CPDR = 100 ; // Period
@@ -587,10 +594,10 @@ void init_pwm()
// LCD_D7 PC1
#define LCD_DATA 0x000000FFL
#ifdef REVB
#define LCD_A0 0x00000080L
#else
#if defined(REVA)
#define LCD_A0 0x00008000L
#else
#define LCD_A0 0x00000080L
#endif
#define LCD_RnW 0x00002000L
#define LCD_E 0x00001000L
@@ -678,13 +685,13 @@ void board_init()
PMC->PMC_PCER0 = (1<<ID_PIOC)|(1<<ID_PIOB)|(1<<ID_PIOA)|(1<<ID_UART0) ; // Enable clocks to PIOB and PIOA and PIOC and UART0
pioptr = PIOA ;
#ifdef REVB
init_soft_power() ;
#else
#if defined(REVA)
// On REVB, PA21 is used as AD8, and measures current consumption.
pioptr->PIO_PER = PIO_PA21 ; // Enable bit A21 (EXT3)
pioptr->PIO_OER = PIO_PA21 ; // Set bit A21 as output
pioptr->PIO_SODR = PIO_PA21 ; // Set bit A21 ON
#else
init_soft_power() ;
#endif
// pioptr->PIO_PUER = 0x80000000 ; // Enable pullup on bit A31 (EXIT)
@@ -695,7 +702,7 @@ void board_init()
// pioptr->PIO_OER = 0x80000000L ; // Set bit C31 as output
// pioptr->PIO_SODR = 0x80000000L ; // Set bit C31
#ifndef REVB
#if defined(REVA)
// Configure RF_power (PC17) and PPM-jack-in (PC19), neither need pullups
pioptr->PIO_PER = 0x000A0000L ; // Enable bit C19, C17
pioptr->PIO_ODR = 0x000A0000L ; // Set bits C19 and C17 as input
@@ -704,25 +711,25 @@ void board_init()
config_free_pins() ;
// Next section configures the key inputs on the LCD data
#ifdef REVB
pioptr->PIO_PER = 0x0000003BL ; // Enable bits 1,3,4,5, 0
pioptr->PIO_OER = PIO_PC0 ; // Set bit 0 output
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups
#else
#if defined(REVA)
pioptr->PIO_PER = 0x0000003DL ; // Enable bits 2,3,4,5, 0
pioptr->PIO_OER = PIO_PC0 ; // Set bit 0 output
pioptr->PIO_ODR = 0x0000003CL ; // Set bits 2, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003CL ; // Set bits 2, 3, 4, 5 with pullups
#else
pioptr->PIO_PER = 0x0000003BL ; // Enable bits 1,3,4,5, 0
pioptr->PIO_OER = PIO_PC0 ; // Set bit 0 output
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups
#endif
pioptr = PIOB ;
#ifdef REVB
pioptr->PIO_PUER = PIO_PB5 ; // Enable pullup on bit B5 (MENU)
pioptr->PIO_PER = PIO_PB5 ; // Enable bit B5
#else
#if defined(REVA)
pioptr->PIO_PUER = PIO_PB6 ; // Enable pullup on bit B6 (MENU)
pioptr->PIO_PER = PIO_PB6 ; // Enable bit B6
#else
pioptr->PIO_PUER = PIO_PB5 ; // Enable pullup on bit B5 (MENU)
pioptr->PIO_PER = PIO_PB5 ; // Enable bit B5
#endif
setup_switches() ;
@@ -790,7 +797,17 @@ uint32_t read_keys()
y |= 0x02 << KEY_EXIT;
if (PIOB->PIO_PDSR & 0x000000020)
y |= 0x02 << KEY_ENTER;
#elif defined(REVB)
#elif defined(REVA)
y = (x & 0x00000060);
if (x & 0x00000008)
y |= 0x10;
if (x & 0x00000010)
y |= 0x08;
if (PIOA->PIO_PDSR & 0x80000000)
y |= 0x04; // EXIT
if (PIOB->PIO_PDSR & 0x000000040)
y |= 0x02; // MENU
#else
y = (x & 0x00000020); // RIGHT
if (x & 0x00000004)
y |= 0x02 << KEY_UP; // UP
@@ -802,16 +819,6 @@ uint32_t read_keys()
y |= 0x02 << KEY_EXIT; // EXIT
if (PIOB->PIO_PDSR & 0x000000020)
y |= 0x02 << KEY_MENU; // MENU
#else
y = (x & 0x00000060);
if (x & 0x00000008)
y |= 0x10;
if (x & 0x00000010)
y |= 0x08;
if (PIOA->PIO_PDSR & 0x80000000)
y |= 0x04; // EXIT
if (PIOB->PIO_PDSR & 0x000000040)
y |= 0x02; // MENU
#endif
return y ;
@@ -827,40 +834,40 @@ uint32_t read_trims()
trima = PIOA->PIO_PDSR;
// TRIM_LH_DOWN PA7 (PA23)
#ifdef REVB
if ((trima & 0x00800000) == 0)
#else
#if defined(REVA)
if ( ( trima & 0x0080 ) == 0 )
#else
if ((trima & 0x00800000) == 0)
#endif
{
trims |= 1;
}
// TRIM_LV_DOWN PA27 (PA24)
#ifdef REVB
if ((trima & 0x01000000) == 0)
#else
#if defined(REVA)
if ( ( trima & 0x08000000 ) == 0 )
#else
if ((trima & 0x01000000) == 0)
#endif
{
trims |= 4;
}
// TRIM_RV_UP PA30 (PA1)
#ifdef REVB
if ((trima & 0x00000002) == 0)
#else
#if defined(REVA)
if ( ( trima & 0x40000000 ) == 0 )
#else
if ((trima & 0x00000002) == 0)
#endif
{
trims |= 0x20;
}
// TRIM_RH_DOWN PA29 (PA0)
#ifdef REVB
if ((trima & 0x00000001) == 0)
#else
#if defined(REVA)
if ( ( trima & 0x20000000 ) == 0 )
#else
if ((trima & 0x00000001) == 0)
#endif
{
trims |= 0x40;
@@ -1020,12 +1027,12 @@ extern uint32_t keyState(EnumKeys enuk)
c = PIOC->PIO_PDSR ;
switch ((uint8_t) enuk) {
#ifdef REVB
case SW_ELE:
xxx = c & 0x80000000; // ELE_DR PC31
#else
#if defined(REVA)
case SW_ELE:
xxx = a & 0x00000100; // ELE_DR PA8
#else
case SW_ELE:
xxx = c & 0x80000000; // ELE_DR PC31
#endif
break;
@@ -1055,12 +1062,12 @@ extern uint32_t keyState(EnumKeys enuk)
xxx = c & 0x00010000; // SW_GEAR PC16
break;
#ifdef REVB
case SW_THR:
xxx = c & 0x00100000; // SW_TCUT PC20
#else
#if defined(REVA)
case SW_THR:
xxx = a & 0x10000000; // SW_TCUT PA28
#else
case SW_THR:
xxx = c & 0x00100000; // SW_TCUT PC20
#endif
break;
@@ -1114,7 +1121,7 @@ void read_9_adc()
Analog_values[6] = ADC->ADC_CDR13;
Analog_values[7] = ADC->ADC_CDR14;
#ifdef REVB
#if defined(REVA)
Analog_values[8] = ADC->ADC_CDR8 ;
#endif
@@ -1293,7 +1300,7 @@ void usb_mode()
sam_boot() ;
}
#if defined(REVB)
#if !defined(REVA)
uint16_t getCurrent()
{
static uint16_t Current ;
+10 -1
View File
@@ -91,7 +91,7 @@ extern uint32_t read_keys();
#define DBLKEYS_PRESSED_RGT_UP(i) ((in & (0x20 + 0x10)) == (0x20 + 0x10))
#define DBLKEYS_PRESSED_LFT_DWN(i) ((in & (0x40 + 0x08)) == (0x40 + 0x08))
#if defined(REVB)
#if !defined(REVA)
extern uint16_t Current_analogue;
extern uint16_t Current_max;
extern uint32_t Current_accumulator;
@@ -99,6 +99,15 @@ extern uint32_t Current_used;
extern uint16_t sessionTimer;
#endif
#if defined(REVC)
extern bool bootloader_allowed;
#define SKIP_INIT() (check_soft_power() == e_power_off || (bootloader_allowed && usbPlugged()))
#define BOOTLOADER_REQ() (bootloader_allowed && usbPlugged())
#else
#define SKIP_INIT() (check_soft_power() >= e_power_usb)
#define BOOTLOADER_REQ() (check_soft_power() == e_power_usb)
#endif
#define SLAVE_MODE() (check_soft_power() == e_power_trainer)
#define JACK_PPM_OUT() PIOC->PIO_PDR = PIO_PC22
#define JACK_PPM_IN() PIOC->PIO_PER = PIO_PC22
+1 -1
View File
@@ -542,7 +542,7 @@ void eeReadAll()
modelDefault(0);
if (check_soft_power() < e_power_usb) { // Usb on or power off
if (!SKIP_INIT()) {
/* we remove all models */
for (uint32_t i=0; i<MAX_MODELS; i++)
eeDeleteModel(i);
+2 -2
View File
@@ -849,7 +849,7 @@ void menuGeneralDiagKeys(uint8_t event)
void menuGeneralDiagAna(uint8_t event)
{
#if defined(PCBSKY9X) && defined(REVB)
#if defined(PCBSKY9X) && !defined(REVA)
#define ANAS_ITEMS_COUNT 4
#elif defined(PCBSKY9X)
#define ANAS_ITEMS_COUNT 3
@@ -894,7 +894,7 @@ void menuGeneralDiagAna(uint8_t event)
#endif
if (m_posVert==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatCalib, -127, 127);
#if defined(PCBSKY9X) && defined(REVB)
#if defined(PCBSKY9X) && !defined(REVA)
lcd_putsLeft(6*FH, STR_CURRENT_CALIB);
putsTelemetryValue(LEN_CALIB_FIELDS*FW+4*FW, 6*FH, getCurrent(), UNIT_MILLIAMPS, (m_posVert==2 ? INVERS : 0)) ;
if (m_posVert==2) CHECK_INCDEC_GENVAR(event, g_eeGeneral.currentCalib, -49, 49);
+6 -3
View File
@@ -819,7 +819,7 @@ void menuModelSetup(uint8_t event)
if (protocol <= PROTO_PPMSIM) {
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+7*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, (attr && m_posHorz==1) ? blink : 0);
}
#ifdef DSM2
#if defined(DSM2)
else if (protocol == PROTO_DSM2) {
if (attr && m_posHorz > 1) m_posHorz = 1;
int8_t x = limit((int8_t)0, (int8_t)g_model.ppmNCH, (int8_t)2);
@@ -833,10 +833,13 @@ void menuModelSetup(uint8_t event)
if (attr && (editMode>0 || p1valdiff || (protocol>PROTO_PPMSIM && !IS_DSM2_PROTOCOL(protocol)))) {
switch (m_posHorz) {
case 0:
CHECK_INCDEC_MODELVAR(event, g_model.protocol,0, PROTO_MAX-1);
CHECK_INCDEC_MODELVAR(event, g_model.protocol, 0, PROTO_MAX-1);
#if defined(DSM2_SERIAL)
if (checkIncDec_Ret) resetProto();
#endif
break;
case 1:
#ifdef DSM2
#if defined(DSM2)
if (protocol == PROTO_DSM2)
CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, 0, 2);
else
+9 -9
View File
@@ -1194,7 +1194,7 @@ void doSplash()
#endif
if (keyDown() || (tsum!=inacSum)) return; // wait for key release
if (check_soft_power() > e_power_trainer) return; // usb and power off
if (SKIP_INIT()) return;
#if !defined(PCBSTD)
if (curTime < get_tmr10ms()) {
@@ -1263,7 +1263,7 @@ void checkTHR()
int16_t v = thrAnaIn(thrchn);
if (check_soft_power() > e_power_trainer || v<=lowLim || keyDown())
if (SKIP_INIT() || v<=lowLim || keyDown())
break;
checkBacklight();
@@ -1307,7 +1307,7 @@ void checkSwitches()
last_bad_switches = switches_states;
}
if (keyDown() || check_soft_power() > e_power_trainer) return; // Usb on or power off
if (keyDown() || SKIP_INIT()) return; // Usb on or power off
checkBacklight();
@@ -1325,7 +1325,7 @@ void alert(const pm_char * t, const pm_char *s MESSAGE_SOUND_ARG)
{
SIMU_SLEEP(1);
if (check_soft_power() >= e_power_usb) return; // Usb on or power off
if (SKIP_INIT()) return;
if (keyDown()) return; // wait for key release
@@ -1484,7 +1484,7 @@ uint8_t checkTrim(uint8_t event)
#endif
}
#if defined(PCBSKY9X) && defined(REVB)
#if defined(PCBSKY9X) && !defined(REVA)
uint16_t Current_analogue;
uint16_t Current_max;
uint32_t Current_accumulator;
@@ -1525,7 +1525,7 @@ uint16_t anaIn(uint8_t chan)
// Google Translate (German): // if table already, then it must also be worthwhile
#if defined(PCBSKY9X)
static const uint8_t crossAna[]={1,5,7,0,4,6,2,3,8};
#if defined(REVB)
#if !defined(REVA)
if ( chan == 8 ) {
return Current_analogue ;
}
@@ -2511,7 +2511,7 @@ FORCEINLINE void doMixerCalculations()
getADC();
#if defined(PCBSKY9X) && defined(REVB) && !defined(SIMU)
#if defined(PCBSKY9X) && !defined(REVA) && !defined(SIMU)
Current_analogue = ( Current_analogue * 31 + s_anaFilt[8] ) >> 5 ;
if (Current_analogue > Current_max)
Current_max = Current_analogue ;
@@ -3382,7 +3382,7 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
startPulses();
if (check_soft_power() <= e_power_trainer) {
if (!SKIP_INIT()) {
wdt_enable(WDTO_500MS);
}
}
@@ -3533,7 +3533,7 @@ int main(void)
#endif
#if defined(PCBSKY9X)
if (check_soft_power() == e_power_usb) {
if (BOOTLOADER_REQ()) {
soft_power_off(); // Only turn power off if necessary
#if defined(HAPTIC)
+6 -6
View File
@@ -721,14 +721,14 @@ enum PowerState {
uint32_t keyState(EnumKeys enuk);
uint32_t check_soft_power();
#else
bool keyState(EnumKeys enuk);
#if defined(PCBGRUVIN9X)
uint8_t check_soft_power();
#else
#define check_soft_power() (e_power_on)
#endif
bool keyState(EnumKeys enuk);
#endif
void readKeysAndTrims();
uint16_t evalChkSum();
@@ -911,13 +911,13 @@ extern void backlightOn();
#if defined (PCBSKY9X)
#define __BACKLIGHT_ON (PWM->PWM_CH_NUM[0].PWM_CDTY = g_eeGeneral.backlightBright)
#define __BACKLIGHT_OFF (PWM->PWM_CH_NUM[0].PWM_CDTY = 100)
#ifdef REVB
#define NUMBER_ANALOG 9
#else
#if defined(REVA)
#define NUMBER_ANALOG 8
#else
#define NUMBER_ANALOG 9
#endif
extern uint16_t Analog_values[NUMBER_ANALOG] ;
void read_9_adc(void ) ;
#endif
#elif defined (PCBGRUVIN9X)
#define SPEAKER_ON TCCR0A |= (1 << COM0A0)
#define SPEAKER_OFF TCCR0A &= ~(1 << COM0A0)
+9 -9
View File
@@ -239,7 +239,15 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
if(hasFocus()) {
#if defined(PCBX9D) || defined(REVB)
#if defined(PCBSKY9X) && defined(REVA)
#define ERSKY9X_RETURN_MASK (0x40)
#define ERSKY9X_EXIT_MASK (0x80000000)
#define ERSKY9X_EXIT_PIO PIOA
#define ERSKY9X_UP_MASK (0x08 >> 1)
#define ERSKY9X_RIGHT_MASK (0x20 >> 1)
#define ERSKY9X_DOWN_MASK (0x10 >> 1)
#define ERSKY9X_LEFT_MASK (0x40 >> 1)
#else
#define ERSKY9X_RETURN_MASK (0x20)
#define ERSKY9X_EXIT_MASK (0x01000000)
#define ERSKY9X_EXIT_PIO PIOC
@@ -249,14 +257,6 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
#define ERSKY9X_LEFT_MASK (0x10 >> 1)
#define ERSKY9X_MENU_MASK (0x04 >> 1)
#define ERSKY9X_PAGE_MASK (0x40 >> 1)
#else
#define ERSKY9X_RETURN_MASK (0x40)
#define ERSKY9X_EXIT_MASK (0x80000000)
#define ERSKY9X_EXIT_PIO PIOA
#define ERSKY9X_UP_MASK (0x08 >> 1)
#define ERSKY9X_RIGHT_MASK (0x20 >> 1)
#define ERSKY9X_DOWN_MASK (0x10 >> 1)
#define ERSKY9X_LEFT_MASK (0x40 >> 1)
#endif
static uint64_t keys1[]={
KEY_Return, INP_B_KEY_MEN, INP_L_KEY_MEN, (uint64_t)PIOB, ERSKY9X_RETURN_MASK,
+45 -45
View File
@@ -49,7 +49,7 @@
// LCD_D7 PC1
#define LCD_DATA 0x000000FFL
#ifdef REVB
#if !defined(REVA)
#define LCD_A0 0x00000080L
#else
#define LCD_A0 0x00008000L
@@ -60,7 +60,7 @@
#define LCD_RES 0x08000000L
// Lookup table for prototype board
#ifndef REVB
#if defined(REVA)
const uint8_t Lcd_lookup[] =
{
0x00,0x01,0x80,0x81,0x40,0x41,0xC0,0xC1,0x20,0x21,0xA0,0xA1,0x60,0x61,0xE0,0xE1,
@@ -87,18 +87,18 @@ void lcdSendCtl(uint8_t val)
register Pio *pioptr ;
// register uint32_t x ;
#ifdef REVB
pioptr = PIOC ;
pioptr->PIO_CODR = LCD_CS1 ; // Select LCD
PIOA->PIO_CODR = LCD_A0 ;
pioptr->PIO_CODR = LCD_RnW ; // Write
pioptr->PIO_ODSR = val ;
#else
#if defined(REVA)
pioptr = PIOC ;
pioptr->PIO_CODR = LCD_CS1 ; // Select LCD
pioptr->PIO_CODR = LCD_A0 ; // Control
pioptr->PIO_CODR = LCD_RnW ; // Write
pioptr->PIO_ODSR = Lcd_lookup[val] ;
#else
pioptr = PIOC ;
pioptr->PIO_CODR = LCD_CS1 ; // Select LCD
PIOA->PIO_CODR = LCD_A0 ;
pioptr->PIO_CODR = LCD_RnW ; // Write
pioptr->PIO_ODSR = val ;
#endif
pioptr->PIO_SODR = LCD_E ; // Start E pulse
@@ -109,12 +109,12 @@ void lcdSendCtl(uint8_t val)
// Wait
}
pioptr->PIO_CODR = LCD_E ; // End E pulse
#ifdef REVB
PIOA->PIO_SODR = LCD_A0 ; // Data
#else
#if defined(REVA)
pioptr->PIO_SODR = LCD_A0 ; // Data
#else
PIOA->PIO_SODR = LCD_A0 ; // Data
#endif
pioptr->PIO_SODR = LCD_CS1 ; // Deselect LCD
pioptr->PIO_SODR = LCD_CS1 ; // Deselect LCD
}
void lcd_init()
@@ -123,7 +123,14 @@ void lcd_init()
// /home/thus/txt/datasheets/lcd/KS0713.pdf
// ~/txt/flieger/ST7565RV17.pdf from http://www.glyn.de/content.asp?wdid=132&sid=
#ifdef REVB
#if defined(REVA)
pioptr = PIOC ;
pioptr->PIO_PER = 0x0C00B0FFL ; // Enable bits 27,26,15,13,12,7-0
pioptr->PIO_CODR = LCD_E | LCD_RnW | LCD_A0 ;
pioptr->PIO_SODR = LCD_RES | LCD_CS1 ;
pioptr->PIO_OER = 0x0C00B0FFL ; // Set bits 27,26,15,13,12,7-0 output
pioptr->PIO_OWER = 0x000000FFL ; // Allow write to ls 8 bits in ODSR
#else
configure_pins( LCD_A0, PIN_ENABLE | PIN_LOW | PIN_OUTPUT | PIN_PORTA | PIN_NO_PULLUP ) ;
pioptr = PIOC ;
pioptr->PIO_PER = 0x0C0030FFL ; // Enable bits 27,26,13,12,7-0
@@ -131,13 +138,6 @@ void lcd_init()
pioptr->PIO_SODR = LCD_RES | LCD_CS1 ;
pioptr->PIO_OER = 0x0C0030FFL ; // Set bits 27,26,13,12,7-0 output
pioptr->PIO_OWER = 0x000000FFL ; // Allow write to ls 8 bits in ODSR
#else
pioptr = PIOC ;
pioptr->PIO_PER = 0x0C00B0FFL ; // Enable bits 27,26,15,13,12,7-0
pioptr->PIO_CODR = LCD_E | LCD_RnW | LCD_A0 ;
pioptr->PIO_SODR = LCD_RES | LCD_CS1 ;
pioptr->PIO_OER = 0x0C00B0FFL ; // Set bits 27,26,15,13,12,7-0 output
pioptr->PIO_OWER = 0x000000FFL ; // Allow write to ls 8 bits in ODSR
#endif
pioptr->PIO_CODR = LCD_RES ; // Reset LCD
@@ -166,14 +166,14 @@ void lcd_init()
lcdSendCtl(0xAF); //DON = 1: display ON
// g_eeGeneral.contrast = 0x22;
#ifdef REVB
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups
pioptr->PIO_ODSR = 0 ; // Drive D0 low
#else
#if defined(REVA)
pioptr->PIO_ODR = 0x0000003CL ; // Set bits 2, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003CL ; // Set bits 2, 3, 4, 5 with pullups
pioptr->PIO_ODSR = 0 ; // Drive D0 low
#else
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups
pioptr->PIO_ODSR = 0 ; // Drive D0 low
#endif
}
@@ -195,12 +195,12 @@ void lcdSetRefVolt(uint8_t val)
}
lcdSendCtl(val);
#ifdef REVB
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups
#else
#if defined(REVA)
pioptr->PIO_ODR = 0x0000003CL ; // Set bits 2, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003CL ; // Set bits 2, 3, 4, 5 with pullups
#else
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups
#endif
pioptr->PIO_ODSR = lcdInputs; // Drive D0 low
@@ -215,14 +215,14 @@ void refreshDisplay()
register uint32_t x;
register uint32_t z;
register uint32_t ebit;
#ifndef REVB
#if defined(REVA)
register uint8_t *lookup;
lookup = (uint8_t *) Lcd_lookup;
#endif
ebit = LCD_E;
#ifdef REVB
#if !defined(REVA)
pioptr = PIOA;
pioptr->PIO_PER = 0x00000080; // Enable bit 7 (LCD-A0)
pioptr->PIO_OER = 0x00000080;// Set bit 7 output
@@ -233,10 +233,10 @@ void refreshDisplay()
lcdLock = 1 ;
pioptr = PIOC;
#ifdef REVB
pioptr->PIO_OER = 0x0C0030FFL; // Set bits 27,26,15,13,12,7-0 output
#else
#if defined(REVA)
pioptr->PIO_OER = 0x0C00B0FFL; // Set bits 27,26,15,13,12,7-0 output
#else
pioptr->PIO_OER = 0x0C0030FFL; // Set bits 27,26,15,13,12,7-0 output
#endif
for (y = 0; y < 8; y++) {
lcdSendCtl(g_eeGeneral.optrexDisplay ? 0 : 0x04);
@@ -247,10 +247,10 @@ void refreshDisplay()
PIOA->PIO_SODR = LCD_A0; // Data
pioptr->PIO_CODR = LCD_RnW; // Write
#ifdef REVB
x = *p;
#else
#if defined(REVA)
x = lookup[*p];
#else
x = *p;
#endif
for (z = 0; z < DISPLAY_W; z += 1) {
@@ -267,10 +267,10 @@ void refreshDisplay()
pioptr->PIO_SODR = ebit; // Start E pulse
// Need a delay here (250nS)
p += 1;
#ifdef REVB
x = *p;
#else
#if defined(REVA)
x = lookup[*p];
#else
x = *p;
#endif
// TC0->TC_CHANNEL[0].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
// while ( TC0->TC_CHANNEL[0].TC_CV < 3 ) // Value depends on MCK/2 (used 6MHz)
@@ -283,12 +283,12 @@ void refreshDisplay()
}
pioptr->PIO_ODSR = 0xFF ; // Drive lines high
#ifdef REVB
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input
#else
#if defined(REVA)
pioptr->PIO_PUER = 0x0000003CL ; // Set bits 2, 3, 4, 5 with pullups
pioptr->PIO_ODR = 0x0000003CL ; // Set bits 2, 3, 4, 5 input
#else
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input
#endif
pioptr->PIO_ODSR = lcdInputs; // Drive D0 low
+23 -25
View File
@@ -62,18 +62,28 @@ void startSound()
init_twi() ;
pioptr = PIOA ;
#ifdef REVB
pioptr->PIO_CODR = 0x02000000L ; // Set bit A25 OFF
pioptr->PIO_PER = 0x02000000L ; // Enable bit A25 (Stock buzzer)
pioptr->PIO_OER = 0x02000000L ; // Set bit A25 as output
#else
#if defined(REVA)
pioptr->PIO_CODR = 0x00010000L ; // Set bit A16 OFF
pioptr->PIO_PER = 0x00010000L ; // Enable bit A16 (Stock buzzer)
pioptr->PIO_OER = 0x00010000L ; // Set bit A16 as output
#else
pioptr->PIO_CODR = 0x02000000L ; // Set bit A25 OFF
pioptr->PIO_PER = 0x02000000L ; // Enable bit A25 (Stock buzzer)
pioptr->PIO_OER = 0x02000000L ; // Set bit A25 as output
#endif
}
#ifdef REVB
#if defined(REVA)
void buzzer_on()
{
PIOA->PIO_SODR = 0x00010000L ; // Set bit A16 ON
}
void buzzer_off()
{
PIOA->PIO_CODR = 0x00010000L ; // Set bit A16 ON
}
#else
void buzzer_on()
{
PIOA->PIO_SODR = 0x02000000L ; // Set bit A25 ON
@@ -83,16 +93,6 @@ void buzzer_off()
{
PIOA->PIO_CODR = 0x02000000L ; // Set bit A25 ON
}
#else
void buzzer_on()
{
PIOA->PIO_SODR = 0x00010000L ; // Set bit A16 ON
}
void buzzer_off()
{
PIOA->PIO_CODR = 0x00010000L ; // Set bit A16 ON
}
#endif
void buzzer_sound( uint8_t time )
@@ -153,7 +153,7 @@ void start_timer1()
}
// Configure DAC1 (or DAC0 for REVB)
// Configure DAC0 (or DAC1 for REVA)
// Not sure why PB14 has not be allocated to the DAC, although it is an EXTRA function
// So maybe it is automatically done
void initDac()
@@ -162,16 +162,14 @@ void initDac()
PMC->PMC_PCER0 |= 0x40000000L ; // Enable peripheral clock to DAC
dacptr = DACC ;
#ifdef REVB
#if defined(REVA)
dacptr->DACC_MR = 0x0B010215L ; // 0000 1011 0000 0001 0000 0010 0001 0101
dacptr->DACC_CHER = 2 ; // Enable channel 1
#else
dacptr->DACC_MR = 0x0B000215L ; // 0000 1011 0000 0001 0000 0010 0001 0101
#else
dacptr->DACC_MR = 0x0B010215L ; // 0000 1011 0000 0001 0000 0010 0001 0101
#endif
#ifdef REVB
dacptr->DACC_CHER = 1 ; // Enable channel 0
#else
dacptr->DACC_CHER = 2 ; // Enable channel 1
dacptr->DACC_CHER = 1 ; // Enable channel 0
#endif
dacptr->DACC_CDR = 2048 ; // Half amplitude
// Data for PDC must NOT be in flash, PDC needs a RAM source.
dacptr->DACC_TPR = CONVERT_PTR(Sine_values);
+1 -1
View File
@@ -121,7 +121,7 @@ void menuStatisticsDebug(uint8_t event)
}
#if defined(PCBSKY9X)
#if defined(REVB)
#if !defined(REVA)
lcd_putsLeft(1*FH, STR_CPU_CURRENT);
putsTelemetryValue(MENU_DEBUG_COL_OFS, 1*FH, getCurrent(), UNIT_MILLIAMPS, 0);
uint32_t current_scale = 488 + g_eeGeneral.currentCalib;