Skip to content

Commit

Permalink
Fix ChibiOS usbcfg code on all STM32 targets (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Jun 6, 2018
1 parent 7102d30 commit 7b3ede6
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 121 deletions.
40 changes: 20 additions & 20 deletions targets/CMSIS-OS/ChibiOS/MBN_QUAIL/common/usbcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,6 @@ static const USBDescriptor vcom_strings[] = {
};


// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

// Convert Hex 32Bits value into char
// value: value to convert
// pbuf: pointer to the buffer
Expand All @@ -273,6 +254,25 @@ void IntToUnicode(uint32_t value , uint8_t *pbuf, uint8_t len)
}
}

// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

/*
* Handles the GET_DESCRIPTOR callback. All required descriptors must be
* handled here.
Expand All @@ -297,7 +297,7 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
{
// request is for serial number
// get it from the silicon unique ID
Get_SerialNum(&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
Get_SerialNum((uint8_t*)&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
}

return &vcom_strings[dindex];
Expand Down
40 changes: 20 additions & 20 deletions targets/CMSIS-OS/ChibiOS/NETDUINO3_WIFI/common/usbcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,6 @@ static const USBDescriptor vcom_strings[] = {
};


// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

// Convert Hex 32Bits value into char
// value: value to convert
// pbuf: pointer to the buffer
Expand All @@ -273,6 +254,25 @@ void IntToUnicode(uint32_t value , uint8_t *pbuf, uint8_t len)
}
}

// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

/*
* Handles the GET_DESCRIPTOR callback. All required descriptors must be
* handled here.
Expand All @@ -297,7 +297,7 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
{
// request is for serial number
// get it from the silicon unique ID
Get_SerialNum(&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
Get_SerialNum((uint8_t*)&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
}

return &vcom_strings[dindex];
Expand Down
40 changes: 20 additions & 20 deletions targets/CMSIS-OS/ChibiOS/ST_NUCLEO144_F746ZG/common/usbcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,6 @@ static const USBDescriptor vcom_strings[] = {
};


// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

// Convert Hex 32Bits value into char
// value: value to convert
// pbuf: pointer to the buffer
Expand All @@ -273,6 +254,25 @@ void IntToUnicode(uint32_t value , uint8_t *pbuf, uint8_t len)
}
}

// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

/*
* Handles the GET_DESCRIPTOR callback. All required descriptors must be
* handled here.
Expand All @@ -297,7 +297,7 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
{
// request is for serial number
// get it from the silicon unique ID
Get_SerialNum(&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
Get_SerialNum((uint8_t*)&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
}

return &vcom_strings[dindex];
Expand Down
40 changes: 20 additions & 20 deletions targets/CMSIS-OS/ChibiOS/ST_STM32F429I_DISCOVERY/common/usbcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,6 @@ static const USBDescriptor vcom_strings[] = {
};


// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

// Convert Hex 32Bits value into char
// value: value to convert
// pbuf: pointer to the buffer
Expand All @@ -273,6 +254,25 @@ void IntToUnicode(uint32_t value , uint8_t *pbuf, uint8_t len)
}
}

// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

/*
* Handles the GET_DESCRIPTOR callback. All required descriptors must be
* handled here.
Expand All @@ -297,7 +297,7 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
{
// request is for serial number
// get it from the silicon unique ID
Get_SerialNum(&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
Get_SerialNum((uint8_t*)&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
}

return &vcom_strings[dindex];
Expand Down
40 changes: 20 additions & 20 deletions targets/CMSIS-OS/ChibiOS/ST_STM32F4_DISCOVERY/common/usbcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,6 @@ static const USBDescriptor vcom_strings[] = {
};


// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

// Convert Hex 32Bits value into char
// value: value to convert
// pbuf: pointer to the buffer
Expand All @@ -273,6 +254,25 @@ void IntToUnicode(uint32_t value , uint8_t *pbuf, uint8_t len)
}
}

// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

/*
* Handles the GET_DESCRIPTOR callback. All required descriptors must be
* handled here.
Expand All @@ -297,7 +297,7 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
{
// request is for serial number
// get it from the silicon unique ID
Get_SerialNum(&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
Get_SerialNum((uint8_t*)&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
}

return &vcom_strings[dindex];
Expand Down
41 changes: 20 additions & 21 deletions targets/CMSIS-OS/ChibiOS/ST_STM32F769I_DISCOVERY/common/usbcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,26 +228,6 @@ static const USBDescriptor vcom_strings[] = {
{sizeof usb_serial_number, (uint8_t*)(&usb_serial_number)},
};


// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

// Convert Hex 32Bits value into char
// value: value to convert
// pbuf: pointer to the buffer
Expand All @@ -273,6 +253,25 @@ void IntToUnicode(uint32_t value , uint8_t *pbuf, uint8_t len)
}
}

// Create the serial number string descriptor
void Get_SerialNum(uint8_t* pbuf)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t*)DEVICE_ID1;
deviceserial1 = *(uint32_t*)DEVICE_ID2;
deviceserial2 = *(uint32_t*)DEVICE_ID3;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, pbuf, 8);
pbuf += 16;
IntToUnicode(deviceserial1, pbuf, 4);
}
}

/*
* Handles the GET_DESCRIPTOR callback. All required descriptors must be
* handled here.
Expand All @@ -297,7 +296,7 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
{
// request is for serial number
// get it from the silicon unique ID
Get_SerialNum(&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
Get_SerialNum((uint8_t*)&usb_serial_number.bPropertyData[INDEX_OF_WCHAR_FOR_UNIQUE_ID]);
}

return &vcom_strings[dindex];
Expand Down

0 comments on commit 7b3ede6

Please sign in to comment.