Skip to content

Commit a85121b

Browse files
matiamicxiaoxiang781216
authored andcommitted
netutils: Add plcatool
Add plcatool - simple tool for managing PLCA configuration in 10BASE-T1S PHYs. Signed-off-by: michal matias <[email protected]>
1 parent 479d206 commit a85121b

File tree

6 files changed

+900
-0
lines changed

6 files changed

+900
-0
lines changed

netutils/plcatool/CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ##############################################################################
2+
# apps/netutils/plcatool/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_NETUTILS_PLCATOOL)
24+
nuttx_add_application(
25+
NAME
26+
plcatool
27+
STACKSIZE
28+
${CONFIG_DEFAULT_TASK_STACKSIZE}
29+
MODULE
30+
${CONFIG_NETUTILS_PLCATOOL}
31+
SRCS
32+
plcatool.c)
33+
endif()

netutils/plcatool/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config NETUTILS_PLCATOOL
7+
bool "plcatool support"
8+
default n
9+
---help---
10+
Build in support for the plcatool command. This command allows configuring
11+
the PLCA access method in 10BASE-T1S network adapters supporting PLCA.
12+
Syntax of the plcatool is inspired by the corresponding syntax used by the ethtool.

netutils/plcatool/Make.defs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/netutils/plcatool/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_NETUTILS_PLCATOOL),)
24+
CONFIGURED_APPS += $(APPDIR)/netutils/plcatool
25+
endif

netutils/plcatool/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
############################################################################
2+
# apps/netutils/plcatool/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
MAINSRC = plcatool.c
26+
27+
PROGNAME = plcatool
28+
PRIORITY = SCHED_PRIORITY_DEFAULT
29+
STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE)
30+
MODULE = $(CONFIG_NETUTILS_PLCATOOL)
31+
32+
include $(APPDIR)/Application.mk

netutils/plcatool/oa_tc14.h

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/****************************************************************************
2+
* apps/netutils/plcatool/oa_tc14.h
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed to the Apache Software Foundation (ASF) under one or more
7+
* contributor license agreements. See the NOTICE file distributed with
8+
* this work for additional information regarding copyright ownership. The
9+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
* "License"); you may not use this file except in compliance with the
11+
* License. You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
* License for the specific language governing permissions and limitations
19+
* under the License.
20+
*
21+
****************************************************************************/
22+
23+
#ifndef __APPS_NETUTILS_PLCATOOL_OA_TC14_H
24+
#define __APPS_NETUTILS_PLCATOOL_OA_TC14_H
25+
26+
/****************************************************************************
27+
* Included Files
28+
****************************************************************************/
29+
30+
#include <nuttx/bits.h>
31+
32+
/****************************************************************************
33+
* Pre-processor Definitions
34+
****************************************************************************/
35+
36+
#define OA_TC14_PLCA_MMD 31
37+
38+
#define OA_TC14_IDVER_ADDR 0xCA00
39+
#define OA_TC14_IDVER_IDM_MASK GENMASK(15, 8)
40+
#define OA_TC14_IDVER_IDM_POS 8
41+
#define OA_TC14_IDVER_VER_MASK GENMASK(7, 0)
42+
#define OA_TC14_IDVER_VER_POS 0
43+
#define OA_TC14_IDVER_VAL 0x0A10
44+
45+
#define OA_TC14_CTRL0_ADDR 0xCA01
46+
#define OA_TC14_CTRL0_EN_MASK BIT(15)
47+
#define OA_TC14_CTRL0_EN_POS 15
48+
#define OA_TC14_CTRL0_RST_MASK BIT(14)
49+
#define OA_TC14_CTRL0_RST_POS 14
50+
51+
#define OA_TC14_CTRL1_ADDR 0xCA02
52+
#define OA_TC14_CTRL1_NCNT_MASK GENMASK(15, 8)
53+
#define OA_TC14_CTRL1_NCNT_POS 8
54+
#define OA_TC14_CTRL1_ID_MASK GENMASK(7, 0)
55+
#define OA_TC14_CTRL1_ID_POS 0
56+
57+
#define OA_TC14_STATUS_ADDR 0xCA03
58+
#define OA_TC14_STATUS_PST_MASK BIT(15)
59+
#define OA_TC14_STATUS_PST_POS 15
60+
61+
#define OA_TC14_TOTMR_ADDR 0xCA04
62+
#define OA_TC14_TOTMR_TOT_MASK GENMASK(7, 0)
63+
#define OA_TC14_TOTMR_TOT_POS 0
64+
65+
#define OA_TC14_BURST_ADDR 0xCA05
66+
#define OA_TC14_BURST_MAXBC_MASK GENMASK(15, 8)
67+
#define OA_TC14_BURST_MAXBC_POS 8
68+
#define OA_TC14_BURST_BTMR_MASK GENMASK(7, 0)
69+
#define OA_TC14_BURST_BTMR_POS 0
70+
71+
#define OA_TC14_DIAG_ADDR 0xCA06
72+
#define OA_TC14_DIAG_RXINTO_MASK BIT(2)
73+
#define OA_TC14_DIAG_RXINTO_POS 2
74+
#define OA_TC14_DIAG_UNEXPB_MASK BIT(1)
75+
#define OA_TC14_DIAG_UNEXPB_POS 1
76+
#define OA_TC14_DIAG_BCNBFTO_MASK BIT(0)
77+
#define OA_TC14_DIAG_BCNBFTO_POS 0
78+
79+
#define oa_tc14_get_field(r, fieldname) \
80+
(((r) & OA_TC14_##fieldname##_MASK) >> OA_TC14_##fieldname##_POS)
81+
82+
#define oa_tc14_field(val, fieldname) \
83+
((val << OA_TC14_##fieldname##_POS) & OA_TC14_##fieldname##_MASK)
84+
85+
#endif /* __APPS_NETUTILS_PLCATOOL_OA_TC14_H */

0 commit comments

Comments
 (0)