Fork

Dependencies:   mbed libscpi

Committer:
bavovanachte
Date:
Thu Jun 10 13:29:48 2021 +0000
Revision:
31:0475756cede6
Parent:
30:b463e1f3cae3
Implemented; - Word write; - SPEED aliases

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wuliqunyy 0:fe3c7dde9771 1 #ifndef I2C_MBED_FPGA_H
wuliqunyy 0:fe3c7dde9771 2 #define I2C_MBED_FPGA_H
wuliqunyy 0:fe3c7dde9771 3
wuliqunyy 6:019ab407ac3c 4 #include "nv_bitfield_map.h"
wuliqunyy 14:062850afdf38 5 #include "i2c_ram_defines.h"
wuliqunyy 6:019ab407ac3c 6 #include "nv_defaults.h"
bavovanachte 26:beaf802e2456 7 #include "mbed.h"
wuliqunyy 6:019ab407ac3c 8
wuliqunyy 6:019ab407ac3c 9
wuliqunyy 14:062850afdf38 10 #define I2C_SLAVE_ADDR 0x6A<<1
wuliqunyy 0:fe3c7dde9771 11
wuliqunyy 5:daab0e0e67e2 12 //Class delclarations
wuliqunyy 5:daab0e0e67e2 13 class i2c_mbed_fpga {
wuliqunyy 5:daab0e0e67e2 14
wuliqunyy 5:daab0e0e67e2 15 public:
wuliqunyy 12:9f8c7f4da5f6 16 /*constructor*/
wuliqunyy 12:9f8c7f4da5f6 17 // {p28:sda, p27:scl}
wuliqunyy 12:9f8c7f4da5f6 18 // {p9: sda, p10:scl}
wuliqunyy 14:062850afdf38 19 i2c_mbed_fpga(): i2c_master(p9, p10){
wuliqunyy 14:062850afdf38 20 i2c_master.frequency(100000);
wuliqunyy 12:9f8c7f4da5f6 21 nv_positin_val = NV_POSITION_DEFAULT;
wuliqunyy 6:019ab407ac3c 22 nv_start_up_val = NV_START_UP_DEFAULT;
wuliqunyy 9:76a0b9f29a2d 23 nv_wind_brake_val = NV_WIND_BRAKE_DEFAULT;
wuliqunyy 10:a8390614edcc 24 ram_open_duty_val = RAM_OPEN_DUTY_DEFAULT;
wuliqunyy 11:b86aea372744 25 nv_spd_control_1_val = NV_SPD_CONTROL_1_DEFAULT;
wuliqunyy 12:9f8c7f4da5f6 26 nv_spd_control_2_val = NV_SPD_CONTROL_1_DEFAULT;
wuliqunyy 12:9f8c7f4da5f6 27 nv_gen_ctrl_val = NV_GEN_CTRL_DEFAULT;
wuliqunyy 15:83bbc18cccbc 28 nv_application_cfg_val = NV_APPLICATION_CFG_DEFAULT;
wuliqunyy 15:83bbc18cccbc 29 nv_i_zc_th_high_val = NV_I_ZC_TH_HIGH_DEFAULT;
wuliqunyy 15:83bbc18cccbc 30 nv_i_zc_th_low_val = NV_I_ZC_TH_LOW_DEFAULT;
wuliqunyy 15:83bbc18cccbc 31 nv_di_th_1st_val = NV_DI_TH_1ST_DEFAULT;
wuliqunyy 15:83bbc18cccbc 32 nv_di_th_2nd_val = NV_DI_TH_2ND_DEFAULT;
wuliqunyy 16:a0bfe33f8a4a 33 nv_dig_config_val = NV_DIG_CONFIG_DEFAULT;
wuliqunyy 16:a0bfe33f8a4a 34 nv_clim_user_0_val = NV_CLIM_USER_0_DEFAULT;
wuliqunyy 20:26e934452728 35 nv_clim_user_1_val = NV_CLIM_USER_1_DEFAULT;
wuliqunyy 20:26e934452728 36 nv_positin2_val = NV_CLIM_POSITIN2_DEFAULT;
wuliqunyy 22:fd929620e873 37 ram_debug_ctrl_val = RAM_DEBUG_CTRL_DEFAULT;
wuliqunyy 5:daab0e0e67e2 38 };
wuliqunyy 6:019ab407ac3c 39
wuliqunyy 6:019ab407ac3c 40 int i2c_word_read(char *word);
bavovanachte 27:9118d8c2509b 41 int i2c_word_read_simple(char address, int* return_value);
bavovanachte 30:b463e1f3cae3 42 int i2c_word_read_interpreter(int address, int* return_value);
wuliqunyy 5:daab0e0e67e2 43 int i2c_word_write(char *word);
bavovanachte 30:b463e1f3cae3 44 int i2c_word_write_simple(char address, int value);
bavovanachte 31:0475756cede6 45 int i2c_word_write_interpreter(int address, int value);
wuliqunyy 14:062850afdf38 46
wuliqunyy 15:83bbc18cccbc 47 //int i2c_window_open();
wuliqunyy 15:83bbc18cccbc 48 //int i2c_motor_start();
wuliqunyy 15:83bbc18cccbc 49
wuliqunyy 15:83bbc18cccbc 50 int i2c_config_mode_entry();
wuliqunyy 16:a0bfe33f8a4a 51 int i2c_mlx_mode_entry();
wuliqunyy 15:83bbc18cccbc 52 int i2c_skip_app_copy();
wuliqunyy 15:83bbc18cccbc 53 int i2c_soft_reset();
bavovanachte 30:b463e1f3cae3 54 bool i2c_check_busy_flag(void);
bavovanachte 30:b463e1f3cae3 55 void wait_for_idle_state(void);
wuliqunyy 16:a0bfe33f8a4a 56
wuliqunyy 16:a0bfe33f8a4a 57
wuliqunyy 12:9f8c7f4da5f6 58 int i2c_set_50k_pwm(unsigned int pwm50k);
wuliqunyy 12:9f8c7f4da5f6 59
wuliqunyy 6:019ab407ac3c 60 int i2c_set_position_pulse_width(unsigned int manstisa_2b, unsigned int exponenet_3b);
wuliqunyy 20:26e934452728 61 int i2c_set_position_flat(unsigned int mantisaa_2b, unsigned int exponent_3b);
wuliqunyy 6:019ab407ac3c 62 int i2c_set_position_duty(unsigned int duty_2b);
wuliqunyy 6:019ab407ac3c 63 int i2c_set_position_maj_vote(unsigned int maj_1b);
wuliqunyy 6:019ab407ac3c 64 int i2c_set_position_anti_cog(unsigned int cog_1b);
wuliqunyy 6:019ab407ac3c 65
wuliqunyy 6:019ab407ac3c 66 int i2c_set_start_up_pulse_width(unsigned int mantisaa_3b, unsigned int exponent_3b);
wuliqunyy 20:26e934452728 67
wuliqunyy 6:019ab407ac3c 68 int i2c_set_start_up_duty(unsigned int duty_2b);
wuliqunyy 20:26e934452728 69 int i2c_set_start_up_flat(unsigned int mantisaa_3b, unsigned int exponent_3b);
wuliqunyy 6:019ab407ac3c 70 int i2c_set_start_up_num_comm(unsigned int comm);
wuliqunyy 6:019ab407ac3c 71 int i2c_set_soft_start_up(unsigned int enbale, unsigned int mantisaa_3b, unsigned int exponent_3b, unsigned int step_size, unsigned int num_steps);
wuliqunyy 6:019ab407ac3c 72 int i2c_set_high_torque_start_up(unsigned int enbale, unsigned int mantisaa_3b, unsigned int exponent_3b);
wuliqunyy 6:019ab407ac3c 73 int i2c_set_single_pulse_start_up(unsigned int enbale, unsigned int mantisaa_3b, unsigned int exponent_3b);
wuliqunyy 12:9f8c7f4da5f6 74
wuliqunyy 17:d7207b1132be 75 int i2c_force_rough_reg(unsigned int reg);
wuliqunyy 12:9f8c7f4da5f6 76 int i2c_set_rough_gain(unsigned int rough_gain);
wuliqunyy 14:062850afdf38 77 int i2c_set_ehp_reg_gain(unsigned int ehp_gain);
wuliqunyy 14:062850afdf38 78 int i2c_set_fall_time_blank(unsigned int blank_time);
wuliqunyy 14:062850afdf38 79
wuliqunyy 12:9f8c7f4da5f6 80 int i2c_set_comm_i_thres(unsigned int i_thr_low, unsigned int i_thr_high);
wuliqunyy 12:9f8c7f4da5f6 81 int i2c_set_comm_di_thres(unsigned int di_1st, unsigned int di_2nd);
wuliqunyy 12:9f8c7f4da5f6 82
wuliqunyy 12:9f8c7f4da5f6 83
wuliqunyy 11:b86aea372744 84 int i2c_clear_spd_ctrl();
wuliqunyy 14:062850afdf38 85 int i2c_set_input_mode(unsigned int mode);
wuliqunyy 9:76a0b9f29a2d 86 int i2c_set_loop_mode(unsigned int openloop);
wuliqunyy 11:b86aea372744 87 int i2c_set_curve_type(unsigned int curvetype);
wuliqunyy 11:b86aea372744 88 int i2c_set_dc_ini(unsigned int ini);
wuliqunyy 11:b86aea372744 89 int i2c_set_dc_sr(unsigned int sr);
wuliqunyy 9:76a0b9f29a2d 90 int i2c_set_open_loop_duty(unsigned int duty);
wuliqunyy 6:019ab407ac3c 91
wuliqunyy 16:a0bfe33f8a4a 92 int i2c_set_clim_start_up(unsigned int clim);
wuliqunyy 16:a0bfe33f8a4a 93 int i2c_set_clim_brake(unsigned int clim);
wuliqunyy 16:a0bfe33f8a4a 94 int i2c_set_clim_run_time(unsigned int clim);
wuliqunyy 16:a0bfe33f8a4a 95
wuliqunyy 22:fd929620e873 96 int i2c_enable_pules_debug_mode(unsigned int enable);
wuliqunyy 22:fd929620e873 97
wuliqunyy 5:daab0e0e67e2 98 private:
wuliqunyy 5:daab0e0e67e2 99 I2C i2c_master;
wuliqunyy 6:019ab407ac3c 100 unsigned int nv_positin_val;
wuliqunyy 6:019ab407ac3c 101 unsigned int nv_start_up_val;
wuliqunyy 6:019ab407ac3c 102 unsigned int nv_wind_brake_val;
wuliqunyy 9:76a0b9f29a2d 103 unsigned int nv_spd_control_1_val;
wuliqunyy 11:b86aea372744 104 unsigned int nv_spd_control_2_val;
wuliqunyy 9:76a0b9f29a2d 105 unsigned int ram_open_duty_val;
wuliqunyy 12:9f8c7f4da5f6 106 unsigned int nv_gen_ctrl_val;
wuliqunyy 12:9f8c7f4da5f6 107 unsigned int nv_comm_ctrl_val;
wuliqunyy 14:062850afdf38 108 unsigned int nv_application_cfg_val;
wuliqunyy 15:83bbc18cccbc 109 unsigned int nv_i_zc_th_high_val;
wuliqunyy 15:83bbc18cccbc 110 unsigned int nv_i_zc_th_low_val;
wuliqunyy 15:83bbc18cccbc 111 unsigned int nv_di_th_1st_val;
wuliqunyy 15:83bbc18cccbc 112 unsigned int nv_di_th_2nd_val;
wuliqunyy 16:a0bfe33f8a4a 113 unsigned int nv_dig_config_val;
wuliqunyy 16:a0bfe33f8a4a 114 unsigned int nv_clim_user_1_val;
wuliqunyy 20:26e934452728 115 unsigned int nv_clim_user_0_val;
wuliqunyy 20:26e934452728 116 unsigned int nv_positin2_val;
wuliqunyy 22:fd929620e873 117 unsigned int ram_debug_ctrl_val;
wuliqunyy 6:019ab407ac3c 118 //Position Detection Task/Functions
wuliqunyy 5:daab0e0e67e2 119 };
wuliqunyy 5:daab0e0e67e2 120
wuliqunyy 0:fe3c7dde9771 121
bavovanachte 26:beaf802e2456 122
wuliqunyy 0:fe3c7dde9771 123 #endif