您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

105 行
3.4 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief This module contains NMC1000 I2C protocol bus APIs implementation.
  6. *
  7. * Copyright (c) 2015 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 _NMI2C_H_
  42. #define _NMI2C_H_
  43. #include "common/include/nm_common.h"
  44. /**
  45. * @fn nm_i2c_read_reg
  46. * @brief Read register
  47. * @param [in] u32Addr
  48. * Register address
  49. * @return Register value
  50. */
  51. uint32 nm_i2c_read_reg(uint32 u32Addr);
  52. /**
  53. * @fn nm_i2c_read_reg_with_ret
  54. * @brief Read register with error code return
  55. * @param [in] u32Addr
  56. * Register address
  57. * @param [out] pu32RetVal
  58. * Pointer to u32 variable used to return the read value
  59. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  60. */
  61. sint8 nm_i2c_read_reg_with_ret(uint32 u32Addr, uint32 *pu32RetVal);
  62. /**
  63. * @fn nm_i2c_write_reg
  64. * @brief write register
  65. * @param [in] u32Addr
  66. * Register address
  67. * @param [in] u32Val
  68. * Value to be written to the register
  69. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  70. */
  71. sint8 nm_i2c_write_reg(uint32 u32Addr, uint32 u32Val);
  72. /**
  73. * @fn nm_i2c_read_block
  74. * @brief Read block of data
  75. * @param [in] u32Addr
  76. * Start address
  77. * @param [out] puBuf
  78. * Pointer to a buffer used to return the read data
  79. * @param [in] u16Sz
  80. * Number of bytes to read. The buffer size must be >= u16Sz
  81. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  82. */
  83. sint8 nm_i2c_read_block(uint32 u32Addr, uint8 *puBuf, uint16 u16Sz);
  84. /**
  85. * @fn nm_i2c_write_block
  86. * @brief Write block of data
  87. * @param [in] u32Addr
  88. * Start address
  89. * @param [in] puBuf
  90. * Pointer to the buffer holding the data to be written
  91. * @param [in] u16Sz
  92. * Number of bytes to write. The buffer size must be >= u16Sz
  93. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  94. */
  95. sint8 nm_i2c_write_block(uint32 u32Addr, uint8 *puBuf, uint16 u16Sz);
  96. #endif /* _NMI2C_H_ */