Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

133 řádky
3.9 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief This module contains NMC1000 SPI protocol 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 _NMSPI_H_
  42. #define _NMSPI_H_
  43. #include "common/include/nm_common.h"
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. /**
  48. * @fn nm_spi_init
  49. * @brief Initialize the SPI
  50. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  51. */
  52. sint8 nm_spi_init(void);
  53. /**
  54. * @fn nm_spi_reset
  55. * @brief reset the SPI
  56. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  57. */
  58. sint8 nm_spi_reset(void);
  59. /**
  60. * @fn nm_spi_deinit
  61. * @brief DeInitialize the SPI
  62. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  63. */
  64. sint8 nm_spi_deinit(void);
  65. /**
  66. * @fn nm_spi_read_reg
  67. * @brief Read register
  68. * @param [in] u32Addr
  69. * Register address
  70. * @return Register value
  71. */
  72. uint32 nm_spi_read_reg(uint32 u32Addr);
  73. /**
  74. * @fn nm_spi_read_reg_with_ret
  75. * @brief Read register with error code return
  76. * @param [in] u32Addr
  77. * Register address
  78. * @param [out] pu32RetVal
  79. * Pointer to u32 variable used to return the read value
  80. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  81. */
  82. sint8 nm_spi_read_reg_with_ret(uint32 u32Addr, uint32 *pu32RetVal);
  83. /**
  84. * @fn nm_spi_write_reg
  85. * @brief write register
  86. * @param [in] u32Addr
  87. * Register address
  88. * @param [in] u32Val
  89. * Value to be written to the register
  90. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  91. */
  92. sint8 nm_spi_write_reg(uint32 u32Addr, uint32 u32Val);
  93. /**
  94. * @fn nm_spi_read_block
  95. * @brief Read block of data
  96. * @param [in] u32Addr
  97. * Start address
  98. * @param [out] puBuf
  99. * Pointer to a buffer used to return the read data
  100. * @param [in] u16Sz
  101. * Number of bytes to read. The buffer size must be >= u16Sz
  102. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  103. */
  104. sint8 nm_spi_read_block(uint32 u32Addr, uint8 *puBuf, uint16 u16Sz);
  105. /**
  106. * @fn nm_spi_write_block
  107. * @brief Write block of data
  108. * @param [in] u32Addr
  109. * Start address
  110. * @param [in] puBuf
  111. * Pointer to the buffer holding the data to be written
  112. * @param [in] u16Sz
  113. * Number of bytes to write. The buffer size must be >= u16Sz
  114. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  115. */
  116. sint8 nm_spi_write_block(uint32 u32Addr, uint8 *puBuf, uint16 u16Sz);
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif /* _NMSPI_H_ */