sdm: clean up soc/hal/ll code
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "soc/clk_tree_defs.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -16,7 +17,11 @@ extern "C" {
|
||||
* @brief RMT group clock source
|
||||
* @note User should select the clock source based on the power and resolution requirement
|
||||
*/
|
||||
#if SOC_RMT_SUPPORTED
|
||||
typedef soc_periph_rmt_clk_src_t rmt_clock_source_t;
|
||||
#else
|
||||
typedef int rmt_clock_source_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The layout of RMT symbol stored in memory, which is decided by the hardware design
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in hal/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for sigma delta modulator.
|
||||
// There is no parameter check in the hal layer, so the caller must ensure the correctness of the parameters.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct gpio_sd_dev_t *sdm_soc_handle_t; // Sigma-Delta SOC layer handle
|
||||
|
||||
/**
|
||||
* HAL context type of Sigma-Delta driver
|
||||
*/
|
||||
typedef struct {
|
||||
sdm_soc_handle_t dev;
|
||||
} sdm_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize Sigma-Delta hal driver
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param group_id Sigma-Delta group number
|
||||
*/
|
||||
void sdm_hal_init(sdm_hal_context_t *hal, int group_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/clk_tree_defs.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if SOC_SDM_SUPPORTED
|
||||
typedef soc_periph_sdm_clk_src_t sdm_clock_source_t; // sigma delta modulator clock source
|
||||
#else
|
||||
typedef int sdm_clock_source_t; // sigma delta modulator clock source, fallback to integer type
|
||||
#endif // SOC_SDM_SUPPORTED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
// 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
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in hal/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for SIGMADELTA.
|
||||
// There is no parameter check in the hal layer, so the caller must ensure the correctness of the parameters.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/sigmadelta_periph.h"
|
||||
#include "hal/sigmadelta_types.h"
|
||||
#include "hal/sigmadelta_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
gpio_sd_dev_t *dev;
|
||||
} sigmadelta_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Set Sigma-delta channel duty.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @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.
|
||||
*/
|
||||
#define sigmadelta_hal_set_duty(hal, channel, duty) sigmadelta_ll_set_duty((hal)->dev, channel, duty)
|
||||
|
||||
/**
|
||||
* @brief Set Sigma-delta channel's clock pre-scale value.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel Sigma-delta channel number
|
||||
* @param prescale The divider of source clock, ranges from 0 to 255
|
||||
*/
|
||||
#define sigmadelta_hal_set_prescale(hal, channel, prescale) sigmadelta_ll_set_prescale((hal)->dev, channel, prescale)
|
||||
|
||||
/**
|
||||
* @brief Init the SIGMADELTA hal and set the SIGMADELTA to the default configuration. This function should be called first before other hal layer function is called
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param sigmadelta_num The uart port number, the max port number is (SIGMADELTA_NUM_MAX -1)
|
||||
*/
|
||||
void sigmadelta_hal_init(sigmadelta_hal_context_t *hal, int sigmadelta_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief SIGMADELTA port number, the max port number is (SIGMADELTA_NUM_MAX -1).
|
||||
*/
|
||||
typedef enum {
|
||||
SIGMADELTA_PORT_0, /*!< SIGMADELTA port 0 */
|
||||
SIGMADELTA_PORT_MAX, /*!< SIGMADELTA port max */
|
||||
} sigmadelta_port_t;
|
||||
|
||||
_Static_assert(SIGMADELTA_PORT_MAX == SOC_SIGMADELTA_NUM, "Sigma-delta port num incorrect.");
|
||||
|
||||
/**
|
||||
* @brief Sigma-delta channel list
|
||||
*/
|
||||
typedef enum {
|
||||
SIGMADELTA_CHANNEL_0, /*!< Sigma-delta channel 0 */
|
||||
SIGMADELTA_CHANNEL_1, /*!< Sigma-delta channel 1 */
|
||||
SIGMADELTA_CHANNEL_2, /*!< Sigma-delta channel 2 */
|
||||
SIGMADELTA_CHANNEL_3, /*!< Sigma-delta channel 3 */
|
||||
#if SOC_SIGMADELTA_CHANNEL_NUM > 4
|
||||
SIGMADELTA_CHANNEL_4, /*!< Sigma-delta channel 4 */
|
||||
SIGMADELTA_CHANNEL_5, /*!< Sigma-delta channel 5 */
|
||||
SIGMADELTA_CHANNEL_6, /*!< Sigma-delta channel 6 */
|
||||
SIGMADELTA_CHANNEL_7, /*!< Sigma-delta channel 7 */
|
||||
#endif
|
||||
SIGMADELTA_CHANNEL_MAX, /*!< Sigma-delta channel max */
|
||||
} sigmadelta_channel_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "soc/clk_tree_defs.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -15,7 +16,11 @@ extern "C" {
|
||||
/**
|
||||
* @brief temperature sensor clock source
|
||||
*/
|
||||
#if SOC_TEMP_SENSOR_SUPPORTED
|
||||
typedef soc_periph_temperature_sensor_clk_src_t temperature_sensor_clk_src_t;
|
||||
#else
|
||||
typedef int temperature_sensor_clk_src_t;
|
||||
#endif // SOC_TEMP_SENSOR_SUPPORTED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user