Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

120 rader
3.4 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief This module contains WINC3400 SPI protocol bus APIs implementation.
  6. *
  7. * Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.
  8. *
  9. * \asf_license_start
  10. *
  11. * \page License
  12. *
  13. * Subject to your compliance with these terms, you may use Microchip
  14. * software and any derivatives exclusively with Microchip products.
  15. * It is your responsibility to comply with third party license terms applicable
  16. * to your use of third party software (including open source software) that
  17. * may accompany Microchip software.
  18. *
  19. * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
  20. * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
  21. * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
  22. * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
  23. * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
  24. * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
  25. * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
  26. * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
  27. * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
  28. * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
  29. * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
  30. *
  31. * \asf_license_stop
  32. *
  33. */
  34. #ifndef _NMSPI_H_
  35. #define _NMSPI_H_
  36. #include "common/include/nm_common.h"
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. /**
  41. * @fn nm_spi_init
  42. * @brief Initialize the SPI
  43. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  44. */
  45. sint8 nm_spi_init(void);
  46. /**
  47. * @fn nm_spi_deinit
  48. * @brief DeInitialize the SPI
  49. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  50. */
  51. sint8 nm_spi_deinit(void);
  52. /**
  53. * @fn nm_spi_read_reg
  54. * @brief Read register
  55. * @param [in] u32Addr
  56. * Register address
  57. * @return Register value
  58. */
  59. uint32 nm_spi_read_reg(uint32 u32Addr);
  60. /**
  61. * @fn nm_spi_read_reg_with_ret
  62. * @brief Read register with error code return
  63. * @param [in] u32Addr
  64. * Register address
  65. * @param [out] pu32RetVal
  66. * Pointer to u32 variable used to return the read value
  67. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  68. */
  69. sint8 nm_spi_read_reg_with_ret(uint32 u32Addr, uint32* pu32RetVal);
  70. /**
  71. * @fn nm_spi_write_reg
  72. * @brief write register
  73. * @param [in] u32Addr
  74. * Register address
  75. * @param [in] u32Val
  76. * Value to be written to the register
  77. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  78. */
  79. sint8 nm_spi_write_reg(uint32 u32Addr, uint32 u32Val);
  80. /**
  81. * @fn nm_spi_read_block
  82. * @brief Read block of data
  83. * @param [in] u32Addr
  84. * Start address
  85. * @param [out] puBuf
  86. * Pointer to a buffer used to return the read data
  87. * @param [in] u16Sz
  88. * Number of bytes to read. The buffer size must be >= u16Sz
  89. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  90. */
  91. sint8 nm_spi_read_block(uint32 u32Addr, uint8 *puBuf, uint16 u16Sz);
  92. /**
  93. * @fn nm_spi_write_block
  94. * @brief Write block of data
  95. * @param [in] u32Addr
  96. * Start address
  97. * @param [in] puBuf
  98. * Pointer to the buffer holding the data to be written
  99. * @param [in] u16Sz
  100. * Number of bytes to write. The buffer size must be >= u16Sz
  101. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  102. */
  103. sint8 nm_spi_write_block(uint32 u32Addr, uint8 *puBuf, uint16 u16Sz);
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107. #endif /* _NMSPI_H_ */