嗨,对话
我想使用DMA来做i2c的高级数据传输,da14586为机器模式。
已经阅读你们的sdk / platform / driver / dma / dma.ch提供的运动和sdk / plation / driver / pdm /pdm_mic.ch对pdm的使用,同时看到你相相关的帖子https://support.dialog-semicondiondiondiondum/forums/post/dialog-smartbond-bl.......,我已经配置了i2c和dma的相关动力,但不知道怎么使用I2C开始通讯DMA行行读与写的作用。当然模式问能否相关联的动机代码,或者问能否相相的动感代码,或者。的仪器的配置配置读写程进程?
下面是我觉得的我的dma的代码
1,DMA初始化部分:
138静态void DMA_INIT(UINT32_T *缓冲区,UINT16_T长度)
139 {
140 dma_setup_for_pdm_to_buffer.channel_number = dma_channel_0;
141 dma_setup_for_pdm_to_buffer.src_address =(uint32_t)i2c_data_cmd_reg;
142.
143 dma_setup_for_pdm_to_buffer.a_inc = dma_ainc_false;
144 dma_setup_for_pdm_to_buffer.b_inc = dma_binc_true;
145 dma_setup_for_pdm_to_buffer.bus_width = dma_bw_halfword;
146 dma_setup_for_pdm_to_buffer.callback = dma_callback;
147 dma_setup_for_pdm_to_buffer.dma_idle = dma_idle_interrupting_mode;
148 dma_setup_for_pdm_to_buffer.dma_init = dma_init_ax_bx_ay_by;
149 dma_setup_for_pdm_to_buffer.dma_prio = dma_prio_3;
150 dma_setup_for_pdm_to_buffer.dma_req_mux = dma_trig_i2c_rxtx;
151 //dma_setup_for_pdm_to_buffer.dreq_mode = dma_dreq_start;
152 dma_setup_for_pdm_to_buffer.dreq_mode = dma_dreq_triggered;
153 dma_setup_for_pdm_to_buffer.irq_enable = dma_irq_state_enabled;
154 dma_setup_for_pdm_to_buffer.user_data = null;
155 dma_setup_for_pdm_to_buffer.dma_sense = dma_sense_level_ssistive;
156.
157 dma_setup_for_pdm_to_buffer.circular =(mic_circular == true)?dma_mode_circular:dma_mode_normal;
158 dma_setup_for_pdm_to_buffer.length = length;
159 dma_setup_for_pdm_to_buffer.dest_address =(uint32_t)缓冲区;
160 dma_setup_for_pdm_to_buffer.irq_nr_of_trans = mic_int_threshold;
161.
162 dma_channel_initialization(&dma_setup_for_pdm_to_buffer);
163}
2,DMA中断回调分
120 void dma_callback(void * user_data,uint16_t len)
121 {
123 pr_bug(“\ n%s:start \ n”,__func__);
136}
3,I2C和DMA初始化
175 void i2c_dma_master_init(uint16_t dev_address,uint8_t speed,uint8_t地址_mode,uint8_t地址_size)
176 {
177 DMA_INIT((UINT32_T *)按下_BUFF,16);
178 dma_channel_enable(dma_setup_for_pdm_to_buffer.channel_number,dma_state_enabled);
179.
180 setbits16(clk_per_reg,i2c_enable,1);//为i2c启用时钟
181 setword16(i2c_enable_reg,0x0);//禁用I2C控制器
182.
183 setword16(i2c_con_reg,i2c_master_mode | i2c_slave_disable | i2c_restart_en);//从站被禁用
184 setbits16(i2c_con_reg,i2c_speed,speed);//设置速度
185 #ifdef i2c_ss_freq_trim.
186 setword16(i2c_ss_scl_hcnt_reg,i2c_ss_scl_hcnt_val);//设置标准速度的SCL时钟高周期计数
187 setword16(i2c_ss_scl_lcnt_reg,i2c_ss_scl_lcnt_val);//设置标准速度的SCL时钟低周期计数
188 #ENDIF // I2C_SS_FREQ_TRIM
189 #ifdef i2c_fs_freq_trim.
190 setword16(i2c_fs_scl_hcnt_reg,i2c_fs_scl_hcnt_val);//将SCL时钟高周期计数设置为快速速度
191 setword16(i2c_fs_scl_lcnt_reg,i2c_fs_scl_lcnt_val);//设置快速速度的SCL时钟低周期计数
192 #ENDIF // I2C_HS_FREQ_TRIM
193 setbits16(i2c_con_reg,i2c_10bitaddr_master,address_mode);//设置寻址模式
194 setword16(i2c_tar_reg,dev_address&0x3ff);//设置从设备地址
195 setword16(i2c_rx_tl_reg,rx_tl);
196 i2c_dev_address = dev_address;
197.
198 setword16(i2c_dma_cr_reg,rdmae | tdmae);
199 setword16(i2c_dma_tdlr_reg,dmatdl);
200 setword16(i2c_dma_rdlr_reg,dmardl);
201.
202 setword16(i2c_enable_reg,0x1);//启用I2C控制器
203.
204 #IF 0.
205 setword16(i2c_enable_reg,0x1);//启用I2C控制器
206 wait_until_no_master_activity();//等待i2c主fsm变得空闲
207 #ENDIF.
208.
209.
210#如果1
211如果(wait_until_no_master_actity()!= 0){
212 pr_err(“%s:等待没有主活动错误\ n”,__func__);
213}
214.
215 if(i2c_send_command(start_press_scnne_cmd)!= 0){
216 pr_err(“%s:i2c发送命令\ n”,__func__);
217}
218.
219 UINT32_T TMP_SIZE = I2C_FIFO_SIZE;
220 uint32_t tmp_cmd = read_press_frame_cmd;
221 UINT8_T * TMP_BUF =按_BUFF;
222 int ret = read_data_single(&tmp_buf,tmp_cmd,tmp_size);
223 PR_BUG(“按SCANN RETVAL(%d)\ n”,RET);
224 #endif.
225}
上行的i2c代码使使使可用,但
以上代码可以初始后,我不再怎么i2c dma开工工作?而且dma中间参数数目也销有用吗?
请问我改怎么动机DMA I2C开始传输?
谢谢。
你好,先生,
我可以有手机和邮件地址吗?
嗨Jelphi.
电话:+8618605514330
邮件:582883253@qq.com.