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.
Dependencies: mbed SDFileSystem_
Diff: main.cpp
- Revision:
- 1:025596ffc973
- Parent:
- 0:b76e4ba14765
- Child:
- 2:42900b8c9a14
--- a/main.cpp Fri Feb 12 05:10:48 2021 +0000
+++ b/main.cpp Fri Feb 12 05:52:56 2021 +0000
@@ -26,15 +26,40 @@
SPI STSPI(PB_15, PB_14, PB_13); //mosi,miso,clk
DigitalOut STSPICS(PB_12);
DigitalOut led(PB_5);
+int initLIS3DH();
+int read3axes(short *tx,short *ty,short *tz);
+int readTemp(short *tmp);
int main()
{
+ initLIS3DH();
+ short x,y,z,tmp;
+
pc.printf("\nSTM32 ADC internal channels reading example\r\n");
while(1) {
pc.printf("ADC Temp = %f\r\n", (adc_temp.read()*100));
pc.printf("ADC VRef = %f\r\n", adc_vref.read());
- pc.printf("\033[2A");
+// pc.printf("\033[2A");
+
+
+ read3axes(&x,&y,&z);
+ readTemp(&tmp);
+ pc.printf("x=%d y=%d z=%d tmperature=%d\r\n", x,y,z,tmp);
+ pc.printf("x=%f y=%f z=%f\r\n", (float)x/1024.0f,(float)y/1024.0f,(float)z/1024.0f);
led = !led;
wait(1.0);
}
}
+/*********** porting **************/
+void spiFormat(int b,int m) {
+ STSPI.format(b,m); /* 8bit */
+}
+void spiFrequency(int f){
+ STSPI.frequency(f); /* 1Mbps */
+}
+void spiWriteCS(int cs) {
+ STSPICS=cs;
+}
+int spiWrite(int wd) {
+ return ( STSPI.write(wd));
+}