| 841 | |
| 842 | |
| 843 | void espInitInstrumentation(txMachine *the) |
| 844 | { |
| 845 | modInstrumentationInit(); |
| 846 | modInstrumentationSetCallback(SystemFreeMemory, modInstrumentationSystemFreeMemory); |
| 847 | |
| 848 | modInstrumentationSetCallback(SlotHeapSize, (ModInstrumentationGetter)modInstrumentationSlotHeapSize); |
| 849 | modInstrumentationSetCallback(ChunkHeapSize, (ModInstrumentationGetter)modInstrumentationChunkHeapSize); |
| 850 | modInstrumentationSetCallback(KeysUsed, (ModInstrumentationGetter)modInstrumentationKeysUsed); |
| 851 | modInstrumentationSetCallback(GarbageCollectionCount, (ModInstrumentationGetter)modInstrumentationGarbageCollectionCount); |
| 852 | modInstrumentationSetCallback(ModulesLoaded, (ModInstrumentationGetter)modInstrumentationModulesLoaded); |
| 853 | modInstrumentationSetCallback(StackRemain, (ModInstrumentationGetter)modInstrumentationStackRemain); |
| 854 | modInstrumentationSetCallback(PromisesSettledCount, (ModInstrumentationGetter)modInstrumentationPromisesSettledCount); |
| 855 | |
| 856 | #if INSTRUMENT_CPULOAD |
| 857 | modInstrumentationSetCallback(CPU0, modInstrumentationCPU0); |
| 858 | #if kTargetCPUCount > 1 |
| 859 | modInstrumentationSetCallback(CPU1, modInstrumentationCPU1); |
| 860 | #endif |
| 861 | /* |
| 862 | timer_config_t config = { |
| 863 | .divider = 16, |
| 864 | .counter_dir = TIMER_COUNT_UP, |
| 865 | .counter_en = TIMER_PAUSE, |
| 866 | .alarm_en = TIMER_ALARM_EN, |
| 867 | .auto_reload = 1, |
| 868 | }; |
| 869 | */ |
| 870 | gptimer_config_t config = { |
| 871 | .clk_src = GPTIMER_CLK_SRC_DEFAULT, |
| 872 | .direction = GPTIMER_COUNT_UP, |
| 873 | .resolution_hz = 1000 * 1000, // 1 tick = 1 us |
| 874 | }; |
| 875 | gptimer_alarm_config_t alarm = { |
| 876 | .reload_count = 0, |
| 877 | .alarm_count = 800, |
| 878 | .flags.auto_reload_on_alarm = true, |
| 879 | }; |
| 880 | gptimer_event_callbacks_t callbacks = { |
| 881 | .on_alarm = timer_group0_isr |
| 882 | }; |
| 883 | |
| 884 | gIdles[0] = xTaskGetIdleTaskHandleForCore(0); |
| 885 | #if kTargetCPUCount > 1 |
| 886 | gIdles[1] = xTaskGetIdleTaskHandleForCore(1); |
| 887 | #endif |
| 888 | |
| 889 | if (!gLoadTimer) { |
| 890 | gptimer_new_timer(&config, &gLoadTimer); |
| 891 | gptimer_set_alarm_action(gLoadTimer, &alarm); |
| 892 | gptimer_register_event_callbacks(gLoadTimer, &callbacks, NULL); |
| 893 | gptimer_enable(gLoadTimer); |
| 894 | gptimer_start(gLoadTimer); |
| 895 | } |
| 896 | |
| 897 | #endif |
| 898 | |
| 899 | #if ESP32 |
| 900 | if (!gInstrumentMutex) |
no test coverage detected