mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
refactor(sigmadelta): add hal sigmadelta driver
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
@@ -12,41 +11,18 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __DRIVER_SIGMADELTA_H__
|
||||
#define __DRIVER_SIGMADELTA_H__
|
||||
#pragma once
|
||||
|
||||
#include <esp_types.h>
|
||||
#include "soc/sigmadelta_periph.h"
|
||||
#include "soc/sigmadelta_caps.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "hal/sigmadelta_types.h"
|
||||
|
||||
#ifdef _cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Sigma-delta channel list
|
||||
*/
|
||||
typedef enum{
|
||||
SIGMADELTA_CHANNEL_0 = 0, /*!< Sigma-delta channel 0 */
|
||||
SIGMADELTA_CHANNEL_1 = 1, /*!< Sigma-delta channel 1 */
|
||||
SIGMADELTA_CHANNEL_2 = 2, /*!< Sigma-delta channel 2 */
|
||||
SIGMADELTA_CHANNEL_3 = 3, /*!< Sigma-delta channel 3 */
|
||||
SIGMADELTA_CHANNEL_4 = 4, /*!< Sigma-delta channel 4 */
|
||||
SIGMADELTA_CHANNEL_5 = 5, /*!< Sigma-delta channel 5 */
|
||||
SIGMADELTA_CHANNEL_6 = 6, /*!< Sigma-delta channel 6 */
|
||||
SIGMADELTA_CHANNEL_7 = 7, /*!< Sigma-delta channel 7 */
|
||||
SIGMADELTA_CHANNEL_MAX,
|
||||
} sigmadelta_channel_t;
|
||||
|
||||
/**
|
||||
* @brief Sigma-delta configure struct
|
||||
*/
|
||||
typedef struct {
|
||||
sigmadelta_channel_t channel; /*!< Sigma-delta channel number */
|
||||
int8_t sigmadelta_duty; /*!< Sigma-delta duty, duty ranges from -128 to 127. */
|
||||
uint8_t sigmadelta_prescale; /*!< Sigma-delta prescale, prescale ranges from 0 to 255. */
|
||||
uint8_t sigmadelta_gpio; /*!< Sigma-delta output io number, refer to gpio.h for more details. */
|
||||
} sigmadelta_config_t;
|
||||
|
||||
/**
|
||||
* @brief Configure Sigma-delta channel
|
||||
*
|
||||
@@ -54,6 +30,7 @@ typedef struct {
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE sigmadelta driver already initialized
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t sigmadelta_config(const sigmadelta_config_t *config);
|
||||
@@ -69,9 +46,10 @@ esp_err_t sigmadelta_config(const sigmadelta_config_t *config);
|
||||
* @param channel Sigma-delta channel number
|
||||
* @param duty Sigma-delta duty of one channel, the value ranges from -128 to 127, recommended range is -90 ~ 90.
|
||||
* The waveform is more like a random one in this range.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE sigmadelta driver has not been initialized
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t sigmadelta_set_duty(sigmadelta_channel_t channel, int8_t duty);
|
||||
@@ -85,6 +63,7 @@ esp_err_t sigmadelta_set_duty(sigmadelta_channel_t channel, int8_t duty);
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE sigmadelta driver has not been initialized
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t sigmadelta_set_prescale(sigmadelta_channel_t channel, uint8_t prescale);
|
||||
@@ -97,6 +76,7 @@ esp_err_t sigmadelta_set_prescale(sigmadelta_channel_t channel, uint8_t prescale
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE sigmadelta driver has not been initialized
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t sigmadelta_set_pin(sigmadelta_channel_t channel, gpio_num_t gpio_num);
|
||||
@@ -104,5 +84,3 @@ esp_err_t sigmadelta_set_pin(sigmadelta_channel_t channel, gpio_num_t gpio_num);
|
||||
#ifdef _cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user