00001 #ifndef _STM32_TWI_H_ 00002 #define _STM32_TWI_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 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * 3. Neither the name of the copyright holders nor the names of 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00029 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00030 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00031 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00032 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00033 * SUCH DAMAGE. 00034 * 00035 * For additional information see http://www.ethernut.de/ 00036 */ 00037 00038 /* 00039 * \verbatim 00040 * $Id: stm32_twi.h 4268 2012-06-15 13:24:08Z haraldkipp $ 00041 * \endverbatim 00042 */ 00043 00049 typedef struct _NUTTWIICB NUTTWIICB; 00050 /* 00051 * Runtime Data container. 00052 * This is installed in heap at initializaton 00053 * of a bus. 00054 */ 00055 struct _NUTTWIICB { 00056 /********** Master mode *********/ 00057 00060 volatile uint_fast16_t tw_mm_sla; 00061 00064 volatile uint_fast8_t tw_mm_err; 00065 00068 volatile uint_fast8_t tw_mm_error; 00069 00072 uint8_t *tw_mm_iadr; 00073 00076 volatile uint_fast8_t tw_mm_iadrlen; 00077 00080 const uint8_t *tw_mm_txbuf; 00081 00084 volatile uint_fast16_t tw_mm_txlen; 00085 00088 volatile uint_fast16_t tw_mm_txidx; 00089 00092 uint8_t *tw_mm_rxbuf; 00093 00096 volatile uint_fast16_t tw_mm_rxlen; 00097 00100 volatile uint_fast16_t tw_mm_rxidx; 00101 00102 00105 volatile uint_fast8_t tw_mm_dir; 00106 00109 HANDLE tw_mm_mtx; 00110 }; 00111 00112 extern NUTTWIBUS Stm32TwiBus_1; 00113 extern NUTTWIBUS Stm32TwiBus_2; 00114 00115 #define I2C1_DMA_CHANNEL_TX DMA1_C6 00116 #define I2C1_DMA_CHANNEL_RX DMA1_C7 00117 00118 #define I2C2_DMA_CHANNEL_TX DMA1_C4 00119 #define I2C2_DMA_CHANNEL_RX DMA1_C5 00120 00121 #ifndef DEF_TWIBUS 00122 #ifdef I2CBUS1_AS_DEFAULT 00123 #define DEF_TWIBUS Stm32TwiBus_1 00124 #else 00125 #define DEF_TWIBUS Stm32TwiBus_2 00126 #endif 00127 #endif 00128 00129 #endif /* _STM32_TWI_H_ */