M480 BSP V3.05.006
The Board Support Package for M480 Series
ccap.c
Go to the documentation of this file.
1/**************************************************************************/
10#include "NuMicro.h"
19int32_t g_CCAP_i32ErrCode = 0;
59void CCAP_Open(uint32_t u32InFormat, uint32_t u32OutFormet)
60{
61 CCAP->PAR = (CCAP->PAR & ~(0x000007BFUL)) | u32InFormat;
62 CCAP->CTL = (CCAP->CTL & ~(0x00000040UL)) | u32OutFormet;
63}
64
80void CCAP_SetCroppingWindow(uint32_t u32VStart,uint32_t u32HStart, uint32_t u32Height, uint32_t u32Width)
81{
83 | (((u32VStart << 16) | u32HStart));
84
85 CCAP->CWS = (CCAP->CWS & ~(CCAP_CWS_CWH_Msk | CCAP_CWS_CWW_Msk))
86 | ((u32Height << 16)| u32Width);
87}
88
89
99void CCAP_SetPacketBuf(uint32_t u32Address )
100{
101 CCAP->PKTBA0 = u32Address;
103}
104
110void CCAP_Close(void)
111{
112 CCAP->CTL &= ~CCAP_CTL_CCAPEN;
113}
114
115
130void CCAP_EnableInt(uint32_t u32IntMask)
131{
133 | u32IntMask;
134}
135
151void CCAP_DisableInt(uint32_t u32IntMask)
152{
153 CCAP->INT = (CCAP->INT & ~(u32IntMask) ) ;
154}
155
156
166void CCAP_EnableMono(uint32_t u32Interface)
167{
168 CCAP->CTL = (CCAP->CTL & ~CCAP_CTL_MY8_MY8) | CCAP_CTL_MONO_Msk |u32Interface;
169}
170
178{
179 CCAP->CTL &= ~CCAP_CTL_MONO_Msk;
180}
181
190void CCAP_EnableLumaYOne(uint32_t u32th)
191{
193 CCAP->LUMA_Y1_THD = u32th & 0xff;
194}
195
203{
204 CCAP->CTL &= ~CCAP_CTL_Luma_Y_One_Msk;
205}
206
212void CCAP_Start(void)
213{
214 CCAP->CTL |= CCAP_CTL_CCAPEN;
215}
216
229void CCAP_Stop(uint32_t u32FrameComplete)
230{
231 uint32_t u32Delay = SystemCoreClock * 2; /* 2 second */
232
234 if(u32FrameComplete==FALSE)
235 CCAP->CTL &= ~CCAP_CTL_CCAPEN;
236 else
237 {
239 while(!CCAP_IS_STOPPED())
240 {
241 u32Delay--;
242 if(u32Delay == 0){
244 break;
245 }
246 }
247 }
248}
249
264void CCAP_SetPacketScaling(uint32_t u32VNumerator, uint32_t u32VDenominator, uint32_t u32HNumerator, uint32_t u32HDenominator)
265{
266 uint32_t u32NumeratorL, u32NumeratorH;
267 uint32_t u32DenominatorL, u32DenominatorH;
268
269 u32NumeratorL = u32VNumerator&0xFF;
270 u32NumeratorH=u32VNumerator>>8;
271 u32DenominatorL = u32VDenominator&0xFF;
272 u32DenominatorH = u32VDenominator>>8;
274 | ((u32NumeratorL << 24)| (u32DenominatorL << 16));
276 | ((u32NumeratorH << 24) | (u32DenominatorH << 16));
277
278 u32NumeratorL = u32HNumerator&0xFF;
279 u32NumeratorH=u32HNumerator>>8;
280 u32DenominatorL = u32HDenominator&0xFF;
281 u32DenominatorH = u32HDenominator>>8;
283 | ((u32NumeratorL << 8)| u32DenominatorL);
285 | ((u32NumeratorH << 8) | u32DenominatorH);
286}
287
297void CCAP_SetPacketStride(uint32_t u32Stride )
298{
299 CCAP->STRIDE = (CCAP->STRIDE & ~CCAP_STRIDE_PKTSTRIDE_Msk) | u32Stride;
300}
301
302 /* end of group CCAP_EXPORTED_FUNCTIONS */
304 /* end of group CCAP_Driver */
306 /* end of group Standard_Driver */
308
309/*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
NuMicro peripheral access layer header file.
int32_t g_CCAP_i32ErrCode
Definition: ccap.c:19
#define CCAP_CTL_CCAPEN
Definition: ccap.h:32
#define CCAP_TIMEOUT_ERR
Definition: ccap.h:91
void CCAP_EnableInt(uint32_t u32IntMask)
Set CCAP Interrupt.
Definition: ccap.c:130
void CCAP_EnableMono(uint32_t u32Interface)
Enable Monochrome CMOS Sensor.
Definition: ccap.c:166
#define CCAP_IS_STOPPED()
Is CCAP module Enable.
Definition: ccap.h:109
void CCAP_DisableMono(void)
Disable Monochrome CMOS Sensor.
Definition: ccap.c:177
void CCAP_SetPacketScaling(uint32_t u32VNumerator, uint32_t u32VDenominator, uint32_t u32HNumerator, uint32_t u32HDenominator)
Set Packet Scaling Vertical and Horizontal Factor Register.
Definition: ccap.c:264
void CCAP_Close(void)
Close Camera Capture Interface.
Definition: ccap.c:110
void CCAP_Stop(uint32_t u32FrameComplete)
Stop Camera Capture Interface.
Definition: ccap.c:229
void CCAP_Start(void)
Start Camera Capture Interface.
Definition: ccap.c:212
void CCAP_SetPacketBuf(uint32_t u32Address)
Set System Memory Packet Base Address0 Register.
Definition: ccap.c:99
void CCAP_DisableInt(uint32_t u32IntMask)
Disable CCAP Interrupt.
Definition: ccap.c:151
void CCAP_DisableLumaYOne(void)
Disable Luminance 8-bit Y to 1-bit Y Conversion.
Definition: ccap.c:202
void CCAP_SetCroppingWindow(uint32_t u32VStart, uint32_t u32HStart, uint32_t u32Height, uint32_t u32Width)
Set Cropping Window Starting Address and Size.
Definition: ccap.c:80
void CCAP_EnableLumaYOne(uint32_t u32th)
Enable Luminance 8-bit Y to 1-bit Y Conversion.
Definition: ccap.c:190
void CCAP_Open(uint32_t u32InFormat, uint32_t u32OutFormet)
Open engine clock and sensor clock.
Definition: ccap.c:59
void CCAP_SetPacketStride(uint32_t u32Stride)
Set Packet Frame Output Pixel Stride Width.
Definition: ccap.c:297
#define FALSE
Boolean false, define to use in API parameters or return value.
Definition: M480.h:609
#define CCAP
Definition: M480.h:458
#define CCAP_PKTSM_PKTSHMH_Msk
Definition: ccap_reg.h:864
#define CCAP_PKTSL_PKTSHML_Msk
Definition: ccap_reg.h:822
#define CCAP_CWSP_CWSADDRV_Msk
Definition: ccap_reg.h:814
#define CCAP_CTL_MONO_Msk
Definition: ccap_reg.h:736
#define CCAP_PKTSL_PKTSHNL_Msk
Definition: ccap_reg.h:825
#define CCAP_INT_VIEN_Msk
Definition: ccap_reg.h:802
#define CCAP_PKTSM_PKTSVMH_Msk
Definition: ccap_reg.h:870
#define CCAP_CWS_CWW_Msk
Definition: ccap_reg.h:817
#define CCAP_PKTSL_PKTSVML_Msk
Definition: ccap_reg.h:828
#define CCAP_PKTSM_PKTSHNH_Msk
Definition: ccap_reg.h:867
#define CCAP_PKTSM_PKTSVNH_Msk
Definition: ccap_reg.h:873
#define CCAP_CWS_CWH_Msk
Definition: ccap_reg.h:819
#define CCAP_INT_MEIEN_Msk
Definition: ccap_reg.h:805
#define CCAP_PKTSL_PKTSVNL_Msk
Definition: ccap_reg.h:831
#define CCAP_INT_ADDRMIEN_Msk
Definition: ccap_reg.h:808
#define CCAP_CTL_UPDATE_Msk
Definition: ccap_reg.h:751
#define CCAP_CTL_SHUTTER_Msk
Definition: ccap_reg.h:739
#define CCAP_CWSP_CWSADDRH_Msk
Definition: ccap_reg.h:811
#define CCAP_CTL_Luma_Y_One_Msk
Definition: ccap_reg.h:748
uint32_t SystemCoreClock
Definition: system_M480.c:21