include/AT91/can_AT91.h
changeset 521 731bbe1b67b4
equal deleted inserted replaced
520:cc993e72b7e6 521:731bbe1b67b4
       
     1 /*
       
     2 This file is part of CanFestival, a library implementing CanOpen Stack.
       
     3 
       
     4 Copyright (C): Edouard TISSERANT and Francis DUPIN
       
     5 AT91 Port: Peter CHRISTEN
       
     6 
       
     7 See COPYING file for copyrights details.
       
     8 
       
     9 This library is free software; you can redistribute it and/or
       
    10 modify it under the terms of the GNU Lesser General Public
       
    11 License as published by the Free Software Foundation; either
       
    12 version 2.1 of the License, or (at your option) any later version.
       
    13 
       
    14 This library is distributed in the hope that it will be useful,
       
    15 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    17 Lesser General Public License for more details.
       
    18 
       
    19 You should have received a copy of the GNU Lesser General Public
       
    20 License along with this library; if not, write to the Free Software
       
    21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    22 */
       
    23 
       
    24 #ifndef __CAN_AT91__
       
    25 #define __CAN_AT91__
       
    26 
       
    27 #include "config.h"
       
    28 
       
    29 // Canfestivals includes
       
    30 #include "can.h"
       
    31 
       
    32 // Number of receive MB
       
    33 #define NB_MB				8
       
    34 #define NB_RX_MB			4
       
    35 // Number of transmit MB
       
    36 #define NB_TX_MB			(NB_MB - NB_RX_MB)
       
    37 
       
    38 #if (NB_TX_MB < 1)
       
    39 #error define less RX MBs, you must have at least 1 TX MB!
       
    40 #elif (NB_RX_MB < 1)
       
    41 #error define at least 1 RX MBs!
       
    42 #endif
       
    43 
       
    44 #define START_TX_MB			NB_RX_MB
       
    45 #define TX_INT_MSK			((0xFF << (NB_MB - NB_TX_MB)) & 0xFF)
       
    46 #define RX_INT_MSK			(0xFF >> (NB_MB - NB_RX_MB))
       
    47 
       
    48 /************************* To be called by user app ***************************/
       
    49 
       
    50 unsigned char canInit(unsigned int bitrate);
       
    51 unsigned char canSend(CAN_PORT notused, Message *m);
       
    52 unsigned char canReceive(Message *m);
       
    53 #endif