recnplay2  2.1.0.0
recnplay2.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef RECNPLAY2_H
29 #define RECNPLAY2_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 
67 #define RECNPLAY2_DURATION_24S 24000
68 
73 #define RECNPLAY2_PIN_STATE_LOW 0x00
74 #define RECNPLAY2_PIN_STATE_HIGH 0x01
75  // recnplay2_set
77 
92 #define RECNPLAY2_MAP_MIKROBUS( cfg, mikrobus ) \
93  cfg.rec = MIKROBUS( mikrobus, MIKROBUS_RST ); \
94  cfg.pe = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
95  cfg.pl = MIKROBUS( mikrobus, MIKROBUS_INT )
96  // recnplay2_map // recnplay2
99 
104 typedef struct
105 {
106  digital_out_t rec;
107  digital_out_t pe;
108  digital_out_t pl;
109 } recnplay2_t;
110 
115 typedef struct
116 {
117  pin_name_t rec;
118  pin_name_t pe;
119  pin_name_t pl;
122 
127 typedef enum
128 {
130  RECNPLAY2_ERROR = -1
131 
133 
150 
165 
177 
188 void recnplay2_set_rec_pin ( recnplay2_t *ctx, uint8_t pin_state );
189 
200 void recnplay2_set_pe_pin ( recnplay2_t *ctx, uint8_t pin_state );
201 
212 void recnplay2_set_pl_pin ( recnplay2_t *ctx, uint8_t pin_state );
213 
224 err_t recnplay2_record_sound ( recnplay2_t *ctx, uint16_t rec_len );
225 
236 err_t recnplay2_play_sound ( recnplay2_t *ctx, uint16_t play_len );
237 
238 #ifdef __cplusplus
239 }
240 #endif
241 #endif // RECNPLAY2_H
242  // recnplay2
244 
245 // ------------------------------------------------------------------------ END
recnplay2_t
Rec N Play 2 Click context object.
Definition: recnplay2.h:105
recnplay2_set_pl_pin
void recnplay2_set_pl_pin(recnplay2_t *ctx, uint8_t pin_state)
Rec N Play 2 PL pin setting function.
recnplay2_t::pe
digital_out_t pe
Definition: recnplay2.h:107
recnplay2_cfg_setup
void recnplay2_cfg_setup(recnplay2_cfg_t *cfg)
Rec N Play 2 configuration object setup function.
recnplay2_cfg_t::pl
pin_name_t pl
Definition: recnplay2.h:119
recnplay2_cfg_t::pe
pin_name_t pe
Definition: recnplay2.h:118
RECNPLAY2_OK
@ RECNPLAY2_OK
Definition: recnplay2.h:129
RECNPLAY2_ERROR
@ RECNPLAY2_ERROR
Definition: recnplay2.h:130
recnplay2_cfg_t
Rec N Play 2 Click configuration object.
Definition: recnplay2.h:116
recnplay2_default_cfg
void recnplay2_default_cfg(recnplay2_t *ctx)
Rec N Play 2 default configuration function.
recnplay2_init
err_t recnplay2_init(recnplay2_t *ctx, recnplay2_cfg_t *cfg)
Rec N Play 2 initialization function.
recnplay2_record_sound
err_t recnplay2_record_sound(recnplay2_t *ctx, uint16_t rec_len)
Rec N Play 2 record sound function.
recnplay2_t::rec
digital_out_t rec
Definition: recnplay2.h:106
recnplay2_cfg_t::rec
pin_name_t rec
Definition: recnplay2.h:117
recnplay2_set_rec_pin
void recnplay2_set_rec_pin(recnplay2_t *ctx, uint8_t pin_state)
Rec N Play 2 REC pin setting function.
recnplay2_t::pl
digital_out_t pl
Definition: recnplay2.h:108
recnplay2_return_value_t
recnplay2_return_value_t
Rec N Play 2 Click return value data.
Definition: recnplay2.h:128
recnplay2_play_sound
err_t recnplay2_play_sound(recnplay2_t *ctx, uint16_t play_len)
Rec N Play 2 play recorded sounds function.
recnplay2_set_pe_pin
void recnplay2_set_pe_pin(recnplay2_t *ctx, uint8_t pin_state)
Rec N Play 2 Pe pin setting function.