Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
i2c_mbed_fpga.h@20:26e934452728, 2021-06-04 (annotated)
- Committer:
- wuliqunyy
- Date:
- Fri Jun 04 08:21:10 2021 +0000
- Revision:
- 20:26e934452728
- Parent:
- 17:d7207b1132be
- Child:
- 22:fd929620e873
FPGA_V2 release
Who changed what in which revision?
User | Revision | Line number | New 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" |
wuliqunyy | 6:019ab407ac3c | 7 | |
wuliqunyy | 6:019ab407ac3c | 8 | |
wuliqunyy | 14:062850afdf38 | 9 | #define I2C_SLAVE_ADDR 0x6A<<1 |
wuliqunyy | 0:fe3c7dde9771 | 10 | |
wuliqunyy | 5:daab0e0e67e2 | 11 | //Class delclarations |
wuliqunyy | 5:daab0e0e67e2 | 12 | class i2c_mbed_fpga { |
wuliqunyy | 5:daab0e0e67e2 | 13 | |
wuliqunyy | 5:daab0e0e67e2 | 14 | public: |
wuliqunyy | 12:9f8c7f4da5f6 | 15 | /*constructor*/ |
wuliqunyy | 12:9f8c7f4da5f6 | 16 | // {p28:sda, p27:scl} |
wuliqunyy | 12:9f8c7f4da5f6 | 17 | // {p9: sda, p10:scl} |
wuliqunyy | 14:062850afdf38 | 18 | i2c_mbed_fpga(): i2c_master(p9, p10){ |
wuliqunyy | 14:062850afdf38 | 19 | i2c_master.frequency(100000); |
wuliqunyy | 12:9f8c7f4da5f6 | 20 | nv_positin_val = NV_POSITION_DEFAULT; |
wuliqunyy | 6:019ab407ac3c | 21 | nv_start_up_val = NV_START_UP_DEFAULT; |
wuliqunyy | 9:76a0b9f29a2d | 22 | nv_wind_brake_val = NV_WIND_BRAKE_DEFAULT; |
wuliqunyy | 10:a8390614edcc | 23 | ram_open_duty_val = RAM_OPEN_DUTY_DEFAULT; |
wuliqunyy | 11:b86aea372744 | 24 | nv_spd_control_1_val = NV_SPD_CONTROL_1_DEFAULT; |
wuliqunyy | 12:9f8c7f4da5f6 | 25 | nv_spd_control_2_val = NV_SPD_CONTROL_1_DEFAULT; |
wuliqunyy | 12:9f8c7f4da5f6 | 26 | nv_gen_ctrl_val = NV_GEN_CTRL_DEFAULT; |
wuliqunyy | 15:83bbc18cccbc | 27 | nv_application_cfg_val = NV_APPLICATION_CFG_DEFAULT; |
wuliqunyy | 15:83bbc18cccbc | 28 | nv_i_zc_th_high_val = NV_I_ZC_TH_HIGH_DEFAULT; |
wuliqunyy | 15:83bbc18cccbc | 29 | nv_i_zc_th_low_val = NV_I_ZC_TH_LOW_DEFAULT; |
wuliqunyy | 15:83bbc18cccbc | 30 | nv_di_th_1st_val = NV_DI_TH_1ST_DEFAULT; |
wuliqunyy | 15:83bbc18cccbc | 31 | nv_di_th_2nd_val = NV_DI_TH_2ND_DEFAULT; |
wuliqunyy | 16:a0bfe33f8a4a | 32 | nv_dig_config_val = NV_DIG_CONFIG_DEFAULT; |
wuliqunyy | 16:a0bfe33f8a4a | 33 | nv_clim_user_0_val = NV_CLIM_USER_0_DEFAULT; |
wuliqunyy | 20:26e934452728 | 34 | nv_clim_user_1_val = NV_CLIM_USER_1_DEFAULT; |
wuliqunyy | 20:26e934452728 | 35 | nv_positin2_val = NV_CLIM_POSITIN2_DEFAULT; |
wuliqunyy | 5:daab0e0e67e2 | 36 | }; |
wuliqunyy | 6:019ab407ac3c | 37 | |
wuliqunyy | 6:019ab407ac3c | 38 | int i2c_word_read(char *word); |
wuliqunyy | 5:daab0e0e67e2 | 39 | int i2c_word_write(char *word); |
wuliqunyy | 14:062850afdf38 | 40 | |
wuliqunyy | 15:83bbc18cccbc | 41 | //int i2c_window_open(); |
wuliqunyy | 15:83bbc18cccbc | 42 | //int i2c_motor_start(); |
wuliqunyy | 15:83bbc18cccbc | 43 | |
wuliqunyy | 15:83bbc18cccbc | 44 | int i2c_config_mode_entry(); |
wuliqunyy | 16:a0bfe33f8a4a | 45 | int i2c_mlx_mode_entry(); |
wuliqunyy | 15:83bbc18cccbc | 46 | int i2c_skip_app_copy(); |
wuliqunyy | 15:83bbc18cccbc | 47 | int i2c_soft_reset(); |
wuliqunyy | 5:daab0e0e67e2 | 48 | |
wuliqunyy | 16:a0bfe33f8a4a | 49 | |
wuliqunyy | 16:a0bfe33f8a4a | 50 | |
wuliqunyy | 12:9f8c7f4da5f6 | 51 | int i2c_set_50k_pwm(unsigned int pwm50k); |
wuliqunyy | 12:9f8c7f4da5f6 | 52 | |
wuliqunyy | 6:019ab407ac3c | 53 | int i2c_set_position_pulse_width(unsigned int manstisa_2b, unsigned int exponenet_3b); |
wuliqunyy | 20:26e934452728 | 54 | int i2c_set_position_flat(unsigned int mantisaa_2b, unsigned int exponent_3b); |
wuliqunyy | 6:019ab407ac3c | 55 | int i2c_set_position_duty(unsigned int duty_2b); |
wuliqunyy | 6:019ab407ac3c | 56 | int i2c_set_position_maj_vote(unsigned int maj_1b); |
wuliqunyy | 6:019ab407ac3c | 57 | int i2c_set_position_anti_cog(unsigned int cog_1b); |
wuliqunyy | 6:019ab407ac3c | 58 | |
wuliqunyy | 6:019ab407ac3c | 59 | int i2c_set_start_up_pulse_width(unsigned int mantisaa_3b, unsigned int exponent_3b); |
wuliqunyy | 20:26e934452728 | 60 | |
wuliqunyy | 6:019ab407ac3c | 61 | int i2c_set_start_up_duty(unsigned int duty_2b); |
wuliqunyy | 20:26e934452728 | 62 | int i2c_set_start_up_flat(unsigned int mantisaa_3b, unsigned int exponent_3b); |
wuliqunyy | 6:019ab407ac3c | 63 | int i2c_set_start_up_num_comm(unsigned int comm); |
wuliqunyy | 6:019ab407ac3c | 64 | 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 | 65 | int i2c_set_high_torque_start_up(unsigned int enbale, unsigned int mantisaa_3b, unsigned int exponent_3b); |
wuliqunyy | 6:019ab407ac3c | 66 | int i2c_set_single_pulse_start_up(unsigned int enbale, unsigned int mantisaa_3b, unsigned int exponent_3b); |
wuliqunyy | 12:9f8c7f4da5f6 | 67 | |
wuliqunyy | 17:d7207b1132be | 68 | int i2c_force_rough_reg(unsigned int reg); |
wuliqunyy | 12:9f8c7f4da5f6 | 69 | int i2c_set_rough_gain(unsigned int rough_gain); |
wuliqunyy | 14:062850afdf38 | 70 | int i2c_set_ehp_reg_gain(unsigned int ehp_gain); |
wuliqunyy | 14:062850afdf38 | 71 | int i2c_set_fall_time_blank(unsigned int blank_time); |
wuliqunyy | 14:062850afdf38 | 72 | |
wuliqunyy | 12:9f8c7f4da5f6 | 73 | int i2c_set_comm_i_thres(unsigned int i_thr_low, unsigned int i_thr_high); |
wuliqunyy | 12:9f8c7f4da5f6 | 74 | int i2c_set_comm_di_thres(unsigned int di_1st, unsigned int di_2nd); |
wuliqunyy | 12:9f8c7f4da5f6 | 75 | |
wuliqunyy | 12:9f8c7f4da5f6 | 76 | |
wuliqunyy | 11:b86aea372744 | 77 | int i2c_clear_spd_ctrl(); |
wuliqunyy | 14:062850afdf38 | 78 | int i2c_set_input_mode(unsigned int mode); |
wuliqunyy | 9:76a0b9f29a2d | 79 | int i2c_set_loop_mode(unsigned int openloop); |
wuliqunyy | 11:b86aea372744 | 80 | int i2c_set_curve_type(unsigned int curvetype); |
wuliqunyy | 11:b86aea372744 | 81 | int i2c_set_dc_ini(unsigned int ini); |
wuliqunyy | 11:b86aea372744 | 82 | int i2c_set_dc_sr(unsigned int sr); |
wuliqunyy | 9:76a0b9f29a2d | 83 | int i2c_set_open_loop_duty(unsigned int duty); |
wuliqunyy | 6:019ab407ac3c | 84 | |
wuliqunyy | 16:a0bfe33f8a4a | 85 | int i2c_set_clim_start_up(unsigned int clim); |
wuliqunyy | 16:a0bfe33f8a4a | 86 | int i2c_set_clim_brake(unsigned int clim); |
wuliqunyy | 16:a0bfe33f8a4a | 87 | int i2c_set_clim_run_time(unsigned int clim); |
wuliqunyy | 16:a0bfe33f8a4a | 88 | |
wuliqunyy | 5:daab0e0e67e2 | 89 | private: |
wuliqunyy | 5:daab0e0e67e2 | 90 | I2C i2c_master; |
wuliqunyy | 6:019ab407ac3c | 91 | unsigned int nv_positin_val; |
wuliqunyy | 6:019ab407ac3c | 92 | unsigned int nv_start_up_val; |
wuliqunyy | 6:019ab407ac3c | 93 | unsigned int nv_wind_brake_val; |
wuliqunyy | 9:76a0b9f29a2d | 94 | unsigned int nv_spd_control_1_val; |
wuliqunyy | 11:b86aea372744 | 95 | unsigned int nv_spd_control_2_val; |
wuliqunyy | 9:76a0b9f29a2d | 96 | unsigned int ram_open_duty_val; |
wuliqunyy | 12:9f8c7f4da5f6 | 97 | unsigned int nv_gen_ctrl_val; |
wuliqunyy | 12:9f8c7f4da5f6 | 98 | unsigned int nv_comm_ctrl_val; |
wuliqunyy | 14:062850afdf38 | 99 | unsigned int nv_application_cfg_val; |
wuliqunyy | 15:83bbc18cccbc | 100 | unsigned int nv_i_zc_th_high_val; |
wuliqunyy | 15:83bbc18cccbc | 101 | unsigned int nv_i_zc_th_low_val; |
wuliqunyy | 15:83bbc18cccbc | 102 | unsigned int nv_di_th_1st_val; |
wuliqunyy | 15:83bbc18cccbc | 103 | unsigned int nv_di_th_2nd_val; |
wuliqunyy | 16:a0bfe33f8a4a | 104 | unsigned int nv_dig_config_val; |
wuliqunyy | 16:a0bfe33f8a4a | 105 | unsigned int nv_clim_user_1_val; |
wuliqunyy | 20:26e934452728 | 106 | unsigned int nv_clim_user_0_val; |
wuliqunyy | 20:26e934452728 | 107 | unsigned int nv_positin2_val; |
wuliqunyy | 6:019ab407ac3c | 108 | |
wuliqunyy | 6:019ab407ac3c | 109 | //Position Detection Task/Functions |
wuliqunyy | 5:daab0e0e67e2 | 110 | }; |
wuliqunyy | 5:daab0e0e67e2 | 111 | |
wuliqunyy | 0:fe3c7dde9771 | 112 | |
wuliqunyy | 0:fe3c7dde9771 | 113 | #endif |