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:
- 3:18847ea9afbe
- Parent:
- 0:ae8082690b32
- Child:
- 4:e3238cb56cb7
--- a/main.cpp Tue Aug 09 02:57:09 2022 +0000 +++ b/main.cpp Tue Aug 09 06:26:00 2022 +0000 @@ -1,24 +1,23 @@ #include "mbed.h" #include "HEPTA_EPS.h" -#define MAG 0x13<<1 +#define MAG 0x13<<1 //addr_compus + Serial pc(USBTX, USBRX); +HEPTA_EPS eps(p16,p26); I2C i2c(p28,p27); -DigitalOut pin(p26); float magnet[3]; char cmd[2]={0}; -const double dt = 1; char send[1], get[1]; int data[8]={0}; -char temp; +char temp; //temperature int main() { - pin=1; i2c.frequency(100000); - printf("magnet setting\r\n"); + pc.printf("magnet setting\r\n"); cmd[0]=0x4B; cmd[1]=0x01; - i2c.write(MAG,cmd,2); wait(0.1); + i2c.write(MAG,cmd,2); cmd[0]=0x4C; cmd[1]=0x00; i2c.write(MAG,cmd,2); @@ -34,8 +33,6 @@ cmd[0]=0x00; i2c.write(MAG,cmd,1,1); i2c.read(MAG,cmd,1); - printf("read:0x%02x\r\n",cmd[0]); - while(1) { for(int i=0;i<8;i++){ send[0]=(char)(0x42+i); @@ -51,8 +48,6 @@ else if(i!=2 && magnet[i]>4095)magnet[i]-=8092; } pc.printf("mx = %2.4f, my = %2.4f, mz = %2.4f\r\n\n",magnet[0],magnet[1],magnet[2]); - wait(dt); + wait(1); } -} - - +} \ No newline at end of file