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

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