at91_spi.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef _DEV_AT91_SPI_H_
  2. #define _DEV_AT91_SPI_H_
  3. /*
  4. * Copyright (C) 2006 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*!
  35. * \file dev/at91_spi.h
  36. * \brief AT91 peripherals.
  37. *
  38. * \verbatim
  39. *
  40. * $Log: at91_spi.h,v $
  41. * Revision 1.2 2006/10/08 16:48:09 haraldkipp
  42. * Documentation fixed
  43. *
  44. * Revision 1.1 2006/09/29 12:34:59 haraldkipp
  45. * Basic AT91 SPI support added.
  46. *
  47. *
  48. * \endverbatim
  49. */
  50. #include <sys/types.h>
  51. #include <cfg/arch.h>
  52. /* Should be in dev/spi.h. */
  53. #define SPI_SETSPEED 0x0401
  54. #define SPI_GETSPEED 0x0402
  55. #define SPI_SETMODE 0x0403
  56. #define SPI_GETMODE 0x0404
  57. #define SPIMF_MASTER 0x00000001 /* Master mode. */
  58. #define SPIMF_PCSDEC 0x00000002 /* Decoded chip selects. */
  59. #define SPIMF_MFDETECT 0x00000004 /* Mode fault detection. */
  60. #define SPIMF_LOOPBACK 0x00000008 /* Loopback mode. */
  61. #define SPIMF_SCKIAHI 0x00000010 /* Clock is high when inactive. */
  62. #define SPIMF_CAPRISE 0x00000020 /* Data cpatured on rising edge. */
  63. #define SPIMF_KEEPCS 0x00000040 /* Chip select remains active after transfer. */
  64. #define SPI_SETDATABITS 0x0405
  65. #define SPI_GETDATABITS 0x0406
  66. /* dev/spi.h. */
  67. __BEGIN_DECLS
  68. /* Prototypes */
  69. extern int At91Spi0Init(void);
  70. extern int At91Spi0InitChipSelects(u_int mask);
  71. extern int At91Spi0Enable(void);
  72. #if defined(SPI1_BASE)
  73. extern int At91Spi1Init(void);
  74. extern int At91Spi1InitChipSelects(u_int mask);
  75. extern int At91Spi1Enable(void);
  76. #endif
  77. extern int At91SpiInit(u_int base);
  78. extern int At91SpiReset(u_int base);
  79. extern int At91SpiInitChipSelects(u_int base, u_int mask);
  80. extern int At91SpiSetRate(u_int base, u_int cs, u_long rate);
  81. extern u_long At91SpiGetModeFlags(u_int base, u_int cs);
  82. extern int At91SpiSetModeFlags(u_int base, u_int cs, u_long mode);
  83. extern u_int At91SpiGetBits(u_int base, u_int cs);
  84. extern int At91SpiSetBits(u_int base, u_int cs, u_int bits);
  85. extern u_int At91SpiGetSckDelay(u_int base, u_int cs);
  86. extern int At91SpiSetSckDelay(u_int base, u_int cs, u_int dly);
  87. extern u_int At91SpiGetTxDelay(u_int base, u_int cs);
  88. extern int At91SpiSetTxDelay(u_int base, u_int cs, u_int dly);
  89. extern u_int At91SpiGetCsDelay(u_int base);
  90. extern int At91SpiSetCsDelay(u_int base, u_int dly);
  91. extern int At91SpiTransfer2(u_int base, u_int cs, CONST void *txbuf, void *rxbuf, int xlen,
  92. CONST void *txnbuf, void *rxnbuf, int xnlen);
  93. __END_DECLS
  94. /* End of prototypes */
  95. #endif