summaryrefslogtreecommitdiff
path: root/bsp/wch/arm/libraries/CH32F20x_StdPeriph_Driver/StdPeriph_Driver/src/ch32f20x_dvp.c
blob: d44cfa7827c1a4f220fbc3f7af32804202df76cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/********************************** (C) COPYRIGHT  *******************************
* File Name          : ch32f20x_dvp.c
* Author             : WCH
* Version            : V1.0.0
* Date               : 2021/08/08
* Description        : This file provides all the DVP firmware functions. 
*******************************************************************************/ 
#include "ch32f20x_dvp.h"


/*******************************************************************************
* Function Name  : DVP_INTCfg
* Description    : DVP interrupt configuration
* Input          : s: interrupt enable
                    ENABLE
                    DISABLE
                   i: interrupt type
                    RB_DVP_IE_STP_FRM
                    RB_DVP_IE_FIFO_OV
                    RB_DVP_IE_FRM_DONE
                    RB_DVP_IE_ROW_DONE
                    RB_DVP_IE_STR_FRM
* Return         : None
*******************************************************************************/
void DVP_INTCfg( uint8_t s,  uint8_t i )
{
    if(s){
        DVP->IER |= i;
    }
    else{
        DVP->IER &= ~i;
    }
}

/*******************************************************************************
* Function Name  : DVP_Mode
* Description    : DVP mode
* Input          : s: data bit width
                    RB_DVP_D8_MOD
                    RB_DVP_D10_MOD
                    RB_DVP_D12_MOD
                   i: data mode
                    Video_Mode
                    JPEG_Mode
* Return         : None
*******************************************************************************/
void DVP_Mode( uint8_t s,  DVP_Data_ModeTypeDef i)
{
    DVP->CR0 &= ~RB_DVP_MSK_DAT_MOD;

    if(s){
        DVP->CR0 |= s;
    }
    else{
        DVP->CR0 &= ~((uint32_t)3<<4);
    }

    if(i){
        DVP->CR0 |= RB_DVP_JPEG;
    }
    else{
        DVP->CR0 &= ~RB_DVP_JPEG;
    }
}

/*******************************************************************************
* Function Name  : DVP_Cfg
* Description    : DVP configuration
* Input          : s:  DMA enable control
                    DVP_DMA_Enable
                    DVP_DMA_Disable
                   i: DVP all clear
                    DVP_FLAG_FIFO_RESET_Enable
                    DVP_FLAG_FIFO_RESET_Disable
                   j:  receive reset enable
                    DVP_RX_RESET_Enable
                    DVP_RX_RESET_Disable
* Return         : None
*******************************************************************************/
void DVP_Cfg( DVP_DMATypeDef s,  DVP_FLAG_FIFO_RESETTypeDef i, DVP_RX_RESETTypeDef j)
{
    switch( s )
    {
        case DVP_DMA_Enable:
            DVP->CR1 |= RB_DVP_DMA_EN;
            break;
        case DVP_DMA_Disable:
            DVP->CR1 &= ~RB_DVP_DMA_EN;
            break;
        default:
            break;
    }

    switch( i )
    {
        case DVP_RX_RESET_Enable:
            DVP->CR1 |= RB_DVP_ALL_CLR;
            break;
        case DVP_RX_RESET_Disable:
            DVP->CR1 &= ~RB_DVP_ALL_CLR;
            break;
        default:
            break;
    }

    switch( j )
    {
        case DVP_RX_RESET_Enable:
            DVP->CR1 |= RB_DVP_RCV_CLR;
            break;
        case DVP_RX_RESET_Disable:
            DVP->CR1 &= ~RB_DVP_RCV_CLR;
            break;
        default:
            break;
    }

}