at91_spi.h

Go to the documentation of this file.
00001 #ifndef _DEV_AT91_SPI_H_
00002 #define _DEV_AT91_SPI_H_
00003 /*
00004  * Copyright (C) 2006 by egnite Software GmbH. 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 EGNITE SOFTWARE GMBH 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 EGNITE
00023  * SOFTWARE GMBH 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 
00052 #include <sys/types.h>
00053 #include <cfg/arch.h>
00054 
00055 /* Should be in dev/spi.h. */
00056 #define SPI_SETSPEED        0x0401
00057 #define SPI_GETSPEED        0x0402
00058 
00059 #define SPI_SETMODE         0x0403
00060 #define SPI_GETMODE         0x0404
00061 
00062 #define SPIMF_MASTER        0x00000001  /* Master mode. */
00063 #define SPIMF_PCSDEC        0x00000002  /* Decoded chip selects. */
00064 #define SPIMF_MFDETECT      0x00000004  /* Mode fault detection. */
00065 #define SPIMF_LOOPBACK      0x00000008  /* Loopback mode. */
00066 #define SPIMF_SCKIAHI       0x00000010  /* Clock is high when inactive. */
00067 #define SPIMF_CAPRISE       0x00000020  /* Data cpatured on rising edge. */
00068 #define SPIMF_KEEPCS        0x00000040  /* Chip select remains active after transfer. */
00069 
00070 #define SPI_SETDATABITS     0x0405
00071 #define SPI_GETDATABITS     0x0406
00072 /* dev/spi.h. */
00073 
00074 
00075 __BEGIN_DECLS
00076 /* Prototypes */
00077 extern int At91Spi0Init(void);
00078 extern int At91Spi0InitChipSelects(u_int mask);
00079 extern int At91Spi0Enable(void);
00080 #if defined(SPI1_BASE)
00081 extern int At91Spi1Init(void);
00082 extern int At91Spi1InitChipSelects(u_int mask);
00083 extern int At91Spi1Enable(void);
00084 #endif
00085 
00086 extern int At91SpiInit(u_int base);
00087 extern int At91SpiReset(u_int base);
00088 extern int At91SpiInitChipSelects(u_int base, u_int mask);
00089 
00090 extern int At91SpiSetRate(u_int base, u_int cs, u_long rate);
00091 extern u_long At91SpiGetModeFlags(u_int base, u_int cs);
00092 extern int At91SpiSetModeFlags(u_int base, u_int cs, u_long mode);
00093 extern u_int At91SpiGetBits(u_int base, u_int cs);
00094 extern int At91SpiSetBits(u_int base, u_int cs, u_int bits);
00095 extern u_int At91SpiGetSckDelay(u_int base, u_int cs);
00096 extern int At91SpiSetSckDelay(u_int base, u_int cs, u_int dly);
00097 extern u_int At91SpiGetTxDelay(u_int base, u_int cs);
00098 extern int At91SpiSetTxDelay(u_int base, u_int cs, u_int dly);
00099 extern u_int At91SpiGetCsDelay(u_int base);
00100 extern int At91SpiSetCsDelay(u_int base, u_int dly);
00101 
00102 extern int At91SpiTransfer2(u_int base, u_int cs, CONST void *txbuf, void *rxbuf, int xlen,
00103                            CONST void *txnbuf, void *rxnbuf, int xnlen);
00104 
00105 __END_DECLS
00106 /* End of prototypes */
00107 #endif

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/