📄 io-can-runtime-cfg.html
字号:
<!-- Copyright (C) 2009 Free Software Foundation, Inc. -->
<!-- This material may be distributed only subject to the terms -->
<!-- and conditions set forth in the Open Publication License, v1.0 -->
<!-- or later (the latest version is presently available at -->
<!-- http://www.opencontent.org/openpub/). -->
<!-- Distribution of the work or derivative of the work in any -->
<!-- standard (paper) book form is prohibited unless prior -->
<!-- permission is obtained from the copyright holder. -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Runtime Configuration</TITLE
><meta name="MSSmartTagsPreventParsing" content="TRUE">
<META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="eCos Reference Manual"
HREF="ecos-ref.html"><LINK
REL="UP"
TITLE="CAN driver details"
HREF="io-can-driver-details.html"><LINK
REL="PREVIOUS"
TITLE="API Details"
HREF="io-can-api-details.html"><LINK
REL="NEXT"
TITLE="Configuration"
HREF="io-can-configuration.html"></HEAD
><BODY
CLASS="SECTION"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>eCos Reference Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="io-can-api-details.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 32. CAN driver details</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="io-can-configuration.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECTION"
><H1
CLASS="SECTION"
><A
NAME="IO-CAN-RUNTIME-CFG"
>Runtime Configuration</A
></H1
><P
>Runtime configuration is achieved by exchanging data structures with the
driver via the <CODE
CLASS="FUNCTION"
>cyg_io_set_config()</CODE
> and
<CODE
CLASS="FUNCTION"
>cyg_io_get_config()</CODE
> functions.</P
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN9228"
>Device configuration</A
></H2
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef struct cyg_can_info_st {
cyg_can_baud_rate_t baud;
} cyg_can_info_t;</PRE
></TD
></TR
></TABLE
><P
>Device configuration is achieved by by exchanging
<CODE
CLASS="STRUCTNAME"
>cyg_can_info_t</CODE
> data structures with the driver
via the <CODE
CLASS="FUNCTION"
>cyg_io_set_config()</CODE
> and
<CODE
CLASS="FUNCTION"
>cyg_io_get_config()</CODE
> functions using the config keys
<CODE
CLASS="VARNAME"
>CYG_IO_GET_CONFIG_CAN_INFO</CODE
> and
<CODE
CLASS="VARNAME"
>CYG_IO_SET_CONFIG_CAN_INFO</CODE
>.
The field <CODE
CLASS="STRUCTFIELD"
>baud</CODE
> contains a baud rate selection.
This must be one of the following values: </P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>CYGNUM_CAN_KBAUD_10
CYGNUM_CAN_KBAUD_20
CYGNUM_CAN_KBAUD_50
CYGNUM_CAN_KBAUD_100
CYGNUM_CAN_KBAUD_125
CYGNUM_CAN_KBAUD_250
CYGNUM_CAN_KBAUD_500
CYGNUM_CAN_KBAUD_800
CYGNUM_CAN_KBAUD_1000</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN9239"
>Timeout configuration</A
></H2
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef struct cyg_can_timeout_info_st
{
cyg_uint32 rx_timeout;
cyg_uint32 tx_timeout;
} cyg_can_timeout_info_t;</PRE
></TD
></TR
></TABLE
><P
>Timeout configuration is achieved by by exchanging
<CODE
CLASS="STRUCTNAME"
>cyg_can_timeout_info_t</CODE
> data structures with the
driver via the <CODE
CLASS="FUNCTION"
>cyg_io_set_config()</CODE
> and
<CODE
CLASS="FUNCTION"
>cyg_io_get_config()</CODE
> functions using the config keys
<CODE
CLASS="VARNAME"
>CYG_IO_SET_CONFIG_CAN_TIMEOUT</CODE
> and
<CODE
CLASS="VARNAME"
>CYG_IO_SET_CONFIG_CAN_TIMEOUT</CODE
>. </P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><SPAN
CLASS="TYPE"
>cyg_uint32</SPAN
> <CODE
CLASS="VARNAME"
>rx_timeout</CODE
></DT
><DD
><P
>Timeout for <CODE
CLASS="FUNCTION"
>cyg_io_read</CODE
> calls.
</P
></DD
><DT
><SPAN
CLASS="TYPE"
>cyg_uint32</SPAN
> <CODE
CLASS="VARNAME"
>tx_timeout</CODE
></DT
><DD
><P
>Timeout for <CODE
CLASS="FUNCTION"
>cyg_io_write</CODE
> calls.
</P
></DD
></DL
></DIV
><P
>Timeout runtime configuration is supported if the configuration options
<CODE
CLASS="VARNAME"
>CYGOPT_IO_CAN_SUPPORT_NONBLOCKING</CODE
>
and <CODE
CLASS="VARNAME"
>CYGOPT_IO_CAN_SUPPORT_TIMEOUTS</CODE
> are enabled. </P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN9266"
>Reading buffer configuration</A
></H2
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>
typedef struct cyg_can_buf_info_st
{
cyg_int32 rx_bufsize;
cyg_int32 rx_count;
cyg_int32 tx_bufsize;
cyg_int32 tx_count;
} cyg_can_buf_info_t;</PRE
></TD
></TR
></TABLE
><P
><CODE
CLASS="VARNAME"
>CYG_IO_GET_CONFIG_CAN_BUFFER_INFO</CODE
> - This function
retrieves the current state of the software buffers in the CAN drivers.
For the transmit buffer it returns the the total number of
<SPAN
CLASS="TYPE"
>cyg_can_message</SPAN
> objects in buffer and the current number of
<SPAN
CLASS="TYPE"
>cyg_can_message</SPAN
> objects occupied in the buffer.
For the receive buffer it returns the total number of
<SPAN
CLASS="TYPE"
>cyg_can_event</SPAN
> objects in receive buffer and the current
number of <SPAN
CLASS="TYPE"
>cyg_can_event</SPAN
> objects occupied in the buffer.
It does not take into account any buffering such as FIFOs or holding
registers that the CAN hardware device itself may have.</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><SPAN
CLASS="TYPE"
>cyg_uint32</SPAN
> <CODE
CLASS="VARNAME"
>rx_bufsize</CODE
></DT
><DD
><P
>Total number of <SPAN
CLASS="TYPE"
>cyg_can_event</SPAN
> buffers in receive queue.
</P
></DD
><DT
><SPAN
CLASS="TYPE"
>cyg_uint32</SPAN
> <CODE
CLASS="VARNAME"
>rx_count</CODE
></DT
><DD
><P
>Current number of <SPAN
CLASS="TYPE"
>cyg_can_event</SPAN
> buffers occupied in receive queue.
</P
></DD
><DT
><SPAN
CLASS="TYPE"
>cyg_uint32</SPAN
> <CODE
CLASS="VARNAME"
>tx_bufsize</CODE
></DT
><DD
><P
>Total number of <SPAN
CLASS="TYPE"
>cyg_can_message</SPAN
> buffers in transmit queue.
</P
></DD
><DT
><SPAN
CLASS="TYPE"
>cyg_uint32</SPAN
> <CODE
CLASS="VARNAME"
>rtx_count</CODE
></DT
><DD
><P
>Current number of <SPAN
CLASS="TYPE"
>cyg_can_message</SPAN
> buffers occupied in transmit queue.
</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN9304"
>Reading hardware description information</A
></H2
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>
typedef struct cyg_can_hdi_st
{
cyg_uint8 support_flags;
cyg_uint8 controller_type;
} cyg_can_hdi;</PRE
></TD
></TR
></TABLE
><P
><CODE
CLASS="VARNAME"
>CYG_IO_GET_CONFIG_CAN_HDI</CODE
> - This function retrieves
information about the used hardware. The Hardware Description Interface
provides a method to gather information about the CAN hardware and the
functionality of the driver. For this purpose the structure
<CODE
CLASS="STRUCTNAME"
>cyg_can_hdi</CODE
> is defined. </P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><SPAN
CLASS="TYPE"
>cyg_uint8</SPAN
> <CODE
CLASS="VARNAME"
>support_flags</CODE
></DT
><DD
><P
>Contains information about the capabilities of the used CAN hardware.
</P
></DD
><DT
><SPAN
CLASS="TYPE"
>cyg_uint8</SPAN
> <CODE
CLASS="VARNAME"
>controller_type</CODE
></DT
><DD
><P
>A number that identifies the CAN controller type.
</P
></DD
></DL
></DIV
><P
>The following flags are available in the field <CODE
CLASS="STRUCTFIELD"
>support_flags</CODE
>: </P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+-------+-------+-------+-------+-------+-------+-------+-------+
| res | res | res |timest.|SW-Filt|FullCAN| Frametype |</PRE
></TD
></TR
></TABLE
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><CODE
CLASS="PARAMETER"
>Frametype</CODE
></DT
><DD
><P
>Bit 0 and Bit 1 of the structure describe the possibilities of the CAN
controller. The following values are defined:
<TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>
CYGNUM_CAN_HDI_FRAMETYPE_STD // receives only standard frame
CYGNUM_CAN_HDI_FRAMETYPE_EXT_PASSIVE // can receive but not send extended frames
CYGNUM_CAN_HDI_FRAMETYPE_EXT_ACTIVE // can send and receive extended frames
</PRE
></TD
></TR
></TABLE
>
</P
></DD
><DT
><CODE
CLASS="PARAMETER"
>FullCAN</CODE
></DT
><DD
><P
>If the Bit 2 - <CODE
CLASS="VARNAME"
>CYGNUM_CAN_HDI_FULLCAN </CODE
> - is set to one,
the CAN controller supports more than one message buffer.
</P
></DD
><DT
><CODE
CLASS="PARAMETER"
>SW-Filter</CODE
></DT
><DD
><P
>If Bit 3 - <CODE
CLASS="VARNAME"
>CYGNUM_CAN_HDI_FILT_SW</CODE
> - is set to one then
the CAN driver supports some kind of software message filtering.
</P
></DD
><DT
><CODE
CLASS="PARAMETER"
>Timestamp</CODE
></DT
><DD
><P
>If Bit 4 - <CODE
CLASS="VARNAME"
>CYGNUM_CAN_HDI_TIMESTAMP</CODE
> - is set to one then
the CAN hardware supports timestamps for CAN messages
</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN9351"
>Reading hardware message buffer configuration</A
></H2
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -