Now the FW compiles on 9XR-PRO. Still fighting with the drivers on my Windows machine...
This commit is contained in:
+1
-1
@@ -694,7 +694,7 @@ TARGET = opentx
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO TARANIS))
|
||||
TTS_SRC = translations/tts_cz.cpp translations/tts_de.cpp translations/tts_en.cpp translations/tts_es.cpp translations/tts_fr.cpp translations/tts_it.cpp translations/tts_pt.cpp translations/tts_sk.cpp translations/tts_se.cpp
|
||||
TTS_SRC = translations/tts_cz.cpp translations/tts_de.cpp translations/tts_en.cpp translations/tts_es.cpp translations/tts_fr.cpp translations/tts_it.cpp translations/tts_pt.cpp translations/tts_sk.cpp translations/tts_se.cpp translations/tts_pl.cpp
|
||||
else
|
||||
STD_TTS_SRC = translations/tts_$(shell sh -c "echo $(TTS) | tr '[:upper:]' '[:lower:]'").cpp
|
||||
TTS_SRC = $(shell sh -c "if test -f $(STD_TTS_SRC); then echo $(STD_TTS_SRC); else echo translations/tts_en.cpp; fi")
|
||||
|
||||
@@ -4138,7 +4138,7 @@ void opentxClose()
|
||||
hapticOff();
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#if defined(CPUARM) && defined(FRSKY)
|
||||
if((g_model.frsky.mAhPersistent) && (g_model.frsky.storedMah != frskyData.hub.currentConsumption)) {
|
||||
g_model.frsky.storedMah = frskyData.hub.currentConsumption;
|
||||
eeDirty(EE_MODEL);
|
||||
|
||||
@@ -162,7 +162,7 @@ static const int8_t volumeScale[VOLUME_LEVEL_MAX+1] =
|
||||
|
||||
void setVolume(uint8_t volume)
|
||||
{
|
||||
coprocVolumeRequired = volumeScale[min<uint8_t>(volume, VOLUME_LEVEL_MAX)];
|
||||
volumeRequired = volumeScale[min<uint8_t>(volume, VOLUME_LEVEL_MAX)];
|
||||
__disable_irq() ;
|
||||
i2cCheck() ;
|
||||
__enable_irq() ;
|
||||
|
||||
@@ -223,7 +223,7 @@ void i2cCheck();
|
||||
void coprocInit();
|
||||
void coprocWriteData(uint8_t *data, uint32_t size);
|
||||
void coprocReadData(bool onlytemp=false);
|
||||
extern int8_t coprocVolumeRequired;
|
||||
extern int8_t volumeRequired;
|
||||
extern uint8_t Coproc_read;
|
||||
extern int8_t Coproc_valid;
|
||||
extern int8_t Coproc_temp;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "../../opentx.h"
|
||||
|
||||
int8_t coprocVolumeRequired ;
|
||||
int8_t volumeRequired ;
|
||||
uint8_t coprocReadDataPending ;
|
||||
uint8_t coprocWriteDataPending ;
|
||||
uint8_t CoProc_appgo_pending ;
|
||||
@@ -76,11 +76,11 @@ void i2cCheck()
|
||||
return ; // Busy
|
||||
}
|
||||
|
||||
if ( coprocVolumeRequired >= 0 ) { // Set volume to this value
|
||||
if ( volumeRequired >= 0 ) { // Set volume to this value
|
||||
TWI0->TWI_MMR = 0x002F0000 ; // Device 5E (>>1) and master is writing
|
||||
TwiOperation = TWI_WRITE_VOL ;
|
||||
TWI0->TWI_THR = coprocVolumeRequired ; // Send data
|
||||
coprocVolumeRequired = -1 ;
|
||||
TWI0->TWI_THR = volumeRequired ; // Send data
|
||||
volumeRequired = -1 ;
|
||||
TWI0->TWI_IER = TWI_IER_TXCOMP ;
|
||||
TWI0->TWI_CR = TWI_CR_STOP ; // Stop Tx
|
||||
}
|
||||
|
||||
@@ -40,11 +40,19 @@
|
||||
// TODO change this, not the right place
|
||||
#define TWI_NONE 0
|
||||
#define TWI_WRITE_VOL 2
|
||||
#define TWI_READ_COPROC 3
|
||||
#define TWI_WAIT_STOP 5
|
||||
#define TWI_WRITE_COPROC 6
|
||||
int8_t coprocVolumeRequired ;
|
||||
static uint8_t TwiOperation ;
|
||||
#define TWI_WAIT_COMP 7
|
||||
#define TWI_READ_RTC 8
|
||||
#define TWI_WRITE_RTC 9
|
||||
#define TWI_WAIT_RTCSTOP 10
|
||||
#define TWI_WRITE_MFP 11
|
||||
int8_t volumeRequired ;
|
||||
int8_t Rtc_read_pending;
|
||||
uint8_t Rtc_write_pending ;
|
||||
int8_t Rtc_valid ;
|
||||
uint8_t MFPsetting = 0 ;
|
||||
uint8_t CALsetting = 0 ;
|
||||
uint8_t *Twi_read_address ;
|
||||
uint8_t TwiOperation ;
|
||||
#define RTC_RX_BUXSIZE 10
|
||||
#define RTC_SIZE 7
|
||||
uint8_t Rtc_status[RTC_RX_BUXSIZE] ;
|
||||
@@ -53,6 +61,18 @@ uint32_t Rtc_write_count ;
|
||||
uint8_t RtcConfig[8] ; // For initial config and writing to RTC
|
||||
// 0x80, 0, 0, 0x08, 0, 0, 0, 0x80
|
||||
|
||||
static uint32_t fromBCD( uint8_t bcd_value )
|
||||
{
|
||||
return ( ( ( bcd_value & 0xF0 ) * 10 ) >> 4 ) + ( bcd_value & 0x0F ) ;
|
||||
}
|
||||
|
||||
static uint32_t toBCD( uint32_t value )
|
||||
{
|
||||
div_t qr ;
|
||||
qr = div( value, 10 ) ;
|
||||
return ( qr.quot << 4 ) + qr.rem ;
|
||||
}
|
||||
|
||||
// This is called from an interrupt routine, or
|
||||
// interrupts must be disabled while it is called
|
||||
// from elsewhere.
|
||||
@@ -62,68 +82,70 @@ void i2cCheck()
|
||||
return ; // Busy
|
||||
}
|
||||
|
||||
if ( coprocVolumeRequired >= 0 ) { // Set volume to this value
|
||||
TWI0->TWI_MMR = 0x002F0000 ; // Device 5E (>>1) and master is writing
|
||||
TwiOperation = TWI_WRITE_VOL ;
|
||||
TWI0->TWI_THR = coprocVolumeRequired ; // Send data
|
||||
Volume_required = -1 ;
|
||||
TWI0->TWI_IER = TWI_IER_TXCOMP ;
|
||||
TWI0->TWI_CR = TWI_CR_STOP ; // Stop Tx
|
||||
if ( volumeRequired >= 0 ) // Set volume to this value
|
||||
{
|
||||
TWI0->TWI_MMR = 0x002F0000 ; // Device 5E (>>1) and master is writing
|
||||
TwiOperation = TWI_WRITE_VOL ;
|
||||
TWI0->TWI_THR = volumeRequired ; // Send data
|
||||
volumeRequired = -1 ;
|
||||
TWI0->TWI_IER = TWI_IER_TXCOMP ;
|
||||
TWI0->TWI_CR = TWI_CR_STOP ; // Stop Tx
|
||||
}
|
||||
else if ( coprocReadDataPending ) {
|
||||
Rtc_valid = 0 ;
|
||||
coprocReadDataPending = 0 ;
|
||||
TWI0->TWI_MMR = 0x006F1100 ; // Device 6F and master is reading, 1 byte addr
|
||||
TWI0->TWI_IADR = 0 ;
|
||||
TwiOperation = TWI_READ_RTC ;
|
||||
else if ( Rtc_read_pending )
|
||||
{
|
||||
Rtc_valid = 0 ;
|
||||
Rtc_read_pending = 0 ;
|
||||
TWI0->TWI_MMR = 0x006F1100 ; // Device 6F and master is reading, 1 byte addr
|
||||
TWI0->TWI_IADR = 0 ;
|
||||
TwiOperation = TWI_READ_RTC ;
|
||||
#ifndef SIMU
|
||||
TWI0->TWI_RPR = (uint32_t)&Rtc_status[0] ;
|
||||
TWI0->TWI_RPR = (uint32_t)&Rtc_status[0] ;
|
||||
#endif
|
||||
TWI0->TWI_RCR = RTC_SIZE - 1 ;
|
||||
if ( TWI0->TWI_SR & TWI_SR_RXRDY )
|
||||
{
|
||||
(void) TWI0->TWI_RHR ;
|
||||
}
|
||||
TWI0->TWI_RCR = RTC_SIZE - 1 ;
|
||||
if ( TWI0->TWI_SR & TWI_SR_RXRDY )
|
||||
{
|
||||
(void) TWI0->TWI_RHR ;
|
||||
}
|
||||
|
||||
if ( ( TWI0->TWI_SR & TWI_SR_TXCOMP ) == 0 )
|
||||
{
|
||||
Debug_I2C_event += 1 ;
|
||||
}
|
||||
|
||||
TWI0->TWI_PTCR = TWI_PTCR_RXTEN ; // Start transfers
|
||||
TWI0->TWI_CR = TWI_CR_START ; // Start Rx
|
||||
TWI0->TWI_IER = TWI_IER_RXBUFF | TWI_IER_TXCOMP ;
|
||||
TWI0->TWI_PTCR = TWI_PTCR_RXTEN ; // Start transfers
|
||||
TWI0->TWI_CR = TWI_CR_START ; // Start Rx
|
||||
TWI0->TWI_IER = TWI_IER_RXBUFF | TWI_IER_TXCOMP ;
|
||||
}
|
||||
else if ( coprocWriteDataPending ) {
|
||||
if ( coprocWriteDataPending & (2|4) ) {
|
||||
TWI0->TWI_MMR = 0x006F0100 ; // Device 6F and master is writing, 1 byte addr
|
||||
TwiOperation = TWI_WRITE_MFP ;
|
||||
if ( Rtc_write_pending & 2 ) {
|
||||
TWI0->TWI_IADR = 7 ;
|
||||
TWI0->TWI_THR = MFPsetting ; // Send data
|
||||
Rtc_write_pending &= ~2 ;
|
||||
}
|
||||
else {
|
||||
TWI0->TWI_IADR = 8 ;
|
||||
TWI0->TWI_THR = CALsetting ; // Send data
|
||||
coprocWriteDataPending &= ~4 ;
|
||||
}
|
||||
TWI0->TWI_IER = TWI_IER_TXCOMP ;
|
||||
TWI0->TWI_CR = TWI_CR_STOP ; // Stop Tx
|
||||
}
|
||||
else {
|
||||
coprocWriteDataPending &= ~1 ;
|
||||
TWI0->TWI_MMR = 0x006F0100 ; // Device 6F and master is writing, 1 byte addr
|
||||
TWI0->TWI_IADR = 0 ;
|
||||
TwiOperation = TWI_WRITE_RTC ;
|
||||
else if ( Rtc_write_pending )
|
||||
{
|
||||
if ( Rtc_write_pending & (2|4) )
|
||||
{
|
||||
TWI0->TWI_MMR = 0x006F0100 ; // Device 6F and master is writing, 1 byte addr
|
||||
TwiOperation = TWI_WRITE_MFP ;
|
||||
if ( Rtc_write_pending & 2 )
|
||||
{
|
||||
TWI0->TWI_IADR = 7 ;
|
||||
TWI0->TWI_THR = MFPsetting ; // Send data
|
||||
Rtc_write_pending &= ~2 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
TWI0->TWI_IADR = 8 ;
|
||||
TWI0->TWI_THR = CALsetting ; // Send data
|
||||
Rtc_write_pending &= ~4 ;
|
||||
}
|
||||
TWI0->TWI_IER = TWI_IER_TXCOMP ;
|
||||
TWI0->TWI_CR = TWI_CR_STOP ; // Stop Tx
|
||||
}
|
||||
else
|
||||
{
|
||||
Rtc_write_pending &= ~1 ;
|
||||
TWI0->TWI_MMR = 0x006F0100 ; // Device 6F and master is writing, 1 byte addr
|
||||
TWI0->TWI_IADR = 0 ;
|
||||
TwiOperation = TWI_WRITE_RTC ;
|
||||
#ifndef SIMU
|
||||
TWI0->TWI_TPR = (uint32_t)Rtc_write_ptr+1 ;
|
||||
TWI0->TWI_TPR = (uint32_t)Rtc_write_ptr+1 ;
|
||||
#endif
|
||||
TWI0->TWI_TCR = Rtc_write_count-1 ;
|
||||
TWI0->TWI_THR = *Rtc_write_ptr ; // First byte
|
||||
TWI0->TWI_PTCR = TWI_PTCR_TXTEN ; // Start data transfer
|
||||
TWI0->TWI_IER = TWI_IER_TXBUFE | TWI_IER_TXCOMP ;
|
||||
}
|
||||
TWI0->TWI_TCR = Rtc_write_count-1 ;
|
||||
TWI0->TWI_THR = *Rtc_write_ptr ; // First byte
|
||||
TWI0->TWI_PTCR = TWI_PTCR_TXTEN ; // Start data transfer
|
||||
TWI0->TWI_IER = TWI_IER_TXBUFE | TWI_IER_TXCOMP ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,14 +210,15 @@ extern "C" void TWI0_IRQHandler()
|
||||
{
|
||||
Rtc_valid = 1 ;
|
||||
// Set the date and time
|
||||
t_time *p = &Time ;
|
||||
struct gtm utm;
|
||||
|
||||
p->second = fromBCD( Rtc_status[0] & 0x7F ) ;
|
||||
p->minute = fromBCD( Rtc_status[1] & 0x7F ) ;
|
||||
p->hour = fromBCD( Rtc_status[2] & 0x3F ) ;
|
||||
p->date = fromBCD( Rtc_status[4] & 0x3F ) ;
|
||||
p->month = fromBCD( Rtc_status[5] & 0x1F ) ;
|
||||
p->year = fromBCD( Rtc_status[6] ) + 2000 ;
|
||||
utm.tm_sec = fromBCD( Rtc_status[0] & 0x7F ) ;
|
||||
utm.tm_min = fromBCD( Rtc_status[1] & 0x7F ) ;
|
||||
utm.tm_hour = fromBCD( Rtc_status[2] & 0x3F ) ;
|
||||
utm.tm_mday = fromBCD( Rtc_status[4] & 0x3F ) ;
|
||||
utm.tm_mon = fromBCD( Rtc_status[5] & 0x1F ) ;
|
||||
utm.tm_year = fromBCD( Rtc_status[6] ) + 2000 ;
|
||||
g_rtcTime = gmktime(&utm);
|
||||
|
||||
TWI0->TWI_PTCR = TWI_PTCR_RXTDIS ; // Stop transfers
|
||||
if ( status & TWI_SR_RXRDY )
|
||||
@@ -206,18 +229,9 @@ extern "C" void TWI0_IRQHandler()
|
||||
|
||||
if ( status & TWI_SR_NACK )
|
||||
{
|
||||
Debug_I2C_event += 0x100 ;
|
||||
TWI0->TWI_CR = TWI_CR_STOP ; // Stop Tx
|
||||
}
|
||||
|
||||
if ( status & TWI_SR_RXBUFF )
|
||||
{
|
||||
if ( TWI0->TWI_IMR & TWI_IMR_RXBUFF )
|
||||
{
|
||||
Debug_I2C_event += 0x1000000 ;
|
||||
}
|
||||
}
|
||||
|
||||
TWI0->TWI_IDR = TWI_IDR_TXCOMP | TWI_IDR_TXBUFE | TWI_IDR_RXBUFF ;
|
||||
TWI0->TWI_PTCR = TWI_PTCR_TXTDIS | TWI_PTCR_RXTDIS ; // Stop transfers
|
||||
if ( ( status & TWI_SR_TXCOMP ) == 0 )
|
||||
@@ -253,7 +267,7 @@ void rtcSetTime(struct gtm * t)
|
||||
I2CTime.Time[5] = (uint8_t) (t->tm_year+1900);
|
||||
I2CTime.Time[6] = (t->tm_year+1900) >> 8;
|
||||
#if defined(REVX)
|
||||
writeRTC( (uint8_t *) &I2CTime.Time[0], 8 ) ;
|
||||
writeRTC((uint8_t *)&I2CTime.Time[0]) ;
|
||||
#else
|
||||
coprocWriteData((uint8_t *) &I2CTime, 8);
|
||||
#endif
|
||||
@@ -261,5 +275,5 @@ void rtcSetTime(struct gtm * t)
|
||||
|
||||
void rtcInit()
|
||||
{
|
||||
coprocReadData();
|
||||
// TODO ? coprocReadData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user