38928e0b74a301ca45701a4c731549162894011f
[apps/agl-service-unicens.git] / ucs2-vol / inc / libmostvolume.h
1 /*
2  * libmostvolume example
3  *
4  * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  * You may also obtain this software under a propriety license from Microchip.
20  * Please contact Microchip for further information.
21  *
22  */
23
24 #ifndef LIB_MOST_VOLUME_H
25 #define LIB_MOST_VOLUME_H
26
27 #include "ucs_api.h"
28
29 #ifdef  __cplusplus
30 extern "C" {
31 #endif
32
33 /** Describes the volume control */
34 enum lib_most_volume_channel_t{
35     LIB_MOST_VOLUME_CH_FRONT_LEFT   = 0,
36     LIB_MOST_VOLUME_CH_FRONT_RIGHT  = 1,
37     LIB_MOST_VOLUME_CH_REAR_LEFT    = 2,
38     LIB_MOST_VOLUME_CH_REAR_RIGHT   = 3,
39     LIB_MOST_VOLUME_CH_CENTER       = 4,
40     LIB_MOST_VOLUME_CH_SUB          = 5,
41     LIB_MOST_VOLUME_MASTER          = 6
42 };
43
44 /** Is fired when the application shall call "lib_most_volume_service()" after a certain time
45   * \param timeout  Time in ms after which the application shall call lib_most_volume_service().
46   *                 Valid values:
47   *                 0x0000: as soon as possible,
48   *                 0x0001..0xFFFE: timeout in ms,
49   *                 0xFFFF: never
50   */
51 typedef void (*lib_most_volume_service_cb_t)(uint16_t timeout);
52
53 /** Initializes the library
54   * \param   UNICENS_inst       Reference to the UNICENS instance, created by the application.
55   * \param   req_service_fptr   Callback function which is fired if the application shall call
56   *                             lib_most_volume_service.
57   * \return  '0' on success, otherwise value >'0'.
58   */
59 extern uint8_t lib_most_volume_init(Ucs_Inst_t *UNICENS_inst, lib_most_volume_service_cb_t req_service_fptr);
60
61 /** Terminates the library
62   * \return  '0' on success, otherwise value >'0'.
63   */
64 extern uint8_t lib_most_volume_exit(void);
65
66 /** Sets a single volume value.
67   * \param   channel        The volume control to be set.
68   * \param   volume         The volume value to be set. Valid values: 0..255.
69   * \return  '0' on success, otherwise value >'0'.
70   */
71 extern uint8_t lib_most_volume_set(enum lib_most_volume_channel_t channel, uint8_t volume);
72
73 /** Shall be called either cyclically (e.g. 50ms -> polling) or after "timeout"
74   * when "service_fptr" is fired (-> event triggered).
75   * \return  '0' on success, otherwise value >'0'.
76   */
77 extern uint8_t lib_most_volume_service(void);
78
79 #ifdef  __cplusplus
80 }
81 #endif
82
83 #endif  /* LIB_MOST_VOLUME_H */
84