# HG changeset patch # User Dmitry Romanov # Date 1542877375 -10800 # Node ID 3db7389d49ccbeb0694b776c8b3b4794354ccb72 # Parent e746bf846638c8895cf3efab79c8b1c717e9d109 revert diff -r e746bf846638 -r 3db7389d49cc Discovery/Src/data_exchange_main.c --- a/Discovery/Src/data_exchange_main.c Wed Nov 21 13:57:58 2018 +0300 +++ b/Discovery/Src/data_exchange_main.c Thu Nov 22 12:02:55 2018 +0300 @@ -306,7 +306,7 @@ uint8_t SPI_DMA_answer = 0; HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET); - delayMicros(50); //~exchange time(+20% reserve) + delayMicros(10); //~exchange time(+20% reserve) HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET); /* one cycle with NotChipSelect true to clear slave spi buffer */ diff -r e746bf846638 -r 3db7389d49cc Discovery/Src/settings.c --- a/Discovery/Src/settings.c Wed Nov 21 13:57:58 2018 +0300 +++ b/Discovery/Src/settings.c Thu Nov 22 12:02:55 2018 +0300 @@ -55,7 +55,7 @@ { .versionFirst = 1, .versionSecond = 4, - .versionThird = 5, + .versionThird = 4, .versionBeta = 0, /* 4 bytes with trailing 0 */ diff -r e746bf846638 -r 3db7389d49cc Small_CPU/Inc/scheduler.h --- a/Small_CPU/Inc/scheduler.h Wed Nov 21 13:57:58 2018 +0300 +++ b/Small_CPU/Inc/scheduler.h Thu Nov 22 12:02:55 2018 +0300 @@ -53,7 +53,7 @@ _Bool demo_mode; uint8_t dataSendToSlaveIsValid; uint8_t dataSendToSlavePending; - uint8_t dataUpdateIsNeeded; + uint8_t dataSendToSlaveStopEval; uint32_t sync_error_count; uint32_t check_sync_not_running; uint8_t ButtonResponsiveness[4]; diff -r e746bf846638 -r 3db7389d49cc Small_CPU/Src/baseCPU2.c --- a/Small_CPU/Src/baseCPU2.c Wed Nov 21 13:57:58 2018 +0300 +++ b/Small_CPU/Src/baseCPU2.c Thu Nov 22 12:02:55 2018 +0300 @@ -387,7 +387,7 @@ MX_DMA_Init(); MX_SPI1_Init(); MX_EXTI_wireless_Init(); -// SPI_Start_single_TxRx_with_Master(); + SPI_Start_single_TxRx_with_Master(); EXTI_Test_Button_Init(); /* @@ -414,7 +414,7 @@ MX_DMA_Init(); MX_SPI1_Init(); // MX_EXTI_wireless_Init(); -// SPI_Start_single_TxRx_with_Master(); + SPI_Start_single_TxRx_with_Master(); // EXTI_Test_Button_Init(); scheduleTestMode(); @@ -496,7 +496,7 @@ MX_DMA_Init(); MX_SPI1_Init(); MX_EXTI_wireless_Init(); -// SPI_Start_single_TxRx_with_Master(); + SPI_Start_single_TxRx_with_Master(); // EXTILine0_Button_DeInit(); not now, later after testing break; diff -r e746bf846638 -r 3db7389d49cc Small_CPU/Src/i2c.c --- a/Small_CPU/Src/i2c.c Wed Nov 21 13:57:58 2018 +0300 +++ b/Small_CPU/Src/i2c.c Thu Nov 22 12:02:55 2018 +0300 @@ -76,16 +76,17 @@ I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; I2cHandle.Init.OwnAddress1 = 0x01; + global.dataSendToSlaveStopEval = 1; global.I2C_SystemStatus = HAL_I2C_Init(&I2cHandle); HAL_I2CEx_AnalogFilter_Config(&I2cHandle, I2C_ANALOGFILTER_ENABLED); -// if(global.dataSendToSlavePending) -// { -// scheduleSpecial_Evaluate_DataSendToSlave(); -// } - global.dataUpdateIsNeeded = 1; + global.dataSendToSlaveStopEval = 0; + if(global.dataSendToSlavePending) + { + scheduleSpecial_Evaluate_DataSendToSlave(); + } return (HAL_StatusTypeDef)global.I2C_SystemStatus; } @@ -109,19 +110,18 @@ if(global.I2C_SystemStatus != HAL_OK) return (HAL_StatusTypeDef)global.I2C_SystemStatus; + global.dataSendToSlaveStopEval = 1; - global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress, pData, Size, 100 /*FIXME , 0*/); if(global.I2C_SystemStatus != HAL_OK) { I2C_Error_count(); } - -// if(global.dataSendToSlavePending) -// { -// scheduleSpecial_Evaluate_DataSendToSlave(); -// } - global.dataUpdateIsNeeded = 1; + global.dataSendToSlaveStopEval = 0; + if(global.dataSendToSlavePending) + { + scheduleSpecial_Evaluate_DataSendToSlave(); + } return (HAL_StatusTypeDef)global.I2C_SystemStatus; } @@ -132,7 +132,7 @@ return (HAL_StatusTypeDef)(global.I2C_SystemStatus & 0x03); - + global.dataSendToSlaveStopEval = 1; global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress, pData, Size, 100 /*FIXME , 1*/); if(global.I2C_SystemStatus != HAL_OK) @@ -140,12 +140,12 @@ I2C_Error_count(); } -// if(global.dataSendToSlavePending) -// { -// scheduleSpecial_Evaluate_DataSendToSlave(); -// } -// - global.dataUpdateIsNeeded = 1; + global.dataSendToSlaveStopEval = 0; + if(global.dataSendToSlavePending) + { + scheduleSpecial_Evaluate_DataSendToSlave(); + } + return (HAL_StatusTypeDef)global.I2C_SystemStatus; } @@ -157,6 +157,7 @@ uint8_t localHALstatusReturn = 0xFF; + global.dataSendToSlaveStopEval = 1; localHALstatusReturn = HAL_I2C_Master_Receive(&I2cHandle, DevAddress, pData, Size, 100); if(localHALstatusReturn != HAL_OK) @@ -164,11 +165,11 @@ I2C_Error_count(); } - global.dataUpdateIsNeeded = 1; -// if(global.dataSendToSlavePending) -// { -// scheduleSpecial_Evaluate_DataSendToSlave(); -// } + global.dataSendToSlaveStopEval = 0; + if(global.dataSendToSlavePending) + { + scheduleSpecial_Evaluate_DataSendToSlave(); + } return (HAL_StatusTypeDef)localHALstatusReturn; } diff -r e746bf846638 -r 3db7389d49cc Small_CPU/Src/scheduler.c --- a/Small_CPU/Src/scheduler.c Wed Nov 21 13:57:58 2018 +0300 +++ b/Small_CPU/Src/scheduler.c Thu Nov 22 12:02:55 2018 +0300 @@ -110,7 +110,7 @@ global.aktualGas[0] = Air; global.lifeData.actualGas = global.aktualGas[0]; - const uint8_t button_standard_sensitivity = ((2400-( 90 *24))/10)+15; + const uint8_t button_standard_sensitivity = ((2400-( 40 *24))/10)+15; global.ButtonResponsiveness[0] = button_standard_sensitivity; global.ButtonResponsiveness[1] = button_standard_sensitivity; global.ButtonResponsiveness[2] = button_standard_sensitivity; @@ -181,46 +181,8 @@ void scheduleSpecial_Evaluate_DataSendToSlave(void) { - - /* for device data updates */ - deviceDataFlashValid = 0; - memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice)); - - //TODO: (kittz) split by current mode. - - // new hw 170523 - if(global.I2C_SystemStatus != HAL_OK) - { - MX_I2C1_TestAndClear(); - MX_I2C1_Init(); - if(!is_init_pressure_done()) - { - init_pressure(); - } - } - - pressure_update(); - copyPressureData(); - compass_read(); - acceleration_read(); - compass_calc(); - battery_gas_gauge_get_data(); - copyCompassData(); - - copyCnsAndOtuData(); - copyTimeData(); - copyBatteryData(); - copyDeviceData(); - copyVpmCrushingData(); - - deviceDataFlashValid = 1; - scheduleUpdateDeviceData(); - - - - -// global.dataSendToSlavePending = 0; -// if(!global.dataSendToSlaveIsValid) return; //TODO: WHAT THE FUCK?????!!!!! + global.dataSendToSlavePending = 0; + if(!global.dataSendToSlaveIsValid) return; global.dataSendToMaster.confirmRequest.uw = 0; @@ -303,7 +265,10 @@ /* for simulation / testing */ global.ceiling_from_main_CPU_mbar = global.dataSendToSlave.data.ambient_pressure_mbar_ceiling; - + /* for device data updates */ + deviceDataFlashValid = 0; + memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice)); + deviceDataFlashValid = 1; } @@ -511,8 +476,8 @@ if(ticksdiff >= counterPressure100msec * 100 + 20) { global.check_sync_not_running++; -// pressure_update(); -// scheduleUpdateDeviceData(); + pressure_update(); + scheduleUpdateDeviceData(); if(global.demo_mode) { turbo_seconds = demo_modify_temperature_and_pressure(global.lifeData.dive_time_seconds, counterPressure100msec, global.ceiling_from_main_CPU_mbar); @@ -543,16 +508,16 @@ // if(global.demo_mode) // global.lifeData.ascent_rate_meter_per_min /= 4; } -// copyPressureData(); + copyPressureData(); counterPressure100msec++; } //evaluate compass data at 50 ms, 150 ms, 250 ms,.... if(ticksdiff >= counterCompass100msec * 100 + 50) { -// compass_read(); -// acceleration_read(); -// compass_calc(); -// copyCompassData(); + compass_read(); + acceleration_read(); + compass_calc(); + copyCompassData(); counterCompass100msec++; } @@ -580,7 +545,7 @@ global.lifeData.ppO2 = decom_calc_ppO2(global.lifeData.pressure_ambient_bar, &global.lifeData.actualGas); decom_oxygen_calculate_cns(&global.lifeData.cns,global.lifeData.ppO2); decom_oxygen_calculate_otu(&global.lifeData.otu,global.lifeData.ppO2); -// battery_gas_gauge_get_data(); + battery_gas_gauge_get_data(); /** counter_exit allows safe exit via button for testing @@ -652,21 +617,21 @@ } } // standard dive or DIVEMODE_Apnea -// copyVpmCrushingData(); -// copyTimeData(); -// copyCnsAndOtuData(); -// copyBatteryData(); + copyVpmCrushingData(); + copyTimeData(); + copyCnsAndOtuData(); + copyBatteryData(); -// // new hw 170523 -// if(global.I2C_SystemStatus != HAL_OK) -// { -// MX_I2C1_TestAndClear(); -// MX_I2C1_Init(); -// if(!is_init_pressure_done()) -// { -// init_pressure(); -// } -// } + // new hw 170523 + if(global.I2C_SystemStatus != HAL_OK) + { + MX_I2C1_TestAndClear(); + MX_I2C1_Init(); + if(!is_init_pressure_done()) + { + init_pressure(); + } + } counterCompass100msec = 0; counterPressure100msec = 0; @@ -721,10 +686,10 @@ { global.check_sync_not_running++; -//pressure_update(); -//scheduleUpdateDeviceData(); +pressure_update(); +scheduleUpdateDeviceData(); global.lifeData.ascent_rate_meter_per_min = 0; -//copyPressureData(); +copyPressureData(); if(temperature_carousel > 20.0f) { @@ -803,10 +768,10 @@ if(ticksdiff >= counterPressure100msec * 100 + 20) { global.check_sync_not_running++; -// pressure_update(); -// scheduleUpdateDeviceData(); + pressure_update(); + scheduleUpdateDeviceData(); global.lifeData.ascent_rate_meter_per_min = 0; -// copyPressureData(); + copyPressureData(); counterPressure100msec++; if(scheduleCheck_pressure_reached_dive_mode_level()) @@ -817,10 +782,10 @@ if(ticksdiff >= counterCompass100msec * 100 + 50) { -// compass_read(); -// acceleration_read(); -// compass_calc(); -// copyCompassData(); + compass_read(); + acceleration_read(); + compass_calc(); + copyCompassData(); counterCompass100msec++; } @@ -873,23 +838,23 @@ decom_oxygen_calculate_cns_degrade(&global.lifeData.cns, global.seconds_since_last_dive); global.lifeData.desaturation_time_minutes = decom_calc_desaturation_time(global.lifeData.tissue_nitrogen_bar,global.lifeData.tissue_helium_bar,global.lifeData.pressure_surface_bar); battery_charger_get_status_and_contral_battery_gas_gauge(0); -// battery_gas_gauge_get_data(); + battery_gas_gauge_get_data(); -// copyCnsAndOtuData(); -// copyTimeData(); -// copyBatteryData(); -// copyDeviceData(); + copyCnsAndOtuData(); + copyTimeData(); + copyBatteryData(); + copyDeviceData(); -// // new hw 170523 -// if(global.I2C_SystemStatus != HAL_OK) -// { -// MX_I2C1_TestAndClear(); -// MX_I2C1_Init(); -// if(!is_init_pressure_done()) -// { -// init_pressure(); -// } -// } + // new hw 170523 + if(global.I2C_SystemStatus != HAL_OK) + { + MX_I2C1_TestAndClear(); + MX_I2C1_Init(); + if(!is_init_pressure_done()) + { + init_pressure(); + } + } counterCompass100msec = 0; counterPressure100msec = 0; @@ -1186,27 +1151,27 @@ if(temperature_centigrad_int32 < global.deviceData.temperatureMinimum.value_int32) { global.deviceData.temperatureMinimum.value_int32 = temperature_centigrad_int32; - /*Last_change_time?*/ scheduleSetDate(&global.deviceData.temperatureMinimum); + scheduleSetDate(&global.deviceData.temperatureMinimum); } if(temperature_centigrad_int32 > global.deviceData.temperatureMaximum.value_int32) { global.deviceData.temperatureMaximum.value_int32 = temperature_centigrad_int32; - /*Last_change_time?*/ scheduleSetDate(&global.deviceData.temperatureMaximum); + scheduleSetDate(&global.deviceData.temperatureMaximum); } pressure_mbar_int32 = (int32_t)get_pressure_mbar(); if(pressure_mbar_int32 > global.deviceData.depthMaximum.value_int32) { global.deviceData.depthMaximum.value_int32 = pressure_mbar_int32; - /*Last_change_time?*/ scheduleSetDate(&global.deviceData.depthMaximum); + scheduleSetDate(&global.deviceData.depthMaximum); } voltage_mvolt_int32 = (int32_t)(get_voltage() * 1000); if(voltage_mvolt_int32 < global.deviceData.voltageMinimum.value_int32) { global.deviceData.voltageMinimum.value_int32 = voltage_mvolt_int32; - /*Last_change_time?*/ scheduleSetDate(&global.deviceData.voltageMinimum); + scheduleSetDate(&global.deviceData.voltageMinimum); } /* third step, counter */ @@ -1233,14 +1198,14 @@ void scheduleUpdateDeviceDataChargerFull(void) { global.deviceData.batteryChargeCompleteCycles.value_int32++; - /*Last_change_time?*/ scheduleSetDate(&global.deviceData.batteryChargeCompleteCycles); + scheduleSetDate(&global.deviceData.batteryChargeCompleteCycles); } void scheduleUpdateDeviceDataChargerCharging(void) { global.deviceData.batteryChargeCycles.value_int32++; - /*Last_change_time?*/ scheduleSetDate(&global.deviceData.batteryChargeCycles); + scheduleSetDate(&global.deviceData.batteryChargeCycles); } diff -r e746bf846638 -r 3db7389d49cc Small_CPU/Src/spi.c --- a/Small_CPU/Src/spi.c Wed Nov 21 13:57:58 2018 +0300 +++ b/Small_CPU/Src/spi.c Thu Nov 22 12:02:55 2018 +0300 @@ -140,7 +140,7 @@ hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; hspi1.Init.NSS = SPI_NSS_HARD_INPUT;//SPI_NSS_SOFT; - hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; + hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi1.Init.TIMode = SPI_TIMODE_DISABLED; hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;//_DISABLED; _ENABLED; @@ -188,7 +188,7 @@ hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; hdma_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; hdma_tx.Init.Mode = DMA_NORMAL; - hdma_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_tx.Init.Priority = DMA_PRIORITY_LOW; hdma_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; hdma_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; hdma_tx.Init.MemBurst = DMA_MBURST_INC4; @@ -369,11 +369,10 @@ } global.dataSendToMaster.power_on_reset = 0; global.deviceDataSendToMaster.power_on_reset = 0; -// if(global.dataUpdateIsNeeded) -// { - scheduleSpecial_Evaluate_DataSendToSlave(); -// global.dataUpdateIsNeeded=0; -// } + if(!global.dataSendToSlaveStopEval) + { + scheduleSpecial_Evaluate_DataSendToSlave(); + } SPI_Start_single_TxRx_with_Master(); } } diff -r e746bf846638 -r 3db7389d49cc ostc4pack/OSTC4_Firmware.bin Binary file ostc4pack/OSTC4_Firmware.bin has changed diff -r e746bf846638 -r 3db7389d49cc ostc4pack/OSTC4_RTE.bin Binary file ostc4pack/OSTC4_RTE.bin has changed diff -r e746bf846638 -r 3db7389d49cc ostc4pack/OSTC4_RTE_upload.bin Binary file ostc4pack/OSTC4_RTE_upload.bin has changed diff -r e746bf846638 -r 3db7389d49cc ostc4pack/OSTC4_firmware_upload.bin Binary file ostc4pack/OSTC4_firmware_upload.bin has changed