Espruino/targets/esp32/jshardwarePWM.h
jumjum123 6a18cbc5dd 1. Makefile, moved $(ESP_ZIP):.... to be after proj:....
2. added README_flash.txt to folder target/esp32
3. added README_flash.txt to zip file created in $(ESP_ZIP):.... in Makefile
4. added header and source file for PWM. ESP32 does not support a general PWM driver(yet).
   Therefore driver/ledc is used.
   5 channel can be used for simple DAC, using default frequency of 5000Hz
   3 more channel are available for different frequency
5. connect jshardwarePWM functions to standard calls in jshardware
6. implemented jshSetOutputValue in jshardware
7. moved targets/esp32/rtosutil.c from RTOS to standard part of ESP32
   targets/esp32/jswrap_rtos.c is added only if var RTOS is defined
2017-01-19 15:39:01 +01:00

34 lines
1.2 KiB
C

/*
* This file is designed to support PWM functions in Espruino for ESP32,
* a JavaScript interpreter for Microcontrollers designed by Gordon Williams
*
* Copyright (C) 2016 by Juergen Marsch
*
* This Source Code Form is subject to the terms of the Mozilla Publici
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* ----------------------------------------------------------------------------
* This file is designed to be parsed during the build process
*
* Contains ESP32 board specific functions.
* ----------------------------------------------------------------------------
*/
#include "jspininfo.h"
#define PWMMax 5 //maximum PWM channel for Analog output (freq = 50000)
#define PWMFreqMax 3 //maximum PWM channel with free frequency
#define PWMTimerBit 10 //10 bit for value
#define PWMTimerRange 1024
struct PWMChannel{Pin pin;}; //will be extended once we know more about PWM for Espruino on ESP32
struct PWMChannel PWMChannels[PWMMax];
struct PWMFreqChannel{Pin pin; int freq};
struct PWMFreqChannel PWMFreqChannels[PWMFreqMax];
void PWMInit();
void writePWM(Pin pin, uint16_t value,int freq);
void setPWM(Pin pin,uint16_t value);