Added USB controller firmware with USB C reversal support

master
gaurav 2022-06-13 20:58:35 +02:00
parent 675f6605f2
commit 907b713329
18 changed files with 7063 additions and 0 deletions

View File

@ -0,0 +1,96 @@
/*
## Cypress FX3 Camera Kit source file (camera_ptzcontrol.c)
## ===========================
##
## Copyright Cypress Semiconductor Corporation, 2010-2012,
## All Rights Reserved
## UNPUBLISHED, LICENSED SOFTWARE.
##
## CONFIDENTIAL AND PROPRIETARY INFORMATION
## WHICH IS THE PROPERTY OF CYPRESS.
##
## Use of this file is governed
## by the license agreement included in the file
##
## <install>/license/license.txt
##
## where <install> is the Cypress software
## installation root directory path.
##
## ===========================
*/
/*
* This file contains function stubs that can be filled in to implement Pan, Tilt
* and Zoom controls for the UVC camera application. These functions have not been
* implemented for the image sensor as of now.
*/
#include "uvc.h"
#include "camera_ptzcontrol.h"
#ifdef UVC_PTZ_SUPPORT
int32_t pan_cur; /* Current pan value. */
int32_t tilt_cur; /* Current tilt value. */
uint16_t zoom_cur; /* Current zoom value. */
void
CyFxUvcAppPTZInit (
void)
{
/* Initialize the Pan, Tilt and Zoom control values. Code can be added here to configure these
* values on the sensor as well.
*/
zoom_cur = ZOOM_DEFAULT;
pan_cur = 0;
tilt_cur = 0;
}
uint16_t
CyFxUvcAppGetCurrentZoom (
void)
{
return zoom_cur;
}
int32_t
CyFxUvcAppGetCurrentPan (
void)
{
return pan_cur;
}
int32_t
CyFxUvcAppGetCurrentTilt (
void)
{
return tilt_cur;
}
void
CyFxUvcAppModifyPan (
int32_t panValue)
{
/* Place holder for the pan modification function */
pan_cur = panValue;
}
void
CyFxUvcAppModifyTilt (
int32_t tiltValue)
{
/* Place holder for the tilt modification function */
tilt_cur = tiltValue;
}
void
CyFxUvcAppModifyZoom (
uint16_t zoomValue)
{
/* Place holder for the zoom modification function */
zoom_cur = zoomValue;
}
#endif

View File

@ -0,0 +1,121 @@
/*
## Cypress FX3 Camera Kit header file (camera_ptzcontrol.h)
## ===========================
##
## Copyright Cypress Semiconductor Corporation, 2010-2012,
## All Rights Reserved
## UNPUBLISHED, LICENSED SOFTWARE.
##
## CONFIDENTIAL AND PROPRIETARY INFORMATION
## WHICH IS THE PROPERTY OF CYPRESS.
##
## Use of this file is governed
## by the license agreement included in the file
##
## <install>/license/license.txt
##
## where <install> is the Cypress software
## installation root directory path.
##
## ===========================
*/
/*
* This file defines the variables and functions used to control and query the Pan, Tilt
* and Zoom controls for this UVC camera function.
*/
#include "uvc.h"
#ifndef _INCLUDED_CAMERA_PTZCONTROL_H_
#define _INCLUDED_CAMERA_PTZCONTROL_H_
#ifdef UVC_PTZ_SUPPORT
#define wObjectiveFocalLengthMin (uint16_t)(1) /* Minimum Lobjective value for the sensor lens. */
#define wObjectiveFocalLengthMax (uint16_t)(10) /* Maximum Lobjective value for the sensor lens. */
#define wOcularFocalLength (uint16_t)(1) /* Locular value for the sensor lens. */
#define ZOOM_DEFAULT (uint16_t)(5) /* Default zoom setting that we start with. */
#define CyFxUvcAppGetMinimumZoom() (wObjectiveFocalLengthMin) /* Minimum supported zoom value. */
#define CyFxUvcAppGetMaximumZoom() (wObjectiveFocalLengthMax) /* Maximum supported zoom value. */
#define CyFxUvcAppGetZoomResolution() ((uint16_t)1) /* Zoom resolution is one unit. */
#define CyFxUvcAppGetDefaultZoom() ((uint16_t)ZOOM_DEFAULT) /* Default zoom setting. */
#define PANTILT_MIN (int32_t)(-648000) /* Minimum value for Pan and Tilt controls. */
#define PANTILT_MAX (int32_t)(648000) /* Maximum value for Pan and Tilt controls. */
#define CyFxUvcAppGetMinimumPan() (PANTILT_MIN) /* Minimum pan value. */
#define CyFxUvcAppGetMaximumPan() (PANTILT_MAX) /* Maximum pan value. */
#define CyFxUvcAppGetPanResolution() ((int32_t)1) /* Resolution for pan setting. */
#define CyFxUvcAppGetDefaultPan() ((int32_t)0) /* Default pan setting. */
#define CyFxUvcAppGetMinimumTilt() (PANTILT_MIN) /* Minimum tilt value. */
#define CyFxUvcAppGetMaximumTilt() (PANTILT_MAX) /* Maximum tilt value. */
#define CyFxUvcAppGetTiltResolution() ((int32_t)1) /* Resolution for tilt setting. */
#define CyFxUvcAppGetDefaultTilt() ((int32_t)0) /* Default tilt setting. */
/* Function : CyFxUvcAppPTZInit
Description : Initialize the Pan, Tilt and Zoom settings for the camera.
Parameters : None
*/
extern void
CyFxUvcAppPTZInit (
void);
/* Function : CyFxUvcAppGetCurrentZoom
Description : Get the current zoom setting for the sensor.
Parameters : None
*/
extern uint16_t
CyFxUvcAppGetCurrentZoom (
void);
/* Function : CyFxUvcAppGetCurrentPan
Description : Get the current pan setting for the camera.
Parameters : None
*/
extern int32_t
CyFxUvcAppGetCurrentPan (
void);
/* Function : CyFxUvcAppGetCurrentTilt
Description : Get the current tilt setting for the camera.
Parameters : None
*/
extern int32_t
CyFxUvcAppGetCurrentTilt (
void);
/* Function : CyFxUvcAppModifyPan
Description : Stub function that can be filled in to implement a camera PAN control.
Parameters :
panValue - PAN control value selected by the host application.
*/
extern void
CyFxUvcAppModifyPan (
int32_t panValue);
/* Function : CyFxUvcAppModifyTilt
Description : Stub function that can be filled in to implement a camera TILT control.
Parameters :
tiltValue - TILT control value selected by the host application.
*/
extern void
CyFxUvcAppModifyTilt (
int32_t tiltValue);
/* Function : CyFxUvcAppModifyZoom
Description : Stub function that can be filled in to implement a camera ZOOM control.
Parameters :
zoomValue - ZOOM control value selected by the host application.
*/
extern void
CyFxUvcAppModifyZoom (
uint16_t zoomValue);
#endif
#endif /* _INCLUDED_CAMERA_PTZCONTROL_H_ */

View File

@ -0,0 +1,56 @@
# Copyright Cypress Semiconductor Corporation, 2010-2011,
# All Rights Reserved
# UNPUBLISHED, LICENSED SOFTWARE.
#
# CONFIDENTIAL AND PROPRIETARY INFORMATION
# WHICH IS THE PROPERTY OF CYPRESS.
#
# Use of this file is governed
# by the license agreement included in the file
#
# <install>/license/license.txt
#
# where <install> is the Cypress software
# installation root directory path.
#
# Cypress FX3 Firmware Startup code
.section .text
.code 32
.global jump
jump:
bx R0
.global CyU3PToolChainInit
CyU3PToolChainInit:
# clear the BSS area
__main:
mov R0, #0
ldr R1, =_bss_start
ldr R2, =_bss_end
1: cmp R1, R2
strlo R0, [R1], #4
blo 1b
b main
.global __user_initial_stackheap
__user_initial_stackheap:
# The tool chain is not expected to place the stack.
# No heap is expected to be used by USB 3.0 platform drivers.
# Place them as required by the user code
.if INTER == TRUE
bx lr
.else
mov pc, lr
.endif
.end
# []

View File

@ -0,0 +1,192 @@
/*
* Project Name: fx3_uvc.cyfx
* Time : 06/09/2022 03:50:05
* Device Type: FX3
* Project Type: GPIF2
*
*
*
*
* This is a generated file and should not be modified
* This file need to be included only once in the firmware
* This file is generated by Gpif2 designer tool version - 1.0.1198.2
*
*/
#ifndef _INCLUDED__
#define _INCLUDED__
#include "cyu3types.h"
#include "cyu3gpif.h"
/* Summary
Number of states in the state machine
*/
#define CY_NUMBER_OF_STATES 20
/* Summary
Mapping of user defined state names to state indices
*/
#define START_SCK0 0
#define IDLE_SCK0 1
#define START_SCK1 3
#define IDLE_SCK1 4
#define WAIT_FOR_FRAME_START_0 2
#define WAIT_FOR_FRAME_START_1 5
#define PUSH_DATA_SCK0 6
#define PUSH_DATA_SCK1 7
#define LINE_END_SCK0 8
#define LINE_END_SCK1 9
#define WAIT_TO_FILL_SCK0 10
#define WAIT_TO_FILL_SCK1 12
#define WAIT_FULL_SCK0 11
#define WAIT_FULL_SCK1 13
#define PARTIAL_BUF_IN_SCK0 14
#define PARTIAL_BUF_IN_SCK1 15
#define FULL_BUF_IN_SCK0 16
#define FULL_BUF_IN_SCK1 17
#define FRAME_END_SCK0 18
#define FRAME_END_SCK1 19
/* Summary
Initial value of early outputs from the state machine.
*/
#define ALPHA_START_SCK0 0x0
#define ALPHA_START_SCK1 0x0
/* Summary
Transition function values used in the state machine.
*/
uint16_t CyFxGpifTransition[] = {
0x0000, 0x5555, 0x8888, 0xAAAA, 0x3333
};
/* Summary
Table containing the transition information for various states.
This table has to be stored in the WAVEFORM Registers.
This array consists of non-replicated waveform descriptors and acts as a
waveform table.
*/
CyU3PGpifWaveData CyFxGpifWavedata[] = {
{{0x1E738201,0x00000000,0x80000000},{0x00000000,0x00000000,0x00000000}},
{{0x2E700202,0x00000900,0x800000A0},{0x00000000,0x00000000,0x00000000}},
{{0x2E728006,0x20080102,0x80000060},{0x00000000,0x00000000,0x00000000}},
{{0x1E738204,0x00000000,0x80000000},{0x00000000,0x00000000,0x00000000}},
{{0x2E700205,0x00000100,0x800000A0},{0x00000000,0x00000000,0x00000000}},
{{0x2E726007,0x24000902,0x80000090},{0x00000000,0x00000000,0x00000000}},
{{0x2E726007,0x24000902,0x80000090},{0x1E739408,0x00080806,0x80000000}},
{{0x2E728006,0x20080102,0x80000060},{0x1E739309,0x00000006,0x80000000}},
{{0x3E70400A,0x00100908,0x80000000},{0x3E70400B,0x00100108,0x80000000}},
{{0x3E70400C,0x00100108,0x80000000},{0x3E70400D,0x00100908,0x80000000}},
{{0x2E728006,0x20080102,0x80000060},{0x3E739E0E,0x00000000,0x80000100}},
{{0x2E726007,0x24000902,0x80000090},{0x3E739E10,0x00000000,0x80000100}},
{{0x2E726007,0x24000902,0x80000090},{0x3E739E0F,0x00000000,0x80000100}},
{{0x2E728006,0x20080102,0x80000060},{0x3E739E11,0x00000000,0x80000100}},
{{0x1E739E12,0x00000000,0x80000000},{0x00000000,0x00000000,0x00000000}},
{{0x1E739E13,0x00000000,0x80000000},{0x00000000,0x00000000,0x00000000}}
};
/* Summary
Table that maps state indices to the descriptor table indices.
*/
uint8_t CyFxGpifWavedataPosition[] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,15,3,0
};
/* Summary
GPIF II configuration register values.
*/
uint32_t CyFxGpifRegValue[] = {
0x80008308, /* CY_U3P_PIB_GPIF_CONFIG */
0x0000006C, /* CY_U3P_PIB_GPIF_BUS_CONFIG */
0x00000000, /* CY_U3P_PIB_GPIF_BUS_CONFIG2 */
0x00000046, /* CY_U3P_PIB_GPIF_AD_CONFIG */
0x00000000, /* CY_U3P_PIB_GPIF_STATUS */
0x00000000, /* CY_U3P_PIB_GPIF_INTR */
0x00000002, /* CY_U3P_PIB_GPIF_INTR_MASK */
0x00000082, /* CY_U3P_PIB_GPIF_SERIAL_IN_CONFIG */
0x00000782, /* CY_U3P_PIB_GPIF_SERIAL_OUT_CONFIG */
0x00014400, /* CY_U3P_PIB_GPIF_CTRL_BUS_DIRECTION */
0x0000FFFA, /* CY_U3P_PIB_GPIF_CTRL_BUS_DEFAULT */
0x00000100, /* CY_U3P_PIB_GPIF_CTRL_BUS_POLARITY */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_TOGGLE */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000001, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000002, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
0x00000006, /* CY_U3P_PIB_GPIF_CTRL_COUNT_CONFIG */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_COUNT_RESET */
0x0000FFFF, /* CY_U3P_PIB_GPIF_CTRL_COUNT_LIMIT */
0x00000109, /* CY_U3P_PIB_GPIF_ADDR_COUNT_CONFIG */
0x00000000, /* CY_U3P_PIB_GPIF_ADDR_COUNT_RESET */
0x00001FFB, /* CY_U3P_PIB_GPIF_ADDR_COUNT_LIMIT */
0x00000000, /* CY_U3P_PIB_GPIF_STATE_COUNT_CONFIG */
0x0000FFFF, /* CY_U3P_PIB_GPIF_STATE_COUNT_LIMIT */
0x00000109, /* CY_U3P_PIB_GPIF_DATA_COUNT_CONFIG */
0x00000000, /* CY_U3P_PIB_GPIF_DATA_COUNT_RESET */
0x00001FFB, /* CY_U3P_PIB_GPIF_DATA_COUNT_LIMIT */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_COMP_VALUE */
0x00000000, /* CY_U3P_PIB_GPIF_CTRL_COMP_MASK */
0x00000000, /* CY_U3P_PIB_GPIF_DATA_COMP_VALUE */
0x00000000, /* CY_U3P_PIB_GPIF_DATA_COMP_MASK */
0x00000000, /* CY_U3P_PIB_GPIF_ADDR_COMP_VALUE */
0x00000000, /* CY_U3P_PIB_GPIF_ADDR_COMP_MASK */
0x00000000, /* CY_U3P_PIB_GPIF_DATA_CTRL */
0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */
0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */
0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */
0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */
0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */
0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */
0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */
0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */
0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */
0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */
0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */
0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */
0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */
0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */
0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */
0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */
0x80010400, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */
0x80010401, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */
0x80010402, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */
0x80010403, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */
0x00000000, /* CY_U3P_PIB_GPIF_LAMBDA_STAT */
0x00000000, /* CY_U3P_PIB_GPIF_ALPHA_STAT */
0x00000000, /* CY_U3P_PIB_GPIF_BETA_STAT */
0x00000000, /* CY_U3P_PIB_GPIF_WAVEFORM_CTRL_STAT */
0x00000000, /* CY_U3P_PIB_GPIF_WAVEFORM_SWITCH */
0x00000000, /* CY_U3P_PIB_GPIF_WAVEFORM_SWITCH_TIMEOUT */
0x00000000, /* CY_U3P_PIB_GPIF_CRC_CONFIG */
0x00000000, /* CY_U3P_PIB_GPIF_CRC_DATA */
0xFFFFFFC1 /* CY_U3P_PIB_GPIF_BETA_DEASSERT */
};
/* Summary
This structure holds all the configuration inputs for the GPIF II.
*/
const CyU3PGpifConfig_t CyFxGpifConfig = {
(uint16_t)(sizeof(CyFxGpifWavedataPosition)/sizeof(uint8_t)),
CyFxGpifWavedata,
CyFxGpifWavedataPosition,
(uint16_t)(sizeof(CyFxGpifTransition)/sizeof(uint16_t)),
CyFxGpifTransition,
(uint16_t)(sizeof(CyFxGpifRegValue)/sizeof(uint32_t)),
CyFxGpifRegValue
};
#endif /* _INCLUDED__ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="us-ascii"?>
<CyXmlSerializer>
<!--This file is machine generated and read. It is not intended to be edited by hand.-->
<!--Due to this, there is no schema for this file.-->
<CyGuid_7d237aff-d944-11da-aaba-00164119d63b type_name="CyGpif2Designer.Common.PrjMgmt.Model.CyPrjMgmtGpif2exe" version="2">
<CyGuid_7d237b00-d944-11da-aaba-00164119d63b type_name="CyGpif2Designer.Common.PrjMgmt.Model.CyPrjMgmtProject" version="1">
<ProjectDocs>
<CyGuid_7d237b03-d944-11da-aaba-00164119d63b type_name="CyGpif2Designer.Common.PrjMgmt.Model.CyPrjMgmtItem" name="gpif2model.xml" persistent="./projectfiles/gpif2model.xml" target="7d237b02-d944-11da-aaba-00164119d63b">
<Hidden v="False" />
</CyGuid_7d237b03-d944-11da-aaba-00164119d63b>
<CyGuid_7d237b03-d944-11da-aaba-00164119d63b type_name="CyGpif2Designer.Common.PrjMgmt.Model.CyPrjMgmtItem" name="gpif2view.xml" persistent="./projectfiles/gpif2view.xml" target="7d237b01-d944-11da-aaba-00164119d63b">
<Hidden v="False" />
</CyGuid_7d237b03-d944-11da-aaba-00164119d63b>
<CyGuid_7d237b03-d944-11da-aaba-00164119d63b type_name="CyGpif2Designer.Common.PrjMgmt.Model.CyPrjMgmtItem" name="gpif2timingsimulation.xml" persistent="./projectfiles/gpif2timingsimulation.xml" target="3ad448c6-d155-4f76-a7fb-e760cd8e6feb">
<Hidden v="False" />
</CyGuid_7d237b03-d944-11da-aaba-00164119d63b>
</ProjectDocs>
<OutputDocs>
<CyGuid_7d237b03-d944-11da-aaba-00164119d63b type_name="CyGpif2Designer.Common.PrjMgmt.Model.CyPrjMgmtItem" name="cyfxgpif2config.h" persistent="C:\Users\gaurav\Documents\ez_usb_eclipe_workspace\UVC_AN75779\cyfxgpif2config.h" target="7d237afd-d944-11da-aaba-00164119d63b">
<Hidden v="False" />
</CyGuid_7d237b03-d944-11da-aaba-00164119d63b>
</OutputDocs>
</CyGuid_7d237b00-d944-11da-aaba-00164119d63b>
<Settings>
<Setting name="GPIF2_OutputName" value="cyfxgpif2config" />
<Setting name="GPIF2_OutputLocation" value="..\" />
<Setting name="GPIF2_Template" value="C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\GPIFII Designer\inputs\outputtemplates\cygpif2cheadertemplate.tpl" />
</Settings>
</CyGuid_7d237aff-d944-11da-aaba-00164119d63b>
</CyXmlSerializer>

View File

@ -0,0 +1,283 @@
<?xml version="1.0" encoding="UTF-8"?>
<GPIFIIModel version="3">
<InterfaceDefination>
<InterfaceSetting>
<I2SEnabled>False</I2SEnabled>
<I2CEnabled>True</I2CEnabled>
<SPIEnabled>False</SPIEnabled>
<I2SEnabled>False</I2SEnabled>
<ADMuxedEnabled>False</ADMuxedEnabled>
<InterfaceType>Slave</InterfaceType>
<CommunicationType>Synchronous</CommunicationType>
<ClockSource>External</ClockSource>
<ClockEdge>Negative</ClockEdge>
<Endianness>LittleEndian</Endianness>
<DataBusWidth>Bit32</DataBusWidth>
<AddressBuswidth>0</AddressBuswidth>
</InterfaceSetting>
</InterfaceDefination>
<Signals>
<Signal ElementId="INPUT0" SignalType="Input" SpecialFunction="None">
<DisplayName>LV</DisplayName>
<GPIOPinNumber>GPIO_17</GPIOPinNumber>
<Polarity>ActiveHigh</Polarity>
</Signal>
<Signal ElementId="INPUT1" SignalType="Input" SpecialFunction="None">
<DisplayName>FV</DisplayName>
<GPIOPinNumber>GPIO_19</GPIOPinNumber>
<Polarity>ActiveHigh</Polarity>
</Signal>
<Signal ElementId="OUTPUT0" SignalType="Output" SpecialFunction="None">
<DisplayName>nSensor_Reset</DisplayName>
<GPIOPinNumber>GPIO_25</GPIOPinNumber>
<IntialValue>High</IntialValue>
<Polarity>ActiveLow</Polarity>
<Delay>Alpha</Delay>
<AssetionType>Assert</AssetionType>
</Signal>
<Signal ElementId="OUTPUT1" SignalType="Output" SpecialFunction="None">
<DisplayName>OUTPUT1</DisplayName>
<GPIOPinNumber>GPIO_22</GPIOPinNumber>
<IntialValue>Low</IntialValue>
<Polarity>ActiveHigh</Polarity>
<Delay>Alpha</Delay>
<AssetionType>Assert</AssetionType>
</Signal>
<Signal ElementId="OUTPUT2" SignalType="Output" SpecialFunction="None">
<DisplayName>OUTPUT2</DisplayName>
<GPIOPinNumber>GPIO_24</GPIOPinNumber>
<IntialValue>Low</IntialValue>
<Polarity>ActiveHigh</Polarity>
<Delay>Alpha</Delay>
<AssetionType>Assert</AssetionType>
</Signal>
</Signals>
<StateMachine>
<AddressCounter />
<DataCounter />
<ControlCounter />
<AddressComparator />
<DataComparator />
<ControlComparator />
<DRQ />
<AddrData />
<State ElementId="STARTSTATE0" StateType="StartState">
<DisplayName>START_SCK0</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
</State>
<State ElementId="STATE0" StateType="NormalState">
<DisplayName>IDLE_SCK0</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
</State>
<State ElementId="STARTSTATE1" StateType="StartState">
<DisplayName>START_SCK1</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
</State>
<State ElementId="STATE1" StateType="NormalState">
<DisplayName>IDLE_SCK1</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
</State>
<State ElementId="STATE2" StateType="NormalState">
<DisplayName>WAIT_FOR_FRAME_START_0</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="LD_DATA_COUNT0" ActionType="LD_DATA_COUNT">
<CounterType>Up</CounterType>
<CounterLoadValue>0</CounterLoadValue>
<CounterLimit>8187</CounterLimit>
<CounterReloadEnable>Disable</CounterReloadEnable>
<CounterIncrement>1</CounterIncrement>
<CounterInterrupt>Mask</CounterInterrupt>
</Action>
<Action ElementId="LD_ADDR_COUNT0" ActionType="LD_ADDR_COUNT">
<CounterType>Up</CounterType>
<CounterLoadValue>0</CounterLoadValue>
<CounterLimit>8187</CounterLimit>
<CounterReloadEnable>Disable</CounterReloadEnable>
<CounterIncrement>1</CounterIncrement>
<CounterInterrupt>Mask</CounterInterrupt>
</Action>
</State>
<State ElementId="STATE3" StateType="NormalState">
<DisplayName>WAIT_FOR_FRAME_START_1</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="LD_DATA_COUNT0" ActionType="LD_DATA_COUNT">
<CounterType>Up</CounterType>
<CounterLoadValue>0</CounterLoadValue>
<CounterLimit>8187</CounterLimit>
<CounterReloadEnable>Disable</CounterReloadEnable>
<CounterIncrement>1</CounterIncrement>
<CounterInterrupt>Mask</CounterInterrupt>
</Action>
<Action ElementId="LD_ADDR_COUNT0" ActionType="LD_ADDR_COUNT">
<CounterType>Up</CounterType>
<CounterLoadValue>0</CounterLoadValue>
<CounterLimit>8187</CounterLimit>
<CounterReloadEnable>Disable</CounterReloadEnable>
<CounterIncrement>1</CounterIncrement>
<CounterInterrupt>Mask</CounterInterrupt>
</Action>
</State>
<State ElementId="STATE4" StateType="NormalState">
<DisplayName>PUSH_DATA_SCK0</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="IN_DATA0" ActionType="IN_DATA">
<DataSourceSink>Socket</DataSourceSink>
<ThreadNumber>Thread0</ThreadNumber>
<SampleData>True</SampleData>
<WriteDataIntoDataSink>True</WriteDataIntoDataSink>
</Action>
<Action ElementId="COUNT_DATA0" ActionType="COUNT_DATA" />
<Action ElementId="LD_ADDR_COUNT0" ActionType="LD_ADDR_COUNT">
<CounterType>Up</CounterType>
<CounterLoadValue>0</CounterLoadValue>
<CounterLimit>8187</CounterLimit>
<CounterReloadEnable>Disable</CounterReloadEnable>
<CounterIncrement>1</CounterIncrement>
<CounterInterrupt>Mask</CounterInterrupt>
</Action>
<Action ElementId="DR_GPIO0" ActionType="DR_GPIO">
<ControlPinName>OUTPUT1</ControlPinName>
</Action>
</State>
<State ElementId="STATE5" StateType="NormalState">
<DisplayName>PUSH_DATA_SCK1</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="IN_DATA0" ActionType="IN_DATA">
<DataSourceSink>Socket</DataSourceSink>
<ThreadNumber>Thread1</ThreadNumber>
<SampleData>True</SampleData>
<WriteDataIntoDataSink>True</WriteDataIntoDataSink>
</Action>
<Action ElementId="COUNT_ADDR0" ActionType="COUNT_ADDR" />
<Action ElementId="LD_DATA_COUNT0" ActionType="LD_DATA_COUNT">
<CounterType>Up</CounterType>
<CounterLoadValue>0</CounterLoadValue>
<CounterLimit>8187</CounterLimit>
<CounterReloadEnable>Disable</CounterReloadEnable>
<CounterIncrement>1</CounterIncrement>
<CounterInterrupt>Mask</CounterInterrupt>
</Action>
</State>
<State ElementId="STATE6" StateType="NormalState">
<DisplayName>LINE_END_SCK0</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="DR_GPIO0" ActionType="DR_GPIO">
<ControlPinName>OUTPUT1</ControlPinName>
</Action>
</State>
<State ElementId="STATE7" StateType="NormalState">
<DisplayName>LINE_END_SCK1</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
</State>
<State ElementId="STATE8" StateType="NormalState">
<DisplayName>WAIT_TO_FILL_SCK0</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="DR_GPIO0" ActionType="DR_GPIO">
<ControlPinName>OUTPUT1</ControlPinName>
</Action>
</State>
<State ElementId="STATE9" StateType="NormalState">
<DisplayName>WAIT_TO_FILL_SCK1</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
</State>
<State ElementId="STATE10" StateType="NormalState">
<DisplayName>WAIT_FULL_SCK0</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="DR_GPIO0" ActionType="DR_GPIO">
<ControlPinName>OUTPUT1</ControlPinName>
</Action>
</State>
<State ElementId="STATE11" StateType="NormalState">
<DisplayName>WAIT_FULL_SCK1</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
</State>
<State ElementId="STATE12" StateType="NormalState">
<DisplayName>PARTIAL_BUF_IN_SCK0</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="INTR_CPU0" ActionType="INTR_CPU" />
<Action ElementId="DR_GPIO0" ActionType="DR_GPIO">
<ControlPinName>OUTPUT2</ControlPinName>
</Action>
</State>
<State ElementId="STATE13" StateType="NormalState">
<DisplayName>PARTIAL_BUF_IN_SCK1</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="INTR_CPU0" ActionType="INTR_CPU" />
<Action ElementId="DR_GPIO0" ActionType="DR_GPIO">
<ControlPinName>OUTPUT2</ControlPinName>
</Action>
</State>
<State ElementId="STATE14" StateType="NormalState">
<DisplayName>FULL_BUF_IN_SCK0</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="INTR_CPU0" ActionType="INTR_CPU" />
<Action ElementId="DR_GPIO0" ActionType="DR_GPIO">
<ControlPinName>OUTPUT2</ControlPinName>
</Action>
</State>
<State ElementId="STATE15" StateType="NormalState">
<DisplayName>FULL_BUF_IN_SCK1</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
<Action ElementId="INTR_CPU0" ActionType="INTR_CPU" />
<Action ElementId="DR_GPIO0" ActionType="DR_GPIO">
<ControlPinName>OUTPUT2</ControlPinName>
</Action>
</State>
<State ElementId="STATE16" StateType="NormalState">
<DisplayName>FRAME_END_SCK0</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
</State>
<State ElementId="STATE17" StateType="NormalState">
<DisplayName>FRAME_END_SCK1</DisplayName>
<RepeatUntillNextTransition>True</RepeatUntillNextTransition>
<RepeatCount>0</RepeatCount>
</State>
<Transition ElementId="TRANSITION0" SourceState="STARTSTATE0" DestinationState="STATE0" Equation="LOGIC_ONE" />
<Transition ElementId="TRANSITION1" SourceState="STARTSTATE1" DestinationState="STATE1" Equation="LOGIC_ONE" />
<Transition ElementId="TRANSITION2" SourceState="STATE0" DestinationState="STATE2" Equation="!FV" />
<Transition ElementId="TRANSITION3" SourceState="STATE1" DestinationState="STATE3" Equation="!FV" />
<Transition ElementId="TRANSITION4" SourceState="STATE2" DestinationState="STATE4" Equation="FV&amp;LV" />
<Transition ElementId="TRANSITION5" SourceState="STATE3" DestinationState="STATE5" Equation="FV&amp;LV" />
<Transition ElementId="TRANSITION6" SourceState="STATE4" DestinationState="STATE5" Equation="LV&amp;DATA_CNT_HIT" />
<Transition ElementId="TRANSITION7" SourceState="STATE5" DestinationState="STATE4" Equation="LV&amp;ADDR_CNT_HIT" />
<Transition ElementId="TRANSITION8" SourceState="STATE4" DestinationState="STATE6" Equation="!LV" />
<Transition ElementId="TRANSITION9" SourceState="STATE5" DestinationState="STATE7" Equation="!LV" />
<Transition ElementId="TRANSITION10" SourceState="STATE6" DestinationState="STATE8" Equation="!DATA_CNT_HIT" />
<Transition ElementId="TRANSITION11" SourceState="STATE7" DestinationState="STATE9" Equation="!ADDR_CNT_HIT" />
<Transition ElementId="TRANSITION12" SourceState="STATE8" DestinationState="STATE4" Equation="LV" />
<Transition ElementId="TRANSITION13" SourceState="STATE9" DestinationState="STATE5" Equation="LV" />
<Transition ElementId="TRANSITION14" SourceState="STATE6" DestinationState="STATE10" Equation="DATA_CNT_HIT" />
<Transition ElementId="TRANSITION15" SourceState="STATE7" DestinationState="STATE11" Equation="ADDR_CNT_HIT" />
<Transition ElementId="TRANSITION16" SourceState="STATE10" DestinationState="STATE5" Equation="LV" />
<Transition ElementId="TRANSITION17" SourceState="STATE11" DestinationState="STATE4" Equation="LV" />
<Transition ElementId="TRANSITION18" SourceState="STATE8" DestinationState="STATE12" Equation="!FV" />
<Transition ElementId="TRANSITION19" SourceState="STATE10" DestinationState="STATE14" Equation="!FV" />
<Transition ElementId="TRANSITION20" SourceState="STATE11" DestinationState="STATE15" Equation="!FV" />
<Transition ElementId="TRANSITION21" SourceState="STATE9" DestinationState="STATE13" Equation="!FV" />
<Transition ElementId="TRANSITION22" SourceState="STATE12" DestinationState="STATE16" Equation="FW_TRG" />
<Transition ElementId="TRANSITION23" SourceState="STATE14" DestinationState="STATE16" Equation="FW_TRG" />
<Transition ElementId="TRANSITION24" SourceState="STATE15" DestinationState="STATE17" Equation="FW_TRG" />
<Transition ElementId="TRANSITION25" SourceState="STATE13" DestinationState="STATE17" Equation="FW_TRG" />
<Transition ElementId="TRANSITION26" SourceState="STATE16" DestinationState="STATE1" Equation="!FW_TRG" />
<Transition ElementId="TRANSITION27" SourceState="STATE17" DestinationState="STATE0" Equation="!FW_TRG" />
</StateMachine>
</GPIFIIModel>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<GPIFIITimingSimulation version="1">
<Clock>100</Clock>
<BufferSize>512</BufferSize>
<WaterMark>0</WaterMark>
</GPIFIITimingSimulation>

View File

@ -0,0 +1,535 @@
<?xml version="1.0" encoding="UTF-8"?>
<Root version="4">
<CyStates>
<CyNormalState>
<Left>230</Left>
<Top>16.8466666666667</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE0</Name>
<DisplayName>IDLE_SCK0</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>847.4</Left>
<Top>20.2</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE1</Name>
<DisplayName>IDLE_SCK1</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>407</Left>
<Top>22.2</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE2</Name>
<DisplayName>WAIT_FOR_FRAME_START_0</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>655</Left>
<Top>22.8</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE3</Name>
<DisplayName>WAIT_FOR_FRAME_START_1</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>425.6</Left>
<Top>236.2</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE4</Name>
<DisplayName>PUSH_DATA_SCK0</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>656.6</Left>
<Top>222.8</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE5</Name>
<DisplayName>PUSH_DATA_SCK1</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>54.2</Left>
<Top>219.8</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE6</Name>
<DisplayName>LINE_END_SCK0</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>1023</Left>
<Top>226.8</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE7</Name>
<DisplayName>LINE_END_SCK1</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>38</Left>
<Top>380.8</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE8</Name>
<DisplayName>WAIT_TO_FILL_SCK0</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>855.4</Left>
<Top>397.6</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE9</Name>
<DisplayName>WAIT_TO_FILL_SCK1</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>240.8</Left>
<Top>396.6</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE10</Name>
<DisplayName>WAIT_FULL_SCK0</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>605.6</Left>
<Top>371.2</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE11</Name>
<DisplayName>WAIT_FULL_SCK1</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>46.2</Left>
<Top>491.2</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE12</Name>
<DisplayName>PARTIAL_BUF_IN_SCK0</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>825.4</Left>
<Top>497.2</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE13</Name>
<DisplayName>PARTIAL_BUF_IN_SCK1</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>231.6</Left>
<Top>493</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE14</Name>
<DisplayName>FULL_BUF_IN_SCK0</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>622.2</Left>
<Top>479.6</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE15</Name>
<DisplayName>FULL_BUF_IN_SCK1</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>134.8</Left>
<Top>618.2</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE16</Name>
<DisplayName>FRAME_END_SCK0</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyNormalState>
<Left>724.8</Left>
<Top>624.6</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STATE17</Name>
<DisplayName>FRAME_END_SCK1</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyNormalState>
<CyStartState>
<Left>29</Left>
<Top>18.4466666666667</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STARTSTATE0</Name>
<DisplayName>START_SCK0</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyStartState>
<CyStartState>
<Left>1021</Left>
<Top>20.4</Top>
<Width>83</Width>
<Height>70</Height>
<Name>STARTSTATE1</Name>
<DisplayName>START_SCK1</DisplayName>
<zIndex>1</zIndex>
<IsGroup>False</IsGroup>
<ParentID>00000000-0000-0000-0000-000000000000</ParentID>
</CyStartState>
</CyStates>
<CyTransitions>
<CyTransition>
<Name>TRANSITION27</Name>
<TransitionEquation>!FW_TRG</TransitionEquation>
<SourceName>STATE17</SourceName>
<SinkName>STATE0</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION26</Name>
<TransitionEquation>!FW_TRG</TransitionEquation>
<SourceName>STATE16</SourceName>
<SinkName>STATE1</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION25</Name>
<TransitionEquation>FW_TRG</TransitionEquation>
<SourceName>STATE13</SourceName>
<SinkName>STATE17</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION24</Name>
<TransitionEquation>FW_TRG</TransitionEquation>
<SourceName>STATE15</SourceName>
<SinkName>STATE17</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION23</Name>
<TransitionEquation>FW_TRG</TransitionEquation>
<SourceName>STATE14</SourceName>
<SinkName>STATE16</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION22</Name>
<TransitionEquation>FW_TRG</TransitionEquation>
<SourceName>STATE12</SourceName>
<SinkName>STATE16</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION21</Name>
<TransitionEquation>!FV</TransitionEquation>
<SourceName>STATE9</SourceName>
<SinkName>STATE13</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION20</Name>
<TransitionEquation>!FV</TransitionEquation>
<SourceName>STATE11</SourceName>
<SinkName>STATE15</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION19</Name>
<TransitionEquation>!FV</TransitionEquation>
<SourceName>STATE10</SourceName>
<SinkName>STATE14</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION18</Name>
<TransitionEquation>!FV</TransitionEquation>
<SourceName>STATE8</SourceName>
<SinkName>STATE12</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION17</Name>
<TransitionEquation>LV</TransitionEquation>
<SourceName>STATE11</SourceName>
<SinkName>STATE4</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION16</Name>
<TransitionEquation>LV</TransitionEquation>
<SourceName>STATE10</SourceName>
<SinkName>STATE5</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION15</Name>
<TransitionEquation>ADDR_CNT_HIT</TransitionEquation>
<SourceName>STATE7</SourceName>
<SinkName>STATE11</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION14</Name>
<TransitionEquation>DATA_CNT_HIT</TransitionEquation>
<SourceName>STATE6</SourceName>
<SinkName>STATE10</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION13</Name>
<TransitionEquation>LV</TransitionEquation>
<SourceName>STATE9</SourceName>
<SinkName>STATE5</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION12</Name>
<TransitionEquation>LV</TransitionEquation>
<SourceName>STATE8</SourceName>
<SinkName>STATE4</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION11</Name>
<TransitionEquation>!ADDR_CNT_HIT</TransitionEquation>
<SourceName>STATE7</SourceName>
<SinkName>STATE9</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION10</Name>
<TransitionEquation>!DATA_CNT_HIT</TransitionEquation>
<SourceName>STATE6</SourceName>
<SinkName>STATE8</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION9</Name>
<TransitionEquation>!LV</TransitionEquation>
<SourceName>STATE5</SourceName>
<SinkName>STATE7</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION8</Name>
<TransitionEquation>!LV</TransitionEquation>
<SourceName>STATE4</SourceName>
<SinkName>STATE6</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION7</Name>
<TransitionEquation>LV&amp;ADDR_CNT_HIT</TransitionEquation>
<SourceName>STATE5</SourceName>
<SinkName>STATE4</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION6</Name>
<TransitionEquation>LV&amp;DATA_CNT_HIT</TransitionEquation>
<SourceName>STATE4</SourceName>
<SinkName>STATE5</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION5</Name>
<TransitionEquation>FV&amp;LV</TransitionEquation>
<SourceName>STATE3</SourceName>
<SinkName>STATE5</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION4</Name>
<TransitionEquation>FV&amp;LV</TransitionEquation>
<SourceName>STATE2</SourceName>
<SinkName>STATE4</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION3</Name>
<TransitionEquation>!FV</TransitionEquation>
<SourceName>STATE1</SourceName>
<SinkName>STATE3</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION2</Name>
<TransitionEquation>!FV</TransitionEquation>
<SourceName>STATE0</SourceName>
<SinkName>STATE2</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION1</Name>
<TransitionEquation>LOGIC_ONE</TransitionEquation>
<SourceName>STARTSTATE1</SourceName>
<SinkName>STATE1</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
<CyTransition>
<Name>TRANSITION0</Name>
<TransitionEquation>LOGIC_ONE</TransitionEquation>
<SourceName>STARTSTATE0</SourceName>
<SinkName>STATE0</SinkName>
<SourceConnectorName>Connector</SourceConnectorName>
<SinkConnectorName>Connector</SinkConnectorName>
<SourceArrowSymbol>None</SourceArrowSymbol>
<SinkArrowSymbol>Arrow</SinkArrowSymbol>
<zIndex>0</zIndex>
</CyTransition>
</CyTransitions>
</Root>

View File

@ -0,0 +1,69 @@
## Copyright Cypress Semiconductor Corporation, 2016-2017,
## All Rights Reserved
## UNPUBLISHED, LICENSED SOFTWARE.
##
## CONFIDENTIAL AND PROPRIETARY INFORMATION
## WHICH IS THE PROPERTY OF CYPRESS.
##
## Use of this file is governed
## by the license agreement included in the file
##
## <install>/license/license.txt
##
## where <install> is the Cypress software
## installation root directory path.
##
FX3FWROOT=../../..
all:compile
include $(FX3FWROOT)/fw_build/fx3_fw/fx3_build_config.mak
MODULE = cyfx_uvc_an75779
SOURCE= uvc.c \
camera_ptzcontrol.c \
cyfxuvcdscr.c \
sensor.c \
cyfxtx.c
ifeq ($(CYFXBUILD),arm)
SOURCE_ASM=cyfx_startup.S
else
SOURCE_ASM=cyfx_gcc_startup.S
endif
C_OBJECT=$(SOURCE:%.c=./%.o)
A_OBJECT=$(SOURCE_ASM:%.S=./%.o)
EXES = $(MODULE).$(EXEEXT)
$(MODULE).$(EXEEXT): $(A_OBJECT) $(C_OBJECT)
$(LINK)
cyfxtx.c:
cp $(FX3FWROOT)/fw_build/fx3_fw/cyfxtx.c .
cyfx_startup.S:
cp $(FX3FWROOT)/fw_build/fx3_fw/cyfx_startup.S .
cyfx_gcc_startup.S:
cp $(FX3FWROOT)/fw_build/fx3_fw/cyfx_gcc_startup.S .
$(C_OBJECT) : %.o : %.c
$(COMPILE)
$(A_OBJECT) : %.o : %.S
$(ASSEMBLE)
clean:
rm -f ./$(MODULE).$(EXEEXT)
rm -f ./$(MODULE).map
rm -f ./*.o
rm -f cyfxtx.c cyfx_startup.S cyfx_gcc_startup.S
compile: $(C_OBJECT) $(A_OBJECT) $(EXES)
#[]#

View File

@ -0,0 +1 @@
SHELL=C:\Windows\system32\cmd.exe

View File

@ -0,0 +1,746 @@
#include <cyu3system.h>
#include <cyu3os.h>
#include <cyu3dma.h>
#include <cyu3error.h>
#include <cyu3uart.h>
#include <cyu3i2c.h>
#include <cyu3types.h>
#include <cyu3gpio.h>
#include <cyu3utils.h>
#include "sensor_imx219.h"
#include "uvc_settings.h"
imgsensor_mode_t *selected_img_mode;
static const imx219_reg_t mode_default[]={ //default register settings, Resolution and FPS specific settings will be over written
{REG_MODE_SEL, 0x00},
{0x30EB, 0x05}, //access sequence
{0x30EB, 0x0C},
{0x300A, 0xFF},
{0x300B, 0xFF},
{0x30EB, 0x05},
{0x30EB, 0x09},
{REG_CSI_LANE, 0x01}, //3-> 4Lane 1-> 2Lane
{REG_DPHY_CTRL, 0x00}, //DPHY timing 0-> auot 1-> manual
{REG_EXCK_FREQ_MSB, 0x18}, //external oscillator frequncy 0x18 -> 24Mhz
{REG_EXCK_FREQ_LSB, 0x00},
{REG_FRAME_LEN_MSB, 0x06}, //frame length , Raspberry pi sends this commands continously when recording video @60fps ,writes come at interval of 32ms , Data 355 for resolution 1280x720 command 162 also comes along with data 0DE7 also 15A with data 0200
{REG_FRAME_LEN_LSB, 0xE3},
{REG_LINE_LEN_MSB, 0x0d}, //does not directly affect how many bits on wire in one line does affect how many clock between lines
{REG_LINE_LEN_LSB, 0x78}, //appears to be having step in value, not every LSb change will reflect on fps
{REG_X_ADD_STA_MSB, 0x02}, //x start
{REG_X_ADD_STA_LSB, 0xA8},
{REG_X_ADD_END_MSB, 0x0A}, //x end
{REG_X_ADD_END_LSB, 0x27},
{REG_Y_ADD_STA_MSB, 0x02}, //y start
{REG_Y_ADD_STA_LSB, 0xB4},
{REG_Y_ADD_END_MSB, 0x06}, //y end
{REG_Y_ADD_END_LSB, 0xEB},
{REG_X_OUT_SIZE_MSB, 0x07}, //resolution 1280 -> 5 00 , 1920 -> 780 , 2048 -> 0x8 0x00
{REG_X_OUT_SIZE_LSB, 0x80},
{REG_Y_OUT_SIZE_MSB, 0x04}, // 720 -> 0x02D0 | 1080 -> 0x438 | this setting changes how many line over wire does not affect frame rate
{REG_Y_OUT_SIZE_LSB, 0x38},
{REG_X_ODD_INC, 0x01}, //increment
{REG_Y_ODD_INC, 0x01}, //increment
{REG_BINNING_H, 0x00}, //binning H 0 off 1 x2 2 x4 3 x2 analog
{REG_BINNING_V, 0x00}, //binning H 0 off 1 x2 2 x4 3 x2 analog
{REG_CSI_FORMAT_C, 0x0A}, //CSI Data format A-> 10bit
{REG_CSI_FORMAT_D, 0x0A}, //CSI Data format
{REG_VTPXCK_DIV, 0x05}, //vtpxclkd_div 5 301
{REG_VTSYCK_DIV, 0x01}, //vtsclk _div 1 303
{REG_PREPLLCK_VT_DIV, 0x03}, //external oscillator /3
{REG_PREPLLCK_OP_DIV, 0x03}, //external oscillator /3
{REG_PLL_VT_MPY_MSB, 0x00}, //PLL_VT multiplizer
{REG_PLL_VT_MPY_LSB, 0x52}, //Changes Frame rate with , integration register 0x15a
{REG_OPPXCK_DIV, 0x0A}, //oppxck_div
{REG_OPSYCK_DIV, 0x01}, //opsysck_div
{REG_PLL_OP_MPY_MSB, 0x00}, //PLL_OP
{REG_PLL_OP_MPY_LSB, 0x32}, // 8Mhz x 0x57 ->696Mhz -> 348Mhz | 0x32 -> 200Mhz | 0x40 -> 256Mhz
{0x455E, 0x00}, //magic?
{0x471E, 0x4B},
{0x4767, 0x0F},
{0x4750, 0x14},
{0x4540, 0x00},
{0x47B4, 0x14},
{0x4713, 0x30},
{0x478B, 0x10},
{0x478F, 0x10},
{0x4793, 0x10},
{0x4797, 0x0E},
{0x479B, 0x0E},
{REG_TP_RED_MSB, 0x03},
{REG_TP_RED_LSB, 0xFF},
{REG_TP_GREEN_MSB, 0x00},
{REG_TP_GREEN_LSB, 0x00},
{REG_TP_BLUE_MSB, 0x00},
{REG_TP_BLUE_LSB, 0x00},
{REG_TEST_PATTERN_MSB, 0x00}, //test pattern
{REG_TEST_PATTERN_LSB, 0x00},
{REG_TP_X_OFFSET_MSB, 0x00}, //tp offset x 0
{REG_TP_X_OFFSET_LSB, 0x00},
{REG_TP_Y_OFFSET_MSB, 0x00}, //tp offset y 0
{REG_TP_Y_OFFSET_LSB, 0x00},
{REG_TP_WIDTH_MSB, 0x05}, //TP width 1920 ->780 1280->500
{REG_TP_WIDTH_LSB, 0x00},
{REG_TP_HEIGHT_MSB, 0x02}, //TP height 1080 -> 438 720->2D0
{REG_TP_HEIGHT_LSB, 0xD0},
{REG_DIG_GAIN_GLOBAL_MSB, 0x01},
{REG_DIG_GAIN_GLOBAL_LSB, 0x00},
{REG_ANA_GAIN_GLOBAL, 0x80}, //analog gain , raspberry pi constinouly changes this depending on scense
{REG_INTEGRATION_TIME_MSB, 0x03}, //integration time , really important for frame rate
{REG_INTEGRATION_TIME_LSB, 0x51},
{REG_MODE_SEL, 0x01},
};
image_sensor_config_t *sensor_config;
static image_sensor_config_t sensor_config_2LANE = {
.sensor_mode = 0x01,
.mode_640x480_30 = { //200Mhz 2Lane 311040 312000
.pix_clk_mul = 0x2E,
.pix_clk_div = 0x4,
.integration = 1725 - 4, //must be < (linelength- 4) to maintain frame rate by framelength or integration time will slow frame rate
.gain = 0x70,
.linelength = 3448, //Warning! This value need to be either 0xD78 or 0xDE7 regardless of frame size and FPS, other values will result undefined and ununderstanable issues in image
.framelength = 1725, //decided how long is frame, basically frame rate with pix clock, it has second priority to integration time. absolute minimum is 255 for imx219
.startx = 1000,
.starty = 750,
.endx = 2280,
.endy = 1715, //this has to odd or bayer oder will change
.width = 640,
.height = 480, //each frame will have two extra line to compensate for debayer crop
.binning = 2,
.test_pattern = 0
},
.mode_640x480_200 = { //200fps with 2 lane and 200MHz mipi
.pix_clk_mul = 0x2E,
.pix_clk_div = 0x4,
.integration = 258 - 4,
.gain = 0x70,
.linelength = 3448,
.framelength = 258,
.startx = 1000,
.starty = 750,
.endx = 2280,
.endy = 1715,
.width = 640,
.height = 480,
.binning = 2,
.test_pattern = 0
},
.mode_1280x720_30 = { //200Mhz 2 lane
.pix_clk_mul = 0x2E,
.pix_clk_div = 0x4,
.integration = 1720 - 4,
.gain = 0x80,
.linelength = 3448,
.framelength = 1720,
.startx = 4,
.starty = 4,
.endx = 0xA27,
.endy = 0x6EB,
.width = 1280,
.height = 720,
.binning = 0,
.test_pattern = 0
},
.mode_1280x720_60 = { //200Mhz mipi 2 lane 927360
.pix_clk_mul = 0x2E,
.pix_clk_div = 0x4,
.integration = 862 - 4,
.gain = 0x80,
.linelength = 0xD78,
.framelength = 862,
.startx = 0x2A8,
.starty = 0x2B4,
.endx = 0xA27,
.endy = 0x6EB,
.width = 1280,
.height = 720,
.binning = 0,
.test_pattern = 0
},
.mode_1920x1080_30 = { //200Mhz 2Lane 2082240
.pix_clk_mul = 0x20,
.pix_clk_div = 0x4,
.integration = 1200 - 4,
.gain = 0x80,
.linelength = 0xD78,
.framelength = 1200,
.startx = 0x2A8,
.starty = 0x2B4,
.endx = 0xA27,
.endy = 0x6EB,
.width = 1920,
.height = 1080,
.binning = 0,
.test_pattern = 0
},
.mode_640x128_600 = { //200Mhz 2LANE 82944
.pix_clk_mul = 0x2D,
.pix_clk_div = 0x4,
.integration = 84 - 4,
.gain = 200,
.linelength = 0xD78,
.framelength = 84,
.startx = 1320,
.starty = 990,
.endx = 2600,
.endy = 1609,
.width = 640,
.height = 128,
.binning = 2,
.test_pattern = 0
},
.mode_640x80_900 = { //200Mhz 2Lane 51840
.pix_clk_mul = 0x2D,
.pix_clk_div = 0x4,
.integration = 56 - 4,
.gain = 200,
.linelength = 0xD78,
.framelength = 56,
.startx = 1320,
.starty = 990,
.endx = 2600,
.endy = 1561,
.width = 640,
.height = 80,
.binning = 2,
.test_pattern = 0
},
.mode_3280x2464_7 = { //200Mhz 2 Lane 3055360
.pix_clk_mul = 0x12,
.pix_clk_div = 0x4,
.integration = 2670 - 4,
.gain = 200,
.linelength = 0xD78, //3448
.framelength = 2670,
.startx = 0,
.starty = 0,
.endx = 3279,
.endy = 2463,
.width = 3280,
.height = 2464,
.binning = 0,
.test_pattern = 1
},
};
static image_sensor_config_t sensor_config_4LANE = {
.sensor_mode = 0x01,
.mode_640x480_30 = {
.pix_clk_mul = 0x53,
.pix_clk_div = 0x4,
.integration = 3209 - 4, //must be < (linelength- 4) to maintain frame rate by framelength or integration time will slow frame rate
.gain = 0x70,
.linelength = 3448, //Warning! This value need to be either 0xD78 or 0xDE7 regardless of frame size and FPS, other values will result undefined and ununderstanable issues in image
.framelength = 3209,
.startx = 1000,
.starty = 750,
.endx = 2280,
.endy = 1715, //this has to be odd or bayer oder will change
.width = 640,
.height = 482, //each frame will have two extra line to compensate for debayer crop
.binning = 2,
.test_pattern = 0
},
.mode_640x480_200 = {
.pix_clk_mul = 0x53,
.pix_clk_div = 0x4,
.integration = 481 - 4,
.gain = 0x70,
.linelength = 3448,
.framelength = 481,
.startx = 1000,
.starty = 750,
.endx = 2280,
.endy = 1715,
.width = 640,
.height = 482,
.binning = 2,
.test_pattern = 0
},
.mode_1280x720_30 = {
.pix_clk_mul = 0x58,
.pix_clk_div = 0x4,
.integration = 3402 - 10,
.gain = 0x80,
.linelength = 3448,
.framelength = 3402,
.startx = 4,
.starty = 4,
.endx = 0xA27,
.endy = 0x6EB,
.width = 1280,
.height = 722,
.binning = 0,
.test_pattern = 0
},
.mode_1280x720_60 = {
.pix_clk_mul = 0x58,
.pix_clk_div = 0x4,
.integration = 1701 - 4,
.gain = 0x80,
.linelength = 0xD78,
.framelength = 1701,
.startx = 0x2A8,
.starty = 0x2B4,
.endx = 0xA27,
.endy = 0x6EB,
.width = 1280,
.height = 722,
.binning = 0,
.test_pattern = 0
},
.mode_1280x720_120 = { //Camera output @120
.pix_clk_mul = 0x58,
.pix_clk_div = 0x4,
.integration = 850 - 4,
.gain = 0x80,
.linelength = 0xD78,
.framelength = 850,
.startx = 0x2A8,
.starty = 0x2B4,
.endx = 0xA27,
.endy = 0x6EB,
.width = 1280,
.height = 722,
.binning = 0,
.test_pattern = 0
},
.mode_1920x1080_30 = { //camera output 1920x1080 @30FPS
.pix_clk_mul = 0x50,
.pix_clk_div = 0x5,
.integration = 2474 - 4,
.gain = 0x80,
.linelength = 0xD78,
.framelength = 2474,
.startx = 0x2A8,
.starty = 0x2B4,
.endx = 0xA27,
.endy = 0x6EB,
.width = 1920,
.height = 1082,
.binning = 0,
.test_pattern = 0
},
.mode_1920x1080_60 = { //camera output 1920x1080 @60FPS
.pix_clk_mul = 0x50,
.pix_clk_div = 0x5,
.integration = 1237 - 4,
.gain = 0x80,
.linelength = 0xD78,
.framelength = 1237,
.startx = 0x2A8,
.starty = 0x2B4,
.endx = 0xA27,
.endy = 0x6EB,
.width = 1920,
.height = 1082,
.binning = 0,
.test_pattern = 0
},
.mode_640x128_682 = { //camera output 640x128 pixel @682 FPS
.pix_clk_mul = 0x53,
.pix_clk_div = 0x4,
.integration = 141 - 4,
.gain = 200,
.linelength = 0xD78,
.framelength = 141,
.startx = 1320,
.starty = 990,
.endx = 2600,
.endy = 1609,
.width = 640,
.height = 128,
.binning = 2,
.test_pattern = 0
},
.mode_640x80_1000 = { //camera output 640x80 pixel @1000 FPS
.pix_clk_mul = 0x53,
.pix_clk_div = 0x4,
.integration = 96 - 4,
.gain = 200,
.linelength = 0xD78,
.framelength = 96,
.startx = 1320,
.starty = 990,
.endx = 2600,
.endy = 1561,
.width = 640,
.height = 80,
.binning = 2,
.test_pattern = 0
},
.mode_3280x2464_15 = { //full frame 3280x2464 @15FPS
.pix_clk_mul = 0x31,
.pix_clk_div = 0x5,
.integration = 3031 - 4,
.gain = 200,
.linelength = 0xD78,
.framelength = 3031,
.startx = 0,
.starty = 0,
.endx = 3279,
.endy = 2463,
.width = 3280,
.height = 2464,
.binning = 0,
.test_pattern = 0
},
};
static void SensorI2CAccessDelay (CyU3PReturnStatus_t status)
{
/* Add a 10us delay if the I2C operation that preceded this call was successful. */
if (status == CY_U3P_SUCCESS)
CyU3PBusyWait (50);
}
CyU3PReturnStatus_t sensor_i2c_write(uint16_t reg_addr, uint8_t data)
{
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
CyU3PI2cPreamble_t preamble;
uint8_t buf[2];
/* Set the parameters for the I2C API access and then call the write API. */
preamble.buffer[0] = SENSOR_ADDR_WR;
preamble.buffer[1] = (reg_addr >> 8) & 0xFF;
preamble.buffer[2] = (reg_addr) & 0xFF;
preamble.length = 3; /* Three byte preamble. */
preamble.ctrlMask = 0x0000; /* No additional start and stop bits. */
buf[0] = data;
apiRetStatus = CyU3PI2cTransmitBytes (&preamble, buf, 1, 0);
SensorI2CAccessDelay (apiRetStatus);
return apiRetStatus;
}
CyU3PReturnStatus_t sensor_i2c_read(uint16_t reg_addr , uint8_t *buffer)
{
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
CyU3PI2cPreamble_t preamble;
preamble.length = 4;
preamble.buffer[0] = SENSOR_ADDR_RD & I2C_SLAVEADDR_MASK; /* Mask out the transfer type bit. */
preamble.buffer[1] = (reg_addr >> 8) & 0xFF;
preamble.buffer[2] = reg_addr & 0xFF;
preamble.buffer[3] = SENSOR_ADDR_RD ;
preamble.ctrlMask = 1<<2; /* Send start bit after third byte of preamble. */
apiRetStatus = CyU3PI2cReceiveBytes (&preamble, buffer, 1, 0);
SensorI2CAccessDelay (apiRetStatus);
return apiRetStatus;
}
static CyU3PReturnStatus_t camera_stream_on (uint8_t on)
{
return sensor_i2c_write(REG_MODE_SEL , on);
}
void SensorReset (void)
{
sensor_i2c_write(REG_SW_RESET , 0x01);
/* Wait for some time to allow proper reset. */
CyU3PThreadSleep (10);
/* Delay the allow the sensor to power up. */
sensor_i2c_write(REG_SW_RESET , 0x00);
CyU3PThreadSleep (10);
return;
}
static void set_mirror_flip(uint8_t image_mirror)
{
// CyU3PDebugPrint(4,"image_mirror = %d\n", image_mirror);
/********************************************************
*
* 0x3820[2] ISP Vertical flip
* 0x3820[1] Sensor Vertical flip
*
* 0x3821[2] ISP Horizontal mirror
* 0x3821[1] Sensor Horizontal mirror
*
* ISP and Sensor flip or mirror register bit should be the same!!
*
********************************************************/
uint8_t iTemp;
image_mirror = IMAGE_NORMAL;
sensor_i2c_read(REG_IMG_ORIENT , iTemp);
iTemp = iTemp & 0x03;
switch (image_mirror)
{
case IMAGE_NORMAL:
sensor_i2c_write(REG_IMG_ORIENT, iTemp | 0x03); //Set normal
break;
case IMAGE_V_MIRROR:
sensor_i2c_write(REG_IMG_ORIENT, iTemp | 0x01); //Set flip
break;
case IMAGE_H_MIRROR:
sensor_i2c_write(REG_IMG_ORIENT, iTemp | 0x02); //Set mirror
break;
case IMAGE_HV_MIRROR:
sensor_i2c_write(REG_IMG_ORIENT, iTemp); //Set mirror and flip
break;
}
}
void sensor_handle_uvc_control(uint8_t frame_index, uint32_t interval)
{
switch(frame_index)
{
case FRAME_640x480:
{
if (interval == INTERVAL_30)
{
selected_img_mode = &sensor_config->mode_640x480_30;
}
else if(interval == INTERVAL_200)
{
selected_img_mode = &sensor_config->mode_640x480_200;
}
}
break;
case FRAME_1280x720:
{
if (interval == INTERVAL_30)
{
selected_img_mode = &sensor_config->mode_1280x720_30;
}
else if(interval == INTERVAL_60)
{
selected_img_mode = &sensor_config->mode_1280x720_60;
}
else if(interval == INTERVAL_120)
{
//selected_img_mode = &sensor_config->mode_1280x720_120;
selected_img_mode = &sensor_config->mode_1280x720_60;
}
}
break;
case FRAME_1920x1080:
{
if (interval == INTERVAL_30)
{
selected_img_mode = &sensor_config->mode_1920x1080_30;
}
else if(interval == INTERVAL_60)
{
//selected_img_mode = &sensor_config->mode_1920x1080_60;
selected_img_mode = &sensor_config->mode_1920x1080_30;
}
}
break;
case FRAME_3280x2462:
{
if (interval == INTERVAL_7)
{
//selected_img_mode = &sensor_config->mode_3280x2464_15;
selected_img_mode = &sensor_config->mode_3280x2464_7;
}
}
break;
case FRMAE_640x128:
{
if (interval == INTERVAL_682)
{
selected_img_mode = &sensor_config->mode_640x128_682;
}
}
break;
case FRMAE_640x80:
{
if (interval == INTERVAL_1000)
{
selected_img_mode = &sensor_config->mode_640x80_1000;
}
}
break;
default:
{
}
}
sensor_configure_mode (selected_img_mode);
}
void sensor_configure_mode(imgsensor_mode_t * mode)
{
set_mirror_flip(mode->mirror);
camera_stream_on(false);
sensor_i2c_write(REG_PLL_VT_MPY_MSB, GET_WORD_MSB(mode->pix_clk_mul));
sensor_i2c_write(REG_PLL_VT_MPY_LSB, GET_WORD_LSB(mode->pix_clk_mul));
sensor_i2c_write(REG_VTPXCK_DIV, GET_WORD_LSB(mode->pix_clk_div));
sensor_i2c_write(REG_INTEGRATION_TIME_MSB, GET_WORD_MSB(mode->integration));
sensor_i2c_write(REG_INTEGRATION_TIME_LSB, GET_WORD_LSB(mode->integration));
sensor_i2c_write(REG_ANALOG_GAIN, GET_WORD_LSB(mode->gain));
sensor_i2c_write(REG_LINE_LEN_MSB, GET_WORD_MSB(mode->linelength));
sensor_i2c_write(REG_LINE_LEN_LSB, GET_WORD_LSB(mode->linelength));
sensor_i2c_write(REG_FRAME_LEN_MSB, GET_WORD_MSB(mode->framelength));
sensor_i2c_write(REG_FRAME_LEN_LSB, GET_WORD_LSB(mode->framelength));
sensor_i2c_write(REG_X_ADD_STA_MSB, GET_WORD_MSB(mode->startx));
sensor_i2c_write(REG_X_ADD_STA_LSB, GET_WORD_LSB(mode->startx));
sensor_i2c_write(REG_Y_ADD_STA_MSB, GET_WORD_MSB(mode->starty));
sensor_i2c_write(REG_Y_ADD_STA_LSB, GET_WORD_LSB(mode->starty));
sensor_i2c_write(REG_X_ADD_END_MSB, GET_WORD_MSB(mode->endx));
sensor_i2c_write(REG_X_ADD_END_LSB, GET_WORD_LSB(mode->endx));
sensor_i2c_write(REG_Y_ADD_END_MSB, GET_WORD_MSB(mode->endy));
sensor_i2c_write(REG_Y_ADD_END_LSB, GET_WORD_LSB(mode->endy));
sensor_i2c_write(REG_X_OUT_SIZE_MSB, GET_WORD_MSB(mode->width));
sensor_i2c_write(REG_X_OUT_SIZE_LSB, GET_WORD_LSB(mode->width));
sensor_i2c_write(REG_Y_OUT_SIZE_MSB, GET_WORD_MSB(mode->height));
sensor_i2c_write(REG_Y_OUT_SIZE_LSB, GET_WORD_LSB(mode->height));
sensor_i2c_write(REG_TEST_PATTERN_LSB, (mode->test_pattern < 8)? mode->test_pattern : 0);
sensor_i2c_write(REG_TP_WIDTH_MSB, GET_WORD_MSB(mode->width));
sensor_i2c_write(REG_TP_WIDTH_LSB, GET_WORD_LSB(mode->width));
sensor_i2c_write(REG_TP_HEIGHT_MSB, GET_WORD_MSB(mode->height));
sensor_i2c_write(REG_TP_HEIGHT_LSB, GET_WORD_LSB(mode->height));
if ( mode->binning == 2)
{
sensor_i2c_write(REG_BINNING_H, 0x03);
sensor_i2c_write(REG_BINNING_V, 0x03);
}
else
{
sensor_i2c_write(REG_BINNING_H, 0x00);
sensor_i2c_write(REG_BINNING_V, 0x00);
}
camera_stream_on(sensor_config->sensor_mode);
}
uint8_t SensorI2cBusTest (void)
{
uint8_t model_lsb;
uint8_t model_msb;
sensor_i2c_read (REG_MODEL_ID_MSB, &model_msb);
sensor_i2c_read (REG_MODEL_ID_LSB, &model_lsb);
if (((((uint16_t)model_msb & 0x0F) << 8) | model_lsb) == CAMERA_ID )
{
CyU3PDebugPrint(4,"I2C Sensor id: 0x%x\n", (((uint16_t)model_msb & 0x0F) << 8) | model_lsb);
return CY_U3P_SUCCESS;
}
return CY_U3P_ERROR_DMA_FAILURE;
}
void SensorInit (void)
{
if (SensorI2cBusTest() != CY_U3P_SUCCESS) /* Verify that the sensor is connected. */
{
CyU3PDebugPrint (4, "Error: Reading Sensor ID failed!\r\n");
return;
}
for (uint16_t i = 0; i < _countof(mode_default); i++)
{
//CyU3PDebugPrint (4, "Reg 0x%x val 0x%x\n", (mode_default + i)->address, (mode_default + i)->val);
sensor_i2c_write((mode_default + i)->address, (mode_default + i)->val);
}
sensor_config = &sensor_config_2LANE;
sensor_configure_mode(&sensor_config->mode_1280x720_30);
}
uint8_t SensorGetBrightness (void)
{
return selected_img_mode->gain;
}
void SensorSetBrightness (uint8_t input)
{
selected_img_mode->gain = input;
sensor_i2c_write (REG_ANALOG_GAIN, input);
}
uint16_t sensor_get_min_exposure (void)
{
return 0;
}
uint16_t sensor_get_max_exposure (void)
{
return sensor_config->mode_3280x2464_15.integration;
}
uint16_t sensor_get_def_exposure (void)
{
return selected_img_mode->integration;
}
uint16_t sensor_get_exposure (void)
{
return selected_img_mode->integration;
}
void sensor_set_exposure (uint16_t integration)
{
if (integration > selected_img_mode->integration)
{
integration = selected_img_mode->integration;
}
sensor_i2c_write (REG_INTEGRATION_TIME_MSB, (integration >> 8) & 0xFF);
sensor_i2c_write (REG_INTEGRATION_TIME_LSB, integration & 0xFF);
}
uint8_t sensor_get_test_pattern (void)
{
return selected_img_mode->test_pattern;
}
void sensor_set_test_pattern (uint8_t test_pattern)
{
if (test_pattern > 8)
{
test_pattern = 0;
}
selected_img_mode->test_pattern = test_pattern;
sensor_i2c_write (REG_TEST_PATTERN_LSB, test_pattern);
}

View File

@ -0,0 +1,183 @@
#ifndef _IMX219MIPI_SENSOR_H
#define _IMX219MIPI_SENSOR_H
#include <cyu3types.h>
#include <stdbool.h>
#define SENSOR_ADDR_WR 0x20 /* Slave address used to write sensor registers. */
#define SENSOR_ADDR_RD 0x21 /* Slave address used to read from sensor registers. */
#define I2C_SLAVEADDR_MASK 0xFE /* Mask to get actual I2C slave address value without direction bit. */
/* GPIO 22 on FX3 is used to reset the Image sensor. */
#define DEBUG1_GPIO 23
#define DEBUG_GPIO 27
#define SENSOR_RESET_GPIO 22
#define _countof(array) (sizeof(array) / sizeof(array[0]))
#define GET_WORD_MSB(x) ((x >> 8) & 0xFF)
#define GET_WORD_LSB(x) ( x & 0xFF)
#define IMX219_SENSOR_ID 0x0219
#define CAMERA_ID IMX219_SENSOR_ID
#define REG_SW_RESET 0x0103
#define REG_MODEL_ID_MSB 0x0000
#define REG_MODEL_ID_LSB 0x0001
#define REG_MODE_SEL 0x0100
#define REG_CSI_LANE 0x0114
#define REG_DPHY_CTRL 0x0128
#define REG_EXCK_FREQ_MSB 0x012A
#define REG_EXCK_FREQ_LSB 0x012B
#define REG_FRAME_LEN_MSB 0x0160
#define REG_FRAME_LEN_LSB 0x0161
#define REG_LINE_LEN_MSB 0x0162
#define REG_LINE_LEN_LSB 0x0163
#define REG_X_ADD_STA_MSB 0x0164
#define REG_X_ADD_STA_LSB 0x0165
#define REG_X_ADD_END_MSB 0x0166
#define REG_X_ADD_END_LSB 0x0167
#define REG_Y_ADD_STA_MSB 0x0168
#define REG_Y_ADD_STA_LSB 0x0169
#define REG_Y_ADD_END_MSB 0x016A
#define REG_Y_ADD_END_LSB 0x016B
#define REG_X_OUT_SIZE_MSB 0x016C
#define REG_X_OUT_SIZE_LSB 0x016D
#define REG_Y_OUT_SIZE_MSB 0x016E
#define REG_Y_OUT_SIZE_LSB 0x016F
#define REG_X_ODD_INC 0x0170
#define REG_Y_ODD_INC 0x0171
#define REG_IMG_ORIENT 0x0172
#define REG_BINNING_H 0x0174
#define REG_BINNING_V 0x0175
#define REG_BIN_CALC_MOD_H 0x0176
#define REG_BIN_CALC_MOD_V 0x0177
#define REG_CSI_FORMAT_C 0x018C
#define REG_CSI_FORMAT_D 0x018D
#define REG_DIG_GAIN_GLOBAL_MSB 0x0158
#define REG_DIG_GAIN_GLOBAL_LSB 0x0159
#define REG_ANA_GAIN_GLOBAL 0x0157
#define REG_INTEGRATION_TIME_MSB 0x015A
#define REG_INTEGRATION_TIME_LSB 0x015B
#define REG_ANALOG_GAIN 0x0157
#define REG_VTPXCK_DIV 0x0301
#define REG_VTSYCK_DIV 0x0303
#define REG_PREPLLCK_VT_DIV 0x0304
#define REG_PREPLLCK_OP_DIV 0x0305
#define REG_PLL_VT_MPY_MSB 0x0306
#define REG_PLL_VT_MPY_LSB 0x0307
#define REG_OPPXCK_DIV 0x0309
#define REG_OPSYCK_DIV 0x030B
#define REG_PLL_OP_MPY_MSB 0x030C
#define REG_PLL_OP_MPY_LSB 0x030D
#define REG_TEST_PATTERN_MSB 0x0600
#define REG_TEST_PATTERN_LSB 0x0601
#define REG_TP_RED_MSB 0x0602
#define REG_TP_RED_LSB 0x0603
#define REG_TP_GREEN_MSB 0x0604
#define REG_TP_GREEN_LSB 0x0605
#define REG_TP_BLUE_MSB 0x0606
#define REG_TP_BLUE_LSB 0x0607
#define REG_TP_X_OFFSET_MSB 0x0620
#define REG_TP_X_OFFSET_LSB 0x0621
#define REG_TP_Y_OFFSET_MSB 0x0622
#define REG_TP_Y_OFFSET_LSB 0x0623
#define REG_TP_WIDTH_MSB 0x0624
#define REG_TP_WIDTH_LSB 0x0625
#define REG_TP_HEIGHT_MSB 0x0626
#define REG_TP_HEIGHT_LSB 0x0627
typedef enum{
IMGSENSOR_MODE_INIT,
IMGSENSOR_MODE_PREVIEW,
IMGSENSOR_MODE_CAPTURE,
IMGSENSOR_MODE_VIDEO,
IMGSENSOR_MODE_HIGH_SPEED_VIDEO,
IMGSENSOR_MODE_SLIM_VIDEO,
} IMGSENSOR_MODE;
enum
{
IMAGE_NORMAL=0,
IMAGE_H_MIRROR,
IMAGE_V_MIRROR,
IMAGE_HV_MIRROR
};
typedef struct imgsensor_mode_struct_s {
uint16_t pix_clk_mul;
uint16_t pix_clk_div;
uint8_t mirror;
uint16_t integration;
uint16_t gain;
uint16_t linelength;
uint16_t framelength;
uint16_t startx;
uint16_t starty;
uint16_t endx;
uint16_t endy;
uint16_t width;
uint16_t height;
uint16_t framerate;
uint8_t binning;
uint8_t test_pattern;
} imgsensor_mode_t;
/* SENSOR PRIVATE STRUCT FOR CONSTANT*/
typedef struct image_sensor_config_s {
uint8_t sensor_mode;
imgsensor_mode_t mode_640x480_30; //640x480 30fps
imgsensor_mode_t mode_1280x720_30; //1280x720 30fps
imgsensor_mode_t mode_1280x720_60; //1280x720 60fps
imgsensor_mode_t mode_1280x720_120; //1280x720 120fps
imgsensor_mode_t mode_1920x1080_30; //1920x1080 30fps
imgsensor_mode_t mode_1920x1080_60; //1920x1080 60fps
imgsensor_mode_t mode_640x480_200;
imgsensor_mode_t mode_640x128_682;
imgsensor_mode_t mode_640x128_600;
imgsensor_mode_t mode_640x80_900;
imgsensor_mode_t mode_640x80_1000;
imgsensor_mode_t mode_3280x2464_15;
imgsensor_mode_t mode_3280x2464_7;
} image_sensor_config_t;
typedef struct imx219_reg_s {
uint16_t address;
uint8_t val;
}imx219_reg_t;
void SensorInit (void);
void SensorReset (void);
uint8_t SensorI2cBusTest (void);
uint8_t SensorGetBrightness (void);
void SensorSetBrightness (uint8_t input);
uint16_t sensor_get_exposure (void);
uint16_t sensor_get_max_exposure();
uint16_t sensor_get_min_exposure();
uint16_t sensor_get_def_exposure();
void sensor_set_exposure (uint16_t input);
uint8_t sensor_get_test_pattern (void);
void sensor_set_test_pattern (uint8_t input);
void sensor_configure_mode(imgsensor_mode_t * mode);
void sensor_handle_uvc_control(uint8_t frame_index, uint32_t interval);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,298 @@
/*
## Cypress FX3 Camera Kit header file (uvc.h)
## ===========================
##
## Copyright Cypress Semiconductor Corporation, 2010-2012,
## All Rights Reserved
## UNPUBLISHED, LICENSED SOFTWARE.
##
## CONFIDENTIAL AND PROPRIETARY INFORMATION
## WHICH IS THE PROPERTY OF CYPRESS.
##
## Use of this file is governed
## by the license agreement included in the file
##
## <install>/license/license.txt
##
## where <install> is the Cypress software
## installation root directory path.
##
## ===========================
*/
/* This header file defines the UVC application constants and the Video Frame configurations */
#ifndef _INCLUDED_CYFXUVCAPP_H_
#define _INCLUDED_CYFXUVCAPP_H_
#include <cyu3types.h>
#include <cyu3usbconst.h>
#include <cyu3externcstart.h>
/* Definitions to enable/disable special features in this UVC application. */
//#define UVC_PTZ_SUPPORT /* Enable if Pan, Tilt and Zoom controls are to be implemented. */
//#define BACKFLOW_DETECT /* Enable if buffer overflow conditions are to be detected. */
//#define DEBUG_PRINT_FRAME_COUNT /* Enable UART debug prints to print the frame count every end of frame */
/* #define USB_DEBUG_INTERFACE */ /* Enable custom USB interface for sensor interface debugging. */
/* #define FX3_UVC_1_0_SUPPORT */ /* Enable to run as UVC 1.0 device. Default is UVC 1.1 device */
/* #define UVC_EXTENSION_UNIT */ /* Enable to add a sample UVC extension unit that communicates with
* the host application associated with this firmware */
#define FRAME_TIMER_ENABLE /* Enable/Disable a timer that aborts an ongoing frame and restarts streaming
* when the transfer is stalled. Default setting is to enable frame timer */
/* UVC application thread parameters. */
#define UVC_APP_THREAD_STACK (0x1000) /* Stack size for the video streaming thread is 4 KB. */
#define UVC_APP_THREAD_PRIORITY (8) /* Priority for the video streaming thread is 8. */
#define UVC_APP_EP0_THREAD_STACK (0x0800) /* Stack size for the UVC control request thread is 2 KB. */
#define UVC_APP_EP0_THREAD_PRIORITY (8) /* Priority for the UVC control request thread is 8. */
/* DMA socket selection for UVC data transfer. */
#define CY_FX_EP_VIDEO_CONS_SOCKET 0x03 /* USB Consumer socket 3 is used for video data. */
#define CY_FX_EP_CONTROL_STATUS_SOCKET 0x02 /* USB Consumer socket 2 is used for the status pipe. */
/* Endpoint definition for UVC application */
#define CY_FX_EP_IN_TYPE 0x80 /* USB IN end points have MSB set */
#define CY_FX_EP_BULK_VIDEO (CY_FX_EP_VIDEO_CONS_SOCKET | CY_FX_EP_IN_TYPE) /* EP 3 IN */
#define CY_FX_EP_CONTROL_STATUS (CY_FX_EP_CONTROL_STATUS_SOCKET | CY_FX_EP_IN_TYPE) /* EP 2 IN */
#ifdef USB_DEBUG_INTERFACE
/* Socket and endpoint definitions for the USB debug interface. */
#define CY_FX_EP_DEBUG_CMD_SOCKET 0x04 /* USB Producer socket 4 is used as the debug command pipe. */
#define CY_FX_EP_DEBUG_RSP_SOCKET 0x04 /* USB Consumer socket 4 is used as the debug response pipe. */
#define CY_FX_EP_DEBUG_CMD (CY_FX_EP_DEBUG_CMD_SOCKET) /* EP 4 OUT */
#define CY_FX_EP_DEBUG_RSP (CY_FX_EP_DEBUG_RSP_SOCKET | CY_FX_EP_IN_TYPE) /* EP 4 IN */
#endif
/* Invalid state for the GPIF state machine */
#define CY_FX_UVC_INVALID_GPIF_STATE (257)
/* Timeout period for the GPIF state machine switch */
#define CY_FX_UVC_GPIF_SWITCH_TIMEOUT (2)
/* UVC Video Streaming Endpoint Packet Size */
#define CY_FX_EP_BULK_VIDEO_PKT_SIZE (0x400) /* 1024 Bytes */
/* UVC Video Streaming Endpoint Packet Count */
#define CY_FX_EP_BULK_VIDEO_PKTS_COUNT (0x20) /* 32 packets (burst of 32) per DMA buffer. */
/* DMA buffer size used for video streaming. */
#define CY_FX_UVC_STREAM_BUF_SIZE (CY_FX_EP_BULK_VIDEO_PKTS_COUNT * CY_FX_EP_BULK_VIDEO_PKT_SIZE) /* 16 KB */ //Totoal RAM availabe for dma buffer on CYUSB3014 224KB
/* Maximum video data that can be accommodated in one DMA buffer. */
#define CY_FX_UVC_BUF_FULL_SIZE (CY_FX_UVC_STREAM_BUF_SIZE - 16)
/* Number of DMA buffers per GPIF DMA thread. */
#define CY_FX_UVC_STREAM_BUF_COUNT (3)
/* Low Byte - UVC Video Streaming Endpoint Packet Size */
#define CY_FX_EP_BULK_VIDEO_PKT_SIZE_L (uint8_t)(CY_FX_EP_BULK_VIDEO_PKT_SIZE & 0x00FF)
/* High Byte - UVC Video Streaming Endpoint Packet Size and No. of BULK packets */
#define CY_FX_EP_BULK_VIDEO_PKT_SIZE_H (uint8_t)((CY_FX_EP_BULK_VIDEO_PKT_SIZE & 0xFF00) >> 8)
/* Maximum commit buffer failures to detect a stop streaming event in a MAC OS */
#define CY_FX_UVC_MAX_COMMIT_BUF_FAILURE_CNT (30)
/* Event bits used for signaling the UVC application threads. */
/* Stream request event. Event flag that indicates that the streaming of video data has
been enabled by the host. This flag is retained ON as long as video streaming is allowed,
and is only turned off when the host indicates that data transfer should be stopped.
*/
#define CY_FX_UVC_STREAM_EVENT (1 << 0)
/* Abort streaming event. This event flag is set when the UVC host sends down a request
(SET_INTERFACE or CLEAR_FEATURE) that indicates that video streaming should be stopped.
The CY_FX_UVC_STREAM_EVENT event is cleared before setting this flag, and these two
events can be considered as mutually exclusive.
*/
#define CY_FX_UVC_STREAM_ABORT_EVENT (1 << 1)
/* UVC VIDEO_CONTROL_REQUEST event. This event flag indicates that a UVC class specific
request addressed to the video control interface has been received. It should be cleared
as soon as serviced by the firmware.
*/
#define CY_FX_UVC_VIDEO_CONTROL_REQUEST_EVENT (1 << 2)
/* UVC VIDEO_STREAM_REQUEST event. This event flag indicates that a UVC class specific
request addressed to the video streaming interface has been received. It should be cleared
as soon as serviced by the firmware.
*/
#define CY_FX_UVC_VIDEO_STREAM_REQUEST_EVENT (1 << 3)
/* FX3 DMA Reset event. This event is set when FX3 is not able to commit a buffer due to a slower USB Host or due to
* a frame timer overflow. When the device is streaming a higher resolution with higher fps, the USB bandwidth will
* be saturated and Host will not be able to keep up. The video stream may work for few seconds and then device will
* receive a commit buffer failure. It is also possible that Sensor/ISP fails to send video data due to some reasons.
* In such cases, it is better to reset DMA and restart the video stream so that there is a continuous video preview.
*/
#define CY_FX_UVC_DMA_RESET_EVENT (1 << 4)
/* USB suspend event handler. This event is set when the USB host sends a USB suspend event to put the FX3
* device into low power mode. This event is sent when the Host application is closed and after the device enumerates.
*/
#define CY_FX_USB_SUSPEND_EVENT_HANDLER (1 << 5)
#ifdef USB_DEBUG_INTERFACE
/* USB Debug Command event. This event flag indicates that a USB debug command has been
received on the command endpoint.
*/
#define CY_FX_USB_DEBUG_CMD_EVENT (1 << 6)
#endif
/*
The following constants are taken from the USB and USB Video Class (UVC) specifications.
They are defined here for convenient usage in the rest of the application source code.
*/
#define CY_FX_INTF_ASSN_DSCR_TYPE (0x0B) /* Type code for Interface Association Descriptor (IAD) */
#define CY_FX_USB_SETUP_REQ_TYPE_MASK (uint32_t)(0x000000FF) /* Mask for bmReqType field from a control request. */
#define CY_FX_USB_SETUP_REQ_MASK (uint32_t)(0x0000FF00) /* Mask for bRequest field from a control request. */
#define CY_FX_USB_SETUP_VALUE_MASK (uint32_t)(0xFFFF0000) /* Mask for wValue field from a control request. */
#define CY_FX_USB_SETUP_INDEX_MASK (uint32_t)(0x0000FFFF) /* Mask for wIndex field from a control request. */
#define CY_FX_USB_SETUP_LENGTH_MASK (uint32_t)(0xFFFF0000) /* Mask for wLength field from a control request. */
#define CY_FX_USB_SET_INTF_REQ_TYPE (uint8_t)(0x01) /* USB SET_INTERFACE Request Type. */
#define CY_FX_USB_SET_INTERFACE_REQ (uint8_t)(0x0B) /* USB SET_INTERFACE Request code. */
#define CY_FX_UVC_MAX_HEADER (12) /* Maximum UVC header size, in bytes. */
#define CY_FX_UVC_HEADER_DEFAULT_BFH (0x8C) /* Default BFH (Bit Field Header) for the UVC Header */
#ifdef FX3_UVC_1_0_SUPPORT
#define CY_FX_UVC_MAX_PROBE_SETTING (26) /* Maximum number of bytes in Probe Control */
#define CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED (32) /* Probe control data size aligned to 16 bytes. */
#else
#define CY_FX_UVC_MAX_PROBE_SETTING (34) /* Maximum number of bytes in Probe Control */
#define CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED (48) /* Probe control data size aligned to 16 bytes. */
#endif
#define CY_FX_UVC_HEADER_FRAME (0) /* UVC header value for normal frame indication */
#define CY_FX_UVC_HEADER_EOF (uint8_t)(1 << 1) /* UVC header value for end of frame indication */
#define CY_FX_UVC_HEADER_FRAME_ID (uint8_t)(1 << 0) /* Frame ID toggle bit in UVC header. */
#define CY_FX_USB_UVC_SET_REQ_TYPE (uint8_t)(0x21) /* UVC Interface SET Request Type */
#define CY_FX_USB_UVC_GET_REQ_TYPE (uint8_t)(0xA1) /* UVC Interface GET Request Type */
#define CY_FX_USB_UVC_GET_CUR_REQ (uint8_t)(0x81) /* UVC GET_CUR Request */
#define CY_FX_USB_UVC_SET_CUR_REQ (uint8_t)(0x01) /* UVC SET_CUR Request */
#define CY_FX_USB_UVC_GET_MIN_REQ (uint8_t)(0x82) /* UVC GET_MIN Request */
#define CY_FX_USB_UVC_GET_MAX_REQ (uint8_t)(0x83) /* UVC GET_MAX Request */
#define CY_FX_USB_UVC_GET_RES_REQ (uint8_t)(0x84) /* UVC GET_RES Request */
#define CY_FX_USB_UVC_GET_LEN_REQ (uint8_t)(0x85) /* UVC GET_LEN Request */
#define CY_FX_USB_UVC_GET_INFO_REQ (uint8_t)(0x86) /* UVC GET_INFO Request */
#define CY_FX_USB_UVC_GET_DEF_REQ (uint8_t)(0x87) /* UVC GET_DEF Request */
#define CY_FX_UVC_STREAM_INTERFACE (uint8_t)(1) /* Streaming Interface : Alternate Setting 1 */
#define CY_FX_UVC_CONTROL_INTERFACE (uint8_t)(0) /* Control Interface */
#define CY_FX_UVC_PROBE_CTRL (uint16_t)(0x0100) /* wValue setting used to access PROBE control. */
#define CY_FX_UVC_COMMIT_CTRL (uint16_t)(0x0200) /* wValue setting used to access COMMIT control. */
#define CY_FX_UVC_INTERFACE_CTRL (uint8_t)(0) /* wIndex value used to select UVC interface control. */
#define CY_FX_UVC_CAMERA_TERMINAL_ID (uint8_t)(1) /* wIndex value used to select Camera terminal. */
#define CY_FX_UVC_PROCESSING_UNIT_ID (uint8_t)(2) /* wIndex value used to select Processing Unit. */
#define CY_FX_UVC_EXTENSION_UNIT_ID (uint8_t)(3) /* wIndex value used to select Extension Unit. */
/* Processing Unit specific UVC control selector codes defined in the USB Video Class specification. */
#define CY_FX_UVC_PU_BACKLIGHT_COMPENSATION_CONTROL (uint16_t)(0x0100)
#define CY_FX_UVC_PU_BRIGHTNESS_CONTROL (uint16_t)(0x0200)
#define CY_FX_UVC_PU_CONTRAST_CONTROL (uint16_t)(0x0300)
#define CY_FX_UVC_PU_GAIN_CONTROL (uint16_t)(0x0400)
#define CY_FX_UVC_PU_POWER_LINE_FREQUENCY_CONTROL (uint16_t)(0x0500)
#define CY_FX_UVC_PU_HUE_CONTROL (uint16_t)(0x0600)
#define CY_FX_UVC_PU_SATURATION_CONTROL (uint16_t)(0x0700)
#define CY_FX_UVC_PU_SHARPNESS_CONTROL (uint16_t)(0x0800)
#define CY_FX_UVC_PU_GAMMA_CONTROL (uint16_t)(0x0900)
#define CY_FX_UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL (uint16_t)(0x0A00)
#define CY_FX_UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL (uint16_t)(0x0B00)
#define CY_FX_UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL (uint16_t)(0x0C00)
#define CY_FX_UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL (uint16_t)(0x0D00)
#define CY_FX_UVC_PU_DIGITAL_MULTIPLIER_CONTROL (uint16_t)(0x0E00)
#define CY_FX_UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL (uint16_t)(0x0F00)
#define CY_FX_UVC_PU_HUE_AUTO_CONTROL (uint16_t)(0x1000)
#define CY_FX_UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL (uint16_t)(0x1100)
#define CY_FX_UVC_PU_ANALOG_LOCK_STATUS_CONTROL (uint16_t)(0x1200)
/* Camera Terminal specific UVC control selector codes defined in the USB Video Class specification. */
#define CY_FX_UVC_CT_SCANNING_MODE_CONTROL (uint16_t)(0x0100)
#define CY_FX_UVC_CT_AE_MODE_CONTROL (uint16_t)(0x0200)
#define CY_FX_UVC_CT_AE_PRIORITY_CONTROL (uint16_t)(0x0300)
#define CY_FX_UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL (uint16_t)(0x0400)
#define CY_FX_UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL (uint16_t)(0x0500)
#define CY_FX_UVC_CT_FOCUS_ABSOLUTE_CONTROL (uint16_t)(0x0600)
#define CY_FX_UVC_CT_FOCUS_RELATIVE_CONTROL (uint16_t)(0x0700)
#define CY_FX_UVC_CT_FOCUS_AUTO_CONTROL (uint16_t)(0x0800)
#define CY_FX_UVC_CT_IRIS_ABSOLUTE_CONTROL (uint16_t)(0x0900)
#define CY_FX_UVC_CT_IRIS_RELATIVE_CONTROL (uint16_t)(0x0A00)
#define CY_FX_UVC_CT_ZOOM_ABSOLUTE_CONTROL (uint16_t)(0x0B00)
#define CY_FX_UVC_CT_ZOOM_RELATIVE_CONTROL (uint16_t)(0x0C00)
#define CY_FX_UVC_CT_PANTILT_ABSOLUTE_CONTROL (uint16_t)(0x0D00)
#define CY_FX_UVC_CT_PANTILT_RELATIVE_CONTROL (uint16_t)(0x0E00)
#define CY_FX_UVC_CT_ROLL_ABSOLUTE_CONTROL (uint16_t)(0x0F00)
#define CY_FX_UVC_CT_ROLL_RELATIVE_CONTROL (uint16_t)(0x1000)
#define CY_FX_UVC_CT_PRIVACY_CONTROL (uint16_t)(0x1100)
#define LOOP_TIMEOUT (1000) /* Period of frame count updates. */
#ifdef UVC_EXTENSION_UNIT
/* Extension Unit Terminal Controls specific UVC control selector codes */
#define CY_FX_UVC_XU_GET_FIRMWARE_VERSION_CONTROL (uint16_t)(0x0100)
/* Customer specific controls can be added here */
#endif
/* Undefined Terminal Controls specific UVC control selector codes defined in the USB Video Class specification */
#define CY_FX_UVC_VC_REQUEST_ERROR_CODE_CONTROL (uint16_t)(0x0200)
/* Video control Error Codes */
#define CY_FX_UVC_VC_ERROR_CODE_NO_ERROR (0x00)
#define CY_FX_UVC_VC_ERROR_CODE_NOT_READY (0x01)
#define CY_FX_UVC_VC_ERROR_CODE_WRONG_STATE (0x02)
#define CY_FX_UVC_VC_ERROR_CODE_POWER (0x03)
#define CY_FX_UVC_VC_ERROR_CODE_OUT_OF_RANGE (0x04)
#define CY_FX_UVC_VC_ERROR_CODE_INVALID_UNIT (0x05)
#define CY_FX_UVC_VC_ERROR_CODE_INVALID_CONTROL (0x06)
#define CY_FX_UVC_VC_ERROR_CODE_INVALID_REQUEST (0x07)
#define CY_FX_UVC_VC_ERROR_CODE_INVALID_VAL_IN_RANGE (0x08)
#define CY_FX_UVC_VC_ERROR_CODE_UNKNOWN (0xFF)
/* Enum for a DMA reset event */
typedef enum CyFxUvcDmaResetVal
{
CY_FX_UVC_DMA_RESET_EVENT_NOT_ACTIVE = 0, /* FX3 DMA reset event haven't occurred */
CY_FX_UVC_DMA_RESET_COMMIT_BUFFER_FAILURE, /* FX3 DMA reset event caused due to a commit buffer failure */
CY_FX_UVC_DMA_RESET_FRAME_TIMER_OVERFLOW /* FX3 DMA reset event caused due to frame timer overflow */
} CyFxUvcDmaResetVal_t;
/* Enum for different frame timer values */
typedef enum CyFxUvcFrameTimerVal
{
CY_FX_UVC_FRAME_TIMER_VAL_100MS = 100,
CY_FX_UVC_FRAME_TIMER_VAL_200MS = 200,
CY_FX_UVC_FRAME_TIMER_VAL_300MS = 300,
CY_FX_UVC_FRAME_TIMER_VAL_400MS = 400,
} CyFxUvcFrameTimerVal_t;
/* Extern definitions of the USB Enumeration constant arrays used for the UVC application.
These arrays are defined in the cyfxuvcdscr.c file.
*/
extern const uint8_t CyFxUSBDeviceDscr[]; /* USB 2.0 Device descriptor. */
extern const uint8_t CyFxUSBDeviceDscrSS[]; /* USB 3.0 device descriptor. */
extern const uint8_t CyFxUSBDeviceQualDscr[]; /* USB 2.0 Device Qual descriptor. */
extern const uint8_t CyFxUSBBOSDscr[]; /* USB 3.0 BOS descriptor. */
extern const uint8_t CyFxUSBFSConfigDscr[]; /* Full Speed Config descriptor. */
extern const uint8_t CyFxUSBHSConfigDscr[]; /* High Speed Config descriptor. */
extern const uint8_t CyFxUSBSSConfigDscr[]; /* USB 3.0 config descriptor. */
extern const uint8_t CyFxUSBStringLangIDDscr[]; /* String 0 descriptor. */
extern const uint8_t CyFxUSBManufactureDscr[]; /* Manufacturer string descriptor. */
extern const uint8_t CyFxUSBProductDscr[]; /* Product string descriptor. */
#include <cyu3externcend.h>
#define FX3_MUXSEL_GPIO 52
#endif /* _INCLUDED_CYFXUVCAPP_H_ */
/*[]*/

View File

@ -0,0 +1,87 @@
/*
* uvc_settings.h
*
* Created on: Jan 25, 2020
* Author: gaurav
*/
#ifndef UVC_SETTINGS_H_
#define UVC_SETTINGS_H_
#define WBVAL(x) (x & 0xFF),((x >> 8) & 0xFF)
#define DBVAL(x) (x & 0xFF),((x >> 8) & 0xFF),((x >> 16) & 0xFF),((x >> 24) & 0xFF)
#define UVC_WIDTH (unsigned int)3280
#define UVC_HEIGHT (unsigned int)2462
#define CAM_FPS_1000 1000
#define CAM_FPS_682 682
#define CAM_FPS_200 200
#define CAM_FPS_120 120
#define CAM_FPS_60 60
#define CAM_FPS_30 30
#define CAM_FPS_15 15
#define CAM_FPS_7 7
#define INTERVAL_1000 (unsigned long)(10000000/CAM_FPS_1000)
#define INTERVAL_682 (unsigned long)(10000000/CAM_FPS_682)
#define INTERVAL_200 (unsigned long)(10000000/CAM_FPS_200)
#define INTERVAL_120 (unsigned long)(10000000/CAM_FPS_120)
#define INTERVAL_60 (unsigned long)(10000000/CAM_FPS_60)
#define INTERVAL_30 (unsigned long)(10000000/CAM_FPS_30)
#define INTERVAL_15 (unsigned long)(10000000/CAM_FPS_15)
#define INTERVAL_7 (unsigned long)(10000000/CAM_FPS_7)
//640x480 supports 30 and 200FPS
#define UVC_WIDTH_640 (unsigned int)640
#define UVC_HEIGHT_126 (unsigned int)126
#define MIN_BIT_RATE_640x126 (unsigned long)(UVC_WIDTH_640*UVC_HEIGHT_126*16*CAM_FPS_682) //YUY2 4byte per 2 pixel
#define MAX_BIT_RATE_640x126 (unsigned long)(UVC_WIDTH_640*UVC_HEIGHT_126*16*CAM_FPS_682)
#define MAX_FRAME_SIZE_640x126 (unsigned long)(UVC_WIDTH_640*UVC_HEIGHT_126*2)//YUY2 4byte per 2 pixel
#define UVC_WIDTH_640 (unsigned int)640
#define UVC_HEIGHT_78 (unsigned int)78
#define MIN_BIT_RATE_640x78 (unsigned long)(UVC_WIDTH_640*UVC_HEIGHT_78*16*CAM_FPS_1000) //YUY2 4byte per 2 pixel
#define MAX_BIT_RATE_640x78 (unsigned long)(UVC_WIDTH_640*UVC_HEIGHT_78*16*CAM_FPS_1000)
#define MAX_FRAME_SIZE_640x78 (unsigned long)(UVC_WIDTH_640*UVC_HEIGHT_78*2)//YUY2 4byte per 2 pixel
#define UVC_WIDTH_640 (unsigned int)650
#define UVC_HEIGHT_480 (unsigned int)480
#define MIN_BIT_RATE_640x480 (unsigned long)(UVC_WIDTH_640*UVC_HEIGHT_480*16*CAM_FPS_30) //YUY2 4byte per 2 pixel
#define MAX_BIT_RATE_640x480 (unsigned long)(UVC_WIDTH_640*UVC_HEIGHT_480*16*CAM_FPS_200)
#define MAX_FRAME_SIZE_640x480 (unsigned long)(UVC_WIDTH_640*UVC_HEIGHT_480*2)//YUY2 4byte per 2 pixel
#define UVC_WIDTH_1280 (unsigned int)1290
#define UVC_HEIGHT_720 (unsigned int)720
#define MIN_BIT_RATE_1280x720 (unsigned long)(UVC_WIDTH_1280*UVC_HEIGHT_720*16*CAM_FPS_30)
#define MAX_BIT_RATE_1280x720 (unsigned long)(UVC_WIDTH_1280*UVC_HEIGHT_720*16*CAM_FPS_120)
#define MAX_FRAME_SIZE_1280x720 (unsigned long)(UVC_WIDTH_1280*UVC_HEIGHT_720*2)
#define UVC_WIDTH_1920 (unsigned int)1930
#define UVC_HEIGHT_1080 (unsigned int)1080
#define MIN_BIT_RATE_1920x1080 (unsigned long)(UVC_WIDTH_1920*UVC_HEIGHT_1080*16*CAM_FPS_30)
#define MAX_BIT_RATE_1920x1080 (unsigned long)(UVC_WIDTH_1920*UVC_HEIGHT_1080*16*CAM_FPS_60)
#define MAX_FRAME_SIZE_1920x1080 (unsigned long)(UVC_WIDTH_1920*UVC_HEIGHT_1080*2)
#define UVC_WIDTH_3280 (unsigned int)3290
#define UVC_HEIGHT_2462 (unsigned int)2464
#define MIN_BIT_RATE_3280x2462 (unsigned long)(UVC_WIDTH_3280*UVC_HEIGHT_2462*16*CAM_FPS_15)
#define MAX_BIT_RATE_3280x2462 (unsigned long)(UVC_WIDTH_3280*UVC_HEIGHT_2462*16*CAM_FPS_15)
#define MAX_FRAME_SIZE_3280x2462 (unsigned long)(UVC_WIDTH_3280*UVC_HEIGHT_2462*2)
#define MAX_FRAME_SIZE (unsigned long)(UVC_WIDTH_3280*UVC_HEIGHT_2462*2)//yuy2
typedef enum
{
FRAME_640x480 = 1,
FRAME_1280x720,
FRAME_1920x1080,
FRAME_3280x2462,
FRMAE_640x128,
FRMAE_640x80,
}frame_t;
#endif /* UVC_SETTINGS_H_ */