You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

142 line
4.2 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief This module contains NMC1000 bus APIs implementation.
  6. *
  7. * Copyright (c) 2015 - 2017 Atmel Corporation. All rights reserved.
  8. *
  9. * \asf_license_start
  10. *
  11. * \page License
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions are met:
  15. *
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. *
  19. * 2. Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. *
  23. * 3. The name of Atmel may not be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  27. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  28. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  29. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  30. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  34. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  35. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * \asf_license_stop
  39. *
  40. */
  41. #ifndef _NMBUS_H_
  42. #define _NMBUS_H_
  43. #include "common/include/nm_common.h"
  44. #include "bus_wrapper/include/nm_bus_wrapper.h"
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. /**
  49. * @fn nm_bus_iface_init
  50. * @brief Initialize bus interface
  51. * @return M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
  52. */
  53. sint8 nm_bus_iface_init(void *);
  54. /**
  55. * @fn nm_bus_iface_deinit
  56. * @brief Deinitialize bus interface
  57. * @return M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
  58. */
  59. sint8 nm_bus_iface_deinit(void);
  60. /**
  61. * @fn nm_bus_reset
  62. * @brief reset bus interface
  63. * @return M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
  64. * @version 1.0
  65. */
  66. sint8 nm_bus_reset(void);
  67. /**
  68. * @fn nm_bus_iface_reconfigure
  69. * @brief reconfigure bus interface
  70. * @return M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
  71. */
  72. sint8 nm_bus_iface_reconfigure(void *ptr);
  73. /**
  74. * @fn nm_read_reg
  75. * @brief Read register
  76. * @param [in] u32Addr
  77. * Register address
  78. * @return Register value
  79. */
  80. uint32 nm_read_reg(uint32 u32Addr);
  81. /**
  82. * @fn nm_read_reg_with_ret
  83. * @brief Read register with error code return
  84. * @param [in] u32Addr
  85. * Register address
  86. * @param [out] pu32RetVal
  87. * Pointer to u32 variable used to return the read value
  88. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  89. */
  90. sint8 nm_read_reg_with_ret(uint32 u32Addr, uint32 *pu32RetVal);
  91. /**
  92. * @fn nm_write_reg
  93. * @brief write register
  94. * @param [in] u32Addr
  95. * Register address
  96. * @param [in] u32Val
  97. * Value to be written to the register
  98. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  99. */
  100. sint8 nm_write_reg(uint32 u32Addr, uint32 u32Val);
  101. /**
  102. * @fn nm_read_block
  103. * @brief Read block of data
  104. * @param [in] u32Addr
  105. * Start address
  106. * @param [out] puBuf
  107. * Pointer to a buffer used to return the read data
  108. * @param [in] u32Sz
  109. * Number of bytes to read. The buffer size must be >= u32Sz
  110. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  111. */
  112. sint8 nm_read_block(uint32 u32Addr, uint8 *puBuf, uint32 u32Sz);
  113. /**
  114. * @fn nm_write_block
  115. * @brief Write block of data
  116. * @param [in] u32Addr
  117. * Start address
  118. * @param [in] puBuf
  119. * Pointer to the buffer holding the data to be written
  120. * @param [in] u32Sz
  121. * Number of bytes to write. The buffer size must be >= u32Sz
  122. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  123. */
  124. sint8 nm_write_block(uint32 u32Addr, uint8 *puBuf, uint32 u32Sz);
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128. #endif /* _NMBUS_H_ */