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.
 
 
 
 

119 rader
3.8 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief This module contains NMC1000 UART 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 _NMUART_H_
  42. #define _NMUART_H_
  43. #include "common/include/nm_common.h"
  44. /*
  45. * @fn nm_uart_sync_cmd
  46. * @brief Check COM Port
  47. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  48. */
  49. sint8 nm_uart_sync_cmd(void);
  50. /**
  51. * @fn nm_uart_read_reg
  52. * @brief Read register
  53. * @param [in] u32Addr
  54. * Register address
  55. * @return Register value
  56. */
  57. uint32 nm_uart_read_reg(uint32 u32Addr);
  58. /**
  59. * @fn nm_uart_read_reg_with_ret
  60. * @brief Read register with error code return
  61. * @param [in] u32Addr
  62. * Register address
  63. * @param [out] pu32RetVal
  64. * Pointer to u32 variable used to return the read value
  65. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  66. */
  67. sint8 nm_uart_read_reg_with_ret(uint32 u32Addr, uint32 *pu32RetVal);
  68. /**
  69. * @fn nm_uart_write_reg
  70. * @brief write register
  71. * @param [in] u32Addr
  72. * Register address
  73. * @param [in] u32Val
  74. * Value to be written to the register
  75. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  76. */
  77. sint8 nm_uart_write_reg(uint32 u32Addr, uint32 u32Val);
  78. /**
  79. * @fn nm_uart_read_block
  80. * @brief Read block of data
  81. * @param [in] u32Addr
  82. * Start address
  83. * @param [out] puBuf
  84. * Pointer to a buffer used to return the read data
  85. * @param [in] u16Sz
  86. * Number of bytes to read. The buffer size must be >= u16Sz
  87. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  88. */
  89. sint8 nm_uart_read_block(uint32 u32Addr, uint8 *puBuf, uint16 u16Sz);
  90. /**
  91. * @fn nm_uart_write_block
  92. * @brief Write block of data
  93. * @param [in] u32Addr
  94. * Start address
  95. * @param [in] puBuf
  96. * Pointer to the buffer holding the data to be written
  97. * @param [in] u16Sz
  98. * Number of bytes to write. The buffer size must be >= u16Sz
  99. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  100. */
  101. sint8 nm_uart_write_block(uint32 u32Addr, uint8 *puBuf, uint16 u16Sz);
  102. /**
  103. * @fn nm_uart_reconfigure
  104. * @brief Reconfigures the UART interface
  105. * @param [in] ptr
  106. * Pointer to a DWORD containing baudrate at this moment.
  107. * @return ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
  108. */
  109. sint8 nm_uart_reconfigure(void *ptr);
  110. #endif /* _NMI2C_H_ */