Skip to content
Merged
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
1 change: 1 addition & 0 deletions features/frameworks/unity/source/unity.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,7 @@ void UnitySkipPrint(const char* msg, const UNITY_LINE_TYPE line)
UNITY_OUTPUT_CHAR(' ');
UnityPrint(msg);
}
UNITY_OUTPUT_CHAR('\n');
}

/*-----------------------------------------------*/
Expand Down
65 changes: 65 additions & 0 deletions targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}
};


Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "pinmap.h"
#include "PeripheralNames.h"


//*** I2C ***
#if DEVICE_I2C
extern const PinMap PinMap_I2C_SDA[];
Expand Down Expand Up @@ -70,4 +71,6 @@ extern const PinMap PinMap_QSPI_DATA2[];
extern const PinMap PinMap_QSPI_DATA3[];
#endif

extern const PinMap PinMap_GPIO[];

#endif
4 changes: 2 additions & 2 deletions targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/gpio_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "mbed_assert.h"
#include "gpio_api.h"
#include "PeripheralPins.h"

/** Set the given pin as GPIO
*
Expand Down Expand Up @@ -224,6 +225,5 @@ int gpio_read(gpio_t *obj)
*/
const PinMap *gpio_pinmap(void)
{
MBED_ASSERT(false);
return NULL;
return PinMap_GPIO;
}
56 changes: 27 additions & 29 deletions targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#if DEVICE_SERIAL

#include "serial_api.h"
#include "mbed_wait_api.h"

#include "mbed_assert.h"
#include "PeripheralPins.h"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion targets/targets.json5
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 1 addition & 3 deletions tools/cmake/mbed_target_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down