Skip to content

Commit

Permalink
mcu: apollo4p: Update to SDK4.5.0
Browse files Browse the repository at this point in the history
Updates to DCU
Updates to HFRC2 for USB
Added support for SD Card
Updated support for HFRC2 Adjustment
Added internal error handling for IOM
Updated RTC due to Errata ERR126

Signed-off-by: Richard Wheatley <[email protected]>
  • Loading branch information
RichardSWheatley committed Jun 25, 2024
1 parent e25327f commit de3a67e
Show file tree
Hide file tree
Showing 107 changed files with 2,265 additions and 957 deletions.
4 changes: 2 additions & 2 deletions mcu/apollo4p/am_mcu_apollo.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -45,7 +45,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************

Expand Down
4 changes: 2 additions & 2 deletions mcu/apollo4p/hal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Makefile - Rules for building the libraries, examples and docs.
#
# Copyright (c) 2023, Ambiq Micro, Inc.
# Copyright (c) 2024, Ambiq Micro, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -31,7 +31,7 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
# This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
#
#******************************************************************************

Expand Down
4 changes: 2 additions & 2 deletions mcu/apollo4p/hal/am_hal_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************

Expand Down
4 changes: 2 additions & 2 deletions mcu/apollo4p/hal/am_hal_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef AM_HAL_ACCESS_H
Expand Down
8 changes: 3 additions & 5 deletions mcu/apollo4p/hal/am_hal_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision stable-7da8bae71f of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************

Expand Down Expand Up @@ -547,8 +547,7 @@ am_hal_adc_configure_slot(void *pHandle,
return AM_HAL_STATUS_OUT_OF_RANGE;
}

if ( (pSlotConfig->ui32TrkCyc < AM_HAL_ADC_MIN_TRKCYC) ||
(pSlotConfig->ui32TrkCyc > _FLD2VAL(ADC_SL0CFG_TRKCYC0, 0xFFFFFFFF)) )
if (pSlotConfig->ui32TrkCyc > _FLD2VAL(ADC_SL0CFG_TRKCYC0, 0xFFFFFFFF))
{
return AM_HAL_STATUS_INVALID_ARG;
}
Expand All @@ -557,7 +556,6 @@ am_hal_adc_configure_slot(void *pHandle,
am_hal_adc_state_t *pADCState = (am_hal_adc_state_t *)pHandle;
uint32_t ui32Module = pADCState->ui32Module;


ui32Config = 0;

//
Expand Down
4 changes: 2 additions & 2 deletions mcu/apollo4p/hal/am_hal_adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision stable-7da8bae71f of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef AM_HAL_ADC_H
Expand Down
5 changes: 2 additions & 3 deletions mcu/apollo4p/hal/am_hal_audadc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision stable-7da8bae71f of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************

Expand Down Expand Up @@ -568,7 +568,6 @@ am_hal_audadc_slot_dc_offset_calculate(void *pHandle,
uint32_t ui32PreciMode = 0, ui32NumBits = 0;
float * pfTemp;


#ifndef AM_HAL_DISABLE_API_VALIDATION
//
// Check the handle.
Expand Down
5 changes: 2 additions & 3 deletions mcu/apollo4p/hal/am_hal_audadc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef AM_HAL_AUDADC_H
Expand Down Expand Up @@ -975,7 +975,6 @@ extern uint32_t am_hal_audadc_samples_read(void *pHandle,
//*****************************************************************************
extern uint32_t am_hal_audadc_sw_trigger(void *pHandle);


//*****************************************************************************
//
//! @brief AUDADC power control function
Expand Down
53 changes: 27 additions & 26 deletions mcu/apollo4p/hal/am_hal_dcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#include "am_mcu_apollo.h"
Expand All @@ -56,6 +56,12 @@ uint64_t gDcuDisable = AM_HAL_DCURAW_DISABLE;
volatile uint32_t *gpDcuEnable = &CRYPTO->HOSTDCUEN2;
volatile uint32_t *gpDcuLock = &CRYPTO->HOSTDCULOCK2;

typedef union
{
uint64_t u64;
uint32_t u32[2];
} am_hal_64b_dcu_t;

//*****************************************************************************
//
//! @brief Get the Current RAW DCU Mask
Expand Down Expand Up @@ -102,20 +108,6 @@ get_ui32_dcu_mask(uint64_t ui64DcuMask, uint8_t threeBitVal)
return ui32Mask;
}

//*****************************************************************************
//
//! @brief Copy words from Register to Register
//
//*****************************************************************************
static void
copy_words(uint32_t *pDst, uint32_t *pSrc, uint32_t numWords)
{
while (numWords--)
{
AM_REGVAL((pDst + numWords)) = AM_REGVAL((pSrc + numWords));
}
}

//*****************************************************************************
//
//! @brief Read DCU Lock
Expand All @@ -130,7 +122,10 @@ copy_words(uint32_t *pDst, uint32_t *pSrc, uint32_t numWords)
static
uint32_t am_hal_dcu_raw_lock_status_get(uint64_t *pui64Val)
{
copy_words((uint32_t *)pui64Val, (uint32_t *)gpDcuLock, sizeof(uint64_t) / 4);
am_hal_64b_dcu_t value;
value.u32[0] = AM_REGVAL(gpDcuLock);
value.u32[1] = AM_REGVAL(gpDcuLock + 1);
*pui64Val = value.u64;
return AM_HAL_STATUS_SUCCESS;
}

Expand Down Expand Up @@ -224,7 +219,10 @@ uint32_t am_hal_dcu_lock(uint32_t ui32Mask)
static
uint32_t am_hal_dcu_raw_get(uint64_t *pui64Val)
{
copy_words((uint32_t *)pui64Val, (uint32_t *)gpDcuEnable, sizeof(uint64_t) / 4);
am_hal_64b_dcu_t value;
value.u32[0] = AM_REGVAL(gpDcuEnable);
value.u32[1] = AM_REGVAL(gpDcuEnable + 1);
*pui64Val = value.u64;
return AM_HAL_STATUS_SUCCESS;
}

Expand Down Expand Up @@ -268,23 +266,26 @@ uint32_t am_hal_dcu_get(uint32_t *pui32Val)
static
uint32_t am_hal_dcu_raw_update(bool bEnable, uint64_t ui64Mask)
{
uint64_t dcuVal;
uint64_t dcuLock;
copy_words((uint32_t *)&dcuLock, (uint32_t *)gpDcuLock, sizeof(uint64_t) / 4);
if (ui64Mask & dcuLock)
am_hal_64b_dcu_t dcuVal;
am_hal_64b_dcu_t dcuLock;
dcuLock.u32[0] = AM_REGVAL(gpDcuLock);
dcuLock.u32[1] = AM_REGVAL(gpDcuLock + 1);
if (ui64Mask & dcuLock.u64)
{
return AM_HAL_STATUS_INVALID_OPERATION;
}
copy_words((uint32_t *)&dcuVal, (uint32_t *)gpDcuEnable, sizeof(uint64_t) / 4);
dcuVal.u32[0] = AM_REGVAL(gpDcuEnable);
dcuVal.u32[1] = AM_REGVAL(gpDcuEnable + 1);
if (bEnable)
{
dcuVal = (dcuVal & ~ui64Mask) | (gDcuEnable & ui64Mask);
dcuVal.u64 = (dcuVal.u64 & ~ui64Mask) | (gDcuEnable & ui64Mask);
}
else
{
dcuVal = (dcuVal & ~ui64Mask) | (gDcuDisable & ui64Mask);
dcuVal.u64 = (dcuVal.u64 & ~ui64Mask) | (gDcuDisable & ui64Mask);
}
copy_words((uint32_t *)gpDcuEnable, (uint32_t *)&dcuVal, sizeof(uint64_t) / 4);
AM_REGVAL(gpDcuEnable) = dcuVal.u32[0];
AM_REGVAL(gpDcuEnable + 1) = dcuVal.u32[1];
CRYPTO_CC_IS_IDLE();
return AM_HAL_STATUS_SUCCESS;
}
Expand Down
4 changes: 2 additions & 2 deletions mcu/apollo4p/hal/am_hal_dcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************

Expand Down
4 changes: 2 additions & 2 deletions mcu/apollo4p/hal/am_hal_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -46,7 +46,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************

Expand Down
6 changes: 3 additions & 3 deletions mcu/apollo4p/hal/am_hal_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -45,7 +45,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision stable-7da8bae71f of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef AM_HAL_GLOBAL_H
Expand Down Expand Up @@ -150,7 +150,7 @@ extern "C"
//! @{
//
//*****************************************************************************
#elif defined(gcc)
#elif defined(gcc) || defined(segger)
#define AM_SHARED_RW __attribute__((section(".shared")))
#define AM_RESOURCE_TABLE __attribute__((section(".resource_table")))
#define AM_USED __attribute__((used))
Expand Down
4 changes: 2 additions & 2 deletions mcu/apollo4p/hal/am_hal_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************

Expand Down
4 changes: 2 additions & 2 deletions mcu/apollo4p/hal/am_hal_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision stable-7da8bae71f of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef AM_HAL_GPIO_H
Expand Down
Loading

0 comments on commit de3a67e

Please sign in to comment.