Problem with comparison.
/Modules/Sensors/ALTIMET01A/SW/MPL115A1/PIC/PIC16F887/main.hex |
---|
0,0 → 1,280 |
:1000000007308A001C2F0000533A613974100D0527 |
:10001000000083168613831286130830F800102818 |
:100020000000F8172128F813C60C03188617031CC4 |
:100030008613781721287813F80B14281F2800003E |
:1000400086173F308400840B23280000F81B1328F8 |
:10005000781B1B280800831603178C170C1400004C |
:10006000000083120C087F3903196F280313B100B5 |
:1000700003170D080313B20003170F080313B3008F |
:100080003108C6000920320803178D000313330816 |
:1000900003178F0083168C170C14000000008312C6 |
:1000A0000C0D0E0D7F3903196F280313B1000317D0 |
:1000B0000D080313B20003170F080313B300310830 |
:1000C000C6000920320803178D00031333080317F5 |
:1000D0008F008D0A03198F0A03132B2803170313AC |
:1000E0008A110A12402F3B30840083130008031941 |
:1000F00086280230F800F701F70B7C28F80B7B28E4 |
:100100009730F700F70B8228800B792808008E3093 |
:10011000F7004208F8004108F900FA01F808031D49 |
:100120009B287908F800F9010830F702F808031D48 |
:100130009B28F701A3280310F81BA228F90DF80D3E |
:10014000F7039B28F81308003E0803196929CA0021 |
:10015000420803196929CA02031CB3287F30CA0761 |
:1001600003186929B9288130CA02031C69290319B7 |
:1001700069294A08F700F801F901FA01C9013F08A5 |
:10018000C800C8174008C7004108C6001930CA0097 |
:100190004508C6020318DC280130C7020318DC2812 |
:1001A000C8020318DC28C9020318DC28C90AC80AD7 |
:1001B000C70A4508C6070E294408C7020318F728CE |
:1001C0000130C8020318F728C9020318F728C90A22 |
:1001D000C80A4408C7074508C607031C0E29C70AF2 |
:1001E000031D0E29C80A031D0E29C90A0E2943083A |
:1001F0008038C80203180D290130C90203180D29DF |
:10020000C90A43088038C8074408C707031CEB28FD |
:10021000C80A031DEB28C90AEB287A14CA0B112956 |
:100220001C290310C60DC70DC80DC90D0310FA0D0A |
:10023000F90DF80DCB0DC8284B1C24290310F80C20 |
:10024000F90CFA0CCB0C2729F70303196929CB1BEE |
:1002500050290310C60DC70DC80DC90D4508C602AB |
:1002600003183C290130C70203183C29C8020318AF |
:100270003C29C902031C5F294408C7020318472907 |
:100280000130C80203184729C902031C5F2943082B |
:100290008038C802031850290130C902031C5F29A5 |
:1002A000FA0A031D5F29F90A031D5F29F80A031DD5 |
:1002B0005F29F70A03196929F80CF90CFA0C3F08B1 |
:1002C000CA004308CA06CA1F6729F8176D29F81320 |
:1002D0006D29F701F801F901FA010800803083184F |
:1002E000C606CB01CC014208CA004608CA0641082E |
:1002F00003195E2AC900F70045080319672AC902D5 |
:100300000319032A031CC1294608CF00CF17470849 |
:10031000CE004808CD00CC010310CF0CCE0CCD0C84 |
:10032000CC0CC90B8B29CA1F98294B147B2A4B1064 |
:1003300049104B16443084008313902A4B12CA1B79 |
:10034000AB29491CB629CF0CCE0CCD0CCC0CF70A2E |
:100350000319762AB629CF1BB9290310CC0DCD0D70 |
:10036000CE0DCF0DF7030319762AAB294B17232A9D |
:100370004B134208CA00CA1FBF29CF176F2ACF13D9 |
:100380006F2A4508C900F7004108C9024208CF009A |
:10039000CF174308CE004408CD00CC010310CF0C8A |
:1003A000CE0CCD0CCC0CC90BCD29CA1FDA29CB142D |
:1003B0007B2ACB104910CB16483084008313902A37 |
:1003C000CB12CA1BED29491CF829CF0CCE0CCD0C41 |
:1003D000CC0CF70A0319762AF829CF1BFB29031046 |
:1003E000CC0DCD0DCE0DCF0DF7030319762AED29D7 |
:1003F000CB17232ACB134608CA00CA1F012ACF17DE |
:100400006F2ACF136F2A4608CF00CF174708CE00B8 |
:100410004808CD00CA1F102ACF134B157B2A4B1159 |
:10042000CC014910443084008313902ACA1B392A16 |
:100430004208CA00491C232ACF0CCE0CCD0CCC0C90 |
:10044000F70A0319762ACC1F342ACD0A031D342A51 |
:10045000CE0A031D342ACF0A031D342ACF0CCE0C3A |
:10046000CD0CF70A0319762A4B1BB829CB1BFA29A6 |
:10047000582A8030CF06CF1F412A7B2A4608CA005F |
:100480004E2A4208CA00CF08031D4E2ACE08031D7B |
:100490004E2ACD08031D4E2AF7016F2ACF1B582A7A |
:1004A0000310CC0DCD0DCE0DCF0DF70B4E2A762AB5 |
:1004B000CA1F5C2ACF176F2ACF136F2A4508F7008F |
:1004C0004608CF004708CE004808CD006F2A4108F3 |
:1004D000F7004208CF004308CE004408CD004F0883 |
:1004E000F8004E08F9004D08FA00AE2AF701F801AD |
:1004F000F901FA01AE2ACC01CD09CE09CF09CC0908 |
:10050000CC0A031D892ACD0A031D892ACE0A0319A4 |
:10051000CF0A4B189729CB18D9294B190F2A3E2AF5 |
:100520000008CD07031C9A2ACE0A031D9A2ACF0A77 |
:100530000319491484030008CE07031CA22ACF0A1A |
:100540000319491484030008801F803ACF07031859 |
:1005500049144B1A9E29CB1AE029162A080030119B |
:100560003008831687008312071113088830930020 |
:100570008316140C031CB92A8312130893018316E3 |
:10058000140C031CC02A83121308B10013088A300C |
:1005900093008316140C031CCA2A831213089301B8 |
:1005A0008316140C031CD12A83121308B2001308FB |
:1005B0008C3093008316140C031CDB2A831213085F |
:1005C00093018316140C031CE22A83121308B30050 |
:1005D00013088E3093008316140C031CEC2A83122C |
:1005E000130893018316140C031CF32A83121308B7 |
:1005F000B4001308903093008316140C031CFD2ADA |
:100600008312130893018316140C031C042B83120A |
:100610001308B5001308923093008316140C031CC2 |
:100620000E2B8312130893018316140C031C152B35 |
:1006300083121308B6001308943093008316140C29 |
:10064000031C1F2B8312130893018316140C031C25 |
:10065000262B83121308B7001308963093008316D5 |
:10066000140C031C302B8312130893018316140CF3 |
:10067000031C372B83121308B80013089301831649 |
:10068000140C031C402B8312301130088316870092 |
:1006900083120715BA013108B900B90DBA0DB90DA9 |
:1006A000BA0DB90DBA0DB90DBA0DB90DBA0DE030CC |
:1006B000B905320CF700F70CF70C1F30F705770877 |
:1006C000B9070318BA0A32080739C201C1008720E6 |
:1006D0007A08C1007908C0007808BF007708BE001A |
:1006E000C501C401C3018230C200A4207708BD0047 |
:1006F0007808BE007908BF007A08C0003A08C20036 |
:100700003908C100872083107A08C4007908C30023 |
:100710007808C2007708C1004008C8003F08C70039 |
:100720003E08C6003D08C5006E217A08A30079087E |
:10073000A2007808A1007708A00033081F39FA0149 |
:10074000BA00B9013408B9070318BA0A3A08C20056 |
:100750003908C10087207A08C1007908C0007808EC |
:10076000BF007708BE00C501C401C3018C30C200C0 |
:10077000A4207708B9007808BA007908BB007A0885 |
:10078000BC0083147A08C4007908C3007808C2004A |
:100790007708C100C801C7014030C6008030C500DD |
:1007A0006E217A08A7007908A6007808A5007708C6 |
:1007B000A40080303502BA01B900BA00B901360888 |
:1007C000B9070318BA0A3A08C2003908C1008720DD |
:1007D0007A08C1007908C0007808BF007708BE0019 |
:1007E000C501C401C3018D30C200A4207708B9003F |
:1007F0007808BA007908BB007A08BC0083147A082C |
:10080000C4007908C3007808C2007708C100C80195 |
:10081000C701C6018030C5006E217A08AB00790897 |
:10082000AA007808A9007708A800FA013708BA00DA |
:10083000B9013808B9070318BA0A3A08C2003908DA |
:10084000C10087207A08C1007908C0007808BF007D |
:100850007708BE00C501C401C3019730C200A420BF |
:100860007A08AF007908AE007808AD007708AC00D0 |
:100870008A110A12602F46080319AB2CCE004A08D1 |
:100880000319AB2CCE0703184C2C7F30CE02031C6F |
:10089000AB2C0319AB2C502C8130CE070318AB2C9A |
:1008A0004E08F700F801F901FA014708D200D21703 |
:1008B0004808D1004908D0001830CE00CF01501CA4 |
:1008C000792C4D08FA07031C6B2CF90A031D6B2CBD |
:1008D000F80A0319CF174C08F907031C722CF80A01 |
:1008E0000319CF174B08C800C8174808F8070318A2 |
:1008F000CF17CF0DF80CF90CFA0CD20CD10CD00C90 |
:100900000310CE0B5E2C0130F7070318AB2CF81B3D |
:10091000902CD20DFA0DF90DF80DF7030319AB2C3D |
:10092000D21FA12CFA0A031DA12CF90A031DA12C28 |
:10093000F80A031DA12CF80CF90CFA0CF70A03199C |
:10094000AB2C4708CF004B08CF06CF1FA92CF817B8 |
:10095000AF2CF813AF2CF701F801F901FA010800E8 |
:1009600030113008831687008312071113082430D2 |
:1009700093008316140C031CBA2C831213089301E2 |
:100980008316140C031CC12C8312301130088316FB |
:100990008700831207150A30BB007320301130081E |
:1009A0008316870083120711130880309300831683 |
:1009B000140C031CD82C8312130893018316140CF7 |
:1009C000031CDF2C83121308B2001308823093003B |
:1009D0008316140C031CE92C83121308930183164D |
:1009E000140C031CF02C83121308B10030113008D2 |
:1009F0008316870083120715BC013208BB00BC00B8 |
:100A0000BB013108BB070318BC0A3C0CB4003B0C0B |
:100A1000B300B40CB30CB40CB30CB40CB30CB40CE6 |
:100A2000B30CB40CB30C0330B4053011300883168A |
:100A30008700831207111308843093008316140C67 |
:100A4000031C1F2D8312130893018316140C031C1F |
:100A5000262D83121308B2001308863093008316E4 |
:100A6000140C031C302D8312130893018316140CED |
:100A7000031C372D83121308B1001308930183164A |
:100A8000140C031C402D831230113008831687008C |
:100A900083120715BC013208BB00BC00BB01310842 |
:100AA000BB070318BC0A3C0CB6003B0CB500B60CE7 |
:100AB000B50CB60CB50CB60CB50CB60CB50CB60C2A |
:100AC000B50C0330B6053608C2003508C1008720D2 |
:100AD0002F08C9002E08C8002D08C7002C08C60022 |
:100AE0007A08CD007908CC007808CB007708CA00D6 |
:100AF0003B2483102708C4002608C3002508C20031 |
:100B00002408C1007A08C8007908C7007808C60020 |
:100B10007708C5006E217708BB007808BC0079080B |
:100B2000BD007A08BE003408C2003308C100872027 |
:100B30003E08C9003D08C8003C08C7003B08C60085 |
:100B40007A08CD007908CC007808CB007708CA0075 |
:100B50003B2483102308C4002208C3002108C200DC |
:100B60002008C1007A08C8007908C7007808C600C4 |
:100B70007708C5006E217708BB007808BC007908AB |
:100B8000BD007A08BE003608C2003508C1008720C3 |
:100B90002B08C9002A08C8002908C7002808C60071 |
:100BA0007A08CD007908CC007808CB007708CA0015 |
:100BB0003B2483103E08C4003D08C3003C08C2002B |
:100BC0003B08C1007A08C8007908C7007808C60049 |
:100BD0007708C5006E217A08BA007908B90078084C |
:100BE000B8007708B7003A08C9003908C8003808C3 |
:100BF000C7003708C6008830CD002030CC00023056 |
:100C0000CB007B30CA003B247708BB007808BC00CF |
:100C10007908BD007A08BE0083107A08C4007908FC |
:100C2000C3007808C2007708C100C801C701483076 |
:100C3000C6008430C5006E218A110A12612F30115E |
:100C4000300883168700831207111308223093009F |
:100C50008316140C031C292E831213089301831688 |
:100C6000140C031C302E83123011300883168700B9 |
:100C7000831207150A30BB00732030113008831629 |
:100C80008700831207111308843093008316140C15 |
:100C9000031C472E8312130893018316140C031CA4 |
:100CA0004E2E83121308B600130886309300831665 |
:100CB000140C031C582E8312130893018316140C72 |
:100CC000031C5F2E83121308B500130893018316CB |
:100CD000140C031C682E8312301130088316870011 |
:100CE00083120715BA013608B900BA00B9013508F0 |
:100CF000B9070318BA0A3A0CB800390CB700B80C97 |
:100D0000B70CB80CB70CB80CB70CB80CB70CB80CC7 |
:100D1000B70C0330B8053808C2003708C100872077 |
:100D20007708B9007808BA007908BB007A08BC00D7 |
:100D300083147A08C4007908C3007808C2007708D1 |
:100D4000C100C801C7017930C6008730C5006E21D7 |
:100D50007708B9007808BA007908BB007A08BC00A7 |
:100D6000C1007908C0007808BF007708BE003330A2 |
:100D7000C500C400AB30C3008130C200A420770896 |
:100D8000B9007808BA007908BB007A08BC00831063 |
:100D90007A08C4007908C3007808C2007708C10047 |
:100DA000C801C7014830C6008330C5006E218A11D2 |
:100DB0000A126A2FF701F801F901FA01CE01CF01F9 |
:100DC000D001D1014D084C044B044A040319182FDB |
:100DD0002030D2000310C60DC70DC80DC90DCE0DB1 |
:100DE000CF0DD00DD10D4D085102031D012F4C0820 |
:100DF0005002031D012F4B084F02031D012F4A080B |
:100E00004E02031C122F4A08CE024B08031C4B0F44 |
:100E1000CF024C08031C4C0FD0024D08031C4D0F91 |
:100E2000D1020314F70DF80DF90DFA0DD20BEA2ECD |
:100E30004E30840083130800840183131F30830520 |
:100E4000713083168F000F0886138312861783165E |
:100E500003170908C039890003131F129F120030BD |
:100E6000031788008312870188018901FF3003136B |
:100E7000B000043003178D0000308F0003132B28BF |
:100E80009412B0123008831687008312301630088F |
:100E9000831687008312B011300883168700223032 |
:100EA000831294004030831694008312301130086E |
:100EB00083168700831207156430BB007320AF2AA6 |
:100EC000B02C7708B1007808B2007908B3007A082E |
:100ED000B4001F2E7708B5007808B6007908B7006F |
:100EE0007A08B800893084003408BC003308BB009D |
:100EF0003208BA003108B9000230BD008A1500205E |
:100F00008A112030C6000920893084003808BC00CE |
:100F10003708BB003608BA003508B9000230BD00FA |
:100F20008A1500208A112030C60009200D30C60025 |
:100F300009200A30C60009200230B100FA30BB0097 |
:0A0F40007320B10B9E2F602F630099 |
:101000000408BE003D08C000031921283C08C9009F |
:101010003B08C8003A08C7003908C600CD01CC011A |
:101020002030CB008230CA008A113B248A157A080E |
:10103000BC007908BB007808BA007708B900C00B7B |
:1010400006283C08C9003B08C8003A08C700390810 |
:10105000C6004608B63CC600FA014708CA00C717D2 |
:101060000310C70CC80CC90CFA0CF90CF80CF70CDF |
:10107000C60B3028CA1F4728F709F809F909FA09E9 |
:10108000F70A0319F80A0319F90A0319FA0A7A0880 |
:10109000BC007908BB007808BA007708B900BC1F0B |
:1010A0005E28BE03BE16B909BA09BB09BC09B90A54 |
:1010B0000319BA0A0319BB0A0319BC0A3B30C5005D |
:1010C0009A30C400CA30C300C2010A30C0003D08D3 |
:1010D0000319BE0A3C08C9003B08C8003A08C7000B |
:1010E0003908C6004508CD004408CC004308CB00B1 |
:1010F0004208CA008A11DA268A150008B900840A53 |
:101100000008BA00840A0008BB00840A0008BC007A |
:10111000FD308407F708031DA0283D0A400203198B |
:10112000A0283E080319A2280F39400203199A2863 |
:101130000318DA28BE1BDA283E1BA2282030D42848 |
:101140002030BE05BE1EB228BE123D08031DBE03E0 |
:101150007708BE002D30C6008A1109208A153E0886 |
:10116000F700BE013D084002031DC2287708BE00FB |
:101170002E30C6008A1109208A153E08F70020305B |
:10118000BE0500303030BE1ED428BE123D08031DFF |
:10119000BE037708BE002D30C6008A1109208A15CB |
:1011A0003E08F700BE013030F7077708C6008A1105 |
:1011B00009208A154508C9004408C8004308C7002B |
:1011C0004208C600CD01CC01CB010A30CA008A1109 |
:1011D000DA268A157A08C5007908C4007808C300A1 |
:0A11E0007708C200C00B6A2808005F |
:04400E00F52CFF3F4F |
:00000001FF |
;PIC16F887 |
;CRC=77E3 CREATED="06-VI-13 00:23" |
/Modules/Sensors/ALTIMET01A/SW/MPL115A1/PIC/PIC16F887/main.pjt |
---|
0,0 → 1,31 |
[PROJECT] |
Target=main.hex |
Development_Mode= |
Processor_Text=PIC16F887 |
ToolSuite=CCS |
Processor=0x887F |
[main] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=main.c |
[Windows] |
0=0000 %S 0 0 796 451 3 0 |
[Opened Files] |
1=main.c |
2=main.h |
3=C:\Program Files (x86)\PICC\devices\16F887.h |
4=MPL115A1.c |
5= |
6=..\1wire.c |
7= |
[Target Data] |
OptionString=-p +FM |
FileList=Z:\home\kaklik\svnMLAB\Modules\Sensors\ALTIMET01A\SW\MPL115A1\PIC\PIC16F887\main.c |
[Units] |
Count=1 |
1=main (main) |
/Modules/Sensors/ALTIMET01A/SW/MPL115A1/PIC/PIC16F887/MPL115A1.c |
---|
0,0 → 1,125 |
/* |
MPL115A1 SDN - +3.3V (always power on) |
MPL115A1 #CS - PIN_C2 |
MPL115A1 DOUT - PIN_C4 |
MPL115A1 DIN - PIN_C5 |
MPL115A1 SCLK - PIN_C3 |
MPL115A1 GND - GND |
MPL115A1 VDD - +3.3V |
*/ |
// SPI mode definitions. |
#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H) |
#define SPI_MODE_1 (SPI_L_TO_H) |
#define SPI_MODE_2 (SPI_H_TO_L) |
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H) |
float a0; // correctiaon coefficients |
float b1; |
float b2; |
float c12; |
void MPL_init() |
{ |
unsigned int8 a0_MSB, a0_LSB; |
unsigned int8 b1_MSB, b1_LSB; |
unsigned int8 b2_MSB, b2_LSB; |
unsigned int8 c12_MSB, c12_LSB; |
output_low(CSN_SPI); |
spi_write(0x88); // get MSB for a0 |
a0_MSB = spi_read(0x00); |
spi_write(0x8A); // get LSB for a0 |
a0_LSB = spi_read(0x00); |
spi_write(0x8C); // get MSB for b1 |
b1_MSB = spi_read(0x00); |
spi_write(0x8E); // get LSB for b1 |
b1_LSB = spi_read(0x00); |
spi_write(0x90); // get MSB for b2 |
b2_MSB = spi_read(0x00); |
spi_write(0x92); // get LSB for b2 |
b2_LSB = spi_read(0x00); |
spi_write(0x94); // get MSB for c12 |
c12_MSB = spi_read(0x00); |
spi_write(0x96); // get LSB for c12 |
c12_LSB = spi_read(0x00); |
spi_read(0x00); |
output_high(CSN_SPI); |
// translate to floating point number |
a0 = ((unsigned int16) a0_MSB << 5) + (a0_LSB >> 3) + (a0_LSB & 0x07)/8.0; |
b1 = ((((b1_MSB & 0x1F) * 0x100) + b1_LSB) / 8192.0) - 3; |
b2 = ((((unsigned int16) (b2_MSB - 0x80) << 8) + b2_LSB)/ 16384.0) - 2; |
c12 =(((c12_MSB * 0x100) + c12_LSB)/16777216.0); |
} |
float MPL_get_pressure() |
{ |
unsigned int8 LSB_data, MSB_data; |
unsigned int16 ADC_pressure, ADC_temperature; |
float Pcomp; |
output_low(CSN_SPI); //Start temperature and pressure conversion |
spi_write(0x24); |
spi_write(0x00); |
output_high(CSN_SPI); |
delay_ms(10); |
output_low(CSN_SPI); // get MSB for Pressure |
spi_write(0x80); |
MSB_data = spi_read(0x00); |
spi_write(0x82); // get LSB for Pressure |
LSB_data = spi_read(0x00); |
output_high(CSN_SPI); |
ADC_pressure = (((unsigned int16) MSB_data << 8) + LSB_data ) >> 6; // conversion of 8bit registers to 16bit variable |
output_low(CSN_SPI); |
spi_write(0x84); |
MSB_data = spi_read(0x00); |
spi_write(0x86); // get LSB for Temperature |
LSB_data = spi_read(0x00); |
spi_read(0x00); |
output_high(CSN_SPI); |
ADC_temperature = (((unsigned int16) MSB_data << 8) + LSB_data ) >> 6; // conversion of 8bit registers to 16bit variable |
Pcomp = (a0 + (b1 + c12 * ADC_temperature) * ADC_pressure + b2 * ADC_temperature ); // compute relative compensated pressure |
return (Pcomp * ((115.0 - 50.0)/1023.0) + 50.0); // return absolute pressure |
} |
float MPL_get_temperature() |
{ |
unsigned int8 LSB_data, MSB_data; |
unsigned int16 ADC_temperature; |
output_low(CSN_SPI); //Start temperature and pressure conversion |
spi_write(0x22); |
spi_write(0x00); |
output_high(CSN_SPI); |
delay_ms(10); |
output_low(CSN_SPI); |
spi_write(0x84); |
MSB_data = spi_read(0x00); |
spi_write(0x86); // get LSB for Temperature |
LSB_data = spi_read(0x00); |
spi_read(0x00); |
output_high(CSN_SPI); |
ADC_temperature = (((unsigned int16) MSB_data << 8) + LSB_data ) >> 6; // conversion of 8bit registers to 16bit variable |
return ( ((float) ADC_temperature - 498.0)/-5.35) + 25.0; // return temperature in deg C |
} |
/Modules/Sensors/ALTIMET01A/SW/MPL115A1/PIC/PIC16F887/main.c |
---|
0,0 → 1,30 |
#include <main.h> |
/* |
MPL115A1 SDN - +3.3V (always power on) |
MPL115A1 #CS - PIN_C2 |
MPL115A1 DOUT - PIN_C4 |
MPL115A1 DIN - PIN_C5 |
MPL115A1 SCLK - PIN_C3 |
MPL115A1 GND - GND |
MPL115A1 VDD - +3.3V |
*/ |
#define CSN_SPI PIN_C2 |
#include "MPL115A1.c" |
void main() |
{ |
printf("Start \r\n"); |
setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64); |
output_high(CSN_SPI); |
delay_ms(100); |
MPL_init(); // get correction coefficients from the sensor |
while(true) |
{ |
printf("%f %f \r\n", MPL_get_pressure(), MPL_get_temperature()); |
delay_ms(500); |
} |
} |
/Modules/Sensors/ALTIMET01A/SW/MPL115A1/PIC/PIC16F887/main.h |
---|
0,0 → 1,20 |
#include <16F887.h> |
#device adc=10 |
#FUSES NOWDT //No Watch Dog Timer |
#FUSES INTRC //Internal RC Osc |
#FUSES NOPUT //No Power Up Timer |
#FUSES MCLR //Master Clear pin enabled |
#FUSES NOPROTECT //Code not protected from reading |
#FUSES NOCPD //No EE protection |
#FUSES NOBROWNOUT //No brownout reset |
#FUSES IESO //Internal External Switch Over mode enabled |
#FUSES FCMEN //Fail-safe clock monitor enabled |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
#FUSES NODEBUG //No Debug mode for ICD |
#FUSES NOWRT //Program memory not write protected |
#FUSES BORV40 //Brownout reset at 4.0V |
#use delay(clock=8000000) |
#use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B6,bits=8) |
/Modules/Sensors/ALTIMET01A/SW/MPL115A1/AVR/ATmega328/MPL115A1.h |
---|
0,0 → 1,17 |
#define PRESH 0x00 // 80 |
#define PRESL 0x02 // 82 |
#define TEMPH 0x04 // 84 |
#define TEMPL 0x06 // 86 |
#define A0MSB 0x08 // 88 |
#define A0LSB 0x0A // 8A |
#define B1MSB 0x0C // 8C |
#define B1LSB 0x0E // 8E |
#define B2MSB 0x10 // 90 |
#define B2LSB 0x12 // 92 |
#define C12MSB 0x14 // 94 |
#define C12LSB 0x16 // 96 |
#define C11MSB 0x18 // 98 |
#define C11LSB 0x1A // 9A |
#define C22MSB 0x1C // 9C |
#define C22LSB 0x1E // 9E |
/Modules/Sensors/ALTIMET01A/SW/MPL115A1/AVR/ATmega328/Makefile |
---|
0,0 → 1,667 |
# Hey Emacs, this is a -*- makefile -*- |
#---------------------------------------------------------------------------- |
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. |
# |
# Released to the Public Domain |
# |
# Additional material for this makefile was written by: |
# Peter Fleury |
# Tim Henigan |
# Colin O'Flynn |
# Reiner Patommel |
# Markus Pfaff |
# Sander Pool |
# Frederik Rouleau |
# Carlos Lamas |
# |
#---------------------------------------------------------------------------- |
# On command line: |
# |
# make all = Make software. |
# |
# make clean = Clean out built project files. |
# |
# make coff = Convert ELF to AVR COFF. |
# |
# make extcoff = Convert ELF to AVR Extended COFF. |
# |
# make program = Download the hex file to the device, using avrdude. |
# Please customize the avrdude settings below first! |
# |
# make debug = Start either simulavr or avarice as specified for debugging, |
# with avr-gdb or avr-insight as the front end for debugging. |
# |
# make filename.s = Just compile filename.c into the assembler code only. |
# |
# make filename.i = Create a preprocessed source file for use in submitting |
# bug reports to the GCC project. |
# |
# To rebuild project do "make clean" then "make all". |
#---------------------------------------------------------------------------- |
# MCU name |
MCU = atmega328p |
# Processor frequency. |
# This will define a symbol, F_CPU, in all source code files equal to the |
# processor frequency. You can then use this symbol in your source code to |
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done |
# automatically to create a 32-bit value in your source code. |
# Typical values are: |
# F_CPU = 1000000 |
# F_CPU = 1843200 |
# F_CPU = 2000000 |
# F_CPU = 3686400 |
# F_CPU = 4000000 |
# F_CPU = 7372800 |
# F_CPU = 8000000 |
# F_CPU = 11059200 |
# F_CPU = 14745600 |
# F_CPU = 16000000 |
# F_CPU = 18432000 |
# F_CPU = 20000000 |
F_CPU = 8000000 |
# Output format. (can be srec, ihex, binary) |
FORMAT = ihex |
# Target file name (without extension). |
TARGET = main |
# Object files directory |
# To put object files in current directory, use a dot (.), do NOT make |
# this an empty or blank macro! |
OBJDIR = . |
# List C source files here. (C dependencies are automatically generated.) |
SRC = $(TARGET).c |
#SRC += LCD_driver.c |
# List C++ source files here. (C dependencies are automatically generated.) |
CPPSRC = |
# List Assembler source files here. |
# Make them always end in a capital .S. Files ending in a lowercase .s |
# will not be considered source files but generated files (assembler |
# output from the compiler), and will be deleted upon "make clean"! |
# Even though the DOS/Win* filesystem matches both .s and .S the same, |
# it will preserve the spelling of the filenames, and gcc itself does |
# care about how the name is spelled on its command-line. |
ASRC = |
# Optimization level, can be [0, 1, 2, 3, s]. |
# 0 = turn off optimization. s = optimize for size. |
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
OPT = s |
# Debugging format. |
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. |
# AVR Studio 4.10 requires dwarf-2. |
# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. |
DEBUG = dwarf-2 |
# List any extra directories to look for include files here. |
# Each directory must be seperated by a space. |
# Use forward slashes for directory separators. |
# For a directory that has spaces, enclose it in quotes. |
EXTRAINCDIRS = |
# Compiler flag to set the C Standard level. |
# c89 = "ANSI" C |
# gnu89 = c89 plus GCC extensions |
# c99 = ISO C99 standard (not yet fully implemented) |
# gnu99 = c99 plus GCC extensions |
CSTANDARD = -std=gnu99 |
# Place -D or -U options here for C sources |
CDEFS = -DF_CPU=$(F_CPU)UL |
# Place -D or -U options here for ASM sources |
ADEFS = -DF_CPU=$(F_CPU) |
# Place -D or -U options here for C++ sources |
CPPDEFS = -DF_CPU=$(F_CPU)UL |
#CPPDEFS += -D__STDC_LIMIT_MACROS |
#CPPDEFS += -D__STDC_CONSTANT_MACROS |
#---------------- Compiler Options C ---------------- |
# -g*: generate debugging information |
# -O*: optimization level |
# -f...: tuning, see GCC manual and avr-libc documentation |
# -Wall...: warning level |
# -Wa,...: tell GCC to pass this to the assembler. |
# -adhlns...: create assembler listing |
CFLAGS = -g$(DEBUG) |
CFLAGS += $(CDEFS) |
CFLAGS += -O$(OPT) |
CFLAGS += -funsigned-char |
CFLAGS += -funsigned-bitfields |
CFLAGS += -fpack-struct |
CFLAGS += -fshort-enums |
CFLAGS += -Wall |
CFLAGS += -Wstrict-prototypes |
#CFLAGS += -mshort-calls |
#CFLAGS += -fno-unit-at-a-time |
#CFLAGS += -Wundef |
#CFLAGS += -Wunreachable-code |
#CFLAGS += -Wsign-compare |
CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) |
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
CFLAGS += $(CSTANDARD) |
#---------------- Compiler Options C++ ---------------- |
# -g*: generate debugging information |
# -O*: optimization level |
# -f...: tuning, see GCC manual and avr-libc documentation |
# -Wall...: warning level |
# -Wa,...: tell GCC to pass this to the assembler. |
# -adhlns...: create assembler listing |
CPPFLAGS = -g$(DEBUG) |
CPPFLAGS += $(CPPDEFS) |
CPPFLAGS += -O$(OPT) |
CPPFLAGS += -funsigned-char |
CPPFLAGS += -funsigned-bitfields |
CPPFLAGS += -fpack-struct |
CPPFLAGS += -fshort-enums |
CPPFLAGS += -fno-exceptions |
CPPFLAGS += -Wall |
CFLAGS += -Wundef |
#CPPFLAGS += -mshort-calls |
#CPPFLAGS += -fno-unit-at-a-time |
#CPPFLAGS += -Wstrict-prototypes |
#CPPFLAGS += -Wunreachable-code |
#CPPFLAGS += -Wsign-compare |
CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) |
CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
#CPPFLAGS += $(CSTANDARD) |
#---------------- Assembler Options ---------------- |
# -Wa,...: tell GCC to pass this to the assembler. |
# -adhlns: create listing |
# -gstabs: have the assembler create line number information; note that |
# for use in COFF files, additional information about filenames |
# and function names needs to be present in the assembler source |
# files -- see avr-libc docs [FIXME: not yet described there] |
# -listing-cont-lines: Sets the maximum number of continuation lines of hex |
# dump that will be displayed for a given single line of source input. |
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 |
#---------------- Library Options ---------------- |
# Minimalistic printf version |
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min |
# Floating point printf version (requires MATH_LIB = -lm below) |
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt |
# If this is left blank, then it will use the Standard printf version. |
#PRINTF_LIB = |
#PRINTF_LIB = $(PRINTF_LIB_MIN) |
PRINTF_LIB = $(PRINTF_LIB_FLOAT) |
# Minimalistic scanf version |
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min |
# Floating point + %[ scanf version (requires MATH_LIB = -lm below) |
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt |
# If this is left blank, then it will use the Standard scanf version. |
SCANF_LIB = |
#SCANF_LIB = $(SCANF_LIB_MIN) |
#SCANF_LIB = $(SCANF_LIB_FLOAT) |
MATH_LIB = -lm |
# List any extra directories to look for libraries here. |
# Each directory must be seperated by a space. |
# Use forward slashes for directory separators. |
# For a directory that has spaces, enclose it in quotes. |
EXTRALIBDIRS = |
#---------------- External Memory Options ---------------- |
# 64 KB of external RAM, starting after internal RAM (ATmega128!), |
# used for variables (.data/.bss) and heap (malloc()). |
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff |
# 64 KB of external RAM, starting after internal RAM (ATmega128!), |
# only used for heap (malloc()). |
#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff |
EXTMEMOPTS = |
#---------------- Linker Options ---------------- |
# -Wl,...: tell GCC to pass this to linker. |
# -Map: create map file |
# --cref: add cross reference to map file |
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
LDFLAGS += $(EXTMEMOPTS) |
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) |
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) |
#LDFLAGS += -T linker_script.x |
#---------------- Programming Options (avrdude) ---------------- |
# Programming hardware: alf avr910 avrisp bascom bsd |
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
# |
# Type: avrdude -c ? |
# to get a full listing. |
# |
#AVRDUDE_PROGRAMMER = stk200 |
AVRDUDE_PROGRAMMER = ponyser |
# com1 = serial port. Use lpt1 to connect to parallel port. |
#AVRDUDE_PORT = lpt1 |
AVRDUDE_PORT = com1 |
# programmer connected to serial device |
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
# Uncomment the following if you want avrdude's erase cycle counter. |
# Note that this counter needs to be initialized first using -Yn, |
# see avrdude manual. |
#AVRDUDE_ERASE_COUNTER = -y |
# Uncomment the following if you do /not/ wish a verification to be |
# performed after programming the device. |
#AVRDUDE_NO_VERIFY = -V |
# Increase verbosity level. Please use this when submitting bug |
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
# to submit bug reports. |
#AVRDUDE_VERBOSE = -v -v |
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) |
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) |
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) |
#---------------- Programming Options (STK500) ---------------- |
# Programming hardware: stk500 |
STK500 = stk500 |
# Location of STK500.exe - no trailing '\' |
STK500_PATH = C:\Program Files\Atmel\AVR Tools\STK500 |
# The STK500 AVR ISP MKII is USB. The USB drivers must already be installed. |
# Do this normally by installing AVR Studio. |
STK500_PORT = USB |
#-erase chip -Program Flash -Verify Flash -File name -Serial programing(ISP) |
STK500_WRITE_FLASH = -e -pf -vf -if$(TARGET).hex -ms |
STK500_WRITE_FLASH += -s |
#Program the Fuse Bytes |
#STK500_FLAGS = -d$(MCU) -c$(STK500_PORT) -fFF79 -FFF79 |
#Skip the Fuse Bytes |
STK500_FLAGS = -d$(MCU) -c$(STK500_PORT) |
#-Set ISP frequency to 250kHz. Limit is 1/4 of internal osc which is default 1MHz |
STK500_FLAGS += -I250kHz |
#---------------- Programming Options (avrdude serial bootloader) ---------------- |
#"C:\arduino\hardware\tools\avr\bin\avrdude" -PCOM28 -c stk500v1 -patmega168 -b19200 -Uflash:w:Simon-PTH-v1.hex -V -F -C"C:\arduino\hardware\tools\avr\etc\avrdude.conf" |
SERIAL_AVRDUDE = "C:\Program Files\arduino-0018\arduino-0018\hardware\tools\avr\bin\avrdude" |
SERIAL_AVRDUDE_CONFIG = "C:\Program Files\arduino-0018\arduino-0018\hardware\tools\avr\etc\avrdude.conf" |
SERIAL_AVRDUDE_PORT = COM6 |
SERIAL_AVRDUDE_SPEED = 57600 |
SERIAL_AVRDUDE_PROGRAMMER = stk500v1 |
SERIAL_AVRDUDE_FLAGS = -p $(MCU) -P $(SERIAL_AVRDUDE_PORT) -c $(SERIAL_AVRDUDE_PROGRAMMER) -b $(SERIAL_AVRDUDE_SPEED) |
SERIAL_AVRDUDE_FLAGS += -C$(SERIAL_AVRDUDE_CONFIG) |
SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) |
SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) |
SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) |
#---------------- Debugging Options ---------------- |
# For simulavr only - target MCU frequency. |
DEBUG_MFREQ = $(F_CPU) |
# Set the DEBUG_UI to either gdb or insight. |
# DEBUG_UI = gdb |
DEBUG_UI = insight |
# Set the debugging back-end to either avarice, simulavr. |
DEBUG_BACKEND = avarice |
#DEBUG_BACKEND = simulavr |
# GDB Init Filename. |
GDBINIT_FILE = __avr_gdbinit |
# When using avarice settings for the JTAG |
JTAG_DEV = /dev/com1 |
# Debugging port used to communicate between GDB / avarice / simulavr. |
DEBUG_PORT = 4242 |
# Debugging host used to communicate between GDB / avarice / simulavr, normally |
# just set to localhost unless doing some sort of crazy debugging when |
# avarice is running on a different computer. |
DEBUG_HOST = localhost |
#============================================================================ |
# Define programs and commands. |
SHELL = sh |
CC = avr-gcc |
OBJCOPY = avr-objcopy |
OBJDUMP = avr-objdump |
SIZE = avr-size |
AR = avr-ar rcs |
NM = avr-nm |
AVRDUDE = avrdude |
REMOVE = rm -f |
REMOVEDIR = rm -rf |
COPY = cp |
WINSHELL = cmd |
# Define Messages |
# English |
MSG_ERRORS_NONE = Errors: none |
MSG_BEGIN = -------- begin -------- |
MSG_END = -------- end -------- |
MSG_SIZE_BEFORE = Size before: |
MSG_SIZE_AFTER = Size after: |
MSG_COFF = Converting to AVR COFF: |
MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
MSG_FLASH = Creating load file for Flash: |
MSG_EEPROM = Creating load file for EEPROM: |
MSG_EXTENDED_LISTING = Creating Extended Listing: |
MSG_SYMBOL_TABLE = Creating Symbol Table: |
MSG_LINKING = Linking: |
MSG_COMPILING = Compiling C: |
MSG_COMPILING_CPP = Compiling C++: |
MSG_ASSEMBLING = Assembling: |
MSG_CLEANING = Cleaning project: |
MSG_CREATING_LIBRARY = Creating library: |
# Define all object files. |
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) |
# Define all listing files. |
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) |
# Compiler flags to generate dependency files. |
GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d |
# Combine all necessary flags and optional flags. |
# Add target processor to flags. |
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) |
ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) |
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
# Default target. |
all: begin gccversion sizebefore build sizeafter end |
# Change the build target to build a HEX file or a library. |
build: elf hex eep lss sym |
#build: lib |
elf: $(TARGET).elf |
hex: $(TARGET).hex |
eep: $(TARGET).eep |
lss: $(TARGET).lss |
sym: $(TARGET).sym |
LIBNAME=lib$(TARGET).a |
lib: $(LIBNAME) |
# Eye candy. |
# AVR Studio 3.x does not check make's exit code but relies on |
# the following magic strings to be generated by the compile job. |
begin: |
@echo |
@echo $(MSG_BEGIN) |
end: |
@echo $(MSG_END) |
@echo |
# Display size of file. |
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf |
sizebefore: |
@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ |
2>/dev/null; echo; fi |
sizeafter: |
@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ |
2>/dev/null; echo; fi |
# Display compiler version information. |
gccversion : |
@$(CC) --version |
# Program the device. |
program: $(TARGET).hex $(TARGET).eep |
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
program_stk500: $(TARGET).hex $(TARGET).eep |
$(STK500_PATH)\$(STK500) $(STK500_FLAGS) $(STK500_WRITE_FLASH) |
program_serial: $(TARGET).hex $(TARGET).eep |
$(SERIAL_AVRDUDE) $(SERIAL_AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) |
# Generate avr-gdb config/init file which does the following: |
# define the reset signal, load the target file, connect to target, and set |
# a breakpoint at main(). |
gdb-config: |
@$(REMOVE) $(GDBINIT_FILE) |
@echo define reset >> $(GDBINIT_FILE) |
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE) |
@echo end >> $(GDBINIT_FILE) |
@echo file $(TARGET).elf >> $(GDBINIT_FILE) |
@echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) |
ifeq ($(DEBUG_BACKEND),simulavr) |
@echo load >> $(GDBINIT_FILE) |
endif |
@echo break main >> $(GDBINIT_FILE) |
debug: gdb-config $(TARGET).elf |
ifeq ($(DEBUG_BACKEND), avarice) |
@echo Starting AVaRICE - Press enter when "waiting to connect" message displays. |
@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ |
$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) |
@$(WINSHELL) /c pause |
else |
@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ |
$(DEBUG_MFREQ) --port $(DEBUG_PORT) |
endif |
@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) |
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. |
COFFCONVERT = $(OBJCOPY) --debugging |
COFFCONVERT += --change-section-address .data-0x800000 |
COFFCONVERT += --change-section-address .bss-0x800000 |
COFFCONVERT += --change-section-address .noinit-0x800000 |
COFFCONVERT += --change-section-address .eeprom-0x810000 |
coff: $(TARGET).elf |
@echo |
@echo $(MSG_COFF) $(TARGET).cof |
$(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
extcoff: $(TARGET).elf |
@echo |
@echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
# Create final output files (.hex, .eep) from ELF output file. |
%.hex: %.elf |
@echo |
@echo $(MSG_FLASH) $@ |
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
%.eep: %.elf |
@echo |
@echo $(MSG_EEPROM) $@ |
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
--change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 |
# Create extended listing file from ELF output file. |
%.lss: %.elf |
@echo |
@echo $(MSG_EXTENDED_LISTING) $@ |
$(OBJDUMP) -h -S $< > $@ |
# Create a symbol table from ELF output file. |
%.sym: %.elf |
@echo |
@echo $(MSG_SYMBOL_TABLE) $@ |
$(NM) -n $< > $@ |
# Create library from object files. |
.SECONDARY : $(TARGET).a |
.PRECIOUS : $(OBJ) |
%.a: $(OBJ) |
@echo |
@echo $(MSG_CREATING_LIBRARY) $@ |
$(AR) $@ $(OBJ) |
# Link: create ELF output file from object files. |
.SECONDARY : $(TARGET).elf |
.PRECIOUS : $(OBJ) |
%.elf: $(OBJ) |
@echo |
@echo $(MSG_LINKING) $@ |
$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) |
# Compile: create object files from C source files. |
$(OBJDIR)/%.o : %.c |
@echo |
@echo $(MSG_COMPILING) $< |
$(CC) -c $(ALL_CFLAGS) $< -o $@ |
# Compile: create object files from C++ source files. |
$(OBJDIR)/%.o : %.cpp |
@echo |
@echo $(MSG_COMPILING_CPP) $< |
$(CC) -c $(ALL_CPPFLAGS) $< -o $@ |
# Compile: create assembler files from C source files. |
%.s : %.c |
$(CC) -S $(ALL_CFLAGS) $< -o $@ |
# Compile: create assembler files from C++ source files. |
%.s : %.cpp |
$(CC) -S $(ALL_CPPFLAGS) $< -o $@ |
# Assemble: create object files from assembler source files. |
$(OBJDIR)/%.o : %.S |
@echo |
@echo $(MSG_ASSEMBLING) $< |
$(CC) -c $(ALL_ASFLAGS) $< -o $@ |
# Create preprocessed source for use in sending a bug report. |
%.i : %.c |
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ |
# Target: clean project. |
clean: begin clean_list end |
clean_list : |
@echo |
@echo $(MSG_CLEANING) |
$(REMOVE) $(TARGET).hex |
$(REMOVE) $(TARGET).eep |
$(REMOVE) $(TARGET).cof |
$(REMOVE) $(TARGET).elf |
$(REMOVE) $(TARGET).map |
$(REMOVE) $(TARGET).sym |
$(REMOVE) $(TARGET).lss |
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) |
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) |
$(REMOVE) $(SRC:.c=.s) |
$(REMOVE) $(SRC:.c=.d) |
$(REMOVE) $(SRC:.c=.i) |
$(REMOVEDIR) .dep |
# Create object files directory |
$(shell mkdir $(OBJDIR) 2>/dev/null) |
# Include the dependency files. |
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) |
# Listing of phony targets. |
.PHONY : all begin finish end sizebefore sizeafter gccversion \ |
build elf hex eep lss sym coff extcoff \ |
clean clean_list program debug gdb-config |
/Modules/Sensors/ALTIMET01A/SW/MPL115A1/AVR/ATmega328/main.c |
---|
0,0 → 1,355 |
/* |
MPL115A1 SPI Digital Barometer Test Code |
Created on: April 20, 2010 |
By: Jim Lindblom - jim at sparkfun.com |
This is a simple test program for the MPL115A1 Pressure Sensor (SPI version). |
UBRR0 is set to 51 and U2X0 is not set, so the baud rate will be 9600@8MHz and 19200@16MHz. |
Press the spacebar to get the pressure measurement. |
Hardware: ATmega328 (I used the Arduino Pro platform) |
Powered at 3.3V, running at 8MHz. |
The sensor is 5V tolerant, and this code should also work on 5V/16MHz Arduinos. |
MPL115A1 Breakout ------------- Arduino |
----------------- ------- |
SDN ------------------- D9 (PB1) |
CSN ------------------- D8 (PB0) |
SDO ------------------- D12 (PB4) |
SDI ------------------- D11 (PB3) |
SCK ------------------- D13 (PB5) |
GND --------------------- GND |
VDD ------------------- VCC (3.3V) |
License: CCAv3.0 Attribution-ShareAlike (http://creativecommons.org/licenses/by-sa/3.0/) |
You're free to use this code for any venture, but I'd love to hear about what you do with it, |
and any awesome changes you make to it. Attribution is greatly appreciated. |
*/ |
//======================// |
// Includes // |
//======================// |
#include <avr/io.h> |
#include <stdio.h> |
#include "MPL115A1.h" |
//======================// |
// Macros // |
//======================// |
#define sbi(var, mask) ((var) |= (uint8_t)(1 << mask)) |
#define cbi(var, mask) ((var) &= (uint8_t)~(1 << mask)) |
//======================// |
// MPL115A1 Defines // |
//======================// |
#define CS 0 //pin for chip select |
#define SDN 1 // pin for interrupt |
//======================// |
// General Functions // |
//======================// |
void ioinit(void); |
void delay_ms(uint16_t x); |
void delay_us(uint16_t x); |
static int uart_putchar(char c, FILE *stream); |
uint8_t uart_getchar(void); |
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); |
//======================// |
// MPL115A1 Functions // |
//======================// |
void init_SPI(void); |
void txdata(char data); |
char rxdata(void); |
char read(uint8_t address); |
void write(uint8_t address, char data); |
float calculatePressure(void); |
//======================// |
// Global Variables // |
//======================// |
signed char sia0MSB, sia0LSB; |
signed char sib1MSB, sib1LSB; |
signed char sib2MSB, sib2LSB; |
signed char sic12MSB, sic12LSB; |
signed char sic11MSB, sic11LSB; |
signed char sic22MSB, sic22LSB; |
signed int sia0, sib1, sib2, sic12, sic11, sic22, siPcomp; |
float decPcomp; |
signed long lt1, lt2, lt3, si_c11x1, si_a11, si_c12x2; |
signed long si_a1, si_c22x2, si_a2, si_a1x1, si_y1, si_a2x2; |
unsigned int uiPadc, uiTadc; |
unsigned char uiPH, uiPL, uiTH, uiTL; |
int main(void) |
{ |
ioinit(); |
init_SPI(); |
sbi(PORTB,CS); // CS Idle High |
sbi(PORTB,SDN); // SDN high turns sensor on |
printf("\n***************MPR115A1 Test****************\n\n"); |
// main program loop |
while(1){ |
printf("\nPress space to print pressure\n"); |
while( !(UCSR0A & (1<<RXC0)) ) |
; |
if (UDR0 == ' ') |
printf("Pressure = %f\n", calculatePressure()); |
} |
} |
float calculatePressure() |
{ |
write(0x24, 0x00); // Start Both Conversions |
// write(0x20, 0x00); // Start Pressure Conversion |
// write(0x22, 0x00); // Start temperature conversion |
delay_ms(10); // Typical wait time is 3ms |
// Read pressure |
uiPH = read(PRESH); |
uiPL = read(PRESL); |
uiTH = read(TEMPH); |
uiTL = read(TEMPL); |
uiPadc = (unsigned int) uiPH << 8; |
uiPadc += (unsigned int) uiPL & 0x00FF; |
uiTadc = (unsigned int) uiTH << 8; |
uiTadc += (unsigned int) uiTL & 0x00FF; |
// Placing Coefficients into 16-bit Variables |
// a0 |
sia0MSB = read(A0MSB); |
sia0LSB = read(A0LSB); |
sia0 = (signed int) sia0MSB << 8; |
sia0 += (signed int) sia0LSB & 0x00FF; |
// b1 |
sib1MSB = read(B1MSB); |
sib1LSB = read(B1LSB); |
sib1 = (signed int) sib1MSB << 8; |
sib1 += (signed int) sib1LSB & 0x00FF; |
// b2 |
sib2MSB = read(B2MSB); |
sib2LSB = read(B2LSB); |
sib2 = (signed int) sib2MSB << 8; |
sib2 += (signed int) sib2LSB & 0x00FF; |
// c12 |
sic12MSB = read(C12MSB); |
sic12LSB = read(C12LSB); |
sic12 = (signed int) sic12MSB << 8; |
sic12 += (signed int) sic12LSB & 0x00FF; |
// c11 |
sic11MSB = read(C11MSB); |
sic11LSB = read(C11LSB); |
sic11 = (signed int) sic11MSB << 8; |
sic11 += (signed int) sic11LSB & 0x00FF; |
// c22 |
sic22MSB = read(C22MSB); |
sic22LSB = read(C22LSB); |
sic22 = (signed int) sic22MSB << 8; |
sic22 += (signed int) sic22LSB & 0x00FF; |
// Coefficient 9 equation compensation |
uiPadc = uiPadc >> 6; |
uiTadc = uiTadc >> 6; |
// Step 1 c11x1 = c11 * Padc |
lt1 = (signed long) sic11; |
lt2 = (signed long) uiPadc; |
lt3 = lt1*lt2; |
si_c11x1 = (signed long) lt3; |
// Step 2 a11 = b1 + c11x1 |
lt1 = ((signed long)sib1)<<14; |
lt2 = (signed long) si_c11x1; |
lt3 = lt1 + lt2; |
si_a11 = (signed long)(lt3>>14); |
// Step 3 c12x2 = c12 * Tadc |
lt1 = (signed long) sic12; |
lt2 = (signed long) uiTadc; |
lt3 = lt1*lt2; |
si_c12x2 = (signed long)lt3; |
// Step 4 a1 = a11 + c12x2 |
lt1 = ((signed long)si_a11<<11); |
lt2 = (signed long)si_c12x2; |
lt3 = lt1 + lt2; |
si_a1 = (signed long) lt3>>11; |
// Step 5 c22x2 = c22*Tadc |
lt1 = (signed long)sic22; |
lt2 = (signed long)uiTadc; |
lt3 = lt1 * lt2; |
si_c22x2 = (signed long)(lt3); |
// Step 6 a2 = b2 + c22x2 |
lt1 = ((signed long)sib2<<15); |
lt2 = ((signed long)si_c22x2>1); |
lt3 = lt1+lt2; |
si_a2 = ((signed long)lt3>>16); |
// Step 7 a1x1 = a1 * Padc |
lt1 = (signed long)si_a1; |
lt2 = (signed long)uiPadc; |
lt3 = lt1*lt2; |
si_a1x1 = (signed long)(lt3); |
// Step 8 y1 = a0 + a1x1 |
lt1 = ((signed long)sia0<<10); |
lt2 = (signed long)si_a1x1; |
lt3 = lt1+lt2; |
si_y1 = ((signed long)lt3>>10); |
// Step 9 a2x2 = a2 * Tadc |
lt1 = (signed long)si_a2; |
lt2 = (signed long)uiTadc; |
lt3 = lt1*lt2; |
si_a2x2 = (signed long)(lt3); |
// Step 10 pComp = y1 + a2x2 |
lt1 = ((signed long)si_y1<<10); |
lt2 = (signed long)si_a2x2; |
lt3 = lt1+lt2; |
// Fixed point result with rounding |
//siPcomp = ((signed int)lt3>>13); |
siPcomp = lt3/8192; |
// decPcomp is defined as a floating point number |
// Conversion to decimal value from 1023 ADC count value |
// ADC counts are 0 to 1023, pressure is 50 to 115kPa respectively |
decPcomp = ((65.0/1023.0)*siPcomp)+50; |
return decPcomp; |
} |
void write(uint8_t address, char data) |
{ |
//write any data byte to any single address |
//adds a 0 to the MSB of the address byte (WRITE mode) |
address &= 0x7F; |
//printf("\nWriting 0x%x to 0x%x\n", data, address); |
cbi(PORTB,CS); |
delay_ms(1); |
txdata(address); |
delay_ms(1); |
txdata(data); |
delay_ms(1); |
sbi(PORTB,CS); |
} |
char read(uint8_t address) |
{ |
//returns the contents of any 1 byte register from any address |
//sets the MSB for every address byte (READ mode) |
char byte; |
address |= 0x80; |
cbi(PORTB,CS); |
txdata(address); |
byte = rxdata(); |
sbi(PORTB,CS); |
return byte; |
} |
char rxdata(void) |
{ |
SPDR = 0x55; |
while((SPSR&0x80) == 0x00) |
; |
return SPDR; |
} |
void txdata(char data) |
{ |
SPDR = data; |
while((SPSR&0x80) == 0x00) |
; |
} |
void init_SPI(void) |
{ |
sbi(SPCR,MSTR); //make SPI master |
cbi(SPCR,CPOL); cbi(SPCR,CPHA); //SCL idle low, sample data on rising edge |
cbi(SPCR,SPR1); cbi(SPCR,SPR0); sbi(SPSR,SPI2X); //Fosc/4 is SPI frequency |
sbi(SPCR,SPE); //enable SPI |
} |
static int uart_putchar(char c, FILE *stream) |
{ |
if (c == '\n') uart_putchar('\r', stream); |
loop_until_bit_is_set(UCSR0A, UDRE0); |
UDR0 = c; |
return 0; |
} |
uint8_t uart_getchar(void) |
{ |
while( !(UCSR0A & (1<<RXC0)) ) |
; |
return(UDR0); |
} |
void ioinit (void) |
{ |
int MYUBRR = 51; // Results in 9600bps@8MHz or 19200bps@16MHz |
//1 = output, 0 = input |
//DDRA = 0b00000000; //ADC inputs |
DDRB = 0b11101111; //MISO input |
DDRC = 0b11111111; //All outputs |
DDRD = 0b11111110; //PORTD (RX on PD0) |
stdout = &mystdout; //Required for printf init |
UBRR0H = (MYUBRR) >> 8; |
UBRR0L = MYUBRR; |
UCSR0B = (1<<RXEN0)|(1<<TXEN0); |
UCSR0C = (3<<UCSZ00); |
TCCR2B = (1<<CS21); |
} |
//General short delays |
void delay_ms(uint16_t x) |
{ |
for (; x > 0 ; x--) |
delay_us(1000); |
} |
//General short delays |
void delay_us(uint16_t x) |
{ |
while(x > 256) |
{ |
TIFR2 = (1<<TOV2); //Clear any interrupt flags on Timer2 |
TCNT2 = 0; //256 - 125 = 131 : Preload timer 2 for x clicks. Should be 1us per click |
while( (TIFR2 & (1<<TOV2)) == 0); |
x -= 256; |
} |
TIFR2 = (1<<TOV2); //Clear any interrupt flags on Timer2 |
TCNT2= 256 - x; //256 - 125 = 131 : Preload timer 2 for x clicks. Should be 1us per click |
while( (TIFR2 & (1<<TOV2)) == 0); |
} |
/Modules/Sensors/ALTIMET01A/SW/MPL115A1/AVR/ATmega328/main.hex |
---|
0,0 → 1,368 |
:100000000C94B5000C94D2000C94D2000C94D20045 |
:100010000C94D2000C94D2000C94D2000C94D20018 |
:100020000C94D2000C94D2000C94D2000C94D20008 |
:100030000C94D2000C94D2000C94D2000C94D200F8 |
:100040000C94D2000C94D2000C94D2000C94D200E8 |
:100050000C94D2000C94D2000C94D2000C94D200D8 |
:100060000C94D2000C94D2006E616E00696E660032 |
:1000700000407A10F35A00A0724E18090010A5D45F |
:10008000E80000E87648170000E40B54020000CABC |
:100090009A3B000000E1F505000080969800000002 |
:1000A00040420F000000A086010000001027000061 |
:1000B0000000E803000000006400000000000A00E7 |
:1000C000000000000100000000002C76D888DC67EA |
:1000D0004F0823DFC1DFAE59E1B1B796E5E3E45342 |
:1000E000C63AE651997696E8E6C28426EB898C9B5F |
:1000F00062ED407C6FFCEFBC9C9F40F2BAA56FA5FF |
:10010000F490055A2AF75C936B6CF9676DC11BFC80 |
:10011000E0E40D47FEF520E6B500D0ED902E03009B |
:10012000943577050080841E080000204E0A0000E8 |
:1001300000C80C333333330F986E12831141EF8DA7 |
:100140002114893BE65516CFFEE6DB18D1844B38E7 |
:100150001BF77C1D901DA4BBE424203284725E2218 |
:100160008100C9F124ECA1E53D2711241FBECFEF8A |
:10017000D8E0DEBFCDBF11E0A0E0B1E0E2E6F6E1FD |
:1001800002C005900D92A837B107D9F711E0A8E792 |
:10019000B1E001C01D92A43DB107E1F70E94C40384 |
:1001A0000C942F0B0C940000806828988EBD0DB421 |
:1001B00007FEFDCF85E58EBD0DB407FEFDCF8EB5E4 |
:1001C000289A089585E58EBD0DB407FEFDCF8EB546 |
:1001D00008958EBD0DB407FEFDCF08958CB58061E6 |
:1001E0008CBD8CB5877F8CBD8CB58B7F8CBD8CB561 |
:1001F0008D7F8CBD8CB58E7F8CBD8DB581608DBDA6 |
:100200008CB580648CBD08951F93182F8A3019F423 |
:100210008DE00E9404018091C00085FFFCCF109307 |
:10022000C60080E090E01F9108958091C00087FF94 |
:10023000FCCF8091C60008958FEE84B98FEF87B907 |
:100240008EEF8AB989E691E09093D1018093D00135 |
:100250001092C50083E38093C40088E18093C100BD |
:1002600086E08093C20082E08093B10008959C01F3 |
:1002700081E007C087BB1092B200B89BFECF205030 |
:10028000314091E021303907A8F781E087BB822F08 |
:1002900081958093B200B89BFECF0895CF93DF93F2 |
:1002A000EC0105C088EE93E00E943701219720976A |
:1002B000C9F7DF91CF9108950F931F93062F182F41 |
:1002C0001F77289881E090E00E944E011EBD0DB47A |
:1002D00007FEFDCF81E090E00E944E010EBD0DB4FF |
:1002E00007FEFDCF81E090E00E944E01289A1F9109 |
:1002F0000F9108952F923F924F925F926F927F924B |
:100300008F929F92AF92BF92CF92DF92EF92FF9225 |
:100310000F931F9384E260E00E945C018AE090E00A |
:100320000E944E0180E00E94D4008093A20182E0EE |
:100330000E94D4008093B50184E00E94D400809391 |
:10034000B40186E00E94D4008093BF013091A201E5 |
:1003500020E09091B501290F311D3093CD012093FC |
:10036000CC013091B40120E0280F311D30938D0174 |
:1003700020938C0188E00E94D400809398018AE049 |
:100380000E94D4008093B20120919801332727FD69 |
:100390003095322F2227280F311D3093CA01209328 |
:1003A000C9018CE00E94D4008093B3018EE00E94CA |
:1003B000D4008093C8012091B301332727FD3095E5 |
:1003C000322F2227280F311D3093B9012093B80115 |
:1003D00080E10E94D4008093A80182E10E94D400B1 |
:1003E0008093BA012091A801332727FD3095322F41 |
:1003F0002227280F311D3093B1012093B00184E1F1 |
:100400000E94D40080939F0186E10E94D4008093D3 |
:10041000A10120919F01332727FD3095322F2227FC |
:10042000280F311D3093B7012093B60188E10E9457 |
:10043000D4008093CB018AE10E94D4008093A00174 |
:100440002091CB01332727FD3095322F2227280F0B |
:10045000311D3093AF012093AE018CE10E94D40096 |
:100460008093A9018EE10E94D4008093A701A090FF |
:10047000A901BB24A7FCB094BA2CAA24A80EB11CD5 |
:10048000B0929301A09292018091CC019091CD0104 |
:1004900006E0969587950A95E1F79093CD018093B4 |
:1004A000CC0180908C0190908D0116E096948794F9 |
:1004B0001A95E1F790928D0180928C011C014424E1 |
:1004C00055242091AE013091AF01442737FD40956E |
:1004D000542FC201B1010E94D3086093C4017093EC |
:1004E000C5018093C6019093C701E090B801F090D8 |
:1004F000B9010027F7FC0095102FBEE0EE0CFF1CA1 |
:10050000001F111FBA95D1F7E60EF71E081F191F1D |
:10051000AEE015950795F794E794AA95D1F7E09288 |
:100520008E01F0928F01009390011093910134019C |
:10053000882499242091B6013091B701442737FDD2 |
:100540004095542FC401B3010E94D3086093AA01BF |
:100550007093AB018093AC019093AD01FBE0EE0C86 |
:10056000FF1C001F111FFA95D1F76E0D7F1D801F14 |
:10057000911FEBE09595879577956795EA95D1F76B |
:1005800060937C0170937D0180937E0190937F0145 |
:10059000CC24B7FCC094DC2CC601B501A4019301A6 |
:1005A0000E94D3086093A3017093A4018093A501D6 |
:1005B0009093A601A090B001B090B101CC24B7FCFB |
:1005C000C094DC2CD594C794B794A794A0928801CA |
:1005D000B0928901C0928A01D0928B0120917C0156 |
:1005E00030917D0140917E0150917F01C201B101A6 |
:1005F0000E94D30860939B0170939C0180939D019E |
:1006000090939E01E090C901F090CA010027F7FC89 |
:100610000095102F4AE0EE0CFF1C001F111F4A9599 |
:10062000D1F7E60EF71E081F191F3AE0159507953A |
:10063000F794E7943A95D1F7E0928001F092810126 |
:100640000093820110938301C601B501A4019301B7 |
:100650000E94D30860939401709395018093960152 |
:10066000909397012AE0EE0CFF1C001F111F2A95A2 |
:10067000D1F7E092BB01F092BC010093BD01109351 |
:10068000BE01609378017093790180937A01909311 |
:100690007B016E0D7F1D801F911F609384017093FD |
:1006A0008501809386019093870120E030E240E04D |
:1006B00050E00E94F20830939A0120939901442758 |
:1006C00037FD4095542FCA01B9010E94E40728E87C |
:1006D00030E242E85DE30E94700820E030E048E448 |
:1006E00052E40E947E079B01AC012093C00130932D |
:1006F000C1014093C2015093C3011F910F91FF901C |
:10070000EF90DF90CF90BF90AF909F908F907F90B1 |
:100710006F905F904F903F902F900895FF920F93AE |
:100720001F93CF93DF938AE090E00E94950AFF2405 |
:10073000C0E0D1E00F2D10E08F2D0E94D40000D03A |
:1007400000D000D0EDB7FEB73196ADB7BEB7129668 |
:10075000DC93CE93119713830283848315820E94C6 |
:10076000800A077010708DB79EB706960FB6F89482 |
:100770009EBF0FBE8DBF0730110521F48AE090E0C7 |
:100780000E94950AF394D6CFCF93DF930E941C0169 |
:100790000E94EE00289A299A8CE091E00E949C0A1F |
:1007A000CAE5D1E08BE391E00E949C0A8091C000F1 |
:1007B00087FFFCCF8091C6008032A1F70E947A01AA |
:1007C00000D000D000D0EDB7FEB7D283C1836383E1 |
:1007D0007483858396830E94800A8DB79EB70696A0 |
:1007E0000FB6F8949EBF0FBE8DBFDCCFA1E1B0E085 |
:1007F000ECEFF3E00C940D093C017F876E876A01F2 |
:10080000FC0117821682838181FD03C06FEF7FEFA9 |
:100810006FC39E012F5F3F4F398B288BF3012381DC |
:10082000EE85FF8523FD859123FF8191FF87EE876C |
:10083000882309F45AC3853251F4EE85FF8523FDE0 |
:10084000859123FF8191FF87EE87853229F490E01F |
:10085000B3010E94540AE2CF982F10E08824992413 |
:100860001032B0F49B3269F09C3228F4903251F08F |
:10087000933271F40BC09D3239F0903349F411601A |
:1008800028C01260146025C0186023C0106121C008 |
:1008900017FD2AC0892F80538A3078F416FF06C0CE |
:1008A000FAE09F9E902C1124980E13C03AE0839E8C |
:1008B000802C1124880E10620CC09E3221F416FD8B |
:1008C00014C3106406C09C3611F4106802C0983638 |
:1008D00059F4EE85FF8523FD959123FF9191FF87C4 |
:1008E000EE87992309F0BCCF892F8554833020F4FB |
:1008F000812F8061905E07C0892F8556833008F074 |
:100900009FC1812F8F7E86FD02C076E0972E6FE318 |
:10091000F62EF822953619F4F0E4FF2A07C0963631 |
:1009200019F420E8F22A02C091109A94F7FE0AC046 |
:100930003BE3391518F45CE3B52E02C0B92CB3942F |
:1009400027E009C047E0491520F4BB2447E0942E76 |
:10095000F7CF292DBB24C60104969D878C87F6010D |
:100960006081718182819381AE014F5F5F4F0B2D5A |
:100970000E9466096C010981202E332400FF04C007 |
:1009800003FD02C01DE209C0F1FE02C01BE205C06A |
:10099000F2FC02C010E001C010E2C1018C70907046 |
:1009A000892BB9F1112311F483E001C084E088158B |
:1009B00010F088240AC0881AF3FC07C080E290E097 |
:1009C000B3010E94540A8A94C9F7112329F0812F98 |
:1009D00090E0B3010E94540A23FE03C008E610E031 |
:1009E0000EC00CE610E00BC0E114F10409F08052D7 |
:1009F00090E0B3010E94540A0F5F1F4F05C0EF2C17 |
:100A0000FF24F0E1EF22FF24F8018491882361F7AD |
:100A100014C1F7FE12C0BC0C24FE04C08A818133CD |
:100A200009F4BA941B141CF0BB24B3942DC0F8E055 |
:100A3000FB1550F538E0B32E27C0F6FC25C0892DF4 |
:100A400090E08C159D054CF02CEFC2162FEFD206CE |
:100A500024F030E8F32A01C09A94992049F0E2E0AA |
:100A6000F0E0EC0FFD1FE90DF11D80818033A1F353 |
:100A7000F7FE0AC0B92CB394892D90E0C816D906A8 |
:100A800014F0992401C09C18F7FC03C025E030E065 |
:100A900009C01C141D041CF021E030E003C09601C5 |
:100AA0002F5F3F4F112311F02F5F3F4F992029F007 |
:100AB000892D90E00196280F391F882D90E0281786 |
:100AC000390714F0882401C0821A4F2C5524C20122 |
:100AD00089709070892B39F008C080E290E0B301F2 |
:100AE0000E94540A8A948820C1F7112329F0812F8B |
:100AF00090E0B3010E94540A43FE07C008C080E39F |
:100B000090E0B3010E94540A8A948820C1F7F7FE4E |
:100B100046C08601D7FE02C000E010E076010894CE |
:100B2000E11CF11CE01AF10A41E050E04C0F5D1F9E |
:100B3000E40EF51E26014B185108892D90E0AA24D9 |
:100B4000BB24A81AB90A5FEF0F3F150729F48EE2FC |
:100B500090E0B3010E94540AC016D10634F040164A |
:100B600051061CF4F701808101C080E30150104060 |
:100B70000894E11CF11C0A151B052CF090E0B30150 |
:100B80000E94540AE0CF0C151D0539F49A81963362 |
:100B900018F4953311F424FE81E390E04BC08A8170 |
:100BA000813309F00F7E90E0B3010E94540A99202E |
:100BB000A1F08EE290E0B3010E94540A12E0E1E05D |
:100BC000F0E0EC0FFD1FE10FF11D1F5F808190E051 |
:100BD000B3010E94540A9A9491F744FC03C085E63D |
:100BE00090E002C085E490E0B3010E94540AD7FC73 |
:100BF00005C0C114D10441F404FF06C0D094C194CF |
:100C0000D108D3948DE201C08BE290E0B3010E9441 |
:100C1000540A80E305C08F5F26EF3FEFC20ED31E5C |
:100C20003AE0C316D104BCF790E0B3010E94540A25 |
:100C3000C601C096B3010E94540ACC84DD8452C11F |
:100C4000933631F0933799F0933509F059C023C0AA |
:100C5000F601808189835E010894A11CB11C22E009 |
:100C600030E0C20ED31E21E0E22EF12C12C0F601BC |
:100C7000A080B18016FD03C06FEF7FEF02C0692D29 |
:100C800070E022E030E0C20ED31EC5010E94490A86 |
:100C90007C011F7713C0F601A080B18016FD03C050 |
:100CA0006FEF7FEF02C0692D70E022E030E0C20EEE |
:100CB000D31EC5010E943E0A7C01106813FF07C0C5 |
:100CC0001BC080E290E0B3010E94540A8A94882DF0 |
:100CD00090E0E816F906A8F30FC0F50117FD85911D |
:100CE00017FF81915F0190E0B3010E94540A8110C7 |
:100CF0008A940894E108F108E114F10471F7F2C054 |
:100D0000943611F0993689F517FF08C0F601208155 |
:100D100031814281538184E090E00AC0F6018081F4 |
:100D200091819C01442737FD4095542F82E090E04B |
:100D3000C80ED91E9FE6F92EF12257FF09C0509523 |
:100D40004095309521953F4F4F4F5F4F90E8F92ADE |
:100D5000CA01B901AE014F5F5F4F2AE030E00E9447 |
:100D6000D10AE82EE889EE1A41C0953721F41F7E9A |
:100D70002AE030E01CC0197F9F3661F0903720F4E4 |
:100D8000983509F0B2C00FC0903739F0983709F0A4 |
:100D9000ACC004C028E030E00AC0106114FD14604B |
:100DA00020E130E004C014FD166020E132E017FFBE |
:100DB00008C0F601608171818281938144E050E036 |
:100DC00008C0F60180819181BC0180E090E042E0A2 |
:100DD00050E0C40ED51EAE014F5F5F4F0E94D10A96 |
:100DE000E82E5889E51A8FE7F82EF122F6FE0BC09F |
:100DF0008EEFF822E91438F4F4FE07C0F2FC05C0C7 |
:100E00009FEEF92202C01E2D01C0192DF4FE0DC067 |
:100E1000FE01EE0DF11D8081803319F4E9EEFE2212 |
:100E200008C01F5FF2FE05C003C08F2D867809F051 |
:100E30001F5F0F2DF3FC14C0F0FE0FC0181510F04B |
:100E40009E2C0BC09E2C980C911A182D06C080E287 |
:100E500090E0B3010E94540A1F5F1815C0F304C04C |
:100E6000181510F4811A01C0882404FF0FC080E314 |
:100E700090E0B3010E94540A02FF1DC001FD03C0AF |
:100E800088E790E00EC088E590E00BC0802F867860 |
:100E900091F001FF02C08BE201C080E2F7FC8DE21D |
:100EA00090E0B3010E94540A06C080E390E0B301D1 |
:100EB0000E94540A9A94E914C0F3EA94E1E0F0E045 |
:100EC000EC0FFD1FEE0DF11D808190E0B3010E943B |
:100ED000540AEE2091F706C080E290E0B3010E9430 |
:100EE000540A8A948820C1F799CCF30166817781EE |
:100EF000CB016196E2E10C9429095058BB27AA273F |
:100F00000ED0B4C0A5D030F0AAD020F031F49F3F6D |
:100F100011F41EF49AC00EF4E095E7FB90C0E92F9F |
:100F2000B6D080F3BA17620773078407950718F0E5 |
:100F300071F49EF5CEC00EF4E0950B2EBA2FA02DC5 |
:100F40000B01B90190010C01CA01A0011124FF2776 |
:100F5000591B99F0593F50F4503E68F11A16F04071 |
:100F6000A22F232F342F4427585FF3CF4695379570 |
:100F70002795A795F0405395C9F77EF41F16BA0B35 |
:100F8000620B730B840BBAF09150A1F0FF0FBB1FE3 |
:100F9000661F771F881FC2F70EC0BA0F621F731F2C |
:100FA000841F48F4879577956795B795F7959E3F89 |
:100FB00008F0B3CF9395880F08F09927EE0F979517 |
:100FC00087950895E89409C097FB3EF49095809525 |
:100FD000709561957F4F8F4F9F4F9923A9F0F92FFF |
:100FE00096E9BB279395F695879577956795B7957D |
:100FF000F111F8CFFAF4BB0F11F460FF1BC06F5F63 |
:101000007F4F8F4F9F4F16C0882311F096E911C074 |
:10101000772321F09EE8872F762F05C0662371F095 |
:1010200096E8862F70E060E02AF09A95660F771FA9 |
:10103000881FDAF7880F9695879597F9089597F99D |
:101040009F6780E870E060E008959FEF80EC08956E |
:1010500000240A9416161706180609060895002497 |
:101060000A9412161306140605060895092E039411 |
:10107000000C11F4882352F0BB0F40F4BF2B11F485 |
:1010800060FF04C06F5F7F4F8F4F9F4F089557FDE4 |
:101090009058440F551F59F05F3F71F04795880FE6 |
:1010A00097FB991F61F09F3F79F08795089512167D |
:1010B00013061406551FF2CF4695F1DF08C0161629 |
:1010C00017061806991FF1CF8695710561050894DA |
:1010D0000895E894BB2766277727CB0197F90895F1 |
:1010E0000BD0C4CFB5DF28F0BADF18F0952309F094 |
:1010F000A6CFABCF1124EECFCADFA0F3959FD1F3DB |
:10110000950F50E0551F629FF001729FBB27F00DB5 |
:10111000B11D639FAA27F00DB11DAA1F649F66270A |
:10112000B00DA11D661F829F2227B00DA11D621F59 |
:10113000739FB00DA11D621F839FA00D611D221F13 |
:10114000749F3327A00D611D231F849F600D211DF7 |
:10115000822F762F6A2F11249F5750408AF0E1F09A |
:1011600088234AF0EE0FFF1FBB1F661F771F881FE3 |
:1011700091505040A9F79E3F510570F060CFAACF23 |
:101180005F3FECF3983EDCF3869577956795B795CE |
:10119000F795E7959F5FC1F7FE2B880F911D9695F8 |
:1011A000879597F90895629FD001739FF001829F00 |
:1011B000E00DF11D649FE00DF11D929FF00D839FE6 |
:1011C000F00D749FF00D659FF00D9927729FB00D83 |
:1011D000E11DF91F639FB00DE11DF91FBD01CF0196 |
:1011E0001124089597FB092E05260ED057FD04D033 |
:1011F0004BD00AD0001C38F450954095309521957D |
:101200003F4F4F4F5F4F0895F6F79095809570953B |
:1012100061957F4F8F4F9F4F08952F923F924F922E |
:101220005F926F927F928F929F92AF92BF92CF9276 |
:10123000DF92EF92FF920F931F93CF93DF93CDB77F |
:10124000DEB7CA1BDB0B0FB6F894DEBF0FBECDBFF7 |
:1012500009942A88398848885F846E847D848C84C8 |
:101260009B84AA84B984C884DF80EE80FD800C81D1 |
:101270001B81AA81B981CE0FD11D0FB6F894DEBFB4 |
:101280000FBECDBFED010895A1E21A2EAA1BBB1B14 |
:10129000FD010DC0AA1FBB1FEE1FFF1FA217B30742 |
:1012A000E407F50720F0A21BB30BE40BF50B661F58 |
:1012B000771F881F991F1A9469F76095709580951C |
:1012C00090959B01AC01BD01CF010895283008F035 |
:1012D00027E03327DA01990F311D87FD91600096D1 |
:1012E0006105710539F432602E5F3D9330E32A9534 |
:1012F000E1F708959F3F30F080387105610509F0EE |
:101300003C5F3C5F3D93913008F08068911DDF9316 |
:10131000CF931F930F93FF92EF92192F987F96957B |
:10132000E92F96959695E90FFF27E653FF4F9927EA |
:101330003327EE24FF24A701E701059008940794C2 |
:1013400028F4360FE71EF81E491F511D660F771F40 |
:10135000881F991F0694A1F70590079428F4E70EBB |
:10136000F81E491F561FC11D770F881F991F661F42 |
:101370000694A1F70590079428F4F80E491F561F0C |
:10138000C71FD11D880F991F661F771F0694A1F7ED |
:101390000590079420F4490F561FC71FD81F990FB7 |
:1013A000661F771F881F0694A9F784911095177000 |
:1013B00041F0D695C79557954795F794E7941A95B8 |
:1013C000C1F7E0E7F0E068941590159135916591CB |
:1013D000959105907FE27395E118F10A430B560B46 |
:1013E000C90BD009C0F7E10CF11E431F561FC91FDE |
:1013F000D01D7EF4703311F48A95E6CFE894015045 |
:1014000030F0080F0AF40027021708F4202F239564 |
:10141000022F7A3328F079E37D932A95E9F710C0FB |
:101420007D932A9589F60694979567953795179534 |
:101430001794E118F10A430B560BC90BD00998F029 |
:1014400023957E9173957A3308F070E37C93201393 |
:10145000B8F77E9170617D9330F0839571E37D9351 |
:1014600070E32A95E1F71124EF90FF900F911F91FF |
:10147000CF91DF91992787FD90950895FC01059004 |
:10148000615070400110D8F7809590958E0F9F1F86 |
:101490000895FC016150704001900110D8F78095CB |
:1014A00090958E0F9F1F08950F931F93CF93DF93F7 |
:1014B0008C01EB018B8181FF1BC082FF0DC02E814F |
:1014C0003F818C819D812817390764F4E881F98177 |
:1014D0000193F983E88306C0E885F985802F099593 |
:1014E000892B31F48E819F8101969F838E8302C068 |
:1014F0000FEF1FEFC801DF91CF911F910F9108955A |
:10150000A0E0B0E0E6E8FAE00C941D09FE01359693 |
:10151000619171918091D0019091D101AF010E94B0 |
:10152000F6032096E2E00C9439096091D0017091A5 |
:10153000D1010E94540A08950F931F93CF93DF9314 |
:101540008C01E091D001F091D101838181FF21C014 |
:10155000C0E0D0E00DC0E091D001F091D101208534 |
:101560003185BF01F9010995892B11F0CFEFDFEF2C |
:10157000F80181918F01882371F7E091D001F091FA |
:10158000D101208531858AE0BF01F9010995892BB8 |
:1015900011F0CFEFDFEFCE01DF91CF911F910F91CF |
:1015A0000895FA01AA27283051F1203181F1E894F9 |
:1015B0006F936E7F6E5F7F4F8F4F9F4FAF4FB1E046 |
:1015C0003ED0B4E03CD0670F781F891F9A1FA11D41 |
:1015D000680F791F8A1F911DA11D6A0F711D811D42 |
:1015E000911DA11D20D009F468943F912AE0269F07 |
:1015F00011243019305D3193DEF6CF010895462F66 |
:101600004770405D4193B3E00FD0C9F7F6CF462F46 |
:101610004F70405D4A3318F0495D31FD40524193AF |
:1016200002D0A9F7EACFB4E0A6959795879577956C |
:101630006795BA95C9F700976105710508959B01F3 |
:10164000AC010A2E06945795479537952795BA957C |
:10165000C9F7620F731F841F951FA01D0895F8948A |
:02166000FFCFBA |
:10166200307825783A203078257809000A2A2A2A03 |
:101672002A2A2A2A2A2A2A2A2A2A2A2A4D50523150 |
:101682003135413120546573742A2A2A2A2A2A2A9A |
:101692002A2A2A2A2A2A2A2A2A0A000A5072657320 |
:1016A2007320737061636520746F207072696E7449 |
:1016B200207072657373757265005072657373750D |
:1016C2007265203D2025660A00000000020000002D |
:0816D20000040100000000000B |
:00000001FF |
/Modules/Sensors/ALTIMET01A/SW/MPL115A1/Wiring/MPL115A1/MPL115A1.ino |
---|
0,0 → 1,118 |
/* |
MPL115A1 sparkfun breakout baropressure meter |
SDN : pin 7 |
CSN : pin 10 |
SDI/MOSI : pin 11 |
SDO/MISO : pin 12 |
SCK : pin 13 |
*/ |
// the sensor communicates using SPI, so include the library: |
#include <SPI.h> |
#define PRESH 0x80 |
#define PRESL 0x82 |
#define TEMPH 0x84 |
#define TEMPL 0x86 |
#define A0MSB 0x88 |
#define A0LSB 0x8A |
#define B1MSB 0x8C |
#define B1LSB 0x8E |
#define B2MSB 0x90 |
#define B2LSB 0x92 |
#define C12MSB 0x94 |
#define C12LSB 0x96 |
#define CONVERT 0x24 |
#define chipSelectPin 10 |
#define shutDown 7 |
float A0_; |
float B1_; |
float B2_; |
float C12_; |
void setup() { |
Serial.begin(115200); |
// start the SPI library: |
SPI.begin(); |
// initalize the data ready and chip select pins: |
pinMode(shutDown, OUTPUT); |
digitalWrite(shutDown, HIGH); |
pinMode(chipSelectPin, OUTPUT); |
digitalWrite(chipSelectPin, HIGH); |
delay (10); |
// read registers that contain the chip-unique parameters to do the math |
unsigned int A0H = readRegister(A0MSB); |
unsigned int A0L = readRegister(A0LSB); |
A0_ = (A0H << 5) + (A0L >> 3) + (A0L & 0x07) / 8.0; |
unsigned int B1H = readRegister(B1MSB); |
unsigned int B1L = readRegister(B1LSB); |
B1_ = ( ( ( (B1H & 0x1F) * 0x100)+B1L) / 8192.0) - 3 ; |
unsigned int B2H = readRegister(B2MSB); |
unsigned int B2L = readRegister(B2LSB); |
B2_ = ( ( ( (B2H - 0x80) << 8) + B2L) / 16384.0 ) - 2 ; |
unsigned int C12H = readRegister(C12MSB); |
unsigned int C12L = readRegister(C12LSB); |
C12_ = ( ( ( C12H * 0x100 ) + C12L) / 16777216.0 ) ; |
} |
void loop() { |
Serial.print("de druk is : "); |
Serial.println(baropPessure()); |
delay(1000); |
} |
//Read registers |
unsigned int readRegister(byte thisRegister ) { |
unsigned int result = 0; // result to return |
digitalWrite(chipSelectPin, LOW); |
delay(10); |
SPI.transfer(thisRegister); |
result = SPI.transfer(0x00); |
digitalWrite(chipSelectPin, HIGH); |
return(result); |
} |
//read pressure |
float baropPessure(){ |
digitalWrite(chipSelectPin, LOW); |
delay(3); |
SPI.transfer(0x24); |
SPI.transfer(0x00); |
digitalWrite(chipSelectPin, HIGH); |
delay(3); |
digitalWrite(chipSelectPin, LOW); |
SPI.transfer(PRESH); |
unsigned int presH = SPI.transfer(0x00); |
delay(3); |
SPI.transfer(PRESL); |
unsigned int presL = SPI.transfer(0x00); |
delay(3); |
SPI.transfer(TEMPH); |
unsigned int tempH = SPI.transfer(0x00); |
delay(3); |
SPI.transfer(TEMPL); |
unsigned int tempL = SPI.transfer(0x00); |
delay(3); |
SPI.transfer(0x00); |
delay(3); |
digitalWrite(chipSelectPin, HIGH); |
unsigned long press = ((presH *256) + presL)/64; |
unsigned long temp = ((tempH *256) + tempL)/64; |
float pressure = A0_+(B1_+C12_*temp)*press+B2_*temp; |
float preskPa = pressure* (65.0/1023.0)+50.0; |
return(preskPa); |
} |
/Modules/Sensors/ALTIMET01A/SW/MPL3115/PIC16F887/main.hex |
---|
0,0 → 1,284 |
:1000000006308A00AA2E00000D054D264121202130 |
:100010006139EF36653A6539A0306E32A0206C3A0E |
:10002000E936653A65392032E5366F10E337E43258 |
:10003000A0060A00D4326D386539613A7539651009 |
:100040005B32E533A0215D105039E530F339753965 |
:1000500065105B28E12EA0206C3A693A7532651074 |
:10006000DB365D100D050001831603178C170C1489 |
:100070000000000083120C087F3903197A2803134B |
:10008000AD0003170D080313AE0003170F08031389 |
:10009000AF002D080C1E4A2899002E0803178D006A |
:1000A00003132F0803178F0083168C170C140000FE |
:1000B000000083120C0D0E0D7F3903197A280313EB |
:1000C000AD0003170D080313AE0003170F08031349 |
:1000D000AF002D080C1E6A2899002E0803178D000A |
:1000E00003132F0803178F008D0A03198F0A0313B8 |
:1000F00034280317031308000830F80000008711A4 |
:10010000A01120088316870000008312BE0D07127D |
:10011000031C902820162008831687009428831239 |
:10012000201220088316870000008312A0152008E3 |
:10013000831687008312871D9B28F80B7E280000FA |
:100140008711A01120088316870000008312201653 |
:10015000200883168700000000008312A0152008E5 |
:10016000831687008312871DB328F8010000071A41 |
:1001700078148711A01120088316870083120712B4 |
:1001800020122008831687008312080020162008FA |
:100190008316870000008312A015200883168700AD |
:1001A0000000831207122012200883168700000027 |
:1001B00083128711A011200883168700C030831294 |
:1001C000BE007C202630BE007C20B830BE007C20E3 |
:1001D000201220088316870000008312A015200833 |
:1001E000831687008312871DF3280000F72800007C |
:1001F000201620088316870000008312201620088E |
:100200008316870000008312A0152008831687003C |
:1002100000008312071220122008831687000000B6 |
:1002200083128711A011200883168700C030831223 |
:10023000BE007C201330BE007C200730BE007C2036 |
:10024000201220088316870000008312A0152008C2 |
:10025000831687008312871D2B2900002F29000099 |
:10026000201620088316870000008312201620081D |
:100270008316870000008312A015200883168700CC |
:100280000000831207122012200883168700000046 |
:1002900083128711A011200883168700C0308312B3 |
:1002A000BE007C202630BE007C203930BE007C2081 |
:1002B000201220088316870000008312A015200852 |
:1002C000831687008312871D6329000067290000B9 |
:1002D0002016200883168700000083128A110A1254 |
:1002E000DD2E2E3084008313000803198429023088 |
:1002F000F800F701F70B7A29F80B79299730F70006 |
:10030000F70B8029800B7729080020162008831618 |
:10031000870000008312A0152008831687000000C4 |
:100320008312071220122008831687000000831210 |
:100330008711A011200883168700C0308312BE00E9 |
:100340007C203C08BE007C202016200883168700F5 |
:1003500000008312A0152008831687000000831276 |
:10036000871DB0290712201220088316870000007D |
:1003700083128711A011200883168700C1308312D1 |
:10038000BE007C20F7010830BF007708C0002016AF |
:1003900020088316870000008312A015200883160A |
:1003A00087008312871DD229071A0314071E031022 |
:1003B000F80D0000A0112008831687008312871112 |
:1003C000BF0BC72920162008831687000000831260 |
:1003D000071240080319F12920122008831687000C |
:1003E00083120000A0152008831687008312871D42 |
:1003F000F72900008711A01120088316870000004C |
:1004000083120712201220088316870078088312AF |
:10041000BD00201220088316870000008312A0155B |
:100420002008831687008312871D142A0000182ACB |
:1004300000002016200883168700000083123D0864 |
:10044000F80008008E30F7003E08F8003D08F9007B |
:10045000FA01F808031D362A7908F800F901083076 |
:10046000F702F808031D362AF7013E2A0310F81B8D |
:100470003D2AF90DF80DF703362AF8130800410854 |
:100480000319042BCD0045080319042BCD02031CCE |
:100490004E2A7F30CD070318042B542A8130CD0219 |
:1004A000031C042B0319042B4D08F700F801F90174 |
:1004B000FA01CC014208CB00CB174308CA0044081C |
:1004C000C9001930CD004808C9020318772A013045 |
:1004D000CA020318772ACB020318772ACC02031822 |
:1004E000772ACC0ACB0ACA0A4808C907A92A4708AA |
:1004F000CA020318922A0130CB020318922ACC02B6 |
:100500000318922ACC0ACB0A4708CA074808C90729 |
:10051000031CA92ACA0A031DA92ACB0A031DA92A5A |
:10052000CC0AA92A46088038CB020318A82A013031 |
:10053000CC020318A82ACC0A46088038CB07470803 |
:10054000CA07031C862ACB0A031D862ACC0A862AE0 |
:100550007A14CD0BAC2AB72A0310C90DCA0DCB0DE6 |
:10056000CC0D0310FA0DF90DF80DCE0D632A4E1CBB |
:10057000BF2A0310F80CF90CFA0CCE0CC22AF703B0 |
:100580000319042BCE1BEB2A0310C90DCA0DCB0D8A |
:10059000CC0D4808C9020318D72A0130CA02031833 |
:1005A000D72ACB020318D72ACC02031CFA2A470801 |
:1005B000CA020318E22A0130CB020318E22ACC0255 |
:1005C000031CFA2A46088038CB020318EB2A0130B4 |
:1005D000CC02031CFA2AFA0A031DFA2AF90A031D9F |
:1005E000FA2AF80A031DFA2AF70A0319042BF80C51 |
:1005F000F90CFA0C4208CD004608CD06CD1F022B9F |
:10060000F817082BF813082BF701F801F901FA0184 |
:10061000080080308318C806CD01CE014408CC0004 |
:100620004808CC0643080319F92BCB00F70047080C |
:100630000319022CCB0203199E2B031C5C2B4808C8 |
:10064000D100D1174908D0004A08CF00CE010310CD |
:10065000D10CD00CCF0CCE0CCB0B262BCC1F332BBC |
:100660004D14162C4D104B104D164630840083133C |
:100670002B2C4D12CC1B462B4B1C512BD10CD00CD0 |
:10068000CF0CCE0CF70A0319112C512BD11B542B74 |
:100690000310CE0DCF0DD00DD10DF7030319112C82 |
:1006A000462B4D17BE2B4D134408CC00CC1F5A2BA4 |
:1006B000D1170A2CD1130A2C4708CB00F7004308A6 |
:1006C000CB024408D100D1174508D0004608CF001E |
:1006D000CE010310D10CD00CCF0CCE0CCB0B682B61 |
:1006E000CC1F752BCD14162CCD104B10CD164A30C7 |
:1006F000840083132B2CCD12CC1B882B4B1C932BEB |
:10070000D10CD00CCF0CCE0CF70A0319112C932B63 |
:10071000D11B962B0310CE0DCF0DD00DD10DF703AD |
:100720000319112C882BCD17BE2BCD134808CC00F4 |
:10073000CC1F9C2BD1170A2CD1130A2C4808D100AE |
:10074000D1174908D0004A08CF00CC1FAB2BD113DA |
:100750004D15162C4D11CE014B10463084008313DD |
:100760002B2CCC1BD42B4408CC004B1CBE2BD10C07 |
:10077000D00CCF0CCE0CF70A0319112CCE1FCF2BA7 |
:10078000CF0A031DCF2BD00A031DCF2BD10A031D87 |
:10079000CF2BD10CD00CCF0CF70A0319112C4D1B09 |
:1007A000532BCD1B952BF32B8030D106D11FDC2B87 |
:1007B000162C4808CC00E92B4408CC00D108031DB6 |
:1007C000E92BD008031DE92BCF08031DE92BF70106 |
:1007D0000A2CD11BF32B0310CE0DCF0DD00DD10D54 |
:1007E000F70BE92B112CCC1FF72BD1170A2CD113A7 |
:1007F0000A2C4708F7004808D1004908D0004A08E9 |
:10080000CF000A2C4308F7004408D1004508D00067 |
:100810004608CF005108F8005008F9004F08FA00C8 |
:10082000492CF701F801F901FA01492CCE01CF0951 |
:10083000D009D109CE09CE0A031D242CCF0A031DED |
:10084000242CD00A0319D10A4D18322BCD18742B41 |
:100850004D19AA2BD92B0008CF07031C352CD00A21 |
:10086000031D352CD10A03194B1484030008D0074B |
:10087000031C3D2CD10A03194B1484030008801F6C |
:10088000803AD10703184B144D1A392BCD1A7B2B04 |
:10089000B12B08000430BC0085217808AD0005307C |
:1008A000BC008521780EF7000F30F7057708BE01F0 |
:1008B000BD0022227708B6007808B7007908B80092 |
:1008C0007A08B900C4007908C3007808C200770824 |
:1008D000C100C801C701C6018330C5003F227A08A4 |
:1008E000B1007908B0007808AF007708AE00BE010B |
:1008F0002D08BD00222283107A08C6007908C500A1 |
:100900007808C4007708C3003108CA003008C9005D |
:100910002F08C8002E08C70009237A08B5007908F7 |
:10092000B4007808B3007708B2003208F700330843 |
:10093000F8003408F9003508FA008A110A12E52E89 |
:100940000130BC008521B001AF01AE017808AD00D7 |
:100950000230BC008521B2017808B1000330BC0030 |
:1009600085217808B300330EF7000F30F7057708BC |
:10097000BE01BD0022227708BD007808BE007908BC |
:10098000BF007A08C000C4007908C3007808C2001C |
:100990007708C100C801C701C6018130C5003F22E8 |
:1009A0007A08BB007908BA007808B9007708B8005F |
:1009B000BD012D0DBE002E0DBF002F0DC000BE0DC0 |
:1009C000BF0DC00DFC30BE05310DF900320DFA002F |
:1009D000F90DFA0DFC30F9057908BD047A08BE045A |
:1009E000330EF700F70CF70C0330F70577083D04DA |
:1009F000F7003E08F8003F08F9004008FA007A08BE |
:100A0000C6007908C5007808C4007708C300B6306E |
:100A1000F700FA01F901F8014308440445044604CB |
:100A2000031D142DF701212D0310F81B202DC30DDC |
:100A3000C40DC50DC60DFA0DF90DF80DF70B142DEB |
:100A4000F8137708BD007808BE007908BF007A085F |
:100A5000C00083107A08C6007908C5007808C40071 |
:100A60007708C3003B08CA003A08C9003908C80023 |
:100A70003808C70009237A08B7007908B600780853 |
:100A8000B5007708B4003408F7003508F8003608D8 |
:100A9000F9003708FA008A110A12EE2E20162008F3 |
:100AA0008316870000008312A01520088316870094 |
:100AB000000083120712201220088316870000000E |
:100AC00083128711A011200883168700C03083127B |
:100AD000BE007C202630BE007C20B830BE007C20CA |
:100AE000201220088316870000008312A01520081A |
:100AF000831687008312871D7B2D00007F2D000049 |
:100B00002016200883168700000083122016200874 |
:100B10008316870000008312A01520088316870023 |
:100B2000000083120712201220088316870000009D |
:100B300083128711A011200883168700C03083120A |
:100B4000BE007C201330BE007C200730BE007C201D |
:100B5000201220088316870000008312A0152008A9 |
:100B6000831687008312871DB32D0000B72D000068 |
:100B70002016200883168700000083122016200804 |
:100B80008316870000008312A015200883168700B3 |
:100B9000000083120712201220088316870000002D |
:100BA00083128711A011200883168700C03083129A |
:100BB000BE007C202630BE007C20B930BE007C20E8 |
:100BC000201220088316870000008312A015200839 |
:100BD000831687008312871DEB2D0000EF2D000088 |
:100BE0002016200883168700000083128A110A123B |
:100BF000F72E0130BC008521AE017808AD0002302F |
:100C0000BC008521B0017808AF000330BC0085210D |
:100C1000780EF7000F30F7057708BE01BD002222DD |
:100C20007708B9007808BA007908BB007A08BC00D8 |
:100C3000C4007908C3007808C2007708C100C80161 |
:100C4000C701C6018330C5003F227A08B400790885 |
:100C5000B3007808B2007708B1002D08BB00BA01D4 |
:100C60003A082F04F7002D083004FA007708BD0079 |
:100C70007A08BE0022227708BA007808BB007908FB |
:100C8000BC007A08BD0083107A08C6007908C50048 |
:100C90007808C4007708C3003408CA003308C900C4 |
:100CA0003208C8003108C70009237A08B80079085B |
:100CB000B7007808B6007708B5003508F7003608A1 |
:100CC000F8003708F9003808FA008A110A12FF2ED6 |
:100CD000F701F801F901FA01C201C301C401C5011C |
:100CE000410840043F043E040319A62E2030C600EC |
:100CF0000310BA0DBB0DBC0DBD0DC20DC30DC40D4F |
:100D0000C50D41084502031D8F2E40084402031DF6 |
:100D10008F2E3F084302031D8F2E3E084202031C04 |
:100D2000A02E3E08C2023F08031C3F0FC30240082A |
:100D3000031C400FC4024108031C410FC5020314E9 |
:100D4000F70DF80DF90DFA0DC60B782E4230840020 |
:100D500083130800840183131F30830571308316C9 |
:100D60008F000F08031787110C3003139900A2306E |
:100D70009800903083129800831603170908C03931 |
:100D8000890003131F129F1200300317880083127B |
:100D9000870188018901FF300313A0000430031785 |
:100DA0008D0000308F00031334201A3003178D009C |
:100DB00000308F0003133420C6280230AD00FA3013 |
:100DC000AE007121AD0BDF2E4A2C7A08A8007908FD |
:100DD000A7007808A6007708A500A02C7A08A40030 |
:100DE0007908A3007808A2007708A1004E2D0230F0 |
:100DF000AD00FA30AE007121AD0BF92EF92D7A0855 |
:100E0000AC007908AB007808AA007708A900023086 |
:100E100084002808B0002708AF002608AE00250887 |
:100E2000AD000130B1008A1500208A1120300C1E5F |
:100E3000172F9900053084002408B0002308AF0064 |
:100E40002208AE002108AD000130B1008A15002053 |
:100E50008A1120300C1E2A2F9900043084002C089F |
:100E6000B0002B08AF002A08AE002908AD00023000 |
:100E7000B1008A1500208A1120300C1E3D2F9900E8 |
:100E80000D300C1E412F99000A300C1E452F990081 |
:100E90000430AD00FA30AE007121AD0B4A2FDC2ECC |
:020EA0006300ED |
:101000000408B2003108B400031992283008BD006A |
:101010002F08BC002E08BB002D08BA00C101C0017A |
:101020002030BF008230BE003A0803198428C20075 |
:101030003E0803198428C207031825287F30C202FE |
:10104000031C84280319842829288130C207031827 |
:1010500084284208F700F801F901FA013B08C600AC |
:10106000C6173C08C5003D08C4001830C200C301C3 |
:10107000441C52284108FA07031C4428F90A031D9E |
:101080004428F80A0319C3174008F907031C4B2822 |
:10109000F80A0319C3173F08BC00BC173C08F8073F |
:1010A0000318C317C30DF80CF90CFA0CC60CC50CC9 |
:1010B000C40C0310C20B37280130F707031884282B |
:1010C000F81B6928C60DFA0DF90DF80DF703031981 |
:1010D0008428C61F7A28FA0A031D7A28F90A031DF4 |
:1010E0007A28F80A031D7A28F80CF90CFA0CF70A8A |
:1010F000031984283B08C3003F08C306C31F822886 |
:10110000F8178828F8138828F701F801F901FA017F |
:101110007A08B0007908AF007808AE007708AD0013 |
:10112000B40B06283008BD002F08BC002E08BB00F9 |
:101130002D08BA003A08B63CBA00FA013B08BE00D6 |
:10114000BB170310BB0CBC0CBD0CFA0CF90CF80C53 |
:10115000F70CBA0BA128BE1FB828F709F809F9093E |
:10116000FA09F70A0319F80A0319F90A0319FA0A1E |
:101170007A08B0007908AF007808AE007708AD00B3 |
:10118000B01FCF28B203B216AD09AE09AF09B0093E |
:10119000AD0A0319AE0A0319AF0A0319B00A3B30AE |
:1011A000B9009A30B800CA30B700B6010A30B400AE |
:1011B00031080319B20A3008BD002F08BC002E0800 |
:1011C000BB002D08BA003908C1003808C000370834 |
:1011D000BF003608BE008A1168268A150008AD00D7 |
:1011E000840A0008AE00840A0008AF00840A0008E0 |
:1011F000B000FD308407F708031D1129310A3402BD |
:10120000031911293208031913290F39340203195C |
:101210000B2903184729B21B4729321B13292030F9 |
:1012200042292030B205B21E2229B2123108031D14 |
:10123000B2037708B2002D300C1E1C299900320829 |
:10124000F700B20131083402031D31297708B200DA |
:101250002E300C1E292999003208F7002030B205E3 |
:1012600000303030B21E4229B2123108031DB203E1 |
:101270007708B2002D300C1E3B2999003208F70088 |
:10128000B2013030F70777080C1E4429990039085D |
:10129000BD003808BC003708BB003608BA00C101E1 |
:1012A000C001BF010A30BE008A1168268A157A087B |
:1012B000B9007908B8007808B7007708B600B40B11 |
:0412C000DB2808001F |
:04400E00F52CFF3F4F |
:00000001FF |
;PIC16F887 |
;CRC=79AB CREATED="06-VI-13 00:24" |
/Modules/Sensors/ALTIMET01A/SW/MPL3115/PIC16F887/main.c |
---|
0,0 → 1,142 |
#define VERSION "0.1" |
#define ID "$Id: main.c 2916 2013-04-14 17:42:03Z kaklik $" |
#include "main.h" |
#use i2c(master, sda=PIN_C4, scl=PIN_C3) |
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) //rcv TXD xmit RXD |
#define MPL3115_ADDR_R 0xC1 //addresa pro cteni |
#define MPL3115_ADDR_W 0xC0 |
void mpl3115_setA (void) //nastavení pro výku |
{ |
i2c_start(); //STANDBY mode |
I2C_Write(MPL3115_ADDR_W); |
I2C_write(0x26); |
I2C_write(0xB8); |
i2c_stop(); |
i2c_start(); //PT_DATA_CFG set |
I2C_Write(MPL3115_ADDR_W); |
I2C_write(0x13); |
I2C_write(0x07); //hodnota |
i2c_stop(); |
i2c_start(); //ACTIVE mode |
I2C_Write(MPL3115_ADDR_W); |
I2C_write(0x26); |
I2C_write(0xB9); |
i2c_stop(); |
} |
void mpl3115_setP (void) //nastavení pro tlak |
{ |
i2c_start(); //STANDBY mode |
I2C_Write(MPL3115_ADDR_W); |
I2C_write(0x26); |
I2C_write(0xB8); |
i2c_stop(); |
i2c_start(); //PT_DATA_CFG set |
I2C_Write(MPL3115_ADDR_W); |
I2C_write(0x13); |
I2C_write(0x07); //hodnota |
i2c_stop(); |
i2c_start(); //ACTIVE mode |
I2C_Write(MPL3115_ADDR_W); |
I2C_write(0x26); |
I2C_write(0x39); |
i2c_stop(); |
} |
byte mpl3115_read (byte reg) |
{ |
byte i; |
i2c_start(); |
I2C_Write(MPL3115_ADDR_W); |
I2C_write(reg); |
i2c_start(); |
I2C_Write(MPL3115_ADDR_R); |
i=i2c_read(0); |
i2c_stop(); |
return i; |
} |
float mpl3115_T (void) //teplota ve stupnich |
{ |
int m; |
float l, t; |
m = mpl3115_read (0x04); |
l = (float)(mpl3115_read(0x05)>>4)/16.0; |
t = (float)(M + L); |
return t; |
} |
float mpl3115_A (void) //vyska v m |
{ |
int16 m, c; |
float l, a; |
m = mpl3115_read (0x01); |
c = mpl3115_read (0x02); |
l = (float)(mpl3115_read(0x03)>>4)/16.0; |
a = (float)((m << 8)|c) + l; |
return a; |
} |
float mpl3115_P (void) //tlak v Pa |
{ |
unsigned int32 m; |
unsigned int16 c; |
unsigned int l; |
float p, l1; |
m = mpl3115_read (0x01); |
c = mpl3115_read (0x02); |
l = mpl3115_read(0x03); |
l1= (float)(l>>4)/4.0; |
p = (float)((m << 10)|(c<<2)|(l>>6)) + l1; |
return p; |
} |
void main() |
{ |
float p, t, a; |
printf("\r\nMLAB Barometer and Altimeter demo code \r\n",); |
printf("Temperature [deg C] Preassure [Pa] Altitude [m] \r\n",); |
while(TRUE) |
{ |
mpl3115_setP(); //nastaveni pro tlak a teplotu |
delay_ms (500); |
t=mpl3115_T(); |
p=mpl3115_P(); |
mpl3115_setA(); //nastaveni pro vysku a teplotu |
delay_ms (500); |
a=mpl3115_A(); |
printf("%3.1f %6.1f %5.2f \r\n", t, p, a); |
delay_ms (1000); |
} |
} |
/Modules/Sensors/ALTIMET01A/SW/MPL3115/PIC16F887/main.pjt |
---|
0,0 → 1,28 |
[PROJECT] |
Target=main.hex |
Development_Mode= |
Processor_Text=PIC16F887 |
ToolSuite=CCS |
Processor=0x887F |
[main] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=main.c |
[Windows] |
0=0000 %S 0 0 796 451 3 0 |
[Opened Files] |
1=main.c |
2=main.h |
3=C:\Program Files (x86)\PICC\devices\16F887.h |
4= |
[Target Data] |
OptionString=-p +FM |
FileList=Z:\home\kaklik\svnMLAB\Modules\Sensors\ALTIMET01A\SW\MPL3115\PIC16F887\main.c |
[Units] |
Count=1 |
1=main (main) |
/Modules/Sensors/ALTIMET01A/SW/MPL3115/PIC16F887/main.err |
---|
0,0 → 1,2 |
Memory usage: ROM=27% RAM=5% - 15% |
0 Errors, 0 Warnings. |
/Modules/Sensors/ALTIMET01A/SW/MPL3115/PIC16F887/main.h |
---|
0,0 → 1,19 |
#include <16F887.h> |
#device adc=8 |
#FUSES NOWDT //No Watch Dog Timer |
#FUSES INTRC //Internal RC Osc |
#FUSES NOPUT //No Power Up Timer |
#FUSES MCLR //Master Clear pin enabled |
#FUSES NOPROTECT //Code not protected from reading |
#FUSES NOCPD //No EE protection |
#FUSES NOBROWNOUT //No brownout reset |
#FUSES IESO //Internal External Switch Over mode enabled |
#FUSES FCMEN //Fail-safe clock monitor enabled |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
#FUSES NODEBUG //No Debug mode for ICD |
#FUSES NOWRT //Program memory not write protected |
#FUSES BORV40 //Brownout reset at 4.0V |
#use delay(clock=8000000) |
/Modules/Sensors/ALTIMET01A/SW/ARM/MPL115A1.cpp |
---|
0,0 → 1,221 |
/* mbed MPL115A1 (Barometric Pressure Sensor) Library |
* |
* This code is based on application notes and |
* Sparkfun example code, written by Jim Lindblom <jim at sparkfun.com> |
* |
* Copyright (c) 2012 Mitja Kleider |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
// TODO: support shutdown pin |
#include "MPL115A1.h" |
MPL115A1::MPL115A1(SPI& spi, PinName ncs) : _spi(spi), _cs(ncs) |
{ |
_cs = 1; |
// sdn = 1; // sensor on |
// SCL idle low, sample data on rising edge |
_spi.format(8, 0); // 8bit, POL 0, PHA 0 |
_spi.frequency(1000000); // 1MHz |
} |
void MPL115A1::write_register(uint8_t address, char data) |
{ |
//write any data byte to any single address |
//adds a 0 to the MSB of the address byte (WRITE mode) |
address &= 0x7F; |
_cs = 0; |
wait_ms(1); |
_spi.write(address); |
wait_ms(1); |
_spi.write(data); |
wait_ms(1); |
_cs = 1; |
} |
char MPL115A1::read_register(uint8_t address) |
{ |
// returns the contents of any 1 byte register from any address |
// sets the MSB for every address byte (READ mode) |
char byte; |
address |= 0x80; |
_cs = 0; |
_spi.write(address); |
byte = _spi.write(0x00); |
_cs = 1; |
return byte; |
} |
float MPL115A1::readPressure() |
{ |
// read pressure, temperature and coefficients, calculate and return absolute pressure [kPa] |
write_register(MPL115A1_STARTBOTH, 0x00); // start temperature and pressure conversions |
wait_ms(10); // AN: data is typically ready after 3ms, DS for both: max. 1ms |
// read raw pressure |
uiPH = read_register(MPL115A1_PRESH); |
uiPL = read_register(MPL115A1_PRESL); |
uiTH = read_register(MPL115A1_TEMPH); |
uiTL = read_register(MPL115A1_TEMPL); |
uiPadc = (unsigned int) uiPH << 8; |
uiPadc += (unsigned int) uiPL & 0x00FF; |
uiTadc = (unsigned int) uiTH << 8; |
uiTadc += (unsigned int) uiTL & 0x00FF; |
// read coefficients, put into 16-bit Variables |
// a0, pressure offset coefficient |
sia0MSB = read_register(MPL115A1_A0MSB); |
sia0LSB = read_register(MPL115A1_A0LSB); |
sia0 = (signed int) sia0MSB << 8; |
sia0 += (signed int) sia0LSB & 0x00FF; |
// b1, pressure sensitivity coefficient |
sib1MSB = read_register(MPL115A1_B1MSB); |
sib1LSB = read_register(MPL115A1_B1LSB); |
sib1 = (signed int) sib1MSB << 8; |
sib1 += (signed int) sib1LSB & 0x00FF; |
// b2, 1st order temperature offset coefficient (TCO) |
sib2MSB = read_register(MPL115A1_B2MSB); |
sib2LSB = read_register(MPL115A1_B2LSB); |
sib2 = (signed int) sib2MSB << 8; |
sib2 += (signed int) sib2LSB & 0x00FF; |
// c12, temperature sensitivity coefficient (TCS) |
sic12MSB = read_register(MPL115A1_C12MSB); |
sic12LSB = read_register(MPL115A1_C12LSB); |
sic12 = (signed int) sic12MSB << 8; |
sic12 += (signed int) sic12LSB & 0x00FF; |
// c11, pressure linearity (2nd order) coefficient |
sic11MSB = read_register(MPL115A1_C11MSB); |
sic11LSB = read_register(MPL115A1_C11LSB); |
sic11 = (signed int) sic11MSB << 8; |
sic11 += (signed int) sic11LSB & 0x00FF; |
// c22, 2nd order temperature offset coefficient |
sic22MSB = read_register(MPL115A1_C22MSB); |
sic22LSB = read_register(MPL115A1_C22LSB); |
sic22 = (signed int) sic22MSB << 8; |
sic22 += (signed int) sic22LSB & 0x00FF; |
// Coefficient 9 equation compensation |
// 10bit stored in 16bit, shift right |
uiPadc = uiPadc >> 6; |
uiTadc = uiTadc >> 6; |
// Step 1: c11x1 = c11 * Padc |
lt1 = (signed long) sic11; |
lt2 = (signed long) uiPadc; |
lt3 = lt1*lt2; |
si_c11x1 = (signed long) lt3; |
// Step 2: a11 = b1 + c11x1 |
lt1 = ((signed long)sib1)<<14; |
lt2 = (signed long) si_c11x1; |
lt3 = lt1 + lt2; |
si_a11 = (signed long)(lt3>>14); |
// Step 3: c12x2 = c12 * Tadc |
lt1 = (signed long) sic12; |
lt2 = (signed long) uiTadc; |
lt3 = lt1*lt2; |
si_c12x2 = (signed long)lt3; |
// Step 4: a1 = a11 + c12x2 |
lt1 = ((signed long)si_a11<<11); |
lt2 = (signed long)si_c12x2; |
lt3 = lt1 + lt2; |
si_a1 = (signed long) lt3>>11; |
// Step 5: c22x2 = c22*Tadc |
lt1 = (signed long)sic22; |
lt2 = (signed long)uiTadc; |
lt3 = lt1 * lt2; |
si_c22x2 = (signed long)(lt3); |
// Step 6: a2 = b2 + c22x2 |
lt1 = ((signed long)sib2<<15); |
lt2 = ((signed long)si_c22x2>1); |
lt3 = lt1+lt2; |
si_a2 = ((signed long)lt3>>16); |
// Step 7: a1x1 = a1 * Padc |
lt1 = (signed long)si_a1; |
lt2 = (signed long)uiPadc; |
lt3 = lt1*lt2; |
si_a1x1 = (signed long)(lt3); |
// Step 8: y1 = a0 + a1x1 |
lt1 = ((signed long)sia0<<10); |
lt2 = (signed long)si_a1x1; |
lt3 = lt1+lt2; |
si_y1 = ((signed long)lt3>>10); |
// Step 9: a2x2 = a2 * Tadc |
lt1 = (signed long)si_a2; |
lt2 = (signed long)uiTadc; |
lt3 = lt1*lt2; |
si_a2x2 = (signed long)(lt3); |
// Step 10: pComp = y1 + a2x2 |
lt1 = ((signed long)si_y1<<10); |
lt2 = (signed long)si_a2x2; |
lt3 = lt1+lt2; |
// Fixed point result with rounding |
//siPcomp = ((signed int)lt3>>13); |
siPcomp = lt3/8192; |
// decPcomp is defined as a floating point number |
// Conversion to decimal value from 1023 ADC count value |
// ADC counts are 0 to 1023, pressure is 50 to 115kPa respectively |
decPcomp = ((65.0/1023.0)*siPcomp)+50; |
return decPcomp; |
} |
float MPL115A1::readTemperature() |
{ |
// read, calculate and return temperature |
write_register(MPL115A1_STARTTEMP, 0x00); // start temperature conversion |
wait_ms(10); // AN: data is typically ready after 3ms, DS for temp: max. 0.7ms |
// read raw temperature |
uiTH = read_register(MPL115A1_TEMPH); |
uiTL = read_register(MPL115A1_TEMPL); |
uiTadc = (unsigned int) uiTH << 8; |
uiTadc += (unsigned int) uiTL & 0x00FF; |
// 10bit stored in 16bit, shift right |
uiTadc = uiTadc >> 6; |
// Tadc is 472 counts at 25degC, -5.35 counts/degC |
// return ((float)uiTadc - 472.0)/(-5.35) + 25 |
return (605.75-uiTadc)*0.186916; |
} |
/Modules/Sensors/ALTIMET01A/SW/ARM/MPL115A1.h |
---|
0,0 → 1,87 |
#ifndef MPL115A1_H |
#define MPL115A1_H |
#include "mbed.h" |
/** barometric pressure and temperature sensor MPL115A1 control class, based on SPI |
* |
* Example: |
* @code |
* #include "mbed.h" |
* #include "MPL115A1.h" |
* |
* SPI spi(p11,p12,p13); |
* MPL115A1 bar(spi, p14); |
* |
* Serial pc(USBTX, USBRX); |
* |
* int main() { |
* while(1) { |
* wait(10); |
* pc.printf("Pressure is %f\n", bar.readPressure()); |
* pc.printf("Temperature is %f\n", bar.readTemperature()); |
* } |
* } |
* @endcode |
*/ |
// real addresses, in read_register: address |= 0x80 |
#define MPL115A1_PRESH 0x00 // 80 |
#define MPL115A1_PRESL 0x02 // 82 |
#define MPL115A1_TEMPH 0x04 // 84 |
#define MPL115A1_TEMPL 0x06 // 86 |
#define MPL115A1_A0MSB 0x08 // 88 |
#define MPL115A1_A0LSB 0x0A // 8A |
#define MPL115A1_B1MSB 0x0C // 8C |
#define MPL115A1_B1LSB 0x0E // 8E |
#define MPL115A1_B2MSB 0x10 // 90 |
#define MPL115A1_B2LSB 0x12 // 92 |
#define MPL115A1_C12MSB 0x14 // 94 |
#define MPL115A1_C12LSB 0x16 // 96 |
#define MPL115A1_C11MSB 0x18 // 98 |
#define MPL115A1_C11LSB 0x1A // 9A |
#define MPL115A1_C22MSB 0x1C // 9C |
#define MPL115A1_C22LSB 0x1E // 9E |
#define MPL115A1_STARTPRES 0x20 // start pressure measurement |
#define MPL115A1_STARTTEMP 0x22 // start temperature measurement |
#define MPL115A1_STARTBOTH 0x24 // start both simultaneously |
class MPL115A1 { |
private: |
SPI& _spi; |
DigitalOut _cs; // chip select, active low |
//DigitalOut sdn; // shutdown pin, high=on, low=off |
public: |
/** Create a barometer object connected to the SPI bus and specified chip select pin |
* |
* @param spi SPI master object |
* @param ncs chip select pin |
*/ |
MPL115A1(SPI& spi, PinName ncs); |
/** start measurement, read registers, calculate and return pressure */ |
float readPressure(); |
/** start measurement, read registers, calculate and return temperature */ |
float readTemperature(); |
private: |
void write_register(uint8_t address, char data); |
char read_register(uint8_t address); |
signed char sia0MSB, sia0LSB; |
signed char sib1MSB, sib1LSB; |
signed char sib2MSB, sib2LSB; |
signed char sic12MSB, sic12LSB; |
signed char sic11MSB, sic11LSB; |
signed char sic22MSB, sic22LSB; |
signed int sia0, sib1, sib2, sic12, sic11, sic22, siPcomp; |
float decPcomp; |
signed long lt1, lt2, lt3, si_c11x1, si_a11, si_c12x2; |
signed long si_a1, si_c22x2, si_a2, si_a1x1, si_y1, si_a2x2; |
unsigned int uiPadc, uiTadc; |
unsigned char uiPH, uiPL, uiTH, uiTL; |
}; |
#endif |