2021-12-31 12:20:19 +00:00
|
|
|
#ifndef __GEN_H__
|
|
|
|
#define __GEN_H__
|
|
|
|
/*
|
|
|
|
* gen.h
|
|
|
|
*
|
|
|
|
* Created: Dec 2021
|
|
|
|
* Author: Arjan te Marvelde
|
|
|
|
*
|
|
|
|
* See gen.c for more information
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define OUTA 0 // Channel A indicator
|
|
|
|
#define OUTB 1 // Channel B indicator
|
|
|
|
|
2022-02-18 16:39:48 +00:00
|
|
|
#define GEN_MINBUFLEN 20 // Minimum nr of byte samples
|
|
|
|
#define GEN_MAXBUFLEN 2000 // Maximum buffer size (byte samples)
|
2021-12-31 12:20:19 +00:00
|
|
|
|
2022-02-18 16:39:48 +00:00
|
|
|
|
|
|
|
extern float _fsys;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The structure that defines the waveform input to wfg_play.
|
|
|
|
* Note that the buffer needs to contain 4N bytes, i.e. needs to be 32bit aligned.
|
|
|
|
* For high frequencies, the minimum buffer length is in the order of 32 bytes (buflen=8).
|
|
|
|
*/
|
2021-12-31 12:20:19 +00:00
|
|
|
typedef struct wfg
|
|
|
|
{
|
2022-02-18 16:39:48 +00:00
|
|
|
uint8_t *buf; // Points to waveform buffer
|
|
|
|
uint32_t len; // Buffer length in byte samples
|
|
|
|
float dur; // Duration of buffer, in seconds
|
2021-12-31 12:20:19 +00:00
|
|
|
} wfg_t;
|
|
|
|
|
2022-02-18 16:39:48 +00:00
|
|
|
/* Initialize both channels */
|
|
|
|
void gen_init(void);
|
2021-12-31 12:20:19 +00:00
|
|
|
|
2022-02-18 16:39:48 +00:00
|
|
|
/* Play a waveform on the channel indicated by output */
|
|
|
|
void gen_play(int output, wfg_t *wave);
|
2021-12-31 12:20:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|