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@14:062850afdf38, 2021-04-22 (annotated)
- Committer:
- wuliqunyy
- Date:
- Thu Apr 22 11:35:17 2021 +0000
- Revision:
- 14:062850afdf38
- Parent:
- 12:9f8c7f4da5f6
- Child:
- 15:83bbc18cccbc
working version with DOE2 CL;
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 | 14:062850afdf38 | 27 | nv_comm_ctrl_val = NV_COMM_CTRL_DEFAULT; |
wuliqunyy | 14:062850afdf38 | 28 | nv_application_cfg_val = NV_APPLICATION_CFG_DEFAULT; |
wuliqunyy | 5:daab0e0e67e2 | 29 | }; |
wuliqunyy | 6:019ab407ac3c | 30 | |
wuliqunyy | 6:019ab407ac3c | 31 | int i2c_word_read(char *word); |
wuliqunyy | 5:daab0e0e67e2 | 32 | int i2c_word_write(char *word); |
wuliqunyy | 14:062850afdf38 | 33 | |
wuliqunyy | 5:daab0e0e67e2 | 34 | int i2c_window_open(); |
wuliqunyy | 5:daab0e0e67e2 | 35 | int i2c_motor_start(); |
wuliqunyy | 5:daab0e0e67e2 | 36 | |
wuliqunyy | 12:9f8c7f4da5f6 | 37 | int i2c_set_50k_pwm(unsigned int pwm50k); |
wuliqunyy | 12:9f8c7f4da5f6 | 38 | |
wuliqunyy | 6:019ab407ac3c | 39 | int i2c_set_position_pulse_width(unsigned int manstisa_2b, unsigned int exponenet_3b); |
wuliqunyy | 6:019ab407ac3c | 40 | int i2c_set_position_duty(unsigned int duty_2b); |
wuliqunyy | 6:019ab407ac3c | 41 | int i2c_set_position_maj_vote(unsigned int maj_1b); |
wuliqunyy | 6:019ab407ac3c | 42 | int i2c_set_position_anti_cog(unsigned int cog_1b); |
wuliqunyy | 6:019ab407ac3c | 43 | |
wuliqunyy | 6:019ab407ac3c | 44 | int i2c_set_start_up_pulse_width(unsigned int mantisaa_3b, unsigned int exponent_3b); |
wuliqunyy | 6:019ab407ac3c | 45 | int i2c_set_start_up_duty(unsigned int duty_2b); |
wuliqunyy | 6:019ab407ac3c | 46 | int i2c_set_start_up_num_comm(unsigned int comm); |
wuliqunyy | 6:019ab407ac3c | 47 | 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 | 48 | int i2c_set_high_torque_start_up(unsigned int enbale, unsigned int mantisaa_3b, unsigned int exponent_3b); |
wuliqunyy | 6:019ab407ac3c | 49 | int i2c_set_single_pulse_start_up(unsigned int enbale, unsigned int mantisaa_3b, unsigned int exponent_3b); |
wuliqunyy | 12:9f8c7f4da5f6 | 50 | |
wuliqunyy | 12:9f8c7f4da5f6 | 51 | int i2c_set_rough_gain(unsigned int rough_gain); |
wuliqunyy | 14:062850afdf38 | 52 | int i2c_set_ehp_reg_gain(unsigned int ehp_gain); |
wuliqunyy | 14:062850afdf38 | 53 | int i2c_set_fall_time_blank(unsigned int blank_time); |
wuliqunyy | 14:062850afdf38 | 54 | |
wuliqunyy | 12:9f8c7f4da5f6 | 55 | int i2c_set_comm_i_thres(unsigned int i_thr_low, unsigned int i_thr_high); |
wuliqunyy | 12:9f8c7f4da5f6 | 56 | int i2c_set_comm_di_thres(unsigned int di_1st, unsigned int di_2nd); |
wuliqunyy | 12:9f8c7f4da5f6 | 57 | |
wuliqunyy | 12:9f8c7f4da5f6 | 58 | |
wuliqunyy | 11:b86aea372744 | 59 | int i2c_clear_spd_ctrl(); |
wuliqunyy | 14:062850afdf38 | 60 | int i2c_set_input_mode(unsigned int mode); |
wuliqunyy | 9:76a0b9f29a2d | 61 | int i2c_set_loop_mode(unsigned int openloop); |
wuliqunyy | 11:b86aea372744 | 62 | int i2c_set_curve_type(unsigned int curvetype); |
wuliqunyy | 11:b86aea372744 | 63 | int i2c_set_dc_ini(unsigned int ini); |
wuliqunyy | 11:b86aea372744 | 64 | int i2c_set_dc_sr(unsigned int sr); |
wuliqunyy | 9:76a0b9f29a2d | 65 | int i2c_set_open_loop_duty(unsigned int duty); |
wuliqunyy | 6:019ab407ac3c | 66 | |
wuliqunyy | 5:daab0e0e67e2 | 67 | private: |
wuliqunyy | 5:daab0e0e67e2 | 68 | I2C i2c_master; |
wuliqunyy | 6:019ab407ac3c | 69 | unsigned int nv_positin_val; |
wuliqunyy | 6:019ab407ac3c | 70 | unsigned int nv_start_up_val; |
wuliqunyy | 6:019ab407ac3c | 71 | unsigned int nv_wind_brake_val; |
wuliqunyy | 9:76a0b9f29a2d | 72 | unsigned int nv_spd_control_1_val; |
wuliqunyy | 11:b86aea372744 | 73 | unsigned int nv_spd_control_2_val; |
wuliqunyy | 9:76a0b9f29a2d | 74 | unsigned int ram_open_duty_val; |
wuliqunyy | 12:9f8c7f4da5f6 | 75 | unsigned int nv_gen_ctrl_val; |
wuliqunyy | 12:9f8c7f4da5f6 | 76 | unsigned int nv_comm_ctrl_val; |
wuliqunyy | 14:062850afdf38 | 77 | unsigned int nv_application_cfg_val; |
wuliqunyy | 6:019ab407ac3c | 78 | |
wuliqunyy | 6:019ab407ac3c | 79 | //Position Detection Task/Functions |
wuliqunyy | 5:daab0e0e67e2 | 80 | }; |
wuliqunyy | 5:daab0e0e67e2 | 81 | |
wuliqunyy | 0:fe3c7dde9771 | 82 | |
wuliqunyy | 0:fe3c7dde9771 | 83 | #endif |