slcd_callback.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief SAM Segment Liquid Crystal Display(SLCD) Controller.
  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. * 4. This software may only be redistributed and used in connection with an
  27. * Atmel microcontroller product.
  28. *
  29. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  30. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  31. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  32. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  33. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  35. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  36. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  37. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  38. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  39. * POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. * \asf_license_stop
  42. *
  43. */
  44. /*
  45. * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
  46. */
  47. #ifndef SLCD_CALLBACK_H_INCLUDED
  48. #define SLCD_CALLBACK_H_INCLUDED
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52. #include <compiler.h>
  53. #include <system_interrupt.h>
  54. /**
  55. * \addtogroup asfdoc_sam0_drivers_slcd_group
  56. *
  57. * @{
  58. */
  59. /**
  60. * \brief SLCD callback type
  61. *
  62. * Enum SLCD callback type.
  63. */
  64. enum slcd_callback_type {
  65. /** Frame Counter 0 Overflow callback */
  66. SLCD_CALLBACK_FC0_OVERFLOW = 0,
  67. /** Frame Counter 1 Overflow callback */
  68. SLCD_CALLBACK_FC1_OVERFLOW,
  69. /** Frame Counter 2 Overflow callback */
  70. SLCD_CALLBACK_FC2_OVERFLOW,
  71. /** VLCD Ready Toggle callback */
  72. SLCD_CALLBACK_VLCD_READY,
  73. /** VLCD Status Toggle callback */
  74. SLCD_CALLBACK_VLCD_TOGGLE,
  75. /** Pump Run Status Toggle callback */
  76. SLCD_CALLBACK_PUMP_TOGGLE,
  77. };
  78. /** SLCD interrupt callback function type. */
  79. typedef void (*slcd_callback_t)(enum slcd_callback_type type);
  80. /** \internal Max number of callback type. */
  81. #define SLCD_CALLBACK_TYPE_NUM 6
  82. /** \name Callback Function
  83. * @{
  84. */
  85. enum status_code slcd_register_callback(
  86. const slcd_callback_t callback,
  87. const enum slcd_callback_type type);
  88. enum status_code slcd_unregister_callback(
  89. const slcd_callback_t callback,
  90. const enum slcd_callback_type type);
  91. /**
  92. * \brief Enable an SLCD callback
  93. *
  94. * \param[in] type Callback source type
  95. *
  96. * \retval STATUS_OK The function exited successfully
  97. * \retval STATUS_ERR_INVALID_ARG If an invalid callback type was supplied
  98. */
  99. static inline void slcd_enable_callback(const enum slcd_callback_type type)
  100. {
  101. if (type < SLCD_CALLBACK_TYPE_NUM){
  102. SLCD->INTENSET.reg = 1 << type;
  103. }
  104. }
  105. /**
  106. * \brief Disable an SLCD callback
  107. *
  108. * \param[in] type Callback source type
  109. *
  110. * \retval STATUS_OK The function exited successfully
  111. * \retval STATUS_ERR_INVALID_ARG If an invalid callback type was supplied
  112. */
  113. static inline void slcd_disable_callback(const enum slcd_callback_type type)
  114. {
  115. if (type < SLCD_CALLBACK_TYPE_NUM){
  116. SLCD->INTENCLR.reg = 1 << type;
  117. }
  118. }
  119. /** @} */
  120. /** @} */
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124. #endif /* SLCD_CALLBACK_H_INCLUDED */