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