SKY9X-REVA removed as it doesn't even build since 2.2

This commit is contained in:
Bertrand Songis
2019-05-19 17:33:14 +02:00
parent 5883bb53ea
commit 0ec34fd72c
19 changed files with 81 additions and 351 deletions
+3 -3
View File
@@ -117,7 +117,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_EXTERNAL_MODULE_PXX2_RECEIVER_1,
ITEM_MODEL_EXTERNAL_MODULE_PXX2_RECEIVER_2,
ITEM_MODEL_EXTERNAL_MODULE_PXX2_RECEIVER_3,
#if defined(PCBSKY9X) && !defined(REVA)
#if defined(PCBSKY9X)
ITEM_MODEL_EXTRA_MODULE_LABEL,
ITEM_MODEL_EXTRA_MODULE_CHANNELS,
ITEM_MODEL_EXTRA_MODULE_BIND,
@@ -157,7 +157,7 @@ enum MenuModelSetupItems {
#if defined(PCBTARANIS)
#define CURRENT_MODULE_EDITED(k) (k >= ITEM_MODEL_EXTERNAL_MODULE_LABEL ? EXTERNAL_MODULE : INTERNAL_MODULE)
#define CURRENT_RECEIVER_EDITED(k) (k - (k >= ITEM_MODEL_EXTERNAL_MODULE_LABEL ? ITEM_MODEL_EXTERNAL_MODULE_PXX2_RECEIVER_1 : ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_1))
#elif defined(PCBSKY9X) && !defined(REVA)
#elif defined(PCBSKY9X)
#define CURRENT_MODULE_EDITED(k) (k >= ITEM_MODEL_EXTRA_MODULE_LABEL ? EXTRA_MODULE : EXTERNAL_MODULE)
#else
#define CURRENT_MODULE_EDITED(k) (EXTERNAL_MODULE)
@@ -189,7 +189,7 @@ enum MenuModelSetupItems {
#define POT_WARN_ITEMS() ((g_model.potsWarnMode) ? (uint8_t)(NUM_POTS+NUM_SLIDERS) : (uint8_t)0)
#define TIMER_ROWS 2, 0, 0, 0, 0
#if defined(PCBSKY9X) && !defined(REVA)
#if defined(PCBSKY9X)
#define EXTRA_MODULE_ROWS LABEL(ExtraModule), 1, 2,
#else
#define EXTRA_MODULE_ROWS
+1 -1
View File
@@ -467,7 +467,7 @@ void perMain()
{
DEBUG_TIMER_START(debugTimerPerMain1);
#if defined(PCBSKY9X) && !defined(REVA)
#if defined(PCBSKY9X)
calcConsumption();
#endif
checkSpeakerVolume();
+1 -3
View File
@@ -1348,7 +1348,7 @@ void doMixerCalculations()
getSwitchesPosition(!s_mixer_first_run_done);
DEBUG_TIMER_STOP(debugTimerGetSwitches);
#if defined(PCBSKY9X) && !defined(REVA) && !defined(SIMU)
#if defined(PCBSKY9X) && !defined(SIMU)
Current_analogue = (Current_analogue*31 + s_anaFilt[8] ) >> 5 ;
if (Current_analogue > Current_max)
Current_max = Current_analogue ;
@@ -1556,12 +1556,10 @@ void opentxClose(uint8_t shutdown)
storageFlushCurrentModel();
#if !defined(REVA)
if (sessionTimer > 0) {
g_eeGeneral.globalTimer += sessionTimer;
sessionTimer = 0;
}
#endif
#if defined(PCBSKY9X)
uint32_t mAhUsed = g_eeGeneral.mAhUsed + Current_used * (488 + g_eeGeneral.txCurrentCalibration) / 8192 / 36;
+1 -4
View File
@@ -179,11 +179,9 @@
#define CASE_PCBX9E(x)
#endif
#if defined(PCBSKY9X) && !defined(PCBAR9X) && !defined(REVA)
#if defined(PCBSKY9X)
#define TX_CAPACITY_MEASUREMENT
#define CASE_CAPACITY(x) x,
#else
#define CASE_CAPACITY(x)
#endif
#if defined(FAI)
@@ -1279,7 +1277,6 @@ extern uint8_t s_frsky_view;
#endif
constexpr uint32_t EARTH_RADIUS = 6371009;
constexpr uint32_t PRECALCULATED_EARTH_RADIUS_CONSTANT = 111194; // meters * pi / 180°
void getGpsPilotPosition();
void getGpsDistance();
@@ -43,7 +43,7 @@ void dacTimerInit()
AUDIO_TIMER->CR1 = TIM_CR1_CEN ;
}
// Configure DAC0 (or DAC1 for REVA)
// Configure DAC0
// Not sure why PB14 has not be allocated to the DAC, although it is an EXTRA function
// So maybe it is automatically done
void dacInit()
+10 -16
View File
@@ -36,8 +36,8 @@ elseif(PCB STREQUAL AR9X)
set(CPU_TYPE_FULL ATSAM3S8C) # for size report
else()
set(FLAVOUR sky9x)
set(PCBREV "REVC" CACHE STRING "PCB Revision (REVA/REVB/REVC)")
set_property(CACHE PCBREV PROPERTY STRINGS "REVA" "REVB" "REVC")
set(PCBREV "REVC" CACHE STRING "PCB Revision (REVB/REVC)")
set_property(CACHE PCBREV PROPERTY STRINGS "REVB" "REVC")
set(TARGET_SRC
${TARGET_SRC}
coproc_driver.cpp
@@ -45,22 +45,16 @@ else()
rtc_driver.cpp
)
set(OPENRC_BOOTLOADER bootflash4.lbm)
if(PCBREV STREQUAL REVA)
add_definitions(-DDREVA)
set(LINKER_SCRIPT targets/sky9x/sam3s2c_flash.ld)
set(CPU_TYPE_FULL ATSAM3S2C) # for size report
if(PCBREV STREQUAL REVB)
add_definitions(-DDREVB)
elseif(PCBREV STREQUAL REVC)
add_definitions(-DDREVC)
else()
if(PCBREV STREQUAL REVB)
add_definitions(-DDREVB)
elseif(PCBREV STREQUAL REVC)
add_definitions(-DDREVC)
else()
message(SEND_ERROR "Unknown PCB Revision '${PCBREV}'")
endif()
add_definitions(-DCOPROCESSOR)
set(LINKER_SCRIPT targets/sky9x/sam3s4c_flash.ld)
set(CPU_TYPE_FULL ATSAM3S4C) # for size report
message(SEND_ERROR "Unknown PCB Revision '${PCBREV}'")
endif()
add_definitions(-DCOPROCESSOR)
set(LINKER_SCRIPT targets/sky9x/sam3s4c_flash.ld)
set(CPU_TYPE_FULL ATSAM3S4C) # for size report
endif()
add_definitions(-DPCBSKY9X -DPPM_PIN_SERIAL -DAUDIO_DUAL_BUFFER)
+1 -8
View File
@@ -52,11 +52,7 @@ void adcInit()
padc = ADC ;
padc->ADC_MR = 0x3FB60000 | timer ; // 0011 1111 1011 0110 xxxx xxxx 0000 0000
padc->ADC_ACR = ADC_ACR_TSON ; // Turn on temp sensor
#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
}
@@ -92,10 +88,7 @@ void adcSingleRead()
adcValues[5] = ADC->ADC_CDR9;
adcValues[6] = ADC->ADC_CDR13;
adcValues[7] = ADC->ADC_CDR14;
#if !defined(REVA)
adcValues[8] = ADC->ADC_CDR8 ;
#endif
temperature = (((int32_t)temperature * 7) + ((((int32_t)ADC->ADC_CDR15 - 838) * 621) >> 11)) >> 3; // Filter it
if (get_tmr10ms() >= 100 && temperature > maxTemperature) {
@@ -139,7 +132,7 @@ void adcRead()
#if !defined(SIMU)
uint16_t getAnalogValue(uint8_t index)
{
#if defined(PCBSKY9X) && !defined(REVA)
#if defined(PCBSKY9X)
static const uint8_t mapping[] = {1,5,7,0,4,6,2,3};
index = mapping[index];
#endif
+2 -14
View File
@@ -72,7 +72,7 @@ void dacTimerStart()
// Sound_g.Frequency = 1000 ;
}
// Configure DAC0 (or DAC1 for REVA)
// Configure DAC0
// Not sure why PB14 has not be allocated to the DAC, although it is an EXTRA function
// So maybe it is automatically done
void dacInit()
@@ -83,17 +83,11 @@ void dacInit()
Dacc *dacptr = DACC;
#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
dacptr->DACC_CHER = 1 ; // Enable channel 0
#endif
dacptr->DACC_CDR = 2048 ; // Half amplitude
dacptr->DACC_PTCR = DACC_PTCR_TXTEN ;
NVIC_EnableIRQ(DACC_IRQn) ;
}
@@ -154,15 +148,9 @@ void audioInit()
dacInit() ;
pioptr = PIOA ;
#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
#if defined(REVX)
configure_pins( PIO_PC26, PIN_ENABLE | PIN_LOW | PIN_OUTPUT | PIN_PORTC | PIN_NO_PULLUP ) ;
+2 -84
View File
@@ -30,12 +30,10 @@ volatile uint32_t Tenms ;
volatile uint8_t lcdLock;
volatile uint32_t lcdInputs;
#if !defined(REVA)
uint16_t Current_analogue;
uint16_t Current_max;
uint32_t Current_accumulator;
uint32_t Current_used;
#endif
extern "C" void sam_boot( void ) ;
@@ -49,49 +47,15 @@ extern "C" void sam_boot( void ) ;
// PC21, PC19, PC15 (PPM2 output)
inline void config_free_pins()
{
#if defined(REVA)
Pio * pioptr = PIOA ;
pioptr->PIO_PER = 0x03800000L ; // Enable bits A25,24,23
pioptr->PIO_ODR = 0x03800000L ; // Set as input
pioptr->PIO_PUER = 0x03800000L ; // Enable pullups
pioptr = PIOB ;
pioptr->PIO_PER = 0x00002080L ; // Enable bits B13, 7
pioptr->PIO_ODR = 0x00002080L ; // Set as input
pioptr->PIO_PUER = 0x00002080L ; // Enable pullups
pioptr = PIOC ;
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()
{
#if defined(REVA)
Pio *pioptr = PIOA ;
pioptr->PIO_PER = 0xF8008184 ; // Enable bits
pioptr->PIO_ODR = 0xF8008184 ; // Set bits input
pioptr->PIO_PUER = 0xF8008184 ; // Set bits with pullups
pioptr = PIOB ;
pioptr->PIO_PER = 0x00000010 ; // Enable bits
pioptr->PIO_ODR = 0x00000010 ; // Set bits input
pioptr->PIO_PUER = 0x00000010 ; // Set bits with pullups
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
}
#if !defined(SIMU)
@@ -228,19 +192,10 @@ void init_pwm()
MATRIX->CCFG_SYSIO |= 0x00000020L ; // Disable TDO let PB5 work!
/* Configure PIO */
#if defined(REVA)
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 ) ;
#if !defined(REVA)
configure_pins( PIO_PC22, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP ) ;
#endif
// Configure clock - depends on MCK frequency
timer = Master_frequency / 2000000 ;
@@ -258,7 +213,6 @@ void init_pwm()
pwmptr->PWM_CH_NUM[0].PWM_CDTYUPD = 40 ; // Duty
pwmptr->PWM_ENA = PWM_ENA_CHID0 ; // Enable channel 0
#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
@@ -267,8 +221,7 @@ void init_pwm()
pwmptr->PWM_CH_NUM[2].PWM_CDTYUPD = 40 ; // Duty
pwmptr->PWM_OOV &= ~0x00040000 ; // Force low
pwmptr->PWM_OSS = 0x00040000 ; // Force low
// pwmptr->PWM_ENA = PWM_ENA_CHID2 ; // Enable channel 2 // TODO on REVA?
#endif
// pwmptr->PWM_ENA = PWM_ENA_CHID2 ; // Enable channel 2
}
// LCD i/o pins
@@ -287,11 +240,7 @@ void init_pwm()
// LCD_D7 PC1
#define LCD_DATA 0x000000FFL
#if defined(REVA)
#define LCD_A0 0x00008000L
#else
#define LCD_A0 0x00000080L
#endif
#define LCD_RnW 0x00002000L
#define LCD_E 0x00001000L
#define LCD_CS1 0x04000000L
@@ -411,46 +360,20 @@ void boardInit()
PIOC->PIO_PER = PIO_PC25 ; // Enable bit C25 (USB-detect)
#if defined(REVA)
// On REVB, PA21 is used as AD8, and measures current consumption.
pioptr = PIOA ;
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
// 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
#endif
#if !defined(REVA)
pwrInit() ;
#endif
config_free_pins() ;
// Next section configures the key inputs on the LCD data
pioptr = PIOC;
#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 ;
#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() ;
@@ -497,14 +420,13 @@ void end_bt_tx_interrupt()
NVIC_DisableIRQ(UART1_IRQn) ;
}
#if !defined(REVA)
uint16_t getCurrent()
{
static uint16_t Current ;
static uint32_t Current_sum ;
static uint8_t Current_count ;
Current_sum += anaIn(8); // TODO enum
Current_sum += anaIn(TX_CURRENT);
if (++Current_count >= 50) {
Current = Current_sum / 5 ;
Current_sum = 0 ;
@@ -514,7 +436,6 @@ uint16_t getCurrent()
uint32_t current_scale = 488 + g_eeGeneral.txCurrentCalibration ;
return (current_scale * Current) / 8192;
}
#endif
uint8_t getTemperature()
{
@@ -567,8 +488,6 @@ void setSticksGain(uint8_t gains)
padc->ADC_COR = offset;
}
#if !defined(REVA)
void calcConsumption()
{
Current_accumulator += Current_analogue ;
@@ -579,7 +498,6 @@ void calcConsumption()
Current_accumulator = 0 ;
}
}
#endif
void checkTrainerSettings()
{
+12 -42
View File
@@ -95,33 +95,18 @@ enum EnumSwitches
#define IS_3POS(sw) ((sw) == 0)
#define IS_TOGGLE(sw) ((sw) == SWSRC_TRN)
#if defined(REVA)
#define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR
#define KEYS_GPIO_REG_EXIT PIOA->PIO_PDSR
#define KEYS_GPIO_REG_UP PIOC->PIO_PDSR
#define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR
#define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR
#define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR
#define KEYS_GPIO_PIN_MENU 0x00000040
#define KEYS_GPIO_PIN_EXIT 0x80000000
#define KEYS_GPIO_PIN_UP 0x00000004
#define KEYS_GPIO_PIN_DOWN 0x00000008
#define KEYS_GPIO_PIN_RIGHT 0x00000010
#define KEYS_GPIO_PIN_LEFT 0x00000020
#else
#define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR
#define KEYS_GPIO_REG_EXIT PIOC->PIO_PDSR
#define KEYS_GPIO_REG_UP PIOC->PIO_PDSR
#define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR
#define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR
#define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR
#define KEYS_GPIO_PIN_MENU 0x00000020
#define KEYS_GPIO_PIN_EXIT 0x01000000
#define KEYS_GPIO_PIN_UP 0x00000002
#define KEYS_GPIO_PIN_DOWN 0x00000020
#define KEYS_GPIO_PIN_RIGHT 0x00000010
#define KEYS_GPIO_PIN_LEFT 0x00000008
#endif
#define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR
#define KEYS_GPIO_REG_EXIT PIOC->PIO_PDSR
#define KEYS_GPIO_REG_UP PIOC->PIO_PDSR
#define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR
#define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR
#define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR
#define KEYS_GPIO_PIN_MENU 0x00000020
#define KEYS_GPIO_PIN_EXIT 0x01000000
#define KEYS_GPIO_PIN_UP 0x00000002
#define KEYS_GPIO_PIN_DOWN 0x00000020
#define KEYS_GPIO_PIN_RIGHT 0x00000010
#define KEYS_GPIO_PIN_LEFT 0x00000008
#if defined(REVX)
#define TRIMS_GPIO_REG_LHL PIOB->PIO_PDSR
@@ -152,15 +137,6 @@ enum EnumSwitches
#define TRIMS_GPIO_PIN_LVU 0x10000000
#define TRIMS_GPIO_PIN_RVD 0x00000002
#define TRIMS_GPIO_PIN_RHR 0x00000200
#elif defined(REVA)
#define TRIMS_GPIO_PIN_LHL 0x00000080
#define TRIMS_GPIO_PIN_LVD 0x08000000
#define TRIMS_GPIO_PIN_RVU 0x40000000
#define TRIMS_GPIO_PIN_RHL 0x20000000
#define TRIMS_GPIO_PIN_LHR 0x00000010
#define TRIMS_GPIO_PIN_LVU 0x10000000
#define TRIMS_GPIO_PIN_RVD 0x00000400
#define TRIMS_GPIO_PIN_RHR 0x00000200
#else
#define TRIMS_GPIO_PIN_LHL 0x00800000
#define TRIMS_GPIO_PIN_LVD 0x01000000
@@ -221,14 +197,12 @@ extern uint8_t temperature ; // Raw temp reading
extern uint8_t maxTemperature ; // Raw temp reading
uint8_t getTemperature();
#if !defined(REVA)
extern uint16_t Current_analogue;
extern uint16_t Current_max;
extern uint32_t Current_accumulator;
extern uint32_t Current_used;
extern uint16_t sessionTimer;
void calcConsumption();
#endif
// Trainer driver
#define SLAVE_MODE() (pwrCheck() == e_power_trainer)
@@ -317,9 +291,7 @@ enum Analogs {
POT3,
POT_LAST = POT3,
TX_VOLTAGE,
#if !defined(REVA)
TX_CURRENT,
#endif
NUM_ANALOGS
};
enum CalibratedAnalogs {
@@ -383,9 +355,7 @@ void btPushByte(uint8_t data);
// Power driver
#define TRAINER_PWR
#if !defined(REVA)
#define SOFT_PWR_CTRL
#endif
void pwrInit();
void pwrOff();
uint32_t pwrCheck();
-6
View File
@@ -24,14 +24,8 @@
#define _BOARD_H_
#include <stdint.h>
#include "chip.h"
#if defined(REVA)
#include "AT91SAM3S2.h"
#else
#include "AT91SAM3S4.h"
#endif
#if !defined(SIMU)
#include "core_cm3.h"
-12
View File
@@ -22,17 +22,6 @@
volatile uint8_t buzzerCount ;
#if defined(REVA)
void buzzerOn()
{
PIOA->PIO_SODR = 0x00010000L ; // Set bit A16 ON
}
void buzzerOff()
{
PIOA->PIO_CODR = 0x00010000L ; // Set bit A16 ON
}
#else
void buzzerOn()
{
PIOA->PIO_SODR = 0x02000000L ; // Set bit A25 ON
@@ -42,7 +31,6 @@ void buzzerOff()
{
PIOA->PIO_CODR = 0x02000000L ; // Set bit A25 ON
}
#endif
void buzzerSound(uint8_t duration)
{
-25
View File
@@ -38,20 +38,6 @@ uint32_t readKeys()
x = lcdLock ? lcdInputs : PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
x = ~x;
#if defined(REVA)
if (x & KEYS_GPIO_PIN_RIGHT)
result |= 0x02 << KEY_RIGHT;
if (x & KEYS_GPIO_PIN_LEFT)
result |= 0x02 << KEY_LEFT;
if (x & KEYS_GPIO_PIN_UP)
result |= 0x02 << KEY_UP;
if (x & KEYS_GPIO_PIN_DOWN)
result |= 0x02 << KEY_DOWN;
if (~KEYS_GPIO_REG_EXIT & KEYS_GPIO_PIN_EXIT)
result |= 0x02 << KEY_EXIT;
if (~KEYS_GPIO_REG_MENU & KEYS_GPIO_PIN_MENU)
result |= 0x02 << KEY_MENU;
#else
if (x & KEYS_GPIO_PIN_RIGHT)
result |= 0x02 << KEY_RIGHT;
if (x & KEYS_GPIO_PIN_UP)
@@ -64,7 +50,6 @@ uint32_t readKeys()
result |= 0x02 << KEY_EXIT;
if (~KEYS_GPIO_REG_MENU & KEYS_GPIO_PIN_MENU)
result |= 0x02 << KEY_MENU;
#endif
// TRACE("readKeys(): %x => %x", x, result);
@@ -141,13 +126,8 @@ uint32_t switchState(uint8_t index)
uint32_t xxx = 0;
switch (index) {
#if defined(REVA)
case SW_ELE:
xxx = a & 0x00000100; // ELE_DR PA8
#else
case SW_ELE:
xxx = c & 0x80000000; // ELE_DR PC31
#endif
break;
case SW_AIL:
@@ -176,13 +156,8 @@ uint32_t switchState(uint8_t index)
xxx = c & 0x00010000; // SW_GEAR PC16
break;
#if defined(REVA)
case SW_THR:
xxx = a & 0x10000000; // SW_TCUT PA28
#else
case SW_THR:
xxx = c & 0x00100000; // SW_TCUT PC20
#endif
break;
case SW_TRN:
+7 -90
View File
@@ -36,60 +36,25 @@
// LCD_D7 PC1
#define LCD_DATA 0x000000FFL
#if !defined(REVA)
#define LCD_A0 0x00000080L
#else
#define LCD_A0 0x00008000L
#endif
#define LCD_RnW 0x00002000L
#define LCD_E 0x00001000L
#define LCD_CS1 0x04000000L
#define LCD_RES 0x08000000L
// Lookup table for prototype board
#if defined(REVA)
const uint8_t Lcd_lookup[] =
{
0x00,0x01,0x80,0x81,0x40,0x41,0xC0,0xC1,0x20,0x21,0xA0,0xA1,0x60,0x61,0xE0,0xE1,
0x10,0x11,0x90,0x91,0x50,0x51,0xD0,0xD1,0x30,0x31,0xB0,0xB1,0x70,0x71,0xF0,0xF1,
0x08,0x09,0x88,0x89,0x48,0x49,0xC8,0xC9,0x28,0x29,0xA8,0xA9,0x68,0x69,0xE8,0xE9,
0x18,0x19,0x98,0x99,0x58,0x59,0xD8,0xD9,0x38,0x39,0xB8,0xB9,0x78,0x79,0xF8,0xF9,
0x04,0x05,0x84,0x85,0x44,0x45,0xC4,0xC5,0x24,0x25,0xA4,0xA5,0x64,0x65,0xE4,0xE5,
0x14,0x15,0x94,0x95,0x54,0x55,0xD4,0xD5,0x34,0x35,0xB4,0xB5,0x74,0x75,0xF4,0xF5,
0x0C,0x0D,0x8C,0x8D,0x4C,0x4D,0xCC,0xCD,0x2C,0x2D,0xAC,0xAD,0x6C,0x6D,0xEC,0xED,
0x1C,0x1D,0x9C,0x9D,0x5C,0x5D,0xDC,0xDD,0x3C,0x3D,0xBC,0xBD,0x7C,0x7D,0xFC,0xFD,
0x02,0x03,0x82,0x83,0x42,0x43,0xC2,0xC3,0x22,0x23,0xA2,0xA3,0x62,0x63,0xE2,0xE3,
0x12,0x13,0x92,0x93,0x52,0x53,0xD2,0xD3,0x32,0x33,0xB2,0xB3,0x72,0x73,0xF2,0xF3,
0x0A,0x0B,0x8A,0x8B,0x4A,0x4B,0xCA,0xCB,0x2A,0x2B,0xAA,0xAB,0x6A,0x6B,0xEA,0xEB,
0x1A,0x1B,0x9A,0x9B,0x5A,0x5B,0xDA,0xDB,0x3A,0x3B,0xBA,0xBB,0x7A,0x7B,0xFA,0xFB,
0x06,0x07,0x86,0x87,0x46,0x47,0xC6,0xC7,0x26,0x27,0xA6,0xA7,0x66,0x67,0xE6,0xE7,
0x16,0x17,0x96,0x97,0x56,0x57,0xD6,0xD7,0x36,0x37,0xB6,0xB7,0x76,0x77,0xF6,0xF7,
0x0E,0x0F,0x8E,0x8F,0x4E,0x4F,0xCE,0xCF,0x2E,0x2F,0xAE,0xAF,0x6E,0x6F,0xEE,0xEF,
0x1E,0x1F,0x9E,0x9F,0x5E,0x5F,0xDE,0xDF,0x3E,0x3F,0xBE,0xBF,0x7E,0x7F,0xFE,0xFF
};
#endif
void lcdSendCtl(uint8_t val)
{
Pio *pioptr;
#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;
#if !defined(REVX)
#if !defined(REVX)
pioptr->PIO_CODR = LCD_CS1; // Select LCD
#endif
PIOA->PIO_CODR = LCD_A0;
#if !defined(REVX)
pioptr->PIO_CODR = LCD_RnW; // Write
#endif
pioptr->PIO_ODSR = val;
#endif
PIOA->PIO_CODR = LCD_A0;
#if !defined(REVX)
pioptr->PIO_CODR = LCD_RnW; // Write
#endif
pioptr->PIO_ODSR = val;
pioptr->PIO_SODR = LCD_E; // Start E pulse
// Need a delay here (250nS)
@@ -99,11 +64,7 @@ void lcdSendCtl(uint8_t val)
// Wait
}
pioptr->PIO_CODR = LCD_E; // End E pulse
#if defined(REVA)
pioptr->PIO_SODR = LCD_A0; // Data
#else
PIOA->PIO_SODR = LCD_A0; // Data
#endif
#if !defined(REVX)
pioptr->PIO_SODR = LCD_CS1; // Deselect LCD
@@ -120,14 +81,6 @@ void lcdInit()
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
lcdLock = 1;
#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;
#if defined(REVX)
@@ -141,7 +94,6 @@ void lcdInit()
pioptr->PIO_SODR = LCD_RES;
pioptr->PIO_OER = PIO_PC27 | PIO_PC26 | PIO_PC13 | PIO_PC12 | 0xFF; // Set bits 27,26,13,12,7-0 output
pioptr->PIO_OWER = 0x000000FFL; // Allow write to ls 8 bits in ODSR
#endif
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
pioptr->PIO_CODR = LCD_RES; // Reset LCD
@@ -176,15 +128,9 @@ void lcdInit()
lcdSendCtl(0xAF); // DON = 1: display ON
#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
lcdLock = 0;
}
@@ -207,15 +153,10 @@ void lcdSetRefVolt(uint8_t val)
}
lcdSendCtl(val);
#if defined(REVA)
pioptr->PIO_ODR = 0x000000FEL; // Set bits 2, 3, 4, 5 input
pioptr->PIO_PUER = 0x000000FEL; // Set bits 2, 3, 4, 5 with pullups
#else
pioptr->PIO_ODR = 0x000000FEL; // Set bits 1, 3, 4, 5 input
pioptr->PIO_PUER = 0x000000FEL; // Set bits 1, 3, 4, 5 with pullups
#endif
pioptr->PIO_ODSR = 0; // Drive D0 low
lcdLock = 0;
}
@@ -227,29 +168,19 @@ void lcdRefresh()
uint32_t x;
uint32_t z;
uint32_t ebit;
#if defined(REVA)
uint8_t *lookup;
lookup = (uint8_t *) Lcd_lookup;
#endif
ebit = LCD_E;
#if !defined(REVA)
pioptr = PIOA;
pioptr->PIO_PER = 0x00000080; // Enable bit 7 (LCD-A0)
pioptr->PIO_OER = 0x00000080;// Set bit 7 output
#endif
// read the inputs, and lock the LCD lines
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
lcdLock = 1;
pioptr = PIOC;
#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);
lcdSendCtl(0x10); //column addr 0
@@ -263,21 +194,13 @@ void lcdRefresh()
pioptr->PIO_CODR = LCD_RnW; // Write
#endif
#if defined(REVA)
x = lookup[*p];
#else
x = *p;
#endif
for (z = 0; z < LCD_W; z += 1) {
pioptr->PIO_ODSR = x;
pioptr->PIO_SODR = ebit; // Start E pulse
// Need a delay here (250nS)
p += 1;
#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)
// {
@@ -291,14 +214,8 @@ void lcdRefresh()
}
pioptr->PIO_ODSR = 0xFF; // Drive lines high
#if defined(REVA)
pioptr->PIO_PUER = 0x000000FEL; // Set bits 2, 3, 4, 5 with pullups
pioptr->PIO_ODR = 0x000000FEL; // Set bits 2, 3, 4, 5 input
#else
pioptr->PIO_PUER = 0x000000FEL; // Set bits 1, 3, 4, 5 with pullups
pioptr->PIO_ODR = 0x000000FEL; // Set bits 1, 3, 4, 5 input
#endif
pioptr->PIO_ODSR = 0xFE; // Drive D0 low
lcdLock = 0;
}
@@ -91,7 +91,6 @@ void disable_main_ppm()
void init_second_ppm(uint32_t period)
{
#if !defined(REVA)
// PWM1 for PPM2
Pwm * pwmptr = PWM;
configure_pins(PIO_PC15, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP);
@@ -107,16 +106,13 @@ void init_second_ppm(uint32_t period)
pwmptr->PWM_IER1 = PWM_IER1_CHID1;
setExtraModulePolarity();
#endif
}
void disable_second_ppm()
{
#if !defined(REVA)
Pio * pioptr = PIOC;
pioptr->PIO_PER = PIO_PC15; // Assign C17 to PIO
PWM->PWM_IDR1 = PWM_IDR1_CHID1;
#endif
}
void init_no_pulses(uint32_t port)
@@ -349,7 +345,6 @@ extern "C" void PWM_IRQHandler(void)
}
}
#if !defined(REVA)
if (reason & PWM_ISR1_CHID1) {
// TODO EXTRA_MODULE will be broken
/*pwmptr->PWM_CH_NUM[1].PWM_CPDRUPD = *modulePulsesData[EXTRA_MODULE].ppm.ptr++;
@@ -358,6 +353,5 @@ extern "C" void PWM_IRQHandler(void)
setExtraModulePolarity();
}*/
}
#endif
}
#endif
+1 -5
View File
@@ -22,7 +22,7 @@
uint32_t pwrPressed()
{
#if defined(SIMU) || defined(REVA)
#if defined(SIMU)
return true;
#else
return PIOC->PIO_PDSR & PIO_PC17;
@@ -32,16 +32,12 @@ uint32_t pwrPressed()
// turn off soft power
void pwrOff()
{
#if !defined(REVA)
configure_pins(PIO_PA8, PIN_ENABLE | PIN_OUTPUT | PIN_LOW | PIN_PORTA | PIN_NO_PULLUP);
#endif
}
#if !defined(REVA)
void pwrInit()
{
// 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
+19 -10
View File
@@ -77,17 +77,13 @@ SECTIONS
KEEP(*(.bootloader)) /* Bootloader code */
. = ALIGN(32768); /* Align the start of the exidx part */
. = 0x8000; /* Set the start of the main program */
_stext = .; /* Provide the name for the start of this section */
KEEP(*(.vectors))
*(.text)
*(.text.*)
. = ALIGN(4); /* Align the start of the exidx part */
*(.ARM.exidx)
*(.ARM.exidx.*)
. = ALIGN(4); /* Align the start of the rodata part */
*(.rodata)
@@ -100,14 +96,25 @@ SECTIONS
} > FLASH = 0
_etext = .; /* Provide the name for the end of this section */
.ARM.extab : {
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} > FLASH
_sidata = .;
/*
* The ".data" section is used for initialized data
* and for functions (.fastrun) which should be copied
* from flash to ram. This functions will later be
* executed from ram instead of flash.
*/
.data : AT (_etext)
.data : AT (_sidata)
{
. = ALIGN(4); /* Align the start of the section */
_sdata = .; /* Provide the name for the start of this section */
@@ -122,7 +129,6 @@ SECTIONS
. = ALIGN(4); /* Align the end of the section */
} > RAM
_edata = .; /* Provide the name for the end of this section */
/*
* The ".bss" section is used for uninitialized data.
@@ -140,8 +146,11 @@ SECTIONS
} > RAM
_ebss = .; /* Provide the name for the end of this section */
/*
. = ALIGN(4); /* Align the end of the section */
__end = .;
_end = .;
/*
* The ".stack" section is our stack.
* Here this section starts at the end of the ram segment.
*/
+18 -11
View File
@@ -72,21 +72,18 @@ SECTIONS
.text :
{
FILL(0xFFFF)
CREATE_OBJECT_SYMBOLS
KEEP(*(.bootloader))
KEEP(*(.bootloader)) /* Bootloader code */
. = ALIGN(32768); /* Align the start of the exidx part */
. = 0x8000; /* Set the start of the main program */
_stext = .; /* Provide the name for the start of this section */
KEEP(*(.vectors))
*(.text)
*(.text.*)
. = ALIGN(4); /* Align the start of the exidx part */
*(.ARM.exidx)
*(.ARM.exidx.*)
. = ALIGN(4); /* Align the start of the rodata part */
*(.rodata)
@@ -99,14 +96,25 @@ SECTIONS
} > FLASH = 0
_etext = .; /* Provide the name for the end of this section */
.ARM.extab : {
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} > FLASH
_sidata = .;
/*
* The ".data" section is used for initialized data
* and for functions (.fastrun) which should be copied
* from flash to ram. This functions will later be
* executed from ram instead of flash.
*/
.data : AT (_etext)
.data : AT (_sidata)
{
. = ALIGN(4); /* Align the start of the section */
_sdata = .; /* Provide the name for the start of this section */
@@ -121,7 +129,6 @@ SECTIONS
. = ALIGN(4); /* Align the end of the section */
} > RAM
_edata = .; /* Provide the name for the end of this section */
/*
* The ".bss" section is used for uninitialized data.
@@ -137,7 +144,7 @@ SECTIONS
. = ALIGN(4); /* Align the end of the section */
} > RAM
_ebss = .; /* Provide the name for the end of this section */
_ebss = .; /* Provide the name for the end of this section */
. = ALIGN(4); /* Align the end of the section */
__end = .;
+2 -10
View File
@@ -355,19 +355,11 @@ void TelemetryItem::eval(const TelemetrySensor & sensor)
}
}
uint32_t angle = abs(gpsItem.gps.latitude - gpsItem.pilotLatitude);
#if defined(PCBSKY9X) //TODO remove when sky9x issue is understood
uint32_t dist = (PRECALCULATED_EARTH_RADIUS_CONSTANT * angle) / 1000000;
#else
uint32_t dist = ((uint64_t)PRECALCULATED_EARTH_RADIUS_CONSTANT * angle) / 1000000;
#endif
uint32_t dist = uint64_t(EARTH_RADIUS * M_PI / 180) * angle / 1000000;
uint32_t result = dist * dist;
angle = abs(gpsItem.gps.longitude - gpsItem.pilotLongitude);
#if defined(PCBSKY9X)
dist = (gpsItem.distFromEarthAxis * angle) / 1000000;
#else
dist = ((uint64_t)gpsItem.distFromEarthAxis * angle) / 1000000;
#endif
dist = uint64_t(gpsItem.distFromEarthAxis) * angle / 1000000;
result += dist * dist;
// Length on ground (ignoring curvature of the earth)