diff --git a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/CMakeLists.txt b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/CMakeLists.txt index cc56e6c42ac..03a40ec15af 100644 --- a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/CMakeLists.txt +++ b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/CMakeLists.txt @@ -51,6 +51,7 @@ target_sources(mbed-apollo3 device/sleep.c device/spi_api.c device/us_ticker.c + device/itm_api.c sdk/CMSIS/AmbiqMicro/Source/system_apollo3.c diff --git a/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/itm_api.c b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/itm_api.c new file mode 100644 index 00000000000..8ecace91202 --- /dev/null +++ b/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/itm_api.c @@ -0,0 +1,48 @@ +/* mbed Microcontroller Library + * Copyright (c) 2017 ARM Limited + * 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. + */ + +#if DEVICE_ITM + +#include "hal/itm_api.h" +#include "cmsis.h" +#include "am_bsp.h" + +#include + +/* SWO frequency: 1000 kHz */ + +#ifndef AM_BSP_GPIO_ITM_SWO +#define AM_GPIO_ITM_SWO 22 + +const am_hal_gpio_pincfg_t g_AM_GPIO_ITM_SWO = +{ + .uFuncSel = AM_HAL_PIN_22_SWO, + .eDriveStrength = AM_HAL_GPIO_PIN_DRIVESTRENGTH_2MA +}; +#endif + + +void itm_init(void) +{ + #ifdef AM_BSP_GPIO_ITM_SWO + am_bsp_itm_printf_enable(); + #else + am_bsp_itm_printf_enable(AM_GPIO_ITM_SWO,g_AM_GPIO_ITM_SWO); + #endif +} + +#endif diff --git a/targets/targets.json b/targets/targets.json index c09b2dc4d2d..8ff83b213ca 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -9061,7 +9061,8 @@ "FLASH", "SPI", "I2C", - "SLEEP" + "SLEEP", + "ITM" ], "components": [ "FLASHIAP"