This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Re: IO CAN documentation patch
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Alexey Shusharin <mrfinch at mail dot ru>
- Cc: ecos-patches at sourceware dot org
- Date: Fri, 24 Aug 2007 15:42:43 +0200
- Subject: Re: IO CAN documentation patch
- References: <1187852358.4976.4.camel@killix>
On Thu, Aug 23, 2007 at 01:59:18PM +0700, Alexey Shusharin wrote:
> Hi
>
> This is I/O CAN documentation patch which adds information about
> callback on event stuff.
Thanks for the patch. I changed the English usage a little. The patch
attached also contains the CYG_ADDRWORD change.
Andrewy
Index: io/can/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/can/current/ChangeLog,v
retrieving revision 1.11
diff -u -w -r1.11 ChangeLog
--- io/can/current/ChangeLog 13 Aug 2007 07:36:34 -0000 1.11
+++ io/can/current/ChangeLog 24 Aug 2007 13:41:03 -0000
@@ -1,3 +1,10 @@
+2007-08-23 Alexey Shusharin <mrfinch@mail.ru>
+
+ * doc/can.sgml: Callback on event documentation.
+ * src/can.c: Change one wakeup to callback in a comment.
+ * include/canio.h: changed cyg_addrword_t to CYG_ADDRWORD so
+ can will compile without the kernel.
+
2007-08-06 Alexey Shusharin <mrfinch@mail.ru>
Andrew Lunn <andrew.lunn@ascom.ch>
Index: io/can/current/doc/can.sgml
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/can/current/doc/can.sgml,v
retrieving revision 1.3
diff -u -w -r1.3 can.sgml
--- io/can/current/doc/can.sgml 3 Jul 2007 14:42:18 -0000 1.3
+++ io/can/current/doc/can.sgml 24 Aug 2007 13:41:04 -0000
@@ -569,7 +569,7 @@
CYGNUM_CAN_EVENT_LEAVING_STANDBY = 0x0200, // CAN hardware leaves standby
CYGNUM_CAN_EVENT_ENTERING_STANDBY = 0x0400, // CAN hardware enters standby
CYGNUM_CAN_EVENT_ARBITRATION_LOST = 0x0800, // arbitration lost
- CYGNUM_CAN_EVENT_DEVICE_CHANGED = 0x1000, // device changed event
+ CYGNUM_CAN_EVENT_FILTER_ERR = 0x1000, // CAN message filter / acceptance filter error
CYGNUM_CAN_EVENT_PHY_FAULT = 0x2000, // General failure of physical layer
CYGNUM_CAN_EVENT_PHY_H = 0x4000, // Fault on CAN-H (Low Speed CAN)
CYGNUM_CAN_EVENT_PHY_L = 0x8000, // Fault on CAN-L (Low Speed CAN)
@@ -692,6 +692,8 @@
CYG_IO_SET_CONFIG_CAN_TIMEOUT
CYG_IO_SET_CONFIG_CAN_MSGBUF
CYG_IO_SET_CONFIG_CAN_MODE
+CYG_IO_SET_CONFIG_CAN_ABORT
+CYG_IO_SET_CONFIG_CAN_CALLBACK
</PROGRAMLISTING>
</SECTION><!-- can-cyg-io-set-config -->
</SECTION><!-- io-can-api-details -->
@@ -1495,7 +1497,73 @@
CYG_TEST_FAIL_FINISH("Error writing config of /dev/can0");
}
</PROGRAMLISTING>
-</SECTION> <!-- can-msgfilt-cfg -->
+</SECTION> <!-- can-msgfilt-deact -->
+
+<SECTION id="can-event-callback">
+<TITLE>Configuring a callback on events</TITLE>
+
+<PARA>
+By default application cannot get information about an event arriving
+in the RX buffer until it calls
+the <function>cyg_io_read()</function>. Usually this leads applications
+to use accessory threads to wait for new CAN events.
+</PARA>
+
+<PARA>
+The CDL option <varname>CYGOPT_IO_CAN_SUPPORT_CALLBACK</varname>
+allows application to use a callback on event arrival. It is
+configured by passing a <structname>cyg_can_callback_cfg</structname>
+data structure to the driver via
+the <function>cyg_io_set_config()</function> function using the config
+key
+<varname>CYG_IO_SET_CONFIG_CAN_CALLBACK</varname>.
+</PARA>
+
+<PROGRAMLISTING>
+CYG_IO_SET_CONFIG_CAN_CALLBACK
+</PROGRAMLISTING>
+
+<PROGRAMLISTING>
+typedef void (*cyg_can_event_cb_t)(cyg_uint16, CYG_ADDRWORD);
+
+typedef struct cyg_can_callback_cfg_st
+{
+ cyg_can_event_cb_t callback_func; // callback function
+ cyg_uint16 flag_mask; // flags mask
+ CYG_ADDRWORD data; // data passed to callback
+} cyg_can_callback_cfg;
+</PROGRAMLISTING>
+
+<variablelist>
+ <varlistentry>
+ <term><type>cyg_can_event_cb_t</type> <varname>callback_func</varname></term>
+ <listitem><para>
+Pointer to the callback function. The function will be called from DSR context so
+you should be careful to only call API functions that are safe in DSR
+context. The First parameter is a combination of event flags for events that have
+occurred. Second parameter is a user defined data pointer or value.
+ </para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><type>CYG_ADDRWORD</type> <varname>data</varname></term>
+ <listitem><para>
+Additional user data that will be passed to callback function as a second parameter.
+ </para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><type>cyg_uint16</type> <varname>flag_mask</varname></term>
+ <listitem><para>
+Should be set with a combination
+of <varname>CYGNUM_CAN_EVENT_*</varname> flags. If one of these
+events happens, the callback function will be called, with the
+actually event flags passed as a parameter. To disable the callback
+function from being called set <varname>flag_mask</varname> to 0.
+ </para></listitem>
+ </varlistentry>
+</variablelist>
+
+</SECTION> <!-- can-event-callback -->
+
</SECTION>
</CHAPTER>
@@ -1541,6 +1609,16 @@
</para></listitem>
</varlistentry>
<varlistentry>
+ <term><type>cdl_option CYGOPT_IO_CAN_SUPPORT_CALLBACK</type></term>
+ <listitem>
+<para>
+This option enables extra code in the generic CAN driver which allows
+an application to register a callback for events. The callback function
+is called from DSR context so you should be careful to only call API
+functions that are safe in DSR context.
+</para></listitem>
+ </varlistentry>
+ <varlistentry>
<term><type>cdl_option CYGNUM_IO_CAN_DEFAULT_TIMEOUT_READ</type></term>
<listitem><para>
The initial timeout value in clock ticks for <FUNCTION>cyg_io_read()</FUNCTION> calls.
Index: io/can/current/include/canio.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/can/current/include/canio.h,v
retrieving revision 1.7
diff -u -w -r1.7 canio.h
--- io/can/current/include/canio.h 13 Aug 2007 07:36:34 -0000 1.7
+++ io/can/current/include/canio.h 24 Aug 2007 13:41:04 -0000
@@ -331,7 +331,7 @@
// Callback configuration structure.
//
-typedef void (*cyg_can_event_cb_t)(cyg_uint16, cyg_addrword_t);
+typedef void (*cyg_can_event_cb_t)(cyg_uint16, CYG_ADDRWORD);
//
// flag_mask should be set with a combination of CYGNUM_CAN_EVENT_* flags.
// If one of these events happens, the callback function will be called,
@@ -341,7 +341,7 @@
{
cyg_can_event_cb_t callback_func; // callback function
cyg_uint16 flag_mask; // flags mask
- cyg_addrword_t data; // data passed to callback
+ CYG_ADDRWORD data; // data passed to callback
} cyg_can_callback_cfg;
Index: io/can/current/src/can.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/can/current/src/can.c,v
retrieving revision 1.5
diff -u -w -r1.5 can.c
--- io/can/current/src/can.c 13 Aug 2007 07:36:34 -0000 1.5
+++ io/can/current/src/can.c 24 Aug 2007 13:41:05 -0000
@@ -668,8 +668,8 @@
#ifdef CYGOPT_IO_CAN_SUPPORT_CALLBACK
//
- // Set waking calls configuration
- // To disable waking calls set waking_mask = 0
+ // Set callback configuration
+ // To disable callback set flag_mask = 0
//
case CYG_IO_SET_CONFIG_CAN_CALLBACK:
{