2025-06-27 00:32:57 +08:00
|
|
|
|
#ifndef DAC_H__
|
|
|
|
|
|
#define DAC_H__
|
|
|
|
|
|
|
|
|
|
|
|
#include "stm32f4xx.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD>Ӧ<EFBFBD>Ķ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
//<2F><>ʱ<EFBFBD><CAB1>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>90Mhzʱ
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#define RATE11025 8163
|
|
|
|
|
|
#define RATE22050 4081
|
|
|
|
|
|
#define RATE44100 2041
|
2025-07-05 19:47:28 +08:00
|
|
|
|
#define RATE48000 1875 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
// dac <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#define DAC_VOL_MAX 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD>õĶ<C3B5>ʱ<EFBFBD><CAB1>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#define DAC_TIMER TIM4
|
|
|
|
|
|
#define DAC_TIMER_RCC RCC_APB1Periph_TIM4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _DAC_UserStruct
|
|
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
u32 *buff1; //buff<66>ĸ<EFBFBD>16λ<36><CEBB><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>16λ<36><CEBB><EFBFBD><EFBFBD>2
|
2025-06-27 00:32:57 +08:00
|
|
|
|
u32 *buff2;
|
|
|
|
|
|
int buff_size;
|
2025-07-05 19:47:28 +08:00
|
|
|
|
int buff_useing;// <09><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>ĸ<EFBFBD>buff
|
|
|
|
|
|
int buff_Invalid;// 1,<2C>п<EFBFBD><D0BF><EFBFBD>buff<66><66>0<EFBFBD><30><EFBFBD><EFBFBD><DEBF><EFBFBD>buff
|
|
|
|
|
|
int rate; //<2F><><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD>Ӧ<EFBFBD>Ķ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void (*call_back)(struct _DAC_UserStruct *u);
|
|
|
|
|
|
}DAC_UserStruct;
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
// <20><>˫<EFBFBD><CBAB><EFBFBD>巽ʽ<E5B7BD><CABD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD>ɹ<EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int DAC_NormalInit (DAC_UserStruct *dac);
|
|
|
|
|
|
|
|
|
|
|
|
void DAC_NormalDeInit (DAC_UserStruct *dac);
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><>ȡDAC<41><43><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
DAC_UserStruct *DAC_GetDacHander (void);
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>Ƶ<EFBFBD><C6B5>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
u16 DAC_GetRate (u16 rate);
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
// <20><><EFBFBD>仺<EFBFBD><E4BBBA><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>0<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>-1<><31>ʧ<EFBFBD><CAA7>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int DAC_FillBuff(int16_t *buf,int size,int nch);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
// <20><>fifo<66><6F>ʽ<EFBFBD><CABD>ʼ<EFBFBD><CABC>,<2C><><EFBFBD><EFBFBD>0<EFBFBD>ɹ<EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int DAC_FifolInit (void);
|
|
|
|
|
|
|
|
|
|
|
|
void DAC_FifoDeInit (void);
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
// <20><><EFBFBD>û<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int DAC_SetSetValuwFun(int (*fun)(uint16_t *));
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>0<EFBFBD>ɹ<EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int DAC_SaveValue(uint16_t value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|