cc_pal.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. //*****************************************************************************
  2. // cc_pal.h
  3. //
  4. // Simplelink abstraction header file for CC3200
  5. //
  6. // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
  7. //
  8. //
  9. // Redistribution and use in source and binary forms, with or without
  10. // modification, are permitted provided that the following conditions
  11. // are met:
  12. //
  13. // Redistributions of source code must retain the above copyright
  14. // notice, this list of conditions and the following disclaimer.
  15. //
  16. // Redistributions in binary form must reproduce the above copyright
  17. // notice, this list of conditions and the following disclaimer in the
  18. // documentation and/or other materials provided with the
  19. // distribution.
  20. //
  21. // Neither the name of Texas Instruments Incorporated nor the names of
  22. // its contributors may be used to endorse or promote products derived
  23. // from this software without specific prior written permission.
  24. //
  25. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  30. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  31. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. //
  37. //*****************************************************************************
  38. #ifndef __CC31xx_PAL_H__
  39. #define __CC31xx_PAL_H__
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /*!
  44. \brief type definition for the spi channel file descriptor
  45. \note On each porting or platform the type could be whatever is needed - integer, pointer to structure etc.
  46. */
  47. typedef int Fd_t;
  48. /*!
  49. \brief type definition for the host interrupt handler
  50. \param pValue - pointer to any memory strcuture. The value of this pointer is givven on
  51. registration of a new interrupt handler
  52. \note
  53. */
  54. typedef void (*SL_P_EVENT_HANDLER)(void);
  55. #define P_EVENT_HANDLER SL_P_EVENT_HANDLER
  56. /*!
  57. \brief open spi communication port to be used for communicating with a SimpleLink device
  58. Given an interface name and option flags, this function opens the spi communication port
  59. and creates a file descriptor. This file descriptor can be used afterwards to read and
  60. write data from and to this specific spi channel.
  61. The SPI speed, clock polarity, clock phase, chip select and all other attributes are all
  62. set to hardcoded values in this function.
  63. \param ifName - points to the interface name/path. The interface name is an
  64. optional attributes that the simple link driver receives
  65. on opening the device. in systems that the spi channel is
  66. not implemented as part of the os device drivers, this
  67. parameter could be NULL.
  68. \param flags - option flags
  69. \return upon successful completion, the function shall open the spi channel and return
  70. a non-negative integer representing the file descriptor.
  71. Otherwise, -1 shall be returned
  72. \sa spi_Close , spi_Read , spi_Write
  73. \note
  74. \warning
  75. */
  76. Fd_t spi_Open(char *ifName, unsigned long flags);
  77. /*!
  78. \brief closes an opened spi communication port
  79. \param fd - file descriptor of an opened SPI channel
  80. \return upon successful completion, the function shall return 0.
  81. Otherwise, -1 shall be returned
  82. \sa spi_Open
  83. \note
  84. \warning
  85. */
  86. int spi_Close(Fd_t fd);
  87. /*!
  88. \brief attempts to read up to len bytes from SPI channel into a buffer starting at pBuff.
  89. \param fd - file descriptor of an opened SPI channel
  90. \param pBuff - points to first location to start writing the data
  91. \param len - number of bytes to read from the SPI channel
  92. \return upon successful completion, the function shall return 0.
  93. Otherwise, -1 shall be returned
  94. \sa spi_Open , spi_Write
  95. \note
  96. \warning
  97. */
  98. int spi_Read(Fd_t fd, unsigned char *pBuff, int len);
  99. /*!
  100. \brief attempts to write up to len bytes to the SPI channel
  101. \param fd - file descriptor of an opened SPI channel
  102. \param pBuff - points to first location to start getting the data from
  103. \param len - number of bytes to write to the SPI channel
  104. \return upon successful completion, the function shall return 0.
  105. Otherwise, -1 shall be returned
  106. \sa spi_Open , spi_Read
  107. \note This function could be implemented as zero copy and return only upon successful completion
  108. of writing the whole buffer, but in cases that memory allocation is not too tight, the
  109. function could copy the data to internal buffer, return back and complete the write in
  110. parallel to other activities as long as the other SPI activities would be blocked untill
  111. the entire buffer write would be completed
  112. \warning
  113. */
  114. int spi_Write(Fd_t fd, unsigned char *pBuff, int len);
  115. /*!
  116. \brief register an interrupt handler for the host IRQ
  117. \param InterruptHdl - pointer to interrupt handler function
  118. \param pValue - pointer to a memory strcuture that is passed to the interrupt handler.
  119. \return upon successful registration, the function shall return 0.
  120. Otherwise, -1 shall be returned
  121. \sa
  122. \note If there is already registered interrupt handler, the function should overwrite the old handler
  123. with the new one
  124. \warning
  125. */
  126. int NwpRegisterInterruptHandler(P_EVENT_HANDLER InterruptHdl , void* pValue);
  127. /*!
  128. \brief Masks host IRQ
  129. \sa NwpUnMaskInterrupt
  130. \warning
  131. */
  132. void NwpMaskInterrupt();
  133. /*!
  134. \brief Unmasks host IRQ
  135. \sa NwpMaskInterrupt
  136. \warning
  137. */
  138. void NwpUnMaskInterrupt();
  139. void NwpPowerOnPreamble(void);
  140. void NwpPowerOff(void);
  141. void NwpPowerOn(void);
  142. #ifdef __cplusplus
  143. }
  144. #endif // __cplusplus
  145. #endif