Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Schedules
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
Software for White Rabbit PTP Core
Commits
f5524687
Commit
f5524687
authored
Aug 30, 2019
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ertm14: initial version of netconsole daemon, snmp in progress...
parent
cdf26ce1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
151 additions
and
13 deletions
+151
-13
ertm14.c
ertm14.c
+101
-0
cmd_ertm14.c
shell/cmd_ertm14.c
+50
-13
No files found.
ertm14.c
View file @
f5524687
...
...
@@ -36,6 +36,17 @@
#include "dev/i2c.h"
#include "softpll_ng.h"
#include "endpoint.h"
#include "console.h"
#include "wrc-task.h"
#define ERTM14_IUART_MAX_PAYLOAD 100
#define ERTM14_IUART_MSG_MMC_UPDATE 0
#define ERTM14_IUART_MSG_IPMI_CONSOLE_REQ 2
#define ERTM14_IUART_MSG_IPMI_SNMP_REQ 3
#define ERTM14_IUART_MSG_IPMI_CONSOLE_RESP 4
#define ERTM14_IUART_MSG_IPMI_SNMP_RESP 5
struct
ertm14_board
board
;
static
struct
ertm14_board_config
ertm14_configs
[
ERTM14_MAX_CONFIGS
];
...
...
@@ -235,13 +246,65 @@ void ertm14_dds_sync_test()
}
}
extern
struct
console_device
console_ipmi_dev
;
static
void
handle_iuart_request
(
uint8_t
*
buf
,
int
size
)
{
uint8_t
tx_buf
[
ERTM14_IUART_MAX_PAYLOAD
];
int
n_tx
;
int
type
=
buf
[
0
];
if
(
size
<=
0
)
return
;
switch
(
type
)
{
case
ERTM14_IUART_MSG_IPMI_CONSOLE_REQ
:
n_tx
=
console_ipmi_process_request
(
&
console_ipmi_dev
,
buf
+
1
,
size
-
1
,
tx_buf
+
1
,
sizeof
(
tx_buf
)
-
1
);
tx_buf
[
0
]
=
ERTM14_IUART_MSG_IPMI_CONSOLE_RESP
;
iuart_send_message
(
&
board
.
iuart_14
,
tx_buf
,
n_tx
+
1
);
break
;
case
ERTM14_IUART_MSG_IPMI_SNMP_REQ
:
//snmp_respond(uint8_t *buf);
break
;
default:
return
;
}
}
static
void
iuart_14_poll
()
{
int
n
=
0
;
int
msg
=
iuart_recv_message
(
&
board
.
iuart_14
);
if
(
msg
<=
0
)
return
;
if
(
msg
==
START_INSN_CHAR_VAL
)
{
//pp_printf("req %d %d %d\n",board.iuart_14.rx_buf, board.iuart_14.rx_csize, board.iuart_14.rx_csize );
handle_iuart_request
(
board
.
iuart_14
.
rx_buf
,
board
.
iuart_14
.
rx_csize
);
}
}
void
ertm14_init
(
void
)
{
int
i
;
uint32_t
id
;
ertm14_config_init
();
wb_gpio_create
(
&
board
.
gpio_aux
,
BASE_AUXWB
);
gen_gpio_set_dir
(
&
pin_main_xo_en_n
,
1
);
...
...
@@ -386,9 +449,47 @@ void ertm14_init(void)
ad9520_init
(
&
board
.
dev_clkb_distr
,
&
board
.
i2c_clkb_distr
,
0x5c
);
// ertm14_dds_sync_test();
pp_printf
(
"Init IUART14
\n
"
);
iuart_init_bare
(
&
board
.
iuart_14
,
BASE_IUART_14
,
115200
);
pp_printf
(
"Task!
\n
"
);
wrc_task_create
(
"iuart14"
,
NULL
,
iuart_14_poll
);
}
void
ertm14_config_init
()
{
int
i
,
j
;
for
(
i
=
0
;
i
<
ERTM14_MAX_CONFIGS
;
i
++
)
{
struct
ertm14_board_config
*
cfg
=
&
ertm14_configs
[
i
];
cfg
->
valid
=
1
;
cfg
->
lo
.
freq_hz
=
100000000
;
cfg
->
ref
.
freq_hz
=
100000000
;
cfg
->
lo
.
ampl_factor
=
50
;
cfg
->
ref
.
ampl_factor
=
50
;
for
(
j
=
0
;
j
<=
ERTM14_RF_OUT_MAX_ID
;
j
++
)
{
cfg
->
ref
.
out_state
[
j
]
=
ERTM15_RF_OUT_MONITOR
;
cfg
->
lo
.
out_state
[
j
]
=
ERTM15_RF_OUT_MONITOR
;
}
for
(
j
=
0
;
j
<
ERTM14_CLKAB_OUT_MAX_ID
;
j
++
)
{
cfg
->
clka_freq_hz
[
j
]
=
100000000
;
cfg
->
clkb_freq_hz
[
j
]
=
100000000
;
}
cfg
->
clka_enable_mask
=
0
;
cfg
->
clkb_enable_mask
=
0
;
}
};
struct
ertm14_board_config
*
ertm14_get_config
(
int
config_id
)
{
return
&
ertm14_configs
[
config_id
];
...
...
shell/cmd_ertm14.c
View file @
f5524687
...
...
@@ -21,7 +21,7 @@ extern struct wb_clock_monitor_device ertm14_cmon;
const
char
*
clock_names
[]
=
{
"clk_dmtd"
,
"clk_sys"
,
"clk_tx1"
,
"clk_tx2"
,
"clk_rx"
};
static
int
selected_config
=
0
;
static
const
char
*
get_rf_out_state_string
(
int
state
)
{
...
...
@@ -38,12 +38,12 @@ static const char *get_rf_out_state_string(int state)
static
void
dump_dds_state
(
const
char
*
name
,
struct
ertm14_dds_config
*
cfg
)
{
int
i
;
pp_printf
(
"%s DDS frequency: %-9d Hz
\n
"
,
name
,
cfg
->
freq_hz
);
pp_printf
(
"%s DDS frequency: %-
0
9d Hz
\n
"
,
name
,
cfg
->
freq_hz
);
pp_printf
(
"%s DDS amplitude factor: %d
\n
"
,
name
,
cfg
->
ampl_factor
);
pp_printf
(
"%s DDS measured power: %d.%-0
3
d dBm
\n
"
,
name
,
cfg
->
amp_power
/
1000
,
cfg
->
amp_power
%
1000
);
pp_printf
(
"%s outputs:
"
,
name
);
pp_printf
(
"%s DDS measured power: %d.%-0
2
d dBm
\n
"
,
name
,
cfg
->
amp_power
/
1000
,
cfg
->
amp_power
%
1000
);
pp_printf
(
"%s outputs:
\n
"
,
name
);
for
(
i
=
ERTM14_RF_OUT_MIN_ID
;
i
<=
ERTM14_RF_OUT_MAX_ID
;
i
++
)
pp_printf
(
"- %s%d: %-08s (last measured power = %d.%-0
3
d dBm)
\n
"
,
name
,
i
,
get_rf_out_state_string
(
cfg
->
out_state
[
i
]
),
pp_printf
(
"- %s%d: %-08s (last measured power = %d.%-0
2
d dBm)
\n
"
,
name
,
i
,
get_rf_out_state_string
(
cfg
->
out_state
[
i
]
),
cfg
->
out_power
[
i
]
/
1000
,
cfg
->
out_power
[
i
]
%
1000
);
}
...
...
@@ -62,12 +62,43 @@ static void dump_config( int id, struct ertm14_board_config *cfg )
if
(
ertm14_get_current_config_id
()
==
id
)
{
pp_printf
(
"ACTIVE
\n
"
);
return
;
}
else
{
pp_printf
(
"
\n
"
);
}
dump_dds_state
(
"LO"
,
&
cfg
->
lo
);
dump_dds_state
(
"REF"
,
&
cfg
->
ref
);
}
#define PARAM_FREQ 0
#define PARAM_AMPL 1
static
void
set_clock_param
(
int
param
,
const
char
*
name
,
const
char
*
value
)
{
if
(
!
name
||
!
value
)
{
pp_printf
(
"Too few arguments.
\n
"
);
return
;
}
int
is_lo
=
!
strcasecmp
(
name
,
"lo"
);
int
is_ref
=
!
strcasecmp
(
name
,
"ref"
);
struct
ertm14_board_config
*
cfg
=
ertm14_get_config
(
selected_config
);
cfg
->
valid
=
1
;
if
(
is_lo
||
is_ref
)
{
struct
ertm14_dds_config
*
dcfg
=
is_lo
?
&
cfg
->
lo
:
&
cfg
->
ref
;
switch
(
param
)
{
case
PARAM_AMPL
:
dcfg
->
ampl_factor
=
atoi
(
value
);
break
;
case
PARAM_FREQ
:
dcfg
->
freq_hz
=
atoi
(
value
);
break
;
default:
break
;
}
}
}
static
int
cmd_ertm
(
const
char
*
args
[])
...
...
@@ -92,12 +123,18 @@ static int cmd_ertm(const char *args[])
for
(
i
=
0
;
i
<
ERTM14_MAX_CONFIGS
;
i
++
)
dump_config
(
i
,
ertm14_get_config
(
i
)
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"freq"
))
{
}
else
if
(
!
strcasecmp
(
args
[
0
],
"rf-distr"
))
{
}
else
if
(
!
strcasecmp
(
args
[
0
],
"clk-distr"
))
{
}
else
if
(
!
strcasecmp
(
args
[
0
],
"select-config"
))
{
if
(
args
[
1
])
selected_config
=
atoi
(
args
[
1
]
);
pp_printf
(
"Selected configuration: %d
\n
"
,
selected_config
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"set-freq"
))
{
set_clock_param
(
PARAM_FREQ
,
args
[
1
],
args
[
2
]);
dump_config
(
selected_config
,
ertm14_get_config
(
selected_config
)
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"set-ampl"
))
{
set_clock_param
(
PARAM_AMPL
,
args
[
1
],
args
[
2
]);
dump_config
(
selected_config
,
ertm14_get_config
(
selected_config
)
);
}
}
...
...
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