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
Diff: main.cpp
- Revision:
- 5:fbeb85ebd47b
- Parent:
- 4:040903da458c
--- a/main.cpp Tue Aug 03 02:54:13 2021 +0000 +++ b/main.cpp Tue Aug 03 08:35:52 2021 +0000 @@ -19,9 +19,18 @@ PIO_intout2 PH_1 PIO_spics PB_12 PIO_battryMonEn PA_5 + PB_7 SDA + PB_6 SCL + */ -DigitalOut hx_clk(PB_7); -DigitalIn hx_dt(PB_6); +//DigitalOut hx_clk(PB_7); +//DigitalIn hx_dt(PB_6); +//I2C i2cacc(p_sda, p_scl) + +#include "H3LIS331DL.h" + +H3LIS331DL h3dacc(PB_7,PB_6); + RawSerial pc(PA_9, PA_10,115200); //console UART LowPowerTicker interrput; @@ -68,18 +77,25 @@ initLIS3DH(); + h3dacc.init(H3LIS331DL_ODR_100Hz, H3LIS331DL_NORMAL,H3LIS331DL_FULLSCALE_2); + pc.printf("\nSTM32 ADC internal channels reading example\r\n"); pc.printf("\nSTM32 3D acc sensor 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("ADC Temp = %f\r\n", (adc_temp.read()*100)); +// pc.printf("ADC VRef = %f\r\n", adc_vref.read()); // pc.printf("\033[2A"); - - +//On board ACC sensor + x=y=z=0; 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); + pc.printf("x=%f y=%f z=%f\r\n", (float)x/1024.0f,(float)y/1024.0f,(float)z/1024.0f); +// Extra ACC sensor + x=y=z=0; + h3dacc.readXYZ(&x, &y, &z); + pc.printf("High x=%d y=%d z=%d \r\n", x,y,z); + led = !led; wait(1.0); }