forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This contains accessor macros for getting the maximum bitrate supported by a CAN controller/transceiver combination. Signed-off-by: Henrik Brix Andersen <[email protected]>
- Loading branch information
1 parent
71c3e4c
commit 5e8399f
Showing
9 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2020 Vestas Wind Systems A/S | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: Test CAN controller node | ||
|
||
compatible: "vnd,can-controller" | ||
|
||
include: can-controller.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2020 Vestas Wind Systems A/S | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: Test CAN transceiver node | ||
|
||
compatible: "vnd,can-transceiver" | ||
|
||
include: can-transceiver.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* @file | ||
* @brief CAN devicetree macro public API header file. | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2022 Vestas Wind Systems A/S | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_INCLUDE_DEVICETREE_CAN_H_ | ||
#define ZEPHYR_INCLUDE_DEVICETREE_CAN_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @defgroup devicetree-can Devicetree CAN API | ||
* @ingroup devicetree | ||
* @{ | ||
*/ | ||
|
||
/** | ||
* @brief Get the maximum transceiver bitrate for a CAN controller | ||
* | ||
* The bitrate will be limited to the maximum bitrate supported by the CAN | ||
* controller. If no CAN transceiver is present in the devicetree, the maximum | ||
* bitrate will be that of the CAN controller. | ||
* | ||
* Example devicetree fragment: | ||
* | ||
* transceiver0: can-phy0 { | ||
* compatible = "vnd,can-transceiver"; | ||
* max-bitrate = <1000000>; | ||
* #phy-cells = <0>; | ||
* }; | ||
* | ||
* can0: can@... { | ||
* compatible = "vnd,can-controller"; | ||
* phys = <&transceiver0>; | ||
* }; | ||
* | ||
* can1: can@... { | ||
* compatible = "vnd,can-controller"; | ||
* | ||
* can-transceiver { | ||
* max-bitrate = <2000000>; | ||
* }; | ||
* }; | ||
* | ||
* Example usage: | ||
* | ||
* DT_CAN_TRANSCEIVER_MAX_BITRATE(DT_NODELABEL(can0), 5000000) // 1000000 | ||
* DT_CAN_TRANSCEIVER_MAX_BITRATE(DT_NODELABEL(can1), 5000000) // 2000000 | ||
* DT_CAN_TRANSCEIVER_MAX_BITRATE(DT_NODELABEL(can1), 1000000) // 1000000 | ||
* | ||
* @param node_id node identifier | ||
* @param max maximum bitrate supported by the CAN controller | ||
* @return the maximum bitrate supported by the CAN controller/transceiver combination | ||
*/ | ||
#define DT_CAN_TRANSCEIVER_MAX_BITRATE(node_id, max) \ | ||
COND_CODE_1(DT_NODE_HAS_PROP(node_id, phys), \ | ||
MIN(DT_PROP(DT_PHANDLE(node_id, phys), max_bitrate), max), \ | ||
MIN(DT_PROP_OR(DT_CHILD(node_id, can_transceiver), max_bitrate, max), max)) | ||
|
||
/** | ||
* @brief Get the maximum transceiver bitrate for a DT_DRV_COMPAT CAN controller | ||
* @param inst DT_DRV_COMPAT instance number | ||
* @param max maximum bitrate supported by the CAN controller | ||
* @return the maximum bitrate supported by the CAN controller/transceiver combination | ||
* @see DT_CAN_TRANSCEIVER_MAX_BITRATE() | ||
*/ | ||
#define DT_INST_CAN_TRANSCEIVER_MAX_BITRATE(inst, max) \ | ||
DT_CAN_TRANSCEIVER_MAX_BITRATE(DT_DRV_INST(inst), max) | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* ZEPHYR_INCLUDE_DEVICETREE_CAN_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters