diff Discovery/Src/data_central.c @ 300:5ca177d2df5d cleanup-4

cleanup: remove commented/unused code, make static without any functional change. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Fri, 17 May 2019 21:19:04 +0200
parents 54d14bc2083c
children eba8d1eb5bef
line wrap: on
line diff
--- a/Discovery/Src/data_central.c	Fri May 17 06:38:56 2019 +0000
+++ b/Discovery/Src/data_central.c	Fri May 17 21:19:04 2019 +0200
@@ -75,7 +75,7 @@
 SDiveState stateSim = { 0 };
 SDiveState stateDeco = { 0 };
 
-SDevice stateDevice =
+static SDevice stateDevice =
 {
 	/* max is 0x7FFFFFFF, min is 0x80000000 but also defined in stdint.h :-) */
 
@@ -94,7 +94,7 @@
 	.voltageMinimum.value_int32 = INT32_MAX,
 };
 
-SVpmRepetitiveData stateVPM =
+static SVpmRepetitiveData stateVPM =
 {
 	.repetitive_variables_not_valid = 1,
 	.is_data_from_RTE_CPU = 0,
@@ -175,65 +175,26 @@
 
 
 uint8_t decoLock = DECO_CALC_undefined;
-int ascent_rate_meter_per_min  = 12;
-int descent_rate_meter_per_min  = 20;
-int max_depth = 70;
-int bottom_time = 10;
+
+static int descent_rate_meter_per_min  = 20;
+static int max_depth = 70;
+static int bottom_time = 10;
 
 _Bool vpm_crush(SDiveState* pDiveState);
 void setSimulationValues(int _ascent_rate_meter_per_min, int _descent_rate_meter_per_min, int _max_depth, int _bottom_time )
 {
-    ascent_rate_meter_per_min = _ascent_rate_meter_per_min;
     descent_rate_meter_per_min = _descent_rate_meter_per_min;
     max_depth = _max_depth;
     bottom_time = _bottom_time;
 }
 
-
-
 int current_second(void) {
 
     return HAL_GetTick() / 1000;
-    // printf("milliseconds: %lld\n", milliseconds);
-    //return milliseconds;
 }
 
-
-
 #define OXY_ONE_SIXTIETH_PART 			0.0166667f
 
-/*void oxygen_calculate_cns(float* oxygen_cns, float pressure_oxygen_real)
-{
-	int cns_no_range = 0;
-	_Bool not_found = 1;
-    //for the cns calculation
-    const float cns_ppo2_ranges[60][2] = {	{0.50, 0.00}, {0.60, 0.14}, {0.64, 0.15}, {0.66, 0.16}, {0.68, 0.17}, {0.70, 0.18},
-										{0.74, 0.19}, {0.76, 0.20}, {0.78, 0.21}, {0.80, 0.22}, {0.82, 0.23}, {0.84, 0.24},
-										{0.86, 0.25}, {0.88, 0.26}, {0.90, 0.28}, {0.92, 0.29}, {0.94, 0.30}, {0.96, 0.31},
-										{0.98, 0.32}, {1.00, 0.33}, {1.02, 0.35}, {1.04, 0.36}, {1.06, 0.38}, {1.08, 0.40},
-										{1.10, 0.42}, {1.12, 0.43}, {1.14, 0.43}, {1.16, 0.44}, {1.18, 0.46}, {1.20, 0.47},
-										{1.22, 0.48}, {1.24, 0.51},	{1.26, 0.52}, {1.28, 0.54}, {1.30, 0.56}, {1.32, 0.57},
-										{1.34, 0.60}, {1.36, 0.62}, {1.38, 0.63}, {1.40, 0.65}, {1.42, 0.68}, {1.44, 0.71},
-										{1.46, 0.74}, {1.48, 0.78}, {1.50, 0.83}, {1.52, 0.93}, {1.54, 1.04}, {1.56, 1.19},
-										{1.58, 1.47}, {1.60, 2.22}, {1.62, 5.00}, {1.65, 6.25}, {1.67, 7.69}, {1.70, 10.0},
-										{1.72,12.50}, {1.74,20.00}, {1.77,25.00}, {1.79,31.25}, {1.80,50.00}, {1.82,100.0}};
-	//find the correct cns range for the corresponding ppo2
-	cns_no_range = 58;
-	while (cns_no_range && not_found)
-	{
-		if (pressure_oxygen_real > cns_ppo2_ranges[cns_no_range][0])
-		{
-			cns_no_range++;
-			not_found = 0;
-		}
-		else
-			cns_no_range--;
-	}
-
-	//calculate cns for the actual ppo2 for 1 second
-	*oxygen_cns += OXY_ONE_SIXTIETH_PART * cns_ppo2_ranges[cns_no_range][1];
-}*/
-
 uint8_t calc_MOD(uint8_t gasId)
 {
 	int16_t oxygen, maxppO2, result;
@@ -261,40 +222,6 @@
 	return result;
 }
 
-uint8_t calc_MinOD(uint8_t gasId)
-{
-	int16_t oxygen, minppO2, result;
-	SSettings *pSettings;
-
-	pSettings = settingsGetPointer();
-
-	oxygen = (int16_t)(pSettings->gas[gasId].oxygen_percentage);
-	minppO2 =(int16_t)(pSettings->ppO2_min);
-	result = 10 *  minppO2;
-	result += 9;
-	result /= oxygen;
-	result -= 10;
-
-	if(result < 0)
-		return 0;
-
-	if(result > 255)
-		return 255;
-
-	return result;
-}
-/*
-float calc_ppO2(float input_ambient_pressure_bar, SGas* pGas)
-{
-    float percent_N2 = 0;
-	float percent_He = 0;
-	float percent_O2 = 0;
-    decom_get_inert_gases(input_ambient_pressure_bar, pGas, &percent_N2, &percent_He);
-    percent_O2 = 1 - percent_N2 - percent_He;
-
-    return  (input_ambient_pressure_bar - WATER_VAPOUR_PRESSURE) * percent_O2;
-}*/
-
 float get_ambiant_pressure_simulation(long dive_time_seconds, float surface_pressure_bar )
 {
   static
@@ -651,7 +578,7 @@
 }
 
 
-int32_t helper_days_from_civil(int32_t y, uint32_t m, uint32_t d)
+static int32_t helper_days_from_civil(int32_t y, uint32_t m, uint32_t d)
 {
 		y += 2000;
     y -= m <= 2;
@@ -663,7 +590,7 @@
 }
 
 
-uint8_t helper_weekday_from_days(int32_t z)
+static uint8_t helper_weekday_from_days(int32_t z)
 {
     return (uint8_t)(z >= -4 ? (z+4) % 7 : (z+5) % 7 + 6);
 }
@@ -714,95 +641,12 @@
   sTime->SubSeconds = 0;
 }
 
-
-/*
-void initDiveState(SDiveSettings * pDiveSettings, SVpm * pVpm)
-{
-    SSettings* pSettings = settingsGetPointer();
-    for(int i = 0; i< NUM_GASES; i++)
-    {
-        pDiveSettings->gas[i] =  pSettings->gas[i];
-        pDiveSettings->gas[NUM_OFFSET_DILUENT + i] =  pSettings->gas[NUM_OFFSET_DILUENT + i];
-        pDiveSettings->setpoint[i] =  pSettings->setpoint[i];
-    }
-    pDiveSettings->diveMode = pSettings->dive_mode;
-
-    pDiveSettings->gf_high = pSettings->GF_high;
-    pDiveSettings->gf_low = pSettings->GF_low;
-    pDiveSettings->last_stop_depth_bar = ((float)pSettings->last_stop_depth_meter) / 10.0;
-    pDiveSettings->ascentRate_meterperminute = 10;
-    pDiveSettings->vpm_conservatism = 1;
-
-    pDiveSettings->input_next_stop_increment_depth_bar = ((float)pSettings->stop_increment_depth_meter) / 10.0f;
-
-    vpm_init(pVpm,  pDiveSettings->vpm_conservatism, 0, 0);
-}
-*/
-_Bool deco_zone_reached(void)
-{
-  	if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE)
-      return stateUsed->lifeData.pressure_ambient_bar <= stateUsed->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero;
-    else
-      return stateUsed->vpm.deco_zone_reached;
-
-}
-
-
 void resetEvents(const SDiveState *pStateUsed)
 {
 	memset((void *)&pStateUsed->events, 0, sizeof(SEvents));
 }
 
 
-/* This is derived from crc32b but does table lookup. First the table
-itself is calculated, if it has not yet been set up.
-Not counting the table setup (which would probably be a separate
-function), when compiled to Cyclops with GCC, this function executes in
-7 + 13n instructions, where n is the number of bytes in the input
-message. It should be doable in 4 + 9n instructions. In any case, two
-of the 13 or 9 instrucions are load byte.
-   This is Figure 14-7 in the text. */
-
-/* http://www.hackersdelight.org/ i guess ;-)  *hw */
-
-uint32_t crc32c_checksum(uint8_t* message, uint16_t length, uint8_t* message2, uint16_t length2) {
-	int i, j;
-	uint32_t byte, crc, mask;
-	static unsigned int table[256] = {0};
-
-	/* Set up the table, if necessary. */
-	if (table[1] == 0) {
-		for (byte = 0; byte <= 255; byte++) {
-			 crc = byte;
-			 for (j = 7; j >= 0; j--) {    // Do eight times.
-					mask = -(crc & 1);
-					crc = (crc >> 1) ^ (0xEDB88320 & mask);
-			 }
-			 table[byte] = crc;
-		}
-	}
-
-	/* Through with table setup, now calculate the CRC. */
-	i = 0;
-	crc = 0xFFFFFFFF;
-	while (length--) {
-		byte = message[i];
-		crc = (crc >> 8) ^ table[(crc ^ byte) & 0xFF];
-		i = i + 1;
-	}
-	if(length2)
-	{
-	 i = 0;
-	 while (length2--) {
-			byte = message2[i];
-			crc = (crc >> 8) ^ table[(crc ^ byte) & 0xFF];
-			i = i + 1;
-	 }
-	}
-	return ~crc;
-}
-
-
 uint32_t	CRC_CalcBlockCRC_moreThan768000(uint32_t *buffer1, uint32_t *buffer2, uint32_t words)
 {
  cm_t        crc_model;