twi_mcf5.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright 2012 by Embedded Technologies s.r.o
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the copyright holders nor the names of
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  24. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  25. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. *
  30. * For additional information see http://www.ethernut.de/
  31. */
  32. #ifndef MCF5_TWI_H_
  33. #define MCF5_TWI_H_
  34. typedef struct _NUTTWIICB NUTTWIICB;
  35. /*
  36. * Runtime Data container.
  37. * This is installed in heap at initializaton of a bus.
  38. */
  39. struct _NUTTWIICB {
  40. /*! \brief Bus slave address.
  41. */
  42. volatile uint_fast16_t tw_mm_sla;
  43. /*! \brief Bus slave device found.
  44. */
  45. volatile uint_fast16_t tw_mm_sla_found;
  46. /*! \brief Bus current error condition.
  47. */
  48. volatile uint_fast8_t tw_mm_err;
  49. /*! \brief Bus last error condition.
  50. */
  51. volatile uint_fast8_t tw_mm_error;
  52. /*! \brief Bus nodes internal address register.
  53. */
  54. uint8_t *tw_mm_iadr;
  55. /*! \brief Bus nodes internal address register length.
  56. */
  57. volatile uint_fast8_t tw_mm_iadrlen;
  58. /*! \brief Bus transmission data buffer pointer.
  59. */
  60. const uint8_t *tw_mm_txbuf;
  61. /*! \brief Bus transmission data block length.
  62. */
  63. volatile uint_fast16_t tw_mm_txlen;
  64. /*! \brief Bus reception data buffer pointer.
  65. */
  66. uint8_t *tw_mm_rxbuf;
  67. /*! \brief Bus reception data block length.
  68. */
  69. volatile uint_fast16_t tw_mm_rxlen;
  70. /*! \brief Bus data direction.
  71. */
  72. volatile uint_fast8_t tw_mm_dir;
  73. /*! \brief Transmission Ongoing Mutex.
  74. */
  75. HANDLE tw_mm_mtx;
  76. };
  77. extern NUTTWIBUS Mcf5TwiBus0;
  78. extern NUTTWIBUS Mcf5TwiBus1;
  79. #ifndef DEF_TWIBUS
  80. #ifdef I2CBUS1_AS_DEFAULT
  81. #define DEF_TWIBUS Mcf5TwiBus1
  82. #else
  83. #define DEF_TWIBUS Mcf5TwiBus0
  84. #endif
  85. #endif
  86. #endif /* MCF5_TWI_H_ */