1 // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include "soc/soc_caps.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /**
24  * @brief SIGMADELTA port number, the max port number is (SIGMADELTA_NUM_MAX -1).
25  */
26 typedef enum {
27     SIGMADELTA_PORT_0,      /*!< SIGMADELTA port 0 */
28     SIGMADELTA_PORT_MAX,    /*!< SIGMADELTA port max */
29 } sigmadelta_port_t;
30 
31 _Static_assert(SIGMADELTA_PORT_MAX == SOC_SIGMADELTA_NUM, "Sigma-delta port num incorrect.");
32 
33 /**
34  * @brief Sigma-delta channel list
35  */
36 typedef enum {
37     SIGMADELTA_CHANNEL_0,   /*!< Sigma-delta channel 0 */
38     SIGMADELTA_CHANNEL_1,   /*!< Sigma-delta channel 1 */
39     SIGMADELTA_CHANNEL_2,   /*!< Sigma-delta channel 2 */
40     SIGMADELTA_CHANNEL_3,   /*!< Sigma-delta channel 3 */
41 #if SOC_SIGMADELTA_CHANNEL_NUM > 4
42     SIGMADELTA_CHANNEL_4,   /*!< Sigma-delta channel 4 */
43     SIGMADELTA_CHANNEL_5,   /*!< Sigma-delta channel 5 */
44     SIGMADELTA_CHANNEL_6,   /*!< Sigma-delta channel 6 */
45     SIGMADELTA_CHANNEL_7,   /*!< Sigma-delta channel 7 */
46 #endif
47     SIGMADELTA_CHANNEL_MAX, /*!< Sigma-delta channel max */
48 } sigmadelta_channel_t;
49 
50 /**
51  * @brief Sigma-delta configure struct
52  */
53 typedef struct {
54     sigmadelta_channel_t channel;    /*!< Sigma-delta channel number */
55     int8_t sigmadelta_duty;          /*!< Sigma-delta duty, duty ranges from -128 to 127. */
56     uint8_t sigmadelta_prescale;     /*!< Sigma-delta prescale, prescale ranges from 0 to 255. */
57     uint8_t  sigmadelta_gpio;        /*!< Sigma-delta output io number, refer to gpio.h for more details. */
58 } sigmadelta_config_t;
59 
60 #ifdef __cplusplus
61 }
62 #endif
63