2 more files removed
This commit is contained in:
@@ -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
|
||||
|
||||
+13
-46
@@ -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
|
||||
@@ -40,7 +33,7 @@
|
||||
void configure_pins( uint32_t pins, uint16_t config )
|
||||
{
|
||||
register Pio *pioptr ;
|
||||
|
||||
|
||||
pioptr = PIOA + ( ( config & PIN_PORT_MASK ) >> 6) ;
|
||||
if ( config & PIN_PULLUP )
|
||||
{
|
||||
@@ -64,11 +57,11 @@ void configure_pins( uint32_t pins, uint16_t config )
|
||||
|
||||
if ( config & PIN_HIGH )
|
||||
{
|
||||
pioptr->PIO_SODR = pins ;
|
||||
pioptr->PIO_SODR = pins ;
|
||||
}
|
||||
else
|
||||
{
|
||||
pioptr->PIO_CODR = pins ;
|
||||
pioptr->PIO_CODR = pins ;
|
||||
}
|
||||
|
||||
if ( config & PIN_INPUT )
|
||||
@@ -99,11 +92,11 @@ void configure_pins( uint32_t pins, uint16_t config )
|
||||
|
||||
if ( config & PIN_ENABLE )
|
||||
{
|
||||
pioptr->PIO_PER = pins ;
|
||||
pioptr->PIO_PER = pins ;
|
||||
}
|
||||
else
|
||||
{
|
||||
pioptr->PIO_PDR = pins ;
|
||||
pioptr->PIO_PDR = pins ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -153,17 +146,17 @@ void configure_pins( uint32_t pins, uint16_t config )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef PCBSKY
|
||||
|
||||
|
||||
void init_keys()
|
||||
{
|
||||
register Pio *pioptr ;
|
||||
|
||||
|
||||
pioptr = PIOC ;
|
||||
// Next section configures the key inputs on the LCD data
|
||||
pioptr->PIO_PER = 0x0000003BL ; // Enable bits 1,3,4,5, 0
|
||||
@@ -230,7 +223,7 @@ void setup_switches()
|
||||
// PC21, PC19, PC15 (PPM2 output)
|
||||
void config_free_pins()
|
||||
{
|
||||
|
||||
|
||||
configure_pins( PIO_PB14, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP ) ;
|
||||
|
||||
}
|
||||
@@ -255,7 +248,7 @@ uint32_t read_keys()
|
||||
register uint32_t y ;
|
||||
|
||||
x = LcdLock ? LcdInputs : PIOC->PIO_PDSR << 1 ; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
|
||||
|
||||
|
||||
y = x & 0x00000020 ; // RIGHT
|
||||
if ( x & 0x00000004 )
|
||||
{
|
||||
@@ -300,7 +293,7 @@ uint32_t read_trims()
|
||||
{
|
||||
trims |= 1 ;
|
||||
}
|
||||
|
||||
|
||||
// TRIM_LV_DOWN PA27 (PA24)
|
||||
if ( ( trima & 0x01000000 ) == 0 )
|
||||
{
|
||||
@@ -375,74 +368,10 @@ uint32_t initReadTrims( void )
|
||||
{
|
||||
__asm("nop") ;
|
||||
}
|
||||
|
||||
|
||||
return read_trims() ;
|
||||
}
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user