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 H3LIS331DL
Diff: main.cpp
- Revision:
- 2:42900b8c9a14
- Parent:
- 1:025596ffc973
- Child:
- 3:43ec9759b4ab
--- a/main.cpp Fri Feb 12 05:52:56 2021 +0000 +++ b/main.cpp Mon Mar 29 06:39:06 2021 +0000 @@ -20,6 +20,8 @@ PIO_spics PB_12 PIO_battryMonEn PA_5 */ +DigitalOut hx_clk(PB_7); +DigitalIn hx_dt(PB_6); RawSerial pc(PA_9, PA_10,115200); //console UART LowPowerTicker interrput; @@ -32,8 +34,33 @@ int main() { + short x,y,z,tmp; + + int i,l; + int lwaight; + float wt; + uint32_t dt; + pc.printf("\nSTM32 Loadcell example\r\n"); + while(1) { + led = !led; + hx_clk=0; + wait(1.0); + dt=0; + for(i=0;i<24;i++) { + hx_clk=1; + wait_us(1); + dt <<= 1; + if (hx_dt==0) dt |= 1; + hx_clk=0; + wait_us(1); + } + pc.printf("data = %08x %d ",dt,dt); + wt = (float)(dt) * 0.000038f - 1.2f; + pc.printf("waight = %3.3f\r\n",wt); + } + + initLIS3DH(); - short x,y,z,tmp; pc.printf("\nSTM32 ADC internal channels reading example\r\n"); while(1) {