mac_mem.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /**************************************************************************************************
  2. Filename: mac_mem.c
  3. Revised: $Date: 2009-08-12 14:34:18 -0700 (Wed, 12 Aug 2009) $
  4. Revision: $Revision: 20549 $
  5. Description: Describe the purpose and contents of the file.
  6. Copyright 2006-2009 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. /* ------------------------------------------------------------------------------------------------
  34. * Includes
  35. * ------------------------------------------------------------------------------------------------
  36. */
  37. /* hal */
  38. #include "hal_types.h"
  39. /* low-level specific */
  40. #include "mac_mem.h"
  41. /* target specific */
  42. #include "hal_mcu.h"
  43. /* debug */
  44. #include "mac_assert.h"
  45. /**************************************************************************************************
  46. * @fn macMemReadRamByte
  47. *
  48. * @brief Read a byte from RAM.
  49. *
  50. * @param pRam - pointer to byte RAM byte to read
  51. *
  52. * @return byte read from RAM
  53. **************************************************************************************************
  54. */
  55. uint8 macMemReadRamByte(macRam_t * pRam)
  56. {
  57. return(*pRam);
  58. }
  59. /**************************************************************************************************
  60. * @fn macMemWriteRam
  61. *
  62. * @brief Write multiple bytes to RAM.
  63. *
  64. * @param pRam - pointer to RAM to be written to
  65. * @param pData - pointer to data to write
  66. * @param len - number of bytes to write
  67. *
  68. * @return none
  69. **************************************************************************************************
  70. */
  71. MAC_INTERNAL_API void macMemWriteRam(macRam_t * pRam, uint8 * pData, uint8 len)
  72. {
  73. while (len)
  74. {
  75. len--;
  76. *pRam = *pData;
  77. pRam++;
  78. pData++;
  79. }
  80. }
  81. /**************************************************************************************************
  82. * @fn macMemReadRam
  83. *
  84. * @brief Read multiple bytes from RAM.
  85. *
  86. * @param pRam - pointer to RAM to be read from
  87. * @param pData - pointer to location to store read data
  88. * @param len - number of bytes to read
  89. *
  90. * @return none
  91. **************************************************************************************************
  92. */
  93. MAC_INTERNAL_API void macMemReadRam(macRam_t * pRam, uint8 * pData, uint8 len)
  94. {
  95. while (len)
  96. {
  97. len--;
  98. *pData = *pRam;
  99. pRam++;
  100. pData++;
  101. }
  102. }
  103. /**************************************************************************************************
  104. * @fn macMemWriteTxFifo
  105. *
  106. * @brief Write multiple bytes to the transmit FIFO.
  107. *
  108. * @param pData - pointer to bytes to be written to TX FIFO
  109. * @param len - number of bytes to write
  110. *
  111. * @return none
  112. **************************************************************************************************
  113. */
  114. MAC_INTERNAL_API void macMemWriteTxFifo(uint8 * pData, uint8 len)
  115. {
  116. MAC_ASSERT(len != 0); /* pointless to write zero bytes */
  117. do
  118. {
  119. RFD = *pData;
  120. pData++;
  121. len--;
  122. }
  123. while (len);
  124. }
  125. /**************************************************************************************************
  126. * @fn macMemReadRxFifo
  127. *
  128. * @brief Read multiple bytes from receive FIFO.
  129. *
  130. * @param pData - pointer to location to store read data
  131. * @param len - number of bytes to read from RX FIFO
  132. *
  133. * @return none
  134. **************************************************************************************************
  135. */
  136. MAC_INTERNAL_API void macMemReadRxFifo(uint8 * pData, uint8 len)
  137. {
  138. MAC_ASSERT(len != 0); /* pointless to read zero bytes */
  139. do
  140. {
  141. *pData = RFD;
  142. pData++;
  143. len--;
  144. }
  145. while (len);
  146. }
  147. /**************************************************************************************************
  148. */