Nut/OS  5.0.5
API Reference
stm32_can.h
Go to the documentation of this file.
00001 #ifndef _STM32_CAN_H_
00002 #define _STM32_CAN_H_
00003 /*
00004  * Copyright (C) 2010 by Ulrich Prinz (uprinz2@netscape.net)
00005  * Copyright (C) 2010 by Rittal GmbH & Co. KG. All rights reserved.
00006  * Copyright (C) 2012 by Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de).
00007  *
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  *
00014  * 1. Redistributions of source code must retain the above copyright
00015  *    notice, this list of conditions and the following disclaimer.
00016  * 2. Redistributions in binary form must reproduce the above copyright
00017  *    notice, this list of conditions and the following disclaimer in the
00018  *    documentation and/or other materials provided with the distribution.
00019  * 3. Neither the name of the copyright holders nor the names of
00020  *    contributors may be used to endorse or promote products derived
00021  *    from this software without specific prior written permission.
00022  *
00023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00030  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00031  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00032  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00033  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00034  * SUCH DAMAGE.
00035  *
00036  * For additional information see http://www.ethernut.de/
00037  */
00038 
00044 struct _CANBUFFER {
00045     CAN_FIFOMailBox_TypeDef *dataptr;  //<physical memory address where the buffer is stored, may be device specific
00046     uint8_t size;         // the allocated size of the buffer
00047     uint8_t datalength;   // the length of the data currently in the buffer
00048     uint8_t dataindex;    // the index into the buffer where the data starts
00049 };
00059 struct _CANBUSINFO {
00060     HANDLE volatile can_rx_rdy;     
00061     HANDLE volatile can_tx_rdy;     
00062     uint32_t can_rx_frames;         
00063     uint32_t can_tx_frames;         
00064     uint32_t can_rx_interrupts;     
00065     uint32_t can_tx_interrupts;     
00066     uint32_t can_sce_interrupts;    
00067     uint32_t can_overruns;          
00068     uint32_t can_errors;            
00069     uint32_t can_rx_timeout;            
00070     CANBUFFER can_RxBuf;            
00071 };
00072 
00073 struct _NUTCANBUS {
00074     uptr_t      bus_base;       /*< Periphery Base Register Address */
00075     __IO uint32_t* bb_base;     /*< Periphery BIT BAND Base Register Address */
00076     IRQ_HANDLER *sig_rx_irq;    /*< IRQ Handler RX Interrupt */
00077     IRQ_HANDLER *sig_tx_irq;    /*< IRQ Handler TX Interrupt */
00078     IRQ_HANDLER *sig_sce_irq;   /*< IRQ Handler SCE Interrupt */
00079     struct _CANBUSINFO  *bus_ci;        /*< CANINFO for the BUS */
00080     int (*bus_inithw)(void);    /*< Function for low level hardware initialization */
00081 };
00082 
00083 extern NUTCANBUS Stm32CanBus1;
00084 extern NUTCANBUS Stm32CanBus1C;
00085 extern NUTCANBUS Stm32CanBus2;
00086 extern NUTCANBUS Stm32CanBus2C;
00087 
00088 #endif