[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/pxa27x Flash.nc, NONE, 1.1 HPLUSBClientGPIO.nc, NONE, 1.1 PXA27Xdynqueue.c, NONE, 1.1 PXA27Xdynqueue.h, NONE, 1.1 PXA27XUDCRegAddrs.h, NONE, 1.1 PXA27XUSBClient.h, NONE, 1.1 PXA27XUSBClientC.nc, NONE, 1.1 PXA27XUSBClientM.nc, NONE, 1.1 PXA27XUSBdata.c, NONE, 1.1 ReceiveBData.nc, NONE, 1.1 SendJTPacket.nc, NONE, 1.1 UID.nc, NONE, 1.1

Josh jsherbach at users.sourceforge.net
Thu Aug 18 13:36:42 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23394

Added Files:
	Flash.nc HPLUSBClientGPIO.nc PXA27Xdynqueue.c PXA27Xdynqueue.h 
	PXA27XUDCRegAddrs.h PXA27XUSBClient.h PXA27XUSBClientC.nc 
	PXA27XUSBClientM.nc PXA27XUSBdata.c ReceiveBData.nc 
	SendJTPacket.nc UID.nc 
Log Message:
files for USBClient as well as interfaces for it, UID reading, and Flash write / erasing

--- NEW FILE: Flash.nc ---
/**
 * Interface for writing and erasing in flash memory
 */

interface Flash
{
  /**
   * Writes numBytes of the buffer data to the address in flash specified
   * by addr. If type is set to FLASH_NORMAL (0), this function will only set 
   * bits low for the bytes it is supposed to write to. If type is set to
   * FLASH_OVERWRITE (1), this function will simply overwrite the section of
   * flash from addr to addr + numBytes. If addr connot be written to for
   * any reason returns FAIL, otherwise returns SUCCESS.
   *
   * @returns SUCCESS or FAIL.
   */
  command result_t write(uint32_t addr, uint8_t* data, uint32_t numBytes,
			 uint8_t type);

  /**
   * Erases the block of flash that contains addr, setting all bits to 1.
   * If this function fails for any reason it will return FAIL, otherwise 
   * SUCCESS.
   *
   * @returns SUCCESS or FAIL.
   */
  command result_t erase(uint32_t addr);
}




--- NEW FILE: HPLUSBClientGPIO.nc ---
/*
 *
 * Routines that abstract the necessary GPIO operations for USBClient
 * controllers.
 *
 */

interface HPLUSBClientGPIO {

  /**
   * Initialization
   *
   * @return SUCCESS always.
   */
  
  async command result_t init();

  /**
   * Checks whether the device is connected to a USB host
   *
   * @return SUCCESS if connected, FAIL otherwise
   */

  async command result_t checkConnection();

}

--- NEW FILE: PXA27Xdynqueue.c ---
/*------------------------------------------------------------------*/
/* dynqueue.c                                                       */
/*------------------------------------------------------------------*/

#include "PXA27Xdynqueue.h"

#define MIN_PHYS_LENGTH 2

struct DynQueue_T
{
   int iLength;
   int iPhysLength;
   int index;
   const void **ppvQueue;
};

/*------------------------------------------------------------------*/

DynQueue DynQueue_new()

/* Return a new DynQueue. */

{
   DynQueue oDynQueue;

   oDynQueue = (DynQueue)malloc(sizeof(struct DynQueue_T));
   //assert(oDynQueue != NULL);
   if(oDynQueue == NULL)
	   return NULL;
   
   oDynQueue->iLength = 0;
   oDynQueue->iPhysLength = MIN_PHYS_LENGTH;
   oDynQueue->ppvQueue = 
      (const void**)calloc(oDynQueue->iPhysLength, sizeof(void*));
   //assert(oDynQueue->ppvQueue != NULL);
   if(oDynQueue->ppvQueue == NULL)
	   return NULL;

   oDynQueue->index = 0;
   return oDynQueue;
}

/*------------------------------------------------------------------*/

void DynQueue_free(DynQueue oDynQueue)

/* Free oDynQueue. */

{
   if (oDynQueue == NULL)
      return;
   
   free(oDynQueue->ppvQueue);
   free(oDynQueue);
}

/*------------------------------------------------------------------*/

int DynQueue_getLength(DynQueue oDynQueue)

/* Return the length of oDynQueue.*/

{
   //assert(oDynQueue != NULL);
   if(oDynQueue == NULL)
	   return 0;
   return oDynQueue->iLength;
}

/*------------------------------------------------------------------*/

void *DynQueue_peek(DynQueue oDynQueue)
/* Returns the first element of oDynQueue without removing it.*/
{
	//assert(oDynQueue != NULL);
	//assert(oDynQueue->iLength > 0);
	if(oDynQueue == NULL || oDynQueue->iLength <= 0)
		return NULL;
	return (void*)(oDynQueue->ppvQueue)[oDynQueue->index];
}

/*------------------------------------------------------------------*/

static void DynQueue_shiftgrow(DynQueue oDynQueue)

/* Shift the elements to the start of the array
	or double the physical length of oDynQueue. */

{
	//assert(oDynQueue != NULL);
	if(oDynQueue == NULL)
		return;
   //choosing to waste space over wasting time by not always shifting
	if(oDynQueue->index > 2 && oDynQueue->index > oDynQueue->iPhysLength / 8){
	   memcpy((void *)oDynQueue->ppvQueue, (void *)(oDynQueue->ppvQueue + oDynQueue->index), sizeof(void *) * oDynQueue->iLength);
	   oDynQueue->index = 0;
	}
   else{
	   oDynQueue->iPhysLength *= 2;
	   oDynQueue->ppvQueue =  (const void**)realloc(oDynQueue->ppvQueue, 
		   sizeof(void*) * oDynQueue->iPhysLength);
	   //assert(oDynQueue->ppvQueue != NULL);
   }
}

/*------------------------------------------------------------------*/

void DynQueue_enqueue(DynQueue oDynQueue, const void *pvItem)
/* Adds pvItem to oDynQueue.*/
{
   //assert(oDynQueue != NULL);
	if(oDynQueue == NULL)
		return;

   if (oDynQueue->iLength + oDynQueue->index == oDynQueue->iPhysLength)
      DynQueue_shiftgrow(oDynQueue);
   
   oDynQueue->ppvQueue[oDynQueue->index + oDynQueue->iLength] = pvItem;
   oDynQueue->iLength++;
}

/*------------------------------------------------------------------*/

void *DynQueue_dequeue(DynQueue oDynQueue)
/* Dequeues the first element of oDynQueue.*/
{
   const void *pvItem;

   //assert(oDynQueue != NULL);
   //assert(oDynQueue->iLength > 0);
	if(oDynQueue == NULL || oDynQueue->iLength <= 0)
		return NULL;

   pvItem = oDynQueue->ppvQueue[oDynQueue->index];
   oDynQueue->ppvQueue[oDynQueue->index] = NULL;
   
   oDynQueue->iLength--;
   oDynQueue->index++;
   return (void*)pvItem;
}

/*------------------------------------------------------------------*/

void DynQueue_push(DynQueue oDynQueue, const void *pvItem){
	//assert(oDynQueue != NULL);
	if(oDynQueue == NULL)
		return;

	if(oDynQueue->iLength == oDynQueue->iPhysLength) //if <- is true, then index == 0
		DynQueue_shiftgrow(oDynQueue);

	if(oDynQueue->index > 0)
		oDynQueue->index--;
	else//assumed index == 0
		memcpy((void *)(oDynQueue->ppvQueue + 1), (void *)oDynQueue->ppvQueue, sizeof(void *) * oDynQueue->iLength);
	oDynQueue->ppvQueue[oDynQueue->index] = pvItem;
}

--- NEW FILE: PXA27Xdynqueue.h ---
/*------------------------------------------------------------------*/
/* dynqueue.h                                                       */
/*------------------------------------------------------------------*/

#ifndef __PXA27Xdynqueue_H__
#define __PXA27Xdynqueue_H__

typedef struct DynQueue_T *DynQueue;
/* A DynQueue is an fifo queue whose length can expand dynamically. */

DynQueue DynQueue_new();
/* Return a new DynQueue. */

void DynQueue_free(DynQueue oDynQueue);
/* Free oDynQueue. */

int DynQueue_getLength(DynQueue oDynQueue);
/* Return the length of oDynQueue.*/

void *DynQueue_dequeue(DynQueue oDynQueue);
/* Dequeues the first element of oDynQueue.*/

void DynQueue_enqueue(DynQueue oDynQueue, const void *pvItem);
/* Adds pvItem to oDynQueue.*/

void *DynQueue_peek(DynQueue oDynQueue);
/* Returns the first element of oDynQueue without removing it.*/

void DynQueue_push(DynQueue oDynQueue, const void *pvItem);
/* Puts an item at the head of oDynQueue the queue.*/

#endif


--- NEW FILE: PXA27XUDCRegAddrs.h ---
#ifndef __UDCREGADDRS_H
#define __UDCREGADDRS_H

#define _udccr ((volatile unsigned long * const) 0x40600000)
#define _udcicr0 ((volatile unsigned long * const) 0x40600004)
#define _udcicr1 ((volatile unsigned long * const) 0x40600008)
#define _udcisr0 ((volatile unsigned long * const) 0x4060000C)
#define _udcisr1 ((volatile unsigned long * const) 0x40600010)
#define _udcfnr ((volatile unsigned long * const) 0x40600014)
#define _udcotgicr ((volatile unsigned long * const) 0x40600018)
#define _udcotgisr ((volatile unsigned long * const) 0x4060001C)
#define _up2ocr ((volatile unsigned long * const) 0x40600020)
#define _up3ocr ((volatile unsigned long * const) 0x40600024)
#define _udccsr0 ((volatile unsigned long * const) 0x40600100)
#define _udccsra ((volatile unsigned long * const) 0x40600104)
#define _udccsrb ((volatile unsigned long * const) 0x40600108)
#define _udccsrc ((volatile unsigned long * const) 0x4060010C)
#define _udccsrd ((volatile unsigned long * const) 0x40600110)
#define _udccsre ((volatile unsigned long * const) 0x40600114)
#define _udccsrf ((volatile unsigned long * const) 0x40600118)
#define _udccsrg ((volatile unsigned long * const) 0x4060011C)
#define _udccsrh ((volatile unsigned long * const) 0x40600120)
#define _udccsri ((volatile unsigned long * const) 0x40600124)
#define _udccsrj ((volatile unsigned long * const) 0x40600128)
#define _udccsrk ((volatile unsigned long * const) 0x4060012C)
#define _udccsrl ((volatile unsigned long * const) 0x40600130)
#define _udccsrm ((volatile unsigned long * const) 0x40600134)
#define _udccsrn ((volatile unsigned long * const) 0x40600138)
#define _udccsrp ((volatile unsigned long * const) 0x4060013C)
#define _udccsrq ((volatile unsigned long * const) 0x40600140)
#define _udccsrr ((volatile unsigned long * const) 0x40600144)
#define _udccsrs ((volatile unsigned long * const) 0x40600148)
#define _udccsrt ((volatile unsigned long * const) 0x4060014C)
#define _udccsru ((volatile unsigned long * const) 0x40600150)
#define _udccsrv ((volatile unsigned long * const) 0x40600154)
#define _udccsrw ((volatile unsigned long * const) 0x40600158)
#define _udccsrx ((volatile unsigned long * const) 0x4060015C)
#define _udcbcr0 ((volatile unsigned long * const) 0x40600200)
#define _udcbcra ((volatile unsigned long * const) 0x40600204)
#define _udcbcrb ((volatile unsigned long * const) 0x40600208)
#define _udcbcrc ((volatile unsigned long * const) 0x4060020C)
#define _udcbcrd ((volatile unsigned long * const) 0x40600210)
#define _udcbcre ((volatile unsigned long * const) 0x40600214)
#define _udcbcrf ((volatile unsigned long * const) 0x40600218)
#define _udcbcrg ((volatile unsigned long * const) 0x4060021C)
#define _udcbcrh ((volatile unsigned long * const) 0x40600220)
#define _udcbcri ((volatile unsigned long * const) 0x40600224)
#define _udcbcrj ((volatile unsigned long * const) 0x40600228)
#define _udcbcrk ((volatile unsigned long * const) 0x4060022C)
#define _udcbcrl ((volatile unsigned long * const) 0x40600230)
#define _udcbcrm ((volatile unsigned long * const) 0x40600234)
#define _udcbcrn ((volatile unsigned long * const) 0x40600238)
#define _udcbcrp ((volatile unsigned long * const) 0x4060023C)
#define _udcbcrq ((volatile unsigned long * const) 0x40600240)
#define _udcbcrr ((volatile unsigned long * const) 0x40600244)
#define _udcbcrs ((volatile unsigned long * const) 0x40600248)
#define _udcbcrt ((volatile unsigned long * const) 0x4060024C)
#define _udcbcru ((volatile unsigned long * const) 0x40600250)
#define _udcbcrv ((volatile unsigned long * const) 0x40600254)
#define _udcbcrw ((volatile unsigned long * const) 0x40600258)
#define _udcbcrx ((volatile unsigned long * const) 0x4060025C)
#define _udcdr0 ((volatile unsigned long * const) 0x40600300)
#define _udcdra ((volatile unsigned long * const) 0x40600304)
#define _udcdrb ((volatile unsigned long * const) 0x40600308)
#define _udcdrc ((volatile unsigned long * const) 0x4060030C)
#define _udcdrd ((volatile unsigned long * const) 0x40600310)
#define _udcdre ((volatile unsigned long * const) 0x40600314)
#define _udcdrf ((volatile unsigned long * const) 0x40600318)
#define _udcdrg ((volatile unsigned long * const) 0x4060031C)
#define _udcdrh ((volatile unsigned long * const) 0x40600320)
#define _udcdri ((volatile unsigned long * const) 0x40600324)
#define _udcdrj ((volatile unsigned long * const) 0x40600328)
#define _udcdrk ((volatile unsigned long * const) 0x4060032C)
#define _udcdrl ((volatile unsigned long * const) 0x40600330)
#define _udcdrm ((volatile unsigned long * const) 0x40600334)
#define _udcdrn ((volatile unsigned long * const) 0x40600338)
#define _udcdrp ((volatile unsigned long * const) 0x4060033C)
#define _udcdrq ((volatile unsigned long * const) 0x40600340)
#define _udcdrr ((volatile unsigned long * const) 0x40600344)
#define _udcdrs ((volatile unsigned long * const) 0x40600348)
#define _udcdrt ((volatile unsigned long * const) 0x4060034C)
#define _udcdru ((volatile unsigned long * const) 0x40600350)
#define _udcdrv ((volatile unsigned long * const) 0x40600354)
#define _udcdrw ((volatile unsigned long * const) 0x40600358)
#define _udcdrx ((volatile unsigned long * const) 0x4060035C)
#define _udccra ((volatile unsigned long * const) 0x40600404)
#define _udccrb ((volatile unsigned long * const) 0x40600408)
#define _udccrc ((volatile unsigned long * const) 0x4060040C)
#define _udccrd ((volatile unsigned long * const) 0x40600410)
#define _udccre ((volatile unsigned long * const) 0x40600414)
#define _udccrf ((volatile unsigned long * const) 0x40600418)
#define _udccrg ((volatile unsigned long * const) 0x4060041C)
#define _udccrh ((volatile unsigned long * const) 0x40600420)
#define _udccri ((volatile unsigned long * const) 0x40600424)
#define _udccrj ((volatile unsigned long * const) 0x40600428)
#define _udccrk ((volatile unsigned long * const) 0x4060042C)
#define _udccrl ((volatile unsigned long * const) 0x40600430)
#define _udccrm ((volatile unsigned long * const) 0x40600434)
#define _udccrn ((volatile unsigned long * const) 0x40600438)
#define _udccrp ((volatile unsigned long * const) 0x4060043C)
#define _udccrq ((volatile unsigned long * const) 0x40600440)
#define _udccrr ((volatile unsigned long * const) 0x40600444)
#define _udccrs ((volatile unsigned long * const) 0x40600448)
#define _udccrt ((volatile unsigned long * const) 0x4060044C)
#define _udccru ((volatile unsigned long * const) 0x40600450)
#define _udccrv ((volatile unsigned long * const) 0x40600454)
#define _udccrw ((volatile unsigned long * const) 0x40600458)
#define _udccrx ((volatile unsigned long * const) 0x4060045C)

#endif

--- NEW FILE: PXA27XUSBClient.h ---
#ifndef __PXA27XUSBCLIENT_H__
#define __PXA27XUSBCLIENT_H__

#define DEBUG 0
#define ASSERT 0

#define USBPOWER 125 // 1/2 of the actually requested power, so 250 ma

#define _PXAREG8(_addr)	(*((volatile uint8_t *)(_addr)))
#define _PXAREG16(_addr)	(*((volatile uint16_t *)(_addr)))

#define _UDC_bit(_udc)  (1 << ((_udc) & 0x1f))


#define USB_ENDPOINT_IN 7

// These define offsets within certain register bitmaps

//UDCCR
#define UDCCR_UDE 0
#define UDCCR_EMCE 3
#define UDCCR_SMAC 4
#define UDCCR_ACN 11


//UDCCSR0
#define UDCCSR0_ACM 9
#define UDCCSR0_AREN 8
#define UDCCSR0_SA 7
#define UDCCSR0_FST 5
#define UDCCSR0_DME 3
#define UDCCSR0_FTF 2
#define UDCCSR0_IPR 1
#define UDCCSR0_OPC 0

//UDCCSRAX
#define UDCCSRAX_DPE 9
#define UDCCSRAX_FEF 8
#define UDCCSRAX_SP 7
#define UDCCSRAX_BNEBNF 6
#define UDCCSRAX_FST 5
#define UDCCSRAX_SST 4
#define UDCCSRAX_DME 3
#define UDCCSRAX_TRN 2
#define UDCCSRAX_PC 1
#define UDCCSRAX_FS 0

//UDCCRAX
#define UDCCRAX_CN 25
#define UDCCRAX_IN 22
#define UDCCRAX_AISN 19
#define UDCCRAX_EN 15
#define UDCCRAX_ET 13
#define UDCCRAX_ED 12
#define UDCCRAX_MPS 2
#define UDCCRAX_DE 1
#define UDCCRAX_EE 0

//Interrupts
#define INT_IRCC 31 // SET_CONFIGURATION or SET_INTERRUPT command received
#define INT_IRSOF 30 // Start-of-frame received
#define INT_IRRU 29 // Resume detected
#define INT_IRSU 28 // Suspend detected
#define INT_IRRS 27 // USB reset detected

#define INT_END0 0 //Endpoint 0 packet complete bit
#define INT_ENDA 2 //Endpoint A packet complete bit
#define INT_ENDB 4 //Endpoint B packet complete bit

// USB control Setup request, Standard
#define USB_GETDESCRIPTOR 0x06
#define USB_SETCONFIGURATION 0x09

// USB control Setup request, Hid

#define USB_HID_GETREPORT 0x01
#define USB_HID_GETIDLE 0x02
#define USB_HID_GETPROTOCOL 0x03
#define USB_HID_SETREPORT 0x09
#define USB_HID_SETIDLE 0x0A
#define USB_HID_SETPROTOCOL 0x0B


// USB Descriptors
#define USB_DESCRIPTOR_DEVICE 0x01
#define USB_DESCRIPTOR_CONFIGURATION 0x02
#define USB_DESCRIPTOR_STRING 0x03
#define USB_DESCRIPTOR_INTERFACE 0x04
#define USB_DESCRIPTOR_ENDPOINT 0x05
#define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06
#define USB_DESCRIPTOR_OTHER_SPEED_CONFIG 0x07
#define USB_DESCRIPTOR_INTERFACE_POWER 0x08
#define USB_DESCRIPTOR_HID 0x21
#define USB_DESCRIPTOR_HID_REPORT 0x22

//Sending Data states, defined as bit flags
#define INPROGRESS 0
#define MIDSEND 1

//States, defined as full numbers, not flags
//0 is nothing
#define POWERED 1 //means attached and powered by the USB host
#define DEFAULT 2 //finished resetting
#define CONFIGURED 3 //ready to be used for communication

#define isFlagged(_BITFIELD, _FLAG) (((_BITFIELD) & (_FLAG)) != 0)
#define getByte(_WORD, _BYTE) ((((_WORD) >> (((_BYTE) & 0x03) * 8))) & 0xFF)
#define getBit(_BITFIELD, _BIT) (((_BITFIELD) >> ((_BIT) & 0x1F)) & 0x01)

#define STRINGS_USED 3

//Interfaces used
#define SENDVARLENPACKET 0
#define SENDJTPACKET 1
#define SENDBAREMSG 2


/*JT protocol numbers; NOTE: some of the constants 
are different between the client (mote) and host (pc) software (namely, 
the byte positions)*/

#define IMOTE_HID_REPORT 1
#define IMOTE_HID_TYPE_COUNT 4

//Imote2 HID report, byte positions
#define IMOTE_HID_TYPE 0
#define IMOTE_HID_NI 1
//Imote2 HID report, type byte,  bit positions
#define IMOTE_HID_TYPE_CL 0
#define IMOTE_HID_TYPE_L 2
#define IMOTE_HID_TYPE_H 4
#define IMOTE_HID_TYPE_MSC 5
//Imote2 HID report, type byte, L defintions
#define IMOTE_HID_TYPE_L_BYTE 0
#define IMOTE_HID_TYPE_L_SHORT 1
#define IMOTE_HID_TYPE_L_INT 2
//Imote2 HID report, L sizes
#define IMOTE_HID_TYPE_L_BYTE_SIZE 15871
#define IMOTE_HID_TYPE_L_SHORT_SIZE 3997695
#define IMOTE_HID_TYPE_L_INT_SIZE 0xFFFFFFFF
//Imote2 HID report, type byte, CL defintions
#define IMOTE_HID_TYPE_CL_GENERAL 0
#define IMOTE_HID_TYPE_CL_BINARY 1
#define IMOTE_HID_TYPE_CL_RPACKET 2
#define IMOTE_HID_TYPE_CL_BLUSH 3
//Imote2 HID report, type byte, MSC definitions
#define IMOTE_HID_TYPE_MSC_DEFAULT 0
#define IMOTE_HID_TYPE_MSC_BLOADER 1
//Imote2 HID report, max packet data sizes
#define IMOTE_HID_BYTE_MAXPACKETDATA 62
#define IMOTE_HID_SHORT_MAXPACKETDATA 61
#define IMOTE_HID_INT_MAXPACKETDATA 59

#endif

--- NEW FILE: PXA27XUSBClientC.nc ---
#include "PXA27XUSBClient.h"

configuration PXA27XUSBClientC {
  provides{
    interface SendVarLenPacket;
    interface SendJTPacket;
    interface ReceiveData;
    interface ReceiveMsg;
    interface ReceiveBData;
    interface BareSendMsg;
  }
  uses{
    interface UID;
    interface PXA27XGPIOInt;
    interface HPLUSBClientGPIO;
  }
}
implementation {
  components Main, PXA27XUSBClientM, PXA27XInterruptM;
  
  SendVarLenPacket = PXA27XUSBClientM;
  SendJTPacket = PXA27XUSBClientM;
  BareSendMsg = PXA27XUSBClientM;
  ReceiveData = PXA27XUSBClientM;
  ReceiveMsg = PXA27XUSBClientM;
  ReceiveBData = PXA27XUSBClientM;
  
  Main.StdControl -> PXA27XUSBClientM;
  
  PXA27XUSBClientM.USBInterrupt -> PXA27XInterruptM.PXA27XIrq[PPID_USBC];
  PXA27XUSBClientM.USBAttached = PXA27XGPIOInt;
  PXA27XUSBClientM = UID;
  PXA27XUSBClientM = HPLUSBClientGPIO;
}

--- NEW FILE: PXA27XUSBClientM.nc ---
#include "PXA27XUSBClient.h"
#include "PXA27XUDCRegAddrs.h"

module PXA27XUSBClientM {
  provides {
    interface StdControl as Control;
    interface ReceiveData; /* Type is
			      IMOTE_HID_TYPE_CL_BLUSH or
			      IMOTE_HID_TYPE_CL_GENERAL.*/
    interface ReceiveMsg;  /* Type is 
			      IMOTE_HID_TYPE_CL_RPACKET.*/
    interface ReceiveBData;/* Type is 
			      IMOTE_HID_TYPE_CL_BINARY.*/
    
    interface SendVarLenPacket;/* Type is assumed to be 
				  IMOTE_HID_TYPE_CL_BLUSH.*/
    interface SendJTPacket;
    interface BareSendMsg; /* Type is assumed to be
			      IMOTE_HID_TYPE_CL_RPACKET */
[...1309 lines suppressed...]
       OutStream[i].endpointDR = NULL;
       OutStream[i].src = NULL;
       OutStream[i].status = 0;
       OutStream[i].type = 0;
       OutStream[i].index = 0;
       OutStream[i].n = 0;
       OutStream[i].len = 0;
       OutPaused = 0;
     }
     if(isFlagged(*(_udcdrb - _udcdr0 + _udccsr0), _UDC_bit(UDCCSRAX_PC)))
       _PXAREG(_udcdrb - _udcdr0 + _udccsr0) |= _UDC_bit(UDCCSRAX_PC);
     
   }
 }
 
 void clearOutQueue(){
   while(DynQueue_getLength(OutQueue) > 0)
     free((uint8_t *)DynQueue_dequeue(OutQueue));
 } 
}

--- NEW FILE: PXA27XUSBdata.c ---
#ifndef __USBDATA_C
#define __USBDATA_C

typedef struct __USBdata{
  volatile unsigned long *endpointDR;
  uint32_t fifosize;
  uint8_t *src;
  uint32_t len;
  uint32_t tlen;
  uint32_t index;
  uint32_t pindex;
  uint32_t n;
  uint16_t status;
  uint8_t type;
  uint8_t source;
  uint8_t *param;
} USBdata_t;
typedef USBdata_t * USBdata;

union string_or_langid{
  uint16_t wLANGID;
  char *bString;
};

typedef struct __hid{
  uint16_t bcdHID;
  uint16_t wDescriptorLength;  
  uint8_t bCountryCode;
  uint8_t bNumDescriptors;
  uint8_t bDescriptorType;
} USBhid;

typedef struct __hidreport{
  uint16_t wLength;
  uint8_t *bString;
} USBhidReport;

typedef struct __string{
   uint8_t bLength;
   union string_or_langid uMisc;
 } __string_t;
typedef __string_t *USBstring;

typedef struct __endpoint{
   uint8_t bEndpointAddress;
   uint8_t bmAttributes;
   uint16_t wMaxPacketSize;
   uint8_t bInterval;
 } __endpoint_t;
typedef __endpoint_t *USBendpoint;

typedef struct __interface{
   uint8_t bInterfaceID;
   uint8_t bAlternateSetting;
   uint8_t bNumEndpoints;
   uint8_t bInterfaceClass;
   uint8_t bInterfaceSubclass;
   uint8_t bInterfaceProtocol;
   uint8_t iInterface;
   USBendpoint *oEndpoints;
 } __interface_t;
typedef __interface_t *USBinterface;

typedef struct __configuration{
   uint16_t wTotalLength;
   uint8_t bNumInterfaces;
   uint8_t bConfigurationID;
   uint8_t iConfiguration;
   uint8_t bmAttributes;
   uint8_t MaxPower;
   USBinterface *oInterfaces;
 } __configuration_t;
typedef __configuration_t *USBconfiguration;

typedef struct __device{
   uint16_t bcdUSB;
   uint8_t bDeviceClass;
   uint8_t bDeviceSubclass;
   uint8_t bDeviceProtocol;
   uint8_t bMaxPacketSize0;
   uint16_t idVendor;
   uint16_t idProduct;
   uint16_t bcdDevice;
   uint8_t iManufacturer;
   uint8_t iProduct;
   uint8_t iSerialNumber;
   uint8_t bNumConfigurations;
   USBconfiguration *oConfigurations;
 } USBdevice;

#endif

--- NEW FILE: ReceiveBData.nc ---
/**
 * Interface for receiving binary data.
 */

interface ReceiveBData
{ 
  event result_t receive(uint8_t* buffer, uint8_t numBytesRead, uint32_t i, uint32_t n);
}

--- NEW FILE: SendJTPacket.nc ---
/**
 * Interface for sending arbitrary streams of bytes using the JTrans protocol.
 */

interface SendJTPacket
{
  /**
   * Send numBytes bytes of the buffer data. Data type is specified by type as 
   * described by the JTrans protocol (b00 General, b01 Binary, b10 Radio
   * Packet, b11 BluSH). If device cannot send the data for any obvious
   * reason (eg when using USB, the device is not enumerated), returns FAIL,
   * otherwise, returns SUCCESS.
   *
   * @returns SUCCESS or FAIL.
   */
  command result_t send(uint8_t* data, uint32_t numBytes, uint8_t type);

  /**
   * Send request completed. The buffer sent, the type requested and success
   * (success is always SUCCESS).
   *
   * @return SUCCESS always.
   */
  event result_t sendDone(uint8_t* packet, uint8_t type, result_t success);
}




--- NEW FILE: UID.nc ---
  /*
   *
   * Routine to abstract retreiving the device's Unique Identifier
   *
   */

interface UID{
  /*
   *
   * @returns UID
   */

  async command uint32_t getUID();
}



More information about the Tinyos-beta-commits mailing list