diff --git a/src/Makefile b/src/Makefile index 3a5db774b..732b83c77 100644 --- a/src/Makefile +++ b/src/Makefile @@ -471,13 +471,13 @@ RUN_FROM_FLASH = 1 ifeq ($(PCB), ACT) # ACT radio OPT = 2 - CPPDEFS += -DPCBACT -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 -DLCD260 -DSTM32F10X_HD + CPPDEFS += -DPCBACT -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 -DLCD=260 -DSTM32F10X_HD EXTRAINCDIRS += sky9x CoOS/kernel CoOS/portable EXTRAINCDIRS += act/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc act/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x - BOARDSRC = x9d/board_x9d.cpp + BOARDSRC = act/board_act.cpp EXTRABOARDSRC += x9d/lcd_driver.cpp SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c - EEPROMSRC = eeprom_arm.cpp eeprom_conversions.cpp + EEPROMSRC = eeprom_avr.cpp # TODO later eeprom_conversions.cpp CPPSRC += x9d/eeprom_driver.cpp x9d/pulses_driver.cpp act/keys_driver.cpp x9d/audio_driver.cpp CPPSRC += sky9x/audio.cpp PULSESSRC = pulses_arm.cpp @@ -487,7 +487,7 @@ endif ifeq ($(PCB), X9D) # X9D radio OPT = 2 - CPPDEFS += -DPCBX9D -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 -DLCD212 + CPPDEFS += -DPCBX9D -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 -DLCD=212 EXTRAINCDIRS += sky9x CoOS/kernel CoOS/portable EXTRAINCDIRS += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include BOARDSRC = x9d/board_x9d.cpp diff --git a/src/act/board_act.cpp b/src/act/board_act.cpp new file mode 100644 index 000000000..bd1b39417 --- /dev/null +++ b/src/act/board_act.cpp @@ -0,0 +1,124 @@ +/* + * Authors (alphabetical order) + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * open9x is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../open9x.h" + +// TODO needed? +uint8_t temperature = 0; // Raw temp reading +uint8_t maxTemperature = 0 ; // Raw temp reading +volatile uint32_t Tenms ; // TODO to remove everywhere / use a #define + +uint8_t getTemperature() +{ + return temperature + g_eeGeneral.temperatureCalib; +} + +void start_ppm_capture() +{ +} + +void usbBootloader() +{ +} + +void usbMassStorage() +{ +} + +// Starts TIMER at 200Hz, 5mS period +void init5msTimer() +{ +/* + // Timer14 + RCC->APB1ENR |= RCC_APB1ENR_TIM14EN ; // Enable clock + TIM14->ARR = 4999 ; // 5mS + TIM14->PSC = (PERI1_FREQUENCY * TIMER_MULT) / 1000000 - 1 ; // 1uS from 30MHz + TIM14->CCER = 0 ; + TIM14->CCMR1 = 0 ; + TIM14->EGR = 0 ; + TIM14->CR1 = 5 ; + TIM14->DIER |= 1 ; + NVIC_EnableIRQ(TIM8_TRG_COM_TIM14_IRQn) ; + */ +} + +void stop5msTimer( void ) +{ +/* + TIM14->CR1 = 0 ; // stop timer + NVIC_DisableIRQ(TIM8_TRG_COM_TIM14_IRQn) ; + RCC->APB1ENR &= ~RCC_APB1ENR_TIM14EN ; // Disable clock + */ +} + +// TODO use the same than board_sky9x.cpp +void interrupt5ms() +{ + static uint32_t pre_scale ; // Used to get 10 Hz counter + + // HAPTIC_HEARTBEAT(); + // AUDIO_HEARTBEAT(); + + if ( ++pre_scale >= 2 ) { + /* if ( Buzzer_count ) { + if ( --Buzzer_count == 0 ) + buzzer_off() ; + } */ + pre_scale = 0 ; + per10ms(); + } +} + +extern "C" void TIM8_TRG_COM_TIM14_IRQHandler() +{ + TIM14->SR &= ~TIM_SR_UIF ; + interrupt5ms() ; +} + +#if !defined(SIMU) +void boardInit() +{ + pwrInit(); + keysInit(); + adcInit(); + delaysInit(); + + init5msTimer(); + + __enable_irq() ; + + eepromInit(); +} +#endif + + diff --git a/src/act/board_act.h b/src/act/board_act.h index 8328976f2..b16d4e85c 100644 --- a/src/act/board_act.h +++ b/src/act/board_act.h @@ -108,11 +108,18 @@ extern uint16_t sessionTimer; #define wdt_reset() #endif -uint32_t check_soft_power(); +#define check_soft_power() e_power_on #define setBacklight(xx) #define __BACKLIGHT_ON #define __BACKLIGHT_OFF #define IS_BACKLIGHT_ON() (1) +#if !defined(SIMU) +#define eeprom_read_block(...) +#define eeWriteBlockCmp(...) +#else +void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size); +#endif + #endif diff --git a/src/act/keys_driver.cpp b/src/act/keys_driver.cpp index 630d3f107..5d3070ba4 100644 --- a/src/act/keys_driver.cpp +++ b/src/act/keys_driver.cpp @@ -78,12 +78,17 @@ void readKeysAndTrims() ++enuk; } - in = readTrims(); + /* in = readTrims(); for (i = 1; i < 256; i <<= 1) { keys[enuk].input(in & i, (EnumKeys) enuk); ++enuk; - } + } */ +} + +uint32_t keyState(EnumKeys enuk) +{ + return 0; } #if !defined(SIMU) diff --git a/src/eeprom_avr.cpp b/src/eeprom_avr.cpp index 8af203c37..00a3bb475 100644 --- a/src/eeprom_avr.cpp +++ b/src/eeprom_avr.cpp @@ -112,7 +112,7 @@ void eeWriteBlockCmp(const void *i_pointer_ram, uint16_t i_pointer_eeprom, size_ static uint8_t EeFsRead(blkid_t blk, uint8_t ofs) { uint8_t ret; -#if defined(PCBX9D) +#if defined(CPUARM) eeprom_read_block(&ret, (uint16_t)(blk*BS+ofs+BLOCKS_OFFSET), 1); #elif defined(SIMU) eeprom_read_block(&ret, (const void*)(uint64_t)(blk*BS+ofs+BLOCKS_OFFSET), 1); @@ -915,7 +915,7 @@ void eeLoadModel(uint8_t id) FRSKY_setModelAlarms(); #endif -#if defined(PCBX9D) && defined(SDCARD) +#if defined(CPUARM) && defined(SDCARD) refreshModelAudioFiles(); #endif diff --git a/src/lcd.h b/src/lcd.h index 42c5dd952..640608a3d 100644 --- a/src/lcd.h +++ b/src/lcd.h @@ -40,7 +40,7 @@ #define xcoord_t uint16_t #define CENTER "\015" #define CENTER_OFS (7*FW-FW/2) -#elif defined(LCD212) +#elif LCD >= 212 #define DISPLAY_W 212 #define DISPLAY_H 64 #define xcoord_t uint16_t diff --git a/src/main_views.cpp b/src/main_views.cpp index ce43ca6ee..8d6fc95dc 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -33,7 +33,7 @@ #include "open9x.h" -#if defined(LCD212) || defined(LCD260) +#if LCD >= 212 #define BOX_WIDTH 31 #define LBOX_CENTERX (BOX_WIDTH/2 + 17) #define LBOX_CENTERY (DISPLAY_H-BOX_WIDTH/2-10) @@ -174,7 +174,7 @@ void displaySliders() } #endif -#if defined(LCD212) +#if LCD >= 212 void displayTimers() { // Main timer @@ -392,7 +392,7 @@ void menuMainView(uint8_t event) s_gvar_timer = 0; } #endif -#if !defined(LCD212) && !defined(LCD260) +#if LCD < 212 else if (view == VIEW_TIMER2) { resetTimer(1); } diff --git a/src/menus.cpp b/src/menus.cpp index ae4e22d75..fbc4996c7 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -63,7 +63,7 @@ void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr) } #if !defined(PCBSTD) -void displayScrollbar(uint8_t x, uint8_t y, uint8_t h, uint16_t offset, uint16_t count, uint8_t visible) +void displayScrollbar(xcoord_t x, uint8_t y, uint8_t h, uint16_t offset, uint16_t count, uint8_t visible) { lcd_vlineStip(x, y, h, SOLID, ERASE); lcd_vlineStip(x, y, h, DOTTED); @@ -389,7 +389,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t s_noScroll = 0; displayScreenIndex(curr, menuTabSize, attr); -#if defined(LCD212) +#if LCD >= 212 if (maxrow > 7) displayScrollbar(DISPLAY_W-1, FH, DISPLAY_H-FH, s_pgOfs, maxrow, 7); #endif @@ -726,7 +726,7 @@ int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int8_t min, int8_t max, } #endif -#if defined(LCD212) +#if LCD >= 212 #define MENU_X 30 #define MENU_W DISPLAY_W-60 #else diff --git a/src/menus.h b/src/menus.h index f87211135..9900b4591 100644 --- a/src/menus.h +++ b/src/menus.h @@ -47,7 +47,7 @@ typedef void (*MenuFuncP)(uint8_t event); void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr); -#if defined(LCD212) +#if LCD >= 212 #define MENUS_SCROLLBAR_WIDTH 2 #else #define MENUS_SCROLLBAR_WIDTH 0 diff --git a/src/model_menus.cpp b/src/model_menus.cpp index c10bf9451..b43fb7f58 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -646,7 +646,7 @@ enum menuModelSetupItems { #define FIELD_TIMER_MAX 2 #endif -#if defined(LCD212) +#if LCD >= 212 #define MODEL_SETUP_2ND_COLUMN (DISPLAY_W-17*FW-MENUS_SCROLLBAR_WIDTH) #else #define MODEL_SETUP_2ND_COLUMN (DISPLAY_W-11*FW-MENUS_SCROLLBAR_WIDTH) @@ -961,7 +961,7 @@ static uint8_t s_currIdx; #define MIXES_2ND_COLUMN (11*FW) #endif -#if defined(LCD212) +#if LCD >= 212 #define EXPO_ONE_2ND_COLUMN (DISPLAY_W - 88) #define EXPO_ONE_FP_WIDTH (9*FW) #else @@ -991,12 +991,12 @@ PhasesType editPhases(uint8_t x, uint8_t y, uint8_t event, PhasesType value, uin uint8_t posHorz = m_posHorz; -#if defined(CPUARM) && !defined(LCD212) +#if defined(CPUARM) && LCD < 212 bool expoMenu = (x==EXPO_ONE_2ND_COLUMN-2*FW); #endif for (uint8_t p=0; p EXPO_ONE_2ND_COLUMN+2*FW))) continue; #endif @@ -1260,7 +1260,7 @@ void menuModelPhasesAll(uint8_t event) } #endif } -#if defined(LCD212) +#if LCD >= 212 if (p->fadeIn || p->fadeOut) { lcd_outdezAtt(24*FW, y, 5*p->fadeIn, PREC1|LEFT); lcd_putc(lcdLastPos, y, '/'); @@ -2173,7 +2173,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) putsSwitches(11*FW, y, ed->swtch, 0); lcd_putsnAtt(DISPLAY_W-sizeof(ed->name)*FW-MENUS_SCROLLBAR_WIDTH, y, ed->name, sizeof(ed->name), ZCHAR | (isExpoActive(i) ? BOLD : 0)); } -#if !defined(LCD212) +#if LCD < 212 else #endif #endif @@ -2194,7 +2194,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) if (md->name[0]) { lcd_putsnAtt(DISPLAY_W-sizeof(md->name)*FW-MENUS_SCROLLBAR_WIDTH, y, md->name, sizeof(md->name), ZCHAR | (isMixActive(i) ? BOLD : 0)); } -#if !defined(LCD212) +#if LCD < 212 else #endif #endif @@ -2377,7 +2377,7 @@ void menuModelLimits(uint8_t event) LimitData *ld = limitaddress(k) ; -#if defined(LCD212) || !defined(PPM_CENTER_ADJUSTABLE) +#if LCD >= 212 || !defined(PPM_CENTER_ADJUSTABLE) int16_t v = (ld->revert) ? -ld->offset : ld->offset; char swVal = '-'; // '-', '<', '>' if((g_chans512[k] - v) > 50) swVal = (ld->revert ? 127 : 126); // Switch to raw inputs? - remove trim! @@ -2442,7 +2442,7 @@ void menuModelLimits(uint8_t event) if (active) ld->max = -100 + checkIncDecModel(event, ld->max+100, -25, limit); break; case ITEM_LIMITS_DIRECTION: -#if defined(PPM_CENTER_ADJUSTABLE) && !defined(LCD212) +#if defined(PPM_CENTER_ADJUSTABLE) && LCD < 212 lcd_putcAtt(LIMITS_REVERT_POS, y, ld->revert ? 127 : 126, attr); #else lcd_putsiAtt(LIMITS_REVERT_POS, y, STR_MMMINV, ld->revert, attr); diff --git a/src/myeeprom.h b/src/myeeprom.h index f588eb33e..80f54c92d 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -80,7 +80,7 @@ PACK(typedef struct t_FrSkyRSSIAlarm { int8_t value:6; }) FrSkyRSSIAlarm; -#if defined(LCD212) || defined(LCD260) +#if LCD >= 212 || defined(LCD260) enum MainViews { VIEW_INPUTS, VIEW_SWITCHES, diff --git a/src/open9x.cpp b/src/open9x.cpp index 4a15c024e..4d5ccbf1d 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -1393,7 +1393,7 @@ void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SO { lcd_clear(); -#if defined(LCD212) +#if LCD >= 212 lcd_img(DISPLAY_W-29, 0, asterisk_lbm, 0, 0); #endif #if !defined(CPUM64) || defined(EXTSTD) diff --git a/src/simpgmspace.cpp b/src/simpgmspace.cpp index 7d1e2033c..4ce15d34c 100644 --- a/src/simpgmspace.cpp +++ b/src/simpgmspace.cpp @@ -97,7 +97,8 @@ sem_t *eeprom_write_sem; void setSwitch(int8_t swtch) { switch (swtch) { -#if defined(PCBX9D) || defined(PCBACT) +#if defined(PCBACT) +#elif defined(PCBX9D) case DSW(SW_SA0): GPIOE->IDR |= PIN_SW_A_L; GPIOB->IDR &= ~PIN_SW_A_H; @@ -259,7 +260,7 @@ uint16_t getTmr16KHz() return get_tmr10ms() * 160; } -#if !defined(PCBX9D) +#if !defined(PCBX9D) && !defined(PCBACT) bool eeprom_thread_running = true; void *eeprom_write_function(void *) { @@ -390,7 +391,7 @@ void StartEepromThread(const char *filename) sem_init(eeprom_write_sem, 0, 0); #endif -#if !defined(PCBX9D) +#if !defined(PCBX9D) && !defined(PCBACT) eeprom_thread_running = true; assert(!pthread_create(&eeprom_thread_pid, NULL, &eeprom_write_function, NULL)); #endif @@ -398,14 +399,14 @@ void StartEepromThread(const char *filename) void StopEepromThread() { -#if !defined(PCBX9D) +#if !defined(PCBX9D) && !defined(PCBACT) eeprom_thread_running = false; sem_post(eeprom_write_sem); pthread_join(eeprom_thread_pid, NULL); #endif } -#if defined(PCBX9D) +#if defined(PCBX9D) || defined(PCBACT) void eeprom_read_block (void *pointer_ram, uint16_t pointer_eeprom, size_t size) #else void eeprom_read_block (void *pointer_ram, const void *pointer_eeprom, size_t size) @@ -423,7 +424,7 @@ void eeprom_read_block (void *pointer_ram, const void *pointer_eeprom, size_t si } } -#if defined(PCBX9D) +#if defined(PCBX9D) || defined(PCBACT) void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size) { assert(size); diff --git a/src/simpgmspace.h b/src/simpgmspace.h index 05d9f2d61..436492874 100644 --- a/src/simpgmspace.h +++ b/src/simpgmspace.h @@ -317,7 +317,7 @@ void StartMainThread(bool tests=true); void StartEepromThread(const char *filename="eeprom.bin"); extern const char *eepromFile; -#if defined(PCBX9D) +#if defined(PCBX9D) || defined(PCBACT) void eeprom_read_block (void *pointer_ram, uint16_t pointer_eeprom, size_t size); #else void eeprom_read_block (void *pointer_ram, const void *pointer_eeprom, size_t size); diff --git a/src/simu.cpp b/src/simu.cpp index 0dcb19180..77c725b1f 100644 --- a/src/simu.cpp +++ b/src/simu.cpp @@ -49,7 +49,24 @@ int g_snapshot_idx = 0; uint64_t toto = 0; -#if defined(PCBX9D) || defined(PCBACT) +#if defined(PCBACT) +#define ERSKY9X_RETURN_PIO GPIOC->IDR +#define ERSKY9X_RETURN_MASK 0x00000020 +#define ERSKY9X_EXIT_PIO GPIOC->IDR +#define ERSKY9X_EXIT_MASK 0x01000000 +#define ERSKY9X_UP_PIO GPIOC->IDR +#define ERSKY9X_UP_MASK 0x00 +#define ERSKY9X_DOWN_PIO GPIOC->IDR +#define ERSKY9X_DOWN_MASK 0x00 +#define ERSKY9X_RIGHT_PIO GPIOC->IDR +#define ERSKY9X_RIGHT_MASK 0x00000010 +#define ERSKY9X_LEFT_PIO GPIOC->IDR +#define ERSKY9X_LEFT_MASK 0x00000008 +#define KEY_MENU_PIO GPIOC->IDR +#define KEY_MENU_MASK 0x00000002 +#define KEY_PAGE_PIO GPIOC->IDR +#define KEY_PAGE_MASK 0x00000040 +#elif defined(PCBX9D) #define ERSKY9X_RETURN_PIO GPIOE->IDR #define ERSKY9X_RETURN_MASK PIN_BUTTON_ENTER #define ERSKY9X_EXIT_PIO GPIOD->IDR