1 Star 0 Fork 0

lcofjp/Arduino-DTMF

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
analogWaveRev.h 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
lcofjp 提交于 2023-10-01 17:30 . initial commit
#ifndef ARDUINO_ANALOG_WAVE
#define ARDUINO_ANALOG_WAVE
#include "FspTimer.h"
#include "r_dtc.h"
#define SAMPLES_FOR_PREDEFINED_WAVE 24
#define WAVE_PRIORITY 1
#define WAVE_BUFFER_SIZE 1000
class analogWaveRev {
private:
FspTimer timer;
volatile uint32_t pin;
uint16_t *buffer;
uint8_t dac_bits;
uint8_t *samples8;
uint16_t *samples16;
uint32_t size;
volatile uint32_t index;
volatile float _amplitude;
volatile uint32_t _offset;
uint16_t freq1, freq2;
float delta_w1, delta_w2;
float w1 = 0, w2 = 0;
uint16_t wave_buffer[2][WAVE_BUFFER_SIZE];
int current_wave = 0;
uint16_t sample_rate;
double freq_max;
double dac_max_samp_rate;
dtc_instance_ctrl_t dtc_ctrl;
transfer_info_t dtc_info;
dtc_extended_cfg_t dtc_cfg_extend;
transfer_cfg_t dtc_cfg;
void init(pin_size_t p);
/* update the output with the next sample value */
// bool update();
void calc_wave(uint16_t *buf);
public:
/* constructor 1 with only DAC pin (to be used when predefined waveform are used) */
analogWaveRev(pin_size_t pinNumber);
/* constructor 2 with buffer to be used (sample in buffer are output ciclycally */
analogWaveRev(pin_size_t pinNumber, uint16_t *_buffer, uint32_t _size, uint32_t _offset);
bool begin(uint16_t _sample_rate);
/* updated the frequency used */
bool freq(uint16_t _freq1_hz, uint16_t _freq2_hz);
/* start the generation of sample */
void start();
/* stop the genration of sample */
void stop();
// void _pre_sync();
// void sine(float freq_hz);
void switch_buffer();
};
#endif
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/lcofjp/arduino-dtmf.git
git@gitee.com:lcofjp/arduino-dtmf.git
lcofjp
arduino-dtmf
Arduino-DTMF
master

搜索帮助