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);
51 
52 
57 typedef struct {
67  bool enable_filter[MCL_ANALOG_CHN_NUM];
69 
74 typedef struct {
78  float current[MCL_ANALOG_CHN_NUM];
81 } mcl_analog_t;
82 
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86 
96 
106 
116 
125 
136 hpm_mcl_stat_t hpm_mcl_analog_step_convert(mcl_analog_t *analog, float value, mcl_analog_chn_t chn, float angle, float *output);
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif
static void init(hpm_panel_t *panel)
Definition: cc10128007.c:86
#define MAKE_STATUS(group, code)
Definition: hpm_common.h:132
@ 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_step_convert(mcl_analog_t *analog, float value, mcl_analog_chn_t chn, float angle, float *output)
Current conversion of stepper motors.
Definition: hpm_mcl_analog.c:109
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_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:100
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:89
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
@ mcl_group_analog
Definition: hpm_mcl_common.h:21
uint32_t hpm_mcl_stat_t
Definition: hpm_mcl_common.h:15
#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:57
bool enable_a_voltage
Definition: hpm_mcl_analog.h:62
bool enable_c_current
Definition: hpm_mcl_analog.h:61
bool enable_b_current
Definition: hpm_mcl_analog.h:60
bool enable_a_current
Definition: hpm_mcl_analog.h:59
bool enable_c_voltage
Definition: hpm_mcl_analog.h:64
mcl_analog_callback_t callback
Definition: hpm_mcl_analog.h:58
bool enable_process_by_user
Definition: hpm_mcl_analog.h:66
bool enable_b_voltage
Definition: hpm_mcl_analog.h:63
bool enable_vbus
Definition: hpm_mcl_analog.h:65
Operational data of the analog function.
Definition: hpm_mcl_analog.h:74
int32_t * num_current_sample_res
Definition: hpm_mcl_analog.h:79
physical_board_analog_t * board_parameter
Definition: hpm_mcl_analog.h:76
mcl_analog_status_t status
Definition: hpm_mcl_analog.h:80
mcl_analog_cfg_t * cfg
Definition: hpm_mcl_analog.h:75
Definition: hpm_mcl_common.h:198
iir df1 running data
Definition: hpm_mcl_filter.h:51
Definition: hpm_mcl_physical.h:60