Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:52

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  * RTEMS generic MPC5200 BSP
0005  *
0006  * This file has to be included by application when using mscan.
0007  */
0008 
0009 /*
0010  * Copyright (c) 2005 embedded brains GmbH & Co. KG
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0031  * POSSIBILITY OF SUCH DAMAGE.
0032  */
0033 
0034 #ifndef __MSCAN_H__
0035 #define __MSCAN_H__
0036 
0037 #ifdef __cplusplus
0038 extern "C" {
0039 #endif
0040 
0041 #define MSCAN_A_DEV_NAME         "/dev/mscana"
0042 #define MSCAN_B_DEV_NAME         "/dev/mscanb"
0043 #define MSCAN_0_DEV_NAME         "/dev/mscan0"
0044 #define MSCAN_1_DEV_NAME         "/dev/mscan1"
0045 #define MSCAN_A                  0
0046 #define MSCAN_B                  1
0047 
0048 #define MSCAN_MAX_DATA_BYTES     8
0049 
0050 #define MSCAN_MESS_ID_RTR        (1 << 15)
0051 #define MSCAN_MESS_ID_RTR_MASK   (1 << 15)
0052 #define MSCAN_MESS_ID_ID_MASK    ((1 << 11)-1)
0053 #define MSCAN_MESS_ID_HAS_RTR(id) (((id)&MSCAN_MESS_ID_RTR_MASK)==MSCAN_MESS_ID_RTR)
0054 
0055 #define MSCAN_SET_RX_ID          1
0056 #define MSCAN_GET_RX_ID          2
0057 #define MSCAN_SET_RX_ID_MASK     3
0058 #define MSCAN_GET_RX_ID_MASK     4
0059 #define MSCAN_SET_TX_ID          5
0060 #define MSCAN_GET_TX_ID          6
0061 #define TOUCAN_MSCAN_INIT        7
0062 #define MSCAN_SET_BAUDRATE       8
0063 #define SET_TX_BUF_NO            9
0064 
0065 struct can_message
0066   {
0067     /* uint16_t mess_len; */
0068   uint16_t mess_id;
0069   uint16_t mess_time_stamp;
0070   uint8_t  mess_data[MSCAN_MAX_DATA_BYTES];
0071   uint8_t  mess_len;
0072   uint8_t  mess_rtr;
0073   uint32_t toucan_tx_idx;
0074   };
0075 
0076 struct mscan_rx_parms
0077   {
0078   struct can_message *rx_mess;
0079   uint32_t rx_timeout;
0080   uint8_t  rx_flags;
0081   };
0082 
0083 struct mscan_tx_parms
0084   {
0085   struct can_message *tx_mess;
0086   uint32_t tx_idx;
0087   };
0088 
0089 struct mscan_ctrl_parms
0090   {
0091     uint32_t ctrl_id;
0092     uint32_t ctrl_id_mask;
0093     uint8_t  ctrl_reg_no;
0094     uint8_t  ctrl_tx_buf_no;
0095     uint32_t ctrl_can_bitrate;
0096     void (*toucan_cb_fnc)(int16_t);
0097   };
0098 
0099 
0100 rtems_device_driver mscan_initialize( rtems_device_major_number,
0101                                       rtems_device_minor_number,
0102                                       void *
0103                                     );
0104 
0105 rtems_device_driver mscan_open( rtems_device_major_number,
0106                                 rtems_device_minor_number,
0107                                 void *
0108                               );
0109 
0110 rtems_device_driver mscan_close( rtems_device_major_number,
0111                                  rtems_device_minor_number,
0112                                  void *
0113                                );
0114 
0115 rtems_device_driver mscan_read( rtems_device_major_number,
0116                                 rtems_device_minor_number,
0117                                 void *
0118                               );
0119 
0120 rtems_device_driver mscan_write( rtems_device_major_number,
0121                                  rtems_device_minor_number,
0122                                  void *
0123                                );
0124 
0125 rtems_device_driver mscan_control( rtems_device_major_number,
0126                                    rtems_device_minor_number,
0127                                    void *
0128                                  );
0129 
0130 
0131 #define MSCAN_DRIVER_TABLE_ENTRY \
0132   { mscan_initialize, mscan_open, mscan_close, \
0133     mscan_read, mscan_write, mscan_control }
0134 
0135 #ifdef __cplusplus
0136 }
0137 #endif
0138 
0139 #endif /* __MSCAN_H__ */