Mercurial > public > ostc4
changeset 278:cc30d1aa03a7
Merged in Ideenmodellierer/ostc4/IPC_Sync_Improvment_3 (pull request #21)
IPC Sync Improvment 3
author | heinrichsweikamp <bitbucket@heinrichsweikamp.com> |
---|---|
date | Sun, 28 Apr 2019 15:54:46 +0000 |
parents | 2f0eb65df557 (diff) 580822b5d3d1 (current diff) |
children | b29fb616c458 |
files | Discovery/Src/data_exchange_main.c |
diffstat | 18 files changed, 185 insertions(+), 291 deletions(-) [+] |
line wrap: on
line diff
--- a/Common/Inc/data_central.h Sun Apr 28 10:16:38 2019 +0200 +++ b/Common/Inc/data_central.h Sun Apr 28 15:54:46 2019 +0000 @@ -394,8 +394,8 @@ extern SDiveState stateSim; extern SDiveState stateDeco; extern uint8_t decoLock; -extern const SDiveState * stateUsed; - +extern const SDiveState *stateUsed; +extern SDiveState *stateUsedWrite; enum DECO_LOCK{ DECO_CALC_running, @@ -454,7 +454,7 @@ int current_second(void); _Bool vpm_crush(SDiveState* pDiveState); _Bool deco_zone_reached(void); -void resetEvents(void); +void resetEvents(const SDiveState *pStateUsed); uint32_t crc32c_checksum(uint8_t* message, uint16_t length, uint8_t* message2, uint16_t length2); uint32_t CRC_CalcBlockCRC(uint32_t *buffer, uint32_t words);
--- a/Discovery/Inc/externLogbookFlash.h Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Inc/externLogbookFlash.h Sun Apr 28 15:54:46 2019 +0000 @@ -145,7 +145,6 @@ void ext_flash_read_block_start(void); void ext_flash_repair_dive_log(void); -void ext_flash_find_start(void); uint8_t ext_flash_erase_firmware_if_not_empty(void); uint8_t ext_flash_erase_firmware2_if_not_empty(void);
--- a/Discovery/Inc/logbook.h Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Inc/logbook.h Sun Apr 28 15:54:46 2019 +0000 @@ -199,7 +199,7 @@ int8_t percentageHe; } SManualGas; -void logbook_writeSample(SDiveState state); +void logbook_writeSample(const SDiveState *state); void logbook_initNewdiveProfile(const SDiveState* pInfo, SSettings* pSettings); void logbook_EndDive(void); @@ -211,7 +211,7 @@ uint8_t logbook_getHeader(uint8_t StepBackwards,SLogbookHeader* pLogbookHeader); uint16_t logbook_readSampleData(uint8_t StepBackwards, uint16_t length,uint16_t* depth, uint8_t* gasid, int16_t* temperature, uint16_t* ppo2, uint16_t* setpoint, uint16_t* sensor1, uint16_t* sensor2, uint16_t* sensor3, uint16_t* cns, uint8_t* bailout, uint16_t* decostopDepth); void logbook_test(void); -void logbook_InitAndWrite(void); +void logbook_InitAndWrite(const SDiveState* pStateReal); void logbook_recover_brokenlog(uint8_t headerId); uint16_t logbook_lastDive_diveNumber(void);
--- a/Discovery/Src/base.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/base.c Sun Apr 28 15:54:46 2019 +0000 @@ -508,8 +508,15 @@ DoDisplayRefresh = 0; RefreshDisplay(); +// Enable this to make the simulator write a logbook entry +// #define SIM_WRITES_LOGBOOK 1 + +#ifdef SIM_WRITES_LOGBOOK + if(stateUsed == stateSimGetPointer()) + logbook_InitAndWrite(stateUsed); +#endif if(stateUsed == stateRealGetPointer()) /* Handle log entries while in dive mode*/ - logbook_InitAndWrite(); + logbook_InitAndWrite(stateUsed); } #ifdef DEBUG_RUNTIME
--- a/Discovery/Src/check_warning.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/check_warning.c Sun Apr 28 15:54:46 2019 +0000 @@ -38,37 +38,30 @@ #include "decom.h" #include "tCCR.h" -/* Private variables wit access ----------------------------------------------*/ -uint8_t betterGasId = 0; -uint8_t betterSetpointId = 0; -int8_t fallback = 0; +/* Private variables with access ----------------------------------------------*/ +static uint8_t betterGasId = 0; +static uint8_t betterSetpointId = 0; +static int8_t fallback = 0; /* Private function prototypes -----------------------------------------------*/ -int8_t check_fallback(SDiveState * pDiveState); -int8_t check_ppO2(SDiveState * pDiveState); -int8_t check_O2_sensors(SDiveState * pDiveState); -int8_t check_CNS(SDiveState * pDiveState); -int8_t check_Deco(SDiveState * pDiveState); -int8_t check_AscentRate(SDiveState * pDiveState); -int8_t check_aGF(SDiveState * pDiveState); -int8_t check_BetterGas(SDiveState * pDiveState); -int8_t check_BetterSetpoint(SDiveState * pDiveState); -int8_t check_Battery(SDiveState * pDiveState); +static int8_t check_fallback(SDiveState * pDiveState); +static int8_t check_ppO2(SDiveState * pDiveState); +static int8_t check_O2_sensors(SDiveState * pDiveState); +static int8_t check_CNS(SDiveState * pDiveState); +static int8_t check_Deco(SDiveState * pDiveState); +static int8_t check_AscentRate(SDiveState * pDiveState); +static int8_t check_aGF(SDiveState * pDiveState); +static int8_t check_BetterGas(SDiveState * pDiveState); +static int8_t check_BetterSetpoint(SDiveState * pDiveState); +static int8_t check_Battery(SDiveState * pDiveState); -int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2); +static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2); /* Exported functions --------------------------------------------------------*/ void check_warning(void) { - SDiveState * pDiveState; - - if(stateUsed == stateRealGetPointer()) - pDiveState = stateRealGetPointerWrite(); - else - pDiveState = stateSimGetPointerWrite(); - - check_warning2(pDiveState); + check_warning2(stateUsedWrite); } @@ -123,7 +116,7 @@ /* Private functions ---------------------------------------------------------*/ -int8_t check_fallback(SDiveState * pDiveState) +static int8_t check_fallback(SDiveState * pDiveState) { if(fallback && ((pDiveState->mode != MODE_DIVE) || (pDiveState->diveSettings.diveMode != DIVEMODE_CCR))) fallback = 0; @@ -133,7 +126,7 @@ } -int8_t check_ppO2(SDiveState * pDiveState) +static int8_t check_ppO2(SDiveState * pDiveState) { if(pDiveState->mode != MODE_DIVE) { @@ -171,7 +164,7 @@ } -int8_t check_O2_sensors(SDiveState * pDiveState) +static int8_t check_O2_sensors(SDiveState * pDiveState) { pDiveState->warnings.sensorLinkLost = 0; pDiveState->warnings.sensorOutOfBounds[0] = 0; @@ -193,7 +186,7 @@ } -int8_t check_BetterGas(SDiveState * pDiveState) +static int8_t check_BetterGas(SDiveState * pDiveState) { if(stateUsed->mode != MODE_DIVE) { @@ -276,7 +269,7 @@ /* check for better travel!!! setpoint hw 151210 */ -int8_t check_BetterSetpoint(SDiveState * pDiveState) +static int8_t check_BetterSetpoint(SDiveState * pDiveState) { pDiveState->warnings.betterSetpoint = 0; betterSetpointId = 0; @@ -315,7 +308,7 @@ /* hw 151030 */ -int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2) +static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2) { if(gas1->helium_percentage != gas2->helium_percentage) return 0; @@ -327,7 +320,7 @@ } -int8_t check_CNS(SDiveState * pDiveState) +static int8_t check_CNS(SDiveState * pDiveState) { if(stateUsed->mode != MODE_DIVE) { @@ -343,7 +336,7 @@ } -int8_t check_Battery(SDiveState * pDiveState) +static int8_t check_Battery(SDiveState * pDiveState) { if(pDiveState->lifeData.battery_charge < 10) pDiveState->warnings.lowBattery = 1; @@ -354,7 +347,7 @@ } -int8_t check_Deco(SDiveState * pDiveState) +static int8_t check_Deco(SDiveState * pDiveState) { if(stateUsed->mode != MODE_DIVE) { @@ -376,7 +369,7 @@ } -int8_t check_AscentRate(SDiveState * pDiveState) +static int8_t check_AscentRate(SDiveState * pDiveState) { if(stateUsed->mode != MODE_DIVE) { @@ -396,7 +389,7 @@ } -int8_t check_aGF(SDiveState * pDiveState) +static int8_t check_aGF(SDiveState * pDiveState) { if(stateUsed->mode != MODE_DIVE) {
--- a/Discovery/Src/data_central.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/data_central.c Sun Apr 28 15:54:46 2019 +0000 @@ -100,17 +100,17 @@ .is_data_from_RTE_CPU = 0, }; -const SDiveState * stateUsed = &stateReal; - +const SDiveState *stateUsed = &stateReal; +SDiveState *stateUsedWrite = &stateReal; void set_stateUsedToReal(void) { - stateUsed = &stateReal; + stateUsed = stateUsedWrite = &stateReal; } void set_stateUsedToSim(void) { - stateUsed = &stateSim; + stateUsed = stateUsedWrite = &stateSim; } _Bool is_stateUsedSetToSim(void) @@ -458,39 +458,25 @@ void updateSetpointStateUsed(void) { - SLifeData *pLifeDataWrite; - - if(is_stateUsedSetToSim()) - pLifeDataWrite = &stateSimGetPointerWrite()->lifeData; - else - pLifeDataWrite = &stateRealGetPointerWrite()->lifeData; - if(stateUsed->diveSettings.diveMode != DIVEMODE_CCR) { - pLifeDataWrite->actualGas.setPoint_cbar = 0; - pLifeDataWrite->ppO2 = decom_calc_ppO2(stateUsed->lifeData.pressure_ambient_bar, &stateUsed->lifeData.actualGas); + stateUsedWrite->lifeData.actualGas.setPoint_cbar = 0; + stateUsedWrite->lifeData.ppO2 = decom_calc_ppO2(stateUsed->lifeData.pressure_ambient_bar, &stateUsed->lifeData.actualGas); } else { if(stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) { - pLifeDataWrite->actualGas.setPoint_cbar = get_ppO2SensorWeightedResult_cbar(); + stateUsedWrite->lifeData.actualGas.setPoint_cbar = get_ppO2SensorWeightedResult_cbar(); } if((stateUsed->lifeData.pressure_ambient_bar * 100) < stateUsed->lifeData.actualGas.setPoint_cbar) - pLifeDataWrite->ppO2 = stateUsed->lifeData.pressure_ambient_bar; + stateUsedWrite->lifeData.ppO2 = stateUsed->lifeData.pressure_ambient_bar; else - pLifeDataWrite->ppO2 = ((float)stateUsed->lifeData.actualGas.setPoint_cbar) / 100; + stateUsedWrite->lifeData.ppO2 = ((float)stateUsed->lifeData.actualGas.setPoint_cbar) / 100; } } -/* -void fallbackToFixedSetpoints(SLifeData *lifeData) -{ - -} -*/ - void setActualGasFirst(SLifeData *lifeData) { SSettings* pSettings = settingsGetPointer(); @@ -555,37 +541,30 @@ void setActualGas_DM(SLifeData *lifeData, uint8_t gasId, uint8_t setpoint_cbar) { - //Real dive => Set events for logbook - if(stateUsed == stateRealGetPointer()) - { - SDiveState * pStateUsed; - pStateUsed = stateRealGetPointerWrite(); - if(stateUsed->diveSettings.ccrOption && gasId < 6) { if(lifeData->actualGas.GasIdInSettings != gasId) { SSettings* pSettings = settingsGetPointer(); - pStateUsed->events.bailout = 1; - pStateUsed->events.info_bailoutO2 = pSettings->gas[gasId].oxygen_percentage; - pStateUsed->events.info_bailoutHe = pSettings->gas[gasId].helium_percentage; + stateUsedWrite->events.bailout = 1; + stateUsedWrite->events.info_bailoutO2 = pSettings->gas[gasId].oxygen_percentage; + stateUsedWrite->events.info_bailoutHe = pSettings->gas[gasId].helium_percentage; } } else { if(lifeData->actualGas.GasIdInSettings != gasId) { - pStateUsed->events.gasChange = 1; - pStateUsed->events.info_GasChange = gasId; + stateUsedWrite->events.gasChange = 1; + stateUsedWrite->events.info_GasChange = gasId; } if( lifeData->actualGas.setPoint_cbar != setpoint_cbar) { // setPoint_cbar = 255 -> change to sensor mode - pStateUsed->events.setpointChange = 1; - pStateUsed->events.info_SetpointChange = setpoint_cbar; + stateUsedWrite->events.setpointChange = 1; + stateUsedWrite->events.info_SetpointChange = setpoint_cbar; } } - } setActualGas(lifeData, gasId, setpoint_cbar); } @@ -597,23 +576,17 @@ nitrogen -= oxygen; nitrogen -= helium; - //Real dive => Set events for logbook - if(stateUsed == stateRealGetPointer()) - { - SDiveState * pStateUsed; - pStateUsed = stateRealGetPointerWrite(); if((lifeData->actualGas.nitrogen_percentage != nitrogen) || (lifeData->actualGas.helium_percentage != helium)) { - pStateUsed->events.manuelGasSet = 1; - pStateUsed->events.info_manuelGasSetHe = helium; - pStateUsed->events.info_manuelGasSetO2 = oxygen; + stateUsedWrite->events.manuelGasSet = 1; + stateUsedWrite->events.info_manuelGasSetHe = helium; + stateUsedWrite->events.info_manuelGasSetO2 = oxygen; } if( lifeData->actualGas.setPoint_cbar != setpoint_cbar) { - pStateUsed->events.setpointChange = 1; - pStateUsed->events.info_SetpointChange = setpoint_cbar; + stateUsedWrite->events.setpointChange = 1; + stateUsedWrite->events.info_SetpointChange = setpoint_cbar; } - } lifeData->actualGas.GasIdInSettings = 0; lifeData->actualGas.nitrogen_percentage = nitrogen; lifeData->actualGas.helium_percentage = helium; @@ -775,18 +748,9 @@ } -void resetEvents(void) +void resetEvents(const SDiveState *pStateUsed) { - SDiveState * pStateUsed; - if(stateUsed == stateRealGetPointer()) - { - pStateUsed = stateRealGetPointerWrite(); - } - else - { - pStateUsed = stateSimGetPointerWrite(); - } - memset(&pStateUsed->events,0, sizeof(SEvents)); + memset((void *)&pStateUsed->events, 0, sizeof(SEvents)); }
--- a/Discovery/Src/data_exchange_main.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/data_exchange_main.c Sun Apr 28 15:54:46 2019 +0000 @@ -436,7 +436,7 @@ vpm_init(&pStateUsed->vpm, pStateUsed->diveSettings.vpm_conservatism, 0, 0); buehlmann_init(); timer_init(); - resetEvents(); + resetEvents(pStateUsed); pStateUsed->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0; /* * ToDo by Peter
--- a/Discovery/Src/externLogbookFlash.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/externLogbookFlash.c Sun Apr 28 15:54:46 2019 +0000 @@ -115,53 +115,54 @@ /* Exported variables --------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ -uint32_t actualAddress = 0; -uint32_t entryPoint = 0; +static uint32_t actualAddress = 0; +static uint32_t entryPoint = 0; -uint32_t actualPointerHeader = 0; -uint32_t actualPointerSample = 0; -uint32_t LengthLeftSampleRead = 0; -uint32_t actualPointerDevicedata = 0; -uint32_t actualPointerVPM = 0; -uint32_t actualPointerSettings = 0; -uint32_t actualPointerFirmware = 0; -uint32_t actualPointerFirmware2 = 0; +static uint32_t actualPointerHeader = 0; +static uint32_t actualPointerSample = 0; +static uint32_t LengthLeftSampleRead = 0; +static uint32_t actualPointerDevicedata = 0; +static uint32_t actualPointerVPM = 0; +static uint32_t actualPointerSettings = 0; +static uint32_t actualPointerFirmware = 0; +static uint32_t actualPointerFirmware2 = 0; /* Private function prototypes -----------------------------------------------*/ -void chip_unselect(void); -void chip_select(void); -void error_led_on(void); -void error_led_off(void); +static void chip_unselect(void); +static void chip_select(void); +static void error_led_on(void); +static void error_led_off(void); -void write_spi(uint8_t data, uint8_t unselect_CS_afterwards); -uint8_t read_spi(uint8_t unselect_CS_afterwards); -void write_address(uint8_t unselect_CS_afterwards); +static void write_spi(uint8_t data, uint8_t unselect_CS_afterwards); +static uint8_t read_spi(uint8_t unselect_CS_afterwards); +static void write_address(uint8_t unselect_CS_afterwards); static void Error_Handler_extflash(void); static void wait_chip_not_busy(void); -void ext_flash_incf_address(uint8_t type); +static void ext_flash_incf_address(uint8_t type); //void ext_flash_incf_address_ring(void); -void ext_flash_decf_address_ring(uint8_t type); +static void ext_flash_decf_address_ring(uint8_t type); -void ext_flash_erase4kB(void); -void ext_flash_erase32kB(void); -void ext_flash_erase64kB(void); -uint8_t ext_flash_erase_if_on_page_start(void); +static void ext_flash_erase4kB(void); +static void ext_flash_erase32kB(void); +static void ext_flash_erase64kB(void); +static uint8_t ext_flash_erase_if_on_page_start(void); -void ef_write_block(uint8_t * sendByte, uint32_t length, uint8_t type, uint8_t do_not_erase); +static void ef_write_block(uint8_t * sendByte, uint32_t length, uint8_t type, uint8_t do_not_erase); -void ext_flash_read_block(uint8_t *getByte, uint8_t type); -void ext_flash_read_block_multi(void *getByte, uint32_t size, uint8_t type); -void ext_flash_read_block_stop(void); +static void ext_flash_read_block(uint8_t *getByte, uint8_t type); +static void ext_flash_read_block_multi(void *getByte, uint32_t size, uint8_t type); +static void ext_flash_read_block_stop(void); static void ef_hw_rough_delay_us(uint32_t delayUs); static void ef_erase_64K(uint32_t blocks); -void ext_flash_overwrite_sample_without_erase(uint8_t *pSample, uint16_t length); +static void ext_flash_overwrite_sample_without_erase(uint8_t *pSample, uint16_t length); + +static void ext_flash_disable_protection(void); -void ext_flash_disable_protection(void); - -_Bool ext_flash_test_remaining_space_of_page_empty(uint32_t pointer, uint16_t length); -void ext_flash_set_to_begin_of_next_page(uint32_t *pointer, uint8_t type); +static _Bool ext_flash_test_remaining_space_of_page_empty(uint32_t pointer, uint16_t length); +static void ext_flash_set_to_begin_of_next_page(uint32_t *pointer, uint8_t type); +static void ext_flash_find_start(void); /* Exported functions --------------------------------------------------------*/ @@ -731,7 +732,7 @@ settings->logFlashNextSampleStartAddress = actualPointerSample; } -void ext_flash_overwrite_sample_without_erase(uint8_t *pSample, uint16_t length) +static void ext_flash_overwrite_sample_without_erase(uint8_t *pSample, uint16_t length) { ef_write_block(pSample,length, EF_SAMPLE, 1); } @@ -1009,7 +1010,7 @@ /// @date 22-June-2016 // =============================================================================== -uint16_t ext_flash_repair_dive_numbers_starting_count_helper(uint8_t *data, uint8_t *change64k, uint16_t startNumber, uint8_t lastLogId) +static uint16_t ext_flash_repair_dive_numbers_starting_count_helper(uint8_t *data, uint8_t *change64k, uint16_t startNumber, uint8_t lastLogId) { const uint32_t headerStep = 0x800; uint8_t actualLogId = 0; @@ -1103,7 +1104,7 @@ return lastCount; } - +/* void OLD_ext_flash_repair_SPECIAL_dive_numbers_starting_count_with(uint16_t startCount) { uint16_t counterStorage[256]; @@ -1146,7 +1147,7 @@ startAbsolute = settingsGetPointer()->lastDiveLogId; -/* + if(start%2) { if(counterStorage[start] != startCount) @@ -1183,7 +1184,7 @@ } start--; } -*/ + // for(int count = start; count > -1; count -= 2) while(count > 0) @@ -1289,7 +1290,7 @@ releaseFrame(97,logCopyDataPtr); settingsGetPointer()->totalDiveCounter = startCount; } - +*/ // =============================================================================== // ext_flash_repair_dive_log @@ -1336,7 +1337,7 @@ } -void ext_flash_find_start(void) +static void ext_flash_find_start(void) { uint8_t id; uint8_t header1, header2; @@ -1422,7 +1423,7 @@ #endif -void ext_flash_disable_protection(void) +static void ext_flash_disable_protection(void) { /* extFlashStatusBit8_Type status; @@ -1475,13 +1476,13 @@ } -void ext_flash_erase_chip(void) +/*void ext_flash_erase_chip(void) { wait_chip_not_busy(); write_spi(0x06,RELEASE); write_spi(0x60,RELEASE); wait_chip_not_busy(); -} +}*/ void ext_flash_erase_firmware(void) { @@ -1525,7 +1526,7 @@ } -void ext_flash_erase4kB(void) +static void ext_flash_erase4kB(void) { wait_chip_not_busy(); write_spi(0x06,RELEASE);/* WREN */ @@ -1536,7 +1537,7 @@ /* be carefull - might not work with entire family and other products * see page 14 of LOGBOOK_V3_S25FS-S_00-271247.pdf */ -void ext_flash_erase32kB(void) +static void ext_flash_erase32kB(void) { uint32_t actualAddress_backup; @@ -1550,7 +1551,7 @@ } -void ext_flash_erase64kB(void) +static void ext_flash_erase64kB(void) { wait_chip_not_busy(); write_spi(0x06,RELEASE);/* WREN */ @@ -1567,7 +1568,7 @@ } /* 4KB, 32KB, 64 KB, not the upper 16 MB with 4 Byte address at the moment */ -uint8_t ext_flash_erase_if_on_page_start(void) +static uint8_t ext_flash_erase_if_on_page_start(void) { if(actualAddress < 0x00008000) { @@ -1601,14 +1602,14 @@ } -void ext_flash_read_block(uint8_t *getByte, uint8_t type) +static void ext_flash_read_block(uint8_t *getByte, uint8_t type) { *getByte = read_spi(HOLDCS);/* read data */ ext_flash_incf_address(type); } -void ext_flash_read_block_multi(void *getByte, uint32_t size, uint8_t type) +static void ext_flash_read_block_multi(void *getByte, uint32_t size, uint8_t type) { uint8_t *data; data = getByte; @@ -1621,7 +1622,7 @@ } -void ext_flash_read_block_stop(void) +static void ext_flash_read_block_stop(void) { chip_unselect(); } @@ -1629,7 +1630,7 @@ /* Private functions ---------------------------------------------------------*/ -void ef_write_block(uint8_t * sendByte, uint32_t length, uint8_t type, uint8_t do_not_erase) +static void ef_write_block(uint8_t * sendByte, uint32_t length, uint8_t type, uint8_t do_not_erase) { uint32_t remaining_page_size, remaining_length, remaining_space_to_ring_end; @@ -1745,7 +1746,7 @@ } -_Bool ext_flash_test_remaining_space_of_page_empty(uint32_t pointer, uint16_t length) +static _Bool ext_flash_test_remaining_space_of_page_empty(uint32_t pointer, uint16_t length) { if((pointer & 0xFFF) == 0) return 1; @@ -1777,7 +1778,7 @@ } -void ext_flash_set_to_begin_of_next_page(uint32_t *pointer, uint8_t type) +static void ext_flash_set_to_begin_of_next_page(uint32_t *pointer, uint8_t type) { uint32_t ringStart, ringStop; @@ -1830,28 +1831,28 @@ } -void chip_unselect(void) +static void chip_unselect(void) { HAL_GPIO_WritePin(EXTFLASH_CSB_GPIO_PORT,EXTFLASH_CSB_PIN,GPIO_PIN_SET); // chip select } -void chip_select(void) +static void chip_select(void) { HAL_GPIO_WritePin(EXTFLASH_CSB_GPIO_PORT,EXTFLASH_CSB_PIN,GPIO_PIN_RESET); // chip select } -void error_led_on(void) +static void error_led_on(void) { HAL_GPIO_WritePin(OSCILLOSCOPE_GPIO_PORT,OSCILLOSCOPE_PIN,GPIO_PIN_SET); } -void error_led_off(void) +static void error_led_off(void) { HAL_GPIO_WritePin(OSCILLOSCOPE_GPIO_PORT,OSCILLOSCOPE_PIN,GPIO_PIN_RESET); } -uint8_t read_spi(uint8_t unselect_CS_afterwards) +static uint8_t read_spi(uint8_t unselect_CS_afterwards) { uint8_t byte; @@ -1870,7 +1871,7 @@ } -void write_spi(uint8_t data, uint8_t unselect_CS_afterwards) +static void write_spi(uint8_t data, uint8_t unselect_CS_afterwards) { chip_select(); @@ -1885,7 +1886,7 @@ } -void write_address(uint8_t unselect_CS_afterwards) +static void write_address(uint8_t unselect_CS_afterwards) { uint8_t hi, med ,lo; @@ -1916,7 +1917,7 @@ } -void ext_flash_incf_address(uint8_t type) +static void ext_flash_incf_address(uint8_t type) { uint32_t ringStart, ringStop; @@ -1963,7 +1964,7 @@ } -void ext_flash_decf_address_ring(uint8_t type) +static void ext_flash_decf_address_ring(uint8_t type) { uint32_t ringStart, ringStop;
--- a/Discovery/Src/logbook.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/logbook.c Sun Apr 28 15:54:46 2019 +0000 @@ -90,10 +90,10 @@ static void logbook_SetAverageDepth(float average_depth_meter); static void logbook_SetMinTemperature(float min_temperature_celsius); static void logbook_SetMaxCNS(float max_cns_percentage); -static void logbook_SetCompartmentDesaturation(void); +static void logbook_SetCompartmentDesaturation(const SDiveState * pStateReal); static void logbook_SetLastStop(float last_stop_depth_bar); static void logbook_writedata(void * data, int length_byte); -static void logbook_UpdateHeader(void); +static void logbook_UpdateHeader(const SDiveState * pStateReal); /* Exported functions --------------------------------------------------------*/ @@ -267,7 +267,7 @@ memcpy(header.n2Compartments, pInfo->lifeData.tissue_nitrogen_bar, 64); memcpy(header.heCompartments, pInfo->lifeData.tissue_helium_bar, 64); - logbook_SetCompartmentDesaturation(); + logbook_SetCompartmentDesaturation(pInfo); ext_flash_start_new_dive_log_and_set_actualPointerSample((uint8_t*)&header); @@ -371,7 +371,7 @@ * @param SDiveState state: */ -void logbook_writeSample(SDiveState state) +void logbook_writeSample(const SDiveState *state) { uint8_t sample[256]; // int position = 0; @@ -385,7 +385,7 @@ int i = 0; for(i = 0; i <256 ;i++) sample[i] = 0; - addU16(sample, (uint16_t)(state.lifeData.depth_meter * 100)); + addU16(sample, (uint16_t)(state->lifeData.depth_meter * 100)); length += 2; sample[2] = 0; length++; @@ -396,50 +396,50 @@ //BuildEevntyte 1 // sub old 0-3 only one at a time - if(state.events.manualMarker) + if(state->events.manualMarker) { eventByte1.uw = 6; } else - if(state.warnings.decoMissed) + if(state->warnings.decoMissed) { eventByte1.uw = 2; } else - if(state.warnings.ppO2Low) + if(state->warnings.ppO2Low) { eventByte1.uw = 4; } else - if(state.warnings.ppO2High) + if(state->warnings.ppO2High) { eventByte1.uw = 5; } else - if(state.warnings.lowBattery) + if(state->warnings.lowBattery) { eventByte1.uw = 7; } else - if(state.warnings.slowWarning) + if(state->warnings.slowWarning) { eventByte1.uw = 1; } // sub bit 4 to 7 - if(state.events.manuelGasSet) + if(state->events.manuelGasSet) { eventByte1.ub.bit4 = 1; } - if(state.events.gasChange) + if(state->events.gasChange) { eventByte1.ub.bit5 = 1; } - if(state.events.setpointChange) + if(state->events.setpointChange) { eventByte1.ub.bit6 = 1; } // sub bit 7 + eventbyte2 - if(state.events.bailout) + if(state->events.bailout) { eventByte1.ub.bit7 = 1; eventByte2.ub.bit0 = 1; @@ -456,32 +456,32 @@ length++; } //Add EventInfos - if(state.events.manuelGasSet) + if(state->events.manuelGasSet) { //manual gas in %O2 & %He - sample[length] = state.events.info_manuelGasSetO2; + sample[length] = state->events.info_manuelGasSetO2; length += 1; - sample[length] = state.events.info_manuelGasSetHe; + sample[length] = state->events.info_manuelGasSetHe; length += 1; } - if(state.events.gasChange) + if(state->events.gasChange) { //Current gas (gasid) - sample[length] = state.events.info_GasChange; + sample[length] = state->events.info_GasChange; length += 1; } - if(state.events.setpointChange) + if(state->events.setpointChange) { //New setpoint in cbar - sample[length] = state.events.info_SetpointChange; + sample[length] = state->events.info_SetpointChange; length += 1; } - if(state.events.bailout) + if(state->events.bailout) { //bailout gas in % O2 & %He - sample[length] = state.events.info_bailoutO2; + sample[length] = state->events.info_bailoutO2; length += 1; - sample[length] = state.events.info_bailoutHe; + sample[length] = state->events.info_bailoutHe; length += 1; } @@ -489,7 +489,7 @@ if(divisor.temperature == 0) { divisor.temperature = smallHeader.tempDivisor - 1; - addS16(&sample[length], (int16_t)((state.lifeData.temperature_celsius * 10.0f) + 0.5f)); + addS16(&sample[length], (int16_t)((state->lifeData.temperature_celsius * 10.0f) + 0.5f)); length += 2; } else @@ -556,9 +556,9 @@ for(int i = 0; i <3; i++) { - sample[length] = (uint8_t)(state.lifeData.ppO2Sensor_bar[i] * 100.0f + 0.5f); + sample[length] = (uint8_t)(state->lifeData.ppO2Sensor_bar[i] * 100.0f + 0.5f); length += 1; - addU16(&sample[length], (uint16_t)(state.lifeData.sensorVoltage_mV[i] * 10.0f + 0.5f)); + addU16(&sample[length], (uint16_t)(state->lifeData.sensorVoltage_mV[i] * 10.0f + 0.5f)); length += 2; } } @@ -574,19 +574,19 @@ if(divisor.decoplan == 0) { divisor.decoplan = smallHeader.decoplanDivisor - 1; - if(state.diveSettings.deco_type.ub.standard == VPM_MODE) + if(state->diveSettings.deco_type.ub.standard == VPM_MODE) { for(int i = 0; i <15; i++) { - sample[length] = state.decolistVPM.output_stop_length_seconds[i] / 60; + sample[length] = state->decolistVPM.output_stop_length_seconds[i] / 60; length += 1; } } - else if(state.diveSettings.deco_type.ub.standard == GF_MODE) + else if(state->diveSettings.deco_type.ub.standard == GF_MODE) { for(int i = 0; i <15; i++) { - sample[length] = state.decolistBuehlmann.output_stop_length_seconds[i] / 60; + sample[length] = state->decolistBuehlmann.output_stop_length_seconds[i] / 60; length += 1; } } @@ -609,7 +609,7 @@ if(divisor.cns == 0) { divisor.cns = smallHeader.cnsDivisor - 1; - addU16(&sample[length], (uint16_t)state.lifeData.cns); + addU16(&sample[length], (uint16_t)state->lifeData.cns); length += 2; } else @@ -1132,7 +1132,7 @@ * and finishes logbook after end of dive *********************************************************************************/ -void logbook_InitAndWrite(void) +void logbook_InitAndWrite(const SDiveState *pStateReal) { SSettings *pSettings = settingsGetPointer(); static uint8_t bDiveMode = 0; @@ -1141,8 +1141,6 @@ uint32_t lasttick = 0; static float min_temperature_float_celsius = 0; - const SDiveState * pStateReal = stateRealGetPointer(); - if(!bDiveMode) { if((pStateReal->mode == MODE_DIVE) && (pStateReal->diveSettings.diveMode != DIVEMODE_Apnea) && (pStateReal->lifeData.dive_time_seconds >= 5)) @@ -1152,8 +1150,8 @@ logbook_initNewdiveProfile(pStateReal,settingsGetPointer()); min_temperature_float_celsius = pStateReal->lifeData.temperature_celsius; //Write logbook sample - logbook_writeSample(*pStateReal); - resetEvents(); + logbook_writeSample(pStateReal); + resetEvents(pStateReal); tickstart = HAL_GetTick(); bDiveMode = 1; } @@ -1166,8 +1164,8 @@ if(ticksdiff >= 2000) { //Write logbook sample - logbook_writeSample(*pStateReal); - resetEvents(); + logbook_writeSample(pStateReal); + resetEvents(pStateReal); if(min_temperature_float_celsius > pStateReal->lifeData.temperature_celsius) min_temperature_float_celsius = pStateReal->lifeData.temperature_celsius; tickstart = lasttick; @@ -1187,7 +1185,7 @@ bDiveMode = 3; } if(bDiveMode == 3) - logbook_UpdateHeader(); + logbook_UpdateHeader(pStateReal); } } else if(bDiveMode == 3) @@ -1196,7 +1194,7 @@ logbook_SetAverageDepth(pStateReal->lifeData.average_depth_meter); logbook_SetMinTemperature(min_temperature_float_celsius); logbook_SetMaxCNS(pStateReal->lifeData.cns); - logbook_SetCompartmentDesaturation(); + logbook_SetCompartmentDesaturation(pStateReal); logbook_SetLastStop(pStateReal->diveSettings.last_stop_depth_bar); logbook_EndDive(); bDiveMode = 0; @@ -1218,10 +1216,8 @@ * @version V0.0.1 * @date 27-Nov-2014 *********************************************************************************/ -static void logbook_UpdateHeader(void) +static void logbook_UpdateHeader(const SDiveState *pStateReal) { - const SDiveState * pStateReal = stateRealGetPointer(); - // uint16_t secondsAtShallow = 0; RTC_DateTypeDef Sdate; RTC_TimeTypeDef Stime; @@ -1339,9 +1335,8 @@ } -static void logbook_SetCompartmentDesaturation(void) +static void logbook_SetCompartmentDesaturation(const SDiveState * pStateReal) { - const SDiveState * pStateReal = stateRealGetPointer(); SLifeData2 secondaryInformation = { 0 }; decom_tissues_desaturation_time(&pStateReal->lifeData, &secondaryInformation);
--- a/Discovery/Src/settings.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/settings.c Sun Apr 28 15:54:46 2019 +0000 @@ -55,8 +55,8 @@ { .versionFirst = 1, .versionSecond = 4, - .versionThird = 7, - .versionBeta = 0, + .versionThird = 8, + .versionBeta = 1, /* 4 bytes with trailing 0 */ .signature = "mh",
--- a/Discovery/Src/t3.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/t3.c Sun Apr 28 15:54:46 2019 +0000 @@ -487,14 +487,7 @@ if((t3_selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) t3_change_customview(); - SDiveState * pDiveState; - - if(stateUsed == stateRealGetPointer()) - pDiveState = stateRealGetPointerWrite(); - else - pDiveState = stateSimGetPointerWrite(); - - t3_basics_refresh_customview(depth, t3_selection_customview, &t3screen, &t3c1, &t3c2, pDiveState->diveSettings.diveMode); + t3_basics_refresh_customview(depth, t3_selection_customview, &t3screen, &t3c1, &t3c2, stateUsedWrite->diveSettings.diveMode); }
--- a/Discovery/Src/tCCR.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/tCCR.c Sun Apr 28 15:54:46 2019 +0000 @@ -59,7 +59,7 @@ /* Private variables with external access via get_xxx() function -------------*/ /* Private function prototypes -----------------------------------------------*/ -void tCCR_fallbackToFixedSetpoint(void); +static void tCCR_fallbackToFixedSetpoint(void); #ifndef USART_IR_HUD @@ -343,23 +343,17 @@ #endif /* Private functions ---------------------------------------------------------*/ -void tCCR_fallbackToFixedSetpoint(void) +static void tCCR_fallbackToFixedSetpoint(void) { if((stateUsed->mode == MODE_DIVE) && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR) && (stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) && (stateUsed->diveSettings.fallbackOption)) { uint8_t setpointCbar, actualGasID; - SDiveState *pState; - if(stateUsed == stateRealGetPointer()) - pState = stateRealGetPointerWrite(); - else - pState = stateSimGetPointerWrite(); + setpointCbar = stateUsed->diveSettings.setpoint[1].setpoint_cbar; + stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint; - setpointCbar = pState->diveSettings.setpoint[1].setpoint_cbar; - pState->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint; - - actualGasID = pState->lifeData.actualGas.GasIdInSettings; - setActualGas_DM(&pState->lifeData,actualGasID,setpointCbar); + actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings; + setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar); set_warning_fallback(); }
--- a/Discovery/Src/tHome.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/tHome.c Sun Apr 28 15:54:46 2019 +0000 @@ -285,10 +285,7 @@ break; case StDBEAR: // t5_gauge - if(is_stateUsedSetToSim()) - stateSimGetPointerWrite()->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; - else - stateRealGetPointerWrite()->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; + stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; set_globalState(StD); break;
--- a/Discovery/Src/tMenuEditXtra.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/tMenuEditXtra.c Sun Apr 28 15:54:46 2019 +0000 @@ -121,56 +121,7 @@ uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { - if(is_stateUsedSetToSim()) - stateSimGetPointerWrite()->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; - else - stateRealGetPointerWrite()->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; + stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; exitMenuEdit_to_Home_with_Menu_Update(); return EXIT_TO_HOME; } - - -/* - uint8_t digitContentNew; - uint32_t newHeading; - - if(action == ACTION_BUTTON_ENTER) - { - return digitContent; - } - if(action == ACTION_BUTTON_ENTER_FINAL) - { - evaluateNewString(editId, &newHeading, 0, 0, 0); - if(newHeading > 359) - newHeading = 0; - - if(is_stateUsedSetToSim()) - stateSimGetPointerWrite()->diveSettings.compassHeading = newHeading; - else - stateRealGetPointerWrite()->diveSettings.compassHeading = newHeading; - exitMenuEdit_to_Home_with_Menu_Update(); - return EXIT_TO_HOME; - } - if(action == ACTION_BUTTON_NEXT) - { - digitContentNew = digitContent + 1; - if((digitNumber == 0) && (digitContentNew > '3')) - digitContentNew = '0'; - else - if(digitContentNew > '9') - digitContentNew = '0'; - return digitContentNew; - } - if(action == ACTION_BUTTON_BACK) - { - digitContentNew = digitContent - 1; - if((digitNumber == 0) && (digitContentNew < '0')) - digitContentNew = '3'; - else - if(digitContentNew < '0') - digitContentNew = '9'; - return digitContentNew; - } - - return EXIT_TO_MENU; -*/
--- a/Discovery/Src/test_vpm.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Discovery/Src/test_vpm.c Sun Apr 28 15:54:46 2019 +0000 @@ -527,7 +527,7 @@ input.events.gasChange = 0; input.events.info_GasChange = 0; } - logbook_writeSample(input); + logbook_writeSample(&input); } volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); @@ -590,7 +590,7 @@ input.events.gasChange = 0; input.events.info_GasChange = 0; } - logbook_writeSample(input); + logbook_writeSample(&input); } volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); @@ -652,7 +652,7 @@ input.events.gasChange = 0; input.events.info_GasChange = 0; } - logbook_writeSample(input); + logbook_writeSample(&input); } volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); @@ -708,7 +708,7 @@ input.lifeData.depth_meter = 0; } - logbook_writeSample(input); + logbook_writeSample(&input); } volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); logbookHeader->total_diveTime_seconds = input.lifeData.dive_time_seconds;
--- a/Small_CPU/Src/baseCPU2.c Sun Apr 28 10:16:38 2019 +0200 +++ b/Small_CPU/Src/baseCPU2.c Sun Apr 28 15:54:46 2019 +0000 @@ -164,8 +164,8 @@ const SFirmwareData cpu2_FirmwareData __attribute__(( section(".firmware_data") ))= { .versionFirst = 1, .versionSecond = 7, - .versionThird = 0, - .versionBeta = 0, + .versionThird = 1, + .versionBeta = 1, /* 4 bytes with trailing 0 */ .signature = "mh",