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ů.
 
 
 
 

138 řádky
4.6 KiB

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