1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 00:35:18 +03:00

Better coprocessor temperature support

This commit is contained in:
romolo.manfredini@gmail.com 2012-10-03 21:05:56 +00:00
parent b4a9d62b22
commit fa97e9366d
4 changed files with 26 additions and 9 deletions

View file

@ -1035,6 +1035,8 @@ void read_9_adc()
#endif #endif
temperature = (((int32_t)temperature * 7) + ((((int32_t)ADC->ADC_CDR15 - 838) * 621) >> 11)) >> 3; // Filter it temperature = (((int32_t)temperature * 7) + ((((int32_t)ADC->ADC_CDR15 - 838) * 621) >> 11)) >> 3; // Filter it
if (get_tmr10ms()<100)
return;
if (temperature < 200 && temperature > maxTemperature) { if (temperature < 200 && temperature > maxTemperature) {
maxTemperature = temperature; maxTemperature = temperature;
} }

View file

@ -165,6 +165,13 @@ void per10ms()
/* Update global Date/Time every 100 per10ms cycles */ /* Update global Date/Time every 100 per10ms cycles */
if (++g_ms100 == 100) { if (++g_ms100 == 100) {
g_rtcTime++; // inc global unix timestamp one second g_rtcTime++; // inc global unix timestamp one second
#if defined (PCBSKY9X)
if (g_rtcTime < 120) {
rtc_init();
} else {
read_coprocessor(true);
}
#endif
g_ms100 = 0; g_ms100 = 0;
} }
#endif #endif

View file

@ -236,6 +236,7 @@ uint8_t Volume_read ;
uint8_t Coproc_read ; uint8_t Coproc_read ;
int8_t Coproc_temp ; int8_t Coproc_temp ;
int8_t Coproc_valid ; int8_t Coproc_valid ;
bool get_onlytemp;
static uint8_t *Twi_read_address ; static uint8_t *Twi_read_address ;
static uint8_t TwiOperation ; static uint8_t TwiOperation ;
@ -357,8 +358,13 @@ void read_volume()
__enable_irq() ; __enable_irq() ;
} }
void read_coprocessor() void read_coprocessor(bool onlytemp)
{ {
if (onlytemp) {
get_onlytemp=true;
} else {
get_onlytemp=false;
}
CoProc_read_pending = 1 ; CoProc_read_pending = 1 ;
__disable_irq() ; __disable_irq() ;
i2c_check_for_request() ; i2c_check_for_request() ;
@ -422,14 +428,16 @@ extern "C" void TWI0_IRQHandler()
// Got data from tiny app // Got data from tiny app
// Set the date and time // Set the date and time
struct gtm utm; struct gtm utm;
utm.tm_sec = Co_proc_status[1] ; if (!get_onlytemp) {
utm.tm_min = Co_proc_status[2] ; utm.tm_sec = Co_proc_status[1] ;
utm.tm_hour = Co_proc_status[3] ; utm.tm_min = Co_proc_status[2] ;
utm.tm_mday = Co_proc_status[4] ; utm.tm_hour = Co_proc_status[3] ;
utm.tm_mon = Co_proc_status[5] - 1; utm.tm_mday = Co_proc_status[4] ;
utm.tm_year = (Co_proc_status[6] + ( Co_proc_status[7] << 8 )) - 1900; utm.tm_mon = Co_proc_status[5] - 1;
utm.tm_year = (Co_proc_status[6] + ( Co_proc_status[7] << 8 )) - 1900;
g_rtcTime = gmktime(&utm);
}
Coproc_temp = Co_proc_status[8]; Coproc_temp = Co_proc_status[8];
g_rtcTime = gmktime(&utm);
} }
TWI0->TWI_PTCR = TWI_PTCR_RXTDIS ; // Stop transfers TWI0->TWI_PTCR = TWI_PTCR_RXTDIS ; // Stop transfers
if ( TWI0->TWI_SR & TWI_SR_RXRDY ) { if ( TWI0->TWI_SR & TWI_SR_RXRDY ) {

View file

@ -46,7 +46,7 @@ extern void start_timer1( void ) ;
extern void initDac( void ) ; extern void initDac( void ) ;
extern void end_sound( void ) ; extern void end_sound( void ) ;
extern void write_coprocessor( uint8_t *ptr, uint32_t count ) ; extern void write_coprocessor( uint8_t *ptr, uint32_t count ) ;
extern void read_coprocessor( void ) ; extern void read_coprocessor( bool onlytemp=false ) ;
extern uint8_t Coproc_read ; extern uint8_t Coproc_read ;
extern int8_t Coproc_valid ; extern int8_t Coproc_valid ;
extern int8_t Coproc_temp ; extern int8_t Coproc_temp ;