Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RBComb Temperature Control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Model registry
Operate
Terraform modules
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
Pascal Engeler
RBComb Temperature Control
Commits
ab0ca967
Commit
ab0ca967
authored
1 year ago
by
Pascal Engeler
Browse files
Options
Downloads
Patches
Plain Diff
Bytesize and datastatus bugfix, added function members
parent
c7c9929f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
firmware/drivers/ad7124_4/ad7124_4.cpp
+16
-5
16 additions, 5 deletions
firmware/drivers/ad7124_4/ad7124_4.cpp
firmware/drivers/ad7124_4/ad7124_4.hpp
+17
-7
17 additions, 7 deletions
firmware/drivers/ad7124_4/ad7124_4.hpp
with
33 additions
and
12 deletions
firmware/drivers/ad7124_4/ad7124_4.cpp
+
16
−
5
View file @
ab0ca967
...
@@ -12,13 +12,13 @@ Ad7124_4::Ad7124_4(unsigned nCS, const SPISettings* spisettings): ncs_(nCS), spi
...
@@ -12,13 +12,13 @@ Ad7124_4::Ad7124_4(unsigned nCS, const SPISettings* spisettings): ncs_(nCS), spi
/*Selection Function Members*/
/*Selection Function Members*/
//Pull nCS low
//Pull nCS low
void
Ad7124_4
::
select
()
void
Ad7124_4
::
select
_
()
{
{
digitalWrite
(
ncs_
,
LOW
);
digitalWrite
(
ncs_
,
LOW
);
}
}
//Pull nCS high
//Pull nCS high
void
Ad7124_4
::
deselect
()
void
Ad7124_4
::
deselect
_
()
{
{
digitalWrite
(
ncs_
,
HIGH
);
digitalWrite
(
ncs_
,
HIGH
);
}
}
...
@@ -29,15 +29,18 @@ template<class T>
...
@@ -29,15 +29,18 @@ template<class T>
void
Ad7124_4
::
write_register
(
uint8_t
reg
,
T
data
){
void
Ad7124_4
::
write_register
(
uint8_t
reg
,
T
data
){
SPIwrite_
(
data
,
reg
);
SPIwrite_
(
data
,
reg
);
//detect and track writes to ADC_CONTROL_DATA_STATUS bit
//detect and track writes to ADC_CONTROL_DATA_STATUS bit
datastatus_
=
((
reg
==
REG_ADC_CONTROL
)
&&
((
data
&
ADC_CONTROL_DATA_STATUS
)
!=
0
));
if
(
reg
==
REG_ADC_CONTROL
){
datastatus_
=
((
data
&
ADC_CONTROL_DATA_STATUS
)
!=
0
);
}
//datastatus_ = ((reg == REG_ADC_CONTROL) && ((data & ADC_CONTROL_DATA_STATUS) != 0));
}
}
uint32_t
Ad7124_4
::
read_register
(
uint8_t
reg
,
uint8_t
num_bytes
){
uint32_t
Ad7124_4
::
read_register
(
uint8_t
reg
,
uint8_t
num_bytes
){
if
(
num_bytes
==
8
){
if
(
num_bytes
==
1
){
SPIread_
(
buf8_
,
reg
,
num_bytes
);
SPIread_
(
buf8_
,
reg
,
num_bytes
);
return
static_cast
<
uint8_t
>
(
buf8_
);
return
static_cast
<
uint8_t
>
(
buf8_
);
}
}
else
if
(
num_bytes
==
16
){
else
if
(
num_bytes
==
2
){
SPIread_
(
buf16_
,
reg
,
num_bytes
);
SPIread_
(
buf16_
,
reg
,
num_bytes
);
return
static_cast
<
uint32_t
>
(
buf16_
);
return
static_cast
<
uint32_t
>
(
buf16_
);
}
}
...
@@ -70,6 +73,10 @@ uint32_t Ad7124_4::get_error(){
...
@@ -70,6 +73,10 @@ uint32_t Ad7124_4::get_error(){
return
buf32_
&
0x00FFFFFF
_u32
;
return
buf32_
&
0x00FFFFFF
_u32
;
}
}
bool
Ad7124_4
::
data_status
(){
return
datastatus_
;
}
void
Ad7124_4
::
reset
(){
void
Ad7124_4
::
reset
(){
SPI
.
beginTransaction
(
*
spisettings_
);
SPI
.
beginTransaction
(
*
spisettings_
);
for
(
unsigned
i
=
0
;
i
<
8
;
++
i
){
for
(
unsigned
i
=
0
;
i
<
8
;
++
i
){
...
@@ -111,6 +118,10 @@ void Ad7124_4::SPIread_(T& data, uint8_t reg, uint8_t readlen)
...
@@ -111,6 +118,10 @@ void Ad7124_4::SPIread_(T& data, uint8_t reg, uint8_t readlen)
}
}
}
}
unsigned
Ad7124_4
::
get_ncs_
(){
return
ncs_
;
}
//explicit instantiations
//explicit instantiations
template
void
Ad7124_4
::
write_register
<
uint8_t
>(
uint8_t
reg
,
uint8_t
data
);
template
void
Ad7124_4
::
write_register
<
uint8_t
>(
uint8_t
reg
,
uint8_t
data
);
...
...
This diff is collapsed.
Click to expand it.
firmware/drivers/ad7124_4/ad7124_4.hpp
+
17
−
7
View file @
ab0ca967
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include
<ad7124_registers.hpp>
#include
<ad7124_registers.hpp>
#include
<SPI.h>
#include
<SPI.h>
class
Ad7124_4
class
Ad7124_4
{
{
public:
public:
...
@@ -11,13 +12,6 @@ public:
...
@@ -11,13 +12,6 @@ public:
Ad7124_4
(
const
Ad7124_4
&
)
=
delete
;
Ad7124_4
(
const
Ad7124_4
&
)
=
delete
;
~
Ad7124_4
()
=
default
;
~
Ad7124_4
()
=
default
;
/*Selection Function Members*/
//Pull nCS low
void
select
();
//Pull nCS high
void
deselect
();
/*Communication Function Members*/
/*Communication Function Members*/
//T must be either uint8_t, uint16_t or uint32_t
//T must be either uint8_t, uint16_t or uint32_t
template
<
class
T
>
template
<
class
T
>
...
@@ -28,12 +22,17 @@ public:
...
@@ -28,12 +22,17 @@ public:
/*Operation Function Members*/
/*Operation Function Members*/
bool
data_available
();
bool
data_available
();
bool
check_error
();
bool
check_error
();
bool
data_status
();
uint32_t
get_data
();
uint32_t
get_data
();
uint32_t
get_error
();
uint32_t
get_error
();
void
reset
();
void
reset
();
/*Friends*/
friend
class
Spi_selecta
;
private:
private:
/*Private Function Members*/
/*Private Function Members*/
//T must be either uint8_t, uint16_t or uint32_t
//T must be either uint8_t, uint16_t or uint32_t
...
@@ -45,6 +44,17 @@ private:
...
@@ -45,6 +44,17 @@ private:
template
<
class
T
>
template
<
class
T
>
void
SPIread_
(
T
&
data
,
uint8_t
reg
,
uint8_t
readlen
);
void
SPIread_
(
T
&
data
,
uint8_t
reg
,
uint8_t
readlen
);
/*Selection Function Members*/
//Pull nCS low
void
select_
();
//Pull nCS high
void
deselect_
();
//Get nCS
unsigned
get_ncs_
();
/*Private Data Members*/
/*Private Data Members*/
const
unsigned
ncs_
;
const
unsigned
ncs_
;
const
SPISettings
*
spisettings_
;
const
SPISettings
*
spisettings_
;
...
...
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