Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
wr2rf-vme
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
wr2rf-vme
Commits
09bd1e8d
Commit
09bd1e8d
authored
May 10, 2023
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a function to get ocxo current
parent
ead60be5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
9 deletions
+37
-9
board.c
software/libwr2rf/board.c
+14
-0
board.h
software/libwr2rf/libwr2rf/board.h
+3
-0
wr2rf.c
software/libwr2rf/wr2rf.c
+20
-9
No files found.
software/libwr2rf/board.c
View file @
09bd1e8d
...
...
@@ -377,6 +377,20 @@ int libwr2rf_enable_check_ocxo(struct libwr2rf_dev *dev)
return
warmup_time
-
v
;
}
/* Read ocxo current sensor, return the current in mA. */
int
libwr2rf_get_ocxo_current_ma
(
struct
libwr2rf_dev
*
dev
)
{
unsigned
addr
=
WR2RF_VME_REGS_INIT
+
WR2RF_INIT_REGS_XADC
;
unsigned
val
=
libwr2rf_read16
(
dev
,
addr
+
(
0x12
<<
1
));
/* See EDA-04387-V2 Sheet 24 (p43) Power for OCXO */
/* V= 40 * 0.05 Ohm * ocxo_cur */
double
v
=
(
val
>>
4
)
/
4096
.
0
;
return
(
v
/
2
.
0
)
*
1000
;
}
int
libwr2rf_check_link_time
(
struct
libwr2rf_dev
*
dev
)
{
unsigned
status
;
...
...
software/libwr2rf/libwr2rf/board.h
View file @
09bd1e8d
...
...
@@ -3,6 +3,9 @@
#include "io.h"
/* For ocxo */
int
libwr2rf_get_ocxo_current_ma
(
struct
libwr2rf_dev
*
dev
);
/* For the main pll (ltc6950). */
void
libwr2rf_pll_spi_init
(
struct
libwr2rf_dev
*
dev
);
uint8_t
libwr2rf_pll_read
(
struct
libwr2rf_dev
*
dev
,
unsigned
reg
);
...
...
software/libwr2rf/wr2rf.c
View file @
09bd1e8d
...
...
@@ -1329,6 +1329,8 @@ ocxo (struct libwr2rf_dev *dev, int argc, char **argv)
printf
(
"ocxo status: 0x%04x
\n
"
,
v
);
v
=
libwr2rf_read16
(
dev
,
WR2RF_VME_REGS_INIT
+
WR2RF_INIT_REGS_OCXO_UPTIME
);
printf
(
"ocxo uptime: 0x%04x (%u)
\n
"
,
v
,
v
);
v
=
libwr2rf_get_ocxo_current_ma
(
dev
);
printf
(
"ocxo current: %u mA
\n
"
,
v
);
}
else
if
(
argc
==
2
&&
strcmp
(
argv
[
1
],
"off"
)
==
0
)
{
libwr2rf_write16
(
dev
,
WR2RF_VME_REGS_INIT
+
WR2RF_INIT_REGS_OCXO_CTRL
,
0
);
...
...
@@ -1345,7 +1347,7 @@ ocxo (struct libwr2rf_dev *dev, int argc, char **argv)
#define XADC_FLAG_TEMP 1
/* Value is a temperature */
#define XADC_FLAG_POWR 2
/* Value is a voltage (unipolar) */
#define XADC_FLAG_OCXO_SENSE 3
/* ocxo current */
struct
xadc_regs_desc
{
const
char
*
name
;
unsigned
flag
;
...
...
@@ -1375,14 +1377,14 @@ static const struct xadc_regs_desc xadc_regs[] =
{
NULL
,
0
},
/* 0x10 */
{
"vaux0"
,
0
},
{
"vaux1"
,
0
},
{
"vaux2"
,
0
},
{
"vaux3"
,
0
},
{
"vaux4"
,
0
},
{
"vaux5"
,
0
},
{
"vaux6"
,
0
},
{
"vaux7"
,
0
},
{
NULL
,
0
},
{
NULL
,
0
},
{
"vaux2"
,
XADC_FLAG_OCXO_SENSE
},
{
NULL
,
0
},
{
NULL
,
0
},
{
NULL
,
0
},
{
NULL
,
0
},
{
NULL
,
0
},
/* 0x18 */
{
NULL
,
0
},
...
...
@@ -1498,6 +1500,15 @@ xadc_dump (struct libwr2rf_dev *dev, int argc, char **argv)
/* See ug480 eq 2-7 p 26 */
printf
(
" %1.02f V"
,
(
val
>>
4
)
/
4096
.
0
*
3
.
0
);
break
;
case
XADC_FLAG_OCXO_SENSE
:
/* See EDA-04387-V2 Sheet 24 (p43) Power for OCXO */
/* V= 40 * 0.05 Ohm * ocxo_cur */
{
double
v
=
(
val
>>
4
)
/
4096
.
0
;
double
a
=
v
/
2
.
0
;
printf
(
" %1.03f V -> %1.03f A"
,
v
,
a
);
}
break
;
default:
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment