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
32extern "C"{
33#endif
34
35#include "mikrosdk_version.h"
36
37#ifdef __GNUC__
38#if mikroSDK_GET_VERSION < 20800ul
39#include "rcu_delays.h"
40#else
41#include "delays.h"
42#endif
43#endif
44
45#include "drv_digital_out.h"
46#include "drv_digital_in.h"
47
63#define RECNPLAY2_DURATION_24S 24000
64
69#define RECNPLAY2_PIN_STATE_LOW 0x00
70#define RECNPLAY2_PIN_STATE_HIGH 0x01
71 // recnplay2_set
73
88#define RECNPLAY2_MAP_MIKROBUS( cfg, mikrobus ) \
89 cfg.rec = MIKROBUS( mikrobus, MIKROBUS_RST ); \
90 cfg.pe = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
91 cfg.pl = MIKROBUS( mikrobus, MIKROBUS_INT )
92 // recnplay2_map // recnplay2
95
100typedef struct
101{
102 digital_out_t rec;
103 digital_out_t pe;
104 digital_out_t pl;
106
111typedef struct
112{
113 pin_name_t rec;
114 pin_name_t pe;
115 pin_name_t pl;
118
123typedef enum
124{
126 RECNPLAY2_ERROR = -1
127
129
146
161
173
184void recnplay2_set_rec_pin ( recnplay2_t *ctx, uint8_t pin_state );
185
196void recnplay2_set_pe_pin ( recnplay2_t *ctx, uint8_t pin_state );
197
208void recnplay2_set_pl_pin ( recnplay2_t *ctx, uint8_t pin_state );
209
220err_t recnplay2_record_sound ( recnplay2_t *ctx, uint16_t rec_len );
221
232err_t recnplay2_play_sound ( recnplay2_t *ctx, uint16_t play_len );
233
234#ifdef __cplusplus
235}
236#endif
237#endif // RECNPLAY2_H
238 // recnplay2
240
241// ------------------------------------------------------------------------ END
void recnplay2_set_rec_pin(recnplay2_t *ctx, uint8_t pin_state)
Rec N Play 2 REC pin setting function.
err_t recnplay2_play_sound(recnplay2_t *ctx, uint16_t play_len)
Rec N Play 2 play recorded sounds function.
void recnplay2_set_pl_pin(recnplay2_t *ctx, uint8_t pin_state)
Rec N Play 2 PL pin setting function.
err_t recnplay2_init(recnplay2_t *ctx, recnplay2_cfg_t *cfg)
Rec N Play 2 initialization function.
err_t recnplay2_record_sound(recnplay2_t *ctx, uint16_t rec_len)
Rec N Play 2 record sound function.
void recnplay2_default_cfg(recnplay2_t *ctx)
Rec N Play 2 default configuration function.
void recnplay2_set_pe_pin(recnplay2_t *ctx, uint8_t pin_state)
Rec N Play 2 Pe pin setting function.
void recnplay2_cfg_setup(recnplay2_cfg_t *cfg)
Rec N Play 2 configuration object setup function.
recnplay2_return_value_t
Rec N Play 2 Click return value data.
Definition: recnplay2.h:124
@ RECNPLAY2_ERROR
Definition: recnplay2.h:126
@ RECNPLAY2_OK
Definition: recnplay2.h:125
Rec N Play 2 Click configuration object.
Definition: recnplay2.h:112
pin_name_t pe
Definition: recnplay2.h:114
pin_name_t pl
Definition: recnplay2.h:115
pin_name_t rec
Definition: recnplay2.h:113
Rec N Play 2 Click context object.
Definition: recnplay2.h:101
digital_out_t pl
Definition: recnplay2.h:104
digital_out_t rec
Definition: recnplay2.h:102
digital_out_t pe
Definition: recnplay2.h:103