Mercurial > public > ostc4
comparison Small_CPU/Src/scheduler.c @ 142:69f4b8067daa FlipDisplay
Use one global structure for all schedule counters
Moved SPI data handling from callback to cyclic 10ms slot
author | Ideenmodellierer |
---|---|
date | Thu, 28 Feb 2019 19:34:08 +0100 |
parents | 5df4f1a315cb |
children | ee744c7160ce |
comparison
equal
deleted
inserted
replaced
141:30d855ea60d8 | 142:69f4b8067daa |
---|---|
64 uint8_t clearDecoNow = 0; | 64 uint8_t clearDecoNow = 0; |
65 uint8_t setButtonsNow = 0; | 65 uint8_t setButtonsNow = 0; |
66 | 66 |
67 /* has to be in SRAM2 */ | 67 /* has to be in SRAM2 */ |
68 uint8_t secondsCount = 0; | 68 uint8_t secondsCount = 0; |
69 | |
70 SScheduleCtrl Scheduler; | |
69 | 71 |
70 /* Private function prototypes -----------------------------------------------*/ | 72 /* Private function prototypes -----------------------------------------------*/ |
71 | 73 |
72 _Bool vpm_crush2(void); | 74 _Bool vpm_crush2(void); |
73 void scheduleUpdateDeviceData(void); | 75 void scheduleUpdateDeviceData(void); |
93 uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow); | 95 uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow); |
94 | 96 |
95 _Bool scheduleCheck_pressure_reached_dive_mode_level(void); | 97 _Bool scheduleCheck_pressure_reached_dive_mode_level(void); |
96 void scheduleSetDate(SDeviceLine *line); | 98 void scheduleSetDate(SDeviceLine *line); |
97 | 99 |
100 extern void SPI_Evaluate_RX_Data(); | |
98 /* Exported functions --------------------------------------------------------*/ | 101 /* Exported functions --------------------------------------------------------*/ |
99 | 102 |
100 void initGlobals(void) | 103 void initGlobals(void) |
101 { | 104 { |
102 initStructWithZeero((uint8_t*) &global, sizeof(SGlobal)); | 105 initStructWithZeero((uint8_t*) &global, sizeof(SGlobal)); |
425 */ | 428 */ |
426 | 429 |
427 void schedule_check_resync(void) | 430 void schedule_check_resync(void) |
428 { | 431 { |
429 //TODO: REMOVE | 432 //TODO: REMOVE |
430 if((global.check_sync_not_running >= 3)) | 433 if((global.check_sync_not_running >= 2)) |
431 { | 434 { |
432 // global.dataSendToSlaveIsNotValidCount = 0; | 435 // global.dataSendToSlaveIsNotValidCount = 0; |
433 global.check_sync_not_running = 0; | 436 global.check_sync_not_running = 0; |
434 global.sync_error_count++; | 437 global.sync_error_count++; |
435 | 438 |
449 * @date 22-April-2014 | 452 * @date 22-April-2014 |
450 ****************************************************************************** | 453 ****************************************************************************** |
451 */ | 454 */ |
452 void scheduleDiveMode(void) | 455 void scheduleDiveMode(void) |
453 { | 456 { |
454 uint32_t tickstart = 0; | 457 // uint32_t tickstart = 0; |
455 uint32_t ticksdiff = 0; | 458 uint32_t ticksdiff = 0; |
456 uint32_t lasttick = 0; | 459 uint32_t lasttick = 0; |
457 tickstart = HAL_GetTick(); | 460 |
458 uint8_t counterPressure100msec = 0; | |
459 uint8_t counterCompass100msec = 0; | |
460 uint8_t counterAmbientLight100msec = 0; | |
461 uint16_t counterWireless1msec = 0; | |
462 // uint8_t counterDemo250msec = 0; | |
463 uint32_t turbo_seconds = 0; | 461 uint32_t turbo_seconds = 0; |
464 uint8_t counterAscentRate = 0; | 462 uint8_t counterAscentRate = 0; |
465 float lastPressure_bar = 0.0f; | 463 float lastPressure_bar = 0.0f; |
466 global.dataSendToMaster.mode = MODE_DIVE; | 464 global.dataSendToMaster.mode = MODE_DIVE; |
467 global.deviceDataSendToMaster.mode = MODE_DIVE; | 465 global.deviceDataSendToMaster.mode = MODE_DIVE; |
468 //uint16_t counterSecondsShallowDepth = 0; | 466 //uint16_t counterSecondsShallowDepth = 0; |
469 uint8_t counter_exit = 0; | 467 uint8_t counter_exit = 0; |
470 | 468 |
471 tickstart = HAL_GetTick() - 1000; | 469 Scheduler.tickstart = HAL_GetTick() - 1000; |
470 Scheduler.counterSPIdata100msec = 0; | |
471 Scheduler.counterCompass100msec = 0; | |
472 Scheduler.counterPressure100msec = 0; | |
473 Scheduler.counterAmbientLight100msec = 0; | |
474 Scheduler.counterWireless1msec = 0; | |
472 | 475 |
473 global.deviceData.diveCycles.value_int32++; | 476 global.deviceData.diveCycles.value_int32++; |
474 scheduleSetDate(&global.deviceData.diveCycles); | 477 scheduleSetDate(&global.deviceData.diveCycles); |
475 global.lifeData.counterSecondsShallowDepth = 0; | 478 global.lifeData.counterSecondsShallowDepth = 0; |
476 | 479 |
477 while(global.mode == MODE_DIVE) | 480 while(global.mode == MODE_DIVE) |
478 { | 481 { |
479 schedule_check_resync(); | 482 schedule_check_resync(); |
480 lasttick = HAL_GetTick(); | 483 lasttick = HAL_GetTick(); |
481 ticksdiff = time_elapsed_ms(tickstart,lasttick); | 484 ticksdiff = time_elapsed_ms(Scheduler.tickstart,lasttick); |
482 | 485 |
483 | 486 |
484 //Evaluate wireless data every ms, if present | 487 //Evaluate wireless data every ms, if present |
485 if(ticksdiff > counterWireless1msec) | 488 if(ticksdiff > Scheduler.counterWireless1msec) |
486 { | 489 { |
487 counterWireless1msec++; | 490 Scheduler.counterWireless1msec++; |
488 changeAgeWirelessData(); | 491 changeAgeWirelessData(); |
489 global.wirelessReceived = wireless_evaluate(global.wirelessdata,MAX_WIRELESS_BYTES, &global.wirelessConfidenceStatus); | 492 global.wirelessReceived = wireless_evaluate(global.wirelessdata,MAX_WIRELESS_BYTES, &global.wirelessConfidenceStatus); |
490 if((global.wirelessReceived > 0) && !wireless_evaluate_crc_error(global.wirelessdata,global.wirelessReceived)) | 493 if((global.wirelessReceived > 0) && !wireless_evaluate_crc_error(global.wirelessdata,global.wirelessReceived)) |
491 { | 494 { |
492 copyWirelessData(); | 495 copyWirelessData(); |
493 } | 496 } |
494 } | 497 } |
495 | 498 |
499 if(ticksdiff >= Scheduler.counterSPIdata100msec * 100 + 10) | |
500 { | |
501 SPI_Evaluate_RX_Data(); | |
502 Scheduler.counterSPIdata100msec++; | |
503 } | |
504 | |
496 //Evaluate pressure at 20 ms, 120 ms, 220 ms,.... | 505 //Evaluate pressure at 20 ms, 120 ms, 220 ms,.... |
497 if(ticksdiff >= counterPressure100msec * 100 + 20) | 506 if(ticksdiff >= Scheduler.counterPressure100msec * 100 + 20) |
498 { | 507 { |
499 global.check_sync_not_running++; | 508 global.check_sync_not_running++; |
500 pressure_update(); | 509 pressure_update(); |
501 scheduleUpdateDeviceData(); | 510 scheduleUpdateDeviceData(); |
502 if(global.demo_mode) | 511 if(global.demo_mode) |
503 { | 512 { |
504 turbo_seconds = demo_modify_temperature_and_pressure(global.lifeData.dive_time_seconds, counterPressure100msec, global.ceiling_from_main_CPU_mbar); | 513 turbo_seconds = demo_modify_temperature_and_pressure(global.lifeData.dive_time_seconds, Scheduler.counterPressure100msec, global.ceiling_from_main_CPU_mbar); |
505 if(turbo_seconds) | 514 if(turbo_seconds) |
506 { | 515 { |
507 global.lifeData.dive_time_seconds += turbo_seconds; | 516 global.lifeData.dive_time_seconds += turbo_seconds; |
508 decom_tissues_exposure((int)(turbo_seconds), &global.lifeData); | 517 decom_tissues_exposure((int)(turbo_seconds), &global.lifeData); |
509 copyTissueData(); | 518 copyTissueData(); |
523 //2 seconds * 30 == 1 minute, bar * 10 = meter | 532 //2 seconds * 30 == 1 minute, bar * 10 = meter |
524 global.lifeData.ascent_rate_meter_per_min = (lastPressure_bar - global.lifeData.pressure_ambient_bar) * 30 * 10; | 533 global.lifeData.ascent_rate_meter_per_min = (lastPressure_bar - global.lifeData.pressure_ambient_bar) * 30 * 10; |
525 } | 534 } |
526 lastPressure_bar = global.lifeData.pressure_ambient_bar; | 535 lastPressure_bar = global.lifeData.pressure_ambient_bar; |
527 counterAscentRate = 0; | 536 counterAscentRate = 0; |
528 | |
529 // if(global.demo_mode) | |
530 // global.lifeData.ascent_rate_meter_per_min /= 4; | |
531 } | 537 } |
532 copyPressureData(); | 538 copyPressureData(); |
533 counterPressure100msec++; | 539 Scheduler.counterPressure100msec++; |
534 } | 540 } |
535 //evaluate compass data at 50 ms, 150 ms, 250 ms,.... | 541 //evaluate compass data at 50 ms, 150 ms, 250 ms,.... |
536 if(ticksdiff >= counterCompass100msec * 100 + 50) | 542 if(ticksdiff >= Scheduler.counterCompass100msec * 100 + 50) |
537 { | 543 { |
538 compass_read(); | 544 compass_read(); |
539 acceleration_read(); | 545 acceleration_read(); |
540 compass_calc(); | 546 compass_calc(); |
541 copyCompassData(); | 547 copyCompassData(); |
542 counterCompass100msec++; | 548 Scheduler.counterCompass100msec++; |
543 } | 549 } |
544 | 550 |
545 if(ticksdiff >= counterAmbientLight100msec * 100 + 70) | 551 if(ticksdiff >= Scheduler.counterAmbientLight100msec * 100 + 70) |
546 { | 552 { |
547 adc_ambient_light_sensor_get_data(); | 553 adc_ambient_light_sensor_get_data(); |
548 copyAmbientLightData(); | 554 copyAmbientLightData(); |
549 counterAmbientLight100msec++; | 555 Scheduler.counterAmbientLight100msec++; |
550 } | 556 } |
551 | 557 |
552 /* if(global.demo_mode && (ticksdiff >= counterDemo250msec * 250 + 10)) | |
553 { | |
554 global.lifeData.dive_time_seconds++; | |
555 copyTimeData(); | |
556 counterDemo250msec++; | |
557 } | |
558 */ | |
559 //Evaluate tissues, toxic data, vpm, etc. once a second | 558 //Evaluate tissues, toxic data, vpm, etc. once a second |
560 if(ticksdiff >= 1000) | 559 if(ticksdiff >= 1000) |
561 { | 560 { |
561 /* reset counter */ | |
562 Scheduler.tickstart = HAL_GetTick(); | |
563 | |
562 if(global.dataSendToSlave.diveModeInfo != DIVEMODE_Apnea) | 564 if(global.dataSendToSlave.diveModeInfo != DIVEMODE_Apnea) |
563 { | 565 { |
564 scheduleUpdateLifeData(0); // includes tissues | 566 scheduleUpdateLifeData(0); // includes tissues |
565 global.lifeData.dive_time_seconds++; // there is dive_time_seconds_without_surface_time too | 567 global.lifeData.dive_time_seconds++; // there is dive_time_seconds_without_surface_time too |
566 global.lifeData.ppO2 = decom_calc_ppO2(global.lifeData.pressure_ambient_bar, &global.lifeData.actualGas); | 568 global.lifeData.ppO2 = decom_calc_ppO2(global.lifeData.pressure_ambient_bar, &global.lifeData.actualGas); |
651 if(!is_init_pressure_done()) | 653 if(!is_init_pressure_done()) |
652 { | 654 { |
653 init_pressure(); | 655 init_pressure(); |
654 } | 656 } |
655 } | 657 } |
656 | 658 Scheduler.counterSPIdata100msec = 0; |
657 counterCompass100msec = 0; | 659 Scheduler.counterCompass100msec = 0; |
658 counterPressure100msec = 0; | 660 Scheduler.counterPressure100msec = 0; |
659 counterAmbientLight100msec = 0; | 661 Scheduler.counterAmbientLight100msec = 0; |
660 counterWireless1msec = 0; | 662 Scheduler.counterWireless1msec = 0; |
661 // counterDemo250msec = 0; | |
662 | |
663 /** keep it in rhythm, do not drop the execution time | |
664 * therefore do not use tickstart = HAL_GetTick(); | |
665 * here | |
666 */ | |
667 tickstart += 1000; | |
668 } | 663 } |
669 } | 664 } |
670 } | 665 } |
671 | 666 |
672 | 667 |
684 // scheduleTestMode | 679 // scheduleTestMode |
685 /// @brief included for sealed hardware with permanent RTE update message | 680 /// @brief included for sealed hardware with permanent RTE update message |
686 // =============================================================================== | 681 // =============================================================================== |
687 void scheduleTestMode(void) | 682 void scheduleTestMode(void) |
688 { | 683 { |
689 uint32_t tickstart = 0; | |
690 uint32_t ticksdiff = 0; | 684 uint32_t ticksdiff = 0; |
691 uint32_t lasttick = 0; | 685 uint32_t lasttick = 0; |
692 tickstart = HAL_GetTick(); | 686 Scheduler.tickstart = HAL_GetTick(); |
693 | 687 |
694 uint8_t counterPressure100msec = 0; | 688 Scheduler.counterPressure100msec = 0; |
695 | 689 |
696 float temperature_carousel = 0.0f; | 690 float temperature_carousel = 0.0f; |
697 float temperature_changer = 0.1f; | 691 float temperature_changer = 0.1f; |
698 | 692 |
699 while(global.mode == MODE_TEST) | 693 while(global.mode == MODE_TEST) |
700 { | 694 { |
701 schedule_check_resync(); | 695 schedule_check_resync(); |
702 lasttick = HAL_GetTick(); | 696 lasttick = HAL_GetTick(); |
703 ticksdiff = time_elapsed_ms(tickstart,lasttick); | 697 ticksdiff = time_elapsed_ms(Scheduler.tickstart,lasttick); |
698 | |
699 //Evaluate received data at 10 ms, 110 ms, 210 ms,... | |
700 if(ticksdiff >= Scheduler.counterSPIdata100msec * 100 + 10) | |
701 { | |
702 SPI_Evaluate_RX_Data(); | |
703 Scheduler.counterSPIdata100msec++; | |
704 } | |
704 | 705 |
705 //Evaluate pressure at 20 ms, 120 ms, 220 ms,... | 706 //Evaluate pressure at 20 ms, 120 ms, 220 ms,... |
706 if(ticksdiff >= counterPressure100msec * 100 + 20) | 707 if(ticksdiff >= Scheduler.counterPressure100msec * 100 + 20) |
707 { | 708 { |
708 global.check_sync_not_running++; | 709 global.check_sync_not_running++; |
709 | 710 |
710 pressure_update(); | 711 pressure_update(); |
711 scheduleUpdateDeviceData(); | 712 scheduleUpdateDeviceData(); |
712 global.lifeData.ascent_rate_meter_per_min = 0; | 713 global.lifeData.ascent_rate_meter_per_min = 0; |
713 copyPressureData(); | 714 copyPressureData(); |
714 | 715 |
715 if(temperature_carousel > 20.0f) | 716 if(temperature_carousel > 20.0f) |
716 { | 717 { |
717 temperature_carousel = 20.0f; | 718 temperature_carousel = 20.0f; |
718 temperature_changer = -0.1f; | 719 temperature_changer = -0.1f; |
726 | 727 |
727 temperature_carousel += temperature_changer; | 728 temperature_carousel += temperature_changer; |
728 | 729 |
729 uint8_t boolPressureData = !global.dataSendToMaster.boolPressureData; | 730 uint8_t boolPressureData = !global.dataSendToMaster.boolPressureData; |
730 | 731 |
731 global.dataSendToMaster.data[boolPressureData].pressure_mbar = get_pressure_mbar(); | 732 global.dataSendToMaster.data[boolPressureData].pressure_mbar = get_pressure_mbar(); |
732 | 733 |
733 global.dataSendToMaster.data[boolPressureData].temperature = temperature_carousel; | 734 global.dataSendToMaster.data[boolPressureData].temperature = temperature_carousel; |
734 global.dataSendToMaster.data[boolPressureData].pressure_uTick = HAL_GetTick(); | 735 global.dataSendToMaster.data[boolPressureData].pressure_uTick = HAL_GetTick(); |
735 global.dataSendToMaster.boolPressureData = boolPressureData; | 736 global.dataSendToMaster.boolPressureData = boolPressureData; |
736 | 737 Scheduler.counterPressure100msec++; |
737 | |
738 counterPressure100msec++; | |
739 } | 738 } |
740 | 739 |
741 if(ticksdiff >= 1000) | 740 if(ticksdiff >= 1000) |
742 { | 741 { |
743 //Set back tick counter | 742 //Set back tick counter |
744 tickstart = HAL_GetTick(); | 743 Scheduler.tickstart = HAL_GetTick(); |
745 counterPressure100msec = 0; | 744 Scheduler.counterPressure100msec = 0; |
745 Scheduler.counterSPIdata100msec = 0; | |
746 } | 746 } |
747 }; | 747 }; |
748 } | 748 } |
749 | 749 |
750 | 750 |
751 | |
752 | |
751 void scheduleSurfaceMode(void) | 753 void scheduleSurfaceMode(void) |
752 { | 754 { |
753 uint32_t tickstart = 0; | 755 |
754 uint32_t ticksdiff = 0; | 756 uint32_t ticksdiff = 0; |
755 uint32_t lasttick = 0; | 757 uint32_t lasttick = 0; |
756 tickstart = HAL_GetTick(); | 758 Scheduler.tickstart = HAL_GetTick(); |
757 uint8_t counterPressure100msec = 0; | 759 Scheduler.counterSPIdata100msec = 0; |
758 uint8_t counterCompass100msec = 0; | 760 Scheduler.counterCompass100msec = 0; |
759 uint8_t counterAmbientLight100msec = 0; | 761 Scheduler.counterPressure100msec = 0; |
760 uint16_t counterWireless1msec = 0; | 762 Scheduler.counterAmbientLight100msec = 0; |
763 Scheduler.counterWireless1msec = 0; | |
764 | |
761 global.dataSendToMaster.mode = MODE_SURFACE; | 765 global.dataSendToMaster.mode = MODE_SURFACE; |
762 global.deviceDataSendToMaster.mode = MODE_SURFACE; | 766 global.deviceDataSendToMaster.mode = MODE_SURFACE; |
763 | 767 |
764 while(global.mode == MODE_SURFACE) | 768 while(global.mode == MODE_SURFACE) |
765 { | 769 { |
766 /* printf("surface...\n"); */ | 770 /* printf("surface...\n"); */ |
767 // SPI_Start_single_TxRx_with_Master(); | 771 // SPI_Start_single_TxRx_with_Master(); |
768 schedule_check_resync(); | 772 schedule_check_resync(); |
769 lasttick = HAL_GetTick(); | 773 lasttick = HAL_GetTick(); |
770 ticksdiff = time_elapsed_ms(tickstart,lasttick); | 774 ticksdiff = time_elapsed_ms(Scheduler.tickstart,lasttick); |
771 | 775 |
772 if(ticksdiff > counterWireless1msec) | 776 if(ticksdiff > Scheduler.counterWireless1msec) |
773 { | 777 { |
774 counterWireless1msec++; | 778 Scheduler.counterWireless1msec++; |
775 changeAgeWirelessData(); | 779 changeAgeWirelessData(); |
776 global.wirelessReceived = wireless_evaluate(global.wirelessdata,MAX_WIRELESS_BYTES, &global.wirelessConfidenceStatus); | 780 global.wirelessReceived = wireless_evaluate(global.wirelessdata,MAX_WIRELESS_BYTES, &global.wirelessConfidenceStatus); |
777 if((global.wirelessReceived > 0) && !wireless_evaluate_crc_error(global.wirelessdata,global.wirelessReceived)) | 781 if((global.wirelessReceived > 0) && !wireless_evaluate_crc_error(global.wirelessdata,global.wirelessReceived)) |
778 { | 782 { |
779 copyWirelessData(); | 783 copyWirelessData(); |
783 { | 787 { |
784 if(scheduleSetButtonResponsiveness()) | 788 if(scheduleSetButtonResponsiveness()) |
785 setButtonsNow = 0; | 789 setButtonsNow = 0; |
786 } | 790 } |
787 | 791 |
792 | |
793 //Evaluate received data at 10 ms, 110 ms, 210 ms,... | |
794 if(ticksdiff >= Scheduler.counterSPIdata100msec * 100 + 10) | |
795 { | |
796 SPI_Evaluate_RX_Data(); | |
797 Scheduler.counterSPIdata100msec++; | |
798 } | |
799 | |
788 //Evaluate pressure at 20 ms, 120 ms, 220 ms,... | 800 //Evaluate pressure at 20 ms, 120 ms, 220 ms,... |
789 if(ticksdiff >= counterPressure100msec * 100 + 20) | 801 if(ticksdiff >= Scheduler.counterPressure100msec * 100 + 20) |
790 { | 802 { |
791 global.check_sync_not_running++; | 803 global.check_sync_not_running++; |
792 pressure_update(); | 804 pressure_update(); |
793 scheduleUpdateDeviceData(); | 805 scheduleUpdateDeviceData(); |
794 global.lifeData.ascent_rate_meter_per_min = 0; | 806 global.lifeData.ascent_rate_meter_per_min = 0; |
795 copyPressureData(); | 807 copyPressureData(); |
796 counterPressure100msec++; | 808 Scheduler.counterPressure100msec++; |
797 | 809 |
798 if(scheduleCheck_pressure_reached_dive_mode_level()) | 810 if(scheduleCheck_pressure_reached_dive_mode_level()) |
799 global.mode = MODE_DIVE; | 811 global.mode = MODE_DIVE; |
800 } | 812 } |
801 | 813 |
802 //evaluate compass data at 50 ms, 150 ms, 250 ms,... | 814 //evaluate compass data at 50 ms, 150 ms, 250 ms,... |
803 | 815 |
804 if(ticksdiff >= counterCompass100msec * 100 + 50) | 816 if(ticksdiff >= Scheduler.counterCompass100msec * 100 + 50) |
805 { | 817 { |
806 compass_read(); | 818 compass_read(); |
807 acceleration_read(); | 819 acceleration_read(); |
808 compass_calc(); | 820 compass_calc(); |
809 copyCompassData(); | 821 copyCompassData(); |
810 counterCompass100msec++; | 822 Scheduler.counterCompass100msec++; |
811 } | 823 } |
812 | 824 |
813 //evaluate compass data at 70 ms, 170 ms, 270 ms,... | 825 //evaluate compass data at 70 ms, 170 ms, 270 ms,... |
814 if(ticksdiff >= counterAmbientLight100msec * 100 + 70) | 826 if(ticksdiff >= Scheduler.counterAmbientLight100msec * 100 + 70) |
815 { | 827 { |
816 adc_ambient_light_sensor_get_data(); | 828 adc_ambient_light_sensor_get_data(); |
817 copyAmbientLightData(); | 829 copyAmbientLightData(); |
818 counterAmbientLight100msec++; | 830 Scheduler.counterAmbientLight100msec++; |
819 } | 831 } |
820 //Evaluate tissues, toxic data, etc. once a second | 832 //Evaluate tissues, toxic data, etc. once a second |
821 if(ticksdiff >= 1000) | 833 if(ticksdiff >= 1000) |
822 { | 834 { |
835 //Set back tick counter | |
836 Scheduler.tickstart = HAL_GetTick(); | |
837 | |
823 if(clearDecoNow) | 838 if(clearDecoNow) |
824 { | 839 { |
825 decom_reset_with_1000mbar(&global.lifeData); ///< this should almost reset desaturation time | 840 decom_reset_with_1000mbar(&global.lifeData); ///< this should almost reset desaturation time |
826 // new 160215 hw | 841 // new 160215 hw |
827 global.repetitive_dive = 0; | 842 global.repetitive_dive = 0; |
830 global.accidentFlag = 0; | 845 global.accidentFlag = 0; |
831 global.accidentRemainingSeconds = 0; | 846 global.accidentRemainingSeconds = 0; |
832 vpm_init(&global.vpm, global.conservatism, global.repetitive_dive, global.seconds_since_last_dive); | 847 vpm_init(&global.vpm, global.conservatism, global.repetitive_dive, global.seconds_since_last_dive); |
833 clearDecoNow = 0; | 848 clearDecoNow = 0; |
834 } | 849 } |
835 | |
836 //Set back tick counter | |
837 tickstart = HAL_GetTick(); | |
838 | |
839 | 850 |
840 if(global.seconds_since_last_dive) | 851 if(global.seconds_since_last_dive) |
841 { | 852 { |
842 schedule_update_timer_helper(-1); | 853 schedule_update_timer_helper(-1); |
843 // global.seconds_since_last_dive++; | 854 // global.seconds_since_last_dive++; |
883 if(!is_init_pressure_done()) | 894 if(!is_init_pressure_done()) |
884 { | 895 { |
885 init_pressure(); | 896 init_pressure(); |
886 } | 897 } |
887 } | 898 } |
888 | 899 Scheduler.counterSPIdata100msec = 0; |
889 counterCompass100msec = 0; | 900 Scheduler.counterCompass100msec = 0; |
890 counterPressure100msec = 0; | 901 Scheduler.counterPressure100msec = 0; |
891 counterAmbientLight100msec = 0; | 902 Scheduler.counterAmbientLight100msec = 0; |
892 counterWireless1msec = 0; | 903 Scheduler.counterWireless1msec = 0; |
893 } | 904 } |
894 } | 905 } |
895 } | 906 } |
896 | 907 static uint8_t dohardspisync = 1; |
908 | |
909 void HardSyncToSPI() | |
910 { | |
911 if(dohardspisync) | |
912 { | |
913 //Set back tick counter | |
914 Scheduler.tickstart = HAL_GetTick(); | |
915 Scheduler.counterSPIdata100msec = 0; | |
916 Scheduler.counterCompass100msec = 0; | |
917 Scheduler.counterPressure100msec = 0; | |
918 Scheduler.counterAmbientLight100msec = 0; | |
919 Scheduler.counterWireless1msec = 0; | |
920 dohardspisync = 0; | |
921 } | |
922 } | |
897 | 923 |
898 /** | 924 /** |
899 ****************************************************************************** | 925 ****************************************************************************** |
900 * @brief scheduleCompassCalibrationMode | 926 * @brief scheduleCompassCalibrationMode |
901 * @author heinrichs weikamp gmbh | 927 * @author heinrichs weikamp gmbh |