lpc176x_spi.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef _LPC17XX_SPI_H_
  2. #define _LPC17XX_SPI_H_
  3. /*
  4. * Copyright (C) 2013 by Simon Budig <simon@budig.de>
  5. *
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * For additional information see http://www.ethernut.de/
  35. */
  36. /*
  37. * \verbatim
  38. * $Id: $
  39. * \endverbatim
  40. */
  41. /*----------------------------------------------------------------------------*
  42. SPI Control Register (S0SPCR)
  43. *----------------------------------------------------------------------------*/
  44. #define SPI_CR_BITENABLE (1 << 2) /* if set send 8..16 bits - see SPI_BITS */
  45. #define SPI_CR_CPHA (1 << 3) /* clock phase */
  46. #define SPI_CR_CPOL (1 << 4) /* clock polarity */
  47. #define SPI_CR_MSTR (1 << 5) /* spi master / slave */
  48. #define SPI_CR_LSBF (1 << 6) /* lsb first */
  49. #define SPI_CR_SPIE (1 << 7) /* spi interrupt enable */
  50. #define SPI_CR_BITS(x) (((x) & 0xf) << 8) /* requires SPI_BITENABLE, valid range 8..16 */
  51. #define SPI_CR_BITS_MASK (0xf << 8)
  52. /*----------------------------------------------------------------------------*
  53. SPI Status Register (S0SPSR)
  54. *----------------------------------------------------------------------------*/
  55. #define SPI_SR_ABRT (1 << 3) /* Slave abort */
  56. #define SPI_SR_MODF (1 << 4) /* Mode fault */
  57. #define SPI_SR_ROVR (1 << 5) /* Read overrun */
  58. #define SPI_SR_WCOL (1 << 6) /* Write collision */
  59. #define SPI_SR_SPIF (1 << 7) /* SPI transfer complete flag */
  60. /*----------------------------------------------------------------------------*
  61. SPI Data Register (S0SPDR)
  62. *----------------------------------------------------------------------------*/
  63. #define SPI_DR_DATALOW_MASK (0x00ff)
  64. #define SPI_DR_DATAHIGH_MASK (0xff00)
  65. /*----------------------------------------------------------------------------*
  66. SPI Clock Counter Register (S0SPCCR)
  67. *----------------------------------------------------------------------------*/
  68. #define SPI_CCR_COUNTER_MASK (0x00ff) /* must be even and >= 8. */
  69. /* Also depends on the peripheral clock chosen */
  70. /*----------------------------------------------------------------------------*
  71. SPI Interrupt Register (S0SPINT)
  72. *----------------------------------------------------------------------------*/
  73. #define SPI_INT_SPIF (1 << 0) /* SPI interrupt flag */
  74. #endif