mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-29 05:38:42 +00:00
examples: Standardise naming of files, symbols, etc. in examples
* Use "example" in all example function & variable names, ie use i2c_example_xxx instead of i2c_xxx for example functions. Closes #198 https://github.com/espressif/esp-idf/issues/198 * Mark example functions, etc. static * Replace uses of "test" & "demo" with "example" * Split the UART example into two * Rename "main" example files to end with "_main.c" for disambiguation
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/* Sigma-delta Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "driver/sigmadelta.h"
|
||||
|
||||
/*
|
||||
* This test code intended to configure sigma-delta and set GPIO4 as signal output pin.
|
||||
* If you connect this GPIO4 with an LED, you will see the LED blinking slowly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Sigma-delta initialization.
|
||||
*/
|
||||
static void sigmadelta_example_init(void)
|
||||
{
|
||||
sigmadelta_config_t sigmadelta_cfg = {
|
||||
/* Sigma-delta channel0*/
|
||||
.channel = SIGMADELTA_CHANNEL_0,
|
||||
/* Sigma-delta set duty 10*/
|
||||
.sigmadelta_duty = 10,
|
||||
/* Set prescale 30 */
|
||||
.sigmadelta_prescale = 80,
|
||||
/*select GPIO4 as output_io */
|
||||
.sigmadelta_gpio = 4,
|
||||
};
|
||||
sigmadelta_config(&sigmadelta_cfg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sigma-delta test to change duty of output signal.
|
||||
*/
|
||||
void app_main()
|
||||
{
|
||||
sigmadelta_example_init();
|
||||
int8_t duty = 0;
|
||||
int inc = 1;
|
||||
while(1) {
|
||||
sigmadelta_set_duty(SIGMADELTA_CHANNEL_0, duty);
|
||||
/*by changing delay time, you can change the blink frequency of LED. */
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
|
||||
duty += inc;
|
||||
if(duty == 127 || duty == -127) inc = (-1) * inc;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user