feat!: changed driver on pcnt
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/pulse_cnt.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
@@ -16,6 +17,7 @@
|
||||
{ \
|
||||
.a_gpio_number = GPIO_NUM_MAX, \
|
||||
.b_gpio_number = GPIO_NUM_MAX, \
|
||||
.pullup = true, \
|
||||
.encoder_pulses = 0}
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -30,13 +32,27 @@ extern "C"
|
||||
{
|
||||
uint8_t a_gpio_number; /*!< Encoder A GPIO number. */
|
||||
uint8_t b_gpio_number; /*!< Encoder B GPIO number. */
|
||||
bool pullup; /*!< Pullup GPIO enable/disable. */
|
||||
uint16_t encoder_pulses; /*!< Number of pulses per one rotation. */
|
||||
} zh_inclinometer_init_config_t;
|
||||
|
||||
/**
|
||||
* @brief Inclinometer handle.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
pcnt_unit_handle_t pcnt_unit_handle; /*!< Inclinometer unique pcnt unit handle. */
|
||||
pcnt_channel_handle_t pcnt_channel_a_handle; /*!< Inclinometer unique pcnt channel handle. */
|
||||
pcnt_channel_handle_t pcnt_channel_b_handle; /*!< Inclinometer unique pcnt channel handle. */
|
||||
float degrees_per_pulse; /*!< Number of degrees per pulse. */
|
||||
bool is_initialized; /*!< Inclinometer initialization flag. */
|
||||
} zh_inclinometer_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize inclinometer.
|
||||
*
|
||||
* @param[in] config Pointer to inclinometer initialized configuration structure. Can point to a temporary variable.
|
||||
* @param[out] handle Pointer to unique inclinometer handle.
|
||||
*
|
||||
* @note Before initialize the inclinometer recommend initialize zh_inclinometer_init_config_t structure with default values.
|
||||
*
|
||||
@@ -44,32 +60,37 @@ extern "C"
|
||||
*
|
||||
* @return ESP_OK if success or an error code otherwise.
|
||||
*/
|
||||
esp_err_t zh_inclinometer_init(const zh_inclinometer_init_config_t *config);
|
||||
esp_err_t zh_inclinometer_init(const zh_inclinometer_init_config_t *config, zh_inclinometer_handle_t *handle);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize inclinometer.
|
||||
*
|
||||
* @param[in, out] handle Pointer to unique inclinometer handle.
|
||||
*
|
||||
* @return ESP_OK if success or an error code otherwise.
|
||||
*/
|
||||
esp_err_t zh_inclinometer_deinit(void);
|
||||
esp_err_t zh_inclinometer_deinit(zh_inclinometer_handle_t *handle);
|
||||
|
||||
/**
|
||||
* @brief Get inclinometer position.
|
||||
*
|
||||
* @param[out] position inclinometer position.
|
||||
* @param[in] handle Pointer to unique inclinometer handle.
|
||||
* @param[out] position Inclinometer position.
|
||||
*
|
||||
* @return ESP_OK if success or an error code otherwise.
|
||||
*/
|
||||
esp_err_t zh_inclinometer_get(double *position);
|
||||
esp_err_t zh_inclinometer_get(zh_inclinometer_handle_t *handle, float *angle);
|
||||
|
||||
/**
|
||||
* @brief Reset inclinometer position.
|
||||
*
|
||||
* @note The inclinometer will be set to 0 position.
|
||||
*
|
||||
* @param[in] handle Pointer to unique inclinometer handle.
|
||||
*
|
||||
* @return ESP_OK if success or an error code otherwise.
|
||||
*/
|
||||
esp_err_t zh_inclinometer_reset(void);
|
||||
esp_err_t zh_inclinometer_reset(zh_inclinometer_handle_t *handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user