From 10bd7b9e96816b97dc53209cba9cc29abf1ae75b Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Sat, 21 Sep 2024 22:30:42 -0700 Subject: [PATCH] Fix some GD32 legacy pin name issues --- .../sleep_manager_racecondition/main.cpp | 6 +- .../TESTS/pin_names/arduino_uno/main.cpp | 2 +- .../TESTS/mbed_functional/callback/main.cpp | 10 +-- .../TARGET_GD32F307VG/PinNames.h | 55 +++++++------- .../TARGET_GD32F450ZI/PinNames.h | 54 +++++++------- targets/cmsis_mcu_descriptions.json5 | 72 +++++++++++++++++++ targets/targets.json5 | 5 +- tools/cmake/toolchains/GCC_ARM.cmake | 1 + 8 files changed, 135 insertions(+), 70 deletions(-) diff --git a/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp b/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp index 034b41cbe42e..39dc418e5310 100644 --- a/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp +++ b/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp @@ -32,7 +32,7 @@ void sleep_manager_locking_thread_test() { for (uint32_t i = 0; i < 100; i++) { sleep_manager_lock_deep_sleep(); - ThisThread::sleep_for(25); + ThisThread::sleep_for(25ms); sleep_manager_unlock_deep_sleep(); } } @@ -45,7 +45,7 @@ void sleep_manager_multithread_test() Thread t2(osPriorityNormal, TEST_STACK_SIZE); t1.start(callback(cb)); - ThisThread::sleep_for(25); + ThisThread::sleep_for(25ms); t2.start(callback(cb)); // Wait for the threads to finish @@ -70,7 +70,7 @@ void sleep_manager_irq_test() Ticker ticker1; Timer timer; - ticker1.attach_us(&sleep_manager_locking_irq_test, 1000); + ticker1.attach(&sleep_manager_locking_irq_test, 1ms); // run this for 10 seconds timer.start(); diff --git a/hal/tests/TESTS/pin_names/arduino_uno/main.cpp b/hal/tests/TESTS/pin_names/arduino_uno/main.cpp index 8022d507bc99..53bd25e1dd80 100644 --- a/hal/tests/TESTS/pin_names/arduino_uno/main.cpp +++ b/hal/tests/TESTS/pin_names/arduino_uno/main.cpp @@ -154,7 +154,7 @@ void UART_test() } // 3. check if Arduino_uno pins are not using the same UART instance as console - int console_uart = pinmap_peripheral(CONSOLE_TX, serial_tx_pinmap()); + uint32_t console_uart = pinmap_peripheral(CONSOLE_TX, serial_tx_pinmap()); if (console_uart != 0) { TEST_ASSERT_NOT_EQUAL(console_uart, pinmap_peripheral(TX_pin, serial_tx_pinmap())); } diff --git a/platform/tests/TESTS/mbed_functional/callback/main.cpp b/platform/tests/TESTS/mbed_functional/callback/main.cpp index 4b8b7fe50eb8..ac33d14bf46a 100644 --- a/platform/tests/TESTS/mbed_functional/callback/main.cpp +++ b/platform/tests/TESTS/mbed_functional/callback/main.cpp @@ -755,11 +755,6 @@ static int construct_count; static int destruct_count; static int copy_count; -static int live_count() -{ - return construct_count - destruct_count; -} - struct FunctionObject { FunctionObject(int n) : val(n) { @@ -824,6 +819,11 @@ void test_trivial() } #if MBED_CONF_PLATFORM_CALLBACK_NONTRIVIAL +static int live_count() +{ + return construct_count - destruct_count; +} + void test_nontrivial() { { diff --git a/targets/TARGET_GigaDevice/TARGET_GD32F30X/TARGET_GD32F307VG/PinNames.h b/targets/TARGET_GigaDevice/TARGET_GD32F30X/TARGET_GD32F307VG/PinNames.h index 1165232d35b9..7fa3d8d73320 100644 --- a/targets/TARGET_GigaDevice/TARGET_GD32F30X/TARGET_GD32F307VG/PinNames.h +++ b/targets/TARGET_GigaDevice/TARGET_GD32F30X/TARGET_GD32F307VG/PinNames.h @@ -151,30 +151,31 @@ typedef enum { ADC_TEMP = 0xF0, ADC_VREF = 0xF1, - +#ifdef TARGET_FF_ARDUINO_UNO /* Arduino connector namings */ - A0 = PORTC_0, - A1 = PORTC_1, - A2 = PORTC_2, - A3 = PORTC_3, - A4 = PORTA_0, - A5 = PORTB_1, - D0 = PORTA_3, - D1 = PORTA_2, - D2 = PORTE_4, - D3 = PORTD_12, - D4 = PORTB_3, - D5 = PORTC_7, - D6 = PORTB_0, - D7 = PORTB_4, - D8 = PORTD_11, - D9 = PORTE_5, - D10 = PORTA_8, - D11 = PORTB_15, - D12 = PORTB_14, - D13 = PORTB_13, - D14 = PORTB_9, - D15 = PORTB_8, + ARDUINO_UNO_A0 = PORTC_0, + ARDUINO_UNO_A1 = PORTC_1, + ARDUINO_UNO_A2 = PORTC_2, + ARDUINO_UNO_A3 = PORTC_3, + ARDUINO_UNO_A4 = PORTA_0, + ARDUINO_UNO_A5 = PORTB_1, + ARDUINO_UNO_D0 = PORTA_3, + ARDUINO_UNO_D1 = PORTA_2, + ARDUINO_UNO_D2 = PORTE_4, + ARDUINO_UNO_D3 = PORTD_12, + ARDUINO_UNO_D4 = PORTB_3, + ARDUINO_UNO_D5 = PORTC_7, + ARDUINO_UNO_D6 = PORTB_0, + ARDUINO_UNO_D7 = PORTB_4, + ARDUINO_UNO_D8 = PORTD_11, + ARDUINO_UNO_D9 = PORTE_5, + ARDUINO_UNO_D10 = PORTA_8, + ARDUINO_UNO_D11 = PORTB_15, + ARDUINO_UNO_D12 = PORTB_14, + ARDUINO_UNO_D13 = PORTB_13, + ARDUINO_UNO_D14 = PORTB_9, + ARDUINO_UNO_D15 = PORTB_8, +#endif LED1 = PORTE_0, LED2 = PORTE_1, @@ -191,13 +192,7 @@ typedef enum { CONSOLE_TX = SERIAL_TX, CONSOLE_RX = SERIAL_RX, - I2C_SCL = D15, - I2C_SDA = D14, - SPI_MOSI = D11, - SPI_MISO = D12, - SPI_SCK = D13, - SPI_CS = D10, - PWM_OUT = D9, + PWM_OUT = PORTE_5, USBFS_VBUS = PORTA_9, USBFS_DM = PORTA_11, diff --git a/targets/TARGET_GigaDevice/TARGET_GD32F4XX/TARGET_GD32F450ZI/PinNames.h b/targets/TARGET_GigaDevice/TARGET_GD32F4XX/TARGET_GD32F450ZI/PinNames.h index ea32271d7723..b79b919f680e 100644 --- a/targets/TARGET_GigaDevice/TARGET_GD32F4XX/TARGET_GD32F450ZI/PinNames.h +++ b/targets/TARGET_GigaDevice/TARGET_GD32F4XX/TARGET_GD32F450ZI/PinNames.h @@ -207,29 +207,31 @@ typedef enum { ADC_VREF = 0xF1, ADC_VBAT = 0xF2, +#ifdef TARGET_FF_ARDUINO_UNO /* Arduino connector pin definitions */ - A0 = PORTC_0, - A1 = PORTA_5, - A2 = PORTC_2, - A3 = PORTC_3, - A4 = PORTA_0, /* PORTB_11 */ - A5 = PORTC_5, /* PORTB_10 */ - D0 = PORTC_11, - D1 = PORTC_10, - D2 = PORTA_15, - D3 = PORTD_12, - D4 = PORTC_8, - D5 = PORTC_7, - D6 = PORTB_0, - D7 = PORTC_12, - D8 = PORTD_13, - D9 = PORTA_8, - D10 = PORTA_1, - D11 = PORTB_15, - D12 = PORTB_14, - D13 = PORTB_13, - D14 = PORTB_9, - D15 = PORTB_8, + ARDUINO_UNO_A0 = PORTC_0, + ARDUINO_UNO_A1 = PORTA_5, + ARDUINO_UNO_A2 = PORTC_2, + ARDUINO_UNO_A3 = PORTC_3, + ARDUINO_UNO_A4 = PORTA_0, /* PORTB_11 */ + ARDUINO_UNO_A5 = PORTC_5, /* PORTB_10 */ + ARDUINO_UNO_D0 = PORTC_11, + ARDUINO_UNO_D1 = PORTC_10, + ARDUINO_UNO_D2 = PORTA_15, + ARDUINO_UNO_D3 = PORTD_12, + ARDUINO_UNO_D4 = PORTC_8, + ARDUINO_UNO_D5 = PORTC_7, + ARDUINO_UNO_D6 = PORTB_0, + ARDUINO_UNO_D7 = PORTC_12, + ARDUINO_UNO_D8 = PORTD_13, + ARDUINO_UNO_D9 = PORTA_8, + ARDUINO_UNO_D10 = PORTA_1, + ARDUINO_UNO_D11 = PORTB_15, + ARDUINO_UNO_D12 = PORTB_14, + ARDUINO_UNO_D13 = PORTB_13, + ARDUINO_UNO_D14 = PORTB_9, + ARDUINO_UNO_D15 = PORTB_8, +#endif LED1 = PORTF_6, LED2 = PORTC_13, @@ -246,13 +248,7 @@ typedef enum { CONSOLE_TX = SERIAL_TX, CONSOLE_RX = SERIAL_RX, - I2C_SCL = PORTB_6, - I2C_SDA = PORTB_7, - SPI_MOSI = PORTB_5, - SPI_MISO = PORTB_4, - SPI_SCK = PORTB_3, - SPI_CS = PORTE_2, - PWM_OUT = D9, + PWM_OUT = PORTA_8, USBFS_VBUS = PORTA_9, USBFS_DM = PORTA_11, diff --git a/targets/cmsis_mcu_descriptions.json5 b/targets/cmsis_mcu_descriptions.json5 index 1c2a755213ee..a47b214c3c5f 100644 --- a/targets/cmsis_mcu_descriptions.json5 +++ b/targets/cmsis_mcu_descriptions.json5 @@ -1261,6 +1261,78 @@ "sub_family": "EFR32MG12P332", "vendor": "Silicon Labs:21" }, + "GD32F307VG": { + "algorithms": [ + { + "default": true, + "file_name": "Flash/GD32F30x_CL.FLM", + "ram_size": null, + "ram_start": null, + "size": 1048576, + "start": 134217728, + "style": "Keil" + } + ], + "family": "GD32F30x Series", + "from_pack": { + "pack": "GD32F30x_DFP", + "url": "https://gd32mcu.com/data/documents/pack/", + "vendor": "GigaDevice", + "version": "2.2.1" + }, + "memories": { + "IRAM1": { + "access": { + "execute": false, + "non_secure": false, + "non_secure_callable": false, + "peripheral": false, + "read": true, + "secure": false, + "write": true + }, + "default": true, + "p_name": null, + "size": 98304, + "start": 536870912, + "startup": false + }, + "IROM1": { + "access": { + "execute": true, + "non_secure": false, + "non_secure_callable": false, + "peripheral": false, + "read": true, + "secure": false, + "write": false + }, + "default": true, + "p_name": null, + "size": 1048576, + "start": 134217728, + "startup": true + } + }, + "name": "GD32F307VG", + "processors": [ + { + "address": null, + "ap": 0, + "apid": null, + "core": "CortexM4", + "default_reset_sequence": null, + "dp": 0, + "fpu": "SinglePrecision", + "mpu": "Present", + "name": null, + "svd": "SVD/GD32F30x_CL.svd", + "unit": 0 + } + ], + "sub_family": "GD32F307", + "vendor": "GigaDevice:123" + }, "GD32F450ZI": { "algorithms": [ { diff --git a/targets/targets.json5 b/targets/targets.json5 index ff92d4a7659d..42913174fce7 100644 --- a/targets/targets.json5 +++ b/targets/targets.json5 @@ -9304,7 +9304,7 @@ "GD32_Target" ], "supported_form_factors": [ - "ARDUINO" + "ARDUINO_UNO" ], "core": "Cortex-M4F", "extra_labels_add": [ @@ -9339,6 +9339,7 @@ "overrides": { "network-default-interface-type": "ETHERNET" }, + "device_name": "GD32F307VG", "image_url": "https://os.mbed.com/media/uploads/Ray_Chen/307-1.png" }, "GD32_F450ZI": { @@ -9346,7 +9347,7 @@ "GD32_Target" ], "supported_form_factors": [ - "ARDUINO" + "ARDUINO_UNO" ], "core": "Cortex-M4F", "extra_labels_add": [ diff --git a/tools/cmake/toolchains/GCC_ARM.cmake b/tools/cmake/toolchains/GCC_ARM.cmake index 2dae4d4546ac..5341f9109343 100644 --- a/tools/cmake/toolchains/GCC_ARM.cmake +++ b/tools/cmake/toolchains/GCC_ARM.cmake @@ -34,6 +34,7 @@ list(APPEND common_options "-Wextra" "-Wno-unused-parameter" "-Wno-missing-field-initializers" + "-Wno-psabi" # Disable "parameter passing changed in GCC 7.1" warning "-fmessage-length=0" "-fno-exceptions" "-ffunction-sections"