mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +03:00
2 more files removed
This commit is contained in:
parent
3b1ac9f5d8
commit
7f6a137ce8
16 changed files with 432 additions and 768 deletions
|
@ -137,17 +137,20 @@ SRC = system_stm32f2xx.c \
|
|||
../src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c \
|
||||
../src/targets/taranis/usbd_desc.c \
|
||||
../src/targets/taranis/aspi.c \
|
||||
../src/targets/taranis/usb_bsp.c
|
||||
../src/targets/taranis/usb_bsp.c \
|
||||
../src/targets/taranis/usb_driver.c \
|
||||
../src/targets/taranis/pwr_driver.c
|
||||
|
||||
CPPSRC = ../src/targets/taranis/lcd_driver.cpp \
|
||||
../src/targets/taranis/keys_driver.cpp \
|
||||
driversboot.cpp \
|
||||
logicioboot.cpp \
|
||||
../src/targets/taranis/diskio.cpp \
|
||||
../src/targets/taranis/usbd_usr.cpp \
|
||||
usbd_storage_msd.cpp \
|
||||
../src/lcd.cpp \
|
||||
../src/keys.cpp \
|
||||
../src/fonts.cpp \
|
||||
power.cpp \
|
||||
boot.cpp
|
||||
|
||||
# List ASM source files here
|
||||
|
|
|
@ -53,17 +53,12 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef PCBSKY
|
||||
#include "AT91SAM3S4.h"
|
||||
#include "core_cm3.h"
|
||||
#endif
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
#include "stm32f2xx.h"
|
||||
#include "stm32f2xx_flash.h"
|
||||
#include "../src/targets/taranis/i2c.h"
|
||||
#include "hal.h"
|
||||
// #include "timers.h"
|
||||
|
||||
extern "C" {
|
||||
#include "usb_dcd_int.h"
|
||||
|
@ -76,13 +71,15 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "board_taranis.h"
|
||||
#include "../src/pwr.h"
|
||||
#include "../src/lcd.h"
|
||||
#include "../src/keys.h"
|
||||
|
||||
#include "radio.h"
|
||||
// #include "radio.h"
|
||||
#include "../src/FatFs/ff.h"
|
||||
#include "../src/FatFs/diskio.h"
|
||||
#include "drivers.h"
|
||||
#include "logicio.h"
|
||||
//#include "drivers.h"
|
||||
// #include "logicio.h"
|
||||
|
||||
#ifdef PCBSKY
|
||||
extern void usbMassStorage( void ) ;
|
||||
|
@ -204,37 +201,7 @@ void delay2ms()
|
|||
}
|
||||
#endif
|
||||
|
||||
static bool usbPlugged(void)
|
||||
{
|
||||
#ifdef PCBSKY
|
||||
return PIOC->PIO_PDSR & 0x02000000 ;
|
||||
#endif
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
return GPIOA->IDR & 0x0200 ;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
|
||||
extern "C" {
|
||||
USB_OTG_CORE_HANDLE USB_OTG_dev;
|
||||
|
||||
void OTG_FS_IRQHandler(void)
|
||||
{
|
||||
USBD_OTG_ISR_Handler (&USB_OTG_dev);
|
||||
}
|
||||
}
|
||||
|
||||
static void usbInit()
|
||||
{
|
||||
USB_OTG_BSP_Init(&USB_OTG_dev);
|
||||
}
|
||||
|
||||
static void usbStart()
|
||||
{
|
||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
|
||||
}
|
||||
|
||||
uint32_t isFirmwareStart( uint32_t *block )
|
||||
{
|
||||
|
@ -358,7 +325,8 @@ void clearLockBits()
|
|||
}
|
||||
#endif
|
||||
|
||||
void interrupt10ms()
|
||||
void per10ms(void);
|
||||
void interrupt10ms(void)
|
||||
{
|
||||
Tenms |= 1 ; // 10 mS has passed
|
||||
per10ms() ;
|
||||
|
@ -760,7 +728,7 @@ int main()
|
|||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
#endif
|
||||
|
||||
init_soft_power() ;
|
||||
pwrInit() ;
|
||||
|
||||
#ifdef PCBSKY
|
||||
MATRIX->CCFG_SYSIO |= 0x000000F0L ; // Disable syspins, enable B4,5,6,7
|
||||
|
@ -788,7 +756,7 @@ extern uint8_t OptrexDisplay ;
|
|||
#endif
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
init_keys() ;
|
||||
keysInit() ;
|
||||
I2C_EE_Init() ;
|
||||
init_hw_timer() ;
|
||||
#endif
|
||||
|
@ -821,7 +789,7 @@ extern uint8_t OptrexDisplay ;
|
|||
|
||||
#ifdef PCBTARANIS
|
||||
// SD card detect pin
|
||||
configure_pins( SD_PRESENT_GPIO_Pin, PIN_PORTD | PIN_INPUT | PIN_PULLUP ) ;
|
||||
// configure_pins( SD_PRESENT_GPIO_Pin, PIN_PORTD | PIN_INPUT | PIN_PULLUP ) ;
|
||||
disk_initialize( 0 ) ;
|
||||
sdInit() ;
|
||||
unlockFlash() ;
|
||||
|
@ -1134,9 +1102,8 @@ extern uint8_t OptrexDisplay ;
|
|||
}
|
||||
if ((state < ST_FLASH_CHECK) || (state == ST_FLASH_DONE))
|
||||
{
|
||||
if ( check_soft_power() == POWER_OFF )
|
||||
{
|
||||
soft_power_off() ;
|
||||
if (pwrCheck() == e_power_off ) {
|
||||
pwrOff() ;
|
||||
for(;;)
|
||||
{
|
||||
// Wait for power to go off
|
||||
|
@ -1152,7 +1119,7 @@ extern uint8_t OptrexDisplay ;
|
|||
}
|
||||
if ( state == ST_REBOOT )
|
||||
{
|
||||
if ( (~read_keys() & 0x7E) == 0 )
|
||||
if ( (~readKeys() & 0x7E) == 0 )
|
||||
{
|
||||
NVIC_SystemReset() ;
|
||||
}
|
||||
|
|
|
@ -21,137 +21,14 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef PCBSKY
|
||||
#include "radio.h"
|
||||
#include "drivers.h"
|
||||
#endif
|
||||
#include "../src/opentx.h"
|
||||
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
#include "radio.h"
|
||||
#include "hal.h"
|
||||
#include "stm32f2xx.h"
|
||||
#include "stm32f2xx_gpio.h"
|
||||
#include "stm32f2xx_rcc.h"
|
||||
#endif
|
||||
#include "drivers.h"
|
||||
#include "logicio.h"
|
||||
|
||||
#ifdef EVT_KEY_MASK
|
||||
#undef EVT_KEY_MASK
|
||||
#endif
|
||||
|
||||
#define EVT_KEY_MASK 0x0f
|
||||
|
||||
|
||||
void b_putEvent( register uint8_t evt) ;
|
||||
void per10ms( void ) ;
|
||||
uint8_t getEvent( void ) ;
|
||||
void pauseEvents(uint8_t event) ;
|
||||
void killEvents(uint8_t event) ;
|
||||
|
||||
uint8_t s_evt;
|
||||
void b_putEvent( uint8_t evt)
|
||||
{
|
||||
s_evt = evt;
|
||||
}
|
||||
|
||||
|
||||
uint8_t getEvent()
|
||||
{
|
||||
register uint8_t evt = s_evt;
|
||||
s_evt=0;
|
||||
return evt;
|
||||
}
|
||||
|
||||
Key keys[NUM_KEYS] ;
|
||||
|
||||
void Key::input(bool val, EnumKeys enuk)
|
||||
{
|
||||
// uint8_t old=m_vals;
|
||||
m_vals <<= 1; if(val) m_vals |= 1; //portbit einschieben
|
||||
m_cnt++;
|
||||
|
||||
if(m_state && m_vals==0){ //gerade eben sprung auf 0
|
||||
if(m_state!=KSTATE_KILLED) {
|
||||
b_putEvent(EVT_KEY_BREAK(enuk));
|
||||
}
|
||||
m_cnt = 0;
|
||||
m_state = KSTATE_OFF;
|
||||
}
|
||||
switch(m_state){
|
||||
case KSTATE_OFF:
|
||||
if(m_vals==FFVAL){ //gerade eben sprung auf ff
|
||||
m_state = KSTATE_START;
|
||||
m_cnt = 0;
|
||||
}
|
||||
break;
|
||||
//fallthrough
|
||||
case KSTATE_START:
|
||||
b_putEvent(EVT_KEY_FIRST(enuk));
|
||||
#ifdef KSTATE_RPTDELAY
|
||||
m_state = KSTATE_RPTDELAY;
|
||||
#else
|
||||
m_state = 16;
|
||||
#endif
|
||||
m_cnt = 0;
|
||||
break;
|
||||
#ifdef KSTATE_RPTDELAY
|
||||
case KSTATE_RPTDELAY: // gruvin: longer delay before first key repeat
|
||||
if(m_cnt == 32) b_putEvent(EVT_KEY_LONG(enuk)); // need to catch this inside RPTDELAY time
|
||||
if (m_cnt == 40) {
|
||||
m_state = 16;
|
||||
m_cnt = 0;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case 16:
|
||||
#ifndef KSTATE_RPTDELAY
|
||||
if(m_cnt == 32) b_putEvent(EVT_KEY_LONG(enuk));
|
||||
//fallthrough
|
||||
#endif
|
||||
case 8:
|
||||
case 4:
|
||||
case 2:
|
||||
if(m_cnt >= 48) { //3 6 12 24 48 pulses in every 480ms
|
||||
m_state >>= 1;
|
||||
m_cnt = 0;
|
||||
}
|
||||
//fallthrough
|
||||
case 1:
|
||||
if( (m_cnt & (m_state-1)) == 0) b_putEvent(EVT_KEY_REPT(enuk));
|
||||
break;
|
||||
|
||||
case KSTATE_PAUSE: //pause
|
||||
if(m_cnt >= 64) {
|
||||
m_state = 8;
|
||||
m_cnt = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case KSTATE_KILLED: //killed
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void b_pauseEvents(uint8_t event)
|
||||
{
|
||||
event=event & EVT_KEY_MASK;
|
||||
if(event < (int)DIM(keys)) keys[event].pauseEvents();
|
||||
}
|
||||
|
||||
void killEvents(uint8_t event)
|
||||
{
|
||||
event=event & EVT_KEY_MASK;
|
||||
if(event < (int)DIM(keys)) keys[event].killEvents();
|
||||
}
|
||||
|
||||
void per10ms()
|
||||
void per10ms(void)
|
||||
{
|
||||
register uint32_t i ;
|
||||
|
||||
uint8_t enuk = KEY_MENU;
|
||||
uint8_t in = ~read_keys() ;
|
||||
uint8_t in = ~readKeys() ;
|
||||
// Bits 3-6 are down, up, right and left
|
||||
// Try to only allow one at a
|
||||
#ifdef REVX
|
||||
|
|
|
@ -4,12 +4,7 @@
|
|||
|
||||
extern volatile uint32_t Spi_complete ;
|
||||
|
||||
extern void putEvent( register uint8_t evt) ;
|
||||
|
||||
extern void per10ms( void ) ;
|
||||
extern uint8_t getEvent( void ) ;
|
||||
extern void pauseEvents(uint8_t event) ;
|
||||
extern void killEvents(uint8_t event) ;
|
||||
extern void init_spi( void ) ;
|
||||
extern void end_spi( void ) ;
|
||||
|
||||
|
|
|
@ -1,123 +0,0 @@
|
|||
/****************************************************************************
|
||||
* Copyright (c) 2012 by Michael Blandford. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
#define PIN_MODE_MASK 0x0003
|
||||
#define PIN_INPUT 0x0000
|
||||
#define PIN_OUTPUT 0x0001
|
||||
#define PIN_PERIPHERAL 0x0002
|
||||
#define PIN_ANALOG 0x0003
|
||||
#define PIN_PULL_MASK 0x000C
|
||||
#define PIN_PULLUP 0x0004
|
||||
#define PIN_NO_PULLUP 0x0000
|
||||
#define PIN_PULLDOWN 0x0008
|
||||
#define PIN_NO_PULLDOWN 0x0000
|
||||
#define PIN_NO_PULL 0x0000
|
||||
#define PIN_PERI_MASK 0x00F0
|
||||
//#define PIN_PERI_MASK_H 0x0020
|
||||
#define PIN_PER_0 0x0000
|
||||
#define PIN_PER_1 0x0010
|
||||
#define PIN_PER_2 0x0020
|
||||
#define PIN_PER_3 0x0030
|
||||
#define PIN_PER_4 0x0040
|
||||
#define PIN_PER_5 0x0050
|
||||
#define PIN_PER_6 0x0060
|
||||
#define PIN_PER_7 0x0070
|
||||
#define PIN_PER_8 0x0080
|
||||
#define PIN_PER_9 0x0090
|
||||
#define PIN_PER_10 0x00A0
|
||||
#define PIN_PER_11 0x00B0
|
||||
#define PIN_PER_12 0x00C0
|
||||
#define PIN_PER_13 0x00D0
|
||||
#define PIN_PER_14 0x00E0
|
||||
#define PIN_PER_15 0x00F0
|
||||
#define PIN_PORT_MASK 0x0700
|
||||
#define PIN_PORTA 0x0000
|
||||
#define PIN_PORTB 0x0100
|
||||
#define PIN_PORTC 0x0200
|
||||
#define PIN_PORTD 0x0300
|
||||
#define PIN_PORTE 0x0400
|
||||
#define PIN_LOW 0x0000
|
||||
#define PIN_HIGH 0x1000
|
||||
#define PIN_SPEED_MASK 0x6000
|
||||
#define PIN_OS2 0x0000
|
||||
#define PIN_OS25 0x2000
|
||||
#define PIN_OS50 0x4000
|
||||
#define PIN_OS100 0x6000
|
||||
#define PIN_PUSHPULL 0x0000
|
||||
#define PIN_ODRAIN 0x8000
|
||||
|
||||
#define GPIO_Pin_0 ((uint16_t)0x0001) /* Pin 0 selected */
|
||||
#define GPIO_Pin_1 ((uint16_t)0x0002) /* Pin 1 selected */
|
||||
#define GPIO_Pin_2 ((uint16_t)0x0004) /* Pin 2 selected */
|
||||
#define GPIO_Pin_3 ((uint16_t)0x0008) /* Pin 3 selected */
|
||||
#define GPIO_Pin_4 ((uint16_t)0x0010) /* Pin 4 selected */
|
||||
#define GPIO_Pin_5 ((uint16_t)0x0020) /* Pin 5 selected */
|
||||
#define GPIO_Pin_6 ((uint16_t)0x0040) /* Pin 6 selected */
|
||||
#define GPIO_Pin_7 ((uint16_t)0x0080) /* Pin 7 selected */
|
||||
#define GPIO_Pin_8 ((uint16_t)0x0100) /* Pin 8 selected */
|
||||
#define GPIO_Pin_9 ((uint16_t)0x0200) /* Pin 9 selected */
|
||||
#define GPIO_Pin_10 ((uint16_t)0x0400) /* Pin 10 selected */
|
||||
#define GPIO_Pin_11 ((uint16_t)0x0800) /* Pin 11 selected */
|
||||
#define GPIO_Pin_12 ((uint16_t)0x1000) /* Pin 12 selected */
|
||||
#define GPIO_Pin_13 ((uint16_t)0x2000) /* Pin 13 selected */
|
||||
#define GPIO_Pin_14 ((uint16_t)0x4000) /* Pin 14 selected */
|
||||
#define GPIO_Pin_15 ((uint16_t)0x8000) /* Pin 15 selected */
|
||||
#define GPIO_Pin_All ((uint16_t)0xFFFF) /* All pins selected */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PCBSKY
|
||||
#define PIN_ENABLE 0x001
|
||||
#define PIN_PERIPHERAL 0x000
|
||||
#define PIN_INPUT 0x002
|
||||
#define PIN_OUTPUT 0x000
|
||||
#define PIN_PULLUP 0x004
|
||||
#define PIN_NO_PULLUP 0x000
|
||||
#define PIN_PULLDOWN 0x008
|
||||
#define PIN_NO_PULLDOWN 0x000
|
||||
#define PIN_PERI_MASK_L 0x010
|
||||
#define PIN_PERI_MASK_H 0x020
|
||||
#define PIN_PER_A 0x000
|
||||
#define PIN_PER_B 0x010
|
||||
#define PIN_PER_C 0x020
|
||||
#define PIN_PER_D 0x030
|
||||
#define PIN_PORT_MASK 0x0C0
|
||||
#define PIN_PORTA 0x000
|
||||
#define PIN_PORTB 0x040
|
||||
#define PIN_PORTC 0x080
|
||||
#define PIN_LOW 0x000
|
||||
#define PIN_HIGH 0x100
|
||||
#endif
|
||||
|
||||
|
||||
extern void configure_pins( uint32_t pins, uint16_t config ) ;
|
||||
extern void init_keys( void ) ;
|
||||
extern uint32_t read_keys( void ) ;
|
||||
extern uint32_t read_trims( void ) ;
|
||||
extern uint32_t keyState( enum EnumKeys enuk) ;
|
||||
extern void init_trims( void ) ;
|
||||
extern void setup_switches( void ) ;
|
||||
extern void config_free_pins( void ) ;
|
||||
|
||||
#define GPIO_ResetBits( port, bits ) (port->BSRRH = bits)
|
||||
#define GPIO_SetBits( port, bits ) (port->BSRRL = bits)
|
||||
#define GPIO_ReadInputDataBit( port, bit) ( (port->IDR & bit) ? Bit_SET : Bit_RESET)
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
uint32_t switchPosition( uint32_t swtch ) ;
|
||||
#endif
|
||||
|
|
@ -25,14 +25,7 @@
|
|||
#include "drivers.h"
|
||||
#endif
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
#include "stm32f2xx.h"
|
||||
#include "stm32f2xx_gpio.h"
|
||||
#include "radio.h"
|
||||
#include "hal.h"
|
||||
#endif
|
||||
|
||||
#include "logicio.h"
|
||||
#include "../src/opentx.h"
|
||||
|
||||
|
||||
#ifndef SIMU
|
||||
|
@ -380,69 +373,5 @@ uint32_t initReadTrims( void )
|
|||
}
|
||||
#endif // PCBSKY
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
void init_keys()
|
||||
{
|
||||
// Buttons PE10, 11, 12, PD2, 3, 7
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN ; // Enable portE clock
|
||||
configure_pins( 0x1C00, PIN_INPUT | PIN_PULLUP | PIN_PORTE ) ;
|
||||
configure_pins( 0x008C, PIN_INPUT | PIN_PULLUP | PIN_PORTD ) ;
|
||||
}
|
||||
|
||||
// Reqd. bit 6 LEFT, 5 RIGHT, 4 UP, 3 DOWN 2 EXIT 1 MENU
|
||||
uint32_t read_keys()
|
||||
{
|
||||
register uint32_t x ;
|
||||
register uint32_t y ;
|
||||
|
||||
x = GPIOD->IDR ; // 7 MENU, 3 PAGE(UP), 2 EXIT
|
||||
|
||||
y = 0 ;
|
||||
if ( x & PIN_BUTTON_MENU )
|
||||
{
|
||||
y |= 0x02 << KEY_MENU ; // up
|
||||
// y |= 0x02 << KEY_MENU ; // MENU
|
||||
}
|
||||
if ( x & PIN_BUTTON_PAGE )
|
||||
{
|
||||
y |= 0x02 << KEY_PAGE ; // LEFT
|
||||
}
|
||||
if ( x & PIN_BUTTON_EXIT )
|
||||
{
|
||||
y |= 0x02 << KEY_EXIT ; // DOWN
|
||||
// y |= 0x02 << KEY_EXIT ; // EXIT
|
||||
}
|
||||
|
||||
x = GPIOE->IDR ; // 10 RIGHT(+), 11 LEFT(-), 12 ENT(DOWN)
|
||||
if ( x & PIN_BUTTON_PLUS )
|
||||
{
|
||||
y |= 0x02 << KEY_PLUS ; // MENU
|
||||
// y |= 0x02 << KEY_UP ; // up
|
||||
}
|
||||
if ( x & PIN_BUTTON_MINUS )
|
||||
{
|
||||
y |= 0x02 << KEY_MINUS ; // RIGHT
|
||||
// y |= 0x02 << KEY_DOWN ; // DOWN
|
||||
}
|
||||
if ( x & PIN_BUTTON_ENTER )
|
||||
{
|
||||
y |= 0x02 << KEY_ENTER ; // EXIT
|
||||
// y |= 0x02 << KEY_RIGHT ; // RIGHT
|
||||
}
|
||||
return y ;
|
||||
}
|
||||
|
||||
//
|
||||
void setup_switches()
|
||||
{
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN ; // Enable portB clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN ; // Enable portE clock
|
||||
configure_pins( 0x0020, PIN_INPUT | PIN_PULLUP | PIN_PORTA ) ;
|
||||
configure_pins( 0x003A, PIN_INPUT | PIN_PULLUP | PIN_PORTB ) ;
|
||||
configure_pins( 0xE307, PIN_INPUT | PIN_PULLUP | PIN_PORTE ) ;
|
||||
|
||||
}
|
||||
|
||||
#endif // PCBTARANIS
|
||||
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny <shadow@privy.de>
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - 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 <stdint.h>
|
||||
#ifdef PCBSKY
|
||||
#include "AT91SAM3S4.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
#include "stm32f2xx_gpio.h"
|
||||
#include "stm32f2xx_rcc.h"
|
||||
#include "hal.h"
|
||||
#endif
|
||||
|
||||
#include "radio.h"
|
||||
#include "logicio.h"
|
||||
|
||||
#ifdef PCBSKY
|
||||
|
||||
|
||||
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 ) ;
|
||||
}
|
||||
|
||||
|
||||
// Returns zero if power is switched off
|
||||
// 1 if power switch is on
|
||||
// 2 if power switch off, trainer power on
|
||||
uint32_t check_soft_power()
|
||||
{
|
||||
if ( PIOC->PIO_PDSR & PIO_PC17 ) // Power on
|
||||
{
|
||||
return POWER_ON ;
|
||||
}
|
||||
return POWER_OFF ;
|
||||
}
|
||||
|
||||
|
||||
// turn off soft power
|
||||
void soft_power_off()
|
||||
{
|
||||
configure_pins( PIO_PA8, PIN_ENABLE | PIN_OUTPUT | PIN_LOW | PIN_PORTA | PIN_NO_PULLUP ) ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
|
||||
void soft_power_off()
|
||||
{
|
||||
GPIO_ResetBits(GPIOPWR,PIN_MCU_PWR);
|
||||
}
|
||||
|
||||
uint32_t check_soft_power()
|
||||
{
|
||||
if (GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET)
|
||||
return POWER_ON;
|
||||
else
|
||||
return POWER_OFF;
|
||||
}
|
||||
|
||||
void init_soft_power()
|
||||
{
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN ; // Enable portD clock
|
||||
GPIO_ResetBits(GPIOPWR, PIN_INT_RF_PWR | PIN_EXT_RF_PWR);
|
||||
|
||||
/* GPIO Configuration*/
|
||||
configure_pins( PIN_INT_RF_PWR | PIN_EXT_RF_PWR | PIN_MCU_PWR, PIN_OUTPUT | PIN_PUSHPULL | PIN_OS25 | PIN_PORTD ) ;
|
||||
|
||||
configure_pins( PIN_PWR_STATUS, PIN_INPUT | PIN_PULLUP | PIN_PORTD ) ;
|
||||
|
||||
configure_pins( PIN_TRNDET, PIN_INPUT | PIN_PULLUP | PIN_PORTA ) ;
|
||||
|
||||
// Soft power ON
|
||||
|
||||
GPIO_SetBits(GPIOPWR,PIN_MCU_PWR);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -37,6 +37,7 @@
|
|||
#include "opentx.h"
|
||||
|
||||
uint8_t s_evt;
|
||||
struct t_inactivity inactivity = {0};
|
||||
|
||||
#if defined(CPUARM)
|
||||
uint8_t getEvent(bool trim)
|
||||
|
@ -97,7 +98,9 @@ void Key::input(bool val, EnumKeys enuk)
|
|||
break;
|
||||
|
||||
case KSTATE_RPTDELAY: // gruvin: delay state before first key repeat
|
||||
if(m_cnt == KEY_LONG_DELAY) putEvent(EVT_KEY_LONG(enuk));
|
||||
if (m_cnt == KEY_LONG_DELAY) {
|
||||
putEvent(EVT_KEY_LONG(enuk));
|
||||
}
|
||||
if (m_cnt == 40) {
|
||||
m_state = 16;
|
||||
m_cnt = 0;
|
||||
|
@ -108,17 +111,19 @@ void Key::input(bool val, EnumKeys enuk)
|
|||
case 8:
|
||||
case 4:
|
||||
case 2:
|
||||
if(m_cnt >= 48) { //3 6 12 24 48 pulses in every 480ms
|
||||
if (m_cnt >= 48) { //3 6 12 24 48 pulses in every 480ms
|
||||
m_state >>= 1;
|
||||
m_cnt = 0;
|
||||
}
|
||||
// no break
|
||||
case 1:
|
||||
if( (m_cnt & (m_state-1)) == 0) putEvent(EVT_KEY_REPT(enuk));
|
||||
if ((m_cnt & (m_state-1)) == 0) {
|
||||
putEvent(EVT_KEY_REPT(enuk));
|
||||
}
|
||||
break;
|
||||
|
||||
case KSTATE_PAUSE: //pause
|
||||
if(m_cnt >= 64) {
|
||||
if (m_cnt >= 64) {
|
||||
m_state = 8;
|
||||
m_cnt = 0;
|
||||
}
|
||||
|
|
231
radio/src/keys.h
Executable file
231
radio/src/keys.h
Executable file
|
@ -0,0 +1,231 @@
|
|||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* opentx 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef keys_h
|
||||
#define keys_h
|
||||
|
||||
enum EnumKeys {
|
||||
KEY_MENU,
|
||||
KEY_EXIT,
|
||||
#if defined(PCBTARANIS)
|
||||
KEY_ENTER,
|
||||
KEY_PAGE,
|
||||
KEY_PLUS,
|
||||
KEY_MINUS,
|
||||
#else
|
||||
KEY_DOWN,
|
||||
KEY_UP,
|
||||
KEY_RIGHT,
|
||||
KEY_LEFT,
|
||||
#endif
|
||||
|
||||
TRM_BASE,
|
||||
TRM_LH_DWN = TRM_BASE,
|
||||
TRM_LH_UP,
|
||||
TRM_LV_DWN,
|
||||
TRM_LV_UP,
|
||||
TRM_RV_DWN,
|
||||
TRM_RV_UP,
|
||||
TRM_RH_DWN,
|
||||
TRM_RH_UP,
|
||||
|
||||
#if ROTARY_ENCODERS > 0 || defined(ROTARY_ENCODER_NAVIGATION)
|
||||
BTN_REa,
|
||||
#endif
|
||||
#if ROTARY_ENCODERS > 0
|
||||
BTN_REb,
|
||||
#endif
|
||||
|
||||
NUM_KEYS,
|
||||
SW_BASE=NUM_KEYS,
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
SW_SA0=SW_BASE,
|
||||
SW_SA1,
|
||||
SW_SA2,
|
||||
SW_SB0,
|
||||
SW_SB1,
|
||||
SW_SB2,
|
||||
SW_SC0,
|
||||
SW_SC1,
|
||||
SW_SC2,
|
||||
SW_SD0,
|
||||
SW_SD1,
|
||||
SW_SD2,
|
||||
SW_SE0,
|
||||
SW_SE1,
|
||||
SW_SE2,
|
||||
SW_SF0,
|
||||
SW_SF2,
|
||||
SW_SG0,
|
||||
SW_SG1,
|
||||
SW_SG2,
|
||||
SW_SH0,
|
||||
SW_SH2,
|
||||
#else
|
||||
SW_ID0=SW_BASE,
|
||||
SW_ID1,
|
||||
SW_ID2,
|
||||
#if defined(EXTRA_3POS)
|
||||
SW_ID3,
|
||||
SW_ID4,
|
||||
SW_ID5,
|
||||
#endif
|
||||
|
||||
SW_THR,
|
||||
SW_RUD,
|
||||
SW_ELE,
|
||||
SW_AIL,
|
||||
SW_GEA,
|
||||
SW_TRN,
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#define EVT_KEY_MASK(e) ((e) & 0x1f)
|
||||
|
||||
#define _MSK_KEY_BREAK 0x20
|
||||
#define _MSK_KEY_REPT 0x40
|
||||
#define _MSK_KEY_FIRST 0x60
|
||||
#define _MSK_KEY_LONG 0x80
|
||||
|
||||
#define EVT_KEY_BREAK(key) ((key)|_MSK_KEY_BREAK)
|
||||
#define EVT_KEY_FIRST(key) ((key)|_MSK_KEY_FIRST)
|
||||
#define EVT_KEY_REPT(key) ((key)|_MSK_KEY_REPT)
|
||||
#define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG)
|
||||
|
||||
#define IS_KEY_BREAK(evt) (((evt)&0xe0) == _MSK_KEY_BREAK)
|
||||
#define IS_KEY_FIRST(evt) (((evt)&0xe0) == _MSK_KEY_FIRST)
|
||||
#define IS_KEY_LONG(evt) (((evt)&0xe0) == _MSK_KEY_LONG)
|
||||
|
||||
#define EVT_ENTRY 0xbf
|
||||
#define EVT_ENTRY_UP 0xbe
|
||||
#define EVT_MENU_UP 0xbd
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
|
||||
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
|
||||
#else
|
||||
#define EVT_ROTARY_BREAK 0xcf
|
||||
#define EVT_ROTARY_LONG 0xce
|
||||
#define EVT_ROTARY_LEFT 0xdf
|
||||
#define EVT_ROTARY_RIGHT 0xde
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define IS_ROTARY_LEFT(evt) (evt==EVT_KEY_FIRST(KEY_MINUS) || evt==EVT_KEY_REPT(KEY_MINUS))
|
||||
#define IS_ROTARY_RIGHT(evt) (evt==EVT_KEY_FIRST(KEY_PLUS) || evt==EVT_KEY_REPT(KEY_PLUS))
|
||||
#define IS_ROTARY_UP(evt) (evt==EVT_KEY_FIRST(KEY_PLUS) || evt==EVT_KEY_REPT(KEY_PLUS))
|
||||
#define IS_ROTARY_DOWN(evt) (evt==EVT_KEY_FIRST(KEY_MINUS) || evt==EVT_KEY_REPT(KEY_MINUS))
|
||||
#define IS_ROTARY_BREAK(evt) (evt==EVT_KEY_BREAK(KEY_ENTER))
|
||||
#define IS_ROTARY_LONG(evt) (evt==EVT_KEY_LONG(KEY_ENTER))
|
||||
#define IS_ROTARY_EVENT(evt) (0)
|
||||
#define CASE_EVT_ROTARY_BREAK /*case EVT_KEY_BREAK(KEY_ENTER):*/
|
||||
#define CASE_EVT_ROTARY_LONG /*case EVT_KEY_LONG(KEY_ENTER):*/
|
||||
#define CASE_EVT_ROTARY_LEFT case EVT_KEY_FIRST(KEY_MOVE_DOWN): case EVT_KEY_REPT(KEY_MOVE_DOWN):
|
||||
#define CASE_EVT_ROTARY_RIGHT case EVT_KEY_FIRST(KEY_MOVE_UP): case EVT_KEY_REPT(KEY_MOVE_UP):
|
||||
#elif defined(ROTARY_ENCODER_NAVIGATION)
|
||||
#define IS_ROTARY_LEFT(evt) (evt == EVT_ROTARY_LEFT)
|
||||
#define IS_ROTARY_RIGHT(evt) (evt == EVT_ROTARY_RIGHT)
|
||||
#define IS_ROTARY_UP(evt) IS_ROTARY_LEFT(evt)
|
||||
#define IS_ROTARY_DOWN(evt) IS_ROTARY_RIGHT(evt)
|
||||
#define IS_ROTARY_BREAK(evt) (evt == EVT_ROTARY_BREAK)
|
||||
#define IS_ROTARY_LONG(evt) (evt == EVT_ROTARY_LONG)
|
||||
#define IS_ROTARY_EVENT(evt) (EVT_KEY_MASK(evt) >= 0x0e)
|
||||
#define CASE_EVT_ROTARY_BREAK case EVT_ROTARY_BREAK:
|
||||
#define CASE_EVT_ROTARY_LONG case EVT_ROTARY_LONG:
|
||||
#define CASE_EVT_ROTARY_LEFT case EVT_ROTARY_LEFT:
|
||||
#define CASE_EVT_ROTARY_RIGHT case EVT_ROTARY_RIGHT:
|
||||
#else
|
||||
#define IS_ROTARY_LEFT(evt) (0)
|
||||
#define IS_ROTARY_RIGHT(evt) (0)
|
||||
#define IS_ROTARY_UP(evt) (0)
|
||||
#define IS_ROTARY_DOWN(evt) (0)
|
||||
#define IS_ROTARY_BREAK(evt) (0)
|
||||
#define IS_ROTARY_LONG(evt) (0)
|
||||
#define IS_ROTARY_EVENT(evt) (0)
|
||||
#define CASE_EVT_ROTARY_BREAK
|
||||
#define CASE_EVT_ROTARY_LONG
|
||||
#define CASE_EVT_ROTARY_LEFT
|
||||
#define CASE_EVT_ROTARY_RIGHT
|
||||
#endif
|
||||
|
||||
class Key
|
||||
{
|
||||
#define FILTERBITS 4
|
||||
|
||||
#ifdef SIMU
|
||||
#define FFVAL 1
|
||||
#else
|
||||
#define FFVAL ((1<<FILTERBITS)-1)
|
||||
#endif
|
||||
|
||||
#define KSTATE_OFF 0
|
||||
#define KSTATE_RPTDELAY 95 // gruvin: delay state before key repeating starts
|
||||
#define KSTATE_START 97
|
||||
#define KSTATE_PAUSE 98
|
||||
#define KSTATE_KILLED 99
|
||||
|
||||
private:
|
||||
uint8_t m_vals; // key debounce? 4 = 40ms
|
||||
uint8_t m_cnt;
|
||||
uint8_t m_state;
|
||||
public:
|
||||
void input(bool val, EnumKeys enuk);
|
||||
bool state() { return m_vals > 0; }
|
||||
void pauseEvents() { m_state = KSTATE_PAUSE; m_cnt = 0; }
|
||||
void killEvents() { m_state = KSTATE_KILLED; }
|
||||
};
|
||||
|
||||
extern Key keys[NUM_KEYS];
|
||||
|
||||
extern uint8_t s_evt;
|
||||
|
||||
#define putEvent(evt) s_evt = evt
|
||||
|
||||
void clearKeyEvents();
|
||||
void pauseEvents(uint8_t enuk);
|
||||
void killEvents(uint8_t enuk);
|
||||
|
||||
#if defined(CPUARM)
|
||||
uint8_t getEvent(bool trim=false);
|
||||
#else
|
||||
uint8_t getEvent();
|
||||
#endif
|
||||
|
||||
uint8_t keyDown();
|
||||
|
||||
#endif
|
|
@ -45,7 +45,6 @@ int16_t anas [NUM_INPUTS] = {0};
|
|||
int16_t trims[NUM_STICKS] = {0};
|
||||
int32_t chans[NUM_CHNOUT] = {0};
|
||||
BeepANACenter bpanaCenter = 0;
|
||||
struct t_inactivity inactivity = {0};
|
||||
|
||||
int24_t act [MAX_MIXERS] = {0};
|
||||
SwOn swOn [MAX_MIXERS]; // TODO better name later...
|
||||
|
|
|
@ -297,83 +297,6 @@ extern void boardInit();
|
|||
|
||||
#define NUM_STICKS 4
|
||||
|
||||
enum EnumKeys {
|
||||
KEY_MENU,
|
||||
KEY_EXIT,
|
||||
#if defined(PCBTARANIS)
|
||||
KEY_ENTER,
|
||||
KEY_PAGE,
|
||||
KEY_PLUS,
|
||||
KEY_MINUS,
|
||||
#else
|
||||
KEY_DOWN,
|
||||
KEY_UP,
|
||||
KEY_RIGHT,
|
||||
KEY_LEFT,
|
||||
#endif
|
||||
|
||||
TRM_BASE,
|
||||
TRM_LH_DWN = TRM_BASE,
|
||||
TRM_LH_UP,
|
||||
TRM_LV_DWN,
|
||||
TRM_LV_UP,
|
||||
TRM_RV_DWN,
|
||||
TRM_RV_UP,
|
||||
TRM_RH_DWN,
|
||||
TRM_RH_UP,
|
||||
|
||||
#if ROTARY_ENCODERS > 0 || defined(ROTARY_ENCODER_NAVIGATION)
|
||||
BTN_REa,
|
||||
#endif
|
||||
#if ROTARY_ENCODERS > 0
|
||||
BTN_REb,
|
||||
#endif
|
||||
|
||||
NUM_KEYS,
|
||||
SW_BASE=NUM_KEYS,
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
SW_SA0=SW_BASE,
|
||||
SW_SA1,
|
||||
SW_SA2,
|
||||
SW_SB0,
|
||||
SW_SB1,
|
||||
SW_SB2,
|
||||
SW_SC0,
|
||||
SW_SC1,
|
||||
SW_SC2,
|
||||
SW_SD0,
|
||||
SW_SD1,
|
||||
SW_SD2,
|
||||
SW_SE0,
|
||||
SW_SE1,
|
||||
SW_SE2,
|
||||
SW_SF0,
|
||||
SW_SF2,
|
||||
SW_SG0,
|
||||
SW_SG1,
|
||||
SW_SG2,
|
||||
SW_SH0,
|
||||
SW_SH2,
|
||||
#else
|
||||
SW_ID0=SW_BASE,
|
||||
SW_ID1,
|
||||
SW_ID2,
|
||||
#if defined(EXTRA_3POS)
|
||||
SW_ID3,
|
||||
SW_ID4,
|
||||
SW_ID5,
|
||||
#endif
|
||||
|
||||
SW_THR,
|
||||
SW_RUD,
|
||||
SW_ELE,
|
||||
SW_AIL,
|
||||
SW_GEA,
|
||||
SW_TRN,
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define NUM_SWITCHES 8
|
||||
|
@ -587,35 +510,6 @@ extern uint8_t stickMode;
|
|||
|
||||
extern uint8_t channel_order(uint8_t x);
|
||||
|
||||
class Key
|
||||
{
|
||||
#define FILTERBITS 4
|
||||
|
||||
#ifdef SIMU
|
||||
#define FFVAL 1
|
||||
#else
|
||||
#define FFVAL ((1<<FILTERBITS)-1)
|
||||
#endif
|
||||
|
||||
#define KSTATE_OFF 0
|
||||
#define KSTATE_RPTDELAY 95 // gruvin: delay state before key repeating starts
|
||||
#define KSTATE_START 97
|
||||
#define KSTATE_PAUSE 98
|
||||
#define KSTATE_KILLED 99
|
||||
|
||||
private:
|
||||
uint8_t m_vals; // key debounce? 4 = 40ms
|
||||
uint8_t m_cnt;
|
||||
uint8_t m_state;
|
||||
public:
|
||||
void input(bool val, EnumKeys enuk);
|
||||
bool state() { return m_vals > 0; }
|
||||
void pauseEvents() { m_state = KSTATE_PAUSE; m_cnt = 0; }
|
||||
void killEvents() { m_state = KSTATE_KILLED; }
|
||||
};
|
||||
|
||||
extern Key keys[NUM_KEYS];
|
||||
|
||||
enum BaseCurves {
|
||||
CURVE_NONE,
|
||||
CURVE_X_GT0,
|
||||
|
@ -630,77 +524,9 @@ enum BaseCurves {
|
|||
#define THRCHK_DEADBAND 16
|
||||
|
||||
#if defined(FSPLASH) || defined(XSPLASH)
|
||||
#define SPLASH_TIMEOUT (g_eeGeneral.splashMode == 0 ? 60000/*infinite=10mn*/ : ((4*100) * (g_eeGeneral.splashMode & 0x03)))
|
||||
#define SPLASH_TIMEOUT (g_eeGeneral.splashMode == 0 ? 60000/*infinite=10mn*/ : ((4*100) * (g_eeGeneral.splashMode & 0x03)))
|
||||
#else
|
||||
#define SPLASH_TIMEOUT (4*100) // 4 seconds
|
||||
#endif
|
||||
|
||||
#define EVT_KEY_MASK(e) ((e) & 0x1f)
|
||||
|
||||
#define _MSK_KEY_BREAK 0x20
|
||||
#define _MSK_KEY_REPT 0x40
|
||||
#define _MSK_KEY_FIRST 0x60
|
||||
#define _MSK_KEY_LONG 0x80
|
||||
|
||||
#define EVT_KEY_BREAK(key) ((key)|_MSK_KEY_BREAK)
|
||||
#define EVT_KEY_FIRST(key) ((key)|_MSK_KEY_FIRST)
|
||||
#define EVT_KEY_REPT(key) ((key)|_MSK_KEY_REPT)
|
||||
#define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG)
|
||||
|
||||
#define IS_KEY_BREAK(evt) (((evt)&0xe0) == _MSK_KEY_BREAK)
|
||||
#define IS_KEY_FIRST(evt) (((evt)&0xe0) == _MSK_KEY_FIRST)
|
||||
#define IS_KEY_LONG(evt) (((evt)&0xe0) == _MSK_KEY_LONG)
|
||||
|
||||
#define EVT_ENTRY 0xbf
|
||||
#define EVT_ENTRY_UP 0xbe
|
||||
#define EVT_MENU_UP 0xbd
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
|
||||
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
|
||||
#else
|
||||
#define EVT_ROTARY_BREAK 0xcf
|
||||
#define EVT_ROTARY_LONG 0xce
|
||||
#define EVT_ROTARY_LEFT 0xdf
|
||||
#define EVT_ROTARY_RIGHT 0xde
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define IS_ROTARY_LEFT(evt) (evt==EVT_KEY_FIRST(KEY_MINUS) || evt==EVT_KEY_REPT(KEY_MINUS))
|
||||
#define IS_ROTARY_RIGHT(evt) (evt==EVT_KEY_FIRST(KEY_PLUS) || evt==EVT_KEY_REPT(KEY_PLUS))
|
||||
#define IS_ROTARY_UP(evt) (evt==EVT_KEY_FIRST(KEY_PLUS) || evt==EVT_KEY_REPT(KEY_PLUS))
|
||||
#define IS_ROTARY_DOWN(evt) (evt==EVT_KEY_FIRST(KEY_MINUS) || evt==EVT_KEY_REPT(KEY_MINUS))
|
||||
#define IS_ROTARY_BREAK(evt) (evt==EVT_KEY_BREAK(KEY_ENTER))
|
||||
#define IS_ROTARY_LONG(evt) (evt==EVT_KEY_LONG(KEY_ENTER))
|
||||
#define IS_ROTARY_EVENT(evt) (0)
|
||||
#define CASE_EVT_ROTARY_BREAK /*case EVT_KEY_BREAK(KEY_ENTER):*/
|
||||
#define CASE_EVT_ROTARY_LONG /*case EVT_KEY_LONG(KEY_ENTER):*/
|
||||
#define CASE_EVT_ROTARY_LEFT case EVT_KEY_FIRST(KEY_MOVE_DOWN): case EVT_KEY_REPT(KEY_MOVE_DOWN):
|
||||
#define CASE_EVT_ROTARY_RIGHT case EVT_KEY_FIRST(KEY_MOVE_UP): case EVT_KEY_REPT(KEY_MOVE_UP):
|
||||
#elif defined(ROTARY_ENCODER_NAVIGATION)
|
||||
#define IS_ROTARY_LEFT(evt) (evt == EVT_ROTARY_LEFT)
|
||||
#define IS_ROTARY_RIGHT(evt) (evt == EVT_ROTARY_RIGHT)
|
||||
#define IS_ROTARY_UP(evt) IS_ROTARY_LEFT(evt)
|
||||
#define IS_ROTARY_DOWN(evt) IS_ROTARY_RIGHT(evt)
|
||||
#define IS_ROTARY_BREAK(evt) (evt == EVT_ROTARY_BREAK)
|
||||
#define IS_ROTARY_LONG(evt) (evt == EVT_ROTARY_LONG)
|
||||
#define IS_ROTARY_EVENT(evt) (EVT_KEY_MASK(evt) >= 0x0e)
|
||||
#define CASE_EVT_ROTARY_BREAK case EVT_ROTARY_BREAK:
|
||||
#define CASE_EVT_ROTARY_LONG case EVT_ROTARY_LONG:
|
||||
#define CASE_EVT_ROTARY_LEFT case EVT_ROTARY_LEFT:
|
||||
#define CASE_EVT_ROTARY_RIGHT case EVT_ROTARY_RIGHT:
|
||||
#else
|
||||
#define IS_ROTARY_LEFT(evt) (0)
|
||||
#define IS_ROTARY_RIGHT(evt) (0)
|
||||
#define IS_ROTARY_UP(evt) (0)
|
||||
#define IS_ROTARY_DOWN(evt) (0)
|
||||
#define IS_ROTARY_BREAK(evt) (0)
|
||||
#define IS_ROTARY_LONG(evt) (0)
|
||||
#define IS_ROTARY_EVENT(evt) (0)
|
||||
#define CASE_EVT_ROTARY_BREAK
|
||||
#define CASE_EVT_ROTARY_LONG
|
||||
#define CASE_EVT_ROTARY_LEFT
|
||||
#define CASE_EVT_ROTARY_RIGHT
|
||||
#define SPLASH_TIMEOUT (4*100) // 4 seconds
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
|
@ -734,6 +560,7 @@ struct t_inactivity
|
|||
uint16_t counter;
|
||||
uint8_t sum;
|
||||
};
|
||||
|
||||
extern struct t_inactivity inactivity;
|
||||
|
||||
#if defined(PXX)
|
||||
|
@ -754,25 +581,8 @@ void str2zchar(char *dest, const char *src, int size);
|
|||
void zchar2str(char *dest, const char *src, int size);
|
||||
#endif
|
||||
|
||||
extern uint8_t s_evt;
|
||||
#define putEvent(evt) s_evt = evt
|
||||
void clearKeyEvents();
|
||||
void pauseEvents(uint8_t enuk);
|
||||
void killEvents(uint8_t enuk);
|
||||
#if defined(CPUARM)
|
||||
uint8_t getEvent(bool trim);
|
||||
#else
|
||||
uint8_t getEvent();
|
||||
#endif
|
||||
|
||||
uint8_t keyDown();
|
||||
|
||||
enum PowerState {
|
||||
e_power_on,
|
||||
e_power_trainer,
|
||||
e_power_usb,
|
||||
e_power_off
|
||||
};
|
||||
#include "keys.h"
|
||||
#include "pwr.h"
|
||||
|
||||
bool switchState(EnumKeys enuk);
|
||||
uint8_t trimDown(uint8_t idx);
|
||||
|
|
47
radio/src/pwr.h
Executable file
47
radio/src/pwr.h
Executable file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* opentx 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef pwr_h
|
||||
#define pwr_h
|
||||
|
||||
enum PowerState {
|
||||
e_power_on,
|
||||
e_power_trainer,
|
||||
e_power_usb,
|
||||
e_power_off
|
||||
};
|
||||
|
||||
#endif
|
|
@ -44,22 +44,6 @@ extern "C" {
|
|||
|
||||
volatile uint32_t Tenms ; // TODO to remove everywhere / use a #define
|
||||
|
||||
#define PIN_MODE_MASK 0x0003
|
||||
#define PIN_INPUT 0x0000
|
||||
#define PIN_OUTPUT 0x0001
|
||||
#define PIN_PERIPHERAL 0x0002
|
||||
#define PIN_ANALOG 0x0003
|
||||
#define PIN_PULL_MASK 0x000C
|
||||
#define PIN_PULLUP 0x0004
|
||||
#define PIN_NO_PULLUP 0x0000
|
||||
#define PIN_PULLDOWN 0x0008
|
||||
#define PIN_NO_PULLDOWN 0x0000
|
||||
#define PIN_PERI_MASK 0x00F0
|
||||
#define PIN_PUSHPULL 0x0000
|
||||
#define PIN_ODRAIN 0x8000
|
||||
#define PIN_PORT_MASK 0x0700
|
||||
#define PIN_SPEED_MASK 0x6000
|
||||
|
||||
#if !defined(SIMU)
|
||||
void configure_pins( uint32_t pins, uint16_t config )
|
||||
{
|
||||
|
@ -106,32 +90,6 @@ void configure_pins( uint32_t pins, uint16_t config )
|
|||
}
|
||||
#endif
|
||||
|
||||
bool usbPlugged(void)
|
||||
{
|
||||
return GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS);
|
||||
}
|
||||
|
||||
#if !defined(SIMU)
|
||||
extern "C" {
|
||||
USB_OTG_CORE_HANDLE USB_OTG_dev;
|
||||
|
||||
void OTG_FS_IRQHandler(void)
|
||||
{
|
||||
USBD_OTG_ISR_Handler (&USB_OTG_dev);
|
||||
}
|
||||
}
|
||||
|
||||
void usbInit()
|
||||
{
|
||||
USB_OTG_BSP_Init(&USB_OTG_dev);
|
||||
}
|
||||
|
||||
void usbStart()
|
||||
{
|
||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
|
||||
}
|
||||
#endif
|
||||
|
||||
void watchdogInit(unsigned int duration)
|
||||
{
|
||||
IWDG->KR = 0x5555 ; // Unlock registers
|
||||
|
|
|
@ -75,6 +75,22 @@ extern "C" {
|
|||
#define JACK_PPM_OUT()
|
||||
#define JACK_PPM_IN()
|
||||
|
||||
#define PIN_MODE_MASK 0x0003
|
||||
#define PIN_INPUT 0x0000
|
||||
#define PIN_OUTPUT 0x0001
|
||||
#define PIN_PERIPHERAL 0x0002
|
||||
#define PIN_ANALOG 0x0003
|
||||
#define PIN_PULL_MASK 0x000C
|
||||
#define PIN_PULLUP 0x0004
|
||||
#define PIN_NO_PULLUP 0x0000
|
||||
#define PIN_PULLDOWN 0x0008
|
||||
#define PIN_NO_PULLDOWN 0x0000
|
||||
#define PIN_PERI_MASK 0x00F0
|
||||
#define PIN_PUSHPULL 0x0000
|
||||
#define PIN_ODRAIN 0x8000
|
||||
#define PIN_PORT_MASK 0x0700
|
||||
#define PIN_SPEED_MASK 0x6000
|
||||
|
||||
void configure_pins( uint32_t pins, uint16_t config );
|
||||
|
||||
#define strcpy_P strcpy
|
||||
|
@ -160,6 +176,10 @@ extern volatile uint16_t Analog_values[];
|
|||
#define BATT_SCALE 150
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Power driver
|
||||
void pwrInit(void);
|
||||
uint32_t pwrCheck(void);
|
||||
|
@ -176,13 +196,15 @@ void pwrOff(void);
|
|||
#define __BACKLIGHT_OFF TIM10->CCR1 = 0
|
||||
#define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0)
|
||||
|
||||
#if !defined(BOOT)
|
||||
// USB driver
|
||||
int usbPlugged(void);
|
||||
#define BOOTLOADER_REQUEST() (0)
|
||||
#define usbBootloader()
|
||||
void usbInit(void);
|
||||
void usbStart(void);
|
||||
bool usbPlugged(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// EEPROM driver
|
||||
|
|
|
@ -34,26 +34,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "../../opentx.h"
|
||||
|
||||
void pwrOff()
|
||||
{
|
||||
GPIO_ResetBits(GPIOPWR,PIN_MCU_PWR);
|
||||
}
|
||||
|
||||
uint32_t pwrCheck()
|
||||
{
|
||||
#if defined(SIMU)
|
||||
return e_power_on;
|
||||
#else
|
||||
if (GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET)
|
||||
return e_power_on;
|
||||
else if (usbPlugged())
|
||||
return e_power_usb;
|
||||
else
|
||||
return e_power_off;
|
||||
#endif
|
||||
}
|
||||
#include "board_taranis.h"
|
||||
#include "../src/pwr.h"
|
||||
|
||||
void pwrInit()
|
||||
{
|
||||
|
@ -101,5 +83,25 @@ void pwrInit()
|
|||
#endif
|
||||
|
||||
// Soft power ON
|
||||
GPIO_SetBits(GPIOPWR,PIN_MCU_PWR);
|
||||
GPIO_SetBits(GPIOPWR, PIN_MCU_PWR);
|
||||
}
|
||||
|
||||
void pwrOff()
|
||||
{
|
||||
GPIO_ResetBits(GPIOPWR, PIN_MCU_PWR);
|
||||
}
|
||||
|
||||
// TODO enums should be UPPERCASE
|
||||
uint32_t pwrCheck()
|
||||
{
|
||||
#if defined(SIMU)
|
||||
return e_power_on;
|
||||
#else
|
||||
if (GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET)
|
||||
return e_power_on;
|
||||
else if (usbPlugged())
|
||||
return e_power_usb;
|
||||
else
|
||||
return e_power_off;
|
||||
#endif
|
||||
}
|
59
radio/src/targets/taranis/usb_driver.c
Executable file
59
radio/src/targets/taranis/usb_driver.c
Executable file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* opentx 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 "board_taranis.h"
|
||||
|
||||
int usbPlugged(void)
|
||||
{
|
||||
return GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS);
|
||||
}
|
||||
|
||||
USB_OTG_CORE_HANDLE USB_OTG_dev;
|
||||
|
||||
void OTG_FS_IRQHandler(void)
|
||||
{
|
||||
USBD_OTG_ISR_Handler (&USB_OTG_dev);
|
||||
}
|
||||
|
||||
void usbInit()
|
||||
{
|
||||
USB_OTG_BSP_Init(&USB_OTG_dev);
|
||||
}
|
||||
|
||||
void usbStart()
|
||||
{
|
||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue