at91_spi.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 THE COPYRIGHT HOLDERS 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 THE
  23. * COPYRIGHT OWNER 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$
  41. * Revision 1.4 2009/01/17 11:26:47 haraldkipp
  42. * Getting rid of two remaining BSD types in favor of stdint.
  43. * Replaced 'u_int' by 'unsinged int' and 'uptr_t' by 'uintptr_t'.
  44. *
  45. * Revision 1.3 2008/08/11 06:59:59 haraldkipp
  46. * BSD types replaced by stdint types (feature request #1282721).
  47. *
  48. * Revision 1.2 2006/10/08 16:48:09 haraldkipp
  49. * Documentation fixed
  50. *
  51. * Revision 1.1 2006/09/29 12:34:59 haraldkipp
  52. * Basic AT91 SPI support added.
  53. *
  54. *
  55. * \endverbatim
  56. */
  57. #include <sys/types.h>
  58. #include <cfg/arch.h>
  59. /* Should be in dev/spi.h. */
  60. #define SPI_SETSPEED 0x0401
  61. #define SPI_GETSPEED 0x0402
  62. #define SPI_SETMODE 0x0403
  63. #define SPI_GETMODE 0x0404
  64. #define SPIMF_MASTER 0x00000001 /* Master mode. */
  65. #define SPIMF_PCSDEC 0x00000002 /* Decoded chip selects. */
  66. #define SPIMF_MFDETECT 0x00000004 /* Mode fault detection. */
  67. #define SPIMF_LOOPBACK 0x00000008 /* Loopback mode. */
  68. #define SPIMF_SCKIAHI 0x00000010 /* Clock is high when inactive. */
  69. #define SPIMF_CAPRISE 0x00000020 /* Data cpatured on rising edge. */
  70. #define SPIMF_KEEPCS 0x00000040 /* Chip select remains active after transfer. */
  71. #define SPI_SETDATABITS 0x0405
  72. #define SPI_GETDATABITS 0x0406
  73. /* dev/spi.h. */
  74. extern int At91Spi0Init(void);
  75. extern int At91Spi0InitChipSelects(unsigned int mask);
  76. extern int At91Spi0Enable(void);
  77. #if defined(SPI1_BASE)
  78. extern int At91Spi1Init(void);
  79. extern int At91Spi1InitChipSelects(unsigned int mask);
  80. extern int At91Spi1Enable(void);
  81. #endif
  82. extern int At91SpiInit(unsigned int base);
  83. extern int At91SpiReset(unsigned int base);
  84. extern int At91SpiInitChipSelects(unsigned int base, unsigned int mask);
  85. extern int At91SpiSetRate(unsigned int base, unsigned int cs, uint32_t rate);
  86. extern uint32_t At91SpiGetModeFlags(unsigned int base, unsigned int cs);
  87. extern int At91SpiSetModeFlags(unsigned int base, unsigned int cs, uint32_t mode);
  88. extern unsigned int At91SpiGetBits(unsigned int base, unsigned int cs);
  89. extern int At91SpiSetBits(unsigned int base, unsigned int cs, unsigned int bits);
  90. extern unsigned int At91SpiGetSckDelay(unsigned int base, unsigned int cs);
  91. extern int At91SpiSetSckDelay(unsigned int base, unsigned int cs, unsigned int dly);
  92. extern unsigned int At91SpiGetTxDelay(unsigned int base, unsigned int cs);
  93. extern int At91SpiSetTxDelay(unsigned int base, unsigned int cs, unsigned int dly);
  94. extern unsigned int At91SpiGetCsDelay(unsigned int base);
  95. extern int At91SpiSetCsDelay(unsigned int base, unsigned int dly);
  96. extern int At91SpiTransfer2(unsigned int base, unsigned int cs, const void *txbuf, void *rxbuf, int xlen,
  97. const void *txnbuf, void *rxnbuf, int xnlen);
  98. #endif