FX3开发入门系列EZ-USB FX3 Software Development Kit

fx3是usb3.0芯片

里边有一个arm 核,

官方资料url
https://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-software-development-kit

FX3开发入门系列EZ-USB FX3 Software Development Kit_第1张图片
FX3开发入门系列EZ-USB FX3 Software Development Kit_第2张图片
文档和示例代码

FX3开发入门系列EZ-USB FX3 Software Development Kit_第3张图片

本文用的windows 下面开发

用的是

FX3_SDK_Windows_v1.3.3.exe

这个软件是集成很多软件 ,有ide 和gpif ii等软件

FX3_SDK_Windows安装之后会出现这些软件
ez usb suite 是eclipse的ide
FX3开发入门系列EZ-USB FX3 Software Development Kit_第4张图片

FX3开发入门系列EZ-USB FX3 Software Development Kit_第5张图片

创建一个新项目了解开发的流程

1.创建 新项目
FX3开发入门系列EZ-USB FX3 Software Development Kit_第6张图片
FX3开发入门系列EZ-USB FX3 Software Development Kit_第7张图片
FX3开发入门系列EZ-USB FX3 Software Development Kit_第8张图片
选 择FX3 Project 建 新项目
FX3开发入门系列EZ-USB FX3 Software Development Kit_第9张图片
FX3开发入门系列EZ-USB FX3 Software Development Kit_第10张图片

在这里插入图片描述
新项目内的文件就一个includes 你的sdk的头文件

FX3开发入门系列EZ-USB FX3 Software Development Kit_第11张图片
cyf_gcc_startup.s 从官方示例取到放项目内
cyxtx.c 也一样从官方取得

main.c 和main.h

main.h
#ifndef MAIN_H_
#define MAIN_H_
#include “cyu3types.h”
#define THREAD_STACK (0x0200) /* App thread stack size /
#define THREAD_PRIORITY (8) /
App thread priority */

#endif /* MAIN_H_ */

main.c

/*

  • main.c
  • Created on: 2020年5月25日
  •  Author: Administrator
    

*/

#include “cyu3system.h”
#include “cyu3os.h”
#include “cyu3error.h”
#include “cyu3gpio.h”
#include “cyu3uart.h”
#include “cyu3utils.h”
#include “main.h”

CyU3PThread Thread1;
CyU3PThread Thread2;
void
Thread1_Entry (
uint32_t input)
{

for (;;)
{
    CyU3PThreadSleep (100);

}

}
void
Thread2_Entry (
uint32_t input)
{

for (;;)
{
    CyU3PThreadSleep (100);
}

}

/* Application define function which creates the application threads. */
void
CyFxApplicationDefine (
void)
{//CyFxApplicationDefine创建线程的。创建2个线程
void *ptr = NULL;
uint32_t ret = CY_U3P_ERROR_MEMORY_ERROR;

// Create thread1
ptr = CyU3PMemAlloc (THREAD_STACK);
if (ptr != NULL)
{
    ret = CyU3PThreadCreate (
            &Thread1,                              /* Thread structure. */
            "Thread 1",                     /* Thread ID and name. */
            Thread1_Entry,                         /* Thread entry function. */
            0,                                     /* Thread input parameter. */
            ptr,                                   /* Pointer to the allocated thread stack. */
            THREAD_STACK,                          /* Allocated thread stack size. */
            THREAD_PRIORITY,                       /* Thread priority. */
            THREAD_PRIORITY,                       /* Thread pre-emption threshold: No preemption. */
            CYU3P_NO_TIME_SLICE,                   /* No time slice. */
            CYU3P_AUTO_START                       /* Start the thread immediately. */
            );
}
else
{
    ret = CY_U3P_ERROR_MEMORY_ERROR;
}
if (ret != CY_U3P_SUCCESS)
{
    goto InitFail;
}
// Create thread2
ptr = CyU3PMemAlloc (THREAD_STACK);
if (ptr != NULL)
{
   ret = CyU3PThreadCreate (
           &Thread2,                              /* Thread structure. */
           "Thread 2",                            /* Thread ID and name. */
           Thread2_Entry,                         /* Thread entry function. */
           0,                                     /* Thread input parameter. */
           ptr,                                   /* Pointer to the allocated thread stack. */
           THREAD_STACK,                          /* Allocated thread stack size. */
           THREAD_PRIORITY,                       /* Thread priority. */
           THREAD_PRIORITY,                       /* Thread pre-emption threshold: No preemption. */
           CYU3P_NO_TIME_SLICE,                   /* No time slice. */
           CYU3P_AUTO_START                       /* Start the thread immediately. */
           );
}
else
{
   ret = CY_U3P_ERROR_MEMORY_ERROR;
}
if (ret != CY_U3P_SUCCESS)
{
   goto InitFail;
}
return;

InitFail:
/* As the initialization failed, there is nothing much we can do. Just reset the device
* so that we go back to the boot-loader. */
CyU3PDeviceReset (CyFalse);
}

int
main (void)
{
CyU3PIoMatrixConfig_t io_cfg;
CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

/* Initialize the device */
//CPU时钟设置、VIC(向量中断控制器)初始化、设置PLLs(锁相环)
//input clk = 19.2 M;SYS_CLK_PLL = 384M,/2....
// Start with the default clock at 384 MHz
/* Initialize the device */
/* For default configuration, pass in NULL as parameter. This will set CPU divider
 * to 2 (~200MHz), DMA and MMIO dividers to 2 (~100MHz); and assume 32KHz standby
 * clock is supplied
 */
status = CyU3PDeviceInit (NULL);
if (status != CY_U3P_SUCCESS)
{
    goto handle_fatal_error;
}

/* Initialize the caches. Enable both Instruction and Data caches. */
//一般在有大数据处理的时候才会打开数据cache,如果是简单的处理打开了cache可能会降低整个系统的效率!cache size:8k.
status = CyU3PDeviceCacheControl (CyTrue, CyTrue, CyTrue);
if (status != CY_U3P_SUCCESS)
{
    goto handle_fatal_error;
}

/* Configure the IO matrix for the device. */
CyU3PMemSet ((uint8_t *)&io_cfg, 0, sizeof(io_cfg));
io_cfg.isDQ32Bit = CyFalse;
io_cfg.s0Mode = CY_U3P_SPORT_INACTIVE;
io_cfg.s1Mode = CY_U3P_SPORT_INACTIVE;
io_cfg.useUart   = CyTrue;
io_cfg.useI2C    = CyFalse;
io_cfg.useI2S    = CyFalse;
io_cfg.useSpi    = CyFalse;
io_cfg.lppMode   = CY_U3P_IO_MATRIX_LPP_UART_ONLY;
/* No GPIOs are enabled. */
io_cfg.gpioSimpleEn[0]  = 0;
io_cfg.gpioSimpleEn[1]  = 0;
io_cfg.gpioComplexEn[0] = 0;
io_cfg.gpioComplexEn[1] = 0;
status = CyU3PDeviceConfigureIOMatrix (&io_cfg);
if (status != CY_U3P_SUCCESS)
{
    goto handle_fatal_error;
}

/* This is a non returnable call for initializing the RTOS kernel */
CyU3PKernelEntry ();//执行到此会跳入: CyFxApplicationDefine().

/* Dummy return to make the compiler happy */
return 0;

handle_fatal_error:

/* Cannot recover from this error. */
while (1);

}
之后编译
FX3开发入门系列EZ-USB FX3 Software Development Kit_第12张图片
FX3开发入门系列EZ-USB FX3 Software Development Kit_第13张图片

代码的学习从示例和官方文档学习

你可能感兴趣的:(EZ-USB,FX3,Software,Development,Kit)