ukkonooa and frequency slider
This commit is contained in:
@@ -1,55 +1,34 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "driver/ledc.h"
|
||||
#include "hal/ledc_types.h"
|
||||
#include "soc/clk_tree_defs.h"
|
||||
#include "esp_clk_tree.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/FreeRTOS.h" // IWYU pragma: keep
|
||||
#include "freertos/projdefs.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
const char* TAG = "MAIN_CPP";
|
||||
#include "freq_slider.h"
|
||||
#include "un.h"
|
||||
|
||||
extern const uint32_t init_buzzer_freq;
|
||||
|
||||
const char* TAG = "MAIN_C";
|
||||
|
||||
|
||||
void app_main() {
|
||||
ESP_LOGI(TAG, "BOOT\n");
|
||||
ESP_LOGI(TAG, "BOOT");
|
||||
|
||||
const uint32_t timer_freq = 2731;
|
||||
// Only enable one task at a time.
|
||||
|
||||
uint32_t clk_freq = 0;
|
||||
ESP_ERROR_CHECK(esp_clk_tree_src_get_freq_hz(SOC_MOD_CLK_RC_FAST, ESP_CLK_TREE_SRC_FREQ_PRECISION_EXACT, &clk_freq));
|
||||
// if (xTaskCreate(freq_slider_task, "freq_slider_task", 4096, NULL, tskIDLE_PRIORITY,
|
||||
// NULL) == pdFALSE) {
|
||||
// ESP_LOGE(TAG, "Failed to create freq_slider_task.");
|
||||
// }
|
||||
|
||||
uint32_t duty_resolution = ledc_find_suitable_duty_resolution(clk_freq, timer_freq);
|
||||
if (duty_resolution == 0) {
|
||||
ESP_LOGE(TAG, "Could not determine optimal duty resolution.\n");
|
||||
return;
|
||||
if (xTaskCreate(un_task, "un_task", 4096, NULL, tskIDLE_PRIORITY,
|
||||
NULL) == pdFALSE) {
|
||||
ESP_LOGE(TAG, "Failed to create un_task.");
|
||||
}
|
||||
|
||||
ledc_timer_config_t ledc_config = {
|
||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.timer_num = LEDC_TIMER_0,
|
||||
.freq_hz = timer_freq,
|
||||
.duty_resolution = duty_resolution,
|
||||
.clk_cfg = LEDC_USE_RC_FAST_CLK
|
||||
};
|
||||
|
||||
ESP_ERROR_CHECK(ledc_timer_config(&ledc_config));
|
||||
|
||||
ledc_channel_config_t ledc_ch_config = {
|
||||
.gpio_num = 9,
|
||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.channel = LEDC_CHANNEL_0,
|
||||
.timer_sel = LEDC_TIMER_0,
|
||||
.duty = (uint32_t) (pow(2, duty_resolution) / 2),
|
||||
// .hpoint = ((uint32_t) pow(2, duty_resolution)) - 1,
|
||||
.hpoint = 0,
|
||||
.sleep_mode = LEDC_SLEEP_MODE_KEEP_ALIVE,
|
||||
.flags.output_invert = false
|
||||
};
|
||||
|
||||
ESP_ERROR_CHECK(ledc_channel_config(&ledc_ch_config));
|
||||
|
||||
while (true) {
|
||||
vTaskDelay(10000);
|
||||
vTaskDelay(pdMS_TO_TICKS(10000));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user