- Timestamp:
- Sep 14, 2020, 6:36:03 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub_riscv/trunk/asp_baseplatform/pdic/k210/dvp.c
r453 r458 66 66 67 67 #define DEAFULT_CLEAR_INT (DVP_STS_FRAME_START | DVP_STS_FRAME_START_WE | \ 68 68 DVP_STS_FRAME_FINISH | DVP_STS_FRAME_FINISH_WE) 69 69 70 70 … … 75 75 { 76 76 uint32_t clk_sel0 = sil_rew_mem((uint32_t *)(TADR_SYSCTL_BASE+TOFF_CLK_SEL0)); 77 78 77 uint32_t source = 0; 78 uint32_t result = 0; 79 79 uint32_t threshold = 0; 80 80 … … 97 97 result = source / (threshold + 1); 98 98 syslog_2(LOG_NOTICE, "## dvp_clock_get_freq req(%d) result(%d) ##", clock, result); 99 99 return result; 100 100 } 101 101 … … 104 104 { 105 105 while(sil_rew_mem((uint32_t *)(hdvp->base+TOFF_DVP_STS)) & DVP_STS_SCCB_EN) 106 106 ; 107 107 sil_wrw_mem((uint32_t *)(hdvp->base+TOFF_DVP_STS), (DVP_STS_SCCB_EN | DVP_STS_SCCB_EN_WE)); 108 109 108 while (sil_rew_mem((uint32_t *)(hdvp->base+TOFF_DVP_STS)) & DVP_STS_SCCB_EN) 109 ; 110 110 } 111 111 … … 150 150 tmp = sil_rew_mem((uint32_t *)(hdvp->base+TOFF_DVP_SCCB_CFG)) & (~DVP_SCCB_BYTE_NUM_MASK); 151 151 152 152 if (hdvp->Init.num_sccb_reg == 8) 153 153 tmp |= DVP_SCCB_BYTE_NUM_2; 154 154 else … … 164 164 sil_wrw_mem((uint32_t *)(hdvp->base+TOFF_DVP_SCCB_CTL), tmp); 165 165 166 166 dvp_sccb_start_transfer(hdvp); 167 167 168 168 sil_wrw_mem((uint32_t *)(hdvp->base+TOFF_DVP_SCCB_CTL), addr); 169 169 170 170 dvp_sccb_start_transfer(hdvp); 171 171 172 172 tmp = sil_rew_mem((uint32_t *)(hdvp->base+TOFF_DVP_SCCB_CFG)); … … 182 182 dvp_init(DVP_Handle_t *hdvp) 183 183 { 184 184 uint32_t v_apb1_clk, v_period; 185 185 186 186 if(hdvp == NULL) … … 201 201 fpioa_set_function(hdvp->Init.SccbSdaPin, FUNC_SCCB_SDA); 202 202 203 204 205 206 207 208 203 /* Do a power cycle */ 204 dvp_dcmi_powerdown(hdvp, false); 205 dly_tsk(10); 206 207 dvp_dcmi_powerdown(hdvp, true); 208 dly_tsk(100); 209 209 210 210 /* … … 372 372 cfg = sil_rew_mem((uint32_t *)(hdvp->base+TOFF_DVP_CFG)); 373 373 cfg &= ~(DVP_CFG_HREF_BURST_NUM_MASK | DVP_CFG_LINE_NUM_MASK); 374 375 376 374 cfg |= hdvp->Init.Height << 20; 375 376 if((cfg & DVP_CFG_BURST_SIZE_4BEATS) != 0) 377 377 divw = 4; 378 378 else 379 379 divw = 1; 380 380 cfg |= (hdvp->Init.Width / 8 / divw) << 12; 381 381 sil_wrw_mem((uint32_t *)(hdvp->base+TOFF_DVP_CFG), cfg); 382 382 return E_OK; 383 383 } … … 403 403 404 404 sccb_cfg = sil_rew_mem((uint32_t *)(hdvp->base+TOFF_DVP_SCCB_CFG)); 405 406 405 sccb_cfg &= ~(DVP_SCCB_SCL_LCNT_MASK | DVP_SCCB_SCL_HCNT_MASK); 406 sccb_cfg |= (v_period_clk_cnt << 8) | (v_period_clk_cnt << 16); 407 407 sil_wrw_mem((uint32_t *)(hdvp->base+TOFF_DVP_SCCB_CFG), sccb_cfg); 408 408 return dvp_clock_get_freq(DVP_CLOCK_REQ) / (v_period_clk_cnt * 2); … … 454 454 uint32_t istatus, estatus; 455 455 456 if(hdvp == NULL) 456 if (hdvp == NULL) { 457 syslog_0(LOG_NOTICE, "dvp_handler hdvp == NULL"); 457 458 return; 459 } 458 460 istatus = sil_rew_mem((uint32_t *)(hdvp->base+TOFF_DVP_STS)); 459 if(istatus == 0) 461 if (istatus == 0) { 462 syslog_0(LOG_DEBUG, "dvp_handler istatus == 0"); 460 463 return; 464 } 461 465 estatus = istatus; 462 syslog_2(LOG_DEBUG, " sensor_irqistatus[%08x] hdvp->state(%d)", istatus, hdvp->state);466 syslog_2(LOG_DEBUG, "dvp_handler istatus[%08x] hdvp->state(%d)", istatus, hdvp->state); 463 467 if((istatus & DVP_STS_FRAME_FINISH) != 0){ //frame end 464 468 estatus |= DVP_STS_FRAME_FINISH_WE; … … 469 473 if((istatus & DVP_STS_FRAME_START) != 0){ //frame start 470 474 estatus |= DVP_STS_FRAME_START_WE; 471 475 if(hdvp->state == DVP_STATE_ACTIVATE){ //only we finish the convert, do transmit again 472 476 /* 473 477 * コンバートスタート … … 479 483 sil_orw_mem((uint32_t *)(hdvp->base+TOFF_DVP_STS), estatus); 480 484 } 481 482
Note:
See TracChangeset
for help on using the changeset viewer.