Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 1:3295382ddc81
- Parent:
- 0:9146d1e52be0
- Child:
- 2:b6a0d4ba24a1
--- a/main.cpp Tue Mar 06 12:33:06 2018 +0000 +++ b/main.cpp Wed Mar 14 21:04:25 2018 +0000 @@ -1,9 +1,48 @@ #include "mbed.h" +#include "main.h" -Serial pc(USBTX, USBRX); // tx, rx +Serial pc(SERIAL_TX, SERIAL_RX, 115200); // tx, rx +//DigitalOut led(LED_RED); +//SPI spi(PTC6,PTC7,PTD1,PTC0); +//SPI spi(PTC6,PTC7,PTD1); // my prefered, but mixed +SPI spi(PTC6,PTC7,PTC5); // PTC5 - the LED +//SPI spi(PTD2,PTD3,PTD1); +DigitalOut cs(PTC0); int main() { - pc.printf("Hello World!\n"); - while(1); + int PROM[8]; + cs.write(1); // disable all SPI + pc.printf("Hello World! 0\r\n"); + MS5611_init(PROM); + for (int i=0; i<8; i++) { + pc.printf("Prom(%i): %x\r\n",i,PROM[i]); + } +} + +void MS5611_init(int *PROM) +{ + spi.format(8,0); // 8 bit mode 0 - this is default anyway but good to code. + spi.frequency(1000000); // 1MHz is this the minimum? + cs.write(0); // Enable the MS5611 intercae + pc.printf("Reset result - expect fe : %x\r\n",spi.write(0x1E)); // reset the device + wait_ms(3); // give time for ROM to reload 2.8ms by the spec + for (int i=0; i<8; i++) { + pc.printf("s: %x r: %x ",0xA0|(i<<1),spi.write(0xA0|(i<<1))); + register uint8_t promh=spi.write(0x00); + register uint8_t proml=spi.write(0x00); + PROM[i]=((promh<<8)|(proml)); + pc.printf("%i: Code=%x : Reply=%x\r\n",i,0xA0|(i<<1),PROM[i]); + wait(1); + } + cs.write(1); // and disable the interace +} + + + +void MS5611(long *D1, long *D2) +{ + // cs.write(0); + spi.format(8,0); + spi.frequency(1000000); } \ No newline at end of file