Functions | |
void | hmc6352_enter_cal () |
void | hmc6352_exit_cal () |
uns16 | hmc6352_get_data () |
uns8 | hmc6352_read_eeprom (uns8 addr) |
uns8 | hmc6352_read_ram (uns8 addr) |
void | hmc6352_save_op_mode () |
void | hmc6352_set_mode (uns8 mode) |
void | hmc6352_setup_io () |
void | hmc6352_sleep () |
void | hmc6352_update_bridge_offsets () |
void | hmc6352_wake () |
void | hmc6352_write_eeprom (uns8 addr, uns8 data) |
void | hmc6352_write_ram (uns8 addr, uns8 data) |
void hmc6352_enter_cal | ( | ) |
00160 { 00161 00162 // Send hmc6352 addr (write) 00163 // Send command C (Enter user calibration mode) 00164 00165 i2c_start(); 00166 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00167 i2c_send_byte(hmc6352_enter_cal_cmd); 00168 i2c_stop(); 00169 }
void hmc6352_exit_cal | ( | ) |
00171 { 00172 00173 // Send hmc6352 addr (write) 00174 // Send command E (Exit user calibration mode) 00175 00176 i2c_start(); 00177 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00178 i2c_send_byte(hmc6352_exit_cal_cmd); 00179 i2c_stop(); 00180 }
uns16 hmc6352_get_data | ( | ) |
00193 { 00194 00195 // Send hmc6352 addr (write) 00196 // Send command A (get data) 00197 00198 // Send hmc6352 addr (read) 00199 // Read data 00200 // Read data 00201 00202 uns16 data; 00203 00204 i2c_start(); 00205 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00206 i2c_send_byte(hmc6352_get_data_cmd); 00207 i2c_stop(); 00208 00209 i2c_start(); 00210 i2c_send_byte(hmc6352_device_addr | hmc6352_read); 00211 data = i2c_receive_byte(); 00212 delay_ms(1); 00213 i2c_send_ack(); 00214 data = data << 8; 00215 data = data + i2c_receive_byte(); 00216 delay_ms(1); 00217 i2c_send_ack(); 00218 i2c_stop(); 00219 00220 return data; 00221 }
uns8 hmc6352_read_eeprom | ( | uns8 | addr | ) |
00055 { 00056 00057 // Send hmc6352 addr (write) 00058 // Send command r (read from eeprom) 00059 // Send eeprom addr 00060 00061 // Send hmc6352 addr (read) 00062 // Read data 00063 00064 uns8 data; 00065 00066 i2c_start(); 00067 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00068 i2c_send_byte(hmc6352_read_from_eeprom); 00069 i2c_send_byte(addr); 00070 i2c_stop(); 00071 00072 i2c_start(); 00073 i2c_send_byte(hmc6352_device_addr | hmc6352_read); 00074 data = i2c_receive_byte(); 00075 i2c_send_ack(); 00076 i2c_stop(); 00077 00078 return data; 00079 }
uns8 hmc6352_read_ram | ( | uns8 | addr | ) |
00099 { 00100 00101 // Send hmc6352 addr (write) 00102 // Send command g (read from ram) 00103 // Send ram addr 00104 00105 // Send hmc6352 addr (read) 00106 // Read data 00107 00108 uns8 data; 00109 00110 i2c_start(); 00111 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00112 i2c_send_byte(hmc6352_read_from_ram); 00113 i2c_send_byte(addr); 00114 i2c_stop(); 00115 00116 i2c_start(); 00117 i2c_send_byte(hmc6352_device_addr | hmc6352_read); 00118 data = i2c_receive_byte(); 00119 i2c_send_ack(); 00120 i2c_stop(); 00121 00122 return data; 00123 }
void hmc6352_save_op_mode | ( | ) |
00182 { 00183 // Send hmc6352 addr (write) 00184 // Send command L (Save op mode to eeprom) 00185 00186 i2c_start(); 00187 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00188 i2c_send_byte(hmc6352_save_op_mode_cmd); 00189 i2c_stop(); 00190 00191 }
void hmc6352_set_mode | ( | uns8 | mode | ) |
00225 { 00226 00227 uns8 data; 00228 data = hmc6352_read_ram(0x74); 00229 00230 switch (mode) { 00231 case hmc6352_mode_standby: 00232 data.1 = 0; 00233 data.0 = 0; 00234 break; 00235 case hmc6352_mode_query: 00236 data.1 = 0; 00237 data.0 = 1; 00238 break; 00239 case hmc6352_mode_continuous: 00240 data.1 = 1; 00241 data.0 = 0; 00242 break; 00243 } 00244 hmc6352_write_ram(0x74, data); 00245 }
void hmc6352_setup_io | ( | ) |
void hmc6352_sleep | ( | ) |
00125 { 00126 00127 // Send hmc6352 addr (write) 00128 // Send command S (sleep) 00129 00130 i2c_start(); 00131 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00132 i2c_send_byte(hmc6352_sleep_cmd); 00133 i2c_stop(); 00134 }
void hmc6352_update_bridge_offsets | ( | ) |
00149 { 00150 00151 // Send hmc6352 addr (write) 00152 // Send command O (update bridge offsets) 00153 00154 i2c_start(); 00155 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00156 i2c_send_byte(hmc6352_update_bridge_cmd); 00157 i2c_stop(); 00158 }
void hmc6352_wake | ( | ) |
00137 { 00138 00139 // Send hmc6352 addr (write) 00140 // Send command W (wake) 00141 00142 i2c_start(); 00143 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00144 i2c_send_byte(hmc6352_wake_cmd); 00145 i2c_stop(); 00146 00147 } //37208656
void hmc6352_write_eeprom | ( | uns8 | addr, | |
uns8 | data | |||
) |
00040 { 00041 00042 // Send hmc6352 addr (write) 00043 // Send command w (write to eeprom) 00044 // Send eeprom addr 00045 // Send data 00046 00047 i2c_start(); 00048 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00049 i2c_send_byte(hmc6352_write_to_eeprom); 00050 i2c_send_byte(addr); 00051 i2c_send_byte(data); 00052 i2c_stop(); 00053 }
void hmc6352_write_ram | ( | uns8 | addr, | |
uns8 | data | |||
) |
00082 { 00083 00084 // Send hmc6352 addr (write) 00085 // Send command G (write to ram) 00086 // Send ram addr 00087 // Send data 00088 00089 i2c_start(); 00090 i2c_send_byte(hmc6352_device_addr | hmc6352_write); 00091 i2c_send_byte(hmc6352_write_to_ram); 00092 i2c_send_byte(addr); 00093 i2c_send_byte(data); 00094 i2c_stop(); 00095 00096 }