main.c

来自「利用FREESCALE的MCU 内嵌USB接口--usb设备开发设计方案调试软件」· C语言 代码 · 共 82 行

C
82
字号
/*******************************************************************
  Copyright (c) 2007 Freescale Semiconductor
  \file     	Main.c
  \brief    	USB Stack for MC9S08JM60
  \author   	Freescale Semiconductor
  \author     Freescale China
  \author   	Freescale Mexico
  \version    1.0
  \date     	2/January/2007

  * History:
  
  30/July/2007      Start of aplication coding
  15/October/2007   Modifications for new version of application
  17/October/2007   Macros added and funcion names changed
                    MCU & MCG Initialization moved to MCU.c
  12/November/2007  Ported to CodeWarrior 6.0
  23/November/2007  Fixed declaration file dependencies
  10/December/2007  Changed PID and VID to current JM60 demo values
*********************************************************************/

/* Include Files */
#include <hidef.h>          /* for EnableInterrupts macro */
#include "derivative.h"     /* include peripheral declarations */
#include "Usb_Drv.h"        /* USB Main Driver */
#include "Usb_Config.h"     /* USB Configuration header */
#include "FSLTypes_File.h"  /* FSL Standar Definitions */
#include "MCU.h"            /* MCU Initialization */
#include "USB_User_API.h"   /* USB API for USB Module */

/* Prototypes */ 
void Init_Sys(void);


void main(void) 
{
  UINT8 u8Counter;

  /* System Initalization */
  Init_Sys();               
    
  /* Enable Interrupts Macro */
  EnableInterrupts;         

  /* Main Loop */
  for(;;) 
  {
    /* USB Manager, please keep it in main Loop */
    Check_USBBus_Status();                
    
    /* Insert your Code Here */
    
    /*The following is only example code, it waits to receive data at one endpoint and sends it 
      through another one */
    if(CheckEndPointOUT(EP1)) 
    {
        for(u8Counter=0;u8Counter<8;u8Counter++)
            EP2_Buffer[u8Counter]=EP1_Buffer[u8Counter];
        EndPoint_IN(EP2,8);
    }
    /*************************/
  } 
}



/*****************************************************************************
 * Init_Sys: Initialize the system
 * Input: 	None
 * Output: None
 * Parameters: None
 *
 ****************************************************************************/
void Init_Sys(void)
{
	Mcu_Init();               /* MCU general Initialization */
	MCG_Init();	              /* Initialize the MCG module to generate 24MHz bus clock */

  /* Insert you initializing functions Here */
  
	Initialize_USBModule();   /* Initialize USB Module */
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?