1 /**
2  * @file    cameraif.h
3  * @brief   CAMERAIF function prototypes and data types.
4  */
5 
6 /******************************************************************************
7  *
8  * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
9  * Analog Devices, Inc.),
10  * Copyright (C) 2023-2024 Analog Devices, Inc.
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  *     http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  *
24  ******************************************************************************/
25 
26 /* Define to prevent redundant inclusion */
27 #ifndef LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX78000_CAMERAIF_H_
28 #define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX78000_CAMERAIF_H_
29 
30 /* **** Includes **** */
31 #include "mxc_device.h"
32 #include "cameraif_regs.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /**
39  * @defgroup cameraif
40  * @ingroup periphlibs
41  * @{
42  */
43 
44 /* **** Definitions **** */
45 
46 /**
47  * @brief   The list of Camera Interface Datawidth options supported
48  *
49  */
50 typedef enum {
51     MXC_PCIF_DATAWIDTH_8_BIT = 0, ///<
52     MXC_PCIF_DATAWIDTH_10_BIT, ///<
53     MXC_PCIF_DATAWIDTH_12_BIT, ///<
54 } mxc_pcif_datawidth_t;
55 
56 /**
57  * @brief   The list of Camera GPIO Datawidth options supported
58  *
59  */
60 typedef enum {
61     MXC_PCIF_GPIO_DATAWIDTH_8_BIT = 0, ///<
62     MXC_PCIF_GPIO_DATAWIDTH_10_BIT, ///<
63     MXC_PCIF_GPIO_DATAWIDTH_12_BIT, ///<
64 } mxc_pcif_gpio_datawidth_t;
65 
66 /**
67  * @brief   The list of Camera Interface ReadMode options supported
68  *
69  */
70 typedef enum {
71     MXC_PCIF_READMODE_SINGLE_MODE = 1, ///<
72     MXC_PCIF_READMODE_CONTINUES_MODE, ///<
73 } mxc_pcif_readmode_t;
74 
75 /**
76  * @brief   The list of Camera Interface TimingSel options supported
77  *
78  */
79 typedef enum {
80     MXC_PCIF_TIMINGSEL_HSYNC_and_VSYNC = 0, ///<
81     MXC_PCIF_TIMINGSEL_SAV_and_EAV, ///<
82 } mxc_pcif_timingsel_t;
83 
84 /* **** Function Prototypes **** */
85 
86 /**
87  * @brief Initialize the Parallel Camera Interface.
88  *
89  * @param gpioDataWidth   Desired datawidth for the camera interface (8, 10 or 12 bits).
90  *
91  * @return E_NO_ERROR if successful, otherwise E_BAD_PARAM.
92  */
93 int MXC_PCIF_Init(mxc_pcif_gpio_datawidth_t gpioDataWidth);
94 
95 /**
96  * @brief   Set data width for the camera interface.
97  *
98  * @param  datawidth 8/10/12 bit
99  */
100 void MXC_PCIF_SetDataWidth(mxc_pcif_datawidth_t datawidth);
101 
102 /**
103  * @brief   Set the desired timing mode for the camera interface.
104  *
105  * @param  timingsel There are two different timing modes. HSYNC/VSYNC and Data Stream.
106  */
107 void MXC_PCIF_SetTimingSel(mxc_pcif_timingsel_t timingsel);
108 
109 /**
110  * @brief  Set camera FIFO threshold.
111  *
112  * @param  fifo_thrsh Desired FIFO threshold.
113  */
114 void MXC_PCIF_SetThreshold(int fifo_thrsh);
115 
116 /**
117  * @brief   Enable camera interrupts.
118  *
119  * @param  flags Interrupt flags
120  */
121 void MXC_PCIF_EnableInt(uint32_t flags);
122 
123 /**
124  * @brief  Disable camera interrupts.
125  *
126  * @param  flags Interrupt flags
127  */
128 void MXC_PCIF_DisableInt(uint32_t flags);
129 
130 /**
131  * @brief  Start to capture image from camera interface
132  *
133  * @param  readmode Single mode or Continues mode
134  */
135 void MXC_PCIF_Start(mxc_pcif_readmode_t readmode);
136 
137 /**
138  * @brief  Stop capture, disable Parallel camera interface
139  *
140  */
141 void MXC_PCIF_Stop(void);
142 
143 /**
144  * @brief   Read fifo of PCIF
145  *
146  * @return  Value of fifo
147  */
148 unsigned int MXC_PCIF_GetData(void);
149 
150 /**@} end of group cameraif */
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif // LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX78000_CAMERAIF_H_
157