diff --git a/.gitmodules b/.gitmodules index 6790fd5..42230cf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,3 +34,6 @@ [submodule "extras/libesphttpd/libesphttpd/lib/heatshrink"] path = extras/libesphttpd/libesphttpd/lib/heatshrink url = https://github.com/atomicobject/heatshrink +[submodule "extras/new_pwm"] + path = extras/new_pwm + url = https://github.com/nochkin/new_pwm diff --git a/examples/new_pwm/Makefile b/examples/new_pwm/Makefile new file mode 100644 index 0000000..fe8b0bd --- /dev/null +++ b/examples/new_pwm/Makefile @@ -0,0 +1,4 @@ +# Simple makefile for simple example +PROGRAM = new_pwm +EXTRA_COMPONENTS = extras/new_pwm +include ../../common.mk diff --git a/examples/new_pwm/new_pwm.c b/examples/new_pwm/new_pwm.c new file mode 100644 index 0000000..678a585 --- /dev/null +++ b/examples/new_pwm/new_pwm.c @@ -0,0 +1,55 @@ +/* Very basic example to test the pwm library + * Hook up an LED to pin14 and you should see the intensity change + * + * Part of esp-open-rtos + * Copyright (C) 2015 Javier Cardona (https://github.com/jcard0na) + * BSD Licensed as described in the file LICENSE + */ +#include "espressif/esp_common.h" +#include "esp/uart.h" +#include "FreeRTOS.h" +#include "task.h" +#include "new_pwm.h" + +#define PWM_CHANNELS 3 +const uint32_t period = 5000; // * 200ns ^= 1 kHz + +// PWM setup +uint32_t io_info[PWM_CHANNELS][3] = { + {0, 0, 12}, + {0, 0, 13}, + {0, 0, 15}, +}; + +// Initial duty: all off +uint32_t pwm_duty_init[PWM_CHANNELS] = {0}; + +void pwm_task(void *pvParameters) +{ + uint32_t counts[PWM_CHANNELS] = {0, 1000, 3000}; + while(1) { + vTaskDelay(10); + for (uint8_t ii=0; ii period) + counts[ii] = 0; + } + pwm_start(); + } +} + +void user_init(void) +{ + uart_set_baud(0, 115200); + + printf("SDK version:%s\n", sdk_system_get_sdk_version()); + + printf("pwm_init()\n"); + pwm_init(period, pwm_duty_init, PWM_CHANNELS, io_info); + + printf("pwm_start()\n"); + pwm_start(); + + xTaskCreate(pwm_task, "new_pwm", 256, NULL, 2, NULL); +} diff --git a/extras/new_pwm b/extras/new_pwm new file mode 160000 index 0000000..8b8fc35 --- /dev/null +++ b/extras/new_pwm @@ -0,0 +1 @@ +Subproject commit 8b8fc35f5fa6c6209e9d77dc539cf34f0f151c30