Better coprocessor temperature support
This commit is contained in:
@@ -1035,6 +1035,8 @@ void read_9_adc()
|
||||
#endif
|
||||
|
||||
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) {
|
||||
maxTemperature = temperature;
|
||||
}
|
||||
|
||||
@@ -165,6 +165,13 @@ void per10ms()
|
||||
/* Update global Date/Time every 100 per10ms cycles */
|
||||
if (++g_ms100 == 100) {
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -236,6 +236,7 @@ uint8_t Volume_read ;
|
||||
uint8_t Coproc_read ;
|
||||
int8_t Coproc_temp ;
|
||||
int8_t Coproc_valid ;
|
||||
bool get_onlytemp;
|
||||
static uint8_t *Twi_read_address ;
|
||||
static uint8_t TwiOperation ;
|
||||
|
||||
@@ -357,8 +358,13 @@ void read_volume()
|
||||
__enable_irq() ;
|
||||
}
|
||||
|
||||
void read_coprocessor()
|
||||
void read_coprocessor(bool onlytemp)
|
||||
{
|
||||
if (onlytemp) {
|
||||
get_onlytemp=true;
|
||||
} else {
|
||||
get_onlytemp=false;
|
||||
}
|
||||
CoProc_read_pending = 1 ;
|
||||
__disable_irq() ;
|
||||
i2c_check_for_request() ;
|
||||
@@ -422,14 +428,16 @@ extern "C" void TWI0_IRQHandler()
|
||||
// Got data from tiny app
|
||||
// Set the date and time
|
||||
struct gtm utm;
|
||||
utm.tm_sec = Co_proc_status[1] ;
|
||||
utm.tm_min = Co_proc_status[2] ;
|
||||
utm.tm_hour = Co_proc_status[3] ;
|
||||
utm.tm_mday = Co_proc_status[4] ;
|
||||
utm.tm_mon = Co_proc_status[5] - 1;
|
||||
utm.tm_year = (Co_proc_status[6] + ( Co_proc_status[7] << 8 )) - 1900;
|
||||
if (!get_onlytemp) {
|
||||
utm.tm_sec = Co_proc_status[1] ;
|
||||
utm.tm_min = Co_proc_status[2] ;
|
||||
utm.tm_hour = Co_proc_status[3] ;
|
||||
utm.tm_mday = Co_proc_status[4] ;
|
||||
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];
|
||||
g_rtcTime = gmktime(&utm);
|
||||
}
|
||||
TWI0->TWI_PTCR = TWI_PTCR_RXTDIS ; // Stop transfers
|
||||
if ( TWI0->TWI_SR & TWI_SR_RXRDY ) {
|
||||
|
||||
@@ -46,7 +46,7 @@ extern void start_timer1( void ) ;
|
||||
extern void initDac( void ) ;
|
||||
extern void end_sound( void ) ;
|
||||
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 int8_t Coproc_valid ;
|
||||
extern int8_t Coproc_temp ;
|
||||
|
||||
Reference in New Issue
Block a user