diff --git a/features/frameworks/unity/source/unity.c b/features/frameworks/unity/source/unity.c index a3a823687c5..c71bc4d02aa 100644 --- a/features/frameworks/unity/source/unity.c +++ b/features/frameworks/unity/source/unity.c @@ -1240,6 +1240,7 @@ void UnitySkipPrint(const char* msg, const UNITY_LINE_TYPE line) UNITY_OUTPUT_CHAR(' '); UnityPrint(msg); } + UNITY_OUTPUT_CHAR('\n'); } /*-----------------------------------------------*/ diff --git a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.c b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.c index 89781cb10cc..978770e760d 100644 --- a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.c +++ b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.c @@ -312,3 +312,68 @@ const PinMap PinMap_PWM_OUT[] = { {NC, NC, 0} }; + +/************ GPIO ***************/ + +// Note that this is only used for testing, so that the test knows what are valid GPIO pins. +// It's not used in normal usage. +// Also, only the "pin" field is significant here. Other fields are don't cares. + +const PinMap PinMap_GPIO[] = { + {IO_0, 0, 0}, + {IO_1, 0, 0}, + {IO_2, 0, 0}, + {IO_3, 0, 0}, + {IO_4, 0, 0}, + {IO_5, 0, 0}, + {IO_6, 0, 0}, + {IO_7, 0, 0}, + {IO_8, 0, 0}, + {IO_9, 0, 0}, + {IO_10, 0, 0}, + {IO_11, 0, 0}, + {IO_12, 0, 0}, + {IO_13, 0, 0}, + {IO_14, 0, 0}, + {IO_15, 0, 0}, + {IO_16, 0, 0}, + {IO_17, 0, 0}, + {IO_18, 0, 0}, + {IO_19, 0, 0}, + {IO_20, 0, 0}, + {IO_21, 0, 0}, + {IO_22, 0, 0}, + {IO_23, 0, 0}, + {IO_24, 0, 0}, + {IO_25, 0, 0}, + {IO_26, 0, 0}, + {IO_27, 0, 0}, + {IO_28, 0, 0}, + {IO_29, 0, 0}, + {IO_39, 0, 0}, + {IO_40, 0, 0}, + {IO_41, 0, 0}, + {IO_44, 0, 0}, + {IO_47, 0, 0}, + {IO_48, 0, 0}, + {IO_49, 0, 0}, + + // Apollo3 I/O pins - BGA package only + {IO_30, 0, 0}, + {IO_31, 0, 0}, + {IO_32, 0, 0}, + {IO_33, 0, 0}, + {IO_34, 0, 0}, + {IO_35, 0, 0}, + {IO_36, 0, 0}, + {IO_37, 0, 0}, + {IO_38, 0, 0}, + {IO_42, 0, 0}, + {IO_43, 0, 0}, + {IO_45, 0, 0}, + {IO_46, 0, 0}, + + {NC, NC, 0} +}; + + diff --git a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.h b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.h index f0d1c3c54b4..67889da03ad 100644 --- a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.h +++ b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.h @@ -23,6 +23,7 @@ #include "pinmap.h" #include "PeripheralNames.h" + //*** I2C *** #if DEVICE_I2C extern const PinMap PinMap_I2C_SDA[]; @@ -70,4 +71,6 @@ extern const PinMap PinMap_QSPI_DATA2[]; extern const PinMap PinMap_QSPI_DATA3[]; #endif +extern const PinMap PinMap_GPIO[]; + #endif diff --git a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/gpio_api.c b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/gpio_api.c index 85c1deda7d3..8565e5943b3 100644 --- a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/gpio_api.c +++ b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/gpio_api.c @@ -23,6 +23,7 @@ #include "mbed_assert.h" #include "gpio_api.h" +#include "PeripheralPins.h" /** Set the given pin as GPIO * @@ -224,6 +225,5 @@ int gpio_read(gpio_t *obj) */ const PinMap *gpio_pinmap(void) { - MBED_ASSERT(false); - return NULL; + return PinMap_GPIO; } diff --git a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/serial_api.c b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/serial_api.c index 2aa68311e2e..5a771e910a4 100644 --- a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/serial_api.c +++ b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/serial_api.c @@ -26,6 +26,7 @@ #if DEVICE_SERIAL #include "serial_api.h" +#include "mbed_wait_api.h" #include "mbed_assert.h" #include "PeripheralPins.h" @@ -142,7 +143,8 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) obj->serial.uart_control->cfg.ui32RxBufferSize = 0; obj->serial.uart_control->cfg.ui32TxBufferSize = 0; - obj->serial.uart_control->cfg.ui32FifoLevels = AM_HAL_UART_RX_FIFO_7_8; + // Mbed expects an interrupt whenever we have at least one char in the Rx FIFO. + obj->serial.uart_control->cfg.ui32FifoLevels = AM_HAL_UART_RX_FIFO_1_8; // start UART instance MBED_ASSERT(am_hal_uart_initialize(uart, &(obj->serial.uart_control->handle)) == AM_HAL_STATUS_SUCCESS); @@ -244,6 +246,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) break; } // NVIC_SetVector(uart_irqs[obj->serial.index], vector); + NVIC_ClearPendingIRQ((IRQn_Type)(UART0_IRQn + obj->serial.uart_control->inst)); NVIC_EnableIRQ((IRQn_Type)(UART0_IRQn + obj->serial.uart_control->inst)); } else { // disable switch (irq) { @@ -275,6 +278,29 @@ int serial_getc(serial_t *obj) do { am_hal_uart_transfer(obj->serial.uart_control->handle, &am_hal_uart_xfer_read_single); + + // Seeing very odd behavior with this uart, where digital glitches on the line can cause the + // framing error bit to set and then cause at least some of the data within the Rx FIFO to be + // deleted. This causes an infinite hang, as Mbed requires serial_getc() to return a character + // if serial_readable() returns true. This UART is not well documented, so unable to say if this + // is an errata or some sort of odd design choice. + // To avoid this, if we did not get any data and the framing error bit is set, simply clear the flag + // and return an arbitrary character. This is a little awkward but prevents a hard-to-debug hang. + if(bytes_read == 0 && UARTn(obj->serial.uart_control->inst)->RSR_b.FESTAT) + { + UARTn(obj->serial.uart_control->inst)->RSR_b.FESTAT = 0; + return 'x'; + } + + // Similar to above but with the overflow flag. Without this logic we can hang when receiving + // at 921600 baud. Oddly, the overflow flag in RSR does not seem to be reliable, but the overflow + // flag in IES seems to be. Not sure why this UART has two overflow flags in the first place, smh... + if(bytes_read == 0 && UARTn(obj->serial.uart_control->inst)->IES_b.OERIS) + { + UARTn(obj->serial.uart_control->inst)->IEC_b.OEIC = 1; + return 'x'; + } + } while (bytes_read == 0); return (int)rx_c; @@ -334,21 +360,6 @@ void serial_pinout_tx(PinName tx) MBED_ASSERT(0); } -#if DEVICE_SERIAL_FC - -void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow) -{ - // todo: - MBED_ASSERT(0); -} - -void serial_set_flow_control_direct(serial_t *obj, FlowControl type, const serial_fc_pinmap_t *pinmap) -{ - // todo: - MBED_ASSERT(0); -} -#endif - const PinMap *serial_tx_pinmap(void) { return PinMap_UART_TX; @@ -359,19 +370,6 @@ const PinMap *serial_rx_pinmap(void) return PinMap_UART_RX; } -#if DEVICE_SERIAL_FC - -const PinMap *serial_cts_pinmap(void) -{ - return PinMap_UART_CTS; -} - -const PinMap *serial_rts_pinmap(void) -{ - return PinMap_UART_RTS; -} -#endif - static inline void uart_irq(uint32_t instance) { void *handle = ap3_uart_control[instance].handle; diff --git a/targets/targets.json5 b/targets/targets.json5 index 7101154834c..ebe038f828c 100644 --- a/targets/targets.json5 +++ b/targets/targets.json5 @@ -3594,7 +3594,7 @@ mode is recommended for target MCUs with small amounts of flash and RAM.", // DISCO_H747I's attributes. "inherits": [ "MCU_STM32H747xI_CM7", - "DISCO_H747" + "DISCO_H747I" ] }, "DISCO_H747I_CM4": { diff --git a/tools/cmake/mbed_target_functions.cmake b/tools/cmake/mbed_target_functions.cmake index 10d1ad484c3..e785e06139a 100644 --- a/tools/cmake/mbed_target_functions.cmake +++ b/tools/cmake/mbed_target_functions.cmake @@ -187,9 +187,7 @@ function(mbed_set_post_build target) mbed_post_build_function(${target}) endif() - if(HAVE_MEMAP_DEPS) - mbed_generate_map_file(${target}) - endif() + mbed_generate_map_file(${target}) # Give chance to adjust MBED_UPLOAD_LAUNCH_COMMANDS or MBED_UPLOAD_RESTART_COMMANDS # for debug launch diff --git a/tools/python/mbed_os_tools/test/host_tests_conn_proxy/conn_proxy.py b/tools/python/mbed_os_tools/test/host_tests_conn_proxy/conn_proxy.py index 6725079db4f..4382acaaf3d 100644 --- a/tools/python/mbed_os_tools/test/host_tests_conn_proxy/conn_proxy.py +++ b/tools/python/mbed_os_tools/test/host_tests_conn_proxy/conn_proxy.py @@ -62,9 +62,11 @@ def append(self, payload: bytes): before = line[:pos] after = line[pos + len(match):] if len(before) > 0: + logger.prn_rxd(before) discarded.append(before) if len(after) > 0: # not a K,V pair part + logger.prn_rxd(after) discarded.append(after) logger.prn_inf("found KV pair in stream: {{%s;%s}}, queued..."% (key, value)) else: