This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

IO CAN documentation patch


Hi

This is I/O CAN documentation patch which adds information about
callback on event stuff.

regards
Alexey Shusharin
diff -bur /opt/ecos-repo/cvs/ecos/packages/io/can/current/ChangeLog ./io/can/current/ChangeLog
--- /opt/ecos-repo/cvs/ecos/packages/io/can/current/ChangeLog	2007-08-23 13:38:37.000000000 +0700
+++ ./io/can/current/ChangeLog	2007-08-23 13:34:28.000000000 +0700
@@ -1,3 +1,8 @@
+2007-08-23 Alexey Shusharin <mrfinch@mail.ru>
+	
+	* doc/can.sgml: Callback on event stuff documentation and some
+	  small fixes
+	
 2007-08-06 Alexey Shusharin <mrfinch@mail.ru>
            Andrew Lunn <andrew.lunn@ascom.ch>
 	
diff -bur /opt/ecos-repo/cvs/ecos/packages/io/can/current/doc/can.sgml ./io/can/current/doc/can.sgml
--- /opt/ecos-repo/cvs/ecos/packages/io/can/current/doc/can.sgml	2007-07-03 21:42:18.000000000 +0700
+++ ./io/can/current/doc/can.sgml	2007-08-23 13:51:54.000000000 +0700
@@ -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,68 @@
     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 callback on events</TITLE>
+
+<PARA>
+By default application can't get information about event arriving in RX buffer
+until it calls <function>cyg_io_read()</function>. Usually it leads application
+to use accessory thread to wait new CAN event.
+</PARA>
+
+<PARA>
+The CDL option <varname>CYGOPT_IO_CAN_SUPPORT_CALLBACK</varname>
+allows application to use a callback on event arriving. It's achieved by
+writing <structname>cyg_can_callback_cfg</structname> data structure to driver
+via the <function>cyg_io_set_config()</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_t);
+
+typedef struct cyg_can_callback_cfg_st
+{
+    cyg_can_event_cb_t callback_func;   // callback function
+    cyg_uint16  flag_mask;              // flags mask
+    cyg_addrword_t 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 of callback function. It will be called from DSR context so you should be
+careful to only call API functions that are safe in DSR context.
+Firts parameter is a combination of happened event flags. Second parameter is a user data.
+          </para></listitem>
+   </varlistentry>
+   <varlistentry>
+       <term><type>cyg_addrword_t</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 callback stuff set <varname>flag_mask</varname> = 0
+          </para></listitem>
+   </varlistentry>
+</variablelist>
+
+</SECTION> <!-- can-event-callback -->
+
 </SECTION>  
 </CHAPTER>
 
@@ -1541,6 +1604,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
+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.
diff -bur /opt/ecos-repo/cvs/ecos/packages/io/can/current/src/can.c ./io/can/current/src/can.c
--- /opt/ecos-repo/cvs/ecos/packages/io/can/current/src/can.c	2007-08-23 13:38:38.000000000 +0700
+++ ./io/can/current/src/can.c	2007-08-23 13:47:09.000000000 +0700
@@ -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:
              {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]