Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to C11, and use char16_t for UTF-16 strings #1010

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions records/tools/armcc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tool_specific:
- -O2
- -Ospace
- --gnu
- --c99
- --c11
- --asm
- --split_sections
- --interleave
Expand All @@ -37,7 +37,7 @@ tool_specific:
c_flags:
# uvision.uvproj.tmpl specifies:
# - O2, space
# - C99
# - C11
# - split sections
- --gnu
- --asm
Expand Down
3 changes: 1 addition & 2 deletions records/tools/armclang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ tool_specific:
- --target=arm-arm-none-eabi
- -Oz
- -g
- --std=c99
- --std=c11
- -fdata-sections
- -ffunction-sections
- -fno-builtin
- -fshort-enums
- -fshort-wchar
- -funsigned-char
- -masm=auto
- -nostdlib
Expand Down
3 changes: 1 addition & 2 deletions records/tools/gcc_arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ tool_specific:
- -Werror
- -ffunction-sections
- -fdata-sections
- -std=gnu99
- -fshort-wchar
- -std=gnu11
- -fno-common
- -ffreestanding
- -fverbose-asm
Expand Down
2 changes: 1 addition & 1 deletion records/tools/uvision.uvproj.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
<wLevel>0</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<uC99>2</uC99>
<useXO>0</useXO>
<VariousControls>
<MiscControls></MiscControls>
Expand Down
32 changes: 32 additions & 0 deletions source/daplink/uchar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @file uchar.h
* @brief Compatibility for libcs without uchar.h
*
* DAPLink Interface Firmware
* Copyright (c) 2023 Google LLC, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef DAPLINK_UCHAR_H
#define DAPLINK_UCHAR_H

#if __has_include_next(<uchar.h>)
#include_next <uchar.h>
#else
#include <stdint.h>
typedef uint16_t char16_t;
#endif

#endif
26 changes: 13 additions & 13 deletions source/hic_hal/atmel/sam3u2c/usb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@
// </e>
// </h>
#define USBD_STRDESC_LANGID 0x0409
#define USBD_STRDESC_MAN L"Arm"
#define USBD_STRDESC_MAN u"Arm"
#ifndef USB_PROD_STR
#define USBD_STRDESC_PROD L"DAPLink CMSIS-DAP"
#define USBD_STRDESC_PROD u"DAPLink CMSIS-DAP"
#else
#define _TOWIDE(x) L ## #x
#define _TOWIDE(x) u ## #x
#define TOWIDE(x) _TOWIDE(x)
#define USBD_STRDESC_PROD TOWIDE(USB_PROD_STR)
#endif
#define USBD_STRDESC_SER_ENABLE 1
#define USBD_STRDESC_SER L"0001A0000000"
#define USBD_STRDESC_SER u"0001A0000000"

// <e0> Class Support
// <i> Enables USB Device Class specific Requests
Expand Down Expand Up @@ -169,8 +169,8 @@
#define USBD_HID_HS_ENABLE 1
#define USBD_HID_HS_WMAXPACKETSIZE 64
#define USBD_HID_HS_BINTERVAL 1
#define USBD_HID_STRDESC L"CMSIS-DAP v1"
#define USBD_WEBUSB_STRDESC L"WebUSB: CMSIS-DAP"
#define USBD_HID_STRDESC u"CMSIS-DAP v1"
#define USBD_WEBUSB_STRDESC u"WebUSB: CMSIS-DAP"
#define USBD_HID_INREPORT_NUM 1
#define USBD_HID_OUTREPORT_NUM 1
#define USBD_HID_INREPORT_MAX_SZ 64
Expand Down Expand Up @@ -221,7 +221,7 @@
#define USBD_MSC_HS_ENABLE 1
#define USBD_MSC_HS_WMAXPACKETSIZE 512
#define USBD_MSC_HS_BINTERVAL 0
#define USBD_MSC_STRDESC L"USB_MSC"
#define USBD_MSC_STRDESC u"USB_MSC"
// Make sure changes to USBD_MSC_INQUIRY_DATA are coordinated with mbed-ls
// since this is used to detect DAPLink drives
#define USBD_MSC_INQUIRY_DATA "MBED " \
Expand Down Expand Up @@ -266,9 +266,9 @@
#define USBD_ADC_BINTERVAL 1
#define USBD_ADC_HS_ENABLE 0
#define USBD_ADC_HS_WMAXPACKETSIZE 64
#define USBD_ADC_CIF_STRDESC L"USB_ADC"
#define USBD_ADC_SIF1_STRDESC L"USB_ADC1"
#define USBD_ADC_SIF2_STRDESC L"USB_ADC2"
#define USBD_ADC_CIF_STRDESC u"USB_ADC"
#define USBD_ADC_SIF1_STRDESC u"USB_ADC1"
#define USBD_ADC_SIF2_STRDESC u"USB_ADC2"
#define USBD_ADC_BSUBFRAMESIZE 2
#define USBD_ADC_BBITRESOLUTION 16
#define USBD_ADC_TSAMFREQ 32000
Expand Down Expand Up @@ -349,8 +349,8 @@
#define USBD_CDC_ACM_HS_ENABLE1 1
#define USBD_CDC_ACM_HS_WMAXPACKETSIZE1 512
#define USBD_CDC_ACM_HS_BINTERVAL1 1
#define USBD_CDC_ACM_CIF_STRDESC L"mbed Serial Port"
#define USBD_CDC_ACM_DIF_STRDESC L"mbed Serial Port"
#define USBD_CDC_ACM_CIF_STRDESC u"mbed Serial Port"
#define USBD_CDC_ACM_DIF_STRDESC u"mbed Serial Port"
#define USBD_CDC_ACM_SENDBUF_SIZE USBD_CDC_ACM_HS_WMAXPACKETSIZE1
#define USBD_CDC_ACM_RECEIVEBUF_SIZE USBD_CDC_ACM_HS_WMAXPACKETSIZE1
#if (((USBD_CDC_ACM_HS_ENABLE1) && (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_HS_WMAXPACKETSIZE1)) || (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_WMAXPACKETSIZE1))
Expand Down Expand Up @@ -401,7 +401,7 @@
#define USBD_BULK_WMAXPACKETSIZE 64
#define USBD_BULK_HS_ENABLE 1
#define USBD_BULK_HS_WMAXPACKETSIZE 512
#define USBD_BULK_STRDESC L"CMSIS-DAP v2"
#define USBD_BULK_STRDESC u"CMSIS-DAP v2"


/* USB Device Calculations ---------------------------------------------------*/
Expand Down
26 changes: 13 additions & 13 deletions source/hic_hal/freescale/k20dx/usb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@
// </e>
// </h>
#define USBD_STRDESC_LANGID 0x0409
#define USBD_STRDESC_MAN L"Arm"
#define USBD_STRDESC_MAN u"Arm"
#ifndef USB_PROD_STR
#define USBD_STRDESC_PROD L"DAPLink CMSIS-DAP"
#define USBD_STRDESC_PROD u"DAPLink CMSIS-DAP"
#else
#define _TOWIDE(x) L ## #x
#define _TOWIDE(x) u ## #x
#define TOWIDE(x) _TOWIDE(x)
#define USBD_STRDESC_PROD TOWIDE(USB_PROD_STR)
#endif
#define USBD_STRDESC_SER_ENABLE 1
#define USBD_STRDESC_SER L"0001A0000000"
#define USBD_STRDESC_SER u"0001A0000000"

// <e0> Class Support
// <i> Enables USB Device Class specific Requests
Expand Down Expand Up @@ -169,8 +169,8 @@
#define USBD_HID_HS_ENABLE 0
#define USBD_HID_HS_WMAXPACKETSIZE 64
#define USBD_HID_HS_BINTERVAL 6
#define USBD_HID_STRDESC L"CMSIS-DAP v1"
#define USBD_WEBUSB_STRDESC L"WebUSB: CMSIS-DAP"
#define USBD_HID_STRDESC u"CMSIS-DAP v1"
#define USBD_WEBUSB_STRDESC u"WebUSB: CMSIS-DAP"
#define USBD_HID_INREPORT_NUM 1
#define USBD_HID_OUTREPORT_NUM 1
#define USBD_HID_INREPORT_MAX_SZ 64
Expand Down Expand Up @@ -220,7 +220,7 @@
#define USBD_MSC_HS_ENABLE 0
#define USBD_MSC_HS_WMAXPACKETSIZE 512
#define USBD_MSC_HS_BINTERVAL 0
#define USBD_MSC_STRDESC L"USB_MSC"
#define USBD_MSC_STRDESC u"USB_MSC"
// Make sure changes to USBD_MSC_INQUIRY_DATA are coordinated with mbed-ls
// since this is used to detect DAPLink drives
#define USBD_MSC_INQUIRY_DATA "MBED " \
Expand Down Expand Up @@ -265,9 +265,9 @@
#define USBD_ADC_BINTERVAL 1
#define USBD_ADC_HS_ENABLE 0
#define USBD_ADC_HS_WMAXPACKETSIZE 64
#define USBD_ADC_CIF_STRDESC L"USB_ADC"
#define USBD_ADC_SIF1_STRDESC L"USB_ADC1"
#define USBD_ADC_SIF2_STRDESC L"USB_ADC2"
#define USBD_ADC_CIF_STRDESC u"USB_ADC"
#define USBD_ADC_SIF1_STRDESC u"USB_ADC1"
#define USBD_ADC_SIF2_STRDESC u"USB_ADC2"
#define USBD_ADC_BSUBFRAMESIZE 2
#define USBD_ADC_BBITRESOLUTION 16
#define USBD_ADC_TSAMFREQ 32000
Expand Down Expand Up @@ -347,8 +347,8 @@
#define USBD_CDC_ACM_HS_ENABLE1 0
#define USBD_CDC_ACM_HS_WMAXPACKETSIZE1 64
#define USBD_CDC_ACM_HS_BINTERVAL1 0
#define USBD_CDC_ACM_CIF_STRDESC L"mbed Serial Port"
#define USBD_CDC_ACM_DIF_STRDESC L"mbed Serial Port"
#define USBD_CDC_ACM_CIF_STRDESC u"mbed Serial Port"
#define USBD_CDC_ACM_DIF_STRDESC u"mbed Serial Port"
#define USBD_CDC_ACM_SENDBUF_SIZE 64
#define USBD_CDC_ACM_RECEIVEBUF_SIZE 64
#if (((USBD_CDC_ACM_HS_ENABLE1) && (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_HS_WMAXPACKETSIZE1)) || (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_WMAXPACKETSIZE1))
Expand Down Expand Up @@ -399,7 +399,7 @@
#define USBD_BULK_WMAXPACKETSIZE 64
#define USBD_BULK_HS_ENABLE 0
#define USBD_BULK_HS_WMAXPACKETSIZE 512
#define USBD_BULK_STRDESC L"CMSIS-DAP v2"
#define USBD_BULK_STRDESC u"CMSIS-DAP v2"


/* USB Device Calculations ---------------------------------------------------*/
Expand Down
26 changes: 13 additions & 13 deletions source/hic_hal/freescale/k26f/usb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@
// </e>
// </h>
#define USBD_STRDESC_LANGID 0x0409
#define USBD_STRDESC_MAN L"Arm"
#define USBD_STRDESC_MAN u"Arm"
#ifndef USB_PROD_STR
#define USBD_STRDESC_PROD L"DAPLink CMSIS-DAP"
#define USBD_STRDESC_PROD u"DAPLink CMSIS-DAP"
#else
#define _TOWIDE(x) L ## #x
#define _TOWIDE(x) u ## #x
#define TOWIDE(x) _TOWIDE(x)
#define USBD_STRDESC_PROD TOWIDE(USB_PROD_STR)
#endif
#define USBD_STRDESC_SER_ENABLE 1
#define USBD_STRDESC_SER L"0001A0000000"
#define USBD_STRDESC_SER u"0001A0000000"

// <e0> Class Support
// <i> Enables USB Device Class specific Requests
Expand Down Expand Up @@ -178,8 +178,8 @@
#define USBD_HID_HS_ENABLE 1
#define USBD_HID_HS_WMAXPACKETSIZE 64 //| (2<<11)
#define USBD_HID_HS_BINTERVAL 1
#define USBD_HID_STRDESC L"CMSIS-DAP v1"
#define USBD_WEBUSB_STRDESC L"WebUSB: CMSIS-DAP"
#define USBD_HID_STRDESC u"CMSIS-DAP v1"
#define USBD_WEBUSB_STRDESC u"WebUSB: CMSIS-DAP"
#define USBD_HID_INREPORT_NUM 1
#define USBD_HID_OUTREPORT_NUM 1
#define USBD_HID_INREPORT_MAX_SZ 64
Expand Down Expand Up @@ -229,7 +229,7 @@
#define USBD_MSC_HS_ENABLE 1
#define USBD_MSC_HS_WMAXPACKETSIZE 512
#define USBD_MSC_HS_BINTERVAL 0
#define USBD_MSC_STRDESC L"USB_MSC"
#define USBD_MSC_STRDESC u"USB_MSC"
// Make sure changes to USBD_MSC_INQUIRY_DATA are coordinated with mbed-ls
// since this is used to detect DAPLink drives
#define USBD_MSC_INQUIRY_DATA "MBED " \
Expand Down Expand Up @@ -274,9 +274,9 @@
#define USBD_ADC_BINTERVAL 1
#define USBD_ADC_HS_ENABLE 0
#define USBD_ADC_HS_WMAXPACKETSIZE 64
#define USBD_ADC_CIF_STRDESC L"USB_ADC"
#define USBD_ADC_SIF1_STRDESC L"USB_ADC1"
#define USBD_ADC_SIF2_STRDESC L"USB_ADC2"
#define USBD_ADC_CIF_STRDESC u"USB_ADC"
#define USBD_ADC_SIF1_STRDESC u"USB_ADC1"
#define USBD_ADC_SIF2_STRDESC u"USB_ADC2"
#define USBD_ADC_BSUBFRAMESIZE 2
#define USBD_ADC_BBITRESOLUTION 16
#define USBD_ADC_TSAMFREQ 32000
Expand Down Expand Up @@ -356,8 +356,8 @@
#define USBD_CDC_ACM_HS_ENABLE1 1
#define USBD_CDC_ACM_HS_WMAXPACKETSIZE1 512
#define USBD_CDC_ACM_HS_BINTERVAL1 1
#define USBD_CDC_ACM_CIF_STRDESC L"mbed Serial Port"
#define USBD_CDC_ACM_DIF_STRDESC L"mbed Serial Port"
#define USBD_CDC_ACM_CIF_STRDESC u"mbed Serial Port"
#define USBD_CDC_ACM_DIF_STRDESC u"mbed Serial Port"
#define USBD_CDC_ACM_SENDBUF_SIZE USBD_CDC_ACM_HS_WMAXPACKETSIZE1
#define USBD_CDC_ACM_RECEIVEBUF_SIZE USBD_CDC_ACM_HS_WMAXPACKETSIZE1
#if (((USBD_CDC_ACM_HS_ENABLE1) && (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_HS_WMAXPACKETSIZE1)) || (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_WMAXPACKETSIZE1))
Expand Down Expand Up @@ -408,7 +408,7 @@
#define USBD_BULK_WMAXPACKETSIZE 64
#define USBD_BULK_HS_ENABLE 1
#define USBD_BULK_HS_WMAXPACKETSIZE 512
#define USBD_BULK_STRDESC L"CMSIS-DAP v2"
#define USBD_BULK_STRDESC u"CMSIS-DAP v2"


/* USB Device Calculations ---------------------------------------------------*/
Expand Down
26 changes: 13 additions & 13 deletions source/hic_hal/freescale/kl26z/usb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@
// </e>
// </h>
#define USBD_STRDESC_LANGID 0x0409
#define USBD_STRDESC_MAN L"Arm"
#define USBD_STRDESC_MAN u"Arm"
#ifndef USB_PROD_STR
#define USBD_STRDESC_PROD L"DAPLink CMSIS-DAP"
#define USBD_STRDESC_PROD u"DAPLink CMSIS-DAP"
#else
#define _TOWIDE(x) L ## #x
#define _TOWIDE(x) u ## #x
#define TOWIDE(x) _TOWIDE(x)
#define USBD_STRDESC_PROD TOWIDE(USB_PROD_STR)
#endif
#define USBD_STRDESC_SER_ENABLE 1
#define USBD_STRDESC_SER L"0001A0000000"
#define USBD_STRDESC_SER u"0001A0000000"

// <e0> Class Support
// <i> Enables USB Device Class specific Requests
Expand Down Expand Up @@ -169,8 +169,8 @@
#define USBD_HID_HS_ENABLE 0
#define USBD_HID_HS_WMAXPACKETSIZE 64
#define USBD_HID_HS_BINTERVAL 6
#define USBD_HID_STRDESC L"CMSIS-DAP v1"
#define USBD_WEBUSB_STRDESC L"WebUSB: CMSIS-DAP"
#define USBD_HID_STRDESC u"CMSIS-DAP v1"
#define USBD_WEBUSB_STRDESC u"WebUSB: CMSIS-DAP"
#define USBD_HID_INREPORT_NUM 1
#define USBD_HID_OUTREPORT_NUM 1
#define USBD_HID_INREPORT_MAX_SZ 64
Expand Down Expand Up @@ -220,7 +220,7 @@
#define USBD_MSC_HS_ENABLE 0
#define USBD_MSC_HS_WMAXPACKETSIZE 512
#define USBD_MSC_HS_BINTERVAL 0
#define USBD_MSC_STRDESC L"USB_MSC"
#define USBD_MSC_STRDESC u"USB_MSC"
// Make sure changes to USBD_MSC_INQUIRY_DATA are coordinated with mbed-ls
// since this is used to detect DAPLink drives
#define USBD_MSC_INQUIRY_DATA "MBED " \
Expand Down Expand Up @@ -265,9 +265,9 @@
#define USBD_ADC_BINTERVAL 1
#define USBD_ADC_HS_ENABLE 0
#define USBD_ADC_HS_WMAXPACKETSIZE 64
#define USBD_ADC_CIF_STRDESC L"USB_ADC"
#define USBD_ADC_SIF1_STRDESC L"USB_ADC1"
#define USBD_ADC_SIF2_STRDESC L"USB_ADC2"
#define USBD_ADC_CIF_STRDESC u"USB_ADC"
#define USBD_ADC_SIF1_STRDESC u"USB_ADC1"
#define USBD_ADC_SIF2_STRDESC u"USB_ADC2"
#define USBD_ADC_BSUBFRAMESIZE 2
#define USBD_ADC_BBITRESOLUTION 16
#define USBD_ADC_TSAMFREQ 32000
Expand Down Expand Up @@ -347,8 +347,8 @@
#define USBD_CDC_ACM_HS_ENABLE1 0
#define USBD_CDC_ACM_HS_WMAXPACKETSIZE1 64
#define USBD_CDC_ACM_HS_BINTERVAL1 0
#define USBD_CDC_ACM_CIF_STRDESC L"mbed Serial Port"
#define USBD_CDC_ACM_DIF_STRDESC L"mbed Serial Port"
#define USBD_CDC_ACM_CIF_STRDESC u"mbed Serial Port"
#define USBD_CDC_ACM_DIF_STRDESC u"mbed Serial Port"
#define USBD_CDC_ACM_SENDBUF_SIZE 64
#define USBD_CDC_ACM_RECEIVEBUF_SIZE 64
#if (((USBD_CDC_ACM_HS_ENABLE1) && (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_HS_WMAXPACKETSIZE1)) || (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_WMAXPACKETSIZE1))
Expand Down Expand Up @@ -399,7 +399,7 @@
#define USBD_BULK_WMAXPACKETSIZE 64
#define USBD_BULK_HS_ENABLE 0
#define USBD_BULK_HS_WMAXPACKETSIZE 512
#define USBD_BULK_STRDESC L"CMSIS-DAP v2"
#define USBD_BULK_STRDESC u"CMSIS-DAP v2"


/* USB Device Calculations ---------------------------------------------------*/
Expand Down
Loading