Initial commit
This commit is contained in:
@@ -0,0 +1,556 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : CDC1.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : FSL_USB_CDC_Device
|
||||
** Version : Component 01.031, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
**
|
||||
** Settings :
|
||||
** Component name : CDC1
|
||||
** CPU : Kinetis K20D72
|
||||
** CDC Settings : Enabled
|
||||
** .inf ClassGuid : 4D36E978-E325-11CE-BFC1-08002BE10318
|
||||
** .inf VID : 2504
|
||||
** .inf PID : 0300
|
||||
** .inf PRVDR : Freescale
|
||||
** .inf MFGNAME : My Company
|
||||
** .inf DESCRIPTION : Freescale CDC Device
|
||||
** .inf SERVICE : Virtual Com Driver
|
||||
** Bus reported device : FSL CDC DEVICE
|
||||
** Bus reported vendor : FREESCALE INC.
|
||||
** Send Buffer : RingBuffer
|
||||
** Receive Buffer : RingBuffer
|
||||
** Use Timeout : Disabled
|
||||
** Contents :
|
||||
** ClearRxBuffer - void CDC1_ClearRxBuffer(void);
|
||||
** ClearTxBuffer - void CDC1_ClearTxBuffer(void);
|
||||
** GetFreeInTxBuf - word CDC1_GetFreeInTxBuf(void);
|
||||
** GetCharsInTxBuf - word CDC1_GetCharsInTxBuf(void);
|
||||
** GetCharsInRxBuf - word CDC1_GetCharsInRxBuf(void);
|
||||
** GetChar - byte CDC1_GetChar(CDC1_TComData *Chr);
|
||||
** RecvChar - byte CDC1_RecvChar(CDC1_TComData *Chr);
|
||||
** SendChar - byte CDC1_SendChar(CDC1_TComData Chr);
|
||||
** SendString - byte CDC1_SendString(CDC1_TComData *Chr);
|
||||
** SendBlock - byte CDC1_SendBlock(byte *data, word dataSize);
|
||||
** PutBufferChecked - byte CDC1_PutBufferChecked(byte *buf, size_t bufSize);
|
||||
** App_Callback - void CDC1_App_Callback(byte controller_ID, byte event_type, void *val);
|
||||
** Notify_Callback - void CDC1_Notify_Callback(byte controller_ID, byte event_type, void *val);
|
||||
** App_Task - byte CDC1_App_Task(byte *txBuf, size_t txBufSize);
|
||||
** Init - byte CDC1_Init(void);
|
||||
**
|
||||
** (c) Copyright Freescale, all rights reserved, 2013
|
||||
** Ported as Processor Expert component: Erich Styger
|
||||
** http: www.mcuoneclipse.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file CDC1.c
|
||||
** @version 01.00
|
||||
** @brief
|
||||
**
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup CDC1_module CDC1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE CDC1. */
|
||||
|
||||
#include "CDC1.h"
|
||||
#include "hidef.h" /* for EnableInterrupts; macro */
|
||||
#include "hal/derivative.h" /* include peripheral declarations */
|
||||
#include "usb_cdc.h" /* USB CDC Class Header File */
|
||||
#include <stdio.h>
|
||||
/* skip the inclusion in dependency state */
|
||||
#ifndef __NO_SETJMP
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define CONTROLLER_ID (0) /* ID to identify USB CONTROLLER */
|
||||
|
||||
#if HIGH_SPEED_DEVICE
|
||||
static uint_32 g_cdcBuffer[DIC_BULK_OUT_ENDP_PACKET_SIZE>>1];
|
||||
#endif
|
||||
|
||||
/* Virtual COM Application start Init Flag */
|
||||
static volatile boolean start_app = FALSE;
|
||||
|
||||
/* Virtual COM Application Carrier Activate Flag */
|
||||
static volatile boolean start_transactions = FALSE;
|
||||
|
||||
static volatile boolean transactionOngoing = FALSE;
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetFreeInTxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of free character in the send buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of free character in the receive
|
||||
** buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
/*
|
||||
word CDC1_GetFreeInTxBuf(void)
|
||||
{
|
||||
*** Implemented as macro in the header file
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetCharsInTxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of character in the send buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of character in the receive buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
/*
|
||||
word CDC1_GetCharsInTxBuf(void)
|
||||
{
|
||||
*** implemented as macro in the header file
|
||||
return (word)Tx1_NofElements();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetCharsInRxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of character in the receive buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of character in the receive buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
word CDC1_GetCharsInRxBuf(void)
|
||||
{
|
||||
static uint8 txBuf[CDC1_DATA_BUFF_SIZE];
|
||||
|
||||
if(CDC1_App_Task(txBuf, sizeof(txBuf))!=ERR_OK) { /* call USB handler: if active, then this will empty the buffer */
|
||||
}
|
||||
return (word)Rx1_NofElements();
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Receives a character from the USB interface. Function is not
|
||||
** blocking if there is no character in the input buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to where to store the character
|
||||
** received
|
||||
** Returns :
|
||||
** --- - Error code, ERR_OK for success,
|
||||
** ERR_RXEMPTY if nothing is in RX buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
/**
|
||||
byte CDC1_GetChar(CDC1_TComData *Chr)
|
||||
{
|
||||
*** implemented as macro in the header file
|
||||
return Rx1_Get(Chr);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_RecvChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Receives a character from the USB interface. Function is
|
||||
** blocking if there is no character in the input buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to where to store the character
|
||||
** received
|
||||
** Returns :
|
||||
** --- - Error code, ERR_OK for success,
|
||||
** ERR_RXEMPTY if nothing is in RX buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_RecvChar(CDC1_TComData *Chr)
|
||||
{
|
||||
while(Rx1_Get(Chr)!=ERR_OK) {
|
||||
/* retry receiving until success */
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a character to the USB interface. Method is
|
||||
** non-blocking: If the output buffer is full, it tries to send
|
||||
** it over USB. If this fails or buffer is still full, the
|
||||
** character will be lost. If OnError() event is enabled, the
|
||||
** error event will be called in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** Chr - Character to send.
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_SendChar(CDC1_TComData Chr)
|
||||
{
|
||||
static uint8 txBuf[CDC1_DATA_BUFF_SIZE];
|
||||
|
||||
if(Tx1_Put(Chr)==ERR_TXFULL) { /* retry once, otherwise throw it away */
|
||||
if(CDC1_App_Task(txBuf, sizeof(txBuf))!=ERR_OK) { /* call USB handler: if active, then this will empty the buffer */
|
||||
return ERR_TXFULL;
|
||||
} else { /* retry, as USB App_Task() should have sent the buffer */
|
||||
return Tx1_Put(Chr); /* retry. If buffer is still full, we will lose the character */
|
||||
}
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendBlock (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a data block to the USB interface. Method is
|
||||
** non-blocking: if data cannot be sent, it will be lost. If
|
||||
** OnError() event is enabled, the error event will be called
|
||||
** in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * data - Pointer to data to send.
|
||||
** dataSize - Size of data in bytes
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_SendBlock(byte *data, word dataSize)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
|
||||
while(dataSize > 0) {
|
||||
if(CDC1_SendChar(*data)!=ERR_OK) {
|
||||
res = ERR_TXFULL;
|
||||
}
|
||||
dataSize--; data++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendString (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a string to the USB interface. Method is
|
||||
** non-blocking: if string cannot be sent, it will be lost. If
|
||||
** OnError() event is enabled, the error event will be called
|
||||
** in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to string to send.
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_SendString(CDC1_TComData *Chr)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
|
||||
while(*Chr != '\0') {
|
||||
if(CDC1_SendChar(*Chr)!=ERR_OK) {
|
||||
res = ERR_TXFULL;
|
||||
}
|
||||
Chr++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_App_Callback (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to handle class callbacks from USB
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** controller_ID - controller ID
|
||||
** event_type - value of the event
|
||||
** val - gives the configuration value
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void CDC1_App_Callback(byte controller_ID, byte event_type, void *val)
|
||||
{
|
||||
UNUSED(controller_ID);
|
||||
UNUSED(val);
|
||||
if(event_type == USB_APP_BUS_RESET) {
|
||||
start_app = FALSE;
|
||||
} else if(event_type == USB_APP_ENUM_COMPLETE) {
|
||||
#if HIGH_SPEED_DEVICE
|
||||
/* prepare for the next receive event */
|
||||
USB_Class_CDC_Interface_DIC_Recv_Data(&controller_ID,
|
||||
(uint_8_ptr)g_cdcBuffer,
|
||||
DIC_BULK_OUT_ENDP_PACKET_SIZE);
|
||||
#endif
|
||||
start_app = TRUE;
|
||||
} else if((event_type == USB_APP_DATA_RECEIVED)&&(start_transactions==TRUE)) {
|
||||
/* Copy Received Data buffer to Application Buffer */
|
||||
USB_PACKET_SIZE BytesToBeCopied;
|
||||
APP_DATA_STRUCT *dp_rcv = (APP_DATA_STRUCT*)val;
|
||||
uint_8 index;
|
||||
|
||||
BytesToBeCopied = (USB_PACKET_SIZE)((dp_rcv->data_size > CDC1_DATA_BUFF_SIZE) ? CDC1_DATA_BUFF_SIZE:dp_rcv->data_size);
|
||||
for(index = 0; index<BytesToBeCopied ; index++) {
|
||||
if(Rx1_Put(dp_rcv->data_ptr[index])!=ERR_OK) {
|
||||
/* Failed to put byte into buffer. Is the buffer to small? Then increase the Rx buffer.
|
||||
Otherwise not much we could do here, so we are loosing byte here.
|
||||
*/
|
||||
/* Enable OnError() event so this event will be called here */
|
||||
}
|
||||
}
|
||||
(void)USB_Class_CDC_Interface_DIC_Recv_Data(CONTROLLER_ID, NULL, 0); /* see http://eprints.utar.edu.my/143/1/BI-2011-0708672-1.pdf, page 131 */
|
||||
} else if((event_type == USB_APP_SEND_COMPLETE)&&(start_transactions==TRUE)) {
|
||||
transactionOngoing = FALSE;
|
||||
/* Previous Send is complete. Queue next receive */
|
||||
#if HIGH_SPEED_DEVICE
|
||||
//(void)USB_Class_CDC_Interface_DIC_Recv_Data(CONTROLLER_ID, g_cdcBuffer, 0);
|
||||
#else
|
||||
(void)USB_Class_CDC_Interface_DIC_Recv_Data(CONTROLLER_ID, NULL, 0);
|
||||
#endif
|
||||
} else if(event_type == USB_APP_ERROR) { /* detach? */
|
||||
start_app = FALSE;
|
||||
start_transactions = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_Notify_Callback (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to handle PSTN Sub Class callbacks
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** controller_ID - controller ID
|
||||
** event_type - value of the event
|
||||
** val -
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void CDC1_Notify_Callback(byte controller_ID, byte event_type, void *val)
|
||||
{
|
||||
UNUSED(controller_ID);
|
||||
UNUSED(val);
|
||||
if(start_app == TRUE) {
|
||||
if(event_type == USB_APP_CDC_CARRIER_ACTIVATED) {
|
||||
start_transactions = TRUE;
|
||||
} else if(event_type == USB_APP_CDC_CARRIER_DEACTIVATED) {
|
||||
start_transactions = FALSE;
|
||||
}
|
||||
}
|
||||
start_transactions = TRUE; /* ??? see http://forums.freescale.com/t5/Freescale-MQX-trade-USB-Host/Cant-get-CDC-virtual-com-demo-to-work-with-VB2005-on-xp-sp3/m-p/92713#M302 */
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_RunUsbEngine (component FSL_USB_CDC_Device)
|
||||
**
|
||||
** Description :
|
||||
** Runs the USB polling engine
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
void CDC1_RunUsbEngine(void)
|
||||
{
|
||||
/* not needed */
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendDataBlock (component FSL_USB_CDC_Device)
|
||||
**
|
||||
** Description :
|
||||
** Sends a USB data block
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_SendDataBlock(byte *data, word dataSize)
|
||||
{
|
||||
uint8 res = ERR_OK;
|
||||
|
||||
transactionOngoing = TRUE;
|
||||
if(USB_Class_CDC_Interface_DIC_Send_Data(CONTROLLER_ID, data, dataSize)!=USB_OK) {
|
||||
transactionOngoing = FALSE;
|
||||
return ERR_FAULT;
|
||||
}
|
||||
/* wait for transaction finish */
|
||||
while(transactionOngoing) { /* wait until transaction is finished */
|
||||
CDC1_RunUsbEngine();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_App_Task (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Application task to be called periodically from the main
|
||||
** task.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * txBuf - Pointer to temporary buffer used to
|
||||
** transmit data over USB. Should be equal or
|
||||
** greater than the endpoint buffer size. Data
|
||||
** will be sent in an asynchronous way, so
|
||||
** make sure the buffer is *not* on the stack.
|
||||
** This buffer must be available until the
|
||||
** next transmission.
|
||||
** txBufSize - Size of the buffer in bytes
|
||||
** Returns :
|
||||
** --- - Error code, returns ERR_OK if USB
|
||||
** enumeration has been finished, error code
|
||||
** otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_App_Task(byte *txBuf, size_t txBufSize)
|
||||
{
|
||||
uint8 i, res;
|
||||
|
||||
/* device is Kinetis K20D72 */
|
||||
CDC1_RunUsbEngine();
|
||||
/* call the periodic task function */
|
||||
USB_Class_CDC_Periodic_Task();
|
||||
/* check whether enumeration is complete or not */
|
||||
if((start_app==TRUE) && (start_transactions==TRUE)) {
|
||||
if(Tx1_NofElements()!=0) {
|
||||
i = 0;
|
||||
while(i<txBufSize && Tx1_Get(&txBuf[i])==ERR_OK) {
|
||||
i++;
|
||||
}
|
||||
res = CDC1_SendDataBlock(txBuf, i);
|
||||
if(res!=ERR_OK) {
|
||||
return res;
|
||||
}
|
||||
#if 0 /* workaround for problem in USB stack v3.1.1: if last block is 8, 16, 32, 40, 48, ... bytes, it does not get out until the next transfer? */
|
||||
if((i%8)==0) {
|
||||
/* workaround: sending a dummy block of zero bytes */
|
||||
res = CDC1_SendDataBlock(txBuf, 0);
|
||||
if(res!=ERR_OK) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} /* if */
|
||||
return ERR_OK;
|
||||
} else {
|
||||
return ERR_BUSOFF; /* USB bus not available yet */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_Init (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Initializes the driver
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_Init(void)
|
||||
{
|
||||
uint_8 err;
|
||||
|
||||
err = USB_Class_CDC_Init(CONTROLLER_ID, CDC1_App_Callback, NULL, CDC1_Notify_Callback, TRUE);
|
||||
if(err != USB_OK) {
|
||||
/* Error initializing USB-CDC Class */
|
||||
return ERR_FAILED;
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_PutBufferChecked (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Puts a data block into the output buffer, but does not send
|
||||
** it. If there is not enough size available, then ERR_TXFULL
|
||||
** is returned, otherwise ERR_OK. The application then needs to
|
||||
** call USB_App_Callback() to actually send the buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * buf - Pointer to buffer to be sent
|
||||
** bufsize - Buffer size in bytes
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_PutBufferChecked(byte *buf, size_t bufSize)
|
||||
{
|
||||
byte res;
|
||||
|
||||
if(bufSize>CDC1_GetFreeInTxBuf()) { /* no room at the Inn... */
|
||||
res = ERR_TXFULL;
|
||||
} else {
|
||||
res = ERR_OK;
|
||||
while(bufSize>0 && res==ERR_OK) {
|
||||
res = Tx1_Put(*buf);
|
||||
bufSize--;
|
||||
buf++;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_ClearRxBuffer (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Clears the receiver buffer content
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
/**
|
||||
void CDC1_ClearRxBuffer(void)
|
||||
{
|
||||
Implemented as macro in the header file
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_ClearTxBuffer (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Clears the transmit buffer content
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
/**
|
||||
void CDC1_ClearTxBuffer(void)
|
||||
{
|
||||
Implemented as macro in the header file
|
||||
}
|
||||
*/
|
||||
|
||||
/* END CDC1. */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,379 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : CDC1.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : FSL_USB_CDC_Device
|
||||
** Version : Component 01.031, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
**
|
||||
** Settings :
|
||||
** Component name : CDC1
|
||||
** CPU : Kinetis K20D72
|
||||
** CDC Settings : Enabled
|
||||
** .inf ClassGuid : 4D36E978-E325-11CE-BFC1-08002BE10318
|
||||
** .inf VID : 2504
|
||||
** .inf PID : 0300
|
||||
** .inf PRVDR : Freescale
|
||||
** .inf MFGNAME : My Company
|
||||
** .inf DESCRIPTION : Freescale CDC Device
|
||||
** .inf SERVICE : Virtual Com Driver
|
||||
** Bus reported device : FSL CDC DEVICE
|
||||
** Bus reported vendor : FREESCALE INC.
|
||||
** Send Buffer : RingBuffer
|
||||
** Receive Buffer : RingBuffer
|
||||
** Use Timeout : Disabled
|
||||
** Contents :
|
||||
** ClearRxBuffer - void CDC1_ClearRxBuffer(void);
|
||||
** ClearTxBuffer - void CDC1_ClearTxBuffer(void);
|
||||
** GetFreeInTxBuf - word CDC1_GetFreeInTxBuf(void);
|
||||
** GetCharsInTxBuf - word CDC1_GetCharsInTxBuf(void);
|
||||
** GetCharsInRxBuf - word CDC1_GetCharsInRxBuf(void);
|
||||
** GetChar - byte CDC1_GetChar(CDC1_TComData *Chr);
|
||||
** RecvChar - byte CDC1_RecvChar(CDC1_TComData *Chr);
|
||||
** SendChar - byte CDC1_SendChar(CDC1_TComData Chr);
|
||||
** SendString - byte CDC1_SendString(CDC1_TComData *Chr);
|
||||
** SendBlock - byte CDC1_SendBlock(byte *data, word dataSize);
|
||||
** PutBufferChecked - byte CDC1_PutBufferChecked(byte *buf, size_t bufSize);
|
||||
** App_Callback - void CDC1_App_Callback(byte controller_ID, byte event_type, void *val);
|
||||
** Notify_Callback - void CDC1_Notify_Callback(byte controller_ID, byte event_type, void *val);
|
||||
** App_Task - byte CDC1_App_Task(byte *txBuf, size_t txBufSize);
|
||||
** Init - byte CDC1_Init(void);
|
||||
**
|
||||
** (c) Copyright Freescale, all rights reserved, 2013
|
||||
** Ported as Processor Expert component: Erich Styger
|
||||
** http: www.mcuoneclipse.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file CDC1.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
**
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup CDC1_module CDC1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __CDC1_H
|
||||
#define __CDC1_H
|
||||
|
||||
/* MODULE CDC1. */
|
||||
|
||||
/* Include shared modules, which are used for whole project */
|
||||
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
#include "MK20D10.h"
|
||||
/* Include inherited beans */
|
||||
#include "Tx1.h"
|
||||
#include "Rx1.h"
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
//#include "Cpu.h"
|
||||
|
||||
|
||||
#ifndef __BWUserType_CDC1_TComData
|
||||
#define __BWUserType_CDC1_TComData
|
||||
typedef byte CDC1_TComData ; /* User type for communication data type. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
DATA_BUFF_SIZE should be greater than or equal to the endpoint buffer size,
|
||||
otherwise there will be data loss. For MC9S08JS16, maximum DATA_BUFF_SIZE
|
||||
supported is 16 Bytes
|
||||
*/
|
||||
#define CDC1_DATA_BUFF_SIZE 64
|
||||
|
||||
#define CDC1_USB_ERR_SEND 1 /* Error while sending */
|
||||
#define CDC1_USB_ERR_BUSOFF 2 /* Bus not ready */
|
||||
#define CDC1_USB_ERR_INIT 3 /* USB initialization error */
|
||||
#define CDC1_USB_ERR_TX_CHAR 4 /* Error sending character */
|
||||
#define CDC1_USB_ERR_TX_STRING 5 /* Error sending string */
|
||||
#define CDC1_USB_ERR_CHECKED_TXFULL 6 /* Error during sending a checked block */
|
||||
#define CDC1_USB_ERR_RECEIVE 7 /* Error while starting an receive transaction */
|
||||
#define CDC1_USB_ERR_RX_PUT 8 /* Error while putting RX byte into buffer */
|
||||
#define CDC1_USB_ERR_TX_BLOCK 9 /* Error sending data block */
|
||||
#define CDC1_USB_TIMEOUT_SEND 10 /* Timeout while sending */
|
||||
|
||||
|
||||
#define CDC1_GetFreeInTxBuf() \
|
||||
Tx1_NofFreeElements()
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetFreeInTxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of free character in the send buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of free character in the receive
|
||||
** buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_RecvChar(CDC1_TComData *Chr);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_RecvChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Receives a character from the USB interface. Function is
|
||||
** blocking if there is no character in the input buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to where to store the character
|
||||
** received
|
||||
** Returns :
|
||||
** --- - Error code, ERR_OK for success,
|
||||
** ERR_RXEMPTY if nothing is in RX buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_SendChar(CDC1_TComData Chr);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a character to the USB interface. Method is
|
||||
** non-blocking: If the output buffer is full, it tries to send
|
||||
** it over USB. If this fails or buffer is still full, the
|
||||
** character will be lost. If OnError() event is enabled, the
|
||||
** error event will be called in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** Chr - Character to send.
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CDC1_GetCharsInTxBuf() \
|
||||
Tx1_NofElements()
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetCharsInTxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of character in the send buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of character in the receive buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
word CDC1_GetCharsInRxBuf(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetCharsInRxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of character in the receive buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of character in the receive buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_Init(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_Init (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Initializes the driver
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_App_Task(byte *txBuf, size_t txBufSize);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_App_Task (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Application task to be called periodically from the main
|
||||
** task.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * txBuf - Pointer to temporary buffer used to
|
||||
** transmit data over USB. Should be equal or
|
||||
** greater than the endpoint buffer size. Data
|
||||
** will be sent in an asynchronous way, so
|
||||
** make sure the buffer is *not* on the stack.
|
||||
** This buffer must be available until the
|
||||
** next transmission.
|
||||
** txBufSize - Size of the buffer in bytes
|
||||
** Returns :
|
||||
** --- - Error code, returns ERR_OK if USB
|
||||
** enumeration has been finished, error code
|
||||
** otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_SendString(CDC1_TComData *Chr);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendString (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a string to the USB interface. Method is
|
||||
** non-blocking: if string cannot be sent, it will be lost. If
|
||||
** OnError() event is enabled, the error event will be called
|
||||
** in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to string to send.
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CDC1_GetChar(Chr) \
|
||||
Rx1_Get(Chr)
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Receives a character from the USB interface. Function is not
|
||||
** blocking if there is no character in the input buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to where to store the character
|
||||
** received
|
||||
** Returns :
|
||||
** --- - Error code, ERR_OK for success,
|
||||
** ERR_RXEMPTY if nothing is in RX buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_PutBufferChecked(byte *buf, size_t bufSize);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_PutBufferChecked (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Puts a data block into the output buffer, but does not send
|
||||
** it. If there is not enough size available, then ERR_TXFULL
|
||||
** is returned, otherwise ERR_OK. The application then needs to
|
||||
** call USB_App_Callback() to actually send the buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * buf - Pointer to buffer to be sent
|
||||
** bufsize - Buffer size in bytes
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void CDC1_App_Callback(byte controller_ID, byte event_type, void *val);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_App_Callback (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to handle class callbacks from USB
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** controller_ID - controller ID
|
||||
** event_type - value of the event
|
||||
** val - gives the configuration value
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void CDC1_Notify_Callback(byte controller_ID, byte event_type, void *val);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_Notify_Callback (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to handle PSTN Sub Class callbacks
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** controller_ID - controller ID
|
||||
** event_type - value of the event
|
||||
** val -
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CDC1_ClearRxBuffer() \
|
||||
Rx1_Clear()
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_ClearRxBuffer (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Clears the receiver buffer content
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CDC1_ClearTxBuffer() \
|
||||
Tx1_Clear()
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_ClearTxBuffer (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Clears the transmit buffer content
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void CDC1_RunUsbEngine(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_RunUsbEngine (component FSL_USB_CDC_Device)
|
||||
**
|
||||
** Description :
|
||||
** Runs the USB polling engine
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_SendBlock(byte *data, word dataSize);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendBlock (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a data block to the USB interface. Method is
|
||||
** non-blocking: if data cannot be sent, it will be lost. If
|
||||
** OnError() event is enabled, the error event will be called
|
||||
** in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * data - Pointer to data to send.
|
||||
** dataSize - Size of data in bytes
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_SendDataBlock(byte *data, word dataSize);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendDataBlock (component FSL_USB_CDC_Device)
|
||||
**
|
||||
** Description :
|
||||
** Sends a USB data block
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END CDC1. */
|
||||
|
||||
#endif
|
||||
/* ifndef __CDC1_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,103 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : CS1.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : CriticalSection
|
||||
** Version : Component 01.006, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
**
|
||||
** Settings :
|
||||
**
|
||||
** Contents :
|
||||
** CriticalVariable - void CS1_CriticalVariable(void);
|
||||
** EnterCritical - void CS1_EnterCritical(void);
|
||||
** ExitCritical - void CS1_ExitCritical(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : Erich Styger, 2014, all rights reserved.
|
||||
** Web : www.mcuoneclipse.com
|
||||
** This an open source software implementing a driver using Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file CS1.c
|
||||
** @version 01.00
|
||||
** @brief
|
||||
**
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup CS1_module CS1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE CS1. */
|
||||
|
||||
#include "CS1.h"
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_CriticalVariable (component CriticalSection)
|
||||
** Description :
|
||||
** Defines a variable if necessary. This is a macro.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
/*
|
||||
void CS1_CriticalVariable(void)
|
||||
{
|
||||
*** Implemented as macro in the header file CS1.h
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_EnterCritical (component CriticalSection)
|
||||
** Description :
|
||||
** Enters a critical section
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
/*
|
||||
void CS1_EnterCritical(void)
|
||||
{
|
||||
*** Implemented as macro in the header file CS1.h
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_ExitCritical (component CriticalSection)
|
||||
** Description :
|
||||
** Exits a critical section
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
/*
|
||||
void CS1_ExitCritical(void)
|
||||
{
|
||||
*** Implemented as macro in the header file CS1.h
|
||||
}
|
||||
*/
|
||||
|
||||
/* END CS1. */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,126 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : CS1.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : CriticalSection
|
||||
** Version : Component 01.006, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
**
|
||||
** Settings :
|
||||
**
|
||||
** Contents :
|
||||
** CriticalVariable - void CS1_CriticalVariable(void);
|
||||
** EnterCritical - void CS1_EnterCritical(void);
|
||||
** ExitCritical - void CS1_ExitCritical(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : Erich Styger, 2014, all rights reserved.
|
||||
** Web : www.mcuoneclipse.com
|
||||
** This an open source software implementing a driver using Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file CS1.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
**
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup CS1_module CS1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __CS1_H
|
||||
#define __CS1_H
|
||||
|
||||
/* MODULE CS1. */
|
||||
|
||||
/* Include shared modules, which are used for whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
/* Include inherited beans */
|
||||
|
||||
//#include "Cpu.h"
|
||||
|
||||
|
||||
/* workaround macros for wrong EnterCritical()/ExitCritical() in the low level drivers. Will be removed once PEx is fixed */
|
||||
#define CS1_CriticalVariableDrv() \
|
||||
CS1_CriticalVariable()
|
||||
#define CS1_EnterCriticalDrv() \
|
||||
CS1_EnterCritical()
|
||||
#define CS1_ExitCriticalDrv() \
|
||||
CS1_ExitCritical()
|
||||
|
||||
#define CS1_CriticalVariable() \
|
||||
uint8 cpuSR; /* variable to store current status */
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_CriticalVariable (component CriticalSection)
|
||||
** Description :
|
||||
** Defines a variable if necessary. This is a macro.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CS1_EnterCritical() \
|
||||
do { \
|
||||
asm ( \
|
||||
"MRS R0, PRIMASK\n\t" \
|
||||
"CPSID I\n\t" \
|
||||
"STRB R0, %[output]" \
|
||||
: [output] "=m" (cpuSR) :: "r0"); \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_EnterCritical (component CriticalSection)
|
||||
** Description :
|
||||
** Enters a critical section
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CS1_ExitCritical() \
|
||||
do{ \
|
||||
asm ( \
|
||||
"ldrb r0, %[input]\n\t" \
|
||||
"msr PRIMASK,r0;\n\t" \
|
||||
::[input] "m" (cpuSR) : "r0"); \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_ExitCritical (component CriticalSection)
|
||||
** Description :
|
||||
** Exits a critical section
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END CS1. */
|
||||
|
||||
#endif
|
||||
/* ifndef __CS1_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,12 @@
|
||||
/******************************************************************************
|
||||
* Configuration file for the FSL USB stack created with Processor Expert.
|
||||
*****************************************************************************/
|
||||
#ifndef __FSL_USB_STACK_CONFIG_
|
||||
#define __FSL_USB_STACK_CONFIG_
|
||||
|
||||
/* Overwrite initialization values from Processor Expert Init() component. These are 'known working values'.
|
||||
* Otherwise you have to setup the bits (e.g. Pull-up/pull-down resistors!
|
||||
* */
|
||||
#define USB_USER_CONFIG_USE_STACK_INIT 1 /* value set by component property 'Use USB Stack Initialization' */
|
||||
|
||||
#endif /* __FSL_USB_STACK_CONFIG_ */
|
||||
@@ -0,0 +1,96 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : PE_Const.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : PE_Const
|
||||
** Version : Driver 01.00
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component "PE_Const" contains internal definitions
|
||||
** of the constants.
|
||||
** Settings :
|
||||
** Contents :
|
||||
** No public methods
|
||||
**
|
||||
** Copyright : 1997 - 2014 Freescale Semiconductor, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file PE_Const.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component "PE_Const" contains internal definitions
|
||||
** of the constants.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup PE_Const_module PE_Const module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __PE_Const_H
|
||||
#define __PE_Const_H
|
||||
|
||||
|
||||
/* Reset cause constants */
|
||||
#define RSTSRC_WAKEUP 0x01U /*!< LLWU module wakeup reset */
|
||||
#define RSTSRC_LVD 0x02U /*!< Low-voltage detect reset */
|
||||
#define RSTSRC_LOC 0x04U /*!< Loss-of-clock reset */
|
||||
#define RSTSRC_LOL 0x08U /*!< Loss-of-lock reset */
|
||||
#define RSTSRC_COP 0x20U /*!< Watchdog reset */
|
||||
#define RSTSRC_WDOG 0x20U /*!< Watchdog reset */
|
||||
#define RSTSRC_PIN 0x40U /*!< External pin reset */
|
||||
#define RSTSRC_POR 0x80U /*!< Power-on reset */
|
||||
#define RSTSRC_JTAG 0x0100U /*!< JTAG reset pin */
|
||||
#define RSTSRC_LOCKUP 0x0200U /*!< Core Lock-up reset */
|
||||
#define RSTSRC_SW 0x0400U /*!< Software reset */
|
||||
#define RSTSRC_MDM_AP 0x0800U /*!< Reset caused by host debugger system */
|
||||
#define RSTSRC_EZPT 0x1000U /*!< EzPort reset */
|
||||
#define RSTSRC_SACKERR 0x2000U /*!< Stop Mode Acknowledge Error Reset */
|
||||
|
||||
|
||||
/* Low voltage interrupt cause constants */
|
||||
#define LVDSRC_LVD 0x01U /*!< Low voltage detect */
|
||||
#define LVDSRC_LVW 0x02U /*!< Low-voltage warning */
|
||||
|
||||
#endif /* _PE_Const_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,128 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : PE_Error.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : PE_Error
|
||||
** Version : Driver 01.00
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component "PE_Error" contains internal definitions
|
||||
** of the error constants.
|
||||
** Contents :
|
||||
** No public methods
|
||||
**
|
||||
** Copyright : 1997 - 2014 Freescale Semiconductor, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file PE_Error.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component "PE_Error" contains internal definitions
|
||||
** of the error constants.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup PE_Error_module PE_Error module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __PE_Error_H
|
||||
#define __PE_Error_H
|
||||
|
||||
#define ERR_OK 0x00U /*!< OK */
|
||||
#define ERR_SPEED 0x01U /*!< This device does not work in the active speed mode. */
|
||||
#define ERR_RANGE 0x02U /*!< Parameter out of range. */
|
||||
#define ERR_VALUE 0x03U /*!< Parameter of incorrect value. */
|
||||
#define ERR_OVERFLOW 0x04U /*!< Timer overflow. */
|
||||
#define ERR_MATH 0x05U /*!< Overflow during evaluation. */
|
||||
#define ERR_ENABLED 0x06U /*!< Device is enabled. */
|
||||
#define ERR_DISABLED 0x07U /*!< Device is disabled. */
|
||||
#define ERR_BUSY 0x08U /*!< Device is busy. */
|
||||
#define ERR_NOTAVAIL 0x09U /*!< Requested value or method not available. */
|
||||
#define ERR_RXEMPTY 0x0AU /*!< No data in receiver. */
|
||||
#define ERR_TXFULL 0x0BU /*!< Transmitter is full. */
|
||||
#define ERR_BUSOFF 0x0CU /*!< Bus not available. */
|
||||
#define ERR_OVERRUN 0x0DU /*!< Overrun error is detected. */
|
||||
#define ERR_FRAMING 0x0EU /*!< Framing error is detected. */
|
||||
#define ERR_PARITY 0x0FU /*!< Parity error is detected. */
|
||||
#define ERR_NOISE 0x10U /*!< Noise error is detected. */
|
||||
#define ERR_IDLE 0x11U /*!< Idle error is detected. */
|
||||
#define ERR_FAULT 0x12U /*!< Fault error is detected. */
|
||||
#define ERR_BREAK 0x13U /*!< Break char is received during communication. */
|
||||
#define ERR_CRC 0x14U /*!< CRC error is detected. */
|
||||
#define ERR_ARBITR 0x15U /*!< A node losts arbitration. This error occurs if two nodes start transmission at the same time. */
|
||||
#define ERR_PROTECT 0x16U /*!< Protection error is detected. */
|
||||
#define ERR_UNDERFLOW 0x17U /*!< Underflow error is detected. */
|
||||
#define ERR_UNDERRUN 0x18U /*!< Underrun error is detected. */
|
||||
#define ERR_COMMON 0x19U /*!< Common error of a device. */
|
||||
#define ERR_LINSYNC 0x1AU /*!< LIN synchronization error is detected. */
|
||||
#define ERR_FAILED 0x1BU /*!< Requested functionality or process failed. */
|
||||
#define ERR_QFULL 0x1CU /*!< Queue is full. */
|
||||
#define ERR_PARAM_MASK 0x80U /*!< Invalid mask. */
|
||||
#define ERR_PARAM_MODE 0x81U /*!< Invalid mode. */
|
||||
#define ERR_PARAM_INDEX 0x82U /*!< Invalid index. */
|
||||
#define ERR_PARAM_DATA 0x83U /*!< Invalid data. */
|
||||
#define ERR_PARAM_SIZE 0x84U /*!< Invalid size. */
|
||||
#define ERR_PARAM_VALUE 0x85U /*!< Invalid value. */
|
||||
#define ERR_PARAM_RANGE 0x86U /*!< Invalid parameter's range or parameters' combination. */
|
||||
#define ERR_PARAM_LOW_VALUE 0x87U /*!< Invalid value (LOW part). */
|
||||
#define ERR_PARAM_HIGH_VALUE 0x88U /*!< Invalid value (HIGH part). */
|
||||
#define ERR_PARAM_ADDRESS 0x89U /*!< Invalid address. */
|
||||
#define ERR_PARAM_PARITY 0x8AU /*!< Invalid parity. */
|
||||
#define ERR_PARAM_WIDTH 0x8BU /*!< Invalid width. */
|
||||
#define ERR_PARAM_LENGTH 0x8CU /*!< Invalid length. */
|
||||
#define ERR_PARAM_ADDRESS_TYPE 0x8DU /*!< Invalid address type. */
|
||||
#define ERR_PARAM_COMMAND_TYPE 0x8EU /*!< Invalid command type. */
|
||||
#define ERR_PARAM_COMMAND 0x8FU /*!< Invalid command. */
|
||||
#define ERR_PARAM_RECIPIENT 0x90U /*!< Invalid recipient. */
|
||||
#define ERR_PARAM_BUFFER_COUNT 0x91U /*!< Invalid buffer count. */
|
||||
#define ERR_PARAM_ID 0x92U /*!< Invalid ID. */
|
||||
#define ERR_PARAM_GROUP 0x93U /*!< Invalid group. */
|
||||
#define ERR_PARAM_CHIP_SELECT 0x94U /*!< Invalid chip select. */
|
||||
#define ERR_PARAM_ATTRIBUTE_SET 0x95U /*!< Invalid set of attributes. */
|
||||
#define ERR_PARAM_SAMPLE_COUNT 0x96U /*!< Invalid sample count. */
|
||||
#define ERR_PARAM_CONDITION 0x97U /*!< Invalid condition. */
|
||||
#define ERR_PARAM_TICKS 0x98U /*!< Invalid ticks parameter. */
|
||||
|
||||
#endif /* __PE_Error_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,223 @@
|
||||
/* ################################################################### */
|
||||
/*##
|
||||
/*## This component module is generated by Processor Expert. Do not modify it. */
|
||||
/*## */
|
||||
/*## Filename : ProcessorExpert.ld */
|
||||
/*## */
|
||||
/*## Project : Landungsbruecke_KDS_v2.0.0 */
|
||||
/*## */
|
||||
/*## Processor : MK20DN512VLL10 */
|
||||
/*## */
|
||||
/*## Compiler : GNU C Compiler */
|
||||
/*## */
|
||||
/*## Date/Time : 2015-01-09, 16:27, # CodeGen: 0 */
|
||||
/*## */
|
||||
/*## Abstract : */
|
||||
/*## */
|
||||
/*## This file is used by the linker. It describes files to be linked, */
|
||||
/*## memory ranges, stack size, etc. For detailed description about linker */
|
||||
/*## command files see compiler documentation. This file is generated by default. */
|
||||
/*## You can switch off generation by setting the property "Generate linker file = no" */
|
||||
/*## in the "Build options" tab of the CPU component and then modify this file as needed. */
|
||||
/*##
|
||||
/*## */
|
||||
/*## ###################################################################*/
|
||||
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(__thumb_startup)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20000000; /* end of m_data */
|
||||
__SP_INIT = _estack;
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
__heap_size = 0x00; /* required amount of heap */
|
||||
__stack_size = 0x0400; /* required amount of stack */
|
||||
|
||||
MEMORY {
|
||||
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000001E0
|
||||
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0007FBF0
|
||||
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000
|
||||
m_data_20000000 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00010000
|
||||
m_cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into INTERNAL_FLASH */
|
||||
.interrupts :
|
||||
{
|
||||
__vector_table = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.vectortable)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} > m_interrupts
|
||||
|
||||
.cfmprotect :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.cfmconfig)) /* Flash Configuration Field (FCF) */
|
||||
. = ALIGN(4);
|
||||
} > m_cfmprotrom
|
||||
|
||||
/* The program code and other data goes into INTERNAL_FLASH */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} > m_text
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } > m_text
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > m_text
|
||||
|
||||
.ctors :
|
||||
{
|
||||
__CTOR_LIST__ = .;
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__CTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.dtors :
|
||||
{
|
||||
__DTOR_LIST__ = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__DTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} > m_text
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} > m_text
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
___ROM_AT = .;
|
||||
} > m_text
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data : AT(___ROM_AT)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} > m_data
|
||||
|
||||
___data_size = _edata - _sdata;
|
||||
___m_data_20000000_ROMStart = ___ROM_AT + SIZEOF(.data);
|
||||
.m_data_20000000 : AT(___m_data_20000000_ROMStart)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
___m_data_20000000_RAMStart = .;
|
||||
*(.m_data_20000000) /* This is an User defined section */
|
||||
___m_data_20000000_RAMEnd = .;
|
||||
. = ALIGN(4);
|
||||
} > m_data_20000000
|
||||
___m_data_20000000_ROMSize = ___m_data_20000000_RAMEnd - ___m_data_20000000_RAMStart;
|
||||
|
||||
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
__START_BSS = .;
|
||||
PROVIDE ( __bss_start__ = __START_BSS );
|
||||
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__END_BSS = .;
|
||||
PROVIDE ( __bss_end__ = __END_BSS );
|
||||
} > m_data
|
||||
|
||||
_romp_at = ___ROM_AT + SIZEOF(.data) +SIZEOF(.m_data_20000000);
|
||||
.romp : AT(_romp_at)
|
||||
{
|
||||
__S_romp = _romp_at;
|
||||
LONG(___ROM_AT);
|
||||
LONG(_sdata);
|
||||
LONG(___data_size);
|
||||
LONG(___m_data_20000000_ROMStart);
|
||||
LONG(___m_data_20000000_RAMStart);
|
||||
LONG(___m_data_20000000_ROMSize);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
} > m_data
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
__heap_addr = .;
|
||||
__HeapBase = .;
|
||||
. = . + __heap_size;
|
||||
__HeapLimit = .;
|
||||
. = . + __stack_size;
|
||||
. = ALIGN(4);
|
||||
} > m_data
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : Rx1.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : RingBuffer
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
** Settings :
|
||||
** Component name : Rx1
|
||||
** Buffer Size : 1
|
||||
** Contents :
|
||||
** Clear - void Rx1_Clear(void);
|
||||
** Put - byte Rx1_Put(Rx1_ElementType elem);
|
||||
** Get - byte Rx1_Get(Rx1_ElementType *elemP);
|
||||
** NofElements - Rx1_BufSizeType Rx1_NofElements(void);
|
||||
** NofFreeElements - Rx1_BufSizeType Rx1_NofFreeElements(void);
|
||||
** Init - void Rx1_Init(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : (c) Copyright Erich Styger, 2014, all rights reserved.
|
||||
** Web: http://www.mcuoneclipse.com
|
||||
** This an open source software of an embedded component for Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file Rx1.c
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup Rx1_module Rx1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE Rx1. */
|
||||
|
||||
#include "Rx1.h"
|
||||
|
||||
#if Rx1_IS_REENTRANT
|
||||
#define Rx1_DEFINE_CRITICAL() CS1_CriticalVariable()
|
||||
#define Rx1_ENTER_CRITICAL() CS1_EnterCritical()
|
||||
#define Rx1_EXIT_CRITICAL() CS1_ExitCritical()
|
||||
#else
|
||||
#define Rx1_DEFINE_CRITICAL() /* nothing */
|
||||
#define Rx1_ENTER_CRITICAL() /* nothing */
|
||||
#define Rx1_EXIT_CRITICAL() /* nothing */
|
||||
#endif
|
||||
static Rx1_ElementType Rx1_buffer[Rx1_BUF_SIZE]; /* ring buffer */
|
||||
static Rx1_BufSizeType Rx1_inIdx; /* input index */
|
||||
static Rx1_BufSizeType Rx1_outIdx; /* output index */
|
||||
static Rx1_BufSizeType Rx1_inSize; /* size data in buffer */
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Put (component RingBuffer)
|
||||
** Description :
|
||||
** Puts a new element into the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** elem - New element to be put into the buffer
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte Rx1_Put(Rx1_ElementType elem)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
Rx1_DEFINE_CRITICAL();
|
||||
|
||||
Rx1_ENTER_CRITICAL();
|
||||
if(Rx1_inSize==Rx1_BUF_SIZE) {
|
||||
res = ERR_TXFULL;
|
||||
} else {
|
||||
Rx1_buffer[Rx1_inIdx] = elem;
|
||||
Rx1_inSize++;
|
||||
Rx1_inIdx++;
|
||||
if(Rx1_inIdx==Rx1_BUF_SIZE) {
|
||||
Rx1_inIdx = 0;
|
||||
}
|
||||
}
|
||||
Rx1_EXIT_CRITICAL();
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Get (component RingBuffer)
|
||||
** Description :
|
||||
** Removes an element from the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * elemP - Pointer to where to store the received
|
||||
** element
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte Rx1_Get(Rx1_ElementType *elemP)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
Rx1_DEFINE_CRITICAL();
|
||||
|
||||
Rx1_ENTER_CRITICAL();
|
||||
if(Rx1_inSize==0) {
|
||||
res = ERR_RXEMPTY;
|
||||
} else {
|
||||
*elemP = Rx1_buffer[Rx1_outIdx];
|
||||
Rx1_inSize--;
|
||||
Rx1_outIdx++;
|
||||
if(Rx1_outIdx==Rx1_BUF_SIZE) {
|
||||
Rx1_outIdx = 0;
|
||||
}
|
||||
}
|
||||
Rx1_EXIT_CRITICAL();
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_NofElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of elements in the buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
Rx1_BufSizeType Rx1_NofElements(void)
|
||||
{
|
||||
return Rx1_inSize;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_NofFreeElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of free elements/space in the
|
||||
** buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
Rx1_BufSizeType Rx1_NofFreeElements(void)
|
||||
{
|
||||
return (Rx1_BufSizeType)(Rx1_BUF_SIZE-Rx1_inSize);
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Init (component RingBuffer)
|
||||
** Description :
|
||||
** Initializes the data structure
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void Rx1_Init(void)
|
||||
{
|
||||
Rx1_inIdx = 0;
|
||||
Rx1_outIdx = 0;
|
||||
Rx1_inSize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Clear (component RingBuffer)
|
||||
** Description :
|
||||
** Clear (empty) the ring buffer.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void Rx1_Clear(void)
|
||||
{
|
||||
Rx1_DEFINE_CRITICAL();
|
||||
|
||||
Rx1_ENTER_CRITICAL();
|
||||
Rx1_Init();
|
||||
Rx1_EXIT_CRITICAL();
|
||||
}
|
||||
|
||||
/* END Rx1. */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,167 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : Rx1.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : RingBuffer
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
** Settings :
|
||||
** Component name : Rx1
|
||||
** Buffer Size : 1
|
||||
** Contents :
|
||||
** Clear - void Rx1_Clear(void);
|
||||
** Put - byte Rx1_Put(Rx1_ElementType elem);
|
||||
** Get - byte Rx1_Get(Rx1_ElementType *elemP);
|
||||
** NofElements - Rx1_BufSizeType Rx1_NofElements(void);
|
||||
** NofFreeElements - Rx1_BufSizeType Rx1_NofFreeElements(void);
|
||||
** Init - void Rx1_Init(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : (c) Copyright Erich Styger, 2014, all rights reserved.
|
||||
** Web: http://www.mcuoneclipse.com
|
||||
** This an open source software of an embedded component for Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file Rx1.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup Rx1_module Rx1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __Rx1_H
|
||||
#define __Rx1_H
|
||||
|
||||
/* MODULE Rx1. */
|
||||
|
||||
/* Include shared modules, which are used for whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
/* Include inherited beans */
|
||||
#include "CS1.h"
|
||||
|
||||
//#include "Cpu.h"
|
||||
|
||||
|
||||
#define Rx1_BUF_SIZE 64 /* number of elements in the buffer */
|
||||
#define Rx1_ELEM_SIZE 1 /* size of a single element in bytes */
|
||||
#define Rx1_IS_REENTRANT 0 /* 0: Critical section NOT used for accessing shared data, 1 otherwise */
|
||||
#if Rx1_ELEM_SIZE==1
|
||||
typedef uint8 Rx1_ElementType; /* type of single element */
|
||||
#elif Rx1_ELEM_SIZE==2
|
||||
typedef uint16 Rx1_ElementType; /* type of single element */
|
||||
#elif Rx1_ELEM_SIZE==4
|
||||
typedef uint32 Rx1_ElementType; /* type of single element */
|
||||
#else
|
||||
#error "illegal element type size in properties"
|
||||
#endif
|
||||
#if Rx1_BUF_SIZE<=256
|
||||
typedef uint8 Rx1_BufSizeType; /* up to 256 elements (index 0x00..0xFF) */
|
||||
#else
|
||||
typedef uint16 Rx1_BufSizeType; /* more than 256 elements, up to 2^16 */
|
||||
#endif
|
||||
|
||||
byte Rx1_Put(Rx1_ElementType elem);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Put (component RingBuffer)
|
||||
** Description :
|
||||
** Puts a new element into the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** elem - New element to be put into the buffer
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte Rx1_Get(Rx1_ElementType *elemP);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Get (component RingBuffer)
|
||||
** Description :
|
||||
** Removes an element from the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * elemP - Pointer to where to store the received
|
||||
** element
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
Rx1_BufSizeType Rx1_NofElements(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_NofElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of elements in the buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void Rx1_Init(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Init (component RingBuffer)
|
||||
** Description :
|
||||
** Initializes the data structure
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
Rx1_BufSizeType Rx1_NofFreeElements(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_NofFreeElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of free elements/space in the
|
||||
** buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void Rx1_Clear(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Clear (component RingBuffer)
|
||||
** Description :
|
||||
** Clear (empty) the ring buffer.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END Rx1. */
|
||||
|
||||
#endif
|
||||
/* ifndef __Rx1_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,202 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : Tx1.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : RingBuffer
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
** Settings :
|
||||
** Component name : Tx1
|
||||
** Buffer Size : 1
|
||||
** Contents :
|
||||
** Clear - void Tx1_Clear(void);
|
||||
** Put - byte Tx1_Put(Tx1_ElementType elem);
|
||||
** Get - byte Tx1_Get(Tx1_ElementType *elemP);
|
||||
** NofElements - Tx1_BufSizeType Tx1_NofElements(void);
|
||||
** NofFreeElements - Tx1_BufSizeType Tx1_NofFreeElements(void);
|
||||
** Init - void Tx1_Init(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : (c) Copyright Erich Styger, 2014, all rights reserved.
|
||||
** Web: http://www.mcuoneclipse.com
|
||||
** This an open source software of an embedded component for Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file Tx1.c
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup Tx1_module Tx1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE Tx1. */
|
||||
|
||||
#include "Tx1.h"
|
||||
|
||||
#if Tx1_IS_REENTRANT
|
||||
#define Tx1_DEFINE_CRITICAL() CS1_CriticalVariable()
|
||||
#define Tx1_ENTER_CRITICAL() CS1_EnterCritical()
|
||||
#define Tx1_EXIT_CRITICAL() CS1_ExitCritical()
|
||||
#else
|
||||
#define Tx1_DEFINE_CRITICAL() /* nothing */
|
||||
#define Tx1_ENTER_CRITICAL() /* nothing */
|
||||
#define Tx1_EXIT_CRITICAL() /* nothing */
|
||||
#endif
|
||||
static Tx1_ElementType Tx1_buffer[Tx1_BUF_SIZE]; /* ring buffer */
|
||||
static Tx1_BufSizeType Tx1_inIdx; /* input index */
|
||||
static Tx1_BufSizeType Tx1_outIdx; /* output index */
|
||||
static Tx1_BufSizeType Tx1_inSize; /* size data in buffer */
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Put (component RingBuffer)
|
||||
** Description :
|
||||
** Puts a new element into the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** elem - New element to be put into the buffer
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte Tx1_Put(Tx1_ElementType elem)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
Tx1_DEFINE_CRITICAL();
|
||||
|
||||
Tx1_ENTER_CRITICAL();
|
||||
if(Tx1_inSize==Tx1_BUF_SIZE) {
|
||||
res = ERR_TXFULL;
|
||||
} else {
|
||||
Tx1_buffer[Tx1_inIdx] = elem;
|
||||
Tx1_inSize++;
|
||||
Tx1_inIdx++;
|
||||
if(Tx1_inIdx==Tx1_BUF_SIZE) {
|
||||
Tx1_inIdx = 0;
|
||||
}
|
||||
}
|
||||
Tx1_EXIT_CRITICAL();
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Get (component RingBuffer)
|
||||
** Description :
|
||||
** Removes an element from the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * elemP - Pointer to where to store the received
|
||||
** element
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte Tx1_Get(Tx1_ElementType *elemP)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
Tx1_DEFINE_CRITICAL();
|
||||
|
||||
Tx1_ENTER_CRITICAL();
|
||||
if(Tx1_inSize==0) {
|
||||
res = ERR_RXEMPTY;
|
||||
} else {
|
||||
*elemP = Tx1_buffer[Tx1_outIdx];
|
||||
Tx1_inSize--;
|
||||
Tx1_outIdx++;
|
||||
if(Tx1_outIdx==Tx1_BUF_SIZE) {
|
||||
Tx1_outIdx = 0;
|
||||
}
|
||||
}
|
||||
Tx1_EXIT_CRITICAL();
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_NofElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of elements in the buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
Tx1_BufSizeType Tx1_NofElements(void)
|
||||
{
|
||||
return Tx1_inSize;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_NofFreeElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of free elements/space in the
|
||||
** buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
Tx1_BufSizeType Tx1_NofFreeElements(void)
|
||||
{
|
||||
return (Tx1_BufSizeType)(Tx1_BUF_SIZE-Tx1_inSize);
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Init (component RingBuffer)
|
||||
** Description :
|
||||
** Initializes the data structure
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void Tx1_Init(void)
|
||||
{
|
||||
Tx1_inIdx = 0;
|
||||
Tx1_outIdx = 0;
|
||||
Tx1_inSize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Clear (component RingBuffer)
|
||||
** Description :
|
||||
** Clear (empty) the ring buffer.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void Tx1_Clear(void)
|
||||
{
|
||||
Tx1_DEFINE_CRITICAL();
|
||||
|
||||
Tx1_ENTER_CRITICAL();
|
||||
Tx1_Init();
|
||||
Tx1_EXIT_CRITICAL();
|
||||
}
|
||||
|
||||
/* END Tx1. */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,167 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : Tx1.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : RingBuffer
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
** Settings :
|
||||
** Component name : Tx1
|
||||
** Buffer Size : 1
|
||||
** Contents :
|
||||
** Clear - void Tx1_Clear(void);
|
||||
** Put - byte Tx1_Put(Tx1_ElementType elem);
|
||||
** Get - byte Tx1_Get(Tx1_ElementType *elemP);
|
||||
** NofElements - Tx1_BufSizeType Tx1_NofElements(void);
|
||||
** NofFreeElements - Tx1_BufSizeType Tx1_NofFreeElements(void);
|
||||
** Init - void Tx1_Init(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : (c) Copyright Erich Styger, 2014, all rights reserved.
|
||||
** Web: http://www.mcuoneclipse.com
|
||||
** This an open source software of an embedded component for Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file Tx1.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup Tx1_module Tx1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __Tx1_H
|
||||
#define __Tx1_H
|
||||
|
||||
/* MODULE Tx1. */
|
||||
|
||||
/* Include shared modules, which are used for whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
/* Include inherited beans */
|
||||
#include "CS1.h"
|
||||
|
||||
//#include "Cpu.h"
|
||||
|
||||
|
||||
#define Tx1_BUF_SIZE 64 /* number of elements in the buffer */
|
||||
#define Tx1_ELEM_SIZE 1 /* size of a single element in bytes */
|
||||
#define Tx1_IS_REENTRANT 0 /* 0: Critical section NOT used for accessing shared data, 1 otherwise */
|
||||
#if Tx1_ELEM_SIZE==1
|
||||
typedef uint8 Tx1_ElementType; /* type of single element */
|
||||
#elif Tx1_ELEM_SIZE==2
|
||||
typedef uint16 Tx1_ElementType; /* type of single element */
|
||||
#elif Tx1_ELEM_SIZE==4
|
||||
typedef uint32 Tx1_ElementType; /* type of single element */
|
||||
#else
|
||||
#error "illegal element type size in properties"
|
||||
#endif
|
||||
#if Tx1_BUF_SIZE<=256
|
||||
typedef uint8 Tx1_BufSizeType; /* up to 256 elements (index 0x00..0xFF) */
|
||||
#else
|
||||
typedef uint16 Tx1_BufSizeType; /* more than 256 elements, up to 2^16 */
|
||||
#endif
|
||||
|
||||
byte Tx1_Put(Tx1_ElementType elem);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Put (component RingBuffer)
|
||||
** Description :
|
||||
** Puts a new element into the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** elem - New element to be put into the buffer
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte Tx1_Get(Tx1_ElementType *elemP);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Get (component RingBuffer)
|
||||
** Description :
|
||||
** Removes an element from the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * elemP - Pointer to where to store the received
|
||||
** element
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
Tx1_BufSizeType Tx1_NofElements(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_NofElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of elements in the buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void Tx1_Init(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Init (component RingBuffer)
|
||||
** Description :
|
||||
** Initializes the data structure
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
Tx1_BufSizeType Tx1_NofFreeElements(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_NofFreeElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of free elements/space in the
|
||||
** buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void Tx1_Clear(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Clear (component RingBuffer)
|
||||
** Description :
|
||||
** Clear (empty) the ring buffer.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END Tx1. */
|
||||
|
||||
#endif
|
||||
/* ifndef __Tx1_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,396 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : USB0.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : Init_USB_OTG
|
||||
** Version : Component 01.004, Driver 01.04, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This file implements the USB_OTG (USB0) module initialization
|
||||
** according to the Peripheral Initialization settings, and
|
||||
** defines interrupt service routines prototypes.
|
||||
** Settings :
|
||||
** Component name : USB0
|
||||
** Device : USB0
|
||||
** Settings :
|
||||
** Clock gate : Enabled
|
||||
** Clock settings :
|
||||
** Clock divider :
|
||||
** Clock divider source : PLL/FLL clock
|
||||
** Clock divider input frequency : 96 MHz
|
||||
** Clock divider fraction : multiply by 1
|
||||
** Clock divider divisor : divide by 2
|
||||
** Module clock source : Clock divider output
|
||||
** Module clock frequency : 48 MHz
|
||||
** Pull-up/pull-down settings :
|
||||
** Weak pulldowns : Enabled
|
||||
** Pull-up/pull-down control : Mode dependent
|
||||
** D+ pull-up : Disabled
|
||||
** D+ pull-down : Disabled
|
||||
** D- pull-down : Disabled
|
||||
** D+ pull-up for non-OTG mode : Disabled
|
||||
** Endpoints :
|
||||
** EP0 : Disabled
|
||||
** Direct low speed : Disabled
|
||||
** Retry : Enabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP1 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP2 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP3 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP4 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP5 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP6 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP7 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP8 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP9 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP10 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP11 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP12 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP13 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP14 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP15 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** Buffer descriptor table :
|
||||
** External object declaration : extern uint8 g_Mem[];
|
||||
** Address : ((uint32)&g_Mem[0])
|
||||
** SOF threshold : 0
|
||||
** Pins :
|
||||
** Alternate clock source : Disabled
|
||||
** SOF output : Disabled
|
||||
** Data plus : Enabled
|
||||
** Pin : USB0_DP
|
||||
** Pin signal :
|
||||
** Data minus : Enabled
|
||||
** Pin : USB0_DM
|
||||
** Pin signal :
|
||||
** Interrupts :
|
||||
** USB :
|
||||
** Interrupt : INT_USB0
|
||||
** Interrupt request : Disabled
|
||||
** Interrupt priority : 0 (Highest)
|
||||
** ISR Name : USB_ISR
|
||||
** Stall : Enabled
|
||||
** Attach : Enabled
|
||||
** Resume : Enabled
|
||||
** Sleep : Enabled
|
||||
** Token OK : Enabled
|
||||
** Start of frame : Enabled
|
||||
** Error interrupt : Enabled
|
||||
** USB reset : Enabled
|
||||
** Asynchronous Resume interrupt : Enabled
|
||||
** Error interrupts :
|
||||
** Bit stuff error : Disabled
|
||||
** DMA error : Disabled
|
||||
** Bus turnaround timeout : Disabled
|
||||
** Data length error : Disabled
|
||||
** CRC16 error : Disabled
|
||||
** CRC5 or EOF : Disabled
|
||||
** PID error : Disabled
|
||||
** OTG interrupts :
|
||||
** ID pin changed : Disabled
|
||||
** 1 ms interrupt : Disabled
|
||||
** Line stage change : Disabled
|
||||
** Session valid : Disabled
|
||||
** "B" session end : Disabled
|
||||
** "A" bus valid : Disabled
|
||||
** Initialization :
|
||||
** Mode : Device
|
||||
** USB transceiver suspend state : Enabled
|
||||
** Call Init method : yes
|
||||
** Contents :
|
||||
** Init - void USB0_Init(void);
|
||||
**
|
||||
** Copyright : 1997 - 2014 Freescale Semiconductor, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file USB0.c
|
||||
** @version 01.04
|
||||
** @brief
|
||||
** This file implements the USB_OTG (USB0) module initialization
|
||||
** according to the Peripheral Initialization settings, and
|
||||
** defines interrupt service routines prototypes.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup USB0_module USB0 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE USB0. */
|
||||
|
||||
#include "USB0.h"
|
||||
/* Including shared modules, which are used in the whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "hal/derivative.h"
|
||||
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB0_Init (component Init_USB_OTG)
|
||||
** Description :
|
||||
** This method initializes registers of the USB_OTG module
|
||||
** according to the Peripheral Initialization settings.
|
||||
** Call this method in user code to initialize the module. By
|
||||
** default, the method is called by PE automatically; see "Call
|
||||
** Init method" property of the component for more details.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
extern uint8 g_Mem[];
|
||||
void USB0_Init(void)
|
||||
{
|
||||
/* SIM_CLKDIV2: USBDIV=1,USBFRAC=0 */
|
||||
SIM_CLKDIV2 = (uint32)((SIM_CLKDIV2 & (uint32)~(uint32)(
|
||||
SIM_CLKDIV2_USBDIV(0x06) |
|
||||
SIM_CLKDIV2_USBFRAC_MASK
|
||||
)) | (uint32)(
|
||||
SIM_CLKDIV2_USBDIV(0x01)
|
||||
));
|
||||
/* SIM_SOPT2: USBSRC=1 */
|
||||
SIM_SOPT2 |= SIM_SOPT2_USBSRC_MASK;
|
||||
/* SIM_SCGC4: USBOTG=1 */
|
||||
SIM_SCGC4 |= SIM_SCGC4_USBOTG_MASK;
|
||||
/* USB0_CTL: ODDRST=1 */
|
||||
USB0_CTL |= USB_CTL_ODDRST_MASK;
|
||||
/* USB0_USBCTRL: SUSP=1,PDE=1,??=0,??=0,??=0,??=0,??=0,??=0 */
|
||||
USB0_USBCTRL = (USB_USBCTRL_SUSP_MASK | USB_USBCTRL_PDE_MASK);
|
||||
/* USB0_OTGISTAT: IDCHG=1,ONEMSEC=1,LINE_STATE_CHG=1,??=1,SESSVLDCHG=1,B_SESS_CHG=1,??=1,AVBUSCHG=1 */
|
||||
USB0_OTGISTAT = USB_OTGISTAT_IDCHG_MASK |
|
||||
USB_OTGISTAT_ONEMSEC_MASK |
|
||||
USB_OTGISTAT_LINE_STATE_CHG_MASK |
|
||||
USB_OTGISTAT_SESSVLDCHG_MASK |
|
||||
USB_OTGISTAT_B_SESS_CHG_MASK |
|
||||
USB_OTGISTAT_AVBUSCHG_MASK |
|
||||
0x12U;
|
||||
/* USB0_ISTAT: STALL=1,ATTACH=1,RESUME=1,SLEEP=1,TOKDNE=1,SOFTOK=1,ERROR=1,USBRST=1 */
|
||||
USB0_ISTAT = USB_ISTAT_STALL_MASK |
|
||||
USB_ISTAT_ATTACH_MASK |
|
||||
USB_ISTAT_RESUME_MASK |
|
||||
USB_ISTAT_SLEEP_MASK |
|
||||
USB_ISTAT_TOKDNE_MASK |
|
||||
USB_ISTAT_SOFTOK_MASK |
|
||||
USB_ISTAT_ERROR_MASK |
|
||||
USB_ISTAT_USBRST_MASK;
|
||||
/* USB0_ERRSTAT: BTSERR=1,??=1,DMAERR=1,BTOERR=1,DFN8=1,CRC16=1,CRC5EOF=1,PIDERR=1 */
|
||||
USB0_ERRSTAT = USB_ERRSTAT_BTSERR_MASK |
|
||||
USB_ERRSTAT_DMAERR_MASK |
|
||||
USB_ERRSTAT_BTOERR_MASK |
|
||||
USB_ERRSTAT_DFN8_MASK |
|
||||
USB_ERRSTAT_CRC16_MASK |
|
||||
USB_ERRSTAT_CRC5EOF_MASK |
|
||||
USB_ERRSTAT_PIDERR_MASK |
|
||||
0x40U;
|
||||
/* USB0_INTEN: STALLEN=1,ATTACHEN=1,RESUMEEN=1,SLEEPEN=1,TOKDNEEN=1,SOFTOKEN=1,ERROREN=1,USBRSTEN=1 */
|
||||
USB0_INTEN = USB_INTEN_STALLEN_MASK |
|
||||
USB_INTEN_ATTACHEN_MASK |
|
||||
USB_INTEN_RESUMEEN_MASK |
|
||||
USB_INTEN_SLEEPEN_MASK |
|
||||
USB_INTEN_TOKDNEEN_MASK |
|
||||
USB_INTEN_SOFTOKEN_MASK |
|
||||
USB_INTEN_ERROREN_MASK |
|
||||
USB_INTEN_USBRSTEN_MASK;
|
||||
/* USB0_ERREN: BTSERREN=0,??=0,DMAERREN=0,BTOERREN=0,DFN8EN=0,CRC16EN=0,CRC5EOFEN=0,PIDERREN=0 */
|
||||
USB0_ERREN = 0x00U;
|
||||
/* USB0_USBTRC0: USBRESET=0,??=1,USBRESMEN=1,??=0,??=0,??=0,SYNC_DET=0,USB_RESUME_INT=0 */
|
||||
USB0_USBTRC0 = (USB_USBTRC0_USBRESMEN_MASK | 0x40U);
|
||||
/* USB0_OTGICR: IDEN=0,ONEMSECEN=0,LINESTATEEN=0,??=0,SESSVLDEN=0,BSESSEN=0,??=0,AVBUSEN=0 */
|
||||
USB0_OTGICR = 0x00U;
|
||||
/* USB0_ADDR: LSEN=0,ADDR=0 */
|
||||
USB0_ADDR = USB_ADDR_ADDR(0x00);
|
||||
/* USB0_ENDPT0: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT0 = 0x00U;
|
||||
/* USB0_ENDPT1: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT1 = 0x00U;
|
||||
/* USB0_ENDPT2: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT2 = 0x00U;
|
||||
/* USB0_ENDPT3: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT3 = 0x00U;
|
||||
/* USB0_ENDPT4: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT4 = 0x00U;
|
||||
/* USB0_ENDPT5: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT5 = 0x00U;
|
||||
/* USB0_ENDPT6: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT6 = 0x00U;
|
||||
/* USB0_ENDPT7: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT7 = 0x00U;
|
||||
/* USB0_ENDPT8: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT8 = 0x00U;
|
||||
/* USB0_ENDPT9: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT9 = 0x00U;
|
||||
/* USB0_ENDPT10: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT10 = 0x00U;
|
||||
/* USB0_ENDPT11: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT11 = 0x00U;
|
||||
/* USB0_ENDPT12: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT12 = 0x00U;
|
||||
/* USB0_ENDPT13: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT13 = 0x00U;
|
||||
/* USB0_ENDPT14: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT14 = 0x00U;
|
||||
/* USB0_ENDPT15: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT15 = 0x00U;
|
||||
USB0_BDTPAGE1 = (uint8)((((uint32)((uint32)&g_Mem[0])) >> 0x08) & 0xFEU);
|
||||
USB0_BDTPAGE2 = (uint8)((((uint32)((uint32)&g_Mem[0])) >> 0x10) & 0xFFU);
|
||||
USB0_BDTPAGE3 = (uint8)((((uint32)((uint32)&g_Mem[0])) >> 0x18) & 0xFFU);
|
||||
/* USB0_SOFTHLD: CNT=0 */
|
||||
USB0_SOFTHLD = USB_SOFTHLD_CNT(0x00);
|
||||
/* USB0_OTGCTL: DPHIGH=0,??=0,DPLOW=0,DMLOW=0,??=0,OTGEN=0,??=0,??=0 */
|
||||
USB0_OTGCTL = 0x00U;
|
||||
/* USB0_CONTROL: ??=0,??=0,??=0,DPPULLUPNONOTG=0,??=0,??=0,??=0,??=0 */
|
||||
USB0_CONTROL = 0x00U;
|
||||
/* USB0_CTL: TXSUSPENDTOKENBUSY=0,HOSTMODEEN=0,ODDRST=0,USBENSOFEN=1 */
|
||||
USB0_CTL = (uint8)((USB0_CTL & (uint8)~(uint8)(
|
||||
USB_CTL_TXSUSPENDTOKENBUSY_MASK |
|
||||
USB_CTL_HOSTMODEEN_MASK |
|
||||
USB_CTL_ODDRST_MASK
|
||||
)) | (uint8)(
|
||||
USB_CTL_USBENSOFEN_MASK
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** The interrupt service routine(s) must be implemented
|
||||
** by user in one of the following user modules.
|
||||
**
|
||||
** If the "Generate ISR" option is enabled, Processor Expert generates
|
||||
** ISR templates in the CPU event module.
|
||||
**
|
||||
** User modules:
|
||||
** main.c
|
||||
** Events.c
|
||||
**
|
||||
** ###################################################################
|
||||
PE_ISR(USB_ISR)
|
||||
{
|
||||
// NOTE: The routine should include actions to clear the appropriate
|
||||
// interrupt flags.
|
||||
//
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/* END USB0. */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,279 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : USB0.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : Init_USB_OTG
|
||||
** Version : Component 01.004, Driver 01.04, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This file implements the USB_OTG (USB0) module initialization
|
||||
** according to the Peripheral Initialization settings, and
|
||||
** defines interrupt service routines prototypes.
|
||||
** Settings :
|
||||
** Component name : USB0
|
||||
** Device : USB0
|
||||
** Settings :
|
||||
** Clock gate : Enabled
|
||||
** Clock settings :
|
||||
** Clock divider :
|
||||
** Clock divider source : PLL/FLL clock
|
||||
** Clock divider input frequency : 96 MHz
|
||||
** Clock divider fraction : multiply by 1
|
||||
** Clock divider divisor : divide by 2
|
||||
** Module clock source : Clock divider output
|
||||
** Module clock frequency : 48 MHz
|
||||
** Pull-up/pull-down settings :
|
||||
** Weak pulldowns : Enabled
|
||||
** Pull-up/pull-down control : Mode dependent
|
||||
** D+ pull-up : Disabled
|
||||
** D+ pull-down : Disabled
|
||||
** D- pull-down : Disabled
|
||||
** D+ pull-up for non-OTG mode : Disabled
|
||||
** Endpoints :
|
||||
** EP0 : Disabled
|
||||
** Direct low speed : Disabled
|
||||
** Retry : Enabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP1 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP2 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP3 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP4 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP5 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP6 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP7 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP8 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP9 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP10 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP11 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP12 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP13 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP14 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP15 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** Buffer descriptor table :
|
||||
** External object declaration : extern uint8 g_Mem[];
|
||||
** Address : ((uint32)&g_Mem[0])
|
||||
** SOF threshold : 0
|
||||
** Pins :
|
||||
** Alternate clock source : Disabled
|
||||
** SOF output : Disabled
|
||||
** Data plus : Enabled
|
||||
** Pin : USB0_DP
|
||||
** Pin signal :
|
||||
** Data minus : Enabled
|
||||
** Pin : USB0_DM
|
||||
** Pin signal :
|
||||
** Interrupts :
|
||||
** USB :
|
||||
** Interrupt : INT_USB0
|
||||
** Interrupt request : Disabled
|
||||
** Interrupt priority : 0 (Highest)
|
||||
** ISR Name : USB_ISR
|
||||
** Stall : Enabled
|
||||
** Attach : Enabled
|
||||
** Resume : Enabled
|
||||
** Sleep : Enabled
|
||||
** Token OK : Enabled
|
||||
** Start of frame : Enabled
|
||||
** Error interrupt : Enabled
|
||||
** USB reset : Enabled
|
||||
** Asynchronous Resume interrupt : Enabled
|
||||
** Error interrupts :
|
||||
** Bit stuff error : Disabled
|
||||
** DMA error : Disabled
|
||||
** Bus turnaround timeout : Disabled
|
||||
** Data length error : Disabled
|
||||
** CRC16 error : Disabled
|
||||
** CRC5 or EOF : Disabled
|
||||
** PID error : Disabled
|
||||
** OTG interrupts :
|
||||
** ID pin changed : Disabled
|
||||
** 1 ms interrupt : Disabled
|
||||
** Line stage change : Disabled
|
||||
** Session valid : Disabled
|
||||
** "B" session end : Disabled
|
||||
** "A" bus valid : Disabled
|
||||
** Initialization :
|
||||
** Mode : Device
|
||||
** USB transceiver suspend state : Enabled
|
||||
** Call Init method : yes
|
||||
** Contents :
|
||||
** Init - void USB0_Init(void);
|
||||
**
|
||||
** Copyright : 1997 - 2014 Freescale Semiconductor, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file USB0.h
|
||||
** @version 01.04
|
||||
** @brief
|
||||
** This file implements the USB_OTG (USB0) module initialization
|
||||
** according to the Peripheral Initialization settings, and
|
||||
** defines interrupt service routines prototypes.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup USB0_module USB0 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef USB0_H_
|
||||
#define USB0_H_
|
||||
|
||||
/* MODULE USB0. */
|
||||
|
||||
/* Including shared modules, which are used in the whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
//#include "Cpu.h"
|
||||
|
||||
/* Peripheral base address parameter */
|
||||
#define USB0_DEVICE USB0_BASE_PTR
|
||||
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB0_Init (component Init_USB_OTG)
|
||||
** Description :
|
||||
** This method initializes registers of the USB_OTG module
|
||||
** according to the Peripheral Initialization settings.
|
||||
** Call this method in user code to initialize the module. By
|
||||
** default, the method is called by PE automatically; see "Call
|
||||
** Init method" property of the component for more details.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void USB0_Init(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** The interrupt service routine must be implemented by user in one
|
||||
** of the user modules (see USB0.c file for more information).
|
||||
** ===================================================================
|
||||
*/
|
||||
//PE_ISR(USB_ISR);
|
||||
void __attribute((interrupt)) USB_ISR(void);
|
||||
|
||||
|
||||
/* END USB0. */
|
||||
#endif /* #ifndef __USB0_H_ */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,112 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : USB1.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : FSL_USB_Stack
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a wrapper to the FSL USB Stack.
|
||||
** Settings :
|
||||
** Component name : USB1
|
||||
** Freescale USB Stack Version : v4.1.1
|
||||
** USB : Init_USB_OTG_VAR0
|
||||
** Device Class : CDC Device
|
||||
** CDC Device : Enabled
|
||||
** CDCDevice : FSL_USB_CDC_Device
|
||||
** HID Keyboard Device : Disabled
|
||||
** MSD Host : Disabled
|
||||
** Call Init Method : yes
|
||||
** Contents :
|
||||
** Init - byte USB1_Init(void);
|
||||
**
|
||||
** (c) Copyright Freescale, all rights reserved, 2013-2014.
|
||||
** Ported as Processor Expert component: Erich Styger
|
||||
** http: www.mcuoneclipse.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file USB1.c
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a wrapper to the FSL USB Stack.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup USB1_module USB1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE USB1. */
|
||||
|
||||
#include "USB1.h"
|
||||
#include "hal/derivative.h" /* include peripheral declarations */
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_usb_int_dis (component FSL_USB_Stack)
|
||||
**
|
||||
** Description :
|
||||
** Disables USB interrupts (if supported)
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
void USB1_usb_int_dis(void)
|
||||
{
|
||||
/* Kinetis K20D72 */
|
||||
NVICISER1 = (1<<9); /* Disable interrupts from USB module (Interrupt Clear-Enable Register) */
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_usb_int_en (component FSL_USB_Stack)
|
||||
**
|
||||
** Description :
|
||||
** Enables USB interrupts (if supported).
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
void USB1_usb_int_en(void)
|
||||
{
|
||||
/* Kinetis K20D72 */
|
||||
NVICICPR2 = (1<<9); /* Clear any pending interrupts on USB (Interrupt Clear-Pending Register) */
|
||||
NVICISER2 = (1<<9); /* Enable interrupts from USB module (Interrupt Set-Enable Register) */
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_Init (component FSL_USB_Stack)
|
||||
** Description :
|
||||
** Initializes the driver
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte USB1_Init(void)
|
||||
{
|
||||
byte err;
|
||||
|
||||
/* Initialize the USB interface */
|
||||
err = CDC1_Init();
|
||||
if(err != ERR_OK) {
|
||||
/* Error initializing USB Class */
|
||||
return ERR_FAILED;
|
||||
}
|
||||
USB1_usb_int_en();
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/* END USB1. */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,132 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : USB1.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : FSL_USB_Stack
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a wrapper to the FSL USB Stack.
|
||||
** Settings :
|
||||
** Component name : USB1
|
||||
** Freescale USB Stack Version : v4.1.1
|
||||
** USB : Init_USB_OTG_VAR0
|
||||
** Device Class : CDC Device
|
||||
** CDC Device : Enabled
|
||||
** CDCDevice : FSL_USB_CDC_Device
|
||||
** HID Keyboard Device : Disabled
|
||||
** MSD Host : Disabled
|
||||
** Call Init Method : yes
|
||||
** Contents :
|
||||
** Init - byte USB1_Init(void);
|
||||
**
|
||||
** (c) Copyright Freescale, all rights reserved, 2013-2014.
|
||||
** Ported as Processor Expert component: Erich Styger
|
||||
** http: www.mcuoneclipse.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file USB1.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a wrapper to the FSL USB Stack.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup USB1_module USB1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __USB1_H
|
||||
#define __USB1_H
|
||||
|
||||
/* MODULE USB1. */
|
||||
|
||||
/* Include shared modules, which are used for whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
/* Include inherited beans */
|
||||
#include "USB0.h"
|
||||
#include "CDC1.h"
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
/* Interfaces/wrappers to the CDC device class, needed by FSShell: */
|
||||
#define USB1_SendString(str) CDC1_SendString(str)
|
||||
#define USB1_RecvChar(chr) CDC1_GetChar(chr)
|
||||
#define USB1_SendChar(chr) CDC1_SendChar(chr)
|
||||
#define USB1_GetCharsInRxBuf() CDC1_GetCharsInRxBuf()
|
||||
|
||||
//#include "Cpu.h"
|
||||
|
||||
|
||||
#ifndef __BWUserType_USB1_TComData
|
||||
#define __BWUserType_USB1_TComData
|
||||
typedef byte USB1_TComData ; /* User type for communication data type. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
DATA_BUFF_SIZE should be greater than or equal to the endpoint buffer size,
|
||||
otherwise there will be data loss. For MC9S08JS16, maximum DATA_BUFF_SIZE
|
||||
supported is 16 Bytes
|
||||
*/
|
||||
#define USB1_DATA_BUFF_SIZE 64 /* data buffer size as specified in the properties */
|
||||
|
||||
#define USB1_USB_ERR_SEND 1 /* Error while sending */
|
||||
#define USB1_USB_ERR_BUSOFF 2 /* Bus not ready */
|
||||
#define USB1_USB_ERR_INIT 3 /* USB initialization error */
|
||||
#define USB1_USB_ERR_TX_CHAR 4 /* Error sending character */
|
||||
#define USB1_USB_ERR_TX_STRING 5 /* Error sending string */
|
||||
#define USB1_USB_ERR_CHECKED_TXFULL 6 /* Error during sending a checked block */
|
||||
#define USB1_USB_ERR_RECEIVE 7 /* Error while starting a receive transaction */
|
||||
|
||||
byte USB1_Init(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_Init (component FSL_USB_Stack)
|
||||
** Description :
|
||||
** Initializes the driver
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void USB1_usb_int_dis(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_usb_int_dis (component FSL_USB_Stack)
|
||||
**
|
||||
** Description :
|
||||
** Disables USB interrupts (if supported)
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void USB1_usb_int_en(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_usb_int_en (component FSL_USB_Stack)
|
||||
**
|
||||
** Description :
|
||||
** Enables USB interrupts (if supported).
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END USB1. */
|
||||
|
||||
#endif
|
||||
/* ifndef __USB1_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,211 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file USB_Config.h
|
||||
*
|
||||
* @author B14088
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date Oct 31, 2010
|
||||
*
|
||||
* @brief
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef USB_CONFIG_H_
|
||||
#define USB_CONFIG_H_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Includes Section */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Typedef Section */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function's Prototypes */
|
||||
/*****************************************************************************/
|
||||
/* CDC class services */
|
||||
extern void USB_Class_CDC_Service_Dic_Bulk_In (PTR_USB_DEV_EVENT_STRUCT event);
|
||||
extern void USB_Class_CDC_Service_Dic_Bulk_Out(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
extern void USB_Class_CDC_Service_Cic_Notify(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
extern void USB_NULL_CALLBACK (PTR_USB_DEV_EVENT_STRUCT event);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Defines & Macros Section */
|
||||
/*****************************************************************************/
|
||||
|
||||
#define REMOTE_WAKEUP_SUPPORT (TRUE)
|
||||
|
||||
/* CDC specific configuration parameters */
|
||||
#define DATA_CLASS_SUPPORT (TRUE)
|
||||
#define CIC_NOTIF_ELEM_SUPPORT (TRUE) /* Mandatory */
|
||||
#define DIC_ISOCHRONOUS_SETTING (FALSE)
|
||||
#define IMPLEMENT_QUEUING (FALSE)
|
||||
|
||||
/* Hardware components configuration */
|
||||
#define USB_HW_VREG_EN TRUE
|
||||
#define USB_HW_PU_EN TRUE
|
||||
|
||||
/* Event callbacks assignation */
|
||||
#define USB_EP0_CALLBACK USB_Control_Service
|
||||
|
||||
#if DIC_ISOCHRONOUS_SETTING
|
||||
#define USB_EP1_CALLBACK USB_Class_CDC_Service_Dic_Iso_In
|
||||
#define USB_EP2_CALLBACK USB_Class_CDC_Service_Dic_Iso_Out
|
||||
#else
|
||||
#define USB_EP1_CALLBACK USB_Class_CDC_Service_Dic_Bulk_In
|
||||
#define USB_EP2_CALLBACK USB_Class_CDC_Service_Dic_Bulk_Out
|
||||
#endif
|
||||
|
||||
#define USB_EP3_CALLBACK USB_Class_CDC_Service_Cic_Notify
|
||||
#define USB_EP4_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP5_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP6_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP7_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP8_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP9_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP10_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP11_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP12_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP13_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP14_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP15_CALLBACK USB_NULL_CALLBACK
|
||||
|
||||
#define USB_BUS_RESET_CALLBACK USB_Reset_Service
|
||||
#define USB_SUSPEND_CALLBACK USB_Suspend_Service
|
||||
#define USB_SOF_CALLBACK USB_Sof_Service
|
||||
#define USB_RESUME_CALLBACK USB_Resume_Service
|
||||
#define USB_SLEEP_CALLBACK USB_Suspend_Service
|
||||
#define USB_SPEED_DETECTION_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_ERROR_CALLBACK USB_Error_Service
|
||||
#define USB_STALL_CALLBACK USB_Stall_Service
|
||||
|
||||
/* Endpoints configuration */
|
||||
#define USB_EP0_ENABLE TRUE
|
||||
#define USB_EP0_DIR EP_CTRL
|
||||
#define USB_EP0_HSHK TRUE
|
||||
#define USB_EP0_SIZE 32
|
||||
|
||||
#if DIC_ISOCHRONOUS_SETTING
|
||||
#define USB_EP1_ENABLE TRUE
|
||||
#define USB_EP1_DIR USB_DIR_IN
|
||||
#define USB_EP1_HSHK FALSE
|
||||
#define USB_EP1_SIZE 64
|
||||
|
||||
#define USB_EP2_ENABLE TRUE
|
||||
#define USB_EP2_DIR EP_OUT
|
||||
#define USB_EP2_HSHK FALSE
|
||||
#define USB_EP2_SIZE 64
|
||||
#else
|
||||
#define USB_EP1_ENABLE TRUE
|
||||
#define USB_EP1_DIR EP_IN
|
||||
#define USB_EP1_HSHK TRUE
|
||||
#define USB_EP1_SIZE 32
|
||||
|
||||
#define USB_EP2_ENABLE TRUE
|
||||
#define USB_EP2_DIR EP_OUT
|
||||
#define USB_EP2_HSHK TRUE
|
||||
#define USB_EP2_SIZE 32
|
||||
#endif
|
||||
|
||||
#define USB_EP3_ENABLE TRUE
|
||||
#define USB_EP3_DIR EP_IN
|
||||
#define USB_EP3_HSHK TRUE
|
||||
#define USB_EP3_SIZE 32
|
||||
|
||||
#define USB_EP4_ENABLE FALSE
|
||||
#define USB_EP4_DIR NA
|
||||
#define USB_EP4_HSHK TRUE
|
||||
#define USB_EP4_SIZE 0
|
||||
|
||||
#define USB_EP5_ENABLE FALSE
|
||||
#define USB_EP5_DIR NA
|
||||
#define USB_EP5_HSHK TRUE
|
||||
#define USB_EP5_SIZE 0
|
||||
|
||||
#define USB_EP6_ENABLE FALSE
|
||||
#define USB_EP6_DIR NA
|
||||
#define USB_EP6_HSHK TRUE
|
||||
#define USB_EP6_SIZE 0
|
||||
|
||||
#define USB_EP7_ENABLE FALSE
|
||||
#define USB_EP7_DIR NA
|
||||
#define USB_EP7_HSHK TRUE
|
||||
#define USB_EP7_SIZE 0
|
||||
|
||||
#define USB_EP8_ENABLE FALSE
|
||||
#define USB_EP8_DIR NA
|
||||
#define USB_EP8_HSHK TRUE
|
||||
#define USB_EP8_SIZE 0
|
||||
|
||||
#define USB_EP9_ENABLE FALSE
|
||||
#define USB_EP9_DIR NA
|
||||
#define USB_EP9_HSHK TRUE
|
||||
#define USB_EP9_SIZE 0
|
||||
|
||||
#define USB_EP10_ENABLE FALSE
|
||||
#define USB_EP10_DIR NA
|
||||
#define USB_EP10_HSHK TRUE
|
||||
#define USB_EP10_SIZE 0
|
||||
|
||||
#define USB_EP11_ENABLE FALSE
|
||||
#define USB_EP11_DIR NA
|
||||
#define USB_EP11_HSHK TRUE
|
||||
#define USB_EP11_SIZE 0
|
||||
|
||||
#define USB_EP12_ENABLE FALSE
|
||||
#define USB_EP12_DIR NA
|
||||
#define USB_EP12_HSHK TRUE
|
||||
#define USB_EP12_SIZE 0
|
||||
|
||||
#define USB_EP13_ENABLE FALSE
|
||||
#define USB_EP13_DIR NA
|
||||
#define USB_EP13_HSHK TRUE
|
||||
#define USB_EP13_SIZE 0
|
||||
|
||||
#define USB_EP14_ENABLE FALSE
|
||||
#define USB_EP14_DIR NA
|
||||
#define USB_EP14_HSHK TRUE
|
||||
#define USB_EP14_SIZE 0
|
||||
|
||||
#define USB_EP15_ENABLE FALSE
|
||||
#define USB_EP15_DIR NA
|
||||
#define USB_EP15_HSHK TRUE
|
||||
#define USB_EP15_SIZE 0
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Extern Variables Section */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function Prototypes Section */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* USB_CONFIG_H_ */
|
||||
@@ -0,0 +1,64 @@
|
||||
/******************************************************/
|
||||
/**
|
||||
* @file hidef.h
|
||||
* Machine/compiler dependent declarations.
|
||||
*/
|
||||
/*----------------------------------------------------
|
||||
Copyright (c) Freescale DevTech
|
||||
All rights reserved
|
||||
Do not modify!
|
||||
*****************************************************/
|
||||
|
||||
#ifndef _H_HIDEF_
|
||||
#define _H_HIDEF_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef EnableInterrupts
|
||||
#ifndef DisableInterrupts
|
||||
|
||||
#if defined(__CWCC__)
|
||||
#pragma gcc_extensions on
|
||||
|
||||
/**** Version for ColFire V1 */
|
||||
#include <stddef.h>
|
||||
#include "types.h"
|
||||
|
||||
/*!< Macro to enable all interrupts. */
|
||||
#define EnableInterrupts asm ("CPSIE i")
|
||||
|
||||
/*!< Macro to disable all interrupts. */
|
||||
#define DisableInterrupts asm ("CPSID i")
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#include <intrinsics.h>
|
||||
|
||||
#define EnableInterrupts; __enable_interrupt()
|
||||
#define DisableInterrupts __disable_interrupt()
|
||||
|
||||
#elif defined (__CC_ARM)
|
||||
#define EnableInterrupts __enable_irq()
|
||||
#define DisableInterrupts __disable_irq()
|
||||
|
||||
#elif defined (__GNUC__)
|
||||
#include <stddef.h>
|
||||
#include "types.h"
|
||||
|
||||
/*!< Macro to enable all interrupts. */
|
||||
#define EnableInterrupts asm ("CPSIE i")
|
||||
|
||||
/*!< Macro to disable all interrupts. */
|
||||
#define DisableInterrupts asm ("CPSID i")
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* #ifdef DisableInterrupts */
|
||||
#endif/* #ifdef EnableInterrupts */
|
||||
/*****************************************************/
|
||||
/* end hidef.h */
|
||||
@@ -0,0 +1,180 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file types.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief The file contains definitions of datatypes.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef _TYPES_H
|
||||
#define _TYPES_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include <stddef.h>
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define LSB(a) ((a)._byte.byte0)
|
||||
#define MSB(a) ((a)._byte.byte1)
|
||||
|
||||
#define LOWER_LSB(a) ((a)._byte.byte0)
|
||||
#define LOWER_MSB(a) ((a)._byte.byte1)
|
||||
#define UPPER_LSB(a) ((a)._byte.byte2)
|
||||
#define UPPER_MSB(a) ((a)._byte.byte3)
|
||||
|
||||
#define _PTR_ *
|
||||
#define _CODE_PTR_ *
|
||||
|
||||
#ifndef TRUE
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define BYTESWAP16(x) (uint_16)((((x) & 0xFF00) >> 0x8) | (((x) & 0xFF) << 0x8))
|
||||
#define BYTESWAP32(val) (uint_32)((BYTESWAP16((uint_32)(val) & (uint_32)0xFFFF) << 0x10) | \
|
||||
(BYTESWAP16((uint_32)((val) >> 0x10))))
|
||||
|
||||
#ifdef CPU_LITTLE_ENDIAN /* << EST: defined by Processor Expert CPU.h for Kinetis devices */
|
||||
#ifndef LITTLE_ENDIAN /* might be defined already on the compiler command line? */
|
||||
#define LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LITTLE_ENDIAN
|
||||
#define ieee_htons(x) (uint_16)(x)
|
||||
#define ieee_htonl(x) (uint_32)(x)
|
||||
#define ieee_ntohs(x) (uint_16)(x)
|
||||
#define ieee_ntohl(x) (uint_32)(x)
|
||||
#else
|
||||
#define ieee_htons(x) BYTESWAP16(x)
|
||||
#define ieee_htonl(x) BYTESWAP32(x)
|
||||
#define ieee_ntohs(x) BYTESWAP16(x)
|
||||
#define ieee_ntohl(x) BYTESWAP32(x)
|
||||
#endif
|
||||
|
||||
#ifndef UNUSED
|
||||
#define UNUSED(x) (void)(x);
|
||||
#endif
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
typedef void _PTR_ pointer; /* Machine representation of a pointer */
|
||||
typedef unsigned char uint_8; /* 8-bit*/
|
||||
typedef signed char int_8; /* 8-bit*/
|
||||
|
||||
typedef unsigned short uint_16; /* 16-bit*/
|
||||
typedef signed short int_16; /* 16-bit*/
|
||||
|
||||
typedef unsigned long uint_32; /* 32-bit*/
|
||||
typedef signed long int_32; /* 32-bit*/
|
||||
|
||||
typedef unsigned char boolean; /* 8-bit*/
|
||||
|
||||
typedef uint_8* uint_8_ptr; /* ptr to 8-bit*/
|
||||
typedef uint_16* uint_16_ptr; /* ptr to 16-bit */
|
||||
typedef uint_32* uint_32_ptr; /* ptr to 32-bit*/
|
||||
|
||||
typedef uint_8_ptr uint8_ptr; /* ptr to 8-bit*/
|
||||
|
||||
/* definition of 8 bit word */
|
||||
typedef union _BYTE
|
||||
{
|
||||
uint_8 _byte;
|
||||
struct
|
||||
{
|
||||
unsigned b0:1;
|
||||
unsigned b1:1;
|
||||
unsigned b2:1;
|
||||
unsigned b3:1;
|
||||
unsigned b4:1;
|
||||
unsigned b5:1;
|
||||
unsigned b6:1;
|
||||
unsigned b7:1;
|
||||
}Bit;
|
||||
} BYTE;
|
||||
|
||||
/* definition of 16 bit word */
|
||||
typedef union _WORD
|
||||
{
|
||||
uint_16 _word;
|
||||
struct
|
||||
{
|
||||
uint_8 byte1;
|
||||
uint_8 byte0;
|
||||
}_byte;
|
||||
struct
|
||||
{
|
||||
BYTE HighB;
|
||||
BYTE LowB;
|
||||
}_Byte;
|
||||
} WORD;
|
||||
|
||||
/* definition of 32 bit word */
|
||||
typedef union _DWORD
|
||||
{
|
||||
uint_32 _dword;
|
||||
struct
|
||||
{
|
||||
uint_8 byte3;
|
||||
uint_8 byte2;
|
||||
uint_8 byte1;
|
||||
uint_8 byte0;
|
||||
}_byte;
|
||||
struct
|
||||
{
|
||||
uint_16 word1;
|
||||
uint_16 word0;
|
||||
}_word;
|
||||
struct
|
||||
{
|
||||
BYTE Byte3;
|
||||
BYTE Byte2;
|
||||
BYTE Byte1;
|
||||
BYTE Byte0;
|
||||
}_Byte;
|
||||
struct
|
||||
{
|
||||
WORD Word1;
|
||||
WORD Word0;
|
||||
}_Word;
|
||||
} DWORD;
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions - None
|
||||
*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_bdt_kinetis.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date Jun-05-2009
|
||||
*
|
||||
* @brief The file contains definitions of Buffer Descriptor Table.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USBBDT_H
|
||||
#define _USBBDT_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
/* Buffer Descriptor Status Register Initialization Parameters */
|
||||
#define _BDTSTALL (0x04) /* Buffer Stall enable */
|
||||
#define _DATA0 (0x00) /* DATA0 packet expected next */
|
||||
#define _DATA1 (0x40) /* DATA1 packet expected next */
|
||||
#define _DTS (0x08) /* DTS Mask */
|
||||
#define _SIE (0x80) /* SIE owns buffer */
|
||||
#define _CPU (0x00) /* CPU owns buffer */
|
||||
#define _KEEP (0x20) /* keep bit */
|
||||
|
||||
#define MAX_BDT_INDEX (64) /* Maximum BDT Indexes */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
/* This structure is an exact replica of the BDT MAP in the USB RAM
|
||||
The BDT_STAT defines the stat byte of the buffer descriptor vector.
|
||||
McuCtlBit structure defines the bits that have a meaning from CPU
|
||||
point of view.SieCtlBit structure defines the bits that have a
|
||||
meaning from USB controller point of view.
|
||||
*/
|
||||
|
||||
#if defined(__CWCC__)
|
||||
#pragma align_array_members on
|
||||
#endif
|
||||
/* << EST pushing current packing */
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
typedef struct _MCU_CTL_BIT{
|
||||
uint_8 :1;
|
||||
uint_8 :1;
|
||||
uint_8 bdtstall:1; /* Buffer Stall Enable */
|
||||
uint_8 dts:1; /* Data Toggle Synch Enable */
|
||||
uint_8 keep:1; /* Address Increment Disable */
|
||||
uint_8 ninc:1; /* BD Keep Enable */
|
||||
uint_8 data:1; /* Data Toggle Synch Value */
|
||||
uint_8 own:1; /* USB Ownership */
|
||||
}MCU_CTL_BIT; /* read Stat */
|
||||
|
||||
typedef struct _SIE_CTL_BIT{
|
||||
uint_8 :1;
|
||||
uint_8 :1;
|
||||
uint_8 pid0:1; /* Packet Identifier bit 0 */
|
||||
uint_8 pid1:1; /* Packet Identifier bit 1 */
|
||||
uint_8 pid2:1; /* Packet Identifier bit 2 */
|
||||
uint_8 pid3:1; /* Packet Identifier bit 3 */
|
||||
uint_8 :1;
|
||||
uint_8 own:1;
|
||||
}SIE_CTL_BIT; /* write Stat */
|
||||
|
||||
typedef struct _REC_PID{
|
||||
uint_8 :2;
|
||||
uint_8 pid:4; /* Packet Identifier */
|
||||
uint_8 :2;
|
||||
}REC_PID;
|
||||
|
||||
typedef union _BD_STAT
|
||||
{
|
||||
uint_8 _byte;
|
||||
MCU_CTL_BIT McuCtlBit;
|
||||
SIE_CTL_BIT SieCtlBit;
|
||||
REC_PID RecPid;
|
||||
} BD_STAT; /* Buffer Descriptor Status Register */
|
||||
|
||||
typedef struct _BUFF_DSC
|
||||
{
|
||||
BD_STAT Stat;
|
||||
uint_8 reserved1;
|
||||
uint_16 cnt; /* Count of bytes receieved or sent */
|
||||
/* six MSB bits are reserved ones */
|
||||
uint_32 addr; /* Buffer Address */
|
||||
} BUFF_DSC, *P_BUFF_DSC; /* Buffer Descriptor Table */
|
||||
|
||||
typedef struct _g_bdtmap {
|
||||
|
||||
BUFF_DSC ep_dsc[MAX_BDT_INDEX]; /* Endpoint Descriptor */
|
||||
}BDTMAP;
|
||||
#if defined(__CWCC__)
|
||||
#pragma align_array_members off
|
||||
#pragma options align=reset
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack()
|
||||
#else /* e.g. gcc */
|
||||
/* << EST restoring previous packing */
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
/******************************************************************************
|
||||
* Global Functions - None
|
||||
*****************************************************************************/
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,809 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_cdc.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB stack CDC layer implementation.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "usb_cdc.h" /* USB CDC Class Header File */
|
||||
/*****************************************************************************
|
||||
* Constant and Macro's
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
#ifdef _MC9S08JS16_H
|
||||
#pragma DATA_SEG APP_DATA
|
||||
#endif
|
||||
|
||||
/* CDC Class Callback Function Pointer */
|
||||
static USB_CLASS_CALLBACK g_cdc_class_callback = NULL;
|
||||
|
||||
/* CDC Class Vendor Callback Function Pointer */
|
||||
static USB_REQ_FUNC g_vendor_req_callback = NULL;
|
||||
|
||||
/* CDC endpoint info array */
|
||||
#ifndef COMPOSITE_DEV
|
||||
static USB_CLASS_CDC_ENDPOINT g_cdc_ep[CDC_DESC_ENDPOINT_COUNT];
|
||||
#else
|
||||
static USB_CLASS_CDC_ENDPOINT g_cdc_ep[COMPOSITE_DESC_ENDPOINT_COUNT];
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* Local Types - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions Prototypes
|
||||
*****************************************************************************/
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
void USB_Class_CDC_Service_Cic_Notify(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
#endif
|
||||
#if !DIC_ISOCHRONOUS_SETTING
|
||||
void USB_Class_CDC_Service_Dic_Bulk_In(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
void USB_Class_CDC_Service_Dic_Bulk_Out(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
#else
|
||||
static void USB_Class_CDC_Service_Dic_Iso_In(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
static void USB_Class_CDC_Service_Dic_Iso_Out(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
#endif
|
||||
#ifndef COMPOSITE_DEV
|
||||
static uint_8 USB_Other_Requests(
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
#endif
|
||||
void USB_Class_CDC_Event(
|
||||
uint_8 controller_ID,
|
||||
uint_8 event,
|
||||
void* val);
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Variables - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions
|
||||
*****************************************************************************/
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Service_Cic_Notify
|
||||
*
|
||||
* @brief The function is callback function of CIC Notification endpoint
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Called by Lower layer when data on CIC Endpoint is sent
|
||||
*****************************************************************************/
|
||||
void USB_Class_CDC_Service_Cic_Notify (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
#if IMPLEMENT_QUEUING
|
||||
uint_8 index;
|
||||
uint_8 producer, consumer;
|
||||
USB_ENDPOINTS *usb_ep_data = (USB_ENDPOINTS *)
|
||||
USB_Desc_Get_Endpoints(event->controller_ID);
|
||||
|
||||
USB_CLASS_CDC_QUEUE queue;
|
||||
|
||||
/* map the endpoint num to the index of the endpoint structure */
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
if(usb_ep_data->ep[index].ep_num == event->ep_num)
|
||||
break;
|
||||
}
|
||||
|
||||
producer = g_cdc_ep[index].bin_producer;
|
||||
|
||||
/* if there are no errors de-queue the queue and decrement the no. of
|
||||
transfers left, else send the same data again */
|
||||
if(event->errors == 0)
|
||||
{
|
||||
g_cdc_ep[index].bin_consumer++;
|
||||
}
|
||||
|
||||
consumer = g_cdc_ep[index].bin_consumer;
|
||||
|
||||
if(consumer != producer)
|
||||
{/*if bin is not empty */
|
||||
|
||||
queue = g_cdc_ep[index].queue[consumer%MAX_QUEUE_ELEMS];
|
||||
|
||||
(void)USB_Class_Send_Data(queue.controller_ID, queue.channel,
|
||||
queue.app_data.data_ptr, queue.app_data.data_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
uint_8 event_type = USB_APP_SEND_COMPLETE;
|
||||
|
||||
if(event->errors != 0)
|
||||
{
|
||||
event_type = USB_APP_ERROR;
|
||||
}
|
||||
g_cdc_class_callback(event->controller_ID, event_type,
|
||||
(uint_8*)(&(event->errors)));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !DIC_ISOCHRONOUS_SETTING
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Service_Dic_Bulk_In
|
||||
*
|
||||
* @brief The function is callback function of DIC Bulk In Endpoint
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Called by Lower Layer when Data on DIC SEND Interface is sent
|
||||
*****************************************************************************/
|
||||
void USB_Class_CDC_Service_Dic_Bulk_In (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
APP_DATA_STRUCT bulk_in_recv;
|
||||
|
||||
#if IMPLEMENT_QUEUING
|
||||
uint_8 index;
|
||||
uint_8 producer, consumer;
|
||||
USB_ENDPOINTS *usb_ep_data = (USB_ENDPOINTS *)
|
||||
USB_Desc_Get_Endpoints(event->controller_ID);
|
||||
|
||||
USB_CLASS_CDC_QUEUE queue;
|
||||
|
||||
bulk_in_recv.data_ptr = event->buffer_ptr;
|
||||
bulk_in_recv.data_size = event->len;
|
||||
|
||||
/* map the endpoint num to the index of the endpoint structure */
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
if(usb_ep_data->ep[index].ep_num == event->ep_num)
|
||||
break;
|
||||
}
|
||||
|
||||
producer = g_cdc_ep[index].bin_producer;
|
||||
|
||||
/* if there are no errors de-queue the queue and decrement the no. of
|
||||
transfers left, else send the same data again */
|
||||
if(event->errors == 0)
|
||||
{
|
||||
g_cdc_ep[index].bin_consumer++;
|
||||
}
|
||||
|
||||
consumer = g_cdc_ep[index].bin_consumer;
|
||||
|
||||
if(consumer != producer)
|
||||
{/*if bin is not empty */
|
||||
|
||||
queue = g_cdc_ep[index].queue[consumer%MAX_QUEUE_ELEMS];
|
||||
|
||||
(void)USB_Class_Send_Data(queue.controller_ID, queue.channel,
|
||||
queue.app_data.data_ptr, queue.app_data.data_size);
|
||||
}
|
||||
#endif
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
if(event->errors != 0)
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_ERROR,
|
||||
(uint_8*)(&(event->errors)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_SEND_COMPLETE,
|
||||
(void*)&bulk_in_recv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Service_Dic_Bulk_Out
|
||||
*
|
||||
* @brief The function is callback function of DIC Bulk Out Endpoint
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Called by Lower Layer when Data on DIC RECV Interface is received
|
||||
*****************************************************************************/
|
||||
void USB_Class_CDC_Service_Dic_Bulk_Out (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{ APP_DATA_STRUCT bulk_out_recv;
|
||||
|
||||
bulk_out_recv.data_ptr = event->buffer_ptr;
|
||||
bulk_out_recv.data_size = event->len;
|
||||
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
if(event->errors != 0)
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_ERROR,
|
||||
(uint_8*)(&(event->errors)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_DATA_RECEIVED,
|
||||
(void*)&bulk_out_recv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Service_Dic_Iso_In
|
||||
*
|
||||
* @brief The function is callback function of DIC Isochronous In Endpoint
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Called by Lower Layer when Data on DIC SEND Interface is sent
|
||||
*****************************************************************************/
|
||||
static void USB_Class_CDC_Service_Dic_Iso_In (
|
||||
PTR_USB_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
APP_DATA_STRUCT iso_in_recv;
|
||||
|
||||
#if IMPLEMENT_QUEUING
|
||||
uint_8 index;
|
||||
uint_8 producer, consumer;
|
||||
USB_ENDPOINTS *usb_ep_data = (USB_ENDPOINTS *)
|
||||
USB_Desc_Get_Endpoints(event->controller_ID);
|
||||
|
||||
USB_CLASS_CDC_QUEUE queue;
|
||||
|
||||
/* map the endpoint num to the index of the endpoint structure */
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
if(usb_ep_data->ep[index].ep_num == event->ep_num)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
producer = g_cdc_ep[index].bin_producer;
|
||||
|
||||
/* if there are no errors de-queue the queue and decrement the no. of
|
||||
transfers left, else send the same data again */
|
||||
if(event->errors == 0)
|
||||
{
|
||||
g_cdc_ep[index].bin_consumer++;
|
||||
}
|
||||
|
||||
consumer = g_cdc_ep[index].bin_consumer;
|
||||
|
||||
if(consumer != producer)
|
||||
{/*if bin is not empty */
|
||||
|
||||
queue = g_cdc_ep[index].queue[consumer%MAX_QUEUE_ELEMS];
|
||||
|
||||
(void)USB_Class_Send_Data(queue.controller_ID, queue.channel,
|
||||
queue.app_data.data_ptr, queue.app_data.data_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
iso_in_recv.data_ptr = event->buffer_ptr;
|
||||
iso_in_recv.data_size = event->len;
|
||||
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
if(event->errors != 0)
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_ERROR,
|
||||
(uint_8*)(&(event->errors)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_SEND_COMPLETE,
|
||||
(void*)&iso_in_recv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Service_Dic_Iso_Out
|
||||
*
|
||||
* @brief This is a callback function of DIC Isochronous Out Endpoint
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Called by Lower Layer when Data on DIC RECV Interface is received
|
||||
*****************************************************************************/
|
||||
static void USB_Class_CDC_Service_Dic_Iso_Out (
|
||||
PTR_USB_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
APP_DATA_STRUCT iso_out_recv;
|
||||
|
||||
iso_out_recv.data_ptr = event->buffer_ptr;
|
||||
iso_out_recv.data_size = event->len;
|
||||
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
if(event->errors != 0)
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_ERROR,
|
||||
(uint_8*)(&(event->errors)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_DATA_RECEIVED,
|
||||
(void*)&iso_out_recv);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Event
|
||||
*
|
||||
* @brief The function initializes CDC endpoints
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param event : Event Type
|
||||
* @param val : Pointer to configuration Value
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
*****************************************************************************/
|
||||
void USB_Class_CDC_Event (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 event, /* [IN] Event Type */
|
||||
void* val /* [OUT] Pointer to configuration Value */
|
||||
)
|
||||
{
|
||||
uint_8 index;
|
||||
USB_ENDPOINTS *usb_ep_data = (USB_ENDPOINTS *)
|
||||
USB_Desc_Get_Endpoints(controller_ID);
|
||||
|
||||
if(event == USB_APP_ENUM_COMPLETE)
|
||||
{
|
||||
uint_8 count = 0,ep_count = 0;
|
||||
uint_8 index_num = 0;
|
||||
|
||||
#ifdef COMPOSITE_DEV
|
||||
DEV_ARCHITECTURE_STRUCT_PTR dev_arc_ptr;
|
||||
CLASS_ARC_STRUCT_PTR dev_class_ptr;
|
||||
dev_arc_ptr = (DEV_ARCHITECTURE_STRUCT *)USB_Desc_Get_Class_Architecture(controller_ID);
|
||||
for(count = 0; count < dev_arc_ptr->cl_count; count++)
|
||||
{
|
||||
dev_class_ptr = (CLASS_ARC_STRUCT_PTR)dev_arc_ptr->value[count];
|
||||
/* Initializes sub_classes */
|
||||
ep_count = dev_class_ptr->value[0];
|
||||
if(dev_class_ptr->class_type == 0x02/*CDC_CC*/)
|
||||
break;
|
||||
index_num +=dev_class_ptr->value[0];
|
||||
}
|
||||
#else
|
||||
ep_count = usb_ep_data->count;
|
||||
#endif
|
||||
|
||||
for(count=index_num; count<ep_count+index_num; count++)
|
||||
{
|
||||
USB_EP_STRUCT_PTR ep_struct_ptr=
|
||||
(USB_EP_STRUCT_PTR) (unsigned long) (&usb_ep_data->ep[count]); // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
(void)_usb_device_deinit_endpoint(&controller_ID,
|
||||
ep_struct_ptr->ep_num, ep_struct_ptr->direction);
|
||||
}
|
||||
|
||||
/* intialize all non control endpoints */
|
||||
for(count=index_num; count<ep_count+index_num; count++)
|
||||
{
|
||||
USB_EP_STRUCT_PTR ep_struct=
|
||||
(USB_EP_STRUCT_PTR) (unsigned long) (&usb_ep_data->ep[count]); // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
|
||||
(void)_usb_device_init_endpoint(&controller_ID, ep_struct->ep_num,
|
||||
ep_struct->size, ep_struct->direction, ep_struct->type, FALSE);
|
||||
|
||||
/* register callback service for Non Control EndPoints */
|
||||
switch(ep_struct->type)
|
||||
{
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
case USB_INTERRUPT_PIPE :
|
||||
(void)_usb_device_register_service(controller_ID,
|
||||
(uint_8)(USB_SERVICE_EP0+ep_struct->ep_num),
|
||||
USB_Class_CDC_Service_Cic_Notify);
|
||||
break;
|
||||
#endif
|
||||
#if !DIC_ISOCHRONOUS_SETTING
|
||||
case USB_BULK_PIPE :
|
||||
#ifdef MULTIPLE_DEVICES
|
||||
if(ep_struct->direction == USB_RECV)
|
||||
{
|
||||
(void)_usb_device_register_service(controller_ID,
|
||||
(uint_8)(USB_SERVICE_EP0+ep_struct->ep_num),
|
||||
USB_Class_CDC_Service_Dic_Bulk_Out);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)_usb_device_register_service(controller_ID,
|
||||
(uint_8)(USB_SERVICE_EP0+ep_struct->ep_num),
|
||||
USB_Class_CDC_Service_Dic_Bulk_In);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#else
|
||||
case USB_ISOCHRONOUS_PIPE :
|
||||
if(ep_struct->direction == USB_RECV)
|
||||
{
|
||||
(void)_usb_device_register_service(controller_ID,
|
||||
(uint_8)(USB_SERVICE_EP0+ep_struct->ep_num),
|
||||
USB_Class_CDC_Service_Dic_Iso_Out);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)_usb_device_register_service(controller_ID,
|
||||
(uint_8)(USB_SERVICE_EP0+ep_struct->ep_num),
|
||||
USB_Class_CDC_Service_Dic_Iso_In);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* set the EndPoint Status as Idle in the device layer */
|
||||
(void)_usb_device_set_status(&controller_ID,
|
||||
(uint_8)(USB_STATUS_ENDPOINT | ep_struct->ep_num |
|
||||
(ep_struct->direction << USB_COMPONENT_DIRECTION_SHIFT)),
|
||||
(uint_8)USB_STATUS_IDLE);
|
||||
}
|
||||
}
|
||||
else if(event == USB_APP_BUS_RESET)
|
||||
{
|
||||
#if IMPLEMENT_QUEUING
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
g_cdc_ep[index].bin_consumer = 0x00;
|
||||
g_cdc_ep[index].bin_producer = 0x00;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
g_cdc_class_callback(controller_ID, event, val);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Other_Requests
|
||||
*
|
||||
* @brief The function provides flexibilty to add class and vendor specific
|
||||
* requests
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Setup packet received
|
||||
* @param data: : Data to be send back
|
||||
* @param size: : Size to be returned
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* Others : When Error
|
||||
*
|
||||
******************************************************************************
|
||||
* Handles CDC Class requests and forwards vendor specific request to the
|
||||
* application
|
||||
*****************************************************************************/
|
||||
#ifndef COMPOSITE_DEV
|
||||
static uint_8 USB_Other_Requests
|
||||
#else
|
||||
uint_8 USB_CDC_Other_Requests
|
||||
#endif
|
||||
(
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet,/* [IN] Pointer to Setup Packet Received */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data Buffer to be sent */
|
||||
USB_PACKET_SIZE *size /* [OUT] Size of Data buffer */
|
||||
)
|
||||
{
|
||||
uint_8 status = USBERR_INVALID_REQ_TYPE;
|
||||
if((setup_packet->request_type & USB_REQUEST_CLASS_MASK) ==
|
||||
USB_REQUEST_CLASS_CLASS)
|
||||
{
|
||||
/* class request so handle it here */
|
||||
status=USB_OK;
|
||||
|
||||
/* call for class/subclass specific requests */
|
||||
switch(setup_packet->request)
|
||||
{
|
||||
case SEND_ENCAPSULATED_COMMAND :
|
||||
/* Add code to transfer Request and Acknowledgement */
|
||||
*size=0;
|
||||
break;
|
||||
case GET_ENCAPSULATED_RESPONSE :
|
||||
/*
|
||||
Add code for handling Transfer Response/Requests and
|
||||
Notification
|
||||
*/
|
||||
*size=0;
|
||||
break;
|
||||
case SET_COMM_FEATURE :
|
||||
status = USB_Class_CDC_PSTN_Set_Comm_Feature(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case GET_COMM_FEATURE :
|
||||
status = USB_Class_CDC_PSTN_Get_Comm_Feature(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case CLEAR_COMM_FEATURE : /* Verify this implementation */
|
||||
*size = COMM_FEATURE_DATA_SIZE;
|
||||
**data = 0x00; *(++(*data)) = 0x00;/* clear both feature bytes */
|
||||
status = USB_Class_CDC_PSTN_Set_Comm_Feature(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case GET_LINE_CODING :
|
||||
status = USB_Class_CDC_PSTN_Get_Line_Coding(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case SET_LINE_CODING :
|
||||
status = USB_Class_CDC_PSTN_Set_Line_Coding(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case SET_CONTROL_LINE_STATE :
|
||||
status = USB_Class_CDC_PSTN_Set_Ctrl_Line_State(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case SEND_BREAK :
|
||||
status = USB_Class_CDC_PSTN_Send_Break(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
default:
|
||||
*size=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if((setup_packet->request_type & USB_REQUEST_CLASS_MASK) ==
|
||||
USB_REQUEST_CLASS_VENDOR)
|
||||
{
|
||||
/* vendor specific request */
|
||||
if(g_vendor_req_callback != NULL)
|
||||
{
|
||||
status = g_vendor_req_callback(controller_ID, setup_packet, data,
|
||||
size);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Init
|
||||
*
|
||||
* @brief The function initializes the Device and Controller layer
|
||||
*
|
||||
* @param controller_ID: Controller ID
|
||||
* @param cdc_class_callback: CDC Class Callback
|
||||
* @param vendor_req_callback: vendor specific class request callback
|
||||
* @param param_callback: PSTN Callback
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* Others : Errors
|
||||
******************************************************************************
|
||||
* This function initializes the CDC Class layer and layers it is dependent upon
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_Init (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_CLASS_CALLBACK cdc_class_callback, /* [IN] CDC Class Callback */
|
||||
USB_REQ_FUNC vendor_req_callback, /* [IN] Vendor Request Callback */
|
||||
USB_CLASS_CALLBACK pstn_callback, /* [IN] PSTN Callback */
|
||||
uint_8 bVregEn /* Enables or disables internal regulator */
|
||||
)
|
||||
{
|
||||
uint_8 index,status = USB_OK;
|
||||
USB_ENDPOINTS *usb_ep_data =
|
||||
(USB_ENDPOINTS *)USB_Desc_Get_Endpoints(controller_ID);
|
||||
#ifndef COMPOSITE_DEV
|
||||
/* Initialize the device layer*/
|
||||
status = _usb_device_init(controller_ID, NULL,
|
||||
(uint_8)(usb_ep_data->count+1), bVregEn);
|
||||
/* +1 is for Control Endpoint */
|
||||
|
||||
if(status == USB_OK)
|
||||
{
|
||||
/* Initialize the generic class functions */
|
||||
status = USB_Class_Init(controller_ID,USB_Class_CDC_Event,
|
||||
USB_Other_Requests);
|
||||
#endif
|
||||
#if IMPLEMENT_QUEUING
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
g_cdc_ep[index].endpoint = usb_ep_data->ep[index].ep_num;
|
||||
g_cdc_ep[index].type = usb_ep_data->ep[index].type;
|
||||
g_cdc_ep[index].bin_consumer = 0x00;
|
||||
g_cdc_ep[index].bin_producer = 0x00;
|
||||
}
|
||||
#endif
|
||||
#if PSTN_SUBCLASS_NOTIF_SUPPORT
|
||||
/* Initialize the pstn subclass functions */
|
||||
status = USB_Class_CDC_Pstn_Init(controller_ID,pstn_callback);
|
||||
#endif
|
||||
if(status == USB_OK)
|
||||
{
|
||||
/* save the callback pointer */
|
||||
g_cdc_class_callback = cdc_class_callback;
|
||||
|
||||
/* save the callback pointer */
|
||||
g_vendor_req_callback = vendor_req_callback;
|
||||
}
|
||||
#ifndef COMPOSITE_DEV
|
||||
}
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_DeInit
|
||||
*
|
||||
* @brief The function de-initializes the Device and Controller layer
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* Others : When Error
|
||||
*
|
||||
******************************************************************************
|
||||
*This function de-initializes the CDC Class layer
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_DeInit
|
||||
(
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
uint_8 status = USB_OK;
|
||||
#ifdef COMPOSITE_DEV
|
||||
UNUSED(controller_ID);
|
||||
#endif
|
||||
/* save the callback pointer */
|
||||
g_cdc_class_callback = NULL;
|
||||
|
||||
/* free the vendor request callback pointer */
|
||||
g_vendor_req_callback = NULL;
|
||||
|
||||
#ifndef COMPOSITE_DEV
|
||||
/* call common class deinit function */
|
||||
status = USB_Class_DeInit(controller_ID);
|
||||
|
||||
if(status == USB_OK)
|
||||
/* Call device deinit function */
|
||||
status = _usb_device_deinit();
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Send_Data
|
||||
*
|
||||
* @brief This function is used to send data from CDC Class over send endpoints
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param ep_num : Endpoint number
|
||||
* @param app_buff : Buffer to send
|
||||
* @param size : Length of the transfer
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* Others : Errors
|
||||
******************************************************************************
|
||||
* Helper function. Sends DATA over CIC and DIC Interfaces to Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_Send_Data (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 ep_num, /* [IN] Endpoint Number */
|
||||
uint_8_ptr app_buff, /* Pointer to Application Buffer */
|
||||
USB_PACKET_SIZE size /* Size of Application Buffer */
|
||||
)
|
||||
{
|
||||
uint_8 status = USB_OK;
|
||||
|
||||
#if IMPLEMENT_QUEUING
|
||||
uint_8 index;
|
||||
uint_8 producer, consumer;
|
||||
|
||||
USB_ENDPOINTS *usb_ep_data = (USB_ENDPOINTS *)
|
||||
USB_Desc_Get_Endpoints(controller_ID);
|
||||
|
||||
/* map the endpoint num to the index of the endpoint structure */
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
if(usb_ep_data->ep[index].ep_num == ep_num)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
producer = g_cdc_ep[index].bin_producer;
|
||||
consumer = g_cdc_ep[index].bin_consumer;
|
||||
|
||||
if(((uint_8)(producer - consumer)) != (uint_8)(MAX_QUEUE_ELEMS))
|
||||
{
|
||||
/* the bin is not full*/
|
||||
|
||||
uint_8 queue_num = (uint_8)(producer % MAX_QUEUE_ELEMS);
|
||||
|
||||
/* put all send request parameters in the endpoint data structure */
|
||||
g_cdc_ep[index].queue[queue_num].controller_ID = controller_ID;
|
||||
g_cdc_ep[index].queue[queue_num].channel = ep_num;
|
||||
g_cdc_ep[index].queue[queue_num].app_data.data_ptr = app_buff;
|
||||
g_cdc_ep[index].queue[queue_num].app_data.data_size = size;
|
||||
|
||||
/* increment producer bin by 1*/
|
||||
g_cdc_ep[index].bin_producer = ++producer;
|
||||
|
||||
if((uint_8)(producer - consumer) == (uint_8)1)
|
||||
{
|
||||
#endif
|
||||
status = USB_Class_Send_Data(controller_ID, ep_num, app_buff,size);
|
||||
#if IMPLEMENT_QUEUING
|
||||
}
|
||||
}
|
||||
else /* bin is full */
|
||||
{
|
||||
status = USBERR_DEVICE_BUSY;
|
||||
}
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
@@ -0,0 +1,202 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_cdc.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB stack CDC class layer API header function.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_CDC_H
|
||||
#define _USB_CDC_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "usb_descriptor.h"
|
||||
#include "usb_class.h"
|
||||
#include "usb_cdc_pstn.h"
|
||||
#include "usb_devapi.h"
|
||||
#ifdef COMPOSITE_DEV
|
||||
#include "usb_composite.h"
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
/* Class specific request Codes */
|
||||
#define SEND_ENCAPSULATED_COMMAND (0x00)
|
||||
#define GET_ENCAPSULATED_RESPONSE (0x01)
|
||||
#define SET_COMM_FEATURE (0x02)
|
||||
#define GET_COMM_FEATURE (0x03)
|
||||
#define CLEAR_COMM_FEATURE (0x04)
|
||||
#define SET_AUX_LINE_STATE (0x10)
|
||||
#define SET_HOOK_STATE (0x11)
|
||||
#define PULSE_SETUP (0x12)
|
||||
#define SEND_PULSE (0x13)
|
||||
#define SET_PULSE_TIME (0x14)
|
||||
#define RING_AUX_JACK (0x15)
|
||||
#define SET_LINE_CODING (0x20)
|
||||
#define GET_LINE_CODING (0x21)
|
||||
#define SET_CONTROL_LINE_STATE (0x22)
|
||||
#define SEND_BREAK (0x23)
|
||||
#define SET_RINGER_PARAMS (0x30)
|
||||
#define GET_RINGER_PARAMS (0x31)
|
||||
#define SET_OPERATION_PARAM (0x32)
|
||||
#define GET_OPERATION_PARAM (0x33)
|
||||
#define SET_LINE_PARAMS (0x34)
|
||||
#define GET_LINE_PARAMS (0x35)
|
||||
#define DIAL_DIGITS (0x36)
|
||||
#define SET_UNIT_PARAMETER (0x37)
|
||||
#define GET_UNIT_PARAMETER (0x38)
|
||||
#define CLEAR_UNIT_PARAMETER (0x39)
|
||||
#define GET_PROFILE (0x3A)
|
||||
#define SET_ETHERNET_MULTICAST_FILTERS (0x40)
|
||||
#define SET_ETHERNET_POW_PATTER_FILTER (0x41)
|
||||
#define GET_ETHERNET_POW_PATTER_FILTER (0x42)
|
||||
#define SET_ETHERNET_PACKET_FILTER (0x43)
|
||||
#define GET_ETHERNET_STATISTIC (0x44)
|
||||
#define SET_ATM_DATA_FORMAT (0x50)
|
||||
#define GET_ATM_DEVICE_STATISTICS (0x51)
|
||||
#define SET_ATM_DEFAULT_VC (0x52)
|
||||
#define GET_ATM_VC_STATISTICS (0x53)
|
||||
#define MDLM_SPECIFIC_REQUESTS_MASK (0x7F)
|
||||
|
||||
/* Class Specific Notification Codes */
|
||||
#define NETWORK_CONNECTION_NOTIF (0x00)
|
||||
#define RESPONSE_AVAIL_NOTIF (0x01)
|
||||
#define AUX_JACK_HOOK_STATE_NOTIF (0x08)
|
||||
#define RING_DETECT_NOTIF (0x09)
|
||||
#define SERIAL_STATE_NOTIF (0x20)
|
||||
#define CALL_STATE_CHANGE_NOTIF (0x28)
|
||||
#define LINE_STATE_CHANGE_NOTIF (0x29)
|
||||
#define CONNECTION_SPEED_CHANGE_NOTIF (0x2A)
|
||||
#define MDLM_SPECIFIC_NOTIF_MASK (0x5F)
|
||||
|
||||
/* Events to the Application */ /* 0 to 4 are reserved for class events */
|
||||
#define USB_APP_CDC_CARRIER_DEACTIVATED (0x21)
|
||||
#define USB_APP_CDC_CARRIER_ACTIVATED (0x22)
|
||||
|
||||
/* other macros */
|
||||
#define NOTIF_PACKET_SIZE (0x08)
|
||||
#define NOTIF_REQUEST_TYPE (0xA1)
|
||||
|
||||
/* macros for queuing */
|
||||
#define MAX_QUEUE_ELEMS (4)
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
#define CIC_SEND_ENDPOINT CIC_NOTIF_ENDPOINT
|
||||
#endif
|
||||
|
||||
#if DIC_ISOCHRONOUS_SETTING
|
||||
#define DIC_SEND_ENDPOINT DIC_ISO_IN_ENDPOINT
|
||||
#define DIC_RECV_ENDPOINT DIC_ISO_OUT_ENDPOINT
|
||||
#else
|
||||
#define DIC_SEND_ENDPOINT DIC_BULK_IN_ENDPOINT
|
||||
#define DIC_RECV_ENDPOINT DIC_BULK_OUT_ENDPOINT
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
#ifndef COMPOSITE_DEV
|
||||
typedef struct _app_data_struct
|
||||
{
|
||||
uint_8_ptr data_ptr; /* pointer to buffer */
|
||||
USB_PACKET_SIZE data_size; /* buffer size of endpoint */
|
||||
}APP_DATA_STRUCT;
|
||||
#endif
|
||||
|
||||
/* structure to hold a request in the endpoint queue */
|
||||
typedef struct _usb_class_cdc_queue
|
||||
{
|
||||
uint_8 controller_ID; /* Controller ID */
|
||||
uint_8 channel; /* Endpoint Number */
|
||||
APP_DATA_STRUCT app_data; /* Application Data Structure */
|
||||
}USB_CLASS_CDC_QUEUE, *PTR_USB_CLASS_CDC_QUEUE;
|
||||
|
||||
/* USB class cdc endpoint data */
|
||||
typedef struct _usb_class_cdc_endpoint
|
||||
{
|
||||
uint_8 endpoint; /* endpoint num */
|
||||
uint_8 type; /* type of endpoint (interrupt, bulk or isochronous) */
|
||||
uint_8 bin_consumer;/* the num of queued elements */
|
||||
uint_8 bin_producer;/* the num of de-queued elements */
|
||||
USB_CLASS_CDC_QUEUE queue[MAX_QUEUE_ELEMS]; /* queue data */
|
||||
}USB_CLASS_CDC_ENDPOINT;
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 USB_Class_CDC_Init (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_CLASS_CALLBACK cdc_class_callback, /* [IN] CDC Class Callback */
|
||||
USB_REQ_FUNC vendor_req_callback, /* [IN] Vendor Request Callback */
|
||||
USB_CLASS_CALLBACK pstn_callback, /* [IN] PSTN Callback */
|
||||
uint_8 bVregEn /* Enables or disables internal regulator */
|
||||
);
|
||||
|
||||
#ifdef COMPOSITE_DEV
|
||||
extern uint_8 USB_CDC_Other_Requests(uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
#endif
|
||||
|
||||
extern uint_8 USB_Class_CDC_DeInit
|
||||
(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern uint_8 USB_Class_CDC_Send_Data (
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8_ptr buff_ptr,
|
||||
USB_PACKET_SIZE size
|
||||
);
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
#define USB_Class_CDC_Interface_CIC_Send_Data(a,b,c) \
|
||||
USB_Class_CDC_Send_Data(a,CIC_SEND_ENDPOINT,b,c)
|
||||
#endif
|
||||
|
||||
#define USB_Class_CDC_Interface_DIC_Send_Data(a,b,c) \
|
||||
USB_Class_CDC_Send_Data(a,DIC_SEND_ENDPOINT,b,c)
|
||||
#define USB_Class_CDC_Interface_DIC_Recv_Data(a,b,c) \
|
||||
_usb_device_recv_data(a,DIC_RECV_ENDPOINT,b,c)
|
||||
#define USB_Class_CDC_Interface_DIC_Get_Send_Buffer(a,b,c) \
|
||||
_usb_device_get_send_buffer(a,DIC_SEND_ENDPOINT,b,c)
|
||||
|
||||
#define USB_Class_CDC_Periodic_Task USB_Class_Periodic_Task
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,398 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_cdc_pstn.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB CDC_PSTN Sub Class implementation.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "usb_cdc_pstn.h" /* USB CDC PSTN Sub Class Header File */
|
||||
|
||||
/*****************************************************************************
|
||||
* Constant and Macro's
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions Prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Types - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions Prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Variables
|
||||
*****************************************************************************/
|
||||
/* PSTN subclass callback pointer */
|
||||
static USB_CLASS_CALLBACK g_pstn_callback = NULL;
|
||||
/* data terminal equipment present or not */
|
||||
static boolean g_dte_present = FALSE;
|
||||
static uint_8 g_dte_status = 0; /* Status of DATA TERMINAL EQUIPMENT */
|
||||
static uint_16 g_break_duration = 0; /* Length of time in milliseconds of the
|
||||
break signal */
|
||||
static uint_8 g_current_interface = 0;
|
||||
static UART_BITMAP g_uart_bitmap;
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
static uint_8 g_serial_state_buf[NOTIF_PACKET_SIZE+UART_BITMAP_SIZE] =
|
||||
{
|
||||
NOTIF_REQUEST_TYPE,SERIAL_STATE_NOTIF,
|
||||
0x00,0x00,/*wValue*/
|
||||
0x00,0x00,/*interface - modifies*/
|
||||
UART_BITMAP_SIZE,0x00,/* wlength*/
|
||||
0x00,0x00 /*data initialized - modifies*/
|
||||
};/*uart bitmap*/
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* Local Functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Pstn_Init
|
||||
*
|
||||
* @brief The function initializes the PSTN Module
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param callback : PSTN Callback
|
||||
*
|
||||
* @return error
|
||||
* USB_OK : Always
|
||||
******************************************************************************
|
||||
* PSTN Sub Class Initialization routine
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_Pstn_Init (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_CLASS_CALLBACK callback /* [IN] PSTN Callback */
|
||||
)
|
||||
{
|
||||
uint_8 error = USB_OK;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* save input parameters */
|
||||
g_pstn_callback = callback;
|
||||
return error;
|
||||
}
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Get_Line_Coding
|
||||
*
|
||||
* @brief This function is called in response to GetLineCoding request
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data to be send
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE: When request for
|
||||
* invalid Interface is presented
|
||||
******************************************************************************
|
||||
* Calls application to receive Line Coding Information
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Get_Line_Coding (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data to be send */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{
|
||||
uint_8 status;
|
||||
UNUSED (size);
|
||||
g_current_interface = (uint_8)setup_packet->index ;
|
||||
status = USB_Desc_Get_Line_Coding(controller_ID, g_current_interface,
|
||||
data);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Set_Line_Coding
|
||||
*
|
||||
* @brief This function is called in response to SetLineCoding request
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE : When request for invalid
|
||||
* Interface is presented
|
||||
******************************************************************************
|
||||
* Calls Applciation to update Line Coding Information
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Set_Line_Coding (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{
|
||||
uint_8 status;
|
||||
UNUSED(data);
|
||||
|
||||
*size = 0;
|
||||
|
||||
g_current_interface = (uint_8)setup_packet->index ;
|
||||
status = USB_Desc_Set_Line_Coding(controller_ID, g_current_interface,
|
||||
(uint_8_ptr *)&setup_packet);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Set_Ctrl_Line_State
|
||||
*
|
||||
* @brief This function is called in response to Set Control Line State
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : Always
|
||||
******************************************************************************
|
||||
* Updates Control Line State
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Set_Ctrl_Line_State (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{
|
||||
UNUSED(data);
|
||||
*size = 0;
|
||||
|
||||
g_dte_status = (uint_8)setup_packet->value ;
|
||||
g_uart_bitmap._byte = 0x00; /* initialize */
|
||||
/* activate/deactivate Tx carrier */
|
||||
g_uart_bitmap.Bitmap_Uart.bTxCarrier = (g_dte_status &
|
||||
CARRIER_ACTIVATION_CHECK) ? 1 : 0 ;
|
||||
/* activate carrier and DTE */
|
||||
g_uart_bitmap.Bitmap_Uart.bRxCarrier = (g_dte_status &
|
||||
CARRIER_ACTIVATION_CHECK) ? 1 : 0 ;
|
||||
|
||||
/* Indicates to DCE if DTE is present or not */
|
||||
g_dte_present = (boolean)((g_dte_status & DTE_PRESENCE_CHECK) ?
|
||||
TRUE : FALSE);
|
||||
UNUSED(g_dte_present);
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
/* Send Notification to Host - Parameter on Device side has changed */
|
||||
USB_Class_CDC_PSTN_Send_Serial_State(controller_ID);
|
||||
#endif
|
||||
if(g_pstn_callback != NULL)
|
||||
{
|
||||
if(g_dte_status & CARRIER_ACTIVATION_CHECK)
|
||||
{
|
||||
g_pstn_callback(controller_ID, USB_APP_CDC_CARRIER_ACTIVATED,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pstn_callback(controller_ID, USB_APP_CDC_CARRIER_DEACTIVATED,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Send_Break
|
||||
*
|
||||
* @brief This function is called in response to Set Config request
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : Always
|
||||
******************************************************************************
|
||||
* Updates Break Duration Information from Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Send_Break (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
UNUSED (data);
|
||||
*size = 0;
|
||||
|
||||
g_break_duration = setup_packet->value;
|
||||
UNUSED(g_break_duration);
|
||||
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Get_Comm_Feature
|
||||
*
|
||||
* @brief This function is called in response to GetCommFeature request
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data to be send
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE : When request for invalid
|
||||
* Interface is presented
|
||||
******************************************************************************
|
||||
* Returns the status of the get comm feature request
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Get_Comm_Feature (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data to send */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{ uint_8 status;
|
||||
|
||||
status = USB_OK;
|
||||
*size = COMM_FEATURE_DATA_SIZE;
|
||||
g_current_interface = (uint_8)setup_packet->index ;
|
||||
if(setup_packet->value == ABSTRACT_STATE_FEATURE)
|
||||
{
|
||||
status = USB_Desc_Get_Abstract_State(controller_ID,
|
||||
g_current_interface, data);
|
||||
}
|
||||
else if(setup_packet->value == COUNTRY_SETTING_FEATURE)
|
||||
{
|
||||
status = USB_Desc_Get_Country_Setting(controller_ID,
|
||||
g_current_interface, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
*size = 0; /* for Reserved/Invalid Feature Selector Value */
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Set_Comm_Feature
|
||||
*
|
||||
* @brief This function is called in response to SetCommFeature request
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE : When request for invalid
|
||||
* Interface is presented
|
||||
******************************************************************************
|
||||
* Sets the comm feature specified by Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Set_Comm_Feature (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{
|
||||
uint_8 status;
|
||||
status = USB_OK;
|
||||
*size = COMM_FEATURE_DATA_SIZE;
|
||||
g_current_interface = (uint_8)setup_packet->index ;
|
||||
if(setup_packet->value == ABSTRACT_STATE_FEATURE)
|
||||
{
|
||||
status = USB_Desc_Set_Abstract_State(controller_ID,
|
||||
g_current_interface, data);
|
||||
}
|
||||
else if(setup_packet->value == COUNTRY_SETTING_FEATURE)
|
||||
{
|
||||
status = USB_Desc_Set_Country_Setting(controller_ID,
|
||||
g_current_interface, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
*size = 0; /* for Reserved/Invalid Feature Selector Value */
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Send_Serial_State
|
||||
*
|
||||
* @brief This function is called to send serial state notification
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return NONE
|
||||
******************************************************************************
|
||||
* Returns the Serial State
|
||||
*****************************************************************************/
|
||||
void USB_Class_CDC_PSTN_Send_Serial_State (
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
/* update array for current interface */
|
||||
g_serial_state_buf[4] = g_current_interface;
|
||||
/* Lower byte of UART BITMAP */
|
||||
g_serial_state_buf[NOTIF_PACKET_SIZE+UART_BITMAP_SIZE-2] =
|
||||
g_uart_bitmap._byte;
|
||||
(void)USB_Class_CDC_Interface_CIC_Send_Data(controller_ID,
|
||||
g_serial_state_buf, (NOTIF_PACKET_SIZE + UART_BITMAP_SIZE));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_cdc_pstn.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB CDC_PSTN Sub Class API header function
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_CDC_PSTN_H
|
||||
#define _USB_CDC_PSTN_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "usb_cdc.h" /* USB CDC Class Header File */
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
#ifdef __MCF52xxx_H__
|
||||
#pragma reverse_bitfields on
|
||||
#endif
|
||||
typedef struct _BITMAP_UART
|
||||
{
|
||||
uint_8 bRxCarrier : 1; /* Receive Carrier Activation Flag */
|
||||
uint_8 bTxCarrier : 1; /* Transmit Carrier Activation Flag */
|
||||
uint_8 bBreak : 1; /* Break Flag */
|
||||
uint_8 bRingSignal : 1; /* Ring Signal Flag */
|
||||
uint_8 bFraming : 1; /* Frame Flag */
|
||||
uint_8 bParity : 1; /* Parity Flag */
|
||||
uint_8 bOverRun : 1; /* OverRun Flag */
|
||||
uint_8 reserved1 : 1; /* Reserved */
|
||||
}BITMAP_UART;
|
||||
#ifdef __MCF52xxx_H__
|
||||
#pragma reverse_bitfields off
|
||||
#endif
|
||||
|
||||
|
||||
typedef union _UART_BITMAP
|
||||
{
|
||||
uint_8 _byte;
|
||||
BITMAP_UART Bitmap_Uart;
|
||||
}UART_BITMAP; /* UART STATE BITMAP */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define UART_BITMAP_SIZE (0x02)
|
||||
#define ABSTRACT_STATE_FEATURE (0x01)
|
||||
#define COUNTRY_SETTING_FEATURE (0x02)
|
||||
#define CARRIER_ACTIVATION_CHECK (0x02)
|
||||
#define DTE_PRESENCE_CHECK (0x01)
|
||||
|
||||
extern uint_8 USB_Class_CDC_Pstn_Init (
|
||||
uint_8 controller_ID,
|
||||
USB_CLASS_CALLBACK callback
|
||||
);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Get_Line_Coding (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Set_Line_Coding (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Set_Ctrl_Line_State (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Send_Break (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Get_Comm_Feature (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Set_Comm_Feature (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
extern void USB_Class_CDC_PSTN_Send_Serial_State (uint_8 controller_ID);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,493 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_class.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief The file contains USB stack Class module implementation.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "usb_class.h" /* USB class Header File */
|
||||
#include "usb_devapi.h" /* USB device Header file */
|
||||
#include "usb_framework.h" /* USB framework module header file */
|
||||
#include "hidef.h" /* for EnableInterrupts; macro */
|
||||
|
||||
#if 0 /* << EST */
|
||||
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
|
||||
#include "exceptions.h"
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* Constant and Macro's
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
/* Class callback pointer */
|
||||
static USB_CLASS_CALLBACK g_class_callback = NULL;
|
||||
/* save the device state before device goes to suspend state */
|
||||
static uint_8 g_device_state_before_suspend;
|
||||
/*****************************************************************************
|
||||
* Local Types - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions Prototypes
|
||||
*****************************************************************************/
|
||||
void USB_Suspend_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
void USB_Resume_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
void USB_Stall_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
void USB_Sof_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
void USB_Reset_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
void USB_Error_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Variables
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
#if 0 /* << EST */
|
||||
#if (defined(_MC9S08MM128_H) || defined(_MC9S08JE128_H))
|
||||
#pragma CODE_SEG DEFAULT
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#endif
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Suspend_Service
|
||||
*
|
||||
* @brief The function is called when host suspends the USB port
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* Sets the device state as USB_STATE_SUSPEND
|
||||
*****************************************************************************/
|
||||
void USB_Suspend_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
/* Get the status of the device before suspend, so that on resume we
|
||||
can get back to the same state */
|
||||
(void)_usb_device_get_status(&(event->controller_ID),
|
||||
USB_STATUS_DEVICE_STATE, &g_device_state_before_suspend);
|
||||
/* Set the device state in the Device Layer to SUSPEND */
|
||||
(void)_usb_device_set_status(&(event->controller_ID), USB_STATUS_DEVICE_STATE,
|
||||
USB_STATE_SUSPEND);
|
||||
|
||||
/* let the application know that bus suspend has taken place */
|
||||
g_class_callback(event->controller_ID, USB_APP_BUS_SUSPEND, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Resume_Service
|
||||
*
|
||||
* @brief The function is called when host resumes the USB port
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* Restore the state of the device before suspend
|
||||
*****************************************************************************/
|
||||
void USB_Resume_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
uint_8 device_state;
|
||||
(void)_usb_device_get_status(&(event->controller_ID), USB_STATUS_DEVICE_STATE,
|
||||
&device_state);
|
||||
if(device_state == USB_STATE_SUSPEND)
|
||||
{
|
||||
/*
|
||||
Set the device state in the Device Layer to the state
|
||||
before suspend
|
||||
*/
|
||||
(void)_usb_device_set_status(&(event->controller_ID),
|
||||
USB_STATUS_DEVICE_STATE, g_device_state_before_suspend);
|
||||
}
|
||||
|
||||
/* let the application know that bus resume has taken place */
|
||||
g_class_callback(event->controller_ID, USB_APP_BUS_RESUME, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Stall_Service
|
||||
*
|
||||
* @brief The function is called when endpoint is stalled
|
||||
*
|
||||
* @param event: Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* This function sends STALL Packet for the endpoint to be stalled. Also, sets
|
||||
* the status of Endpoint as STALLED
|
||||
*****************************************************************************/
|
||||
void USB_Stall_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
if(event->ep_num == CONTROL_ENDPOINT)
|
||||
{
|
||||
/* Update the Endpoint Status in the Device Layer to Idle */
|
||||
(void)_usb_device_set_status(&(event->controller_ID),
|
||||
(uint_8)(USB_STATUS_ENDPOINT | CONTROL_ENDPOINT |
|
||||
(event->direction << USB_COMPONENT_DIRECTION_SHIFT)),
|
||||
(uint_16)USB_STATUS_IDLE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Sof_Service
|
||||
*
|
||||
* @brief The function is called when SOF flag is set (from ISR)
|
||||
*
|
||||
* @param event: Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* This function is called when SOF token is received by controller. Updates
|
||||
* SOF Count status.
|
||||
*****************************************************************************/
|
||||
void USB_Sof_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
uint_16 sof_count;
|
||||
|
||||
/* update SOF */
|
||||
sof_count = event->buffer_ptr[0];
|
||||
sof_count <<= SOF_HIGH_BYTE_SHIFT;
|
||||
sof_count |= event->buffer_ptr[1];
|
||||
|
||||
/* write SOF to status */
|
||||
(void)_usb_device_set_status(&(event->controller_ID), USB_STATUS_SOF_COUNT,
|
||||
(uint_8)sof_count);
|
||||
return;
|
||||
}
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Reset_Service
|
||||
*
|
||||
* @brief The function is called upon a bus reset event.
|
||||
Initializes the control endpoint.
|
||||
*
|
||||
* @param event: Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* Reset Callback function. This function re-initializes CONTROL Endpoint
|
||||
*****************************************************************************/
|
||||
void USB_Reset_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
|
||||
USB_EP_STRUCT ep_struct;
|
||||
uint_8 err;
|
||||
|
||||
/* Initialize the endpoint 0 in both directions */
|
||||
ep_struct.direction = USB_SEND;
|
||||
ep_struct.ep_num = CONTROL_ENDPOINT;
|
||||
ep_struct.size = CONTROL_MAX_PACKET_SIZE;
|
||||
ep_struct.type = USB_CONTROL_PIPE;
|
||||
|
||||
/* Deinit Endpoint in case its already initialized */
|
||||
err = _usb_device_deinit_endpoint(&(event->controller_ID),
|
||||
ep_struct.ep_num, ep_struct.direction);
|
||||
/* now initialize the endpoint */
|
||||
err = _usb_device_init_endpoint(&(event->controller_ID),
|
||||
ep_struct.ep_num, (uint_16)ep_struct.size, ep_struct.direction, ep_struct.type, TRUE);
|
||||
|
||||
ep_struct.direction = USB_RECV;
|
||||
/* Deinit Endpoint in case its already initialized */
|
||||
(void)_usb_device_deinit_endpoint(&(event->controller_ID),
|
||||
ep_struct.ep_num, ep_struct.direction);
|
||||
/* now initialize the endpoint */
|
||||
(void)_usb_device_init_endpoint(&(event->controller_ID),
|
||||
ep_struct.ep_num, (uint_16)ep_struct.size, ep_struct.direction, ep_struct.type, TRUE);
|
||||
|
||||
/* set the default device state */
|
||||
(void)_usb_device_set_status(&(event->controller_ID), USB_STATUS_DEVICE_STATE,
|
||||
USB_STATE_DEFAULT);
|
||||
|
||||
/* set the default device state */
|
||||
(void)_usb_device_set_status(&(event->controller_ID), USB_STATUS_DEVICE,
|
||||
SELF_POWERED >> SELF_POWER_BIT_SHIFT);
|
||||
|
||||
/* set the EndPoint Status as Idle in the device layer */
|
||||
(void)_usb_device_set_status(&(event->controller_ID),
|
||||
(uint_8)(USB_STATUS_ENDPOINT | CONTROL_ENDPOINT |
|
||||
(USB_SEND << USB_COMPONENT_DIRECTION_SHIFT)),
|
||||
USB_STATUS_IDLE);
|
||||
/* let the application know that bus reset has taken place */
|
||||
g_class_callback(event->controller_ID, USB_APP_BUS_RESET, NULL);
|
||||
|
||||
UNUSED(err);
|
||||
return;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Error_Service
|
||||
*
|
||||
* @brief The function is called when an error has been detected
|
||||
*
|
||||
* @param event: Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* Calls application with the error code received from the lower layer
|
||||
*****************************************************************************/
|
||||
void USB_Error_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
/* notify the application of the error */
|
||||
g_class_callback(event->controller_ID, USB_APP_ERROR,
|
||||
(uint_8*)(&(event->errors)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_Init
|
||||
*
|
||||
* @brief The function initializes the Class Module
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param class_callback : Class callback
|
||||
* @param other_req_callback : Other Requests Callback
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* Others : Errors
|
||||
******************************************************************************
|
||||
* Initializes USB Class Module
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_Init (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_CLASS_CALLBACK class_callback, /* [IN] Class Callback */
|
||||
USB_REQ_FUNC other_req_callback /* [IN] Other Requests Callback */
|
||||
)
|
||||
{
|
||||
uint_8 status = USB_Framework_Init(controller_ID,class_callback,
|
||||
other_req_callback);
|
||||
|
||||
/* save callback address */
|
||||
g_class_callback = class_callback;
|
||||
|
||||
if(status == USB_OK)
|
||||
{
|
||||
/* Register all the services here */
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_BUS_RESET, USB_Reset_Service);
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_SOF,USB_Sof_Service);
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_SLEEP,USB_Suspend_Service);
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_RESUME,USB_Resume_Service);
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_STALL,USB_Stall_Service);
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_ERROR,USB_Error_Service);
|
||||
|
||||
/* set the device state as powered */
|
||||
(void)_usb_device_set_status(&controller_ID,
|
||||
USB_STATUS_DEVICE_STATE,USB_STATE_POWERED);
|
||||
g_device_state_before_suspend = USB_STATE_POWERED;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_DeInit
|
||||
*
|
||||
* @brief The function De-initializes the Class Module
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* Others : Errors
|
||||
******************************************************************************
|
||||
* De-initializes USB Class Module
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_DeInit
|
||||
(
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
uint_8 status = USB_OK;
|
||||
/* Free class_callback */
|
||||
g_class_callback = NULL;
|
||||
|
||||
/* Unegister all the services here */
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_BUS_RESET);
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_SOF);
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_SLEEP);
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_RESUME);
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_STALL);
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_ERROR);
|
||||
|
||||
if(status == USB_OK)
|
||||
/* Call Framework deinit function */
|
||||
status = USB_Framework_DeInit(controller_ID);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_Initiate_Resume
|
||||
*
|
||||
* @brief The function initiates resume procedure
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return device_state
|
||||
******************************************************************************/
|
||||
uint_8 USB_Class_Initiate_Resume(
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
uint_8 device_state, state;
|
||||
|
||||
(void)_usb_device_get_status(&controller_ID, USB_STATUS_DEVICE_STATE,
|
||||
&device_state);
|
||||
(void)_usb_device_get_status(&controller_ID, USB_STATUS_DEVICE, &state);
|
||||
if((device_state == USB_STATE_SUSPEND) &&
|
||||
(state & REMOTE_WAKEUP_STATUS_MASK ) &&
|
||||
(USB_Frame_Remote_Wakeup(controller_ID) == TRUE))
|
||||
{
|
||||
DisableInterrupts;
|
||||
#if 0
|
||||
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
|
||||
usb_int_dis();
|
||||
#endif
|
||||
#else /* << EST */
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#endif
|
||||
/* Resume the bus */
|
||||
_usb_device_assert_resume(&controller_ID);
|
||||
|
||||
device_state = USB_STATE_CONFIG;
|
||||
/* Set the device state in the Device Layer to DEFAULT */
|
||||
(void)_usb_device_set_status(&controller_ID, USB_STATUS_DEVICE_STATE,
|
||||
USB_STATE_CONFIG);
|
||||
EnableInterrupts;;
|
||||
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
|
||||
usb_int_en();
|
||||
#endif
|
||||
}
|
||||
return device_state;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_Send_Data
|
||||
*
|
||||
* @brief The function calls the device to send data upon receiving an IN token
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param ep_num : Endpoint number
|
||||
* @param buff_ptr : Buffer to send
|
||||
* @param size : Length of transfer
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* Others : Errors
|
||||
******************************************************************************
|
||||
* Used by Application to send Data on USB Bus if not suspended
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_Send_Data (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 ep_num, /* [IN] Endpoint number */
|
||||
uint_8_ptr buff_ptr, /* [IN] Buffer to send */
|
||||
USB_PACKET_SIZE size /* [IN] Length of the transfer */
|
||||
)
|
||||
{
|
||||
|
||||
uint_8 status = USB_OK;
|
||||
uint_8 device_state;
|
||||
|
||||
device_state = USB_Class_Initiate_Resume(controller_ID);
|
||||
|
||||
if(device_state != USB_STATE_SUSPEND)
|
||||
{ /* if not suspended */
|
||||
status = _usb_device_send_data(&controller_ID, ep_num, buff_ptr, size);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_Periodic_Task
|
||||
*
|
||||
* @brief The function calls for periodic tasks
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* Called to check for any pending requests
|
||||
*****************************************************************************/
|
||||
void USB_Class_Periodic_Task (void)
|
||||
{
|
||||
#ifdef DELAYED_PROCESSING
|
||||
USB_Framework_Periodic_Task();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_class.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB stack class layer API header function.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_CLASS_H
|
||||
#define _USB_CLASS_H
|
||||
|
||||
|
||||
/*#define DELAYED_PROCESSING 1 This define is used to delay the control
|
||||
processing and not have it executed as part
|
||||
of the interrupt routine */
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "usb_devapi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define SOF_HIGH_BYTE_SHIFT (8)
|
||||
#define GET_STATUS_DEVICE_MASK (0x0003)
|
||||
#ifdef OTG_BUILD
|
||||
#define GET_STATUS_OTG_MASK (0x0001)
|
||||
#endif
|
||||
#define REMOTE_WAKEUP_STATUS_MASK (0x0002)
|
||||
#define BUS_POWERED (0x80)
|
||||
#define SELF_POWERED (0x40)
|
||||
#define SELF_POWER_BIT_SHIFT (6)
|
||||
|
||||
/* Events to the Application */
|
||||
#define USB_APP_BUS_RESET (0)
|
||||
#define USB_APP_CONFIG_CHANGED (1)
|
||||
#define USB_APP_ENUM_COMPLETE (2)
|
||||
#define USB_APP_SEND_COMPLETE (3)
|
||||
#define USB_APP_DATA_RECEIVED (4)
|
||||
#define USB_APP_ERROR (5)
|
||||
#define USB_APP_GET_DATA_BUFF (6)
|
||||
#define USB_APP_EP_STALLED (7)
|
||||
#define USB_APP_EP_UNSTALLED (8)
|
||||
#define USB_APP_GET_TRANSFER_SIZE (9)
|
||||
#define USB_APP_BUS_SUSPEND (0x0A)
|
||||
#define USB_APP_BUS_RESUME (0x0B)
|
||||
|
||||
/* max packet size for the control endpoint */
|
||||
|
||||
/* USB Specs define CONTROL_MAX_PACKET_SIZE for High Speed device as only 64,
|
||||
whereas for FS its allowed to be 8, 16, 32 or 64 */
|
||||
|
||||
#if HIGH_SPEED_DEVICE
|
||||
#define CONTROL_MAX_PACKET_SIZE (64) /* max supported value is 64*/
|
||||
#else
|
||||
#define CONTROL_MAX_PACKET_SIZE (16) /* max supported value is 16*/
|
||||
#endif
|
||||
|
||||
/* identification values and masks to identify request types */
|
||||
#define USB_REQUEST_CLASS_MASK (0x60)
|
||||
#define USB_REQUEST_CLASS_STRD (0x00)
|
||||
#define USB_REQUEST_CLASS_CLASS (0x20)
|
||||
#define USB_REQUEST_CLASS_VENDOR (0x40)
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
/* eight byte usb setup packet structure */
|
||||
typedef struct _USB_SETUP_STRUCT {
|
||||
uint_8 request_type; /* bmRequestType */
|
||||
uint_8 request; /* Request code */
|
||||
uint_16 value; /* wValue */
|
||||
uint_16 index; /* wIndex */
|
||||
uint_16 length; /* Length of the data */
|
||||
} USB_SETUP_STRUCT;
|
||||
|
||||
/* callback function pointer structure for Application to handle events */
|
||||
typedef void(_CODE_PTR_ USB_CLASS_CALLBACK)(uint_8, uint_8, void*);
|
||||
|
||||
/* callback function pointer structure to handle USB framework request */
|
||||
typedef uint_8 (_CODE_PTR_ USB_REQ_FUNC)(uint_8, USB_SETUP_STRUCT *,
|
||||
uint_8_ptr*,
|
||||
USB_PACKET_SIZE*);
|
||||
|
||||
/*callback function pointer structure for application to provide class params*/
|
||||
typedef uint_8 (_CODE_PTR_ USB_CLASS_SPECIFIC_HANDLER_FUNC)(
|
||||
uint_8,
|
||||
uint_16,
|
||||
uint_16, // Application needs to know which Interface is being communicated with
|
||||
uint_8_ptr*,
|
||||
USB_PACKET_SIZE*);
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 USB_Class_Init (
|
||||
uint_8 controller_ID,
|
||||
USB_CLASS_CALLBACK class_callback,
|
||||
USB_REQ_FUNC other_req_callback
|
||||
);
|
||||
|
||||
extern uint_8 USB_Class_DeInit
|
||||
(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern uint_8 USB_Class_Initiate_Resume(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern uint_8 USB_Class_Send_Data (
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8_ptr buff_ptr,
|
||||
USB_PACKET_SIZE size
|
||||
);
|
||||
|
||||
extern void USB_Class_Periodic_Task(void);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,311 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_dci_kinetis.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief The file contains Macro's and functions needed by the DCI layer.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_DCI_H
|
||||
#define _USB_DCI_H
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "hal/derivative.h"
|
||||
#include "usb_devapi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define BYTES_1024 (1024)
|
||||
#define BYTES_512 (512)
|
||||
#define ENDPT_EP_STALL_MASK (0x02)
|
||||
#define FRAME_HIGH_BYTE_SHIFT (8)
|
||||
|
||||
#ifdef USB_LOWPOWERMODE
|
||||
typedef enum _stopmode
|
||||
{
|
||||
STOP_MODE1 = 1, /* STOP MODE 1 */
|
||||
STOP_MODE2 = 2, /* STOP MODE 2 */
|
||||
STOP_MODE3 = 3, /* STOP MODE 3 */
|
||||
STOP_MODE4 = 4 /* STOP MODE 4 */
|
||||
}STOP_MODE;
|
||||
#endif
|
||||
|
||||
/* USBTRC0 Initialization Parameters */
|
||||
#define _USBPHYEN (0x01) /* Use internal transceiver */
|
||||
#define _USBPUEN (0x40) /* Use internal pull-up resistor */
|
||||
#define _USBREGEN (0x04) /* Use the internal regulator */
|
||||
#define _USBRESET (0x80)
|
||||
|
||||
#define UCFG_VAL (_USBPUEN|_USBREGEN)
|
||||
|
||||
#define CTL_RESET_VAL (0) /* value programmed to the CTL
|
||||
register in RESET */
|
||||
|
||||
#define EP_CTRL (0x0C) /* Cfg Control pipe for this endpoint */
|
||||
// HIGH_SPEED_DEVICE
|
||||
#if !HIGH_SPEED_DEVICE
|
||||
#define EP_OUT (0x08) /* Cfg OUT only pipe for this endpoint*/
|
||||
#define EP_IN (0x04) /* Cfg IN only pipe for this endpoint */
|
||||
#endif
|
||||
#define HSHK_EN (0x01) /* Enable handshake packet */
|
||||
/* Handshake should be disable for
|
||||
isochorous transfer */
|
||||
#define EP_CTL_DIS (0x10)
|
||||
|
||||
#define EP_DISABLE (0)
|
||||
|
||||
#define TRANSFER_INDEX(x) (x>>1)
|
||||
|
||||
#define MAX_EP_BUFFER_SIZE USB_MAX_EP_BUFFER_SIZE /*Max Endpoint Buffer Size*/
|
||||
|
||||
/* Macro's to check whether corresponding INT_STAT bit is set */
|
||||
#define BUS_RESET_FLAG(x) ((x) & 1)
|
||||
#define ERROR_FLAG(x) ((x) & 2)
|
||||
#define SOF_TOKEN_FLAG(x) ((x) & 4)
|
||||
#define SLEEP_FLAG(x) ((x) & 0x10)
|
||||
#define RESUME_FLAG(x) ((x) & 0x20)
|
||||
#define STALL_FLAG(x) ((x) & 0x80)
|
||||
#define TOKEN_COMPL_FLAG(x) ((x) & 8)
|
||||
|
||||
/* Setup the controller for Remote Wakeup */
|
||||
#define USB_DCI_WAKEUP \
|
||||
{ \
|
||||
USB0_ISTAT |= USB_ISTAT_RESUME_MASK; \
|
||||
USB0_INTEN &= ~USB_INTEN_RESUMEEN_MASK; \
|
||||
USB0_CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK; \
|
||||
}
|
||||
|
||||
/* control endpoint transfer types */
|
||||
#define USB_TRF_UNKNOWN (0xFF)
|
||||
|
||||
|
||||
#define BDT_MIN_BUFFER_SIZE (16) /* space occupied by smallest
|
||||
buffer in BDT */
|
||||
|
||||
#define BDT_MIN_BUFFER_ADDR_INC (4) /* min offset increment
|
||||
correspoding to min buffer
|
||||
size */
|
||||
|
||||
#define BDT_OFFSET_SHIFT (4) /* bdt offset shift */
|
||||
|
||||
#define INVALID_BDT_INDEX (0xFF)/* invalid bdt index */
|
||||
|
||||
#define ENDPOINT_NUMBER_SHIFT (4) /* endpoint shift & mask to */
|
||||
#define ENDPOINT_NUMBER_MASK (0xF0)/* use in setting and getting
|
||||
status */
|
||||
|
||||
#define ENDPOINT_DIRECTION_SHIFT (3) /* direction shift & mask to */
|
||||
#define ENDPOINT_DIRECTION_MASK (0x08)/* be used for STAT byte
|
||||
in BDT */
|
||||
|
||||
#define SEND_CONTROL_ENDPOINT_BDT_INDEX (2) /* BDT Index for Control Endpoint
|
||||
SEND direction */
|
||||
#define RECV_CONTROL_ENDPOINT_BDT_INDEX (0) /* BDT Index for Control Endpoint
|
||||
RECV direction */
|
||||
|
||||
#define EPCTL_STALL (0x02)/* Stall bit in Endpoint
|
||||
Control Reg */
|
||||
|
||||
#define USB_SETUP_TOKEN (0x0d)/* Setup Token PID */
|
||||
#define USB_SETUP_DIRECTION (0x80)/* Data xfer direction
|
||||
for Setup packet */
|
||||
|
||||
#define INT_STAT_CLEAR_ALL (0xBF)/* Value to clear
|
||||
all Interrupts */
|
||||
#define ERR_STAT_CLEAR_ALL (0xBF)/* Value to clear
|
||||
all Errors */
|
||||
#define ERR_ENB_ENABLE_ALL (0xBF)/* Value to enable
|
||||
all Error Interrupts */
|
||||
#define INTENB_BUS_RESET_VAL (0x9F)/* Value to enable
|
||||
Interrupts in Bus Reset */
|
||||
#define INTENB_DISABLE_ALL_VAL (0x00)/* Value to disable all
|
||||
Interrupts */
|
||||
|
||||
#define MAX_USB_RAM_BUFFER_INDEX (14) /* MAX possible RAM buffer
|
||||
Index */
|
||||
|
||||
#define EP_START_BUFFER_ADDR (0x08)/* First USB_RAM buffer offset*/
|
||||
|
||||
#define ASSERT_RESUME_DELAY_COUNT (20000)/* Delay for assert resume, 48MHz clock */
|
||||
|
||||
#define NO_ERRORS (0) /* Init value for error */
|
||||
|
||||
#define USB_RAM_EVEN_BUFFER (0)
|
||||
#define USB_RAM_ODD_BUFFER (1)
|
||||
|
||||
#define SWAP16(val) (val)
|
||||
|
||||
#define SWAP32(val) (val)
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
#ifdef LONG_SEND_TRANSACTION
|
||||
#define LONG_TRANSACTION
|
||||
#endif
|
||||
|
||||
#ifdef LONG_RECEIVE_TRANSACTION
|
||||
#define LONG_TRANSACTION
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
uint_8 Byte;
|
||||
struct {
|
||||
uint_8 EP_HSHK :1; /* When set this bet enables an endpoint to perform handshaking during a transaction to this endpoint. This bit will generally be set unless the endpoint is Isochronous */
|
||||
uint_8 EP_STALL :1; /* When set this bit indicates that the endpoint is stalled */
|
||||
uint_8 EP_TX_EN :1; /* This bit, when set, enables the endpoint for TX transfers */
|
||||
uint_8 EP_RX_EN :1; /* This bit, when set, enables the endpoint for RX transfers */
|
||||
uint_8 EP_CTRL_DIS :1; /* This bit, when set, disables control (SETUP) transfers. When cleared, control transfers are enabled. This applies if and only if the EP_RX_EN and EP_TX_EN bits are also set */
|
||||
uint_8 :1;
|
||||
uint_8 RETRY_DIS :1; /* This is a Host mode only bit and is only present in the control register for endpoint 0 (ENDPT0) */
|
||||
uint_8 HOST_WO_HUB :1; /* This is a Host mode only bit and is only present in the control register for endpoint 0 (ENDPT0) */
|
||||
} Bits;
|
||||
} ENDPT0STR;
|
||||
|
||||
/* << EST pushing current packing */
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
/* This structure is used to hold endpoint paramaetes and the
|
||||
transaction parameters on the IO's happening on them */
|
||||
typedef struct _BDT_ELEM
|
||||
{
|
||||
uint_16 len; /* endpoint max buffer len */
|
||||
uint_32 addr; /* endpoint buffer addr in USB_RAM */
|
||||
#ifdef LONG_TRANSACTION
|
||||
uint_8_ptr app_buffer; /* application buffer pointer */
|
||||
USB_PACKET_SIZE app_len; /* application buffer len */
|
||||
USB_PACKET_SIZE curr_offset; /* current offset for long transactions */
|
||||
#endif
|
||||
uint_8 flag; /* zero termination flag */
|
||||
uint_8 bdtmap_index; /* Corresponding to the buffer */
|
||||
uint_8 direction; /* Direction (Send/Receive) */
|
||||
uint_8 type; /* Type of Endpoint */
|
||||
} BDT_ELEM, *P_BDT_ELEM;
|
||||
#if defined(__CWCC__)
|
||||
#pragma options align = reset
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack()
|
||||
#else /* gcc */
|
||||
/* << EST restoring previous packing */
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
|
||||
uint_8 USB_DCI_DeInit(void);
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
//extern uint_8 USB_Device_Call_Service(
|
||||
// uint_8 type,
|
||||
// PTR_USB_DEV_EVENT_STRUCT event
|
||||
//);
|
||||
|
||||
#ifndef OTG_BUILD
|
||||
void USB_ISR(void);
|
||||
#endif
|
||||
|
||||
#if HIGH_SPEED_DEVICE
|
||||
/* Device Queue Head and Device Transfer Descriptor Related Defination */
|
||||
#define SIZE_OF_QHD 0x40
|
||||
#define SIZE_OF_DTD0 0x20
|
||||
#define SIZE_OF_DTD1 0x20
|
||||
#define dTD_SIZE_EPIN (SIZE_OF_DTD0 + SIZE_OF_DTD1) //0x40
|
||||
#define dTD_SIZE_EPOUT (SIZE_OF_DTD0 + SIZE_OF_DTD1) //0x40
|
||||
#define BUFFER_USED_PER_EP ((SIZE_OF_QHD + dTD_SIZE_EPIN) +(SIZE_OF_QHD + dTD_SIZE_EPOUT)) //0x100
|
||||
#define ZLT_ENABLE 0
|
||||
#define ZLT_DISABLE 1
|
||||
#define IOS_NOTSET 0
|
||||
#define IOS_SET 1
|
||||
#define IOC_NOTSET 0
|
||||
#define IOC_SET 1
|
||||
#define TERMINATE 1
|
||||
#define NOT_TERMINATE 0
|
||||
#define NO_STATUS 0
|
||||
#define ACTIVE 0x00000080
|
||||
#define EPOUT_COMPLETE 0x00000001
|
||||
#define EPIN_COMPLETE 0x00010000
|
||||
#define EPOUT_PRIME 0x00000001
|
||||
#define EPIN_PRIME 0x00010000
|
||||
#define EPOUT_ENABLE 0x00000080
|
||||
#define EPIN_ENABLE 0x00800000
|
||||
#define STALL_RX 0x00000001
|
||||
#define STALL_TX 0x00010000
|
||||
|
||||
/* Maximum packet size defination */
|
||||
#define MPS_8 8
|
||||
#define MPS_64 64
|
||||
|
||||
/* enum for endpoint numbers */
|
||||
enum {
|
||||
EP0,
|
||||
EP1,
|
||||
EP2,
|
||||
EP3,
|
||||
EP4,
|
||||
EP5
|
||||
};
|
||||
|
||||
enum {
|
||||
OUT,
|
||||
IN
|
||||
};
|
||||
|
||||
/* enum for data transfer type on endpoints */
|
||||
enum {
|
||||
CONTROL,
|
||||
ISOCHRONOUS,
|
||||
BULK,
|
||||
INTERRUPT
|
||||
};
|
||||
|
||||
/* Status of all transaction on USB */
|
||||
typedef enum {
|
||||
USB_SUCCESS,
|
||||
USB_FAILURE,
|
||||
USB_INVALID = -1 /* Always Keep this entry in last */
|
||||
} usb_status_t;
|
||||
|
||||
/* USB Device State which are handled by DCD */
|
||||
typedef enum {
|
||||
USB_DEV_DUMMY_STATE,
|
||||
USB_DEV_DEFAULT_STATE,
|
||||
USB_DEV_ADDRESSED_STATE,
|
||||
USB_DEV_CONFIGURED_STATE
|
||||
} usb_state_t;
|
||||
#endif // HIGH_SPEED_DEVICE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,262 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_dciapi.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date Jun-05-2009
|
||||
*
|
||||
* @brief The file contains DCI api function definetions .
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_DCIAPI_H
|
||||
#define _USB_DCIAPI_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "usb_devapi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define MAX_SUPPORTED_ENDPOINTS (USB_SERVICE_MAX_EP + 1)
|
||||
/* Maximum endpoints supported */
|
||||
#define MIN_SUPPORTED_ENDPOINTS (1) /* Minimum endpoints supported */
|
||||
#define DOUBLE_BUFFERED_ENPOINT_NUMBER (0) /* First double buffered endpoint */
|
||||
|
||||
#ifdef MCU_MK70F12
|
||||
#define NUM_USB_CONTROLLERS (2)
|
||||
#else
|
||||
#define NUM_USB_CONTROLLERS (1)
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
typedef enum USB_Controllers_t
|
||||
{
|
||||
MAX3353,
|
||||
ULPI
|
||||
}USB_Controllers_t;
|
||||
|
||||
#if HIGH_SPEED_DEVICE
|
||||
typedef struct dqh_setup_t {
|
||||
unsigned int dqh_word0;
|
||||
unsigned int dqh_word1;
|
||||
unsigned int dqh_word2;
|
||||
unsigned int dqh_word3;
|
||||
unsigned int dqh_word4;
|
||||
unsigned int dqh_word5;
|
||||
unsigned int dqh_word6;
|
||||
unsigned int dqh_word7;
|
||||
unsigned int dqh_word8;
|
||||
unsigned int dqh_word9;
|
||||
unsigned int dqh_word10;
|
||||
unsigned int dqh_word11;
|
||||
} dqh_setup_t;
|
||||
|
||||
typedef struct dtd_setup_t {
|
||||
unsigned int dtd_word0;
|
||||
unsigned int dtd_word1;
|
||||
unsigned int dtd_word2;
|
||||
unsigned int dtd_word3;
|
||||
unsigned int dtd_word4;
|
||||
unsigned int dtd_word5;
|
||||
unsigned int dtd_word6;
|
||||
unsigned int dtd_word7;
|
||||
} dtd_setup_t;
|
||||
|
||||
typedef struct dqh_t {
|
||||
unsigned int dqh_base;
|
||||
unsigned int next_link_ptr;
|
||||
unsigned int buffer_ptr0;
|
||||
unsigned int buffer_ptr1;
|
||||
unsigned int buffer_ptr2;
|
||||
unsigned int buffer_ptr3;
|
||||
unsigned int buffer_ptr4;
|
||||
unsigned short total_bytes;
|
||||
unsigned short mps;
|
||||
unsigned short current_offset;
|
||||
unsigned char zlt;
|
||||
unsigned char ios;
|
||||
unsigned char terminate;
|
||||
unsigned char ioc;
|
||||
unsigned char status;
|
||||
unsigned char mult;
|
||||
} dqh_t;
|
||||
|
||||
typedef struct dtd_t {
|
||||
unsigned int dtd_base;
|
||||
unsigned int next_link_ptr;
|
||||
unsigned int buffer_ptr0;
|
||||
unsigned int buffer_ptr1;
|
||||
unsigned int buffer_ptr2;
|
||||
unsigned int buffer_ptr3;
|
||||
unsigned int buffer_ptr4;
|
||||
unsigned short total_bytes;
|
||||
unsigned short current_offset;
|
||||
unsigned char terminate;
|
||||
unsigned char ioc;
|
||||
unsigned char status;
|
||||
} dtd_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int ep_dqh_base_addrs; /* Base Address of Queue Header */
|
||||
unsigned int ep_dtd_base_addrs; /* Base Address of Transfer Descriptor */
|
||||
unsigned int ep0_buffer_addrs; /* Buffer Addres for EP0 IN */
|
||||
unsigned int buffer1_address; /* Buffer1 address for bulk transfer */
|
||||
unsigned int buffer1_status; /* Status of Buffer1 */
|
||||
unsigned int buffer2_address; /* Buffer2 address for bulk transfer */
|
||||
unsigned int buffer2_status; /* Status of Buffer2 */
|
||||
} buffer_map_t;
|
||||
|
||||
/* USB standard device request*/
|
||||
typedef struct usb_standrd_device_request {
|
||||
unsigned char bmRequestType;
|
||||
unsigned char bRequest;
|
||||
unsigned short wValue;
|
||||
unsigned short wIndex;
|
||||
unsigned short wLength;
|
||||
} usb_standard_device_request_t;
|
||||
|
||||
#endif // HIGH_SPEED_DEVICE
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 USB_DCI_Init(
|
||||
uint_8 controller_ID,
|
||||
uint_8 bVregEn
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Init_EndPoint(
|
||||
uint_8 controller_ID,
|
||||
USB_EP_STRUCT_PTR ep_ptr,
|
||||
boolean flag
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Cancel_Transfer(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Deinit_EndPoint(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void USB_DCI_Stall_EndPoint(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void USB_DCI_Unstall_EndPoint(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void USB_DCI_Get_Setup_Data(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint8_ptr buff_ptr
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Get_Transfer_Status(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void USB_DCI_Clear_DATA0_Endpoint(
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Recv_Data(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint8_ptr buff_ptr,
|
||||
USB_PACKET_SIZE size
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Send_Data(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint8_ptr buff_ptr,
|
||||
USB_PACKET_SIZE size
|
||||
);
|
||||
|
||||
extern void USB_DCI_Set_Address(
|
||||
uint_8 controller_ID,
|
||||
uint_8 address
|
||||
);
|
||||
|
||||
extern void USB_DCI_Shutdown(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern void USB_DCI_Assert_Resume(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern void Clear_Mem(uint_8* start_addr,uint_32 count, uint_8 val);
|
||||
|
||||
#define USB_DCI_Cancel_Transfer _usb_device_cancel_transfer
|
||||
|
||||
#define USB_DCI_Recv_Data _usb_device_recv_data
|
||||
|
||||
#define USB_DCI_Send_Data _usb_device_send_data
|
||||
|
||||
#define USB_DCI_Shutdown _usb_device_shutdown
|
||||
|
||||
#define USB_DCI_Stall_EndPoint _usb_device_stall_endpoint
|
||||
|
||||
#define USB_DCI_Unstall_EndPoint _usb_device_unstall_endpoint
|
||||
|
||||
#define USB_DCI_Get_Transfer_Status _usb_device_get_transfer_status
|
||||
|
||||
#define USB_DCI_Clear_DATA0_Endpoint _usb_device_clear_data0_endpoint
|
||||
|
||||
#define USB_DCI_Get_Setup_Data _usb_device_read_setup_data
|
||||
|
||||
#define USB_DCI_Set_Address _usb_device_set_address
|
||||
|
||||
#define USB_DCI_Assert_Resume _usb_device_assert_resume
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,889 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_descriptor.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief This file contains USB descriptors for Virtual COM Loopback
|
||||
* Application
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "hal/derivative.h"
|
||||
#include "types.h"
|
||||
#include "usb_class.h"
|
||||
#include "usb_descriptor.h"
|
||||
|
||||
#if (defined __MCF52xxx_H__)||(defined __MK_xxx_H__)
|
||||
/* Put CFV2 descriptors in RAM */
|
||||
#define USB_DESC_CONST
|
||||
#else
|
||||
#define USB_DESC_CONST const
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Constant and Macro's
|
||||
*****************************************************************************/
|
||||
/* structure containing details of all the endpoints used by this device */
|
||||
USB_DESC_CONST USB_ENDPOINTS usb_desc_ep =
|
||||
{
|
||||
CDC_DESC_ENDPOINT_COUNT,
|
||||
{
|
||||
#if DATA_CLASS_SUPPORT
|
||||
#if DIC_ISOCHRONOUS_SETTING
|
||||
{
|
||||
DIC_ISO_IN_ENDPOINT,
|
||||
USB_ISOCHRONOUS_PIPE,
|
||||
USB_SEND,
|
||||
DIC_ISO_IN_ENDP_PACKET_SIZE
|
||||
},
|
||||
{
|
||||
DIC_ISO_OUT_ENDPOINT,
|
||||
USB_ISOCHRONOUS_PIPE,
|
||||
USB_RECV,
|
||||
DIC_ISO_OUT_ENDP_PACKET_SIZE
|
||||
}
|
||||
#else
|
||||
{
|
||||
DIC_BULK_IN_ENDPOINT,
|
||||
USB_BULK_PIPE,
|
||||
USB_SEND,
|
||||
DIC_BULK_IN_ENDP_PACKET_SIZE
|
||||
},
|
||||
{
|
||||
DIC_BULK_OUT_ENDPOINT,
|
||||
USB_BULK_PIPE,
|
||||
USB_RECV,
|
||||
DIC_BULK_OUT_ENDP_PACKET_SIZE
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
,
|
||||
{
|
||||
CIC_NOTIF_ENDPOINT,
|
||||
USB_INTERRUPT_PIPE,
|
||||
USB_SEND,
|
||||
CIC_NOTIF_ENDP_PACKET_SIZE
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
uint_8 USB_DESC_CONST g_device_descriptor[DEVICE_DESCRIPTOR_SIZE] =
|
||||
{
|
||||
DEVICE_DESCRIPTOR_SIZE, /* Device Descriptor Size */
|
||||
USB_DEVICE_DESCRIPTOR, /* Device Type of descriptor */
|
||||
0x00, 0x02, /* BCD USB version */
|
||||
0x02, /* Device Class is indicated in
|
||||
the interface descriptors */
|
||||
0x00, /* Device Subclass is indicated
|
||||
in the interface descriptors */
|
||||
0x00, /* Device Protocol */
|
||||
CONTROL_MAX_PACKET_SIZE, /* Max Packet size */
|
||||
(0x2A3C&0xFF),((0x2A3C>>8)&0xFF), /* Vendor ID "Trinamic" */
|
||||
(0x0700&0xFF),((0x0700>>8)&0xFF), /* "TRINAMIC Evaluation Device" */
|
||||
0x02,0x00, /* BCD Device version */
|
||||
0x01, /* Manufacturer string index */
|
||||
0x02, /* Product string index */
|
||||
0x00, /* Serial number string index */
|
||||
0x01 /* Number of configurations */
|
||||
};
|
||||
|
||||
uint_8 USB_DESC_CONST g_config_descriptor[CONFIG_DESC_SIZE] =
|
||||
{
|
||||
CONFIG_ONLY_DESC_SIZE, /* Configuration Descriptor Size */
|
||||
USB_CONFIG_DESCRIPTOR, /* "Configuration" type of descriptor */
|
||||
CONFIG_DESC_SIZE, 0x00, /* Total length of the Configuration descriptor */
|
||||
(uint_8)(1+DATA_CLASS_SUPPORT),/*NumInterfaces*/
|
||||
0x01, /* Configuration Value */
|
||||
0x00, /* Configuration Description String Index*/
|
||||
BUS_POWERED|SELF_POWERED|(REMOTE_WAKEUP_SUPPORT<<REMOTE_WAKEUP_SHIFT),
|
||||
/* Attributes.support RemoteWakeup and self power*/
|
||||
0x32, /* Current draw from bus -- 100mA*/
|
||||
|
||||
/* CIC INTERFACE DESCRIPTOR */
|
||||
IFACE_ONLY_DESC_SIZE,
|
||||
USB_IFACE_DESCRIPTOR,
|
||||
0x00, /* bInterfaceNumber */
|
||||
0x00, /* bAlternateSetting */
|
||||
CIC_ENDP_COUNT, /* management and notification(optional)element present */
|
||||
0x02, /* Communication Interface Class */
|
||||
CIC_SUBCLASS_CODE,
|
||||
CIC_PROTOCOL_CODE,
|
||||
0x00, /* Interface Description String Index*/
|
||||
|
||||
/* CDC Class-Specific descriptor */
|
||||
0x05, /* size of Functional Desc in bytes */
|
||||
USB_CS_INTERFACE, /* descriptor type*/
|
||||
HEADER_FUNC_DESC,
|
||||
0x10, 0x01, /* USB Class Definitions for CDC spec release number in BCD */
|
||||
|
||||
0x05, /* Size of this descriptor */
|
||||
USB_CS_INTERFACE, /* descriptor type*/
|
||||
CALL_MANAGEMENT_FUNC_DESC,
|
||||
0x01,/*may use 0x03 */ /* device handales call management itself(D0 set)
|
||||
and will process commands multiplexed over the data interface */
|
||||
0x01, /* Indicates multiplexed commands are
|
||||
handled via data interface */
|
||||
|
||||
0x04, /* Size of this descriptor */
|
||||
USB_CS_INTERFACE, /* descriptor type*/
|
||||
ABSTRACT_CONTROL_FUNC_DESC,
|
||||
0x06, /*may use 0x0F */ /* Device Supports all commands for ACM - CDC
|
||||
PSTN SubClass bmCapabilities */
|
||||
|
||||
0x05, /* size of Functional Desc in bytes */
|
||||
USB_CS_INTERFACE, /* descriptor type*/
|
||||
UNION_FUNC_DESC,
|
||||
0x00, /* Interface Number of Control */
|
||||
0x01 /* Interface Number of Subordinate (Data Class) Interface */
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT /*Endpoint descriptor */
|
||||
, /* Comma Added if NOTIF ELEM IS TO BE ADDED */
|
||||
ENDP_ONLY_DESC_SIZE,
|
||||
USB_ENDPOINT_DESCRIPTOR,
|
||||
CIC_NOTIF_ENDPOINT|(USB_SEND << 7),
|
||||
USB_INTERRUPT_PIPE,
|
||||
CIC_NOTIF_ENDP_PACKET_SIZE, 0x00,
|
||||
0x0A
|
||||
#endif
|
||||
|
||||
#if DATA_CLASS_SUPPORT
|
||||
, /* Comma Added if DATA_CLASS_DESC IS TO BE ADDED */
|
||||
IFACE_ONLY_DESC_SIZE,
|
||||
USB_IFACE_DESCRIPTOR,
|
||||
(uint_8)(0x00+DATA_CLASS_SUPPORT), /* bInterfaceNumber */
|
||||
0x00, /* bAlternateSetting */
|
||||
DIC_ENDP_COUNT, /* notification element included */
|
||||
0x0A, /* DATA Interface Class */
|
||||
0x00, /* Data Interface SubClass Code */
|
||||
DIC_PROTOCOL_CODE,
|
||||
0x00, /* Interface Description String Index*/
|
||||
|
||||
#if ! DIC_ISOCHRONOUS_SETTING
|
||||
/*Endpoint descriptor */
|
||||
ENDP_ONLY_DESC_SIZE,
|
||||
USB_ENDPOINT_DESCRIPTOR,
|
||||
DIC_BULK_IN_ENDPOINT|(USB_SEND << 7),
|
||||
USB_BULK_PIPE,
|
||||
DIC_BULK_IN_ENDP_PACKET_SIZE, 0x00,
|
||||
0x00,/* This value is ignored for Bulk ENDPOINT */
|
||||
|
||||
/*Endpoint descriptor */
|
||||
ENDP_ONLY_DESC_SIZE,
|
||||
USB_ENDPOINT_DESCRIPTOR,
|
||||
DIC_BULK_OUT_ENDPOINT|(USB_RECV << 7),
|
||||
USB_BULK_PIPE,
|
||||
DIC_BULK_OUT_ENDP_PACKET_SIZE, 0x00,
|
||||
0x00 /* This value is ignored for Bulk ENDPOINT */
|
||||
#else
|
||||
/*Endpoint descriptor */
|
||||
ENDP_ONLY_DESC_SIZE,
|
||||
USB_ENDPOINT_DESCRIPTOR,
|
||||
DIC_ISO_IN_ENDPOINT|(USB_SEND << 7),
|
||||
USB_ISOCHRONOUS_PIPE,
|
||||
DIC_ISO_IN_ENDP_PACKET_SIZE, 0x00,
|
||||
0x01,/* This value is for Iso ENDPOINT */
|
||||
|
||||
/*Endpoint descriptor */
|
||||
ENDP_ONLY_DESC_SIZE,
|
||||
USB_ENDPOINT_DESCRIPTOR,
|
||||
DIC_ISO_OUT_ENDPOINT|(USB_RECV << 7),
|
||||
USB_ISOCHRONOUS_PIPE,
|
||||
DIC_ISO_OUT_ENDP_PACKET_SIZE, 0x00,
|
||||
0x01 /* This value is for Iso ENDPOINT */
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
uint_8 USB_DESC_CONST USB_STR_0[USB_STR_0_SIZE+USB_STR_DESC_SIZE] =
|
||||
{sizeof(USB_STR_0),
|
||||
USB_STRING_DESCRIPTOR,
|
||||
0x09,
|
||||
0x04/*equiavlent to 0x0409*/
|
||||
};
|
||||
|
||||
uint_8 USB_DESC_CONST USB_STR_1[USB_STR_1_SIZE+USB_STR_DESC_SIZE]
|
||||
= { sizeof(USB_STR_1),
|
||||
USB_STRING_DESCRIPTOR,
|
||||
|
||||
'T',0,
|
||||
'R',0,
|
||||
'I',0,
|
||||
'N',0,
|
||||
'A',0,
|
||||
'M',0,
|
||||
'I',0,
|
||||
'C',0,
|
||||
' ',0,
|
||||
'M',0,
|
||||
'o',0,
|
||||
't',0,
|
||||
'i',0,
|
||||
'o',0,
|
||||
'n',0,
|
||||
' ',0,
|
||||
'C',0,
|
||||
'o',0,
|
||||
'n',0,
|
||||
't',0,
|
||||
'r',0,
|
||||
'o',0,
|
||||
'l',0,
|
||||
' ',0,
|
||||
' ',0,
|
||||
' ',0,
|
||||
' ',0,
|
||||
' ',0
|
||||
};
|
||||
|
||||
|
||||
uint_8 USB_DESC_CONST USB_STR_2[USB_STR_2_SIZE+USB_STR_DESC_SIZE]
|
||||
= { sizeof(USB_STR_2),
|
||||
USB_STRING_DESCRIPTOR,
|
||||
|
||||
'E',0,
|
||||
'v',0,
|
||||
'a',0,
|
||||
'l',0,
|
||||
'u',0,
|
||||
'a',0,
|
||||
't',0,
|
||||
'i',0,
|
||||
'o',0,
|
||||
'n',0,
|
||||
' ',0,
|
||||
'D',0,
|
||||
'e',0,
|
||||
'v',0,
|
||||
'i',0,
|
||||
'c',0,
|
||||
'e',0,
|
||||
' ',0
|
||||
};
|
||||
|
||||
uint_8 USB_DESC_CONST USB_STR_n[USB_STR_n_SIZE+USB_STR_DESC_SIZE]
|
||||
= { sizeof(USB_STR_n),
|
||||
USB_STRING_DESCRIPTOR,
|
||||
'B',0,
|
||||
'A',0,
|
||||
'D',0,
|
||||
' ',0,
|
||||
'S',0,
|
||||
'T',0,
|
||||
'R',0,
|
||||
'I',0,
|
||||
'N',0,
|
||||
'G',0,
|
||||
' ',0,
|
||||
'I',0,
|
||||
'N',0,
|
||||
'D',0,
|
||||
'E',0,
|
||||
'X',0
|
||||
};
|
||||
|
||||
|
||||
USB_PACKET_SIZE const g_std_desc_size[USB_MAX_STD_DESCRIPTORS+1] =
|
||||
{0,
|
||||
DEVICE_DESCRIPTOR_SIZE,
|
||||
CONFIG_DESC_SIZE,
|
||||
0, /* string */
|
||||
0, /* Interface */
|
||||
0, /* Endpoint */
|
||||
0, /* Device Qualifier */
|
||||
0 /* other speed config */
|
||||
};
|
||||
|
||||
uint_8_ptr const g_std_descriptors[USB_MAX_STD_DESCRIPTORS+1] =
|
||||
{
|
||||
NULL,
|
||||
(uint_8_ptr)g_device_descriptor,
|
||||
(uint_8_ptr)g_config_descriptor,
|
||||
NULL, /* string */
|
||||
NULL, /* Interface */
|
||||
NULL, /* Endpoint */
|
||||
NULL, /* Device Qualifier */
|
||||
NULL /* other speed config*/
|
||||
};
|
||||
|
||||
uint_8 const g_string_desc_size[USB_MAX_STRING_DESCRIPTORS+1] =
|
||||
{
|
||||
sizeof(USB_STR_0),
|
||||
sizeof(USB_STR_1),
|
||||
sizeof(USB_STR_2),
|
||||
sizeof(USB_STR_n)
|
||||
};
|
||||
|
||||
uint_8_ptr const g_string_descriptors[USB_MAX_STRING_DESCRIPTORS+1] =
|
||||
{
|
||||
(uint_8_ptr)USB_STR_0,
|
||||
(uint_8_ptr)USB_STR_1,
|
||||
(uint_8_ptr)USB_STR_2,
|
||||
(uint_8_ptr)USB_STR_n
|
||||
};
|
||||
|
||||
#ifdef __HC08__ /* << EST */
|
||||
#pragma MESSAGE DISABLE C4800 /* implicit cast in assignment */
|
||||
#endif
|
||||
USB_ALL_LANGUAGES g_languages = { USB_STR_0, sizeof(USB_STR_0),
|
||||
{
|
||||
{
|
||||
(uint_16)0x0409,
|
||||
(const uint_8 **) (unsigned long) g_string_descriptors, // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
g_string_desc_size
|
||||
}
|
||||
}
|
||||
};
|
||||
#ifdef __HC08__ /* << EST */
|
||||
#pragma MESSAGE DEFAULT C4800
|
||||
#endif
|
||||
|
||||
uint_8 const g_valid_config_values[USB_MAX_CONFIG_SUPPORTED+1]={0,1};
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
#ifdef _MC9S08JS16_H
|
||||
#pragma DATA_SEG APP_DATA
|
||||
#endif
|
||||
|
||||
static uint_8 g_line_coding[USB_MAX_SUPPORTED_INTERFACES][LINE_CODING_SIZE] =
|
||||
{
|
||||
{ (LINE_CODE_DTERATE_IFACE0>> 0) & 0x000000FF,
|
||||
(LINE_CODE_DTERATE_IFACE0>> 8) & 0x000000FF,
|
||||
(LINE_CODE_DTERATE_IFACE0>>16) & 0x000000FF,
|
||||
(LINE_CODE_DTERATE_IFACE0>>24) & 0x000000FF,
|
||||
/*e.g. 0x00,0xC2,0x01,0x00 : 0x0001C200 is 115200 bits per second */
|
||||
LINE_CODE_CHARFORMAT_IFACE0,
|
||||
LINE_CODE_PARITYTYPE_IFACE0,
|
||||
LINE_CODE_DATABITS_IFACE0
|
||||
}
|
||||
};
|
||||
|
||||
static uint_8 g_abstract_state[USB_MAX_SUPPORTED_INTERFACES][COMM_FEATURE_DATA_SIZE] =
|
||||
{
|
||||
{ (STATUS_ABSTRACT_STATE_IFACE0>>0) & 0x00FF,
|
||||
(STATUS_ABSTRACT_STATE_IFACE0>>8) & 0x00FF
|
||||
}
|
||||
};
|
||||
|
||||
static uint_8 g_country_code[USB_MAX_SUPPORTED_INTERFACES][COMM_FEATURE_DATA_SIZE] =
|
||||
{
|
||||
{ (COUNTRY_SETTING_IFACE0>>0) & 0x00FF,
|
||||
(COUNTRY_SETTING_IFACE0>>8) & 0x00FF
|
||||
}
|
||||
};
|
||||
|
||||
static uint_8 g_alternate_interface[USB_MAX_SUPPORTED_INTERFACES];
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Types - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions Prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Variables - None
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Descriptor
|
||||
*
|
||||
* @brief The function returns the correponding descriptor
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param type : type of descriptor requested
|
||||
* @param sub_type : string index for string descriptor
|
||||
* @param index : string descriptor language Id
|
||||
* @param descriptor : output descriptor pointer
|
||||
* @param size : size of descriptor returned
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* This function is used to pass the pointer to the requested descriptor
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Get_Descriptor (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 type, /* [IN] type of descriptor requested */
|
||||
uint_8 str_num, /* [IN] string index for string descriptor */
|
||||
uint_16 index, /* [IN] string descriptor language Id */
|
||||
uint_8_ptr *descriptor, /* [OUT] output descriptor pointer */
|
||||
USB_PACKET_SIZE *size /* [OUT] size of descriptor returned */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* string descriptors are handled saperately */
|
||||
if(type == USB_STRING_DESCRIPTOR)
|
||||
{
|
||||
if(index == 0)
|
||||
{
|
||||
/* return the string and size of all languages */
|
||||
*descriptor = (uint_8_ptr) (unsigned long) g_languages.languages_supported_string; // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
*size = g_languages.languages_supported_size;
|
||||
} else
|
||||
{
|
||||
uint_8 lang_id=0;
|
||||
uint_8 lang_index=USB_MAX_LANGUAGES_SUPPORTED;
|
||||
|
||||
for(;lang_id< USB_MAX_LANGUAGES_SUPPORTED;lang_id++)
|
||||
{
|
||||
/* check whether we have a string for this language */
|
||||
if(index == g_languages.usb_language[lang_id].language_id)
|
||||
{ /* check for max descriptors */
|
||||
if(str_num < USB_MAX_STRING_DESCRIPTORS)
|
||||
{ /* setup index for the string to be returned */
|
||||
lang_index=str_num;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* set return val for descriptor and size */
|
||||
*descriptor = (uint_8_ptr) (unsigned long) g_languages.usb_language[lang_id]. // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
lang_desc[lang_index];
|
||||
*size = g_languages.usb_language[lang_id].
|
||||
lang_desc_size[lang_index];
|
||||
}
|
||||
|
||||
}
|
||||
else if(type < USB_MAX_STD_DESCRIPTORS+1)
|
||||
{
|
||||
/* Set return val for descriptor and size */
|
||||
*descriptor = (uint_8_ptr) (unsigned long) g_std_descriptors [type]; // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
|
||||
/* if there is no descriptor then return error */
|
||||
if(*descriptor == NULL)
|
||||
{
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
*size = g_std_desc_size[type];
|
||||
}
|
||||
else /* invalid descriptor */
|
||||
{
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Interface
|
||||
*
|
||||
* @brief The function returns the alternate interface
|
||||
*
|
||||
* @param controller_ID : Controller Id
|
||||
* @param interface : Interface number
|
||||
* @param alt_interface : Output alternate interface
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* This function is called by the framework module to get the current interface
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Get_Interface (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] interface number */
|
||||
uint_8_ptr alt_interface /* [OUT] output alternate interface */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* get alternate interface*/
|
||||
*alt_interface = g_alternate_interface[interface];
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Set_Interface
|
||||
*
|
||||
* @brief The function sets the alternate interface
|
||||
*
|
||||
* @param controller_ID : Controller Id
|
||||
* @param interface : Interface number
|
||||
* @param alt_interface : Input alternate interface
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* This function is called by the framework module to set the interface
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Set_Interface (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] interface number */
|
||||
uint_8 alt_interface /* [IN] input alternate interface */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* set alternate interface*/
|
||||
g_alternate_interface[interface]=alt_interface;
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Valid_Configation
|
||||
*
|
||||
* @brief The function checks whether the configuration parameter
|
||||
* input is valid or not
|
||||
*
|
||||
* @param controller_ID : Controller Id
|
||||
* @param config_val : Configuration value
|
||||
*
|
||||
* @return TRUE When Valid
|
||||
* FALSE When Error
|
||||
*****************************************************************************
|
||||
* This function checks whether the configuration is valid or not
|
||||
*****************************************************************************/
|
||||
boolean USB_Desc_Valid_Configation (
|
||||
uint_8 controller_ID,/*[IN] Controller ID */
|
||||
uint_16 config_val /*[IN] configuration value */
|
||||
)
|
||||
{
|
||||
uint_8 loop_index=0;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* check with only supported val right now */
|
||||
while(loop_index < (USB_MAX_CONFIG_SUPPORTED+1))
|
||||
{
|
||||
if(config_val == g_valid_config_values[loop_index])
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
loop_index++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Valid_Interface
|
||||
*
|
||||
* @brief The function checks whether the interface parameter
|
||||
* input is valid or not
|
||||
*
|
||||
* @param controller_ID : Controller Id
|
||||
* @param interface : Target interface
|
||||
*
|
||||
* @return TRUE When Valid
|
||||
* FALSE When Error
|
||||
*****************************************************************************
|
||||
* This function checks whether the interface is valid or not
|
||||
*****************************************************************************/
|
||||
boolean USB_Desc_Valid_Interface (
|
||||
uint_8 controller_ID, /*[IN] Controller ID */
|
||||
uint_8 interface /*[IN] target interface */
|
||||
)
|
||||
{
|
||||
uint_8 loop_index=0;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* check with only supported val right now */
|
||||
while(loop_index < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
if(interface == g_alternate_interface[loop_index])
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
loop_index++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Remote_Wakeup
|
||||
*
|
||||
* @brief The function checks whether the remote wakeup is supported or not
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return REMOTE_WAKEUP_SUPPORT (TRUE) - if remote wakeup supported
|
||||
*****************************************************************************
|
||||
* This function returns remote wakeup is supported or not
|
||||
*****************************************************************************/
|
||||
boolean USB_Desc_Remote_Wakeup (
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
return REMOTE_WAKEUP_SUPPORT;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Endpoints
|
||||
*
|
||||
* @brief The function returns with the list of all non control endpoints used
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return pointer to USB_ENDPOINTS
|
||||
*****************************************************************************
|
||||
* This function returns the information about all the non control endpoints
|
||||
* implemented
|
||||
*****************************************************************************/
|
||||
void* USB_Desc_Get_Endpoints (
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
return (void*) (unsigned long) &usb_desc_ep; // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Line_Coding
|
||||
*
|
||||
* @brief The function returns the Line Coding/Configuraion
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param coding_data : Output line coding data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Returns current Line Coding Parameters
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Get_Line_Coding (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *coding_data /* [OUT] Line Coding Data */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* get line coding data*/
|
||||
*coding_data = g_line_coding[interface];
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Set_Line_Coding
|
||||
*
|
||||
* @brief The function sets the Line Coding/Configuraion
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param coding_data : Output line coding data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Sets Line Coding Structure with the HOST specified values
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Set_Line_Coding (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *coding_data /* [IN] Line Coding Data */
|
||||
)
|
||||
{
|
||||
uint_8 count;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* set line coding data*/
|
||||
for(count = 0; count < LINE_CODING_SIZE; count++)
|
||||
{
|
||||
g_line_coding[interface][count] = *((*coding_data +
|
||||
USB_SETUP_PKT_SIZE) + count);
|
||||
}
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Abstract_State
|
||||
*
|
||||
* @brief The function gets the current setting for communication feature
|
||||
* (ABSTRACT_STATE)
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param feature_data : Output comm feature data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Returns ABSTRACT STATE Communication Feature to the Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Get_Abstract_State (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *feature_data /* [OUT] Output Comm Feature Data */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* get line coding data*/
|
||||
*feature_data = g_abstract_state[interface];
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Country_Setting
|
||||
*
|
||||
* @brief The function gets the current setting for communication feature
|
||||
* (COUNTRY_CODE)
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param feature_data : Output comm feature data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Returns the country Code to the Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Get_Country_Setting (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *feature_data /* [OUT] Output Comm Feature Data */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* get line coding data*/
|
||||
*feature_data = g_country_code[interface];
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Set_Abstract_State
|
||||
*
|
||||
* @brief The function gets the current setting for communication feature
|
||||
* (ABSTRACT_STATE)
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param feature_data : Output comm feature data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Sets the ABSTRACT State specified by the Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Set_Abstract_State (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *feature_data /* [OUT] Output Comm Feature Data */
|
||||
)
|
||||
{
|
||||
uint_8 count;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* set Abstract State Feature*/
|
||||
for(count = 0; count < COMM_FEATURE_DATA_SIZE; count++)
|
||||
{
|
||||
g_abstract_state[interface][count] = *(*feature_data + count);
|
||||
}
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Set_Country_Setting
|
||||
*
|
||||
* @brief The function gets the current setting for communication feature
|
||||
* (COUNTRY_CODE)
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param feature_data : Output comm feature data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Sets the country code specified by the HOST
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Set_Country_Setting(
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *feature_data /* [OUT] Output Comm Feature Data */
|
||||
)
|
||||
{
|
||||
uint_8 count;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
for(count = 0; count < COMM_FEATURE_DATA_SIZE; count++)
|
||||
{
|
||||
g_country_code[interface][count] = *(*feature_data + count);
|
||||
}
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_descriptor.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file is a header file for USB Descriptors required for Virtual
|
||||
* COM Loopback Application
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_DESCRIPTOR_H
|
||||
#define _USB_DESCRIPTOR_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "usb_class.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define REMOTE_WAKEUP_SUPPORT (FALSE)
|
||||
#define DATA_CLASS_SUPPORT (TRUE)
|
||||
#define CIC_NOTIF_ELEM_SUPPORT (TRUE) /* Mandatory */
|
||||
#define DIC_ISOCHRONOUS_SETTING (FALSE)
|
||||
|
||||
#define IMPLEMENT_QUEUING (TRUE)
|
||||
|
||||
/* Communication Class SubClass Codes */
|
||||
#define DIRECT_LINE_CONTROL_MODEL (0x01)
|
||||
#define ABSTRACT_CONTROL_MODEL (0x02)
|
||||
#define TELEPHONE_CONTROL_MODEL (0x03)
|
||||
#define MULTI_CHANNEL_CONTROL_MODEL (0x04)
|
||||
#define CAPI_CONTROL_MOPDEL (0x05)
|
||||
#define ETHERNET_NETWORKING_CONTROL_MODEL (0x06)
|
||||
#define ATM_NETWORKING_CONTROL_MODEL (0x07)
|
||||
#define WIRELESS_HANDSET_CONTROL_MODEL (0x08)
|
||||
#define DEVICE_MANAGEMENT (0x09)
|
||||
#define MOBILE_DIRECT_LINE_MODEL (0x0A)
|
||||
#define OBEX (0x0B)
|
||||
#define ETHERNET_EMULATION_MODEL (0x0C)
|
||||
|
||||
/* Communication Class Protocol Codes */
|
||||
#define NO_CLASS_SPECIFIC_PROTOCOL (0x00)
|
||||
#define AT_250_PROTOCOL (0x01)
|
||||
#define AT_PCCA_101_PROTOCOL (0x02)
|
||||
#define AT_PCCA_101_ANNEX_O (0x03)
|
||||
#define AT_GSM_7_07 (0x04)
|
||||
#define AT_3GPP_27_007 (0x05)
|
||||
#define AT_TIA_CDMA (0x06)
|
||||
#define ETHERNET_EMULATION_PROTOCOL (0x07)
|
||||
#define EXTERNAL_PROTOCOL (0xFE)
|
||||
#define VENDOR_SPECIFIC (0xFF)
|
||||
|
||||
/* Data Class Protocol Codes */
|
||||
/* #define NO_CLASS_SPECIFIC_PROTOCOL (0x00) */
|
||||
#define PYHSICAL_INTERFACE_PROTOCOL (0x30)
|
||||
#define HDLC_PROTOCOL (0x31)
|
||||
#define TRANSPARENT_PROTOCOL (0x32)
|
||||
#define MANAGEMENT_PROTOCOL (0x50)
|
||||
#define DATA_LINK_Q931_PROTOCOL (0x51)
|
||||
#define DATA_LINK_Q921_PROTOCOL (0x52)
|
||||
#define DATA_COMPRESSION_V42BIS (0x90)
|
||||
#define EURO_ISDN_PROTOCOL (0x91)
|
||||
#define RATE_ADAPTION_ISDN_V24 (0x92)
|
||||
#define CAPI_COMMANDS (0x93)
|
||||
#define HOST_BASED_DRIVER (0xFD)
|
||||
#define CDC_UNIT_FUNCTIONAL (0xFE)
|
||||
/* #define VENDOR_SPECIFIC (0xFF) */
|
||||
|
||||
/* Descriptor SubType in Communications Class Functional Descriptors */
|
||||
#define HEADER_FUNC_DESC (0x00)
|
||||
#define CALL_MANAGEMENT_FUNC_DESC (0x01)
|
||||
#define ABSTRACT_CONTROL_FUNC_DESC (0x02)
|
||||
#define DIRECT_LINE_FUNC_DESC (0x03)
|
||||
#define TELEPHONE_RINGER_FUNC_DESC (0x04)
|
||||
#define TELEPHONE_REPORT_FUNC_DESC (0x05)
|
||||
#define UNION_FUNC_DESC (0x06)
|
||||
#define COUNTRY_SELECT_FUNC_DESC (0x07)
|
||||
#define TELEPHONE_MODES_FUNC_DESC (0x08)
|
||||
#define USB_TERMINAL_FUNC_DESC (0x09)
|
||||
#define NETWORK_CHANNEL_FUNC_DESC (0x0A)
|
||||
#define PROTOCOL_UNIT_FUNC_DESC (0x0B)
|
||||
#define EXTENSION_UNIT_FUNC_DESC (0x0C)
|
||||
#define MULTI_CHANNEL_FUNC_DESC (0x0D)
|
||||
#define CAPI_CONTROL_FUNC_DESC (0x0E)
|
||||
#define ETHERNET_NETWORKING_FUNC_DESC (0x0F)
|
||||
#define ATM_NETWORKING_FUNC_DESC (0x10)
|
||||
#define WIRELESS_CONTROL_FUNC_DESC (0x11)
|
||||
#define MOBILE_DIRECT_LINE_FUNC_DESC (0x12)
|
||||
#define MDLM_DETAIL_FUNC_DESC (0x13)
|
||||
#define DEVICE_MANAGEMENT_FUNC_DESC (0x14)
|
||||
#define OBEX_FUNC_DESC (0x15)
|
||||
#define COMMAND_SET_FUNC_DESC (0x16)
|
||||
#define COMMAND_SET_DETAIL_FUNC_DESC (0x17)
|
||||
#define TELEPHONE_CONTROL_FUNC_DESC (0x18)
|
||||
#define OBEX_SERVICE_ID_FUNC_DESC (0x19)
|
||||
|
||||
|
||||
#define CIC_SUBCLASS_CODE ABSTRACT_CONTROL_MODEL
|
||||
#define CIC_PROTOCOL_CODE NO_CLASS_SPECIFIC_PROTOCOL
|
||||
#define DIC_PROTOCOL_CODE NO_CLASS_SPECIFIC_PROTOCOL
|
||||
#define CIC_ENDP_COUNT (0+(CIC_NOTIF_ELEM_SUPPORT & 0x01) * 1)
|
||||
#define DIC_ENDP_COUNT (2)
|
||||
|
||||
#define CIC_NOTIF_ENDPOINT (3)
|
||||
#define CIC_NOTIF_ENDP_PACKET_SIZE (16)
|
||||
#define DIC_BULK_IN_ENDPOINT (1)
|
||||
#define DIC_BULK_IN_ENDP_PACKET_SIZE (16)/* max supported is 64 */
|
||||
#define DIC_BULK_OUT_ENDPOINT (2)
|
||||
#define DIC_BULK_OUT_ENDP_PACKET_SIZE (16)/* max supported is 64*/
|
||||
|
||||
#if DIC_ISOCHRONOUS_SETTING
|
||||
#define DIC_ISO_IN_ENDPOINT (1)
|
||||
#define DIC_ISO_IN_ENDP_PACKET_SIZE (64)
|
||||
#define DIC_ISO_OUT_ENDPOINT (2)
|
||||
#define DIC_ISO_OUT_ENDP_PACKET_SIZE (64)
|
||||
#endif
|
||||
#define REMOTE_WAKEUP_SHIFT (5)
|
||||
|
||||
/* Various descriptor sizes */
|
||||
#define DEVICE_DESCRIPTOR_SIZE (18)
|
||||
#define CONFIG_ONLY_DESC_SIZE (9)
|
||||
#define CONFIG_DESC_SIZE (CONFIG_ONLY_DESC_SIZE + 28 + \
|
||||
(CIC_NOTIF_ELEM_SUPPORT & 0x01) \
|
||||
* 7 + DATA_CLASS_SUPPORT * 23)
|
||||
#define DEVICE_QUALIFIER_DESCRIPTOR_SIZE (10)
|
||||
#define IFACE_ONLY_DESC_SIZE (9)
|
||||
#define ENDP_ONLY_DESC_SIZE (7)
|
||||
|
||||
/* Max descriptors provided by the Application */
|
||||
#define USB_MAX_STD_DESCRIPTORS (7)
|
||||
|
||||
/* Max configuration supported by the Application */
|
||||
#define USB_MAX_CONFIG_SUPPORTED (1)
|
||||
|
||||
/* Max string descriptors supported by the Application */
|
||||
#define USB_MAX_STRING_DESCRIPTORS (3)
|
||||
|
||||
/* Max language codes supported by the USB */
|
||||
#define USB_MAX_LANGUAGES_SUPPORTED (1)
|
||||
|
||||
/* string descriptors sizes */
|
||||
#define USB_STR_DESC_SIZE (2)
|
||||
#define USB_STR_0_SIZE (2)
|
||||
#define USB_STR_1_SIZE (56)
|
||||
#define USB_STR_2_SIZE (36)
|
||||
#define USB_STR_n_SIZE (32)
|
||||
|
||||
/* descriptors codes */
|
||||
#define USB_DEVICE_DESCRIPTOR (1)
|
||||
#define USB_CONFIG_DESCRIPTOR (2)
|
||||
#define USB_STRING_DESCRIPTOR (3)
|
||||
#define USB_IFACE_DESCRIPTOR (4)
|
||||
#define USB_ENDPOINT_DESCRIPTOR (5)
|
||||
#define USB_DEVQUAL_DESCRIPTOR (6)
|
||||
#define USB_CS_INTERFACE (0x24)
|
||||
#define USB_CS_ENDPOINT (0x25)
|
||||
|
||||
#define USB_MAX_SUPPORTED_INTERFACES (2)
|
||||
|
||||
/* Implementation Specific Macros */
|
||||
#define LINE_CODING_SIZE (0x07)
|
||||
#define COMM_FEATURE_DATA_SIZE (0x02)
|
||||
|
||||
#define LINE_CODE_DTERATE_IFACE0 (115200) /*e.g 9600 is 0x00002580 */
|
||||
#define LINE_CODE_CHARFORMAT_IFACE0 (0x00) /* 1 stop bit */
|
||||
#define LINE_CODE_PARITYTYPE_IFACE0 (0x00) /* No Parity */
|
||||
#define LINE_CODE_DATABITS_IFACE0 (0x08) /* Data Bits Format */
|
||||
|
||||
#define LINE_CODE_DTERATE_IFACE1 (9600) /*e.g. 115200 is 0x0001C200*/
|
||||
#define LINE_CODE_CHARFORMAT_IFACE1 (0x00) /* 1 stop bit */
|
||||
#define LINE_CODE_PARITYTYPE_IFACE1 (0x00) /* No Parity */
|
||||
#define LINE_CODE_DATABITS_IFACE1 (0x08) /* Data Bits Format */
|
||||
|
||||
#define STATUS_ABSTRACT_STATE_IFACE0 (0x0000) /* Disable Multiplexing
|
||||
ENDP in this interface will
|
||||
continue to accept/offer data*/
|
||||
#define STATUS_ABSTRACT_STATE_IFACE1 (0x0000) /* Disable Multiplexing
|
||||
ENDP in this interface will
|
||||
continue to accept/offer data*/
|
||||
#define COUNTRY_SETTING_IFACE0 (0x0000) /* Country Code in the format as
|
||||
defined in [ISO3166] */
|
||||
#define COUNTRY_SETTING_IFACE1 (0x0000) /* Country Code in the format as
|
||||
defined in [ISO3166] */
|
||||
|
||||
/* Notifications Support */
|
||||
#define PSTN_SUBCLASS_NOTIF_SUPPORT (TRUE)
|
||||
#define WMC_SUBCLASS_NOTIF_SUPPORT (FALSE)
|
||||
#define CDC_CLASS_NOTIF_SUPPORT (FALSE)
|
||||
|
||||
#define CDC_DESC_ENDPOINT_COUNT (CIC_ENDP_COUNT+(DATA_CLASS_SUPPORT & 0x01) \
|
||||
*DIC_ENDP_COUNT)
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
typedef const struct _USB_LANGUAGE
|
||||
{
|
||||
uint_16 const language_id; /* Language ID */
|
||||
uint_8 const ** lang_desc; /* Language Descriptor String */
|
||||
uint_8 const * lang_desc_size; /* Language Descriptor Size */
|
||||
} USB_LANGUAGE;
|
||||
|
||||
typedef const struct _USB_ALL_LANGUAGES
|
||||
{
|
||||
/* Pointer to Supported Language String */
|
||||
uint_8 const *languages_supported_string;
|
||||
/* Size of Supported Language String */
|
||||
uint_8 const languages_supported_size;
|
||||
/* Array of Supported Languages */
|
||||
USB_LANGUAGE usb_language[USB_MAX_SUPPORTED_INTERFACES];
|
||||
}USB_ALL_LANGUAGES;
|
||||
|
||||
typedef const struct _USB_ENDPOINTS
|
||||
{
|
||||
/* Number of non control Endpoints */
|
||||
uint_8 count;
|
||||
/* Array of Endpoints Structures */
|
||||
USB_EP_STRUCT ep[CDC_DESC_ENDPOINT_COUNT];
|
||||
}USB_ENDPOINTS;
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 USB_Desc_Get_Descriptor(
|
||||
uint_8 controller_ID,
|
||||
uint_8 type,
|
||||
uint_8 str_num,
|
||||
uint_16 index,
|
||||
uint_8_ptr *descriptor,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Desc_Get_Interface(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr alt_interface);
|
||||
|
||||
|
||||
extern uint_8 USB_Desc_Set_Interface(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8 alt_interface);
|
||||
|
||||
extern boolean USB_Desc_Valid_Configation(
|
||||
uint_8 controller_ID,
|
||||
uint_16 config_val);
|
||||
|
||||
extern boolean USB_Desc_Valid_Interface(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface);
|
||||
|
||||
extern boolean USB_Desc_Remote_Wakeup(uint_8 controller_ID);
|
||||
|
||||
extern void* USB_Desc_Get_Endpoints(uint_8 controller_ID);
|
||||
|
||||
extern uint_8 USB_Desc_Get_Line_Coding(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *coding_data);
|
||||
|
||||
extern uint_8 USB_Desc_Set_Line_Coding(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *coding_data);
|
||||
|
||||
extern uint_8 USB_Desc_Get_Abstract_State(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *feature_data);
|
||||
extern uint_8 USB_Desc_Get_Country_Setting(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *feature_data);
|
||||
extern uint_8 USB_Desc_Set_Abstract_State(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *feature_data);
|
||||
extern uint_8 USB_Desc_Set_Country_Setting(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *feature_data);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,480 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_devapi.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief This file contains S08 USB stack device layer API header function.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_DEVAPI_H
|
||||
#define _USB_DEVAPI_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h" /* User Defined Data Types */
|
||||
#include "hidef.h" /* for EnableInterrupts; macro */
|
||||
#include <stdint.h>
|
||||
#include "hal/derivative.h" /* include peripheral declarations */
|
||||
#include "usb_user_config.h" /* User Configuration File << EST 'user_config.h' conflicts with MQX Lite */
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#if 0 /* << EST */
|
||||
#ifndef _MC9S08JS16_H
|
||||
#define USB_MAX_EP_BUFFER_SIZE (512)
|
||||
#else
|
||||
#define USB_MAX_EP_BUFFER_SIZE (255)
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#define USB_MAX_EP_BUFFER_SIZE (512)
|
||||
#endif
|
||||
#ifndef CONTROL_ENDPOINT
|
||||
#define CONTROL_ENDPOINT (0)
|
||||
#endif
|
||||
|
||||
#define USB_SETUP_PKT_SIZE (8) /* Setup Packet Size */
|
||||
|
||||
/* Error codes */
|
||||
#define USB_OK (0x00)
|
||||
#define USBERR_ALLOC (0x81)
|
||||
#define USBERR_BAD_STATUS (0x82)
|
||||
#define USBERR_CLOSED_SERVICE (0x83)
|
||||
#define USBERR_OPEN_SERVICE (0x84)
|
||||
#define USBERR_TRANSFER_IN_PROGRESS (0x85)
|
||||
#define USBERR_ENDPOINT_STALLED (0x86)
|
||||
#define USBERR_ALLOC_STATE (0x87)
|
||||
#define USBERR_DRIVER_INSTALL_FAILED (0x88)
|
||||
#define USBERR_DRIVER_NOT_INSTALLED (0x89)
|
||||
#define USBERR_INSTALL_ISR (0x8A)
|
||||
#define USBERR_INVALID_DEVICE_NUM (0x8B)
|
||||
#define USBERR_ALLOC_SERVICE (0x8C)
|
||||
#define USBERR_INIT_FAILED (0x8D)
|
||||
#define USBERR_SHUTDOWN (0x8E)
|
||||
#define USBERR_INVALID_PIPE_HANDLE (0x8F)
|
||||
#define USBERR_OPEN_PIPE_FAILED (0x90)
|
||||
#define USBERR_INIT_DATA (0x91)
|
||||
#define USBERR_SRP_REQ_INVALID_STATE (0x92)
|
||||
#define USBERR_TX_FAILED (0x93)
|
||||
#define USBERR_RX_FAILED (0x94)
|
||||
#define USBERR_EP_INIT_FAILED (0x95)
|
||||
#define USBERR_EP_DEINIT_FAILED (0x96)
|
||||
#define USBERR_TR_FAILED (0x97)
|
||||
#define USBERR_BANDWIDTH_ALLOC_FAILED (0x98)
|
||||
#define USBERR_INVALID_NUM_OF_ENDPOINTS (0x99)
|
||||
#define USBERR_NOT_SUPPORTED (0x9A)
|
||||
|
||||
#define USBERR_DEVICE_NOT_FOUND (0xC0)
|
||||
#define USBERR_DEVICE_BUSY (0xC1)
|
||||
#define USBERR_NO_DEVICE_CLASS (0xC3)
|
||||
#define USBERR_UNKNOWN_ERROR (0xC4)
|
||||
#define USBERR_INVALID_BMREQ_TYPE (0xC5)
|
||||
#define USBERR_GET_MEMORY_FAILED (0xC6)
|
||||
#define USBERR_INVALID_MEM_TYPE (0xC7)
|
||||
#define USBERR_NO_DESCRIPTOR (0xC8)
|
||||
#define USBERR_NULL_CALLBACK (0xC9)
|
||||
#define USBERR_NO_INTERFACE (0xCA)
|
||||
#define USBERR_INVALID_CFIG_NUM (0xCB)
|
||||
#define USBERR_INVALID_ANCHOR (0xCC)
|
||||
#define USBERR_INVALID_REQ_TYPE (0xCD)
|
||||
|
||||
/* Pipe Types */
|
||||
#define USB_CONTROL_PIPE (0x00)
|
||||
#define USB_ISOCHRONOUS_PIPE (0x01)
|
||||
#define USB_BULK_PIPE (0x02)
|
||||
#define USB_INTERRUPT_PIPE (0x03)
|
||||
|
||||
/* Device States */
|
||||
#define USB_STATE_UNKNOWN (0xFF)
|
||||
#define USB_STATE_PENDING_ADDRESS (0x04)
|
||||
#define USB_STATE_POWERED (0x03)
|
||||
#define USB_STATE_DEFAULT (0x02)
|
||||
#define USB_STATE_ADDRESS (0x01)
|
||||
#define USB_STATE_CONFIG (0x00)
|
||||
#define USB_STATE_SUSPEND (0x80)
|
||||
|
||||
/* Get_Status Request information for DEVICE */
|
||||
#define USB_SELF_POWERED (0x01)
|
||||
#define USB_REMOTE_WAKEUP (0x02)
|
||||
|
||||
/* Get_Status Request information for OTG (WINDEX = 0xF000) */
|
||||
#ifdef OTG_BUILD
|
||||
#define USB_OTG_HOST_REQUEST_FLAG (0x01)
|
||||
#endif
|
||||
|
||||
/* Bus Control values */
|
||||
#define USB_NO_OPERATION (0x00)
|
||||
#define USB_ASSERT_BUS_RESET (0x01)
|
||||
#define USB_DEASSERT_BUS_RESET (0x02)
|
||||
#define USB_ASSERT_RESUME (0x03)
|
||||
#define USB_DEASSERT_RESUME (0x04)
|
||||
#define USB_SUSPEND_SOF (0x05)
|
||||
#define USB_RESUME_SOF (0x06)
|
||||
|
||||
/* possible values of Status */
|
||||
#define USB_STATUS_IDLE (0)
|
||||
#define USB_STATUS_TRANSFER_ACCEPTED (6)
|
||||
#define USB_STATUS_TRANSFER_PENDING (2)
|
||||
#define USB_STATUS_TRANSFER_IN_PROGRESS (3)
|
||||
#define USB_STATUS_ERROR (4)
|
||||
#define USB_STATUS_DISABLED (5)
|
||||
#define USB_STATUS_STALLED (1)
|
||||
#define USB_STATUS_TRANSFER_QUEUED (7)
|
||||
|
||||
#define USB_STATUS_UNKNOWN (0xFF)
|
||||
|
||||
#define USB_CONTROL_ENDPOINT (0)
|
||||
|
||||
#define USB_RECV (0)
|
||||
#define USB_SEND (1)
|
||||
|
||||
#define USB_DEVICE_DONT_ZERO_TERMINATE (0x1)
|
||||
|
||||
#define USB_SETUP_DATA_XFER_DIRECTION (0x80)
|
||||
|
||||
#define USB_SPEED_FULL (0)
|
||||
#define USB_SPEED_LOW (1)
|
||||
#define USB_SPEED_HIGH (2)
|
||||
|
||||
#define USB_MAX_PKTS_PER_UFRAME (0x6)
|
||||
|
||||
#define USB_TEST_MODE_TEST_PACKET (0x0400)
|
||||
|
||||
/* Available service types */
|
||||
/* Services 0 through 15 are reserved for endpoints */
|
||||
#define USB_SERVICE_EP0 (0x00)
|
||||
#define USB_SERVICE_EP1 (0x01)
|
||||
#define USB_SERVICE_EP2 (0x02)
|
||||
#define USB_SERVICE_EP3 (0x03)
|
||||
#define USB_SERVICE_EP4 (0x04)
|
||||
#define USB_SERVICE_EP5 (0x05)
|
||||
#define USB_SERVICE_EP6 (0x06)
|
||||
#define USB_SERVICE_EP7 (0x07)
|
||||
#define USB_SERVICE_EP8 (0x08)
|
||||
#define USB_SERVICE_EP9 (0x09)
|
||||
#define USB_SERVICE_EP10 (0x0A)
|
||||
#define USB_SERVICE_EP11 (0x0B)
|
||||
#define USB_SERVICE_EP12 (0x0C)
|
||||
#define USB_SERVICE_EP13 (0x0d)
|
||||
#define USB_SERVICE_EP14 (0x0E)
|
||||
#define USB_SERVICE_EP15 (0x0F)
|
||||
|
||||
#define USB_SERVICE_BUS_RESET (0x10)
|
||||
#define USB_SERVICE_SUSPEND (0x11)
|
||||
#define USB_SERVICE_SOF (0x12)
|
||||
#define USB_SERVICE_RESUME (0x13)
|
||||
#define USB_SERVICE_SLEEP (0x14)
|
||||
#define USB_SERVICE_SPEED_DETECTION (0x15)
|
||||
#define USB_SERVICE_ERROR (0x16)
|
||||
#define USB_SERVICE_STALL (0x17)
|
||||
#define USB_SERVICE_MAX (0x18)
|
||||
|
||||
#if 0 /* << EST */
|
||||
#if (defined(_MCF51JM128_H) ||defined(_MCF51MM256_H) || (defined _MCF51JE256_H))
|
||||
#define USB_SERVICE_MAX_EP USB_SERVICE_EP15
|
||||
#else
|
||||
#ifdef DOUBLE_BUFFERING_USED
|
||||
#define USB_SERVICE_MAX_EP USB_SERVICE_EP6
|
||||
#else
|
||||
#define USB_SERVICE_MAX_EP USB_SERVICE_EP4
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#ifdef DOUBLE_BUFFERING_USED
|
||||
#define USB_SERVICE_MAX_EP USB_SERVICE_EP6
|
||||
#else
|
||||
#define USB_SERVICE_MAX_EP USB_SERVICE_EP4
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Informational Request/Set Types */
|
||||
/* component parameter in USB_Device_Get/Set_Status */
|
||||
#define USB_COMPONENT_DIRECTION_SHIFT (7)
|
||||
#define USB_COMPONENT_DIRECTION_MASK (0x01)
|
||||
#define USB_STATUS_DEVICE_STATE (0x01)
|
||||
#define USB_STATUS_INTERFACE (0x02)
|
||||
#define USB_STATUS_ADDRESS (0x03)
|
||||
#define USB_STATUS_CURRENT_CONFIG (0x04)
|
||||
#define USB_STATUS_SOF_COUNT (0x05)
|
||||
#define USB_STATUS_DEVICE (0x06)
|
||||
|
||||
// Endpoint attributes
|
||||
#define EP_TRANSFER_TYPE_CONTROL (0x0<<0)
|
||||
#define EP_TRANSFER_TYPE_ISOCHRONOUS (0x1<<0)
|
||||
#define EP_TRANSFER_TYPE_BULK (0x2<<0)
|
||||
#define EP_TRANSFER_TYPE_INTERRUPT (0x3<<0)
|
||||
|
||||
/* Standard Request Code */
|
||||
#define GET_STATUS 0x0
|
||||
#define CLEAR_FEATURE 0x1
|
||||
#define SET_FEATURE 0x3
|
||||
#define SET_ADDRESS 0x5
|
||||
#define GET_DESCRIPTOR 0x6
|
||||
#define SET_DESCRIPTOR 0x7
|
||||
#define GET_CONFIGURATION 0x8
|
||||
#define SET_CONFIGURATION 0x9
|
||||
#define GET_INTERFACE 0xA
|
||||
#define SET_INTERFACE 0xB
|
||||
#define SYNCH_FRAME 0xC
|
||||
|
||||
#ifdef OTG_BUILD
|
||||
#define USB_STATUS_OTG (0x07)
|
||||
#define USB_STATUS_TEST_MODE (0x08)
|
||||
#else
|
||||
#define USB_STATUS_TEST_MODE (0x07)
|
||||
#endif
|
||||
|
||||
#define USB_STATUS_ENDPOINT (0x10)
|
||||
#define USB_STATUS_ENDPOINT_NUMBER_MASK (0x0F)
|
||||
|
||||
#define UNINITIALISED_VAL (0xFFFFFFFF)
|
||||
|
||||
#if 0 /* << EST */
|
||||
#if (defined MCU_MK40N512VMD100) || (defined MCU_MK53N512CMD100) || (defined MCU_MK60N512VMD100) || (defined MCU_MK70F12)
|
||||
#define USB_DEVICE_ASSERT_RESUME() USB0_CTL |= USB_CTL_RESUME_MASK;
|
||||
#define USB_DEVICE_DEASSERT_RESUME() USB0_CTL &= ~USB_CTL_RESUME_MASK;
|
||||
#elif (defined _MC9S08JE128_H) || (defined _MC9S08JM16_H) || defined(_MC9S08JM60_H) || (defined _MC9S08JS16_H) || (defined _MC9S08MM128_H)
|
||||
#define USB_DEVICE_ASSERT_RESUME() CTL_CRESUME = 1;
|
||||
#define USB_DEVICE_DEASSERT_RESUME() CTL_CRESUME = 0;
|
||||
#elif (defined _MCF51JE256_H) || (defined MCU_mcf51jf128) || defined(_MCF51MM256_H)
|
||||
#define USB_DEVICE_ASSERT_RESUME() USBTRC0_USBRESMEN = 1;
|
||||
#define USB_DEVICE_DEASSERT_RESUME() USBTRC0_USBRESMEN = 0;
|
||||
#elif (defined __MCF52221_H__) || defined(__MCF52259_H__)
|
||||
#define USB_DEVICE_ASSERT_RESUME() CTL |= MCF_USB_OTG_CTL_RESUME;
|
||||
#define USB_DEVICE_DEASSERT_RESUME() CTL &= ~MCF_USB_OTG_CTL_RESUME;
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#endif
|
||||
|
||||
#define USB_PROCESS_PENDING() ((gu8ProcessPendingFlag != 0) || (gtUSBEPEventFlags != 0))
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
typedef void _PTR_ _usb_device_handle;
|
||||
typedef uint_8 T_EP_BITFIELD;
|
||||
|
||||
#if 0 /* << EST */
|
||||
#if !(defined _MC9S08JE128_H) && !(defined _MC9S08JM16_H) && !defined(_MC9S08JM60_H) && !(defined _MC9S08JS16_H) && !(defined _MC9S08MM128_H)
|
||||
#pragma pack (1) /* Enforce 1 byte struct alignment */
|
||||
#endif
|
||||
#else
|
||||
#ifndef __HIWARE__
|
||||
/* << EST pushing current packing */
|
||||
#pragma pack(push)
|
||||
#pragma pack(1) /* Enforce 1 byte struct alignment */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __MK_xxx_H__
|
||||
#if (defined(__CWCC__) || defined(__GNUC__))
|
||||
#define ALIGN __attribute__ ((packed))
|
||||
#elif((defined __IAR_SYSTEMS_ICC__) || (defined __CC_ARM))
|
||||
#define ALIGN
|
||||
#else
|
||||
#define ALIGN
|
||||
#endif
|
||||
#else
|
||||
#define ALIGN
|
||||
#endif
|
||||
|
||||
typedef struct _USB_DEV_EVENT_STRUCT
|
||||
{
|
||||
uint_8 controller_ID; /* controller ID */
|
||||
uint_8 ep_num;
|
||||
boolean setup; /* is setup packet */
|
||||
boolean direction; /* direction of endpoint */
|
||||
uint_8* buffer_ptr; /* pointer to buffer */
|
||||
uint_8 errors; /* Any errors */
|
||||
USB_PACKET_SIZE len; /* buffer size of endpoint */
|
||||
}ALIGN USB_DEV_EVENT_STRUCT, *PTR_USB_DEV_EVENT_STRUCT;
|
||||
|
||||
// Same endpoint can have multiple function assignments in g_usb_CB, depending on user input
|
||||
#ifndef MULTIPLE_DEVICES
|
||||
typedef void(_CODE_PTR_ const USB_SERVICE_CALLBACK)(PTR_USB_DEV_EVENT_STRUCT);
|
||||
#else
|
||||
typedef void(_CODE_PTR_ USB_SERVICE_CALLBACK)(PTR_USB_DEV_EVENT_STRUCT);
|
||||
#endif
|
||||
|
||||
typedef struct _USB_EP_STRUCT
|
||||
{
|
||||
uint_8 ep_num; /* endpoint number */
|
||||
uint_8 type; /* type of endpoint */
|
||||
uint_8 direction; /* direction of endpoint */
|
||||
USB_PACKET_SIZE size ALIGN; /* buffer size of endpoint */
|
||||
}ALIGN USB_EP_STRUCT, *USB_EP_STRUCT_PTR;
|
||||
|
||||
#if (defined(__CWCC__))/*||defined(__GNUC__))*/ /* << EST: that pragma does not exist for gcc */
|
||||
#pragma options align = reset
|
||||
#elif defined(__GNUC__) /* << EST */
|
||||
/* << EST restoring previous packing */
|
||||
#pragma pack(pop)
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__CC_ARM)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
|
||||
extern volatile uint_8 gu8ProcessPendingFlag;
|
||||
extern volatile T_EP_BITFIELD gtUSBEPEventFlags;
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 _usb_device_init (
|
||||
uint_8 device_number,
|
||||
_usb_device_handle _PTR_ handle,
|
||||
uint_8 number_of_endpoints,
|
||||
uint_8 bVregEn
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_deinit(void);
|
||||
|
||||
extern uint_8 _usb_device_init_endpoint(
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_16 max_packet_size,
|
||||
uint_8 direction,
|
||||
uint_8 endpoint_type,
|
||||
uint_8 flag
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_cancel_transfer (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_deinit_endpoint (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_recv_data (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint8_ptr buffer_ptr,
|
||||
uint_32 size
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_send_data (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint8_ptr buffer_ptr,
|
||||
uint_32 size
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_get_send_buffer (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 ep_num, /* [IN] Endpoint number */
|
||||
uint_8_ptr *buff_ptr, /* [OUT] Buffer for IN endpoint */
|
||||
USB_PACKET_SIZE *size /* [OUT] Size of IN endpoint */
|
||||
);
|
||||
|
||||
extern void _usb_device_shutdown (
|
||||
_usb_device_handle handle
|
||||
);
|
||||
|
||||
extern void _usb_device_stall_endpoint (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void _usb_device_unstall_endpoint (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void _usb_device_read_setup_data (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8_ptr buffer_ptr
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_get_status (
|
||||
_usb_device_handle handle,
|
||||
uint_8 component,
|
||||
uint_8_ptr status
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_set_status (
|
||||
_usb_device_handle handle,
|
||||
uint_8 component,
|
||||
uint_8 setting
|
||||
);
|
||||
|
||||
extern void _usb_device_clear_data0_endpoint(
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void _usb_device_assert_resume (
|
||||
_usb_device_handle handle
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_register_service (
|
||||
uint_8 controller_ID,
|
||||
uint_8 type,
|
||||
USB_SERVICE_CALLBACK service
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_unregister_service (
|
||||
_usb_device_handle handle,
|
||||
uint_8 event_endpoint
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_get_transfer_status (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void _usb_device_set_address (
|
||||
_usb_device_handle handle,
|
||||
uint_8 address
|
||||
);
|
||||
|
||||
extern uint_8 USB_Device_Call_Service(
|
||||
uint_8 type,
|
||||
PTR_USB_DEV_EVENT_STRUCT event
|
||||
);
|
||||
|
||||
extern void USB_Engine(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,629 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_driver.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief The file contains S08 USB stack device layer implementation.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "usb_devapi.h" /* USB Device Layer API Header File */
|
||||
#include "usb_dciapi.h" /* USB Controller API Header File */
|
||||
#ifdef _MK_xxx_H_
|
||||
#include "usb_dci_kinetis.h"
|
||||
#endif
|
||||
#ifndef MULTIPLE_DEVICES
|
||||
#include "USB_Config.h"
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Constant and Macro's
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
extern void USB_Control_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Reset_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Sof_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Resume_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Suspend_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Error_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Stall_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
|
||||
/* Array of USB Service pointers */
|
||||
#ifdef MULTIPLE_DEVICES
|
||||
static USB_SERVICE_CALLBACK g_usb_CB[USB_SERVICE_MAX];
|
||||
#else
|
||||
static USB_SERVICE_CALLBACK g_usb_CB[USB_SERVICE_MAX] = {
|
||||
USB_EP0_CALLBACK,
|
||||
USB_EP1_CALLBACK,
|
||||
USB_EP2_CALLBACK,
|
||||
USB_EP3_CALLBACK,
|
||||
USB_EP4_CALLBACK,
|
||||
USB_EP5_CALLBACK,
|
||||
USB_EP6_CALLBACK,
|
||||
USB_EP7_CALLBACK,
|
||||
USB_EP8_CALLBACK,
|
||||
USB_EP9_CALLBACK,
|
||||
USB_EP10_CALLBACK,
|
||||
USB_EP11_CALLBACK,
|
||||
USB_EP12_CALLBACK,
|
||||
USB_EP13_CALLBACK,
|
||||
USB_EP14_CALLBACK,
|
||||
USB_EP15_CALLBACK,
|
||||
USB_BUS_RESET_CALLBACK,
|
||||
USB_SUSPEND_CALLBACK,
|
||||
USB_SOF_CALLBACK,
|
||||
USB_RESUME_CALLBACK,
|
||||
USB_SLEEP_CALLBACK,
|
||||
USB_SPEED_DETECTION_CALLBACK,
|
||||
USB_ERROR_CALLBACK,
|
||||
USB_STALL_CALLBACK
|
||||
};
|
||||
#endif
|
||||
/* Array of USB Component Status */
|
||||
/* Test mode is the last service */
|
||||
static uint_8 g_usb_component_status[USB_STATUS_TEST_MODE];
|
||||
/* Array of USB Endpoint Status */
|
||||
static uint_8 g_usb_ep_status[MAX_SUPPORTED_ENDPOINTS];
|
||||
/* Current un-initialized non CONTROL Endpoint */
|
||||
static uint_8 g_EPn=0;
|
||||
/* Maximum number of Non CONTROL Endpoint required by upper layer */
|
||||
static uint_8 g_EPn_max=0;
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Types - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions Prototypes - None
|
||||
*****************************************************************************/
|
||||
static void USB_Device_Init_Params(void);
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Variables - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions
|
||||
*****************************************************************************/
|
||||
#if 0 /* << EST */
|
||||
#if (defined(_MC9S08MM128_H) || defined(_MC9S08JE128_H))
|
||||
#pragma CODE_SEG DEFAULT
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 USB_DCI_DeInit(void);
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Device_Init_Params
|
||||
*
|
||||
* @brief The function initializes the Device Layer Structures
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Initializes USB Device Layer Structures
|
||||
*****************************************************************************/
|
||||
static void USB_Device_Init_Params(void)
|
||||
{
|
||||
uint_8 loop_index=0;
|
||||
|
||||
g_EPn= g_EPn_max; /* 1 control endpoint */
|
||||
|
||||
/*
|
||||
Initialize USB_STATUS_DEVICE_STATE, USB_STATUS_INTERFACE,
|
||||
USB_STATUS_ADDRESS, USB_STATUS_CURRENT_CONFIG, USB_STATUS_SOF_COUNT
|
||||
and USB_STATUS_DEVICE to USB_STATUS_UNKNOWN
|
||||
*/
|
||||
for(loop_index = 0; loop_index < USB_STATUS_TEST_MODE; loop_index++)
|
||||
{
|
||||
#ifdef OTG_BUILD
|
||||
if(loop_index != (USB_STATUS_OTG-1)) /* Do not initialize the OTG status with 0xFFFF */
|
||||
#endif
|
||||
{
|
||||
g_usb_component_status[loop_index] = USB_STATUS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize status of All Endpoints to USB_STATUS_DISABLED */
|
||||
for(loop_index = 0; loop_index < MAX_SUPPORTED_ENDPOINTS; loop_index++)
|
||||
{
|
||||
g_usb_ep_status[loop_index] = USB_STATUS_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_init
|
||||
*
|
||||
* @brief The function initializes the Device and Controller layer
|
||||
*
|
||||
* @param device_number : USB Device controller to initialize
|
||||
* @param handle : pointer to USB Device handle
|
||||
* @param number_of_endpoints : Endpoint count of the application
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_NUM_OF_ENDPOINTS : When endpoints > max Supported
|
||||
******************************************************************************
|
||||
* This function initializes the Device layer and the Controller layer of the
|
||||
* S08 USB stack. It initializes the variables used for this layer and then
|
||||
* calls the controller layer initialize function
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_init (
|
||||
uint_8 device_number, /* [IN] USB Device controller to initialize */
|
||||
_usb_device_handle _PTR_ handle, /* [IN] Pointer to USB Device handle */
|
||||
uint_8 number_of_endpoints, /* [IN] Number of endpoints to initialize */
|
||||
uint_8 bVregEn /* Enables or disables internal regulator */
|
||||
)
|
||||
{
|
||||
UNUSED(handle);
|
||||
|
||||
/* validate endpoints param */
|
||||
if((number_of_endpoints > MAX_SUPPORTED_ENDPOINTS) ||
|
||||
(number_of_endpoints < MIN_SUPPORTED_ENDPOINTS))
|
||||
{
|
||||
return USBERR_INVALID_NUM_OF_ENDPOINTS;
|
||||
}
|
||||
|
||||
/* init variables */
|
||||
g_EPn_max = (uint_8)(number_of_endpoints - 1);
|
||||
|
||||
USB_Device_Init_Params();
|
||||
|
||||
#ifdef MULTIPLE_DEVICES
|
||||
/* Initialize all services to null value */
|
||||
Clear_Mem((uint_8_ptr)g_usb_CB,
|
||||
(uint_32)(sizeof(USB_SERVICE_CALLBACK) * USB_SERVICE_MAX), (uint_8)0);
|
||||
#endif
|
||||
/* Call controller layer initialization function */
|
||||
return USB_DCI_Init(device_number, bVregEn);
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_deinit
|
||||
*
|
||||
* @brief The function de-initializes the Device and Controller layer
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_NUM_OF_ENDPOINTS : When endpoints > max Supported
|
||||
******************************************************************************
|
||||
* This function de-initializes the Device layer and the Controller layer
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_deinit(void)
|
||||
{
|
||||
g_EPn_max = 0;
|
||||
/* Call controller layer de-initialization function */
|
||||
return USB_DCI_DeInit();
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_init_endpoint
|
||||
*
|
||||
* @brief The function initializes the endpoint
|
||||
*
|
||||
* @param handle : USB Device handle
|
||||
* @param endpoint_number : Endpoint number
|
||||
* @param max_packet_size : Maximum packet size (in bytes) for the endpoint
|
||||
* @param direction : Direction of transfer
|
||||
* @param endpoint_type : Type of endpoint
|
||||
* @param flag : Zero termination flag
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_EP_INIT_FAILED : When endpoints > max Supported
|
||||
******************************************************************************
|
||||
*
|
||||
* This function initializes an endpoint the Device layer and the Controller
|
||||
* layer in the S08 USB stack. It validate whether all endpoints have already
|
||||
* been initialized or not and then calls the controller layer endpoint
|
||||
* initialize function
|
||||
*
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_init_endpoint (
|
||||
_usb_device_handle handle, /* [IN] USB Device handle */
|
||||
uint_8 endpoint_number, /* [IN] Endpoint number*/
|
||||
uint_16 max_packet_size, /* [IN] Maximum packet size (in bytes) for the endpoint */
|
||||
uint_8 direction, /* [IN] Direction of transfer */
|
||||
uint_8 endpoint_type, /* [IN] Type of endpoint */
|
||||
uint_8 flag /* [IN] Zero termination flag */
|
||||
)
|
||||
{
|
||||
USB_EP_STRUCT ep_str;
|
||||
|
||||
uint_8 status = USB_OK;
|
||||
|
||||
/* check if all endpoint have already been initialised */
|
||||
if((g_EPn == 0) && (endpoint_number != CONTROL_ENDPOINT))
|
||||
{
|
||||
return USBERR_EP_INIT_FAILED;
|
||||
}
|
||||
|
||||
ep_str.direction = direction;
|
||||
ep_str.ep_num = endpoint_number;
|
||||
|
||||
#if 0 /* << EST */
|
||||
#ifndef _MC9S08JS16_H
|
||||
ep_str.size = max_packet_size;
|
||||
#else
|
||||
ep_str.size = (char)max_packet_size;
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
ep_str.size = max_packet_size;
|
||||
#endif
|
||||
|
||||
ep_str.type = endpoint_type;
|
||||
|
||||
/* call controller layer for initiazation */
|
||||
status = USB_DCI_Init_EndPoint(*((uint_8*)handle), &ep_str, flag);
|
||||
|
||||
/* if endpoint successfully initialised update counter */
|
||||
if((ep_str.ep_num != CONTROL_ENDPOINT) && (status == USB_OK))
|
||||
{
|
||||
g_EPn--;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_deinit_endpoint
|
||||
*
|
||||
* @brief The function de-initializes the endpoint
|
||||
*
|
||||
* @param handle : USB Device handle
|
||||
* @param endpoint_number : Endpoint number
|
||||
* @param direction : Endpoint direction
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_EP_DEINIT_FAILED : When endpoints > max Supported
|
||||
******************************************************************************
|
||||
*
|
||||
* This function deinitializes an endpoint the Device layer and the Controller
|
||||
* layer in the S08 USB stack. It validate whether all endpoints have already
|
||||
* been deinitialized or not and then calls the controller layer endpoint
|
||||
* deinitialize function
|
||||
*
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_deinit_endpoint (
|
||||
_usb_device_handle handle, /* [IN] USB Device handle */
|
||||
uint_8 endpoint_number, /* [IN] Endpoint number */
|
||||
uint_8 direction /* [IN] Direction */
|
||||
)
|
||||
{
|
||||
uint_8 status=USB_OK;
|
||||
|
||||
/* check if all endpoint have already been initialised */
|
||||
if((g_EPn == g_EPn_max) && (endpoint_number != CONTROL_ENDPOINT))
|
||||
{
|
||||
return USBERR_EP_DEINIT_FAILED;
|
||||
}
|
||||
|
||||
/* call controller layer for initiazation */
|
||||
status = USB_DCI_Deinit_EndPoint(*((uint_8*)handle), endpoint_number, direction);
|
||||
|
||||
/* if endpoint successfully deinitialised update counter */
|
||||
if((endpoint_number != CONTROL_ENDPOINT) && (status == USB_OK))
|
||||
{
|
||||
g_EPn++;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_get_status
|
||||
*
|
||||
* @brief The function retrieves various endpoint as well as USB component status
|
||||
*
|
||||
* @param handle : USB Device handle
|
||||
* @param component : USB component
|
||||
* @param status : Pointer to 16 bit return value
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_BAD_STATUS : When error
|
||||
*
|
||||
******************************************************************************
|
||||
* This function retrieves the endpoint as well USB component status which is
|
||||
* stored by calling USB_Device_Set_Status. This function can be called by Ap-
|
||||
* plication as well as the DCI layer.
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_get_status (
|
||||
_usb_device_handle handle, /* [IN] USB Device handle */
|
||||
uint_8 component, /* [IN] USB component */
|
||||
uint_8_ptr status /* [OUT] Pointer to 16 bit return value */
|
||||
)
|
||||
{
|
||||
/* get the endpoint number from component input variable */
|
||||
uint_8 ep_num = (uint_8)(component & USB_STATUS_ENDPOINT_NUMBER_MASK);
|
||||
UNUSED (handle);
|
||||
|
||||
if((component <= USB_STATUS_TEST_MODE) &&
|
||||
(component >= USB_STATUS_DEVICE_STATE))
|
||||
{
|
||||
/* Get the corresponding component status
|
||||
-1 as components start from 1 */
|
||||
*status = g_usb_component_status[component-1];
|
||||
}
|
||||
else if((component & USB_STATUS_ENDPOINT) &&
|
||||
(ep_num < MAX_SUPPORTED_ENDPOINTS))
|
||||
{
|
||||
/* Get the corresponding endpoint status */
|
||||
*status = g_usb_ep_status[ep_num];
|
||||
}
|
||||
else
|
||||
{
|
||||
return USBERR_BAD_STATUS;
|
||||
}
|
||||
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_set_status
|
||||
*
|
||||
* @brief The function saves status of endpoints as well as USB components.
|
||||
*
|
||||
* @param handle : USB Device handle
|
||||
* @param component : USB component
|
||||
* @param setting : Value to be set
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_BAD_STATUS : When error
|
||||
*
|
||||
******************************************************************************
|
||||
* This function sets the endpoint as well USB component status which can be
|
||||
* retrieved by calling _usb_device_get_status. This function can be called by
|
||||
* Application as well as the DCI layer.
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_set_status(
|
||||
_usb_device_handle handle, /* [IN] USB Device handle */
|
||||
uint_8 component, /* [IN] USB Component status to set */
|
||||
uint_8 setting /* [IN] Status to set */
|
||||
)
|
||||
{
|
||||
/* get the endpoint number from component input variable */
|
||||
uint_8 ep_num = (uint_8)(component & USB_STATUS_ENDPOINT_NUMBER_MASK);
|
||||
UNUSED (handle);
|
||||
|
||||
if((component <= USB_STATUS_TEST_MODE) &&
|
||||
(component >= USB_STATUS_DEVICE_STATE))
|
||||
{
|
||||
/*
|
||||
Set the corresponding component setting
|
||||
-1 as components start from 1
|
||||
*/
|
||||
g_usb_component_status[component-1] = setting;
|
||||
}
|
||||
else if((component & USB_STATUS_ENDPOINT) &&
|
||||
(ep_num < MAX_SUPPORTED_ENDPOINTS))
|
||||
{
|
||||
uint_8 direction =
|
||||
(uint_8)((component >> USB_COMPONENT_DIRECTION_SHIFT) &
|
||||
USB_COMPONENT_DIRECTION_MASK);
|
||||
/* HALT Endpoint */
|
||||
if(setting == USB_STATUS_STALLED)
|
||||
{
|
||||
_usb_device_stall_endpoint(handle, ep_num, direction);
|
||||
}
|
||||
else if((setting == USB_STATUS_IDLE) &&
|
||||
(g_usb_ep_status[ep_num] == USB_STATUS_STALLED))
|
||||
{
|
||||
_usb_device_unstall_endpoint(handle, ep_num, direction);
|
||||
|
||||
if(ep_num == CONTROL_ENDPOINT)
|
||||
{
|
||||
direction = (uint_8)((direction == USB_SEND)?
|
||||
(USB_RECV):(USB_SEND));
|
||||
_usb_device_unstall_endpoint(handle, ep_num, direction);
|
||||
}
|
||||
}
|
||||
/* Set the corresponding endpoint setting */
|
||||
g_usb_ep_status[ep_num] = setting;
|
||||
}
|
||||
else
|
||||
{
|
||||
return USBERR_BAD_STATUS;
|
||||
}
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_register_service
|
||||
*
|
||||
* @brief The function registers a callback function from the Application layer
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param type : event type or endpoint number
|
||||
* @param service : callback function pointer
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_ALLOC_SERVICE : When invalid type or already registered
|
||||
*
|
||||
******************************************************************************
|
||||
* This function registers a callback function from the application if it is
|
||||
* called not already registered so that the registered callback function can
|
||||
* be if the event of that type occurs
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_register_service(
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 type, /* [IN] type of event or endpoint
|
||||
number to service */
|
||||
USB_SERVICE_CALLBACK service /* [IN] pointer to callback
|
||||
function */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
UNUSED (service);
|
||||
#ifdef MULTIPLE_DEVICES
|
||||
/* check if the type is valid and callback for the type
|
||||
is not already registered */
|
||||
if(((type <= USB_SERVICE_MAX_EP) ||
|
||||
((type < USB_SERVICE_MAX) && (type >= USB_SERVICE_BUS_RESET))) &&
|
||||
(g_usb_CB[type] == NULL))
|
||||
{
|
||||
|
||||
/* register the callback function */
|
||||
g_usb_CB[type] = service;
|
||||
return USB_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return USBERR_ALLOC_SERVICE;
|
||||
}
|
||||
#else
|
||||
UNUSED(type);
|
||||
return USB_OK;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_unregister_service
|
||||
*
|
||||
* @brief The function unregisters an event or endpoint callback function
|
||||
*
|
||||
* @param handle : USB Device handle
|
||||
* @param event_endpoint : event type or endpoint number
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_UNKNOWN_ERROR : When invalid type or not registered
|
||||
*
|
||||
*****************************************************************************
|
||||
* This function un registers a callback function which has been previously
|
||||
* registered by the application layer
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_unregister_service(
|
||||
_usb_device_handle handle, /* [IN] USB Device handle */
|
||||
uint_8 event_endpoint /* [IN] Endpoint (0 through 15) or event to service */
|
||||
)
|
||||
{
|
||||
UNUSED (handle);
|
||||
/* check if the type is valid and callback for the type
|
||||
is already registered */
|
||||
if(((event_endpoint <= USB_SERVICE_MAX_EP) ||
|
||||
((event_endpoint < USB_SERVICE_MAX) && (event_endpoint >= USB_SERVICE_BUS_RESET))) &&
|
||||
(g_usb_CB[event_endpoint] != NULL))
|
||||
{
|
||||
#ifdef MULTIPLE_DEVICES
|
||||
/* unregister the callback */
|
||||
g_usb_CB[event_endpoint] = NULL;
|
||||
#endif
|
||||
return USB_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return USBERR_UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Device_Call_Service
|
||||
*
|
||||
* @brief The function is a device layer event handler
|
||||
*
|
||||
* @param type : Type of service or endpoint
|
||||
* @param event : Pointer to event structure
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : Always
|
||||
*
|
||||
*****************************************************************************
|
||||
*
|
||||
* This function calls the registered service callback function of the applic-
|
||||
* ation layer based on the type of event received. This function is called
|
||||
* from the DCI layer.
|
||||
*
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Device_Call_Service(
|
||||
uint_8 type, /* [IN] Type of service or endpoint */
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to event structure */
|
||||
)
|
||||
{
|
||||
|
||||
if(type == USB_SERVICE_BUS_RESET)
|
||||
{ /* if it is an reset interrupt then reset all status structures */
|
||||
USB_Device_Init_Params();
|
||||
}
|
||||
|
||||
/* check if the callback is registered or not */
|
||||
if(g_usb_CB[type] != NULL)
|
||||
{
|
||||
/* call the callback function */
|
||||
g_usb_CB[type](event);
|
||||
}
|
||||
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
void USB_NULL_CALLBACK (PTR_USB_DEV_EVENT_STRUCT event)
|
||||
{
|
||||
UNUSED(event);
|
||||
|
||||
#if (defined(__CWCC__) || defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__))
|
||||
asm("nop");
|
||||
#elif defined (__CC_ARM)
|
||||
__nop();
|
||||
#endif
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,151 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_framwork.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB Framework module API header function.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_FRAMEWORK_H
|
||||
#define _USB_FRAMEWORK_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "usb_class.h"
|
||||
#include "usb_descriptor.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define MAX_STRD_REQ (13) /* Max value of standard request */
|
||||
/* size of data to be returned for various Get Desc calls */
|
||||
#define DEVICE_STATUS_SIZE (2)
|
||||
#ifdef OTG_BUILD
|
||||
#define OTG_STATUS_SIZE (2)
|
||||
#endif
|
||||
#define INTERFACE_STATUS_SIZE (2)
|
||||
|
||||
#define CONFIG_SIZE (1)
|
||||
#define INTERFACE_SIZE (1)
|
||||
#define FRAME_SIZE (2)
|
||||
#define ENDP_STATUS_SIZE (2)
|
||||
|
||||
#ifdef OTG_BUILD
|
||||
#define DEVICE_SET_FEATURE_B_HNP_ENABLE (0x0003) /* B HNP enable SET/CLEAR feature value */
|
||||
#define DEVICE_SET_FEATURE_A_HNP_SUPPORT (0x0004) /* A HNP support SET/CLEAR feature value */
|
||||
#endif
|
||||
|
||||
/* Standard Feature Selectors */
|
||||
#define DEVICE_FEATURE_REMOTE_WAKEUP (0x0001)
|
||||
#define DEVICE_FEATURE_TEST_MODE (0x0002)
|
||||
#define DEVICE_SET_FEATURE_MASK ((uint_16)((1<<(DEVICE_FEATURE_REMOTE_WAKEUP)) | (1<<(DEVICE_FEATURE_TEST_MODE))))
|
||||
#define DEVICE_CLEAR_FEATURE_MASK ((uint_16)(1<<(DEVICE_FEATURE_REMOTE_WAKEUP)))
|
||||
|
||||
|
||||
|
||||
#define REPORT_DESCRIPTOR_TYPE (0x22)
|
||||
#define STRING_DESCRIPTOR_TYPE (0x03)
|
||||
|
||||
/* masks and values for provides of Get Desc information */
|
||||
#define USB_REQUEST_SRC_MASK (0x03)
|
||||
#define USB_REQUEST_SRC_DEVICE (0x00)
|
||||
#define USB_REQUEST_SRC_INTERFACE (0x01)
|
||||
#define USB_REQUEST_SRC_ENDPOINT (0x02)
|
||||
|
||||
#define USB_SET_REQUEST_MASK (0x02)
|
||||
|
||||
/* wIndex values for GET_Status */
|
||||
#ifdef OTG_BUILD
|
||||
#define USB_WINDEX_OTG_STATUS_SEL (0xF000)
|
||||
#endif
|
||||
|
||||
/* for transfer direction check */
|
||||
#define USB_DATA_TO_HOST (0x80)
|
||||
#define USB_DATA_TO_DEVICE (0x00)
|
||||
#define USB_DATA_DIREC_MASK (0x80)
|
||||
|
||||
#define USB_uint_16_low(x) ((uint_8)x) /* lsb byte */
|
||||
#define USB_uint_16_high(x) ((uint_8)(x>>8)) /* msb byte */
|
||||
|
||||
#ifdef CPU_LITTLE_ENDIAN /* << EST: defined by Processor Expert CPU.h for Kinetis devices */
|
||||
#ifndef LITTLE_ENDIAN /* might be defined already on the compiler command line? */
|
||||
#define LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if(defined LITTLE_ENDIAN)
|
||||
#define BYTE_SWAP16(a) (a)
|
||||
#else
|
||||
#define BYTE_SWAP16(a) (uint_16)((((uint_16)(a)&0xFF00)>>8) | \
|
||||
(((uint_16)(a)&0x00FF)<<8))
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern boolean USB_Frame_Remote_Wakeup(uint_8 controller_ID);
|
||||
|
||||
#define USB_Frame_Remote_Wakeup USB_Desc_Remote_Wakeup
|
||||
|
||||
typedef struct _app_data_struct
|
||||
{
|
||||
uint_8_ptr data_ptr; /* pointer to buffer */
|
||||
USB_PACKET_SIZE data_size; /* buffer size of endpoint */
|
||||
}APP_DATA_STRUCT;
|
||||
|
||||
extern uint_8 USB_Framework_Init (
|
||||
uint_8 controller_ID,
|
||||
USB_CLASS_CALLBACK callback,
|
||||
USB_REQ_FUNC other_req_callback
|
||||
);
|
||||
|
||||
extern uint_8 USB_Framework_DeInit
|
||||
(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern uint_8 USB_Framework_Reset (
|
||||
uint_8 controller_ID
|
||||
);
|
||||
#ifdef DELAYED_PROCESSING
|
||||
extern void USB_Framework_Periodic_Task(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_user_config.h << EST 'user_config.h' conflicts with MQX Lite
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains User Modifiable Macros for Virtual COM Loopback
|
||||
* Application
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if 0 /* << EST */
|
||||
#include "derivative.h"
|
||||
|
||||
#if (defined MCU_MK70F12) || (defined __MCF52277_H__)
|
||||
#define HIGH_SPEED_DEVICE (0)
|
||||
#else
|
||||
#define HIGH_SPEED_DEVICE (0)
|
||||
#endif
|
||||
|
||||
#if (defined MCU_MK20D7) || (defined MCU_MK40D7)
|
||||
#define MCGOUTCLK_72_MHZ
|
||||
#endif
|
||||
|
||||
#if ((defined __MK_xxx_H__)||(defined MCU_mcf51jf128))
|
||||
#define KEY_PRESS_SIM_TMR_INTERVAL (1000) /* 2s between simulated key press events */
|
||||
#else
|
||||
#ifdef __MCF52277_H__
|
||||
#define BUTTON_PRESS_SIMULATION (1)
|
||||
#define KEY_PRESS_SIM_TMR_INTERVAL (2000) /* 2s between simulated key press events */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include "FSL_USB_Stack_Config.h"
|
||||
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#define HIGH_SPEED_DEVICE (0)
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
Below two MACROS are required for Virtual COM Loopback
|
||||
Application to execute
|
||||
*/
|
||||
#define LONG_SEND_TRANSACTION /* support to send large data pkts */
|
||||
#define LONG_RECEIVE_TRANSACTION /* support to receive large data pkts */
|
||||
#ifndef _MC9S08JS16_H
|
||||
#define USB_OUT_PKT_SIZE 32 /* Define the maximum data length received from the host */
|
||||
#else
|
||||
#define USB_OUT_PKT_SIZE 16 /* Define the maximum data length received from the host */
|
||||
#endif
|
||||
|
||||
/* User Defined MACRO to set number of Timer Objects */
|
||||
#define MAX_TIMER_OBJECTS 5
|
||||
|
||||
#if MAX_TIMER_OBJECTS
|
||||
/* When Enabled Timer Callback is invoked with an argument */
|
||||
#define TIMER_CALLBACK_ARG
|
||||
#undef TIMER_CALLBACK_ARG
|
||||
#endif
|
||||
|
||||
#if 0 /* << EST */
|
||||
#ifndef _MC9S08JS16_H
|
||||
#define USB_PACKET_SIZE uint_16 /* support 16/32 bit packet size */
|
||||
#else
|
||||
#define USB_PACKET_SIZE uint_8 /* support 8 bit packet size */
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#define USB_PACKET_SIZE uint_16 /* support 16/32 bit packet size */
|
||||
#endif
|
||||
|
||||
#if 0 /* << EST */
|
||||
#ifndef _MCF51JM128_H
|
||||
/* Use double buffered endpoints 5 & 6. To be only used with S08 cores */
|
||||
#define DOUBLE_BUFFERING_USED
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
/* Use double buffered endpoints 5 & 6. To be only used with S08 cores */
|
||||
#define DOUBLE_BUFFERING_USED
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file wdt_kinetis.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief This file contains the implementation of the Watchdog service routines on CFV2
|
||||
*****************************************************************************/
|
||||
|
||||
#include "types.h" /* User Defined Data Types */
|
||||
#include "hal/derivative.h" /* include peripheral declarations */
|
||||
#include "wdt_kinetis.h" /* own header with public declarations */
|
||||
|
||||
/*****************************************************************************/
|
||||
void Watchdog_Reset(void)
|
||||
{
|
||||
#if defined(MCU_MKL25Z4) || defined(MCU_MKL26Z4) || defined(MCU_MKL46Z4)
|
||||
(void)(RCM_SRS0 |= RCM_SRS0_WDOG_MASK);
|
||||
#else
|
||||
(void)(WDOG_REFRESH = 0xA602, WDOG_REFRESH = 0xB480);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file Wdt_kinetis.h
|
||||
*
|
||||
* @brief This is the header file for the Watchdog service routines on CFV2
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _WDT_KINETIS_
|
||||
#define _WDT_KINETIS_
|
||||
|
||||
/*****************************************************************************
|
||||
* Public functions
|
||||
*
|
||||
****************************************************************************/
|
||||
extern void Watchdog_Reset(void);
|
||||
|
||||
#endif /* _INIT_HW_ */
|
||||
Reference in New Issue
Block a user