Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

205 linhas
4.6 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief This module contains SAMD21 BSP APIs declarations.
  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 _NM_BSP_SAMD21_APP_H_
  35. #define _NM_BSP_SAMD21_APP_H_
  36. #include "bsp/include/nm_bsp.h"
  37. #include "common/include/nm_common.h"
  38. #include <asf.h>
  39. #define M2M_PRINTX(x) nm_bsp_uart_send((const uint8_t *)x,sizeof(x))
  40. /**
  41. *Extern global variables
  42. *
  43. */
  44. extern uint32 gu32Jiffies20ms;
  45. extern uint32 gu32Jiffies1ms;
  46. #ifdef __cplusplus
  47. extern "C"{
  48. #endif
  49. /*
  50. *
  51. */
  52. #define SW1 NBIT0
  53. #define SW2 NBIT1
  54. /**/
  55. #define NM_BSP_PERM_FIRMWARE_SIZE (1024UL*256) /* Permenant storage size available for the firmware */
  56. #define TICK_RES 20 /*!< Tick resolution in milliseconds*/
  57. #define TICK_RES_SLEEP 20 /*it must be equal tick or higher*/
  58. #define NM_BSP_TIME_MSEC (gu32Jiffies20ms * TICK_RES)
  59. /**
  60. *
  61. *Callback functions
  62. */
  63. typedef void (*tpfNmBspBtnPress)(uint8 u8Btn, uint8 u8Type);
  64. typedef void (*tpfNmBspTimerCb)(void);
  65. /**
  66. * @fn nm_bsp_init
  67. * @brief Initialize BSP
  68. * @return 0 in case of success and -1 in case of failure
  69. * @author M. Abdelmawla
  70. * @date 11 July 2012
  71. * @version 1.0
  72. */
  73. sint8 nm_bsp_app_init(void);
  74. /*
  75. * @fn nm_bsp_app_configurable_timer_init
  76. * @brief Initialize the Configurable Timer
  77. * @date 08 October 2015
  78. * @version 1.0
  79. */
  80. void nm_bsp_app_configurable_timer_init(uint32_t u32Period);
  81. /**
  82. * @fn nm_bsp_deinit
  83. * @brief De-iInitialize BSP
  84. * @return 0 in case of success and -1 in case of failure
  85. * @author M. Abdelmawla
  86. * @date 11 July 2012
  87. * @version 1.0
  88. */
  89. sint8 nm_bsp_app_deinit(void);
  90. /**
  91. * @fn nm_bsp_btn_init
  92. * @brief Initialize buttons driver
  93. * @author M.S.M
  94. * @date 28 oct 2013
  95. * @version 1.0
  96. */
  97. void nm_bsp_uart_send(const uint8 *pu8Buf, uint16 u16Sz);
  98. /**
  99. * @fn nm_bsp_btn_init
  100. * @brief Initialize buttons driver
  101. * @author M.S.M
  102. * @date 28 oct 2013
  103. * @version 1.0
  104. */
  105. void nm_bsp_btn_init(tpfNmBspBtnPress pfBtnCb);
  106. #ifdef _STATIC_PS_
  107. /**
  108. * @fn nm_bsp_register_wake_isr
  109. * @brief REGISTER wake up timer
  110. * @author M.S.M
  111. * @date 28 oct 2013
  112. * @version 1.0
  113. */
  114. void nm_bsp_register_wake_isr(tpfNmBspIsr pfIsr,uint32 u32MsPeriod);
  115. /**
  116. * @fn nm_bsp_wake_ctrl
  117. * @brief control wake up timer
  118. * @author M.S.M
  119. * @date 28 oct 2013
  120. * @version 1.0
  121. */
  122. void nm_bsp_wake_ctrl(uint8 en);
  123. #endif
  124. #if (defined _STATIC_PS_)||(defined _DYNAMIC_PS_)
  125. /**
  126. * @fn nm_bsp_enable_mcu_ps
  127. * @brief Start POWER SAVE FOR MCU
  128. * @author M.S.M
  129. * @date 28 oct 2013
  130. * @version 1.0
  131. */
  132. void nm_bsp_enable_mcu_ps(void);
  133. #endif
  134. /**
  135. * @fn nm_bsp_start_timer
  136. * @brief Start 20ms timer
  137. * @author M.S.M
  138. * @date 28 oct 2013
  139. * @version 1.0
  140. */
  141. void nm_bsp_start_timer(tpfNmBspTimerCb pfCb, uint32 u32Period);
  142. /*
  143. * @fn nm_bsp_start_1ms_timer
  144. * @brief Start 1ms timer
  145. * @date 08 October 2015
  146. * @version 1.0
  147. */
  148. void nm_bsp_start_1ms_timer(tpfNmBspTimerCb pfCb);
  149. /*
  150. * @fn nm_bsp_start_configurable_timer
  151. * @brief Start configurable timer
  152. * @date 08 October 2015
  153. * @version 1.0
  154. */
  155. void nm_bsp_start_configurable_timer(tpfNmBspTimerCb pfCb);
  156. /**
  157. * @fn nm_bsp_stop_timer
  158. * @brief Stop 20ms timer
  159. * @author M.S.M
  160. * @date 28 oct 2013
  161. * @version 1.0
  162. */
  163. void nm_bsp_stop_timer(void);
  164. /*
  165. * @fn nm_bsp_stop_1ms_timer
  166. * @brief Stop 1ms timer
  167. * @date 08 October 2015
  168. * @version 1.0
  169. */
  170. void nm_bsp_stop_1ms_timer(void);
  171. /*
  172. * @fn nm_bsp_stop_configurable_timer
  173. * @brief Stop configurable timer
  174. * @date 08 October 2015
  175. * @version 1.0
  176. */
  177. void nm_bsp_stop_configurable_timer(void);
  178. #ifdef __cplusplus
  179. }
  180. #endif
  181. #endif /* _NM_BSP_SAMD21_H_ */