利用EZH驱动音频芯片WD588

EZH 类似一个独立的内核,但是需要使用汇编来实现代码的录入。

知识点1

EZH需要一段RAM来运行自己的程序,所以在分散加载文件中需要把这部分RAM独立出来
以“EZH_SECT”命名, 如下
ezh_wt588.c

define EZH_CODE attribute((section("EZH_SECT")))

分散加载文件格式,这里我们用SRAMX作为EZH代码的执行区域


image.png

知识点2

所有的代码是宏,通过IDE生成2进制的可执行文件。并不能用C来开发。

知识点3

对应的IO口需要配置为EZH模式,在LPC5410x上只有P0组的IO口可以被配置为EZH的接口
IOCON->PIO[0][WT588_DATA] = PINFUNC_EZH | 1<<7 | 1<<8;

核心API

void wt588_cmdset(uint32_t command)

command这里就是发送的index号

细节1

EZH GPIO配置,这里用的是PIO0_9,
#define WT588_DATA 9

细节2

WD588 初始化部分,注意这里的65000 需要根据内核的主频来做修改,我这里用的应该是96MHz的

E_BCLR_IMM(GPO, GPO, WT588_DATA)           // Set DATA IO to low for 5mS, start transfer    
E_HEART_RYTHM_IMM(65000)                   // set the timer initial value
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0
E_HEART_RYTHM_IMM(65000)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(65000)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(65000)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(65000)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(65000)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(65000)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(65000)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT    

细节3

// Transfer bit-8
E_LSR(R0, R4, 8)
E_AND_IMMS(R1, R0, 0x01)            
E_COND_GOTOL(AZ, set1)                      // If above Zero
E_COND_GOTOL(ZE, set0)                      // If Zero or Below

这段代码开始 就是按照每一个bit上是0还是1,

如果是0 则去set0 处,如果是1 则去set1 处

set0

E_BSET_IMM(GPO, GPO, WT588_DATA)           // Set DATAIO to high
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT    
E_BCLR_IMM(GPO, GPO, WT588_DATA)           // Set DATAIO to low     
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 600uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT   

E_GOTO_REG(RA)

set1

E_BSET_IMM(GPO, GPO, WT588_DATA)           // Set DATAIO to high
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 600uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(7225)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT   

E_BCLR_IMM(GPO, GPO, WT588_DATA)           // Set DATAIO to low 
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0 
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT                            // wait for the timer decreate to 0  
E_HEART_RYTHM_IMM(2406)                    // set the timer initial value: 200uS
E_WAIT_FOR_BEAT   
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。