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 
48 #ifndef SLCD_CALLBACK_H_INCLUDED
49 #define SLCD_CALLBACK_H_INCLUDED
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 #include <compiler.h>
56 #include <system_interrupt.h>
57 /**
58  * \addtogroup asfdoc_sam0_drivers_slcd_group
59  *
60  * @{
61  */
62 
63 /**
64  * \brief SLCD callback type
65  *
66  * Enum SLCD callback type.
67  */
68 enum slcd_callback_type {
69 	/** Frame Counter 0 Overflow callback */
70 	SLCD_CALLBACK_FC0_OVERFLOW = 0,
71 	/** Frame Counter 1 Overflow callback */
72 	SLCD_CALLBACK_FC1_OVERFLOW,
73 	/** Frame Counter 2 Overflow callback */
74 	SLCD_CALLBACK_FC2_OVERFLOW,
75 	/** VLCD Ready Toggle callback */
76 	SLCD_CALLBACK_VLCD_READY,
77 	/** VLCD Status Toggle callback */
78 	SLCD_CALLBACK_VLCD_TOGGLE,
79 	/** Pump Run Status Toggle callback */
80 	SLCD_CALLBACK_PUMP_TOGGLE,
81 };
82 
83 /** SLCD interrupt callback function type. */
84 typedef void (*slcd_callback_t)(enum slcd_callback_type type);
85 
86 /** \internal Max number of callback type. */
87 #define SLCD_CALLBACK_TYPE_NUM 6
88 
89 /** \name Callback Function
90  * @{
91  */
92 
93 enum status_code slcd_register_callback(
94 	const slcd_callback_t callback,
95 	const enum slcd_callback_type type);
96 
97 enum status_code slcd_unregister_callback(
98 	const slcd_callback_t callback,
99 	const enum slcd_callback_type type);
100 
101 /**
102  * \brief Enable an SLCD callback
103  *
104  * \param[in] type Callback source type
105  *
106  * \retval STATUS_OK  The function exited successfully
107  * \retval STATUS_ERR_INVALID_ARG  If an invalid callback type was supplied
108  */
slcd_enable_callback(const enum slcd_callback_type type)109 static inline void slcd_enable_callback(const enum slcd_callback_type type)
110 {
111 	if (type < SLCD_CALLBACK_TYPE_NUM){
112 		SLCD->INTENSET.reg = 1 << type;
113 	}
114 }
115 
116 /**
117  * \brief Disable an SLCD callback
118  *
119  * \param[in]  type Callback source type
120  *
121  * \retval STATUS_OK  The function exited successfully
122  * \retval STATUS_ERR_INVALID_ARG  If an invalid callback type was supplied
123  */
slcd_disable_callback(const enum slcd_callback_type type)124 static inline void slcd_disable_callback(const enum slcd_callback_type type)
125 {
126 	if (type < SLCD_CALLBACK_TYPE_NUM){
127 		SLCD->INTENCLR.reg = 1 << type;
128 	}
129 }
130 
131 /** @} */
132 
133 /** @} */
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif  /* SLCD_CALLBACK_H_INCLUDED */
139