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@6:019ab407ac3c, 2021-01-25 (annotated)
- Committer:
- wuliqunyy
- Date:
- Mon Jan 25 13:21:57 2021 +0000
- Revision:
- 6:019ab407ac3c
- Parent:
- 5:daab0e0e67e2
- Child:
- 9:76a0b9f29a2d
Code clean up with I2C class
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 | 6:019ab407ac3c | 5 | #include "nv_defines.h" |
wuliqunyy | 6:019ab407ac3c | 6 | #include "nv_defaults.h" |
wuliqunyy | 6:019ab407ac3c | 7 | |
wuliqunyy | 6:019ab407ac3c | 8 | |
wuliqunyy | 6:019ab407ac3c | 9 | #define I2C_SLAVE_ADDR 0x18<<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 | 5:daab0e0e67e2 | 15 | /*constructor*/ |
wuliqunyy | 5:daab0e0e67e2 | 16 | i2c_mbed_fpga(): i2c_master(p9, p10){ |
wuliqunyy | 6:019ab407ac3c | 17 | i2c_master.frequency(35000); |
wuliqunyy | 6:019ab407ac3c | 18 | nv_positin_val = NV_POSITION_DEFUALT; |
wuliqunyy | 6:019ab407ac3c | 19 | nv_start_up_val = NV_START_UP_DEFAULT; |
wuliqunyy | 6:019ab407ac3c | 20 | nv_wind_brake_val = NV_WIND_BRAKE_DEFAULT; |
wuliqunyy | 5:daab0e0e67e2 | 21 | }; |
wuliqunyy | 6:019ab407ac3c | 22 | |
wuliqunyy | 6:019ab407ac3c | 23 | int i2c_word_read(char *word); |
wuliqunyy | 5:daab0e0e67e2 | 24 | int i2c_word_write(char *word); |
wuliqunyy | 6:019ab407ac3c | 25 | int i2c_word_safe_write(char *word); |
wuliqunyy | 6:019ab407ac3c | 26 | |
wuliqunyy | 5:daab0e0e67e2 | 27 | int i2c_window_open(); |
wuliqunyy | 5:daab0e0e67e2 | 28 | int i2c_motor_start(); |
wuliqunyy | 5:daab0e0e67e2 | 29 | |
wuliqunyy | 6:019ab407ac3c | 30 | int i2c_set_position_pulse_width(unsigned int manstisa_2b, unsigned int exponenet_3b); |
wuliqunyy | 6:019ab407ac3c | 31 | int i2c_set_position_duty(unsigned int duty_2b); |
wuliqunyy | 6:019ab407ac3c | 32 | int i2c_set_position_maj_vote(unsigned int maj_1b); |
wuliqunyy | 6:019ab407ac3c | 33 | int i2c_set_position_anti_cog(unsigned int cog_1b); |
wuliqunyy | 6:019ab407ac3c | 34 | |
wuliqunyy | 6:019ab407ac3c | 35 | int i2c_set_start_up_pulse_width(unsigned int mantisaa_3b, unsigned int exponent_3b); |
wuliqunyy | 6:019ab407ac3c | 36 | int i2c_set_start_up_duty(unsigned int duty_2b); |
wuliqunyy | 6:019ab407ac3c | 37 | int i2c_set_start_up_num_comm(unsigned int comm); |
wuliqunyy | 6:019ab407ac3c | 38 | 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 | 39 | int i2c_set_high_torque_start_up(unsigned int enbale, unsigned int mantisaa_3b, unsigned int exponent_3b); |
wuliqunyy | 6:019ab407ac3c | 40 | int i2c_set_single_pulse_start_up(unsigned int enbale, unsigned int mantisaa_3b, unsigned int exponent_3b); |
wuliqunyy | 6:019ab407ac3c | 41 | |
wuliqunyy | 6:019ab407ac3c | 42 | |
wuliqunyy | 5:daab0e0e67e2 | 43 | private: |
wuliqunyy | 5:daab0e0e67e2 | 44 | I2C i2c_master; |
wuliqunyy | 6:019ab407ac3c | 45 | unsigned int nv_positin_val; |
wuliqunyy | 6:019ab407ac3c | 46 | unsigned int nv_start_up_val; |
wuliqunyy | 6:019ab407ac3c | 47 | unsigned int nv_wind_brake_val; |
wuliqunyy | 6:019ab407ac3c | 48 | |
wuliqunyy | 6:019ab407ac3c | 49 | //Position Detection Task/Functions |
wuliqunyy | 5:daab0e0e67e2 | 50 | }; |
wuliqunyy | 5:daab0e0e67e2 | 51 | |
wuliqunyy | 0:fe3c7dde9771 | 52 | |
wuliqunyy | 0:fe3c7dde9771 | 53 | #endif |