can_dev.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 by Ole Reinhardt <ole.reinhardt@kernelconcepts.de>,
00003  *                       Kernelconcepts http://www.kernelconcepts.de
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. Neither the name of the copyright holders nor the names of
00015  *    contributors may be used to endorse or promote products derived
00016  *    from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00019  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00021  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00022  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00023  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00024  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00025  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00026  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00027  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00028  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00029  * SUCH DAMAGE.
00030  *
00031  * For additional information see http://www.ethernut.de/
00032  *
00033  */
00034 
00043 /*
00044  * $Log: can_dev.c,v $
00045  * Revision 1.6  2007/09/08 03:01:11  hwmaier
00046  * Changes to support RX time-out, CAN_SetRxTimeout() added.
00047  *
00048  * Revision 1.5  2005/10/07 21:38:44  hwmaier
00049  * CAN_SetSpeed function added.
00050  *
00051  * Revision 1.4  2004/08/25 15:45:18  olereinhardt
00052  * Added function to set acceptance filter
00053  *
00054  * Revision 1.3  2004/08/02 09:56:13  olereinhardt
00055  * changed typing of CAN_TryRxFrame
00056  *
00057  * Revision 1.2  2004/06/23 10:17:04  olereinhardt
00058  * Added buffer monitoring functions (free / avail)
00059  *
00060  * Revision 1.1  2004/06/07 15:15:28  olereinhardt
00061  * Initial checkin
00062  *
00063  */
00064 
00069 
00070 
00071 /* Not ported. */
00072 #ifdef __GNUC__
00073 
00074 #include <stdio.h>
00075 #include <sys/timer.h>
00076 #include <sys/device.h>
00077 #include <dev/can_dev.h>
00078 
00079 
00080 u_char CAN_SetSpeed(NUTDEVICE *dev, u_long baudrate)
00081 {
00082     return (((IFCAN *)(dev->dev_icb))->can_set_baud)(dev, baudrate);
00083 }
00084 
00085 void CAN_SetFilter(NUTDEVICE *dev, u_char *ac, u_char *am)
00086 {
00087     (((IFCAN *)(dev->dev_icb))->can_set_ac)(dev, ac);
00088     (((IFCAN *)(dev->dev_icb))->can_set_am)(dev, am);
00089 }
00090 
00091 void CAN_TxFrame(NUTDEVICE *dev, CANFRAME *frame)
00092 {
00093     (((IFCAN *)(dev->dev_icb))->can_send)(dev, frame);
00094 }
00095 
00096 u_char CAN_TryTxFrame(NUTDEVICE *dev, CANFRAME *frame)
00097 {
00098     if (((IFCAN *)(dev->dev_icb))->can_txfree(dev)) {
00099         (((IFCAN *)(dev->dev_icb))->can_send)(dev, frame);
00100         return 0;
00101     }
00102     return 1;
00103 }
00104 
00105 u_char CAN_TxFree(NUTDEVICE *dev)
00106 {
00107     return ((IFCAN *)(dev->dev_icb))->can_txfree(dev);
00108 }
00109 
00110 u_char CAN_RxFrame(NUTDEVICE *dev, CANFRAME *frame)
00111 {
00112   return (((IFCAN *)(dev->dev_icb))->can_recv)(dev, frame);
00113 }
00114 
00115 u_char CAN_TryRxFrame(NUTDEVICE *dev, CANFRAME *frame)
00116 {
00117     if (((IFCAN *)(dev->dev_icb))->can_rxavail(dev)) {
00118         (((IFCAN *)(dev->dev_icb))->can_recv)(dev, frame);
00119         return 0;
00120     }
00121     return 1;
00122 }
00123 
00124 u_char CAN_RxAvail(NUTDEVICE *dev)
00125 {
00126     return ((IFCAN *)(dev->dev_icb))->can_rxavail(dev);
00127 }
00128 
00139 void CAN_SetRxTimeout(NUTDEVICE *dev, u_long timeout)
00140 {
00141     ((IFCAN *)(dev->dev_icb))->can_rtimeout = timeout;
00142 }
00143 
00144 
00145 #else
00146 
00147 void keep_icc_happy(void)
00148 {
00149 }
00150 
00151 #endif
00152 

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/