Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
May1624-Wireless-Controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jdkruege
May1624-Wireless-Controller
Commits
c75f4917
Commit
c75f4917
authored
9 years ago
by
jdkruege
Browse files
Options
Downloads
Patches
Plain Diff
Changed LSM9DS0 to follow a singleton pattern,.
parent
f7ea215a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Development/Software/Controller API/LSM9DS0.cpp
+15
-2
15 additions, 2 deletions
Development/Software/Controller API/LSM9DS0.cpp
Development/Software/Controller API/LSM9DS0.h
+11
-2
11 additions, 2 deletions
Development/Software/Controller API/LSM9DS0.h
with
26 additions
and
4 deletions
Development/Software/Controller API/LSM9DS0.cpp
+
15
−
2
View file @
c75f4917
/*
/*
* @author Branden Sammons
* @author Branden Sammons
& Jonathan Krueger
*/
*/
#include
"LSM9DS0.h"
#include
"LSM9DS0.h"
bool
LSM9DS0
::
initialized
=
false
;
/**
/**
* Constructor for the LSM9DS0 class.
* Constructor for the LSM9DS0 class.
* Sets up the right SPI channels, frequency, mode, and registers.
* Sets up the right SPI channels, frequency, mode, and registers.
*/
*/
LSM9DS0
::
LSM9DS0
()
{
LSM9DS0
::
LSM9DS0
()
{
// set up the mraa library
// set up the mraa library
mraa_init
();
mraa_init
();
...
@@ -28,9 +29,21 @@ LSM9DS0::LSM9DS0() {
...
@@ -28,9 +29,21 @@ LSM9DS0::LSM9DS0() {
// set up registers
// set up registers
// place holder
// place holder
}
}
LSM9DS0
LSM9DS0
::
instance
()
{
if
(
!
initialized
)
{
myInstance
=
LSM9DS0
();
initialized
=
true
;
}
return
myInstance
;
}
/**
/**
* Deconstructor for the LSM9DS0 class.
* Deconstructor for the LSM9DS0 class.
* Realeases the SPI channels.
* Realeases the SPI channels.
...
...
This diff is collapsed.
Click to expand it.
Development/Software/Controller API/LSM9DS0.h
+
11
−
2
View file @
c75f4917
...
@@ -5,18 +5,27 @@
...
@@ -5,18 +5,27 @@
#include
"mraa.h"
#include
"mraa.h"
#include
<unistd.h>
#include
<unistd.h>
#include
<stdint.h>
#include
<stdint.h>
#include
"Service.h"
class
LSM9DS0
{
class
LSM9DS0
{
public:
public:
LSM9DS0
();
~
LSM9DS0
();
~
LSM9DS0
();
static
LSM9DS0
instance
();
void
run
();
uint8_t
read_G
(
uint8_t
address
);
uint8_t
read_G
(
uint8_t
address
);
void
write_G
(
uint8_t
address
,
uint8_t
data
);
void
write_G
(
uint8_t
address
,
uint8_t
data
);
uint8_t
read_XM
(
uint8_t
address
);
uint8_t
read_XM
(
uint8_t
address
);
void
write_XM
(
uint8_t
address
,
uint8_t
data
);
void
write_XM
(
uint8_t
address
,
uint8_t
data
);
private:
private:
static
bool
initialized
;
static
LSM9DS0
myInstance
;
LSM9DS0
();
mraa_spi_context
SPI_1
;
mraa_spi_context
SPI_1
;
mraa_spi_context
SPI_2
;
mraa_spi_context
SPI_2
;
uint8_t
read
(
mraa_spi_context
SPI
,
uint8_t
address
);
uint8_t
read
(
mraa_spi_context
SPI
,
uint8_t
address
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment