2 /*
3 Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 /*
37 * ======== dgn2.h ========
38 * Generator Device Module Interface
39 */
41 #ifndef DGN2_
42 #define DGN2_
44 //#include <ti/bios/include/std.h>
45 #include <stddef.h>
46 #include "dev2.h"
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
52 extern __FAR__ DEV2_Fxns DGN2_FXNS;
54 /*
55 * ======== DGN2_Params ========
56 */
57 typedef struct { /* device parameters */
58 struct {
59 Int value; /* constant value */
60 } constant;
61 struct {
62 UInt32 seed; /* seed value */
63 Int lower; /* lower limit of generator */
64 Int upper; /* upper limit of generator */
65 } rand;
66 struct {
67 Int gain; /* gain */
68 Int freq; /* frequency (cycles / sec) */
69 Int phase; /* phase (in radians) */
70 Int rate; /* sample rate (samples / sec) */
71 } sine;
72 struct {
73 Fxn fxn; /* user function */
74 Arg arg; /* and argument */
75 } user;
76 } DGN2_Params;
78 typedef DGN2_Params DGN2_IParams;
80 extern __FAR__ DGN2_Params DGN2_PARAMS; /* default parameter values */
82 typedef struct DGN2_GenObj {
83 Fxn fxn;
84 Arg arg;
85 UInt32 seed; /* current seed value */
86 Int index; /* current index into sine value table */
87 Int step; /* the step for indexing the sine table */
88 Int shift; /* sine shift value to achieve gain */
89 DGN2_Params *dparams; /* parameters */
90 } DGN2_GenObj;
92 extern Void DGN2_iconst(DGN2_GenObj *gen, Int16 *addr, size_t size);
93 extern Void DGN2_irand(DGN2_GenObj *gen, Int16 *addr, size_t size);
94 extern Void DGN2_isine(DGN2_GenObj *gen, Int16 *addr, size_t size);
95 extern Void DGN2_printHex(Arg arg, Ptr addr, size_t size);
96 extern Void DGN2_user(DGN2_GenObj *gen, Ptr addr, size_t size);
98 #define DGN2_CONST (Int32)DGN2_iconst /* constant series device id */
99 #define DGN2_RAND (Int32)DGN2_irand /* random series device id */
100 #define DGN2_SINE (Int32)DGN2_isine /* sine wave device id */
101 #define DGN2_USER (Int32)DGN2_user /* user function */
103 #ifdef __cplusplus
104 }
105 #endif /* extern "C" */
107 #endif /* DGN2_ */