Mercurial > public > ostc4
changeset 85:923c4566a2a1 kittz
increased interCPU baudrate, cpu2: i2c in SPI1 IRQ
author | Dmitry Romanov <kitt@bk.ru> |
---|---|
date | Wed, 21 Nov 2018 12:49:54 +0300 |
parents | e6abbef57475 |
children | cc41b5eaf1a7 |
files | Discovery/Src/ostc.c Discovery/Src/settings.c Small_CPU/Src/scheduler.c Small_CPU/Src/spi.c ostc4pack/OSTC4_Firmware.bin ostc4pack/OSTC4_RTE.bin ostc4pack/OSTC4_RTE_upload.bin ostc4pack/OSTC4_firmware_upload.bin |
diffstat | 8 files changed, 72 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/Discovery/Src/ostc.c Wed Nov 21 10:25:15 2018 +0300 +++ b/Discovery/Src/ostc.c Wed Nov 21 12:49:54 2018 +0300 @@ -81,7 +81,7 @@ cpu2DmaSpi.Init.CLKPolarity = SPI_POLARITY_LOW; cpu2DmaSpi.Init.CLKPhase = SPI_PHASE_1EDGE; cpu2DmaSpi.Init.NSS = SPI_NSS_SOFT;//SPI_NSS_HARD_OUTPUT;//SPI_NSS_SOFT; - cpu2DmaSpi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; + cpu2DmaSpi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; cpu2DmaSpi.Init.FirstBit = SPI_FIRSTBIT_MSB; cpu2DmaSpi.Init.TIMode = SPI_TIMODE_DISABLED; cpu2DmaSpi.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
--- a/Discovery/Src/settings.c Wed Nov 21 10:25:15 2018 +0300 +++ b/Discovery/Src/settings.c Wed Nov 21 12:49:54 2018 +0300 @@ -55,7 +55,7 @@ { .versionFirst = 1, .versionSecond = 4, - .versionThird = 2, + .versionThird = 3, .versionBeta = 0, /* 4 bytes with trailing 0 */
--- a/Small_CPU/Src/scheduler.c Wed Nov 21 10:25:15 2018 +0300 +++ b/Small_CPU/Src/scheduler.c Wed Nov 21 12:49:54 2018 +0300 @@ -272,11 +272,35 @@ 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(); + scheduleUpdateDeviceData(); + + + deviceDataFlashValid = 1; } @@ -486,8 +510,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); @@ -518,16 +542,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++; } @@ -555,7 +579,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 @@ -632,16 +656,16 @@ // 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; @@ -696,10 +720,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) { @@ -778,10 +802,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()) @@ -792,10 +816,10 @@ if(ticksdiff >= counterCompass100msec * 100 + 50) { - compass_read(); - acceleration_read(); - compass_calc(); - copyCompassData(); +// compass_read(); +// acceleration_read(); +// compass_calc(); +// copyCompassData(); counterCompass100msec++; } @@ -848,23 +872,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(); - // 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;
--- a/Small_CPU/Src/spi.c Wed Nov 21 10:25:15 2018 +0300 +++ b/Small_CPU/Src/spi.c Wed Nov 21 12:49:54 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_128; + hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; 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_LOW; + hdma_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH; 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,11 @@ } global.dataSendToMaster.power_on_reset = 0; global.deviceDataSendToMaster.power_on_reset = 0; - if(global.dataUpdateIsNeeded) - { - scheduleSpecial_Evaluate_DataSendToSlave(); - global.dataUpdateIsNeeded=0; - } +// if(global.dataUpdateIsNeeded) +// { + scheduleSpecial_Evaluate_DataSendToSlave(); +// global.dataUpdateIsNeeded=0; +// } SPI_Start_single_TxRx_with_Master(); } }