Esempio n. 1
0
uint8_t Get_TLV_Interrupt (uint8_t tag) {
	uint8_t *pPDTAG;
	uint8_t bPDTAG_bytes;
	uint16_t count = 0;
	uint16_t pcount = 0;

	Get_TLV_Info (TLV_PDTAG, 0, &bPDTAG_bytes, (uint16_t **) &pPDTAG); // Get Peripheral data pointer

	// read memory configuration from TLV to get offset for Peripherals
	while (Get_TLV_Memory (count) ) {
		count++;
	}

	pcount = pPDTAG[count * 2 + 1];
	count++;                                     // inc count to first Periperal
	pPDTAG += (pcount + count) * 2;              // adjust point to first address of Peripheral
	count = 0;                                   // set counter back to 0

	// TLV access Function Call
	for (count = 0; count <= tag; count += 2) {
		if (pPDTAG[count] == 0) {
			return 0;    // Return 0: not found/end of table
		}

		if (count == tag) {
			return (pPDTAG[count]);    // Return found data
		}
	}

	return 0;                                    // Return 0: not found
}
Esempio n. 2
0
uint16_t Get_TLV_Peripheral (uint8_t tag, uint8_t instance) {
	uint8_t *pPDTAG;
	uint8_t bPDTAG_bytes;
	uint16_t count = 0;
	uint16_t pcount = 0;

	Get_TLV_Info (TLV_PDTAG, 0, &bPDTAG_bytes, (uint16_t **) &pPDTAG); // Get Peripheral data pointer

	// read memory configuration from TLV to get offset for Peripherals
	while (Get_TLV_Memory (count) ) {
		count++;
	}

	pcount = pPDTAG[count * 2 + 1];              // get number of Peripheral entries
	count++;                                     // inc count to first Periperal
	pPDTAG += count * 2;                         // adjust point to first address of Peripheral
	count = 0;                                   // set counter back to 0
	pcount *= 2;                                 // align pcount for work comparision

	// TLV access Function Call
	for (count = 0; count <= pcount; count += 2) {
		if (pPDTAG[count + 1] == tag) {            // test if required Peripheral is found
			if (instance > 0) {                       // test if required instance is found
				instance--;
			} else {
				return (pPDTAG[count] | pPDTAG[count + 1] << 8); // Return found data
			}
		}
	}

	return 0;                                    // Return 0: not found
}
Esempio n. 3
0
/**
  * Get Memory Info out of the TLV Table
  *
  * \param instance: Index of the Instance [0..]
  * \return Memory Data found
  */
uint16_t Get_TLV_Memory(uint8_t instance)
{
    uint8_t * pPDTAG;
    uint8_t bPDTAG_bytes;
    uint16_t count;

    instance *= 2;                               // set tag for word access comparison
    // TLV access Function Call
    Get_TLV_Info(TLV_PDTAG, 0, &bPDTAG_bytes, (uint16_t **) &pPDTAG); // Get Peripheral data pointer
    for(count=0;count<=instance;count+=2)
    {
      if (pPDTAG[count] == 0) return 0;          // Return 0 if end reached
      if (count == instance) return (pPDTAG[count] | pPDTAG[count+1]<<8);
    }
    return 0;                                    // Return 0: not found
}
Esempio n. 4
0
VOID USB_InitSerialStringDescriptor(VOID)
{
    BYTE i,j,hexValue;
    PBYTE pbSerNum;
    BYTE bBytes;

    j=1;                   // we start with second byte, first byte (lenght) will be filled later
    pbSerNum=0;
    abramSerialStringDescriptor[j++] = DESC_TYPE_STRING;

    // TLV access Function Call
    Get_TLV_Info(TLV_DIERECORD, 0, (uint8_t *)&bBytes, (uint16_t **)&pbSerNum); //The die record used for serial number
    if (bBytes == 0)    // no serial number available
    {
        // use 00 as serial number = no serial number available
        abramSerialStringDescriptor[0] = 4;      //length
        abramSerialStringDescriptor[j++] = 0;    // no serial number available
        abramSerialStringDescriptor[j++] = 0;    // no serial number available
    }
    else
    {
        for(i=0; (i<bBytes)&&(i<8); i++,pbSerNum++)
        {
            hexValue = (*pbSerNum & 0xF0)>> 4;
            if(hexValue < 10 ) abramSerialStringDescriptor[j++] = (hexValue + '0');
            else abramSerialStringDescriptor[j++] = (hexValue + 55);
            abramSerialStringDescriptor[j++] = 0x00;  // needed for UNI-Code

            hexValue = (*pbSerNum & 0x0F);
            if(hexValue < 10 ) abramSerialStringDescriptor[j++] = (hexValue + '0');
            else abramSerialStringDescriptor[j++] = (hexValue + 55);
            abramSerialStringDescriptor[j++] = 0x00;    // needed for UNI-Code
        }
        abramSerialStringDescriptor[0] = i*4 +2;        // calculate the length
    }
}