Nut/OS  5.0.5
API Reference
twibus_avr.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2012 by Ole Reinhardt (ole.reinhardt@embedded-it.de)
00003  *
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  * 3. Neither the name of the copyright holders nor the names of
00016  *    contributors may be used to endorse or promote products derived
00017  *    from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00022  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00023  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00024  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00025  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00026  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00027  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00028  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00029  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  *
00032  * For additional information see http://www.ethernut.de/
00033  */
00034 
00035 #ifndef _DEV_TWIBUS_AVR_H_
00036 #define _DEV_TWIBUS_AVR_H_
00037 
00038 #include <sys/types.h>
00039 #include <cfg/arch.h>
00040 
00041 typedef struct _NUTTWIICB NUTTWIICB;
00042 /*
00043  * Runtime Data container.
00044  * This is installed in heap at initializaton
00045  * of a bus.
00046  */
00047 struct _NUTTWIICB {
00048     /********** Master mode *********/
00049 
00052     volatile uint_fast8_t tw_if_busy;
00053 
00056     volatile uint_fast16_t tw_mm_sla;
00057 
00060     volatile uint_fast8_t tw_mm_err;
00061 
00064     volatile uint_fast8_t tw_mm_error;
00065 
00068     const uint8_t *tw_mm_txbuf;
00069 
00072     volatile uint_fast16_t tw_mm_txlen;
00073 
00076     volatile uint_fast16_t tw_mm_txidx;
00077 
00080     uint8_t *tw_mm_rxbuf;
00081 
00084     volatile uint_fast16_t tw_mm_rxlen;
00085 
00088     volatile uint_fast16_t tw_mm_rxidx;
00089 
00090 
00093     volatile uint_fast8_t tw_mm_dir;
00094 
00097     HANDLE tw_mm_mtx;
00098 
00099     /********** Slave mode *********/
00100 
00101 
00104     uint_fast8_t tw_sm_sla;
00105 
00108     volatile uint_fast8_t tw_sm_err;
00109 
00112     volatile uint_fast8_t tw_sm_error;
00113 
00114 
00117     uint8_t *tw_sm_txbuf;
00118 
00121     uint_fast16_t tw_sm_txlen;
00122 
00125     volatile uint_fast16_t tw_sm_txidx;
00126 
00129     uint8_t *tw_sm_rxbuf;
00130 
00133     volatile uint_fast16_t tw_sm_rxlen;
00134 
00137     volatile uint_fast16_t tw_sm_rxidx;
00138 
00141     HANDLE tw_sm_rxmtx;
00142 
00145     HANDLE tw_sm_txmtx;
00146 };
00147 
00148 extern NUTTWIBUS TwBbifBus;
00149 
00150 #ifndef DEF_TWIBUS
00151 #define DEF_TWIBUS TwBbifBus
00152 #endif
00153 
00154 #endif /* _DEV_TWIBUS_AVR_H_ */