HPM SDK
HPMicro Software Development Kit
hpm_mcl_analog.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 #ifndef HPM_MCL_ANALOG_H
8 #define HPM_MCL_ANALOG_H
9 
10 #include "hpm_mcl_common.h"
11 #include "hpm_mcl_filter.h"
12 
13 enum {
18 };
19 
20 typedef enum {
26 
31 typedef enum {
40 
45 typedef struct {
46  hpm_mcl_stat_t (*init)(void);
47  hpm_mcl_stat_t (*update_sample_location)(mcl_analog_chn_t chn, uint32_t tick);
48  _FUNC_OPTIONAL_ hpm_mcl_stat_t (*process_by_user)(mcl_analog_chn_t chn, int32_t adc_value, float *output);
49  hpm_mcl_stat_t (*get_value)(mcl_analog_chn_t chn, int32_t *value);
50  hpm_mcl_stat_t (*step_convert)(mcl_analog_chn_t chn, float value, float angle, float *output, bool is_closed_loop);
52 
53 
58 typedef struct {
69  bool enable_filter[MCL_ANALOG_CHN_NUM];
71 
76 typedef struct {
80  float current[MCL_ANALOG_CHN_NUM];
83 } mcl_analog_t;
84 
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88 
98 
108 
118 
127 
139 hpm_mcl_stat_t hpm_mcl_analog_step_convert(mcl_analog_t *analog, float value, mcl_analog_chn_t chn, float angle, float *output, bool is_closed_loop);
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif
static void init(hpm_panel_t *panel, const hpm_panel_timing_t *timing)
Definition: cc10128007.c:86
#define MAKE_STATUS(group, code)
Definition: hpm_common.h:144
@ mcl_analog_get_value_error
Definition: hpm_mcl_analog.h:17
@ mcl_analog_init_error
Definition: hpm_mcl_analog.h:14
@ mcl_analog_not_ready
Definition: hpm_mcl_analog.h:15
@ mcl_analog_update_location_error
Definition: hpm_mcl_analog.h:16
hpm_mcl_stat_t hpm_mcl_analog_get_value(mcl_analog_t *analog, mcl_analog_chn_t chn, float *value)
Get the value of the analog channel.
Definition: hpm_mcl_analog.c:63
mcl_analog_chn_t
Analog function channel numbers.
Definition: hpm_mcl_analog.h:31
@ analog_c_current
Definition: hpm_mcl_analog.h:34
@ analog_a_voltage
Definition: hpm_mcl_analog.h:35
@ analog_b_voltage
Definition: hpm_mcl_analog.h:36
@ analog_b_current
Definition: hpm_mcl_analog.h:33
@ analog_vbus
Definition: hpm_mcl_analog.h:38
@ analog_c_voltage
Definition: hpm_mcl_analog.h:37
@ analog_a_current
Definition: hpm_mcl_analog.h:32
mcl_analog_status_t
Definition: hpm_mcl_analog.h:20
@ analog_status_init
Definition: hpm_mcl_analog.h:22
@ analog_status_null
Definition: hpm_mcl_analog.h:21
@ analog_status_fail
Definition: hpm_mcl_analog.h:24
@ analog_status_run
Definition: hpm_mcl_analog.h:23
hpm_mcl_stat_t hpm_mcl_analog_step_convert(mcl_analog_t *analog, float value, mcl_analog_chn_t chn, float angle, float *output, bool is_closed_loop)
Convert step motor current.
Definition: hpm_mcl_analog.c:108
hpm_mcl_stat_t hpm_mcl_analog_disable_iir_filter(mcl_analog_t *analog, mcl_analog_chn_t chn)
Turn off the iir filter for analog functions.
Definition: hpm_mcl_analog.c:99
hpm_mcl_stat_t hpm_mcl_analog_iir_filter_init(mcl_analog_t *analog, mcl_analog_chn_t chn, mcl_filter_iir_df1_t *iir)
Initializing the iir filter for analog functions.
Definition: hpm_mcl_analog.c:88
hpm_mcl_stat_t hpm_mcl_analog_init(mcl_analog_t *analog, mcl_analog_cfg_t *cfg, mcl_cfg_t *mcl_cfg)
Initialize data structures for analog functions.
Definition: hpm_mcl_analog.c:9
uint32_t hpm_mcl_stat_t
Definition: hpm_mcl_common.h:15
@ mcl_group_analog
Definition: hpm_mcl_common.h:21
#define MCL_ANALOG_CHN_NUM
Definition: hpm_mcl_physical.h:11
callback function
Definition: hpm_mcl_analog.h:45
Configuration of analog functions.
Definition: hpm_mcl_analog.h:58
bool enable_a_voltage
Definition: hpm_mcl_analog.h:63
bool enable_c_current
Definition: hpm_mcl_analog.h:62
bool enable_b_current
Definition: hpm_mcl_analog.h:61
bool enable_a_current
Definition: hpm_mcl_analog.h:60
bool enable_c_voltage
Definition: hpm_mcl_analog.h:65
bool enable_step_convert_by_user
Definition: hpm_mcl_analog.h:68
mcl_analog_callback_t callback
Definition: hpm_mcl_analog.h:59
bool enable_process_by_user
Definition: hpm_mcl_analog.h:67
bool enable_b_voltage
Definition: hpm_mcl_analog.h:64
bool enable_vbus
Definition: hpm_mcl_analog.h:66
Operational data of the analog function.
Definition: hpm_mcl_analog.h:76
int32_t * num_current_sample_res
Definition: hpm_mcl_analog.h:81
physical_board_analog_t * board_parameter
Definition: hpm_mcl_analog.h:78
mcl_analog_status_t status
Definition: hpm_mcl_analog.h:82
mcl_analog_cfg_t * cfg
Definition: hpm_mcl_analog.h:77
Definition: hpm_mcl_common.h:239
iir df1 running data
Definition: hpm_mcl_filter.h:51
Definition: hpm_mcl_physical.h:60