comparison Small_CPU/Src/scheduler.c @ 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
comparison
equal deleted inserted replaced
84:e6abbef57475 85:923c4566a2a1
270 /* for device data updates */ 270 /* for device data updates */
271 deviceDataFlashValid = 0; 271 deviceDataFlashValid = 0;
272 memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice)); 272 memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice));
273 273
274 //TODO: (kittz) split by current mode. 274 //TODO: (kittz) split by current mode.
275
276 // new hw 170523
277 if(global.I2C_SystemStatus != HAL_OK)
278 {
279 MX_I2C1_TestAndClear();
280 MX_I2C1_Init();
281 if(!is_init_pressure_done())
282 {
283 init_pressure();
284 }
285 }
286
287 pressure_update();
288 copyPressureData();
289 compass_read();
290 acceleration_read();
291 compass_calc();
292 battery_gas_gauge_get_data();
293 copyCompassData();
294
275 copyCnsAndOtuData(); 295 copyCnsAndOtuData();
276 copyTimeData(); 296 copyTimeData();
277 copyBatteryData(); 297 copyBatteryData();
278 copyDeviceData(); 298 copyDeviceData();
279 copyVpmCrushingData(); 299 copyVpmCrushingData();
300 scheduleUpdateDeviceData();
301
302
303
280 304
281 deviceDataFlashValid = 1; 305 deviceDataFlashValid = 1;
282 } 306 }
283 307
284 308
484 508
485 //Evaluate pressure at 20 ms, 120 ms, 220 ms,.... 509 //Evaluate pressure at 20 ms, 120 ms, 220 ms,....
486 if(ticksdiff >= counterPressure100msec * 100 + 20) 510 if(ticksdiff >= counterPressure100msec * 100 + 20)
487 { 511 {
488 global.check_sync_not_running++; 512 global.check_sync_not_running++;
489 pressure_update(); 513 // pressure_update();
490 scheduleUpdateDeviceData(); 514 // scheduleUpdateDeviceData();
491 if(global.demo_mode) 515 if(global.demo_mode)
492 { 516 {
493 turbo_seconds = demo_modify_temperature_and_pressure(global.lifeData.dive_time_seconds, counterPressure100msec, global.ceiling_from_main_CPU_mbar); 517 turbo_seconds = demo_modify_temperature_and_pressure(global.lifeData.dive_time_seconds, counterPressure100msec, global.ceiling_from_main_CPU_mbar);
494 if(turbo_seconds) 518 if(turbo_seconds)
495 { 519 {
516 counterAscentRate = 0; 540 counterAscentRate = 0;
517 541
518 // if(global.demo_mode) 542 // if(global.demo_mode)
519 // global.lifeData.ascent_rate_meter_per_min /= 4; 543 // global.lifeData.ascent_rate_meter_per_min /= 4;
520 } 544 }
521 copyPressureData(); 545 // copyPressureData();
522 counterPressure100msec++; 546 counterPressure100msec++;
523 } 547 }
524 //evaluate compass data at 50 ms, 150 ms, 250 ms,.... 548 //evaluate compass data at 50 ms, 150 ms, 250 ms,....
525 if(ticksdiff >= counterCompass100msec * 100 + 50) 549 if(ticksdiff >= counterCompass100msec * 100 + 50)
526 { 550 {
527 compass_read(); 551 // compass_read();
528 acceleration_read(); 552 // acceleration_read();
529 compass_calc(); 553 // compass_calc();
530 copyCompassData(); 554 // copyCompassData();
531 counterCompass100msec++; 555 counterCompass100msec++;
532 } 556 }
533 557
534 if(ticksdiff >= counterAmbientLight100msec * 100 + 70) 558 if(ticksdiff >= counterAmbientLight100msec * 100 + 70)
535 { 559 {
553 scheduleUpdateLifeData(0); // includes tissues 577 scheduleUpdateLifeData(0); // includes tissues
554 global.lifeData.dive_time_seconds++; // there is dive_time_seconds_without_surface_time too 578 global.lifeData.dive_time_seconds++; // there is dive_time_seconds_without_surface_time too
555 global.lifeData.ppO2 = decom_calc_ppO2(global.lifeData.pressure_ambient_bar, &global.lifeData.actualGas); 579 global.lifeData.ppO2 = decom_calc_ppO2(global.lifeData.pressure_ambient_bar, &global.lifeData.actualGas);
556 decom_oxygen_calculate_cns(&global.lifeData.cns,global.lifeData.ppO2); 580 decom_oxygen_calculate_cns(&global.lifeData.cns,global.lifeData.ppO2);
557 decom_oxygen_calculate_otu(&global.lifeData.otu,global.lifeData.ppO2); 581 decom_oxygen_calculate_otu(&global.lifeData.otu,global.lifeData.ppO2);
558 battery_gas_gauge_get_data(); 582 // battery_gas_gauge_get_data();
559 583
560 584
561 /** counter_exit allows safe exit via button for testing 585 /** counter_exit allows safe exit via button for testing
562 * and demo_mode is exited too if aplicable. 586 * and demo_mode is exited too if aplicable.
563 */ 587 */
630 // copyVpmCrushingData(); 654 // copyVpmCrushingData();
631 // copyTimeData(); 655 // copyTimeData();
632 // copyCnsAndOtuData(); 656 // copyCnsAndOtuData();
633 // copyBatteryData(); 657 // copyBatteryData();
634 658
635 // new hw 170523 659 // // new hw 170523
636 if(global.I2C_SystemStatus != HAL_OK) 660 // if(global.I2C_SystemStatus != HAL_OK)
637 { 661 // {
638 MX_I2C1_TestAndClear(); 662 // MX_I2C1_TestAndClear();
639 MX_I2C1_Init(); 663 // MX_I2C1_Init();
640 if(!is_init_pressure_done()) 664 // if(!is_init_pressure_done())
641 { 665 // {
642 init_pressure(); 666 // init_pressure();
643 } 667 // }
644 } 668 // }
645 669
646 counterCompass100msec = 0; 670 counterCompass100msec = 0;
647 counterPressure100msec = 0; 671 counterPressure100msec = 0;
648 counterAmbientLight100msec = 0; 672 counterAmbientLight100msec = 0;
649 counterWireless1msec = 0; 673 counterWireless1msec = 0;
694 //Evaluate pressure at 20 ms, 120 ms, 220 ms,... 718 //Evaluate pressure at 20 ms, 120 ms, 220 ms,...
695 if(ticksdiff >= counterPressure100msec * 100 + 20) 719 if(ticksdiff >= counterPressure100msec * 100 + 20)
696 { 720 {
697 global.check_sync_not_running++; 721 global.check_sync_not_running++;
698 722
699 pressure_update(); 723 //pressure_update();
700 scheduleUpdateDeviceData(); 724 //scheduleUpdateDeviceData();
701 global.lifeData.ascent_rate_meter_per_min = 0; 725 global.lifeData.ascent_rate_meter_per_min = 0;
702 copyPressureData(); 726 //copyPressureData();
703 727
704 if(temperature_carousel > 20.0f) 728 if(temperature_carousel > 20.0f)
705 { 729 {
706 temperature_carousel = 20.0f; 730 temperature_carousel = 20.0f;
707 temperature_changer = -0.1f; 731 temperature_changer = -0.1f;
776 800
777 //Evaluate pressure at 20 ms, 120 ms, 220 ms,... 801 //Evaluate pressure at 20 ms, 120 ms, 220 ms,...
778 if(ticksdiff >= counterPressure100msec * 100 + 20) 802 if(ticksdiff >= counterPressure100msec * 100 + 20)
779 { 803 {
780 global.check_sync_not_running++; 804 global.check_sync_not_running++;
781 pressure_update(); 805 // pressure_update();
782 scheduleUpdateDeviceData(); 806 // scheduleUpdateDeviceData();
783 global.lifeData.ascent_rate_meter_per_min = 0; 807 global.lifeData.ascent_rate_meter_per_min = 0;
784 copyPressureData(); 808 // copyPressureData();
785 counterPressure100msec++; 809 counterPressure100msec++;
786 810
787 if(scheduleCheck_pressure_reached_dive_mode_level()) 811 if(scheduleCheck_pressure_reached_dive_mode_level())
788 global.mode = MODE_DIVE; 812 global.mode = MODE_DIVE;
789 } 813 }
790 814
791 //evaluate compass data at 50 ms, 150 ms, 250 ms,... 815 //evaluate compass data at 50 ms, 150 ms, 250 ms,...
792 816
793 if(ticksdiff >= counterCompass100msec * 100 + 50) 817 if(ticksdiff >= counterCompass100msec * 100 + 50)
794 { 818 {
795 compass_read(); 819 // compass_read();
796 acceleration_read(); 820 // acceleration_read();
797 compass_calc(); 821 // compass_calc();
798 copyCompassData(); 822 // copyCompassData();
799 counterCompass100msec++; 823 counterCompass100msec++;
800 } 824 }
801 825
802 //evaluate compass data at 70 ms, 170 ms, 270 ms,... 826 //evaluate compass data at 70 ms, 170 ms, 270 ms,...
803 if(ticksdiff >= counterAmbientLight100msec * 100 + 70) 827 if(ticksdiff >= counterAmbientLight100msec * 100 + 70)
846 scheduleUpdateLifeData(0); 870 scheduleUpdateLifeData(0);
847 decom_oxygen_calculate_otu_degrade(&global.lifeData.otu, global.seconds_since_last_dive); 871 decom_oxygen_calculate_otu_degrade(&global.lifeData.otu, global.seconds_since_last_dive);
848 decom_oxygen_calculate_cns_degrade(&global.lifeData.cns, global.seconds_since_last_dive); 872 decom_oxygen_calculate_cns_degrade(&global.lifeData.cns, global.seconds_since_last_dive);
849 global.lifeData.desaturation_time_minutes = decom_calc_desaturation_time(global.lifeData.tissue_nitrogen_bar,global.lifeData.tissue_helium_bar,global.lifeData.pressure_surface_bar); 873 global.lifeData.desaturation_time_minutes = decom_calc_desaturation_time(global.lifeData.tissue_nitrogen_bar,global.lifeData.tissue_helium_bar,global.lifeData.pressure_surface_bar);
850 battery_charger_get_status_and_contral_battery_gas_gauge(0); 874 battery_charger_get_status_and_contral_battery_gas_gauge(0);
851 battery_gas_gauge_get_data(); 875 // battery_gas_gauge_get_data();
852 876
853 // copyCnsAndOtuData(); 877 // copyCnsAndOtuData();
854 // copyTimeData(); 878 // copyTimeData();
855 // copyBatteryData(); 879 // copyBatteryData();
856 // copyDeviceData(); 880 // copyDeviceData();
857 881
858 // new hw 170523 882 // // new hw 170523
859 if(global.I2C_SystemStatus != HAL_OK) 883 // if(global.I2C_SystemStatus != HAL_OK)
860 { 884 // {
861 MX_I2C1_TestAndClear(); 885 // MX_I2C1_TestAndClear();
862 MX_I2C1_Init(); 886 // MX_I2C1_Init();
863 if(!is_init_pressure_done()) 887 // if(!is_init_pressure_done())
864 { 888 // {
865 init_pressure(); 889 // init_pressure();
866 } 890 // }
867 } 891 // }
868 892
869 counterCompass100msec = 0; 893 counterCompass100msec = 0;
870 counterPressure100msec = 0; 894 counterPressure100msec = 0;
871 counterAmbientLight100msec = 0; 895 counterAmbientLight100msec = 0;
872 counterWireless1msec = 0; 896 counterWireless1msec = 0;