Skip to content

Commit a325d2e

Browse files
Correct Arduino Library folder structure and files created
Created .cpp, .h, and register files for code. Started each file with documentation block. Set up folder structure to be correct
1 parent b373f53 commit a325d2e

File tree

10 files changed

+98
-66
lines changed

10 files changed

+98
-66
lines changed

Documentation/README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

Enclosure/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

Firmware/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

Hardware/README.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

Libraries/README.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

Production/README.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

Software/README.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/SparkFun_TMAG5273.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/******************************************************************************
2+
SparkFunTMAG5273.cpp
3+
SparkFunTMAG5273 Library Source File
4+
Madison Chodikov @ SparkFun Electronics
5+
Original Creation Date: May 1st, 2023
6+
https://github.com/sparkfun/SparkFun_TMAG5273_Arduino_Library
7+
8+
This file implements all functions of the TMAG5273. Functions here range
9+
from ________
10+
11+
Development environment specifics:
12+
IDE: Arduino 1.8.9
13+
Hardware Platform: Arduino Uno
14+
TMAG5273 Breakout Version: 1.0.0
15+
This code is beerware; if you see me (or any other SparkFun employee) at the
16+
local, and you've found our code helpful, please buy us a round!
17+
Distributed as-is; no warranty is given.
18+
******************************************************************************/
19+
20+
#include <Arduino.h>
21+
#include <Wire.h>
22+
#include "SparkFun_TMAG5273_Registers.h"
23+
#include "SparkFun_TMAG5273.h"
24+
25+
TMAG5273::TMAG5273()
26+
{
27+
}
28+
29+
/* BEGIN
30+
This function checks if the TMAG will ACK over I2C, and
31+
if the TMAG will correctly self-identify with the proper
32+
device ID. This will set the address of the deivce along
33+
with setting the wire for the I2C Communication.
34+
This will return true if both checks pass.
35+
*/
36+
bool TMAG5273::begin(uint8_t sensorAddress, TwoWire &wirePort)
37+
{
38+
_i2cPort = &wirePort; // Chooses the wire port of the device
39+
_deviceAddress = sensorAddress; // Sets the address of the device
40+
41+
//make sure the TMP will acknowledge over I2C
42+
_i2cPort->beginTransmission(_deviceAddress);
43+
if (_i2cPort->endTransmission() != 0)
44+
{
45+
return false;
46+
}
47+
48+
uint16_t deviceID = readRegister(TMAG5273_DEVICE_ID); // reads registers into rawData
49+
50+
//make sure the device ID reported by the TMP is correct
51+
//should always be 0x0117
52+
if (deviceID != DEVICE_ID_VALUE)
53+
{
54+
return false;
55+
}
56+
57+
return true; //returns true if all the checks pass
58+
}
59+
60+

src/SparkFun_TMAG5273.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/******************************************************************************
2+
SparkFunTMAG5273.cpp
3+
SparkFunTMAG5273 Library Source File
4+
Madison Chodikov @ SparkFun Electronics
5+
Original Creation Date: May 1st, 2023
6+
https://github.com/sparkfun/SparkFun_TMAG5273_Arduino_Library
7+
8+
This file implements all functions of the TMAG5273. Functions here range
9+
from ________
10+
11+
Development environment specifics:
12+
IDE: Arduino 1.8.9
13+
Hardware Platform: Arduino Uno
14+
TMAG5273 Breakout Version: 1.0.0
15+
This code is beerware; if you see me (or any other SparkFun employee) at the
16+
local, and you've found our code helpful, please buy us a round!
17+
Distributed as-is; no warranty is given.
18+
******************************************************************************/
19+

src/SparkFun_TMAG5273_Registers.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/******************************************************************************
2+
SparkFunTMAG5273.cpp
3+
SparkFunTMAG5273 Library Source File
4+
Madison Chodikov @ SparkFun Electronics
5+
Original Creation Date: May 1st, 2023
6+
https://github.com/sparkfun/SparkFun_TMAG5273_Arduino_Library
7+
8+
This file implements all functions of the TMAG5273. Functions here range
9+
from ________
10+
11+
Development environment specifics:
12+
IDE: Arduino 1.8.9
13+
Hardware Platform: Arduino Uno
14+
TMAG5273 Breakout Version: 1.0.0
15+
This code is beerware; if you see me (or any other SparkFun employee) at the
16+
local, and you've found our code helpful, please buy us a round!
17+
Distributed as-is; no warranty is given.
18+
******************************************************************************/
19+

0 commit comments

Comments
 (0)