ms5611.c File Reference

Include dependency graph for ms5611.c:

Defines

#define MS5511_PROM_READ   0xa0
#define MS5511_RESET   0x1e

Functions

uns8 ms5511_calc_crc (uns8 n_prom[])
void ms5511_calc_temp_and_pressure ()
uns16 ms5511_get_config (uns8 config_word)
uns32 ms5511_get_raw_pressure ()
uns32 ms5511_get_raw_temp ()
void ms5511_init ()
void ms5511_reset ()
void ms5511_setup_io (void)

Variables

int16 c1
int16 c2
int16 c3
int16 c4
int16 c5
int16 c6

Define Documentation

#define MS5511_PROM_READ   0xa0
#define MS5511_RESET   0x1e

Function Documentation

uns8 ms5511_calc_crc ( uns8  n_prom[]  ) 

00164 {
00165     int cnt; // simple counter
00166     uns16 n_rem; // crc reminder
00167     uns16 crc_read; // original value of the crc
00168     uns8 n_bit;
00169     
00170     n_rem = 0x00;
00171     crc_read = n_prom[7]; //save read CRC
00172     n_prom[7] = (0xFF00 & (n_prom[7])); //CRC byte is replaced by 0
00173     
00174     for (cnt = 0; cnt < 16; cnt++) { // operation is performed on bytes
00175     
00176          // choose LSB or MSB
00177         if (cnt%2==1) n_rem ^= (unsigned short) ((n_prom[cnt>>1]) & 0x00FF);
00178         else n_rem ^= (unsigned short) (n_prom[cnt>>1]>>8);
00179         
00180         for (n_bit = 8; n_bit > 0; n_bit--) {
00181         
00182             if (n_rem & (0x8000)) {
00183                 n_rem = (n_rem << 1) ^ 0x3000;
00184             } else {
00185                 n_rem = (n_rem << 1);
00186             }
00187         }
00188     }
00189     n_rem = (0x000F & (n_rem >> 12)); // // final 4-bit reminder is CRC code
00190     n_prom[7] = crc_read; // restore the crc_read to its original place
00191 
00192     return (n_rem ^ 0x00);
00193 
00194 }

void ms5511_calc_temp_and_pressure (  ) 

00160                                      {
00161 }   

uns16 ms5511_get_config ( uns8  config_word  ) 

00067                                           {
00068 
00069 return i2c_read_eeprom_16bit(MS5511_ADDR << 1, MS5511_PROM_READ + (config_word << 1));
00070 
00071 uns8 r1, r2;
00072 
00073     i2c_start();
00074     i2c_send_byte(MS5511_ADDR << 1);
00075     i2c_send_byte(MS5511_PROM_READ + (config_word << 1));
00076     i2c_stop();
00077     
00078     i2c_start();
00079     i2c_send_byte((MS5511_ADDR << 1) + 1);   // read
00080     
00081     r1 = i2c_receive_byte();
00082     serial_print_str("r1=");
00083     serial_print_int_hex(r1);
00084     serial_print_nl();
00085     
00086     r2 = i2c_receive_byte();
00087     serial_print_str("r2=");
00088     serial_print_int_hex(r2);
00089     serial_print_nl();
00090     
00091     return (r1 << 8) + r2;
00092     
00093 
00094 }   

Here is the call graph for this function:

Here is the caller graph for this function:

uns32 ms5511_get_raw_pressure (  ) 

00096                                 {
00097 
00098 uns32 result;
00099 
00100     return result;
00101     
00102 }

uns32 ms5511_get_raw_temp (  ) 

00104                             {
00105 
00106 }

void ms5511_init (  ) 

00108                    {
00109 uns16 c0, c7;
00110     // reset
00111     ms5511_reset();
00112 
00113     // get config
00114     c0 = ms5511_get_config(0);
00115     
00116     serial_print_str("C1\n");
00117     c1 = ms5511_get_config(1);
00118     serial_print_str("C2\n");
00119     c2 = ms5511_get_config(2);
00120     serial_print_str("C3\n");
00121     c3 = ms5511_get_config(3);
00122     serial_print_str("C4\n");
00123     c4 = ms5511_get_config(4);
00124     serial_print_str("C5\n");
00125     c5 = ms5511_get_config(5);
00126     serial_print_str("C6    \n");
00127     c6 = ms5511_get_config(6);
00128     c7 = ms5511_get_config(7);
00129 
00130     serial_print_str("c0=");
00131     serial_print_int(c0);
00132     serial_print_nl();
00133     serial_print_str("c1=");
00134     serial_print_int(c1);
00135     serial_print_nl();
00136     serial_print_str("c2=");
00137     serial_print_int(c2);
00138     serial_print_nl();
00139     serial_print_str("c3=");
00140     serial_print_int(c3);
00141     serial_print_nl();
00142     serial_print_str("c4=");
00143     serial_print_int(c4);
00144     serial_print_nl();
00145     serial_print_str("c5=");
00146     serial_print_int(c5);
00147     serial_print_nl();
00148     serial_print_str("c6=");
00149     serial_print_int(c6);
00150     serial_print_nl();
00151     serial_print_str("c7=");
00152     serial_print_int(c7);
00153     serial_print_nl();
00154 
00155     
00156 }

Here is the call graph for this function:

void ms5511_reset (  ) 

00056                     {
00057 
00058     i2c_start();
00059     i2c_send_byte(MS5511_ADDR << 1);
00060     i2c_send_byte(MS5511_RESET);
00061     i2c_stop();
00062 
00063 }

Here is the call graph for this function:

Here is the caller graph for this function:

void ms5511_setup_io ( void   ) 

00048                            {
00049     
00050     i2c_setup_io();
00051     
00052 }

Here is the call graph for this function:


Variable Documentation

int16 c1
int16 c2
int16 c3
int16 c4
int16 c5
int16 c6

Generated on Fri Aug 19 09:07:44 2011 for Pic Pack Library by  doxygen 1.6.1