Merge remote-tracking branch 'origin/next' into Horus

# Conflicts:
#	companion/src/CMakeLists.txt
#	companion/src/firmwares/opentx/opentxinterface.cpp
#	companion/src/firmwares/opentx/simulator/CMakeLists.txt
#	companion/src/firmwares/opentx/stamp-opentx.h.in
#	radio/src/Makefile
#	radio/src/cli.cpp
#	radio/src/gui/Taranis/helpers.cpp
#	radio/src/gui/Taranis/lcd.cpp
#	radio/src/gui/Taranis/menu_model_setup.cpp
#	radio/src/gui/Taranis/view_main.cpp
#	radio/src/lua_api.cpp
#	radio/src/main_avr.cpp
#	radio/src/myeeprom.h
#	radio/src/opentx.cpp
#	radio/src/pulses/pxx_arm.cpp
#	radio/src/storage/eeprom_conversions.cpp
#	radio/src/targets/Horus/adc_driver.cpp
#	radio/src/targets/Horus/board_horus.cpp
#	radio/src/targets/Horus/board_horus.h
#	radio/src/targets/Horus/diskio.cpp
#	radio/src/targets/Horus/hal.h
#	radio/src/targets/Horus/haptic_driver.cpp
#	radio/src/targets/Horus/i2c_driver.cpp
#	radio/src/targets/Horus/keys_driver.cpp
#	radio/src/targets/Horus/lcd_driver.cpp
#	radio/src/targets/Horus/led_driver.cpp
#	radio/src/targets/Horus/pulses_driver.cpp
#	radio/src/targets/Horus/pwr_driver.c
#	radio/src/targets/Horus/sdio_sd.c
#	radio/src/targets/Horus/sdio_sd.h
#	radio/src/targets/Horus/serial2_driver.cpp
#	radio/src/targets/Horus/telemetry_driver.cpp
#	radio/src/targets/Horus/usb_conf.h
#	radio/src/targets/Horus/usbd_desc.c
#	radio/src/targets/Horus/usbd_storage_msd.cpp
This commit is contained in:
Bertrand Songis
2015-11-15 23:08:34 +01:00
85 changed files with 7036 additions and 3662 deletions
+70 -10
View File
@@ -150,17 +150,65 @@ void lcdSetRefVolt(uint8_t val)
#endif
}
#if defined(LCD_ST7920)
void lcdRefresh(){
lcdRefresh_ST7920(1);
}
uint8_t lcdRefresh_ST7920(uint8_t full)
{
#else
void lcdRefresh()
{
#endif
LCD_LOCK();
#if defined(LCD_ST7920)
static uint8_t state;
uint8_t yst,yend;
uint8_t x_addr = 0;
uint8_t y_addr = 0;
uint16_t line_offset = 0;
uint8_t col_offset = 0;
uint16_t byte_offset = 0;
uint8_t bit_count = 0;
for (uint8_t y=0; y<64; y++) {
uint8_t result;
uint8_t *p;
if(full!=0){
yst=0;
yend=64;
state=0;
}
else{
switch (state){//Since writing to ST7920 is too slow we need to split it to five bands.
default:
case 0:
yst=0;
yend=13;
state=1;
break;
case 1:
yst=13;
yend=26;
state=2;
break;
case 2:
yst=26;
yend=39;
state=3;
break;
case 3:
yst=39;
yend=52;
state=4;
break;
case 4:
yst=52;
yend=64;
state=0;
break;
}
}
for (uint8_t y=yst; y<yend; y++) {
x_addr = 0;
//Convert coordinates to weirdly-arranged 128x64 screen (the ST7920 is mapped for 256x32 displays)
if (y > 31) {
@@ -170,20 +218,28 @@ void lcdRefresh()
else {
y_addr = y;
}
lcdSendCtl( 0x80 | y_addr ); //Set Vertical Address
lcdSendCtl( 0x80 | y_addr ); //Set Vertical Address
_delay_us(49);
lcdSendCtl( 0x80 | x_addr ); //Set Horizontal Address
lcdSendCtl( 0x80 | x_addr ); //Set Horizontal Address
_delay_us(49);
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0); //HIGH RS and LOW RW will put the LCD to
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW); //Write data register mode
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0); //HIGH RS and LOW RW will put the LCD to
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW); //Write data register mode
bit_count = y & 0x07; //Count from 0 bis 7 -> 0=0, 1=1..7=7, 8=0, 9=1...
col_offset = 1 << bit_count; //Build a value for a AND operation with the vorrect bitposition
line_offset = ( y / 8 ) * 128; //On the ST7565 there are 8 lines with each 128 bytes width
for (coord_t x=0; x<16; x++) { //Walk through 16 bytes form left to right (128 Pixel)
byte_offset = line_offset + ( x * 8 ); //Calculate the position of the first byte im array
// adressing the bytes sequential and shift the bits at the correct position, afterwards a OR operation to get all bits in one byte
// the position of the LSB is the left-most position of the byte to the ST7920
PORTA_LCD_DAT = (((displayBuf[byte_offset] & col_offset) >> bit_count) << 7) | (((displayBuf[byte_offset + 1] & col_offset) >> bit_count) << 6) | (((displayBuf[byte_offset + 2] & col_offset) >> bit_count ) << 5) | (((displayBuf[byte_offset + 3] & col_offset) >> bit_count ) << 4) | (((displayBuf[byte_offset + 4] & col_offset) >> bit_count ) << 3) | (((displayBuf[byte_offset + 5] & col_offset) >> bit_count ) << 2) | (((displayBuf[byte_offset + 6] & col_offset) >> bit_count ) << 1) | (((displayBuf[byte_offset + 7] & col_offset) >> bit_count ) << 0);
p=displayBuf + line_offset + ( x * 8 ); //Calculate the position of the first byte im array
// adressing the bytes sequential and set the bits at the correct position merging them with an OR operation to get all bits in one byte
// the position of the LSB is the right-most position of the byte to the ST7920
result = ((*p++ & col_offset)!=0?0x80:0);
result|= ((*p++ & col_offset)!=0?0x40:0);
result|= ((*p++ & col_offset)!=0?0x20:0);
result|= ((*p++ & col_offset)!=0?0x10:0);
result|= ((*p++ & col_offset)!=0?0x08:0);
result|= ((*p++ & col_offset)!=0?0x04:0);
result|= ((*p++ & col_offset) !=0?0x02:0);
result|= ((*p++ & col_offset)!=0?0x01:0);
PORTA_LCD_DAT = result;
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_E);
_delay_us(8);
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_E);
@@ -216,4 +272,8 @@ void lcdRefresh()
}
#endif
LCD_UNLOCK();
#if defined(LCD_ST7920)
return state;
#endif
}
@@ -0,0 +1,120 @@
/**
******************************************************************************
* @file usbd_desc.h
* @author MCD Application Team
* @version V1.1.0
* @date 19-March-2012
* @brief header file for the usbd_desc.c file
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_DESC_H
#define __USB_DESC_H
/* Includes ------------------------------------------------------------------*/
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_def.h"
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @{
*/
/** @defgroup USB_DESC
* @brief general defines for the usb device library file
* @{
*/
/** @defgroup USB_DESC_Exported_Defines
* @{
*/
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
#define USB_STRING_DESCRIPTOR_TYPE 0x03
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
#define USB_SIZ_DEVICE_DESC 18
#define USB_SIZ_STRING_LANGID 4
/**
* @}
*/
/** @defgroup USBD_DESC_Exported_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup USBD_DESC_Exported_Macros
* @{
*/
/**
* @}
*/
/** @defgroup USBD_DESC_Exported_Variables
* @{
*/
extern const uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC];
extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ];
extern const uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC];
extern const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC];
extern const uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID];
extern const USBD_DEVICE USR_desc;
/**
* @}
*/
/** @defgroup USBD_DESC_Exported_FunctionsPrototype
* @{
*/
uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length);
uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length);
uint8_t * USBD_USR_ManufacturerStrDescriptor ( uint8_t speed , uint16_t *length);
uint8_t * USBD_USR_ProductStrDescriptor ( uint8_t speed , uint16_t *length);
uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length);
uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length);
uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length);
#ifdef USB_SUPPORT_USER_STRING_DESC
uint8_t * USBD_USR_USRStringDesc (uint8_t speed, uint8_t idx , uint16_t *length);
#endif /* USB_SUPPORT_USER_STRING_DESC */
/**
* @}
*/
#endif /* __USBD_DESC_H */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+1 -2
View File
@@ -4,6 +4,5 @@ MEGA2560 board
DIY radio wih :
- Arduino MEGA2560 or compatible
- Gruvin9x features (soft-off, SD-Card, RTC, haptic, voice, rotary encoders)
- LCD 128x64 Artronic (ST7565R) or Zolen (ST7565P)
- Aurora9 or T9X gimballs
- LCD 128x64 8 bits parallel mode
- home made case
@@ -42,13 +42,17 @@ inline void boardInit()
{
// Set up I/O port data directions and initial states (unused pin setting : input, pull-up on)
DDRA = 0b11111111; PORTA = 0b00000000; // LCD data
DDRB = 0b01110111; PORTB = 0b00101111; // 7:PPM_IN 6:PPM_OUT, 5:SimCTRL, 4:Buzzer, SDCARD[3:MISO 2:MOSI 1:SCK 0:CS]
DDRB = 0b01110111; PORTB = 0b10101111; // 7:N/A 6:PPM_OUT, 5:SimCTRL, 4:Buzzer, SDCARD[3:MISO 2:MOSI 1:SCK 0:CS]
DDRC = 0b11111100; PORTC = 0b00000011; // 7-3:LCD, 2:BackLight, 1:ID2_SW, 0:ID1_SW
DDRD = 0b00000000; PORTD = 0b11111100; // 7:AilDR_SW, 6:N/A, 5:N/A, 4:N/A, 3:RENC2_B, 2:RENC2_A, 1:I2C_SDA, 0:I2C_SCL
DDRE = 0b00000010; PORTE = 0b11111100; // 7:N/A, 6:N/A, 5:RENC1_B, 4:RENC1_A, 3:N/A, 2:N/A, 1:TELEM_TX, 0:TELEM_RX
DDRE = 0b00000010; PORTE = 0b01111100; // 7:PPM_IN, 6:N/A, 5:RENC1_B, 4:RENC1_A, 3:N/A, 2:N/A, 1:TELEM_TX, 0:TELEM_RX
DDRF = 0b00000000; PORTF = 0b11111111; // 7-0:Trim switch inputs
DDRG = 0b00000000; PORTG = 0b11111111; // 7:N/A, 6:N/A, 5:N/A, 4:N/A, 3:N/A, 2:TCut_SW, 1:Gear_SW, 0: RudDr_SW
#if defined(PCBMEGA2560) && defined(DEBUG)
DDRH = 0b01011000; PORTH = 0b11110110; // 7:N/A, 6:RF_Activated, 5:DSC_Activated, 4:Hold_Power, 3:Speaker, 2:N/A, 1:N/A, 0:Haptic
#else
DDRH = 0b00011000; PORTH = 0b11110110; // 7:N/A, 6:RF_Activated, 5:DSC_Activated, 4:Hold_Power, 3:Speaker, 2:N/A, 1:N/A, 0:Haptic
#endif
DDRJ = 0b00000000; PORTJ = 0b11111111; // 7:N/A, 6:N/A, 5:N/A, 4:N/A, 3:N/A, 2:N/A, 1:RENC2_push, 0:RENC1_push
DDRK = 0b00000000; PORTK = 0b00000000; // Analogic input (no pull-ups)
DDRL = 0b00000000; PORTL = 0b11111111; // 7:TRN_SW 6:EleDR_SW, 5:ESC, 4:MENU 3:Keyb_Left, 2:Keyb_Right, 1:Keyb_Up, 0:Keyb_Down
+1 -1
View File
@@ -111,7 +111,7 @@ void sdPoll10ms(void);
# define INP_L_Trainer 7
// Servitudes driver
# define INP_B_PPM_IN 7
//#define INP_E_PPM_IN 7 //reserved PPM_IN
# define OUT_B_PPM 6
# define OUT_B_SIM_CTL 5
# define OUT_B_BUZZER 4
+114 -117
View File
@@ -51,7 +51,7 @@
// LCD_D6 PC2
// LCD_D7 PC1
#define LCD_DATA 0x000000FFL
#define LCD_DATA 0x000000FFL
#if !defined(REVA)
#define LCD_A0 0x00000080L
#else
@@ -66,111 +66,105 @@
#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
} ;
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)
{
register Pio *pioptr ;
register 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] ;
pioptr = PIOC;
pioptr->PIO_CODR = LCD_CS1; // Select LCD
pioptr->PIO_CODR = LCD_A0; // Control
pioptr->PIO_CODR = LCD_RnW; // Write
pioptr->PIO_ODSR = Lcd_lookup[val];
#else
pioptr = PIOC ;
pioptr = PIOC;
#if !defined(REVX)
pioptr->PIO_CODR = LCD_CS1 ; // Select LCD
pioptr->PIO_CODR = LCD_CS1; // Select LCD
#endif
PIOA->PIO_CODR = LCD_A0 ;
PIOA->PIO_CODR = LCD_A0;
#if !defined(REVX)
pioptr->PIO_CODR = LCD_RnW ; // Write
pioptr->PIO_CODR = LCD_RnW; // Write
#endif
pioptr->PIO_ODSR = val ;
pioptr->PIO_ODSR = val;
#endif
pioptr->PIO_SODR = LCD_E ; // Start E pulse
pioptr->PIO_SODR = LCD_E; // Start E pulse
// Need a delay here (250nS)
TC0->TC_CHANNEL[0].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
while ( TC0->TC_CHANNEL[0].TC_CV < 9 ) // Value depends on MCK/2 (used 18MHz)
{
// Wait
}
pioptr->PIO_CODR = LCD_E ; // End E pulse
pioptr->PIO_CODR = LCD_E; // End E pulse
#if defined(REVA)
pioptr->PIO_SODR = LCD_A0 ; // Data
pioptr->PIO_SODR = LCD_A0; // Data
#else
PIOA->PIO_SODR = LCD_A0 ; // Data
PIOA->PIO_SODR = LCD_A0; // Data
#endif
#if !defined(REVX)
pioptr->PIO_SODR = LCD_CS1 ; // Deselect LCD
pioptr->PIO_SODR = LCD_CS1; // Deselect LCD
#endif
}
void lcdInit()
{
register Pio *pioptr ;
register Pio *pioptr;
// /home/thus/txt/datasheets/lcd/KS0713.pdf
// ~/txt/flieger/ST7565RV17.pdf from http://www.glyn.de/content.asp?wdid=132&sid=
// read the inputs, and lock the LCD lines
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
lcdLock = 1 ;
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
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)
pioptr->PIO_PER = PIO_PC27 | PIO_PC12 | 0xFF ;
pioptr->PIO_CODR = LCD_E ;
pioptr->PIO_CODR = LCD_RnW | LCD_CS1 ; // No longer needed, used elsewhere
#else
pioptr->PIO_PER = PIO_PC27 | PIO_PC26 | PIO_PC13 | PIO_PC12 | 0xFF ;
pioptr->PIO_CODR = LCD_E | LCD_RnW | LCD_CS1 ;
#endif
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
configure_pins( LCD_A0, PIN_ENABLE | PIN_LOW | PIN_OUTPUT | PIN_PORTA | PIN_NO_PULLUP );
pioptr = PIOC;
#if defined(REVX)
pioptr->PIO_PER = PIO_PC27 | PIO_PC12 | 0xFF;
pioptr->PIO_CODR = LCD_E;
pioptr->PIO_CODR = LCD_RnW | LCD_CS1; // No longer needed, used elsewhere
#else
pioptr->PIO_PER = PIO_PC27 | PIO_PC26 | PIO_PC13 | PIO_PC12 | 0xFF;
pioptr->PIO_CODR = LCD_E | LCD_RnW | LCD_CS1;
#endif
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
pioptr->PIO_CODR = LCD_RES ; // Reset LCD
TC0->TC_CHANNEL[0].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
while ( TC0->TC_CHANNEL[0].TC_CV < 200 ) // > 10us, Value depends on MCK/2 (used 18MHz)
{
// Wait
}
pioptr->PIO_SODR = LCD_RES ; // Remove LCD reset
TC0->TC_CHANNEL[0].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
while ( TC0->TC_CHANNEL[0].TC_CV < 27000 ) // 1500us, Value depends on MCK/2 (used 18MHz)
{
// Wait
}
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
pioptr->PIO_CODR = LCD_RES; // Reset LCD
while ( TC0->TC_CHANNEL[0].TC_CV < 500 ) ; // > 10us, Value depends on MCK/2 (used 18MHz)
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
pioptr->PIO_SODR = LCD_RES; // Remove LCD reset
while ( TC0->TC_CHANNEL[0].TC_CV < 27000 ) ; // 1500us, Value depends on MCK/2 (used 18MHz)
lcdSendCtl(0xe2); //Initialize the internal functions
lcdSendCtl(0xae); //DON = 0: display OFF
lcdSendCtl(0xa1); //ADC = 1: reverse direction(SEG132->SEG1)
@@ -182,50 +176,63 @@ void lcdInit()
lcdSendCtl(0x25); //Select int resistance ratio R2 R1 R0 =5
lcdSendCtl(0x81); //Set reference voltage Mode
lcdSendCtl(0x22); // 24 SV5 SV4 SV3 SV2 SV1 SV0 = 0x18
lcdSendCtl(0xAF); //DON = 1: display ON
// g_eeGeneral.contrast = 0x22;
#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
#if defined(REVX)
// 200mS delay (only if not wdt reset)
if ( ( ( ResetReason & RSTC_SR_RSTTYP ) != (2 << 8) ) && !unexpectedShutdown ) {
for (uint32_t j = 0; j < 100; j += 1 ) {
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
while ( TC0->TC_CHANNEL[0].TC_CV < 36000 ) {
// Value depends on MCK/2 (used 18MHz) give 2mS delay
wdt_reset(); // Wait
}
}
}
#endif
lcdLock = 0 ;
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;
}
void lcdSetRefVolt(uint8_t val)
{
register Pio *pioptr ;
pioptr = PIOC ;
register Pio *pioptr;
pioptr = PIOC;
// read the inputs, and lock the LCD lines
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
lcdLock = 1 ;
lcdLock = 1;
pioptr->PIO_OER = 0x0C00B0FFL ; // Set bits 27,26,15,13,12,7-0 output
pioptr->PIO_OER = 0x0C00B0FFL; // Set bits 27,26,15,13,12,7-0 output
lcdSendCtl(0x81);
if ( val == 0 )
{
val = 0x22 ;
val = 0x22;
}
lcdSendCtl(val);
#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_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 = 0x0000003AL ; // Set bits 1, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups
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 = lcdInputs; // Drive D0 low
lcdLock = 0 ;
pioptr->PIO_ODSR = 0; // Drive D0 low
lcdLock = 0;
}
void lcdRefresh()
@@ -251,7 +258,7 @@ void lcdRefresh()
// read the inputs, and lock the LCD lines
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
lcdLock = 1 ;
lcdLock = 1;
pioptr = PIOC;
#if defined(REVA)
@@ -264,13 +271,13 @@ void lcdRefresh()
lcdSendCtl(0x10); //column addr 0
lcdSendCtl(y | 0xB0); //page addr y
#if !defined(REVX)
pioptr->PIO_CODR = LCD_CS1; // Select LCD
#endif
#if !defined(REVX)
pioptr->PIO_CODR = LCD_CS1; // Select LCD
#endif
PIOA->PIO_SODR = LCD_A0; // Data
#if !defined(REVX)
pioptr->PIO_CODR = LCD_RnW; // Write
#endif
#if !defined(REVX)
pioptr->PIO_CODR = LCD_RnW; // Write
#endif
#if defined(REVA)
x = lookup[*p];
@@ -278,16 +285,6 @@ void lcdRefresh()
x = *p;
#endif
for (z = 0; z < LCD_W; z += 1) {
// The following 7 lines replaces by a lookup table
// x = __RBIT( *p++ ) ;
// x >>= 23 ;
// if ( x & 0x00000100 )
// {
// x |= 1 ;
// }
// pioptr->PIO_ODSR = x ;
pioptr->PIO_ODSR = x;
pioptr->PIO_SODR = ebit; // Start E pulse
// Need a delay here (250nS)
@@ -297,27 +294,27 @@ void lcdRefresh()
#else
x = *p;
#endif
// TC0->TC_CHANNEL[0].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
// 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)
// {
// // Wait
// }
pioptr->PIO_CODR = ebit; // End E pulse
}
#if !defined(REVX)
pioptr->PIO_SODR = LCD_CS1; // Deselect LCD
#endif
#if !defined(REVX)
pioptr->PIO_SODR = LCD_CS1; // Deselect LCD
#endif
}
pioptr->PIO_ODSR = 0xFF ; // Drive lines high
pioptr->PIO_ODSR = 0xFF; // Drive lines high
#if defined(REVA)
pioptr->PIO_PUER = 0x0000003CL ; // Set bits 2, 3, 4, 5 with pullups
pioptr->PIO_ODR = 0x0000003CL ; // Set bits 2, 3, 4, 5 input
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 = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input
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 = lcdInputs; // Drive D0 low
pioptr->PIO_ODSR = 0xFE; // Drive D0 low
lcdLock = 0;
}
+7 -1
View File
@@ -131,7 +131,11 @@ void boardInit()
RCC_APB1PeriphClockCmd(LCD_RCC_APB1Periph | BACKLIGHT_RCC_APB1Periph | INTERRUPT_5MS_APB1Periph | TIMER_2MHz_APB1Periph | I2C_RCC_APB1Periph | SD_RCC_APB1Periph | TRAINER_RCC_APB1Periph | TELEMETRY_RCC_APB1Periph | SERIAL_RCC_APB1Periph, ENABLE);
RCC_APB2PeriphClockCmd(BACKLIGHT_RCC_APB2Periph | ADC_RCC_APB2Periph | HAPTIC_RCC_APB2Periph | INTMODULE_RCC_APB2Periph | EXTMODULE_RCC_APB2Periph | HEARTBEAT_RCC_APB2Periph, ENABLE);
#if !defined(REV9E)
// some REV9E boards need that the pwrInit() is moved a little bit later
pwrInit();
#endif
keysInit();
adcInit();
delaysInit();
@@ -179,6 +183,7 @@ void boardInit()
else {
if (pwr_on != 1) {
pwr_on = 1;
pwrInit();
backlightInit();
haptic.play(15, 3, PLAY_NOW);
}
@@ -191,6 +196,7 @@ void boardInit()
}
}
else {
pwrInit();
backlightInit();
}
toplcdInit();
@@ -264,7 +270,7 @@ void checkTrainerSettings()
uint8_t requiredTrainerMode = g_model.trainerMode;
if (requiredTrainerMode != currentTrainerMode) {
switch (currentTrainerMode) {
case TRAINER_MODE_MASTER:
case TRAINER_MODE_MASTER_TRAINER_JACK:
stop_trainer_capture();
break;
case TRAINER_MODE_SLAVE:
@@ -143,7 +143,12 @@ void configure_pins( uint32_t pins, uint16_t config );
extern uint16_t sessionTimer;
#define SLAVE_MODE() (g_model.trainerMode == TRAINER_MODE_SLAVE)
#if defined(REV9E)
#define TRAINER_CONNECTED() (true)
#else
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_GPIO_DETECT, TRAINER_GPIO_PIN_DETECT) == Bit_RESET)
#endif
#ifdef __cplusplus
extern "C" {
+8 -4
View File
@@ -127,13 +127,15 @@ extern "C" void TIM3_IRQHandler()
if ( (TRAINER_TIMER->DIER & TIM_DIER_CC3IE ) && ( TRAINER_TIMER->SR & TIM_SR_CC3IF ) ) {
// capture mode on trainer jack
capture = TRAINER_TIMER->CCR3 ;
doCapture = true;
if (TRAINER_CONNECTED() && currentTrainerMode == TRAINER_MODE_MASTER_TRAINER_JACK)
doCapture = true;
}
if ( ( TRAINER_TIMER->DIER & TIM_DIER_CC2IE ) && ( TRAINER_TIMER->SR & TIM_SR_CC2IF ) ) {
// capture mode on heartbeat pin (external module)
capture = TRAINER_TIMER->CCR2 ;
doCapture = true ;
if (currentTrainerMode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE)
doCapture = true ;
}
if (doCapture) {
@@ -247,8 +249,10 @@ extern "C" void HEARTBEAT_USART_IRQHandler()
while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
data = HEARTBEAT_USART->DR;
if (!(status & USART_FLAG_ERRORS))
sbusFifo.push(data);
if (!(status & USART_FLAG_ERRORS)) {
if (currentTrainerMode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE)
sbusFifo.push(data);
}
status = HEARTBEAT_USART->SR;
}
File diff suppressed because it is too large Load Diff
+17 -2
View File
@@ -795,10 +795,12 @@ char *findTrueFileName(const char *path)
strcat(result, res->d_name);
TRACE("\tfound: %s", res->d_name);
fileMap.insert(filemap_t:: value_type(path, result));
simu::closedir(dir);
return result;
}
}
}
simu::closedir(dir);
}
#endif
}
@@ -840,10 +842,10 @@ FRESULT f_open (FIL * fil, const TCHAR *name, BYTE flag)
fil->fsize = tmp.st_size;
fil->fptr = 0;
}
fil->fs = (FATFS*)fopen(realPath, (flag & FA_WRITE) ? "wb+" : "rb+");
fil->fs = (FATFS*)fopen(realPath, (flag & FA_WRITE) ? ((flag & FA_CREATE_ALWAYS) ? "wb+" : "ab+") : "rb+");
fil->fptr = 0;
if (fil->fs) {
TRACE("f_open(%s) = %p", path, (FILE*)fil->fs);
TRACE("f_open(%s, %x) = %p", path, flag, (FILE*)fil->fs);
return FR_OK;
}
TRACE("f_open(%s) = error %d (%s)", path, errno, strerror(errno));
@@ -877,6 +879,19 @@ FRESULT f_lseek (FIL* fil, DWORD offset)
return FR_OK;
}
UINT f_size(FIL* fil)
{
if (fil && fil->fs) {
long curr = ftell((FILE*)fil->fs);
fseek((FILE*)fil->fs, 0, SEEK_END);
long size = ftell((FILE*)fil->fs);
fseek((FILE*)fil->fs, curr, SEEK_SET);
TRACE("f_size(%p) %u", fil->fs, size);
return size;
}
return 0;
}
FRESULT f_close (FIL * fil)
{
if (fil && fil->fs) {