bigfuxes: unwanted RTC initialization each start, bug in PT reference resistor index.... specific powersave changes, not enabling vbat_c from pwr_save, it will be handled by max31865 driver

tatry_variant
Mateusz Lubecki 2022-12-29 19:08:19 +01:00
rodzic 55e5d36621
commit 2f2cb1b11d
5 zmienionych plików z 32 dodań i 18 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.openocd.launchConfigurationType"> <launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.openocd.launchConfigurationType">
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.PERIPHERALS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;peripherals&gt;&#10; &lt;peripheral name=&quot;GPIOA&quot;/&gt;&#10; &lt;peripheral name=&quot;GPIOB&quot;/&gt;&#10;&lt;/peripherals&gt;&#10;"/> <stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.PERIPHERALS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;peripherals&gt;&#10; &lt;peripheral name=&quot;GPIOA&quot;/&gt;&#10; &lt;peripheral name=&quot;GPIOB&quot;/&gt;&#10; &lt;peripheral name=&quot;RTC&quot;/&gt;&#10;&lt;/peripherals&gt;&#10;"/>
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doContinue" value="true"/> <booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doContinue" value="true"/>
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/> <booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/>
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/> <booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/>

Wyświetl plik

@ -299,7 +299,7 @@ int pwr_save_switch_mode_to_c0(void) {
} }
// turn ON +5V_S // turn ON +5V_S
io___cntrl_vbat_s_enable(); //io___cntrl_vbat_s_enable(); //TODO: Tatry specific!!!
// turn ON +5V_R and VBATT_SW_R // turn ON +5V_R and VBATT_SW_R
io___cntrl_vbat_r_enable(); io___cntrl_vbat_r_enable();
@ -334,7 +334,7 @@ int pwr_save_switch_mode_to_c1(void) {
} }
// turn ON +5V_S (and internal VHF radio module in HW-RevB) // turn ON +5V_S (and internal VHF radio module in HW-RevB)
io___cntrl_vbat_s_enable(); //io___cntrl_vbat_s_enable(); // TODO: tatry specific!!!
// turn ON +5V_R and VBATT_SW_R // turn ON +5V_R and VBATT_SW_R
io___cntrl_vbat_r_enable(); io___cntrl_vbat_r_enable();
@ -435,7 +435,7 @@ int pwr_save_switch_mode_to_m4(void) {
} }
// turn ON +5V_S (and internal VHF radio module in HW-RevB) // turn ON +5V_S (and internal VHF radio module in HW-RevB)
io___cntrl_vbat_s_enable(); //io___cntrl_vbat_s_enable(); // TODO: tatry specific!!
// turn OFF +5V_R and VBATT_SW_R // turn OFF +5V_R and VBATT_SW_R
io___cntrl_vbat_r_disable(); io___cntrl_vbat_r_disable();

Wyświetl plik

@ -30,7 +30,7 @@ extern uint8_t max31865_merasurements_error_counter;
extern int_average_t max31865_average; extern int_average_t max31865_average;
extern uint8_t max31865_ok; extern uint8_t max31865_ok;
void max31865_init(uint8_t rdt_type, uint8_t reference_resistor); void max31865_init(uint8_t rdt_type, uint8_t reference_resistor_index);
void max31865_init_average(void); void max31865_init_average(void);
void max31865_pool(void); void max31865_pool(void);
int32_t max31865_get_pt100_result(); int32_t max31865_get_pt100_result();

Wyświetl plik

@ -457,10 +457,10 @@ void system_clock_start_rtc_l4(void) {
} }
// set date // set date
RTC->DR = 0x00229110; RTC->DR = 0x00229229;
// set time // set time
RTC->TR = 0x00191311; RTC->TR = 0x00170001; // UTC
// exit RTC set mode // exit RTC set mode
RTC->ISR &= (0xFFFFFFFF ^ RTC_ISR_INIT); RTC->ISR &= (0xFFFFFFFF ^ RTC_ISR_INIT);
@ -529,11 +529,11 @@ int system_clock_configure_rtc_l4(void) {
break; break;
} }
} }
}
if (SystemRtcHasFailed == 0) { if (SystemRtcHasFailed == 0) {
// starting and configuring the RTC itself // starting and configuring the RTC itself
system_clock_start_rtc_l4(); system_clock_start_rtc_l4();
}
} }
// disable access do backup domain // disable access do backup domain

Wyświetl plik

@ -21,6 +21,9 @@
int32_t test; int32_t test;
//tary specific
#include "io.h"
typedef enum max31865_pool_state_t { typedef enum max31865_pool_state_t {
MAX_UNINITIALIZED, MAX_UNINITIALIZED,
MAX_IDLE, MAX_IDLE,
@ -76,6 +79,11 @@ max31865_pool_state_t max31865_current_state = MAX_UNINITIALIZED;
*/ */
float max31865_rref = 0; float max31865_rref = 0;
/**
* And it's index from the table
*/
uint8_t max31865_rref_index = 0;
/** /**
* This variable is incremented from 0 up to 9 to pause measurement * This variable is incremented from 0 up to 9 to pause measurement
* state machine into MAX_SHUTDOWN state. When it reach 9 measurement * state machine into MAX_SHUTDOWN state. When it reach 9 measurement
@ -220,7 +228,7 @@ static void max31865_send_config_register(void) {
} }
} }
void max31865_init(uint8_t rdt_type, uint8_t reference_resistor) { void max31865_init(uint8_t rdt_type, uint8_t reference_resistor_index) {
uint8_t * rx_data; uint8_t * rx_data;
@ -236,15 +244,17 @@ void max31865_init(uint8_t rdt_type, uint8_t reference_resistor) {
return; return;
} }
if (reference_resistor > 31) { if (reference_resistor_index > 31) {
max31865_current_state = MAX_UNINITIALIZED; max31865_current_state = MAX_UNINITIALIZED;
return; return;
} }
else { else {
max31865_rref = max31865_rref_lookup_table[reference_resistor]; max31865_rref = max31865_rref_lookup_table[reference_resistor_index];
} }
max31865_rref_index = reference_resistor_index;
// set filter to 50Hz // set filter to 50Hz
max31865_filter_select = 1; max31865_filter_select = 1;
@ -288,10 +298,10 @@ void max31865_pool(void) {
case MAX_IDLE: case MAX_IDLE:
// MAX31865 is powered up but not initialized // MAX31865 is powered up but not initialized
if (max31865_rdt_sensor_type == 1) { if (max31865_rdt_sensor_type == 1) {
max31865_init(MAX_3WIRE, max31865_rref); max31865_init(MAX_3WIRE, max31865_rref_index);
} }
else { else {
max31865_init(MAX_4WIRE, max31865_rref); max31865_init(MAX_4WIRE, max31865_rref_index);
} }
if (max31865_ok == 1) { if (max31865_ok == 1) {
@ -386,18 +396,22 @@ void max31865_pool(void) {
max31865_vbias = 0; max31865_vbias = 0;
// this function may change 'max31865_current_state' internally due to errors // this function may change 'max31865_current_state' internally due to errors
max31865_send_config_register(); //max31865_send_config_register();
max31865_shutdown_ticks = 0; max31865_shutdown_ticks = 0;
} }
// tatry specific
io___cntrl_vbat_s_disable();
break; break;
case MAX_SHUTDOWN: case MAX_SHUTDOWN:
// MAX31865 is powered up and initialized but PT bias is disabled // MAX31865 is powered up and initialized but PT bias is disabled
// and no measurement is ongoing // and no measurement is ongoing
if (max31865_shutdown_ticks++ > MAX31865_INTERVAL) { if (max31865_shutdown_ticks++ > MAX31865_INTERVAL) {
max31865_current_state = MAX_INITIALIZED; io___cntrl_vbat_s_enable();
max31865_current_state = MAX_IDLE; //
max31865_shutdown_ticks = 0; max31865_shutdown_ticks = 0;
} }