initial commit
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# Makefile - Rules for building the libraries, examples and docs.
|
||||
#
|
||||
# Copyright (c) 2020, Ambiq Micro
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# Third party software included in this distribution is subject to the
|
||||
# additional license terms as defined in the /docs/licenses directory.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
SUBDIRS=${wildcard */}
|
||||
|
||||
all:
|
||||
@for i in ${SUBDIRS}; \
|
||||
do \
|
||||
if [ -f $${i}/Makefile ]; then \
|
||||
$(MAKE) -C $${i} || exit $$?; fi; \
|
||||
done
|
||||
|
||||
clean:
|
||||
@for i in ${SUBDIRS}; \
|
||||
do \
|
||||
if [ -f $${i}/Makefile ]; then \
|
||||
$(MAKE) -C $${i} clean; fi; \
|
||||
done
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_sdk_version.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Defines SDK version.
|
||||
//!
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_SDK_VERSION_H
|
||||
#define AM_SDK_VERSION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macros to define HAL SDK version.
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Define the current HAL version.
|
||||
//
|
||||
#ifndef AM_HAL_VERSION_MAJ
|
||||
#define AM_HAL_VERSION_MAJ 2
|
||||
#define AM_HAL_VERSION_MIN 4
|
||||
#define AM_HAL_VERSION_REV 2
|
||||
#endif // AM_HAL_VERSION_MAJ
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_SDK_VERSION_H
|
||||
@@ -0,0 +1,57 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# Makefile - Rules for building the libraries, examples and docs.
|
||||
#
|
||||
# Copyright (c) 2020, Ambiq Micro
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# Third party software included in this distribution is subject to the
|
||||
# additional license terms as defined in the /docs/licenses directory.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
SUBDIRS=${wildcard */}
|
||||
|
||||
all:
|
||||
@for i in ${SUBDIRS}; \
|
||||
do \
|
||||
if [ -f $${i}/Makefile ]; then \
|
||||
$(MAKE) -C $${i} || exit $$?; fi; \
|
||||
done
|
||||
|
||||
clean:
|
||||
@for i in ${SUBDIRS}; \
|
||||
do \
|
||||
if [ -f $${i}/Makefile ]; then \
|
||||
$(MAKE) -C $${i} clean; fi; \
|
||||
done
|
||||
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_mcu_apollo.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Top Include for Apollo1 class devices.
|
||||
//!
|
||||
//! This file provides all the includes necessary for an apollo device.
|
||||
//!
|
||||
//! @addtogroup hal Hardware Abstraction Layer (HAL)
|
||||
//
|
||||
//! @defgroup apollo1hal HAL for Apollo
|
||||
//! @ingroup hal
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_MCU_APOLLO_H
|
||||
#define AM_MCU_APOLLO_H
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Define AM_CMSIS_REGS to indicate that AM_REGS registers are supported.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_CMSIS_REGS 0 // 0 = Use AM_REGS
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// C99
|
||||
//
|
||||
//*****************************************************************************
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
#include "intrinsics.h" // __CLZ() and other intrinsics
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Registers
|
||||
//
|
||||
//*****************************************************************************
|
||||
#include "regs/am_reg_adc.h"
|
||||
#include "regs/am_reg_base_addresses.h"
|
||||
#include "regs/am_reg_clkgen.h"
|
||||
#include "regs/am_reg_ctimer.h"
|
||||
#include "regs/am_reg_gpio.h"
|
||||
#include "regs/am_reg_iomstr.h"
|
||||
#include "regs/am_reg_ioslave.h"
|
||||
#include "regs/am_reg_itm.h"
|
||||
#include "regs/am_reg_jedec.h"
|
||||
#include "regs/am_reg_macros.h"
|
||||
#include "regs/am_reg_mcuctrl.h"
|
||||
#include "regs/am_reg_nvic.h"
|
||||
#include "regs/am_reg_rtc.h"
|
||||
#include "regs/am_reg_rstgen.h"
|
||||
#include "regs/am_reg_sysctrl.h"
|
||||
#include "regs/am_reg_systick.h"
|
||||
#include "regs/am_reg_tpiu.h"
|
||||
#include "regs/am_reg_uart.h"
|
||||
#include "regs/am_reg_vcomp.h"
|
||||
#include "regs/am_reg_wdt.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// HAL
|
||||
//
|
||||
//*****************************************************************************
|
||||
#include "hal/am_hal_adc.h"
|
||||
#include "hal/am_hal_cachectrl.h"
|
||||
#include "hal/am_hal_clkgen.h"
|
||||
#include "hal/am_hal_ctimer.h"
|
||||
#include "hal/am_hal_debug.h"
|
||||
#include "hal/am_hal_flash.h"
|
||||
#include "hal/am_hal_global.h"
|
||||
#include "hal/am_hal_gpio.h"
|
||||
#include "hal/am_hal_i2c_bit_bang.h"
|
||||
#include "hal/am_hal_interrupt.h"
|
||||
#include "hal/am_hal_iom.h"
|
||||
#include "hal/am_hal_ios.h"
|
||||
#include "hal/am_hal_itm.h"
|
||||
#include "hal/am_hal_mcuctrl.h"
|
||||
#include "hal/am_hal_otp.h"
|
||||
#include "hal/am_hal_pin.h"
|
||||
#include "hal/am_hal_pwrctrl.h"
|
||||
#include "hal/am_hal_queue.h"
|
||||
#include "hal/am_hal_reset.h"
|
||||
#include "hal/am_hal_rtc.h"
|
||||
#include "hal/am_hal_sysctrl.h"
|
||||
#include "hal/am_hal_systick.h"
|
||||
#include "hal/am_hal_tpiu.h"
|
||||
#include "hal/am_hal_uart.h"
|
||||
#include "hal/am_hal_vcomp.h"
|
||||
#include "hal/am_hal_wdt.h"
|
||||
|
||||
|
||||
#endif // AM_MCU_APOLLO_H
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# Makefile - Rules for compiling
|
||||
#
|
||||
# Copyright (c) 2020, Ambiq Micro
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# Third party software included in this distribution is subject to the
|
||||
# additional license terms as defined in the /docs/licenses directory.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
# All makefiles use this to find the top level directory.
|
||||
SWROOT?=../../..
|
||||
|
||||
# Include rules for building the HAL.
|
||||
include $(SWROOT)/makedefs/am_hal.mk
|
||||
|
||||
# Generate pin definitions for apollo3.
|
||||
CHIP_GENERATION = 1
|
||||
@@ -0,0 +1,609 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_adc.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the Analog to Digital Converter.
|
||||
//!
|
||||
//! @addtogroup adc1 Analog-to-Digital Converter (ADC)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Private SRAM view of temperature trims from OTP.
|
||||
//!
|
||||
//! These three words have to be loaded via code running only in SRAM.
|
||||
//!
|
||||
//! This static SRAM union is private to the ADC HAL functions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static union
|
||||
{
|
||||
//! These values are loaded as uint32_t values from OTP.
|
||||
struct
|
||||
{
|
||||
//! Temperature of the package test head (in degrees Kelvin)
|
||||
uint32_t ui32CalibrationTemperature;
|
||||
|
||||
//! Voltage corresponding to temperature measured on test head.
|
||||
uint32_t ui32CalibrationVoltage;
|
||||
|
||||
//! ADC offset voltage measured on the package test head.
|
||||
uint32_t ui32CalibrationOffset;
|
||||
|
||||
//! Flag if default (guess) or measured.
|
||||
bool bMeasured;
|
||||
} ui32;
|
||||
//! These values are accessed as floats when used for temperature calculation.
|
||||
struct
|
||||
{
|
||||
//! Temperature of the package test head in degrees Kelvin
|
||||
float fCalibrationTemperature;
|
||||
|
||||
//! Voltage corresponding to temperature measured on test head.
|
||||
float fCalibrationVoltage;
|
||||
|
||||
//! ADC offset voltage measured on the package test head.
|
||||
float fCalibrationOffset;
|
||||
|
||||
//! Flag if default (guess) or measured.
|
||||
float fMeasuredFlag;
|
||||
} flt;
|
||||
} priv_temp_trims;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configure the ADC.
|
||||
//!
|
||||
//! @param psConfig - pointer to the configuration structure for the ADC.
|
||||
//!
|
||||
//! This function may be used to perform the initial setup of the ADC based on
|
||||
//! setting found in a configuration structure. In addition, calling this
|
||||
//! function copies the temperature trim values from OTP to SRAM.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_config(am_hal_adc_config_t *psConfig)
|
||||
{
|
||||
__asm("");
|
||||
|
||||
//
|
||||
// Set general ADC configuration parameters.
|
||||
//
|
||||
AM_REG(ADC, CFG) = (psConfig->ui32Clock |
|
||||
psConfig->ui32TriggerConfig |
|
||||
psConfig->ui32Reference |
|
||||
psConfig->ui32MaxSampleRate |
|
||||
psConfig->ui32PowerMode |
|
||||
psConfig->ui32Repeat |
|
||||
psConfig-> ui32POnTemp |
|
||||
AM_REG_ADC_CFG_ADCEN(1));
|
||||
|
||||
//
|
||||
// Set the window limits for the ADC.
|
||||
//
|
||||
AM_REG(ADC, WLIM) = psConfig->ui32Window;
|
||||
|
||||
//
|
||||
// Grab the temperature trims from OTP once.
|
||||
//
|
||||
priv_temp_trims.ui32.ui32CalibrationTemperature =
|
||||
am_hal_flash_load_ui32(AM_HAL_ADC_CALIB_TEMP_ADDR);
|
||||
priv_temp_trims.ui32.ui32CalibrationVoltage =
|
||||
am_hal_flash_load_ui32(AM_HAL_ADC_CALIB_AMBIENT_ADDR);
|
||||
priv_temp_trims.ui32.ui32CalibrationOffset =
|
||||
am_hal_flash_load_ui32(AM_HAL_ADC_CALIB_ADC_OFFSET_ADDR);
|
||||
|
||||
//
|
||||
// If any of the OTP calibration values are invalid, set up some
|
||||
// obviously invalid defaults. For example, with these defaults the
|
||||
// function am_hal_adc_volts_to_celsius() will return the value for
|
||||
// absolute zero while avoiding a divide-by-zero error.
|
||||
//
|
||||
if ((priv_temp_trims.ui32.ui32CalibrationTemperature == 0xffffffff) ||
|
||||
(priv_temp_trims.ui32.ui32CalibrationVoltage == 0xffffffff) ||
|
||||
(priv_temp_trims.ui32.ui32CalibrationOffset == 0xffffffff))
|
||||
{
|
||||
priv_temp_trims.flt.fCalibrationOffset = 0.0F;
|
||||
priv_temp_trims.flt.fCalibrationTemperature = 0.0F;
|
||||
priv_temp_trims.flt.fCalibrationVoltage = 1.0F;
|
||||
priv_temp_trims.ui32.bMeasured = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
priv_temp_trims.ui32.bMeasured = true;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the temperature trim parameters after configuring the ADC.
|
||||
//!
|
||||
//! @param pfTemp - pointer to a location to store the calibration temperature.
|
||||
//! @param pfVoltage - pointer to a location to store the calibration voltage.
|
||||
//! @param pfOffsetV - pointer to a location to store the calibration offset.
|
||||
//!
|
||||
//! This function may be used to access the actual temperature sensor trim
|
||||
//! values from the private structure.
|
||||
//!
|
||||
//! WARNING: only call this after the ADC has been configured with
|
||||
//! am_hal_adc_config.
|
||||
//!
|
||||
//! @return True if the returned values are actual calibrated values.
|
||||
//! False if the returned values are default (non-measureed) values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
am_hal_adc_temp_trims_get(float * pfTemp, float * pfVoltage, float * pfOffsetV)
|
||||
{
|
||||
//
|
||||
// Return trim temperature as a float, if you can.
|
||||
//
|
||||
if (pfTemp != NULL)
|
||||
{
|
||||
*pfTemp = priv_temp_trims.flt.fCalibrationTemperature;
|
||||
}
|
||||
|
||||
//
|
||||
// Return trim voltage as a float, if you can.
|
||||
//
|
||||
if (pfVoltage != NULL)
|
||||
{
|
||||
*pfVoltage = priv_temp_trims.flt.fCalibrationVoltage;
|
||||
}
|
||||
|
||||
//
|
||||
// Return trim ADC offset voltage as a float, if you can.
|
||||
//
|
||||
if (pfOffsetV != NULL)
|
||||
{
|
||||
*pfOffsetV = priv_temp_trims.flt.fCalibrationOffset;
|
||||
}
|
||||
|
||||
return priv_temp_trims.ui32.bMeasured;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set the ADC window parameters.
|
||||
//!
|
||||
//! @param ui32Upper - the upper limit for the ADC window.
|
||||
//! @param ui32Upper - the lower limit for the ADC window.
|
||||
//!
|
||||
//! This function may be used to change the ADC window parameters. Please note
|
||||
//! that the upper and lower limits are only 16-bits wide in the ADC hardware.
|
||||
//! This function will ignore the upper 16 bits of these arguments.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_window_set(uint32_t ui32Upper, uint32_t ui32Lower)
|
||||
{
|
||||
//
|
||||
// Set the window limits for the ADC.
|
||||
//
|
||||
AM_REG(ADC, WLIM) = AM_HAL_ADC_WINDOW(ui32Upper, ui32Lower);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configure a single ADC slot.
|
||||
//!
|
||||
//! @param ui32SlotNumber - the number of the ADC slot to be configured.
|
||||
//! @param ui32SlotConfig - contains slot-specific options.
|
||||
//!
|
||||
//! This function may be used to configure the settings for an individual ADC
|
||||
//! slot. The parameter \b ui32SlotConfig should be the logical 'OR' of a slot
|
||||
//! average macro, a slot hold-time macro, a slot channel macro, and
|
||||
//! optionally, the slot window enable macro.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_slot_config(uint32_t ui32SlotNumber, uint32_t ui32SlotConfig)
|
||||
{
|
||||
uint32_t ui32RegOffset;
|
||||
|
||||
//
|
||||
// Locate the correct register for this ADC slot.
|
||||
//
|
||||
ui32RegOffset = (AM_REG_ADCn(0) + AM_REG_ADC_SL0CFG_O +
|
||||
(4 * ui32SlotNumber));
|
||||
|
||||
//
|
||||
// Write the register with the caller's configuration value.
|
||||
//
|
||||
AM_REGVAL(ui32RegOffset) = ui32SlotConfig;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Read One ADC FIFO Entry.
|
||||
//!
|
||||
//! @param psFifoReadValue - pointer to FIFO Read Value Structure.
|
||||
//!
|
||||
//! This function reads the FIFO data register, extracts the bit fields and
|
||||
//! puts them into a device independent view of the values. It also grabs the
|
||||
//! interrupt status bits at the time the FIFO is read and returns them in
|
||||
//! the structure. Caller should check the return value to see if the FIFO
|
||||
//! contained anything useful. Caller can also use the return value to see if
|
||||
//! there are any additional values available at the time of call.
|
||||
//! Any interrupt status bits are cleared as a result of this call.
|
||||
//! The top of FIFO entry is popped off of the FIFO by this call, if any thing
|
||||
//! was present.
|
||||
//!
|
||||
//! This function can be called either from an ISR or from the Base level.
|
||||
//!
|
||||
//! This function can be called repeatedly on the ISR or Base level, until the
|
||||
//! the FIFO contains no more data, as indicated by a zero in the returned
|
||||
//! value.
|
||||
//!
|
||||
//! @return FIFO depth from reading FIFO register. Non-zero --> valid data
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_adc_fifo_read(am_hal_adc_fifo_read_t *psFifoReadValue)
|
||||
{
|
||||
uint32_t ui32FIFOValue;
|
||||
uint32_t ui32Count;
|
||||
|
||||
//
|
||||
// Grab a value from the ADC FIFO.
|
||||
//
|
||||
psFifoReadValue-> ui8IntStatus = AM_REG(ADC, INTSTAT);
|
||||
|
||||
//
|
||||
// Clear any current interrupts.
|
||||
//
|
||||
AM_REG(ADC, INTCLR) = psFifoReadValue-> ui8IntStatus;
|
||||
|
||||
//
|
||||
// Grab a value from the ADC FIFO.
|
||||
//
|
||||
ui32FIFOValue = AM_REG(ADC, FIFO);
|
||||
|
||||
//
|
||||
// Read once, extract the fields.
|
||||
//
|
||||
psFifoReadValue-> ui8Slot = AM_READ_SM(AM_REG_ADC_FIFO_SLOTNUM,
|
||||
ui32FIFOValue);
|
||||
psFifoReadValue->ui16Data = AM_READ_SM(AM_REG_ADC_FIFO_DATA, ui32FIFOValue);
|
||||
|
||||
//
|
||||
// Check FIFO valid bits.
|
||||
//
|
||||
ui32Count = AM_READ_SM(AM_REG_ADC_FIFO_COUNT, ui32FIFOValue);
|
||||
|
||||
if (ui32Count)
|
||||
{
|
||||
//
|
||||
// Pop the FIFO.
|
||||
//
|
||||
AM_REG(ADC, FIFO) = 0; // write anything to it.
|
||||
}
|
||||
|
||||
//
|
||||
// Return FIFO valid bits.
|
||||
//
|
||||
return ui32Count;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Issue Software Trigger to the ADC.
|
||||
//!
|
||||
//! This function issues the software trigger to the ADC.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_trigger(void)
|
||||
{
|
||||
//
|
||||
// Write to the Software trigger register in the ADC.
|
||||
//
|
||||
AM_REG(ADC, SWT) = 0x37;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the ADC.
|
||||
//!
|
||||
//! Use this function to enable the ADC.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_enable(void)
|
||||
{
|
||||
//
|
||||
// Enable the ADC.
|
||||
//
|
||||
AM_BFW(ADC, CFG, ADCEN, 0x1);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the ADC.
|
||||
//!
|
||||
//! Use this function to disable the ADC.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the ADC.
|
||||
//
|
||||
AM_BFW(ADC, CFG, ADCEN, 0x0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the ADC battery load resistor.
|
||||
//!
|
||||
//! Use this function to enable the ADC battery load resistor.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_batt_load_enable(void)
|
||||
{
|
||||
//
|
||||
// Enable the ADC battery load resistor.
|
||||
//
|
||||
AM_BFW(ADC, CFG, BATTLOAD,
|
||||
AM_REG_ADC_CFG_BATTLOAD_EN >> AM_REG_ADC_CFG_BATTLOAD_S);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the ADC battery load resistor.
|
||||
//!
|
||||
//! Use this function to disable the ADC battery load resistor.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_batt_load_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the ADC battery load resistor.
|
||||
//
|
||||
AM_BFW(ADC, CFG, BATTLOAD,
|
||||
AM_REG_ADC_CFG_BATTLOAD_DIS >> AM_REG_ADC_CFG_BATTLOAD_S);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable selected ADC Interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_adc.h.
|
||||
//!
|
||||
//! Use this function to enable the ADC interrupts.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_int_enable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Enable the interrupts.
|
||||
//
|
||||
AM_REG(ADC, INTEN) |= ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return enabled ADC Interrupts.
|
||||
//!
|
||||
//! Use this function to get all enabled ADC interrupts.
|
||||
//!
|
||||
//! @return enabled ADC Interrupts.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_adc_int_enable_get(void)
|
||||
{
|
||||
//
|
||||
// Return enabled interrupts.
|
||||
//
|
||||
return AM_REG(ADC, INTEN);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable selected ADC Interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_adc.h.
|
||||
//!
|
||||
//! Use this function to disable the ADC interrupts.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_int_disable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Disable the interrupts.
|
||||
//
|
||||
AM_REG(ADC, INTEN) &= ~ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clear selected ADC Interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_adc.h.
|
||||
//!
|
||||
//! Use this function to clear the ADC interrupts.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_int_clear(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Clear the interrupts.
|
||||
//
|
||||
AM_REG(ADC, INTCLR) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set selected ADC Interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_adc.h.
|
||||
//!
|
||||
//! Use this function to set the ADC interrupts.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_int_set(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Set the interrupts.
|
||||
//
|
||||
AM_REG(ADC, INTSET) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return either enabled or raw selected ADC interrupt status.
|
||||
//!
|
||||
//! @param bEnabledOnly - return the status of only the enabled interrupts.
|
||||
//!
|
||||
//! Use this function to get the ADC interrupt status.
|
||||
//!
|
||||
//! @return enabled or raw ADC interrupt status.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_adc_int_status_get(bool bEnabledOnly)
|
||||
{
|
||||
//
|
||||
// Return the status.
|
||||
//
|
||||
if (bEnabledOnly)
|
||||
{
|
||||
uint32_t u32RetVal = AM_REG(ADC, INTEN);
|
||||
u32RetVal &= AM_REG(ADC, INTSTAT);
|
||||
return u32RetVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AM_REG(ADC, INTSTAT);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return temperature in degrees C of supplied voltage.
|
||||
//!
|
||||
//! @param fVoltage - return the temperature corresponding to this voltage.
|
||||
//!
|
||||
//! Use this function to convert volts from the temperature sensor into degrees
|
||||
//! C. Caller converts ADC binary code to volts based on reference used.
|
||||
//! This routine looks up the trim parameters from OTP and returns corrected
|
||||
//! temperature.
|
||||
//!
|
||||
//! The computation is based on a line running through 0 degrees K.
|
||||
//! We find the slope from the trimmed temperature calibration point.
|
||||
//!
|
||||
//!
|
||||
//! @return the temperature in degrees C.
|
||||
//
|
||||
//*****************************************************************************
|
||||
float
|
||||
am_hal_adc_volts_to_celsius(float fVoltage)
|
||||
{
|
||||
float fTemp;
|
||||
|
||||
//
|
||||
// Get calibration temperature from trimmed values & convert to degrees K.
|
||||
//
|
||||
float fCalibration_temp = priv_temp_trims.flt.fCalibrationTemperature;
|
||||
|
||||
//
|
||||
// Get remaining trimmed values.
|
||||
//
|
||||
float fCalibration_voltage = priv_temp_trims.flt.fCalibrationVoltage;
|
||||
float fCalibration_offset = priv_temp_trims.flt.fCalibrationOffset;
|
||||
|
||||
//
|
||||
// Compute the temperature.
|
||||
//
|
||||
fTemp = fCalibration_temp;
|
||||
fTemp /= (fCalibration_voltage - fCalibration_offset);
|
||||
fTemp *= (fVoltage - fCalibration_offset);
|
||||
|
||||
//
|
||||
// Give it back to the caller in Celsius.
|
||||
//
|
||||
return fTemp - 273.15f;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,359 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_adc.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the Analog to Digital Converter
|
||||
//!
|
||||
//! @addtogroup adc1 Analog-to-Digital Converter (ADC)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_ADC_H
|
||||
#define AM_HAL_ADC_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Clock Selection
|
||||
//! @brief These macros may be used to set the ADC module's clock source.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_CLOCK_OFF AM_REG_ADC_CFG_CLKSEL_OFF
|
||||
#define AM_HAL_ADC_CLOCK_12MHZ AM_REG_ADC_CFG_CLKSEL_12MHZ
|
||||
#define AM_HAL_ADC_CLOCK_6MHZ AM_REG_ADC_CFG_CLKSEL_6MHZ
|
||||
#define AM_HAL_ADC_CLOCK_3MHZ AM_REG_ADC_CFG_CLKSEL_3MHZ
|
||||
#define AM_HAL_ADC_CLOCK_1_5MHZ AM_REG_ADC_CFG_CLKSEL_1_5MHZ
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Trigger Settings
|
||||
//! @brief ADC trigger setting macros.
|
||||
//!
|
||||
//! These macros alter the ADC's trigger source and trigger polarity. Note that
|
||||
//! the external trigger setting needs to be ORed with a POS or NEG option to
|
||||
//! define the desired trigger polarity.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_TRIGGER_FALL AM_REG_ADC_CFG_TRIGPOL_FALLING_EDGE
|
||||
#define AM_HAL_ADC_TRIGGER_RISE AM_REG_ADC_CFG_TRIGPOL_RISING_EDGE
|
||||
#define AM_HAL_ADC_TRIGGER_SOFT AM_REG_ADC_CFG_TRIGSEL(8)
|
||||
#define AM_HAL_ADC_TRIGGER_EXT(n) AM_REG_ADC_CFG_TRIGSEL(n)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Reference Settings
|
||||
//! @brief ADC reference voltage setting macros.
|
||||
//!
|
||||
//! These macros control the ADC reference voltage source.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_REF_VDD AM_REG_ADC_CFG_REFSEL_VDD
|
||||
#define AM_HAL_ADC_REF_EXT AM_REG_ADC_CFG_REFSEL_ADCREF
|
||||
#define AM_HAL_ADC_REF_INT AM_REG_ADC_CFG_REFSEL_INTERNAL
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Sample mode
|
||||
//! @brief ADC sample mode settings
|
||||
//!
|
||||
//! These macros control the maximum allowable sample rate of the ADC.
|
||||
//! Selecting a higher maximum sample rate will cause the microcontroller to
|
||||
//! allocate more current to the ADC. It is recommended that this setting is
|
||||
//! kept at the lowest possible value unless the application requires a faster
|
||||
//! sample rate.
|
||||
//!
|
||||
//! There are only two allowable settings to the mode register.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_MODE_125KSPS AM_REG_ADC_CFG_OPMODE(0)
|
||||
#define AM_HAL_ADC_MODE_1MSPS AM_REG_ADC_CFG_OPMODE(2)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Low Power Mode
|
||||
//! @brief ADC power conservation settings.
|
||||
//!
|
||||
//! These macros select the power state to enter between active scans. Each low
|
||||
//! power mode has it's own set of timing constraints. Please see the datasheet
|
||||
//! for additional timing information on each power mode.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_LPMODE_NONE AM_REG_ADC_CFG_LPMODE(0)
|
||||
#define AM_HAL_ADC_LPMODE_1 AM_REG_ADC_CFG_LPMODE(1)
|
||||
#define AM_HAL_ADC_LPMODE_2 AM_REG_ADC_CFG_LPMODE(2)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable repeating scan mode.
|
||||
//!
|
||||
//! Use this macro to enable repeating scans using a timer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_REPEAT AM_REG_ADC_CFG_RPTEN(1)
|
||||
#define AM_HAL_ADC_NO_REPEAT AM_REG_ADC_CFG_RPTEN(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Power On Temp Sensor
|
||||
//!
|
||||
//! Use this macro to turn on the temp sensor
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_PON_TEMP AM_REG_ADC_CFG_TMPSPWR_EN
|
||||
#define AM_HAL_ADC_POFF_TEMP AM_REG_ADC_CFG_TMPSPWR_DIS
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set ADC window limits.
|
||||
//!
|
||||
//! Use this macro to set the window limits on the ADC.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_WINDOW(upper, lower) \
|
||||
((upper << 16) | (lower & 0xFFFF))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Slot configuration
|
||||
//! @brief Slot configuration macros
|
||||
//!
|
||||
//! These macros may be used to configure an individual ADC slot.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_SLOT_AVG_1 AM_REG_ADC_SL0CFG_ADSEL0(0)
|
||||
#define AM_HAL_ADC_SLOT_AVG_2 AM_REG_ADC_SL0CFG_ADSEL0(1)
|
||||
#define AM_HAL_ADC_SLOT_AVG_4 AM_REG_ADC_SL0CFG_ADSEL0(2)
|
||||
#define AM_HAL_ADC_SLOT_AVG_8 AM_REG_ADC_SL0CFG_ADSEL0(3)
|
||||
#define AM_HAL_ADC_SLOT_AVG_16 AM_REG_ADC_SL0CFG_ADSEL0(4)
|
||||
#define AM_HAL_ADC_SLOT_AVG_32 AM_REG_ADC_SL0CFG_ADSEL0(5)
|
||||
#define AM_HAL_ADC_SLOT_AVG_64 AM_REG_ADC_SL0CFG_ADSEL0(6)
|
||||
#define AM_HAL_ADC_SLOT_AVG_128 AM_REG_ADC_SL0CFG_ADSEL0(7)
|
||||
|
||||
#define AM_HAL_ADC_SLOT_HOLD_1 AM_REG_ADC_SL0CFG_THSEL0(0)
|
||||
#define AM_HAL_ADC_SLOT_HOLD_2 AM_REG_ADC_SL0CFG_THSEL0(1)
|
||||
#define AM_HAL_ADC_SLOT_HOLD_4 AM_REG_ADC_SL0CFG_THSEL0(2)
|
||||
#define AM_HAL_ADC_SLOT_HOLD_8 AM_REG_ADC_SL0CFG_THSEL0(3)
|
||||
#define AM_HAL_ADC_SLOT_HOLD_16 AM_REG_ADC_SL0CFG_THSEL0(4)
|
||||
#define AM_HAL_ADC_SLOT_HOLD_32 AM_REG_ADC_SL0CFG_THSEL0(5)
|
||||
#define AM_HAL_ADC_SLOT_HOLD_64 AM_REG_ADC_SL0CFG_THSEL0(6)
|
||||
#define AM_HAL_ADC_SLOT_HOLD_128 AM_REG_ADC_SL0CFG_THSEL0(7)
|
||||
|
||||
#define AM_HAL_ADC_SLOT_CHANNEL(n) AM_REG_ADC_SL0CFG_CHSEL0(n)
|
||||
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_EXT0 AM_REG_ADC_SL0CFG_CHSEL0_EXT0
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_EXT1 AM_REG_ADC_SL0CFG_CHSEL0_EXT1
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_EXT2 AM_REG_ADC_SL0CFG_CHSEL0_EXT2
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_EXT3 AM_REG_ADC_SL0CFG_CHSEL0_EXT3
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_EXT4 AM_REG_ADC_SL0CFG_CHSEL0_EXT4
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_EXT5 AM_REG_ADC_SL0CFG_CHSEL0_EXT5
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_EXT6 AM_REG_ADC_SL0CFG_CHSEL0_EXT6
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_EXT7 AM_REG_ADC_SL0CFG_CHSEL0_EXT7
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_TEMP AM_REG_ADC_SL0CFG_CHSEL0_TEMP
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_VDD AM_REG_ADC_SL0CFG_CHSEL0_VDD
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_VSS AM_REG_ADC_SL0CFG_CHSEL0_VSS
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_VBATT AM_REG_ADC_SL0CFG_CHSEL0_VBATT
|
||||
|
||||
#define AM_HAL_ADC_SLOT_WINDOW_EN AM_REG_ADC_SL0CFG_WCEN0(1)
|
||||
#define AM_HAL_ADC_SLOT_ENABLE AM_REG_ADC_SL0CFG_SLEN0(1)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Interrupt Status Bits
|
||||
//! @brief Interrupt Status Bits for enable/disble use
|
||||
//!
|
||||
//! These macros may be used to enable an individual ADC interrupt cause.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_INTEN_WCINC AM_REG_ADC_INTEN_WCINC(1)
|
||||
#define AM_HAL_ADC_INTEN_WCEXC AM_REG_ADC_INTEN_WCEXC(1)
|
||||
#define AM_HAL_ADC_INTEN_FIFOOVR2 AM_REG_ADC_INTEN_FIFOOVR2(1)
|
||||
#define AM_HAL_ADC_INTEN_FIFOOVR1 AM_REG_ADC_INTEN_FIFOOVR1(1)
|
||||
#define AM_HAL_ADC_INTEN_SCNCMP AM_REG_ADC_INTEN_SCNCMP(1)
|
||||
#define AM_HAL_ADC_INTEN_CNVCMP AM_REG_ADC_INTEN_CNVCMP(1)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Temperature Trim Value Locations
|
||||
//! @brief Temperature calibration trim value locations in OTP.
|
||||
//!
|
||||
//! These macros are used to access the temperature trim values in OTP.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_CALIB_AMBIENT_ADDR (0x5002004C)
|
||||
#define AM_HAL_ADC_CALIB_AMBIENT_OFFSET (0x0000004C)
|
||||
#define AM_HAL_ADC_CALIB_TEMP_ADDR (0x50020050)
|
||||
#define AM_HAL_ADC_CALIB_TEMP_OFFSET (0x00000050)
|
||||
#define AM_HAL_ADC_CALIB_ADC_OFFSET_ADDR (0x50020054)
|
||||
#define AM_HAL_ADC_CALIB_ADC_OFFSET_OFFSET (0x00000054)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configuration structure for the ADC.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! Select the ADC Clock source using one of the clock source macros.
|
||||
//
|
||||
uint32_t ui32Clock;
|
||||
|
||||
//
|
||||
//! Select the ADC trigger source using a trigger source macro.
|
||||
//
|
||||
uint32_t ui32TriggerConfig;
|
||||
|
||||
//
|
||||
//! Use a macro to select the ADC reference voltage.
|
||||
//
|
||||
uint32_t ui32Reference;
|
||||
|
||||
//
|
||||
//! Use a macro to choose a maximum sample rate setting.
|
||||
//
|
||||
uint32_t ui32MaxSampleRate;
|
||||
|
||||
//
|
||||
//! Use a macro to choose the power mode for the ADC's idle state.
|
||||
//
|
||||
uint32_t ui32PowerMode;
|
||||
|
||||
//
|
||||
//! Use the Repeat macro to enable repeating samples using Timer3A
|
||||
//
|
||||
uint32_t ui32Repeat;
|
||||
|
||||
//
|
||||
//! Power on the Temperature Sensor
|
||||
//
|
||||
uint32_t ui32POnTemp;
|
||||
|
||||
//
|
||||
//! Set the ADC window limits using the window limit macro.
|
||||
//
|
||||
uint32_t ui32Window;
|
||||
}
|
||||
am_hal_adc_config_t;
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief FIFO read value structure for the ADC.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! Interrupt status bits at the time the FIFO was read
|
||||
//
|
||||
uint8_t ui8IntStatus;
|
||||
|
||||
//
|
||||
//! 3 bit Slot # returning data for this FIFO read
|
||||
//
|
||||
uint8_t ui8Slot;
|
||||
|
||||
//
|
||||
//! 16 bit (10.6) ADC data from this FIFO read
|
||||
//
|
||||
uint16_t ui16Data;
|
||||
}
|
||||
am_hal_adc_fifo_read_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_adc_config(am_hal_adc_config_t *psConfig);
|
||||
extern void am_hal_adc_window_set(uint32_t ui32Upper, uint32_t ui32Lower);
|
||||
extern void am_hal_adc_slot_config(uint32_t ui32SlotNumber,
|
||||
uint32_t ui32SlotConfig);
|
||||
|
||||
extern uint32_t am_hal_adc_fifo_read(am_hal_adc_fifo_read_t *psFifoReadValue);
|
||||
extern void am_hal_adc_trigger(void);
|
||||
extern void am_hal_adc_enable(void);
|
||||
extern void am_hal_adc_disable(void);
|
||||
extern void am_hal_adc_batt_load_enable(void);
|
||||
extern void am_hal_adc_batt_load_disable(void);
|
||||
extern void am_hal_adc_int_enable(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_adc_int_enable_get(void);
|
||||
extern void am_hal_adc_int_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_adc_int_clear(uint32_t ui32Interrupt);
|
||||
extern void am_hal_adc_int_set(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_adc_int_status_get(bool bEnabledOnly);
|
||||
extern float am_hal_adc_volts_to_celsius(float fVoltage);
|
||||
extern bool am_hal_adc_temp_trims_get(float * pfTemp, float * pfVoltage, float * pfOffsetV);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_ADC_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,77 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_cachectrl.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the CACHE controller.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_CACHECTRL_H
|
||||
#define AM_HAL_CACHECTRL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These function-like macros stub out these functions for Apollo.
|
||||
//
|
||||
#define am_hal_cachectrl_config_default()
|
||||
#define am_hal_cachectrl_enable(x)
|
||||
#define am_hal_cachectrl_disable()
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_CACHECTRL_H
|
||||
@@ -0,0 +1,500 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_clkgen.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the CLKGEN.
|
||||
//!
|
||||
//! @addtogroup clkgen1 Clock Generator (CLKGEN)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Select the clock divisor for the main system clock.
|
||||
//!
|
||||
//! @param ui32ClockSetting - The divisor value for the system clock.
|
||||
//!
|
||||
//! This function can be used to select the frequency of the main system clock.
|
||||
//! The \e ui32ClockSetting parameter should be set to one of the following
|
||||
//! values:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_SYSCLK_24MHZ
|
||||
//! AM_HAL_CLKGEN_SYSCLK_12MHZ
|
||||
//! AM_HAL_CLKGEN_SYSCLK_8MHZ
|
||||
//! AM_HAL_CLKGEN_SYSCLK_6MHZ
|
||||
//! AM_HAL_CLKGEN_SYSCLK_4_8MHZ
|
||||
//! AM_HAL_CLKGEN_SYSCLK_4MHZ
|
||||
//! AM_HAL_CLKGEN_SYSCLK_3_4MHZ
|
||||
//! AM_HAL_CLKGEN_SYSCLK_3MHZ
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_sysclk_select(uint32_t ui32ClockSetting)
|
||||
{
|
||||
//
|
||||
// Unlock the clock control register.
|
||||
//
|
||||
AM_REG(CLKGEN, CLKKEY) = AM_REG_CLKGEN_CLKKEY_KEYVAL;
|
||||
|
||||
//
|
||||
// Set the HFRC divisor to the user-selected value.
|
||||
//
|
||||
AM_REG(CLKGEN, CCTRL) = ui32ClockSetting;
|
||||
|
||||
//
|
||||
// Lock the clock configuration registers.
|
||||
//
|
||||
AM_REG(CLKGEN, CLKKEY) = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the current system clock frequency.
|
||||
//!
|
||||
//! This function can be used to determine the frequency of the main system
|
||||
//! clock. The return value is the system clock frequency measured in hertz.
|
||||
//!
|
||||
//! @return System clock frequency in Hz
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_clkgen_sysclk_get(void)
|
||||
{
|
||||
uint32_t ui32ClockSetting;
|
||||
|
||||
//
|
||||
// Read the value of the clock divider.
|
||||
//
|
||||
ui32ClockSetting = AM_BFR(CLKGEN, CCTRL, CORESEL);
|
||||
|
||||
switch ( ui32ClockSetting )
|
||||
{
|
||||
case AM_HAL_CLKGEN_SYSCLK_24MHZ:
|
||||
return 24000000;
|
||||
case AM_HAL_CLKGEN_SYSCLK_12MHZ:
|
||||
return 12000000;
|
||||
case AM_HAL_CLKGEN_SYSCLK_8MHZ:
|
||||
return 8000000;
|
||||
case AM_HAL_CLKGEN_SYSCLK_6MHZ:
|
||||
return 6000000;
|
||||
case AM_HAL_CLKGEN_SYSCLK_4_8MHZ:
|
||||
return 4800000;
|
||||
case AM_HAL_CLKGEN_SYSCLK_4MHZ:
|
||||
return 4000000;
|
||||
case AM_HAL_CLKGEN_SYSCLK_3_4MHZ:
|
||||
return 3428571;
|
||||
case AM_HAL_CLKGEN_SYSCLK_3MHZ:
|
||||
return 3000000;
|
||||
default:
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable selected CLKGEN Interrupts.
|
||||
//!
|
||||
//! Use this function to enable the interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_clkgen.h
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_int_enable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Enable the interrupts.
|
||||
//
|
||||
AM_REG(CLKGEN, INTEN) |= ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return enabled CLKGEN Interrupts.
|
||||
//!
|
||||
//! Use this function to get all enabled CLKGEN interrupts.
|
||||
//!
|
||||
//! @return enabled CLKGEN interrupts.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_clkgen_int_enable_get(void)
|
||||
{
|
||||
//
|
||||
// Return the enabled interrupts.
|
||||
//
|
||||
return AM_REG(CLKGEN, INTEN);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable selected CLKGEN Interrupts.
|
||||
//!
|
||||
//! Use this function to disable the CLKGEN interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_clkgen.h
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_int_disable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Disable the interrupts.
|
||||
//
|
||||
AM_REG(CLKGEN, INTEN) &= ~ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Sets the interrupt status.
|
||||
//!
|
||||
//! @param ui32IntFlags interrupts to be enabled.
|
||||
//!
|
||||
//! This function sets the interrupts.
|
||||
//!
|
||||
//! Valid values for ui32IntFlags are:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_INT_RTC_ALARM
|
||||
//! AM_HAL_CLKGEN_INT_XT_FAIL
|
||||
//! AM_HAL_CLKGEN_INT_AUTOCAL_COMPLETE
|
||||
//! AM_HAL_CLKGEN_INT AUTOCAL_FAIL
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_int_set(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Set the interrupt status.
|
||||
//
|
||||
AM_REG(CLKGEN, INTSET) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Gets the interrupt configuration.
|
||||
//!
|
||||
//! @param bEnabledOnly - return the status of only the enabled interrupts.
|
||||
//!
|
||||
//! This function gets the currently configured interrupts.
|
||||
//!
|
||||
//! @return the configured interrupts.
|
||||
//!
|
||||
//! Possible values for the return are:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_INT_RTC_ALARM
|
||||
//! AM_HAL_CLKGEN_INT_XT_FAIL
|
||||
//! AM_HAL_CLKGEN_INT_AUTOCAL_COMPLETE
|
||||
//! AM_HAL_CLKGEN_INT AUTOCAL_FAIL
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_clkgen_int_status_get(bool bEnabledOnly)
|
||||
{
|
||||
//
|
||||
// Return the status.
|
||||
//
|
||||
if ( bEnabledOnly )
|
||||
{
|
||||
uint32_t u32RetVal = AM_REG(CLKGEN, INTSTAT);
|
||||
u32RetVal &= AM_REG(CLKGEN, INTEN);
|
||||
return u32RetVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AM_REG(CLKGEN, INTSTAT);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clears the interrupts.
|
||||
//!
|
||||
//! @param ui32IntFlags interrupts to be cleared.
|
||||
//!
|
||||
//! This function clears the interrupts.
|
||||
//!
|
||||
//! Valid values for ui32IntFlags are:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_INT_RTC_ALARM
|
||||
//! AM_HAL_CLKGEN_INT_XT_FAIL
|
||||
//! AM_HAL_CLKGEN_INT_AUTOCAL_COMPLETE
|
||||
//! AM_HAL_CLKGEN_INT AUTOCAL_FAIL
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_int_clear(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Clear the interrupts.
|
||||
//
|
||||
AM_REG(CLKGEN, INTCLR) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Starts the desired oscillator(s) (OSC).
|
||||
//!
|
||||
//! @param ui32OscFlags oscillator(s) to start.
|
||||
//!
|
||||
//! This function starts the desired oscillator(s) (OSC).
|
||||
//!
|
||||
//! Valid values for ui32OscFlags are:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_OSC_LFRC
|
||||
//! AM_HAL_CLKGEN_OSC_XT
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_osc_start(uint32_t ui32OscFlags)
|
||||
{
|
||||
if ( ui32OscFlags & (AM_HAL_CLKGEN_OSC_LFRC | AM_HAL_CLKGEN_OSC_XT) )
|
||||
{
|
||||
//
|
||||
// Start the oscillator(s).
|
||||
// Note that these bits are cleared in order to enable the oscillator.
|
||||
//
|
||||
AM_REG(CLKGEN, OCTRL) &= ~ui32OscFlags;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Stops the desired oscillator(s) (OSC).
|
||||
//!
|
||||
//! @param ui32OscFlags oscillator(s) to stop.
|
||||
//!
|
||||
//! This function stops the desired oscillator(s) (OSC).
|
||||
//!
|
||||
//! Valid values for ui32OscFlags are:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_OSC_LFRC
|
||||
//! AM_HAL_CLKGEN_OSC_XT
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_osc_stop(uint32_t ui32OscFlags)
|
||||
{
|
||||
if ( ui32OscFlags & (AM_HAL_CLKGEN_OSC_LFRC | AM_HAL_CLKGEN_OSC_XT) )
|
||||
{
|
||||
//
|
||||
// Stop the oscillator(s).
|
||||
// Note that these bits are set in order to stop the oscillator.
|
||||
//
|
||||
AM_REG(CLKGEN, OCTRL) |= ui32OscFlags;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enables the clock out signal.
|
||||
//!
|
||||
//! @param ui32Signal desired location for the clock out signal.
|
||||
//!
|
||||
//! This function enables the clock out signal. See am_reg_clkgen.h for
|
||||
//! available signals.
|
||||
//!
|
||||
//! ie. AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_clkout_enable(uint32_t ui32Signal)
|
||||
{
|
||||
//
|
||||
// Enable the clock out on desired signal.
|
||||
//
|
||||
AM_REG(CLKGEN, CLKOUT) = AM_REG_CLKGEN_CLKOUT_CKEN_M | ui32Signal;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disables the clock out signal.
|
||||
//!
|
||||
//! This function disables the clock out signal.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_clkout_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the clock out.
|
||||
//
|
||||
AM_REG(CLKGEN, CLKOUT) = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable UART system clock.
|
||||
//!
|
||||
//! This function enables or disables the UART system clock.
|
||||
//!
|
||||
//! @param ui32Module must be 0 for Apollo.
|
||||
//! @param ui32UartEn is one of the following.
|
||||
//! AM_HAL_CLKGEN_UARTEN_DIS
|
||||
//! AM_HAL_CLKGEN_UARTEN_EN
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_uarten_set(uint32_t ui32Module, uint32_t ui32UartEn)
|
||||
{
|
||||
uint32_t ui32Mask;
|
||||
|
||||
if ( (ui32Module >= AM_REG_UART_NUM_MODULES) ||
|
||||
(ui32UartEn > AM_HAL_CLKGEN_UARTEN_EN) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ui32UartEn <<= (ui32Module * AM_HAL_CLKGEN_UARTEN_UARTENn_S(ui32Module));
|
||||
ui32Mask = ~(AM_HAL_CLKGEN_UARTEN_UARTENn_M(ui32Module));
|
||||
|
||||
//
|
||||
// Begin critical section.
|
||||
//
|
||||
AM_CRITICAL_BEGIN
|
||||
|
||||
//
|
||||
// Set the UART clock
|
||||
//
|
||||
AM_REG(CLKGEN, UARTEN) &= ui32Mask;
|
||||
AM_REG(CLKGEN, UARTEN) |= ui32UartEn;
|
||||
|
||||
//
|
||||
// Begin critical section.
|
||||
//
|
||||
AM_CRITICAL_END
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enables HFRC auto-adjustment at the specified interval.
|
||||
//!
|
||||
//! @param ui32Warmup - How long to give the HFRC to stabilize during each
|
||||
//! calibration attempt.
|
||||
//! @param ui32Frequency - How often the auto-adjustment should happen.
|
||||
//!
|
||||
//! This function enables HFRC auto-adjustment from an external crystal
|
||||
//! oscillator even when the crystal is not normally being used.
|
||||
//!
|
||||
//! ui32Warmup should be one of the following values:
|
||||
//!
|
||||
//! AM_REG_CLKGEN_HFADJ_HFWARMUP_1SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFWARMUP_2SEC
|
||||
//!
|
||||
//! ui32Frequency should be one of the following values:
|
||||
//!
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_4SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_16SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_32SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_64SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_128SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_256SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_512SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_1024SEC
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_hfrc_adjust_enable(uint32_t ui32Warmup, uint32_t ui32Frequency)
|
||||
{
|
||||
//
|
||||
// Set the HFRC Auto-adjust register for the user's chosen settings. Assume
|
||||
// that the HFRC should be calibrated to 24 MHz and that the crystal is
|
||||
// running at 32.768 kHz.
|
||||
//
|
||||
AM_REG(CLKGEN, HFADJ) = (ui32Warmup |
|
||||
ui32Frequency |
|
||||
AM_REG_CLKGEN_HFADJ_HFXTADJ(732) |
|
||||
AM_REG_CLKGEN_HFADJ_HFADJEN_EN);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disables HFRC auto-adjustment.
|
||||
//!
|
||||
//! This function disables HFRC auto-adjustment.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_hfrc_adjust_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the clock out.
|
||||
//
|
||||
AM_REG(CLKGEN, HFADJ) = (AM_REG_CLKGEN_HFADJ_HFXTADJ(732) |
|
||||
AM_REG_CLKGEN_HFADJ_HFADJEN_DIS);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,216 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_clkgen.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the CLKGEN.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_CLKGEN_H
|
||||
#define AM_HAL_CLKGEN_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name System Clock max frequency
|
||||
//! @brief Defines the maximum clock frequency for this device.
|
||||
//!
|
||||
//! These macros provide a definition of the maximum clock frequency.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_FREQ_MAX_HZ 24000000
|
||||
#define AM_HAL_CLKGEN_FREQ_MAX_KHZ (AM_HAL_CLKGEN_FREQ_MAX_HZ / 1000)
|
||||
#define AM_HAL_CLKGEN_FREQ_MAX_MHZ (AM_HAL_CLKGEN_FREQ_MAX_HZ / 1000000)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name System Clock Selection
|
||||
//! @brief Divisor selection for the main system clock.
|
||||
//!
|
||||
//! These macros may be used along with the am_hal_clkgen_sysctl_select()
|
||||
//! function to select the frequency of the main system clock.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_SYSCLK_MAX AM_REG_CLKGEN_CCTRL_CORESEL_HFRC
|
||||
#define AM_HAL_CLKGEN_SYSCLK_24MHZ AM_REG_CLKGEN_CCTRL_CORESEL_HFRC
|
||||
#define AM_HAL_CLKGEN_SYSCLK_12MHZ AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV2
|
||||
#define AM_HAL_CLKGEN_SYSCLK_8MHZ AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV3
|
||||
#define AM_HAL_CLKGEN_SYSCLK_6MHZ AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV4
|
||||
#define AM_HAL_CLKGEN_SYSCLK_4_8MHZ AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV5
|
||||
#define AM_HAL_CLKGEN_SYSCLK_4MHZ AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV6
|
||||
#define AM_HAL_CLKGEN_SYSCLK_3_4MHZ AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV7
|
||||
#define AM_HAL_CLKGEN_SYSCLK_3MHZ AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV8
|
||||
#define AM_HAL_CLKGEN_CORESEL_MAXDIV AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV2
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Interrupt Status Bits
|
||||
//! @brief Interrupt Status Bits for enable/disble use
|
||||
//!
|
||||
//! These macros may be used to set and clear interrupt bits.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_INT_ALM AM_REG_CLKGEN_INTEN_ALM_M
|
||||
#define AM_HAL_CLKGEN_INT_OF AM_REG_CLKGEN_INTEN_OF_M
|
||||
#define AM_HAL_CLKGEN_INT_ACC AM_REG_CLKGEN_INTEN_ACC_M
|
||||
#define AM_HAL_CLKGEN_INT_ACF AM_REG_CLKGEN_INTEN_ACF_M
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name OSC Start and Stop
|
||||
//! @brief OSC Start and Stop defines.
|
||||
//!
|
||||
//! OSC Start and Stop defines to be used with \e am_hal_clkgen_osc_x().
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_OSC_LFRC AM_REG_CLKGEN_OCTRL_STOPRC_M
|
||||
#define AM_HAL_CLKGEN_OSC_XT AM_REG_CLKGEN_OCTRL_STOPXT_M
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// OSC Start, Stop, Select defines
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV2 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV2
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV4 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV4
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV8 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV8
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV16 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV16
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV32 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV32
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_RTC_100Hz AM_REG_CLKGEN_CLKOUT_CKSEL_RTC_100Hz
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV2M AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV2M
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT AM_REG_CLKGEN_CLKOUT_CKSEL_XT
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_CG_100Hz AM_REG_CLKGEN_CLKOUT_CKSEL_CG_100Hz
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV2 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV2
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV4 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV4
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV8 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV8
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV32 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV32
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV64 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV64
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV128 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV128
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV256 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV256
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_CORE_CLK AM_REG_CLKGEN_CLKOUT_CKSEL_CORE_CLK
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_FLASH_CLK AM_REG_CLKGEN_CLKOUT_CKSEL_FLASH_CLK
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC_DIV2 AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV2
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC_DIV32 AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV32
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC_DIV512 AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV512
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC_DIV32K AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV32K
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV256 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV256
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV8K AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV8K
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV64K AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV64K
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV16 AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV16
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV128 AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV128
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_ULFRC_1Hz AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_1Hz
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV4K AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV4K
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV1M AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV1M
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV64K AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV64K
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV16M AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV16M
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC_DIV2M AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV2M
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRCNE AM_REG_CLKGEN_CLKOUT_CKSEL_HFRCNE
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRCNE_DIV8 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRCNE_DIV8
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_CORE_CLKNE AM_REG_CLKGEN_CLKOUT_CKSEL_CORE_CLKNE
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XTNE AM_REG_CLKGEN_CLKOUT_CKSEL_XTNE
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XTNE_DIV16 AM_REG_CLKGEN_CLKOUT_CKSEL_XTNE_DIV16
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRCNE_DIV32 AM_REG_CLKGEN_CLKOUT_CKSEL_LFRCNE_DIV32
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_FCLKNE AM_REG_CLKGEN_CLKOUT_CKSEL_FCLKNE
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRCNE AM_REG_CLKGEN_CLKOUT_CKSEL_LFRCNE
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UARTEN
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_UARTEN_DIS 0
|
||||
#define AM_HAL_CLKGEN_UARTEN_EN AM_REG_CLKGEN_UARTEN_UARTEN_M
|
||||
|
||||
#define AM_HAL_CLKGEN_UARTEN_UARTENn_S(module) \
|
||||
((module) * 0)
|
||||
|
||||
#define AM_HAL_CLKGEN_UARTEN_UARTENn_M(module) \
|
||||
(AM_REG_CLKGEN_UARTEN_UARTEN_M << AM_HAL_CLKGEN_UARTEN_UARTENn_S(module))
|
||||
|
||||
//
|
||||
// UARTEN: entype is one of DIS, EN.
|
||||
//
|
||||
#define AM_HAL_CLKGEN_UARTEN_UARTENn(module, entype) \
|
||||
(AM_REG_CLKGEN_UARTEN_UARTEN_##entype << \
|
||||
AM_HAL_CLKGEN_UARTEN_UARTENn_S(module))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_clkgen_sysclk_select(uint32_t ui32ClockSetting);
|
||||
extern uint32_t am_hal_clkgen_sysclk_get(void);
|
||||
extern void am_hal_clkgen_osc_start(uint32_t ui32OscFlags);
|
||||
extern void am_hal_clkgen_osc_stop(uint32_t ui32OscFlags);
|
||||
extern void am_hal_clkgen_clkout_enable(uint32_t ui32Signal);
|
||||
extern void am_hal_clkgen_clkout_disable(void);
|
||||
extern void am_hal_clkgen_uarten_set(uint32_t ui32Module, uint32_t ui32UartEn);
|
||||
extern void am_hal_clkgen_int_enable(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_clkgen_int_enable_get(void);
|
||||
extern void am_hal_clkgen_int_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_clkgen_int_clear(uint32_t ui32Interrupt);
|
||||
extern void am_hal_clkgen_int_set(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_clkgen_int_status_get(bool bEnabledOnly);
|
||||
extern void am_hal_clkgen_hfrc_adjust_enable(uint32_t ui32Warmup, uint32_t ui32Frequency);
|
||||
extern void am_hal_clkgen_hfrc_adjust_disable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_CLKGEN_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,257 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_ctimer.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the CTIMER.
|
||||
//!
|
||||
//! @addtogroup ctimer1 Counter/Timer (CTIMER)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_CTIMER_H
|
||||
#define AM_HAL_CTIMER_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Interrupt Status Bits
|
||||
//! @brief Interrupt Status Bits for enable/disble use
|
||||
//!
|
||||
//! These macros may be used to set and clear interrupt bits
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_INT_TIMERA0 AM_REG_CTIMER_INTEN_CTMRA0INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB0 AM_REG_CTIMER_INTEN_CTMRB0INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERA1 AM_REG_CTIMER_INTEN_CTMRA1INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB1 AM_REG_CTIMER_INTEN_CTMRB1INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERA2 AM_REG_CTIMER_INTEN_CTMRA2INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB2 AM_REG_CTIMER_INTEN_CTMRB2INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERA3 AM_REG_CTIMER_INTEN_CTMRA3INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB3 AM_REG_CTIMER_INTEN_CTMRB3INT_M
|
||||
|
||||
//
|
||||
// Deprecated in Apollo2, use these macros on new code.
|
||||
//
|
||||
#define AM_HAL_CTIMER_INT_TIMERA0C0 AM_HAL_CTIMER_INT_TIMERA0
|
||||
#define AM_HAL_CTIMER_INT_TIMERB0C0 AM_HAL_CTIMER_INT_TIMERB0
|
||||
#define AM_HAL_CTIMER_INT_TIMERA1C0 AM_HAL_CTIMER_INT_TIMERA1
|
||||
#define AM_HAL_CTIMER_INT_TIMERB1C0 AM_HAL_CTIMER_INT_TIMERB1
|
||||
#define AM_HAL_CTIMER_INT_TIMERA2C0 AM_HAL_CTIMER_INT_TIMERA2
|
||||
#define AM_HAL_CTIMER_INT_TIMERB2C0 AM_HAL_CTIMER_INT_TIMERB2
|
||||
#define AM_HAL_CTIMER_INT_TIMERA3C0 AM_HAL_CTIMER_INT_TIMERA3
|
||||
#define AM_HAL_CTIMER_INT_TIMERB3C0 AM_HAL_CTIMER_INT_TIMERB3
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Configuration options
|
||||
//! @brief Configuration options for \e am_hal_ctimer_config_t
|
||||
//!
|
||||
//! These options are to be used with the \e am_hal_ctimer_config_t structure
|
||||
//! used by \e am_hal_ctimer_config
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_CLK_PIN AM_REG_CTIMER_CTRL0_TMRA0CLK(0x0)
|
||||
#define AM_HAL_CTIMER_HFRC_24MHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x1)
|
||||
#define AM_HAL_CTIMER_HFRC_3MHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x2)
|
||||
#define AM_HAL_CTIMER_HFRC_187_5KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x3)
|
||||
#define AM_HAL_CTIMER_HFRC_47KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x4)
|
||||
#define AM_HAL_CTIMER_HFRC_12KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x5)
|
||||
#define AM_HAL_CTIMER_XT_32_768KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x6)
|
||||
#define AM_HAL_CTIMER_XT_16_384KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x7)
|
||||
#define AM_HAL_CTIMER_XT_2_048KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x8)
|
||||
#define AM_HAL_CTIMER_XT_256HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x9)
|
||||
#define AM_HAL_CTIMER_LFRC_512HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0xA)
|
||||
#define AM_HAL_CTIMER_LFRC_32HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0xB)
|
||||
#define AM_HAL_CTIMER_LFRC_1HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0xC)
|
||||
#define AM_HAL_CTIMER_LFRC_1_16HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0xD)
|
||||
#define AM_HAL_CTIMER_RTC_100HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0xE)
|
||||
#define AM_HAL_CTIMER_HCLK AM_REG_CTIMER_CTRL0_TMRA0CLK(0xF)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Timer function macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_FN_ONCE AM_REG_CTIMER_CTRL0_TMRA0FN(0)
|
||||
#define AM_HAL_CTIMER_FN_REPEAT AM_REG_CTIMER_CTRL0_TMRA0FN(1)
|
||||
#define AM_HAL_CTIMER_FN_PWM_ONCE AM_REG_CTIMER_CTRL0_TMRA0FN(2)
|
||||
#define AM_HAL_CTIMER_FN_PWM_REPEAT AM_REG_CTIMER_CTRL0_TMRA0FN(3)
|
||||
#define AM_HAL_CTIMER_FN_CONTINUOUS AM_REG_CTIMER_CTRL0_TMRA0FN(4)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Half-timer options.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_INT_ENABLE AM_REG_CTIMER_CTRL0_TMRA0IE_M
|
||||
#define AM_HAL_CTIMER_PIN_ENABLE AM_REG_CTIMER_CTRL0_TMRA0PE_M
|
||||
#define AM_HAL_CTIMER_PIN_INVERT AM_REG_CTIMER_CTRL0_TMRA0POL_M
|
||||
#define AM_HAL_CTIMER_CLEAR AM_REG_CTIMER_CTRL0_TMRA0CLR_M
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Additional timer options.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_LINK AM_REG_CTIMER_CTRL0_CTLINK0_M
|
||||
#define AM_HAL_CTIMER_ADC_TRIG AM_REG_CTIMER_CTRL3_ADCEN_M
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Timer selection macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_TIMERA 0x0000FFFF
|
||||
#define AM_HAL_CTIMER_TIMERB 0xFFFF0000
|
||||
#define AM_HAL_CTIMER_BOTH 0xFFFFFFFF
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Timer configuration structure
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! Set to 1 to operate this timer as a 32-bit timer instead of two 16-bit
|
||||
//! timers.
|
||||
//
|
||||
uint32_t ui32Link;
|
||||
|
||||
//
|
||||
//! Configuration options for TIMERA
|
||||
//
|
||||
uint32_t ui32TimerAConfig;
|
||||
|
||||
//
|
||||
//! Configuration options for TIMERB
|
||||
//
|
||||
uint32_t ui32TimerBConfig;
|
||||
|
||||
}
|
||||
am_hal_ctimer_config_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Function pointer type for CTimer interrupt handlers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (*am_hal_ctimer_handler_t)(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_ctimer_config(uint32_t ui32TimerNumber,
|
||||
am_hal_ctimer_config_t *psConfig);
|
||||
|
||||
extern void am_hal_ctimer_config_single(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment,
|
||||
uint32_t ui32ConfigVal);
|
||||
|
||||
extern void am_hal_ctimer_start(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern void am_hal_ctimer_stop(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern void am_hal_ctimer_clear(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern uint32_t am_hal_ctimer_read(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern void am_hal_ctimer_pin_enable(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern void am_hal_ctimer_pin_disable(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern void am_hal_ctimer_pin_invert(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment,
|
||||
bool bInvertOutput);
|
||||
|
||||
extern void am_hal_ctimer_compare_set(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment,
|
||||
uint32_t ui32CompareReg,
|
||||
uint32_t ui32Value);
|
||||
|
||||
extern void am_hal_ctimer_period_set(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment,
|
||||
uint32_t ui32Period,
|
||||
uint32_t ui32OnTime);
|
||||
|
||||
extern void am_hal_ctimer_adc_trigger_enable(void);
|
||||
extern void am_hal_ctimer_adc_trigger_disable(void);
|
||||
extern void am_hal_ctimer_int_enable(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_ctimer_int_enable_get(void);
|
||||
extern void am_hal_ctimer_int_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_ctimer_int_set(uint32_t ui32Interrupt);
|
||||
extern void am_hal_ctimer_int_clear(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_ctimer_int_status_get(bool bEnabledOnly);
|
||||
extern void am_hal_ctimer_int_register(uint32_t ui32Interrupt,
|
||||
am_hal_ctimer_handler_t pfnHandler);
|
||||
extern void am_hal_ctimer_int_service(uint32_t ui32Status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_CTIMER_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,84 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_debug.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Useful functions for debugging.
|
||||
//!
|
||||
//! These functions and macros were created to assist with debugging. They are
|
||||
//! intended to be as unintrusive as possible and designed to be removed from
|
||||
//! the compilation of a project when they are no longer needed.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Default implementation of a failed ASSERT statement.
|
||||
//!
|
||||
//! @param pcFile is the name of the source file where the error occurred.
|
||||
//! @param ui32Line is the line number where the error occurred.
|
||||
//! @param pcMessage is an optional message describing the failure.
|
||||
//!
|
||||
//! This function is called by am_hal_debug_assert() macro when the supplied
|
||||
//! condition is not true. The implementation here simply halts the application
|
||||
//! for further analysis. Individual applications may define their own
|
||||
//! implementations of am_hal_debug_error() to provide more detailed feedback
|
||||
//! about the failed am_hal_debug_assert() statement.
|
||||
//!
|
||||
//! @return
|
||||
//
|
||||
//*****************************************************************************
|
||||
#if defined (__IAR_SYSTEMS_ICC__)
|
||||
__weak void
|
||||
#else
|
||||
void __attribute__((weak))
|
||||
#endif
|
||||
am_hal_debug_error(const char *pcFile, uint32_t ui32Line, const char *pcMessage)
|
||||
{
|
||||
//
|
||||
// Halt for analysis.
|
||||
//
|
||||
while(1);
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_debug.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Useful macros for debugging.
|
||||
//!
|
||||
//! These functions and macros were created to assist with debugging. They are
|
||||
//! intended to be as unintrusive as possible and designed to be removed from
|
||||
//! the compilation of a project when they are no longer needed.
|
||||
//!
|
||||
//! @addtogroup haldebug3 HAL Debug/Assert Utilities
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_DEBUG_H
|
||||
#define AM_HAL_DEBUG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Determine DBG_FILENAME
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// By spec and convention, the standard __FILE__ compiler macro includes a full
|
||||
// path (absolute or relative) to the file being compiled. This makes recreating
|
||||
// binaries virtually impossible unless rebuilt on the same or identically
|
||||
// configured system.
|
||||
//
|
||||
// To be able to build consistent binaries on different systems, we want to make
|
||||
// sure the full pathname is not included in the binary. Only IAR EWARM provides
|
||||
// an easy mechanism to provide only the filename without the path. For other
|
||||
// platforms, we will simply use a generic pathname.
|
||||
//
|
||||
#if defined (__IAR_SYSTEMS_ICC__)
|
||||
//
|
||||
// With EWARM the --no_path_in_file_macros option reduces __FILE__ to only the
|
||||
// module name. Therefore this define assumes the option is being used.
|
||||
//
|
||||
#define DBG_FILENAME __FILE__
|
||||
#elif defined(__KEIL__)
|
||||
//
|
||||
// Keil provides __MODULE__ which is simply the module name portion of __FILE__.
|
||||
//
|
||||
#define DBG_FILENAME __MODULE__
|
||||
#elif defined(__ARMCC_VERSION)
|
||||
#define DBG_FILENAME __MODULE__
|
||||
#else
|
||||
//
|
||||
// With GCC, we're out of luck.
|
||||
//
|
||||
#define DBG_FILENAME "debug_filename.ext"
|
||||
//#define DBG_FILENAME __FILE__
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Debug assert macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_DEBUG_NO_ASSERT
|
||||
|
||||
#define am_hal_debug_assert_msg(bCondition, pcMessage) \
|
||||
if ( !(bCondition)) am_hal_debug_error(DBG_FILENAME, __LINE__, pcMessage)
|
||||
|
||||
#define am_hal_debug_assert(bCondition) \
|
||||
if ( !(bCondition)) am_hal_debug_error(DBG_FILENAME, __LINE__, 0)
|
||||
|
||||
#else
|
||||
|
||||
#define am_hal_debug_assert_msg(bCondition, pcMessage)
|
||||
#define am_hal_debug_assert(bCondition)
|
||||
|
||||
#endif // AM_DEBUG_ASSERT
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function prototypes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_debug_error(const char *pcFile, uint32_t ui32Line,
|
||||
const char *pcMessage);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_DEBUG_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,439 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_flash.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for performing Flash operations.
|
||||
//!
|
||||
//! @addtogroup flash1 Flash
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//
|
||||
// Look-up table
|
||||
//
|
||||
const g_am_hal_flash_t g_am_hal_flash =
|
||||
{
|
||||
// am_hal_flash_mass_erase
|
||||
((int (*)(uint32_t, uint32_t)) 0x0800004d),
|
||||
// am_hal_flash_page_erase
|
||||
((int (*)(uint32_t, uint32_t, uint32_t)) 0x08000051),
|
||||
// am_hal_flash_program_main
|
||||
((int (*)(uint32_t, const uint32_t *, uint32_t *, uint32_t)) 0x08000055),
|
||||
// am_hal_flash_program_otp
|
||||
((int (*)(uint32_t, uint32_t, const uint32_t *, uint32_t, uint32_t)) 0x08000059),
|
||||
// am_hal_flash_program_main_sram
|
||||
((void (*)(void)) 0x0800005d),
|
||||
// am_hal_flash_program_otp_sram
|
||||
((void (*)(void)) 0x08000061),
|
||||
// am_hal_flash_erase_main_pages_sram
|
||||
((void (*)(void)) 0x08000065),
|
||||
// am_hal_flash_mass_erase_sram
|
||||
((void (*)(void)) 0x08000069)
|
||||
};
|
||||
|
||||
//
|
||||
// Set up a very small function that will be guaranteed to be located in SRAM
|
||||
// which can be used to to retrieve data from OTP.
|
||||
// Make sure the function is word-aligned.
|
||||
//
|
||||
uint32_t SRAM_load_ui32[8 / 4] =
|
||||
{
|
||||
0xBF006800, // 6800 ldr r0,[r0,#0]
|
||||
// BF00 nop
|
||||
0xBF004770 // 4770 bx lr
|
||||
// BF00 nop
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Implement an iterative spin loop.
|
||||
//!
|
||||
//! @param ui32Iterations - Number of iterations to delay.
|
||||
//!
|
||||
//! Use this function to implement a CPU busy waiting spin. For Apollo, this
|
||||
//! delay can be used for timing purposes since for Apollo, each iteration will
|
||||
//! take 3 cycles.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
__asm void
|
||||
am_hal_flash_delay(uint32_t ui32Iterations)
|
||||
{
|
||||
SUBS R0, #1
|
||||
BNE am_hal_flash_delay
|
||||
BX LR
|
||||
}
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
void __attribute__((naked))
|
||||
am_hal_flash_delay(uint32_t ui32Iterations)
|
||||
{
|
||||
__asm(" subs r0, #1\n"
|
||||
" bne am_hal_flash_delay\n"
|
||||
" bx lr");
|
||||
}
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
void __attribute__((naked))
|
||||
am_hal_flash_delay(uint32_t ui32Iterations)
|
||||
{
|
||||
__asm(" subs r0, #1\n"
|
||||
" bne am_hal_flash_delay\n"
|
||||
" bx lr");
|
||||
}
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
void
|
||||
am_hal_flash_delay(uint32_t ui32Iterations)
|
||||
{
|
||||
asm("SUBS R0, #1");
|
||||
asm("BNE.N am_hal_flash_delay");
|
||||
asm("BX LR");
|
||||
}
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Delays for a desired amount of cycles while also waiting for a
|
||||
//! status change.
|
||||
//!
|
||||
//! @param ui32usMaxDelay - Maximum number of ~1uS delay loops.
|
||||
//! @param ui32Address - Address of the register for the status change.
|
||||
//! @param ui32Mask - Mask for the status change.
|
||||
//! @param ui32Value - Target value for the status change.
|
||||
//!
|
||||
//! This function will delay for approximately the given number of microseconds
|
||||
//! while checking for a status change, exiting when either the given time has
|
||||
//! expired or the status change is detected.
|
||||
//!
|
||||
//! @returns 0 = timeout.
|
||||
//! 1 = status change detected.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_flash_delay_status_change(uint32_t ui32usMaxDelay, uint32_t ui32Address,
|
||||
uint32_t ui32Mask, uint32_t ui32Value)
|
||||
{
|
||||
while ( ui32usMaxDelay-- )
|
||||
{
|
||||
//
|
||||
// Check the status
|
||||
//
|
||||
if ( ( AM_REGVAL(ui32Address) & ui32Mask ) == ui32Value )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Call the BOOTROM cycle function to delay for about 1 microsecond.
|
||||
//
|
||||
am_hal_flash_delay( FLASH_CYCLES_US(1) );
|
||||
}
|
||||
|
||||
return 0;
|
||||
} // am_hal_flash_delay_status_change()
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief This function performs a mass erase on a flash block.
|
||||
//!
|
||||
//! @param ui32Value - The flash program key.
|
||||
//! @param ui32FlashBlk - The flash block to erase.
|
||||
//!
|
||||
//! This function will erase the desired block of flash.
|
||||
//!
|
||||
//! @note Each flash block contains a maximum of 256kB.
|
||||
//!
|
||||
//! @return 0 for success, non-zero for failure.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
am_hal_flash_mass_erase(uint32_t ui32Value, uint32_t ui32FlashBlk)
|
||||
{
|
||||
return g_am_hal_flash.am_hal_flash_mass_erase(ui32Value, ui32FlashBlk);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief This function performs a page erase on a flash block.
|
||||
//!
|
||||
//! @param ui32Value - The flash program key.
|
||||
//! @param ui32FlashBlk - The flash block to reference the page number with.
|
||||
//! @param ui32PageNum - The flash page offset into the selected block.
|
||||
//!
|
||||
//! This function will erase the desired flash page in the desired block of
|
||||
//! flash.
|
||||
//!
|
||||
//! @note For Apollo, each flash page is 2KB (or AM_HAL_FLASH_PAGE_SIZE).
|
||||
//! Each flash block (instance) contains a maximum of 128 pages
|
||||
//! (or AM_HAL_FLASH_BLOCK_PAGES).
|
||||
//!
|
||||
//! @note When given an absolute flash address, a couple of helpful macros can
|
||||
//! be utilized when calling this function.
|
||||
//! For example:
|
||||
//! am_hal_flash_page_erase(AM_HAL_FLASH_PROGRAM_KEY,
|
||||
//! AM_HAL_FLASH_ADDR2BLOCK(ui32Addr),
|
||||
//! AM_HAL_FLASH_ADDR2PAGE(ui32Addr) );
|
||||
//!
|
||||
//! @return 0 for success, non-zero for failure.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
am_hal_flash_page_erase(uint32_t ui32Value, uint32_t ui32FlashBlk,
|
||||
uint32_t ui32PageNum)
|
||||
{
|
||||
return g_am_hal_flash.am_hal_flash_page_erase(ui32Value, ui32FlashBlk,
|
||||
ui32PageNum);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief This programs up to N bytes of the Main array on one flash block.
|
||||
//!
|
||||
//! @param ui32Value - The Program key.
|
||||
//! @param pui32Src - Pointer to word aligned array of data to program into
|
||||
//! the flash block.
|
||||
//! @param pui32Dst - Pointer to word aligned location to to begin programming
|
||||
//! the flash block.
|
||||
//! @param ui32NumWords - The Number of words to program.
|
||||
//!
|
||||
//! This function will program multiple words in the OTP block on flash
|
||||
//! block (instance) 0.
|
||||
//!
|
||||
//! @return 0 for success, non-zero for failure.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
am_hal_flash_program_main(uint32_t ui32Value, const uint32_t *pui32Src,
|
||||
uint32_t *pui32Dst, uint32_t ui32NumWords)
|
||||
{
|
||||
return g_am_hal_flash.am_hal_flash_program_main(ui32Value, pui32Src,
|
||||
pui32Dst, ui32NumWords);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief This function programs multiple words in the OTP.
|
||||
//!
|
||||
//! @param ui32Value - The OTP key.
|
||||
//! @param ui32FlashBlk - The flash block where OTP lives (forced to block 0)
|
||||
//! @param *pui32Src - Pointer to word aligned array of data to program into
|
||||
//! the OTP block.
|
||||
//! @param ui32Offset - Word offset into OTP (offset of 0 is the first word).
|
||||
//! @param ui32NumWords - The Number of words to program.
|
||||
//!
|
||||
//! This function will program multiple words in the OTP block on flash
|
||||
//! block (instance) 0.
|
||||
//!
|
||||
//! @note Only the upper half of the OTP block can be written
|
||||
//! so 1 < ui32NumWords < 257.
|
||||
//!
|
||||
//! @return 0 for success, non-zero for failure.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
am_hal_flash_program_otp(uint32_t ui32Value, uint32_t ui32FlashBlk,
|
||||
const uint32_t *pui32Src, uint32_t ui32Offset,
|
||||
uint32_t ui32NumWords)
|
||||
{
|
||||
return g_am_hal_flash.am_hal_flash_program_otp(ui32Value, 0, pui32Src,
|
||||
ui32Offset, ui32NumWords);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief This function programs multiple words in the OTP using SRAM as args.
|
||||
//!
|
||||
//! This function will program multiple words in the OTP block using SRAM as
|
||||
//! its arguments. This is helpful for tools/manufacturing.
|
||||
//!
|
||||
//! The SRAM addresses of interest are:
|
||||
//!
|
||||
//! 0x10000000 Offset in to OTP block, 0 <= Offset < 256
|
||||
//! 0x10000004 Number of 32-bit words to program
|
||||
//! 0x10000008 OTP key
|
||||
//! 0x1000000C Debugger sets this to -1 and all return codes are >= 0
|
||||
//! 0x10000010 First 32-bit word of data buffer to be programmed
|
||||
//!
|
||||
//! @note This routine spins when am_hal_flash_program_otp() returns and waits
|
||||
//! for the debugger surrogate in the parallel programmer.
|
||||
//!
|
||||
//! @return never returns, spins here waiting for debugger or debugger surrogate
|
||||
//! on the parallel programmer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_flash_program_otp_sram(void)
|
||||
{
|
||||
g_am_hal_flash.am_hal_flash_program_otp_sram();
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief This function erases pages in the main array using SRAM as args.
|
||||
//!
|
||||
//! This function will erase multiple pages in the flash main array using SRAM
|
||||
//! as its arguments. This is helpful for tools/manufacturing.
|
||||
//!
|
||||
//! The SRAM addresses of interest are:
|
||||
//!
|
||||
//! 0x10000000 Flash block/instance number
|
||||
//! 0x10000004 Number of pages to erase (must be between 1 and 128
|
||||
//! inclusive)
|
||||
//! 0x10000008 PROGRAM key
|
||||
//! 0x1000000C Debugger sets this to -1 and all return codes are >= 0
|
||||
//! 0x10000010 Page number of the first flash page to erase. NOTE: these
|
||||
//! *HAVE* to be sequential (range 0 <= PageNumber <= 127)
|
||||
//!
|
||||
//! @note This routine spins when am_hal_flash_page_erase() returns and waits
|
||||
//! for the debugger surrogate in the parallel programmer. Before spinning it
|
||||
//! unconditional executes a break point instruction.
|
||||
//!
|
||||
//! @return never returns, spins here waiting for debugger or debugger surrogate
|
||||
//! on the parallel programmer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_flash_erase_main_pages_sram(void)
|
||||
{
|
||||
g_am_hal_flash.am_hal_flash_erase_main_pages_sram();
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief This function mass erases a flash block with SRAM as args.
|
||||
//!
|
||||
//! This function will perform a mass erase on a flash block using SRAM as its
|
||||
//! arguments. This is helpful for tools/manufacturing.
|
||||
//!
|
||||
//! The SRAM addresses of interest are:
|
||||
//!
|
||||
//! 0x10000000 Pointer in to flash block.
|
||||
//! 0x10000004 PROGRAM key
|
||||
//! 0x10000008 Return code (Debugger sets this to -1 and all return
|
||||
//! codes are >= 0)
|
||||
//!
|
||||
//! @note This routine spins when am_hal_flash_mass_erase() returns and waits
|
||||
//! for the debugger surrogate in the parallel programmer.
|
||||
//!
|
||||
//! @return never returns, spins here waiting for debugger or debugger surrogate
|
||||
//! on the parallel programmer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_flash_mass_erase_sram(void)
|
||||
{
|
||||
g_am_hal_flash.am_hal_flash_mass_erase_sram();
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief This function programs the main array using SRAM as args.
|
||||
//!
|
||||
//! This function will program the main array using SRAM as it arguments. This
|
||||
//! is helpful for tools/manufacturing.
|
||||
//!
|
||||
//! The SRAM addresses of interest are:
|
||||
//!
|
||||
//! 0x10000000 Pointer in to flash
|
||||
//! 0x10000004 Number of 32-bit words to program
|
||||
//! 0x10000008 PROGRAM key.
|
||||
//! 0x1000000C Debugger sets this to -1 and all return codes are >= 0
|
||||
//! 0x10000010 First 32-bit word of data buffer to be programmed
|
||||
//!
|
||||
//! @note This routine spins when am_hal_flash_program_main() returns and waits
|
||||
//! for the debugger surrogate in the parallel programmer. Before spinning it
|
||||
//! unconditionally executes a break point instruction.
|
||||
//!
|
||||
//! @return never returns, spins here waiting for debugger or debugger surrogate
|
||||
//! on the parallel programmer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_flash_program_main_sram(void)
|
||||
{
|
||||
g_am_hal_flash.am_hal_flash_program_main_sram();
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return ui32 value obtained from anywhere in D Code or System Bus
|
||||
//!
|
||||
//! @param ui32Address - return the value corresponding to this location in OTP
|
||||
//!
|
||||
//! Use this function to read a value from various peripheral locations
|
||||
//! that must be read from code running in SRAM.
|
||||
//!
|
||||
//! This function is not required to reside in SRAM as it calls a small
|
||||
//! function that does the actual read which is guaranteed to be in SRAM.
|
||||
//!
|
||||
//! @return the value found
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_flash_load_ui32(uint32_t ui32Address)
|
||||
{
|
||||
//
|
||||
// Call the simple routine that has been set up in SRAM as an array.
|
||||
// First set up a function pointer to the array, being sure to set the
|
||||
// .T bit (Thumb bit, bit0) in the branch address, then use that
|
||||
// function ptr to call the SRAM function.
|
||||
//
|
||||
uint32_t SRAMCode = (uint32_t)SRAM_load_ui32 | 0x1;
|
||||
uint32_t (*pFunc)(uint32_t) = (uint32_t (*)(uint32_t))SRAMCode;
|
||||
return (*pFunc)(ui32Address);
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,184 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_flash.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for performing Flash operations.
|
||||
//!
|
||||
//! @addtogroup flash1 Flash
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_FLASH_H
|
||||
#define AM_HAL_FLASH_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Flash Program keys.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_FLASH_PROGRAM_KEY 0x12344321
|
||||
#define AM_HAL_FLASH_OTP_KEY 0x87655678
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Some helpful flash values and macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_FLASH_ADDR 0x00000000
|
||||
#define AM_HAL_FLASH_PAGE_SIZE ( 2 * 1024 )
|
||||
#define AM_HAL_FLASH_INFO_SIZE AM_HAL_FLASH_PAGE_SIZE
|
||||
#define AM_HAL_FLASH_BLOCK_SIZE ( 256 * 1024 )
|
||||
#define AM_HAL_FLASH_BLOCK_PAGES ( AM_HAL_FLASH_BLOCK_SIZE / AM_HAL_FLASH_PAGE_SIZE )
|
||||
#define AM_HAL_FLASH_INSTANCE_SIZE AM_HAL_FLASH_BLOCK_SIZE
|
||||
#define AM_HAL_FLASH_INSTANCE_PAGES AM_HAL_FLASH_BLOCK_PAGES
|
||||
#define AM_HAL_FLASH_TOTAL_SIZE ( AM_HAL_FLASH_BLOCK_SIZE * 2 )
|
||||
#define AM_HAL_FLASH_LARGEST_VALID_ADDR ( AM_HAL_FLASH_ADDR + AM_HAL_FLASH_TOTAL_SIZE - 1 )
|
||||
|
||||
//
|
||||
// Convert an absolute flash address to a block (instance)
|
||||
//
|
||||
#define AM_HAL_FLASH_ADDR2BLOCK(addr) ( ( addr >> 18 ) & 1 )
|
||||
#define AM_HAL_FLASH_ADDR2INST(addr) ( ( addr >> 18 ) & 1 )
|
||||
|
||||
//
|
||||
// Convert an absolute flash address to a page number relative to the block
|
||||
//
|
||||
#define AM_HAL_FLASH_ADDR2PAGE(addr) ( ( addr >> 11 ) & 0x7F )
|
||||
|
||||
//
|
||||
// Convert an absolute flash address to an absolute page number
|
||||
//
|
||||
#define AM_HAL_FLASH_ADDR2ABSPAGE(addr) ( addr >> 11 )
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Given an integer number of microseconds, convert to a value representing the
|
||||
// number of am_hal_flash_delay() cycles that will provide that amount of delay.
|
||||
// This macro is designed to take into account some of the call overhead.
|
||||
//
|
||||
// e.g. To provide a 2us delay:
|
||||
// am_hal_flash_delay( FLASH_CYCLES_US(2) );
|
||||
//
|
||||
// IMPORTANT - Apollo is spec'ed to run at multiple frequencies from 24MHz down
|
||||
// to 3MHz. The macro must be able to handle any frequency and must be
|
||||
// determined at runtime. Because 3MHz is a valid frequency, the macro cannot
|
||||
// account for any overhead.
|
||||
// For best results, when 24MHz operation is known use FLASH_CYCLES_US_MAX().
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define FLASH_CYCLES_US_MAX(n) ((n * (AM_HAL_CLKGEN_FREQ_MAX_MHZ / 3)) - 4)
|
||||
#define FLASH_CYCLES_US(n) ((n * ((am_hal_clkgen_sysclk_get() / 1000000) / 3)) - 0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Structure of function pointers to helper functions for invoking various
|
||||
// flash operations.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct am_hal_flash_helper_struct
|
||||
{
|
||||
int (*am_hal_flash_mass_erase)(uint32_t, uint32_t);
|
||||
int (*am_hal_flash_page_erase)(uint32_t, uint32_t, uint32_t);
|
||||
int (*am_hal_flash_program_main)(uint32_t, const uint32_t *,
|
||||
uint32_t*, uint32_t);
|
||||
int (*am_hal_flash_program_otp)(uint32_t, uint32_t,
|
||||
const uint32_t*, uint32_t, uint32_t);
|
||||
void (*am_hal_flash_program_main_sram)(void);
|
||||
void (*am_hal_flash_program_otp_sram)(void);
|
||||
void (*am_hal_flash_erase_main_pages_sram)(void);
|
||||
void (*am_hal_flash_mass_erase_sram)(void);
|
||||
} g_am_hal_flash_t;
|
||||
extern const g_am_hal_flash_t g_am_hal_flash;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Function prototypes for the helper functions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_flash_delay(uint32_t ui32Iterations);
|
||||
extern uint32_t am_hal_flash_delay_status_change(uint32_t ui32usDelay,
|
||||
uint32_t ui32Address,
|
||||
uint32_t ui32Mask,
|
||||
uint32_t ui32Value);
|
||||
extern int am_hal_flash_mass_erase(uint32_t ui32Value,
|
||||
uint32_t ui32FlashBlk);
|
||||
extern int am_hal_flash_page_erase(uint32_t ui32Value,
|
||||
uint32_t ui32FlashBlk,
|
||||
uint32_t ui32PageNum);
|
||||
extern int am_hal_flash_program_otp(uint32_t ui32Value,
|
||||
uint32_t ui32FlashBlk,
|
||||
const uint32_t *pui32Src,
|
||||
uint32_t ui32Offset,
|
||||
uint32_t ui32NumWords);
|
||||
extern int am_hal_flash_program_main(uint32_t value, const uint32_t *pSrc,
|
||||
uint32_t *pDst, uint32_t NumberOfWords);
|
||||
|
||||
// SRAM variants
|
||||
extern void am_hal_flash_erase_main_pages_sram(void);
|
||||
extern void am_hal_flash_mass_erase_sram(void);
|
||||
extern void am_hal_flash_program_otp_sram(void);
|
||||
extern void am_hal_flash_program_main_sram(void);
|
||||
|
||||
// SRAM resident reader function for OTP can't be in FLASH
|
||||
uint32_t am_hal_flash_load_ui32(uint32_t ui32Address);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_FLASH_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,62 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_global.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Locate global variables here.
|
||||
//!
|
||||
//! This module contains global variables that are used throughout the HAL.
|
||||
//!
|
||||
//! One use in particular is that it uses a global HAL flags variable that
|
||||
//! contains flags used in various parts of the HAL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t volatile g_ui32HALflags = 0x00000000;
|
||||
@@ -0,0 +1,124 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_global.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Locate all HAL global variables here.
|
||||
//!
|
||||
//! This module contains global variables that are used throughout the HAL,
|
||||
//! but not necessarily those designated as const (which typically end up in
|
||||
//! flash). Consolidating globals here will make it easier to manage them.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_GLOBAL_H
|
||||
#define AM_HAL_GLOBAL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Device definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_DEVICE_NAME "Apollo"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Macros used to access the bit fields in the flags variable.
|
||||
//
|
||||
//******************************************************************************
|
||||
#define AM_HAL_FLAGS_BFR(flagnm) \
|
||||
((g_ui32HALflags & AM_HAL_FLAGS_##flagnm##_M) >> AM_HAL_FLAGS_##flagnm##_S)
|
||||
|
||||
#define AM_HAL_FLAGS_BFW(flagnm, value) \
|
||||
g_ui32HALflags = ((g_ui32HALflags & (~(AM_HAL_FLAGS_##flagnm##_M))) | \
|
||||
((value << AM_HAL_FLAGS_##flagnm##_S) & (AM_HAL_FLAGS_##flagnm##_M)) )
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// ITMSKIPENABLEDISABLE - Set when the ITM is not to be disabled. This is
|
||||
// typically needed by Keil debug.ini.
|
||||
//
|
||||
//******************************************************************************
|
||||
#define AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_S 0
|
||||
#define AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_M (1 << AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_S)
|
||||
#define AM_HAL_FLAGS_ITMSKIPENABLEDISABLE(n) (((n) << AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_S) & AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_M)
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// ITMBKPT - Breakpoint at the end of itm_enable(), which is needed by
|
||||
// Keil debug.ini.
|
||||
//
|
||||
//******************************************************************************
|
||||
#define AM_HAL_FLAGS_ITMBKPT_S 1
|
||||
#define AM_HAL_FLAGS_ITMBKPT_M (1 << AM_HAL_FLAGS_ITMBKPT_S)
|
||||
#define AM_HAL_FLAGS_ITMBKPT(n) (((n) << AM_HAL_FLAGS_ITMBKPT_S) & AM_HAL_FLAGS_ITMBKPT_M)
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Next available flag or bit field.
|
||||
//
|
||||
//******************************************************************************
|
||||
#define AM_HAL_FLAGS_NEXTBITFIELD_S 2
|
||||
#define AM_HAL_FLAGS_NEXTBITFIELD_M (1 << AM_HAL_FLAGS_NEXTBITFIELD_S)
|
||||
#define AM_HAL_FLAGS_NEXTBITFIELD(n) (((n) << AM_HAL_FLAGS_NEXTBITFIELD_S) & AM_HAL_FLAGS_NEXTBITFIELD_M)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Global Variables extern declarations.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern volatile uint32_t g_ui32HALflags;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_GLOBAL_H
|
||||
@@ -0,0 +1,495 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_gpio.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the GPIO module
|
||||
//!
|
||||
//! @addtogroup gpio1 GPIO
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Array of function pointers for handling GPIO interrupts.
|
||||
//
|
||||
//*****************************************************************************
|
||||
am_hal_gpio_handler_t am_hal_gpio_ppfnHandlers[64];
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Read the configuration information for the given pin..
|
||||
//!
|
||||
//! @param ui32GPIONum is the GPIO number whose configuration we want to read.
|
||||
//!
|
||||
//! This function reads the PADREG and CFG registers for the given GPIO and
|
||||
//! returns them in the following format:
|
||||
//!
|
||||
//! ((CFG << 8) | PADREG)
|
||||
//!
|
||||
//! This is the same format used by the \e am_hal_gpio_pin_config()
|
||||
//! function-like macro.
|
||||
//!
|
||||
//! @return Pin configuration information.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_gpio_pin_config_read(uint32_t ui32PinNumber)
|
||||
{
|
||||
uint32_t ui32CfgVal, ui32PadregVal;
|
||||
|
||||
am_hal_debug_assert_msg(ui32PinNumber <= 63, "Invalid GPIO number.");
|
||||
|
||||
ui32CfgVal = AM_HAL_GPIO_CFG_R(ui32PinNumber);
|
||||
ui32PadregVal = AM_HAL_GPIO_PADREG_R(ui32PinNumber);
|
||||
|
||||
return ((ui32CfgVal << 8) | ui32PadregVal);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the state of ALL GPIOs from the INPUT READ REGISTER.
|
||||
//!
|
||||
//! This function retrieves the state of ALL GPIOs from the INPUT READ
|
||||
//! REGISTER.
|
||||
//!
|
||||
//! @return the state for the requested GPIO or -1 for error.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint64_t
|
||||
am_hal_gpio_input_read(void)
|
||||
{
|
||||
//
|
||||
// Combine upper or lower GPIO words into one 64 bit return value.
|
||||
//
|
||||
uint64_t u64RetVal;
|
||||
u64RetVal = ((uint64_t) AM_REGn(GPIO, 0, RDB)) << 32;
|
||||
u64RetVal |= ((uint64_t) AM_REGn(GPIO, 0, RDA)) << 0;
|
||||
return u64RetVal;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the state of ALL GPIOs from the DATA OUTPUT REGISTER.
|
||||
//!
|
||||
//! This function retrieves the state of ALL GPIOs from the DATA OUTPUT
|
||||
//! REGISTER.
|
||||
//!
|
||||
//! @return the state for the requested GPIO or -1 for error.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint64_t
|
||||
am_hal_gpio_out_read(void)
|
||||
{
|
||||
//
|
||||
// Combine upper or lower GPIO words into one 64 bit return value.
|
||||
//
|
||||
uint64_t u64RetVal;
|
||||
u64RetVal = ((uint64_t) AM_REGn(GPIO, 0, WTB)) << 32;
|
||||
u64RetVal |= ((uint64_t) AM_REGn(GPIO, 0, WTA)) << 0;
|
||||
return u64RetVal;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Gets the state of one GPIO from the DATA ENABLE REGISTER.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//!
|
||||
//! This function gets the state of one GPIO from the DATA ENABLE REGISTER.
|
||||
//!
|
||||
//! @return the current state for the requested GPIO.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_gpio_out_enable_bit_get(uint32_t ui32BitNum)
|
||||
{
|
||||
//
|
||||
// Handle upper or lower GPIO word and return 0 or 1.
|
||||
//
|
||||
if ( ui32BitNum > 31 )
|
||||
{
|
||||
return !!(AM_REGn(GPIO, 0, ENB) & (1 << (ui32BitNum - 32)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return !!(AM_REGn(GPIO, 0, ENA) & (1 << ui32BitNum));
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Gets the state of ALL GPIOs from the DATA ENABLE REGISTER.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//!
|
||||
//! This function gets the state of all GPIOs from the DATA ENABLE REGISTER.
|
||||
//!
|
||||
//! @return the current state for the ALL GPIOs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint64_t
|
||||
am_hal_gpio_out_enable_get(void)
|
||||
{
|
||||
//
|
||||
// Combine upper or lower GPIO words into one 64 bit return value.
|
||||
//
|
||||
uint64_t u64RetVal;
|
||||
u64RetVal = ((uint64_t) AM_REGn(GPIO, 0, ENB)) << 32;
|
||||
u64RetVal |= ((uint64_t) AM_REGn(GPIO, 0, ENA)) << 0;
|
||||
return u64RetVal;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable selected GPIO Interrupts.
|
||||
//!
|
||||
//! @param ui64Interrupt - GPIOs to enable interrupts on.
|
||||
//!
|
||||
//! Use this function to enable the GPIO interrupts.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_gpio_int_enable(uint64_t ui64Interrupt)
|
||||
{
|
||||
//
|
||||
// Enable the interrupts.
|
||||
//
|
||||
AM_REG(GPIO, INT1EN) |= (ui64Interrupt >> 32);
|
||||
AM_REG(GPIO, INT0EN) |= (ui64Interrupt & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable selected GPIO Interrupts.
|
||||
//!
|
||||
//! Use this function to enable the GPIO interrupts.
|
||||
//!
|
||||
//! @return logical or of all enabled interrupts. Use AM_HAL_GPIO_BITx to mask
|
||||
//! interrupts of interest.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint64_t
|
||||
am_hal_gpio_int_enable_get(void)
|
||||
{
|
||||
//
|
||||
// Return enabled interrupts.
|
||||
//
|
||||
uint64_t u64RetVal;
|
||||
u64RetVal = ((uint64_t) AM_REGn(GPIO, 0, INT1EN)) << 32;
|
||||
u64RetVal |= ((uint64_t) AM_REGn(GPIO, 0, INT0EN)) << 0;
|
||||
return u64RetVal;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable selected GPIO Interrupts.
|
||||
//!
|
||||
//! @param ui64Interrupt - GPIOs to disable interrupts on.
|
||||
//!
|
||||
//! Use this function to disable the GPIO interrupts.
|
||||
//!
|
||||
//! ui64Interrupt should be a logical or of AM_HAL_GPIO_BITx defines.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_gpio_int_disable(uint64_t ui64Interrupt)
|
||||
{
|
||||
//
|
||||
// Disable the interrupts.
|
||||
//
|
||||
AM_REG(GPIO, INT1EN) &= ~(ui64Interrupt >> 32);
|
||||
AM_REG(GPIO, INT0EN) &= ~(ui64Interrupt & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clear selected GPIO Interrupts.
|
||||
//!
|
||||
//! @param ui64Interrupt - GPIOs to clear interrupts on.
|
||||
//!
|
||||
//! Use this function to clear the GPIO interrupts.
|
||||
//!
|
||||
//! ui64Interrupt should be a logical or of AM_HAL_GPIO_BITx defines.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_gpio_int_clear(uint64_t ui64Interrupt)
|
||||
{
|
||||
//
|
||||
// Clear the interrupts.
|
||||
//
|
||||
AM_REG(GPIO, INT1CLR) = (ui64Interrupt >> 32);
|
||||
AM_REG(GPIO, INT0CLR) = (ui64Interrupt & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set selected GPIO Interrupts.
|
||||
//!
|
||||
//! @param ui64Interrupt - GPIOs to set interrupts on.
|
||||
//!
|
||||
//! Use this function to set the GPIO interrupts.
|
||||
//!
|
||||
//! ui64Interrupt should be a logical or of AM_HAL_GPIO_BITx defines.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_gpio_int_set(uint64_t ui64Interrupt)
|
||||
{
|
||||
//
|
||||
// Set the interrupts.
|
||||
//
|
||||
AM_REG(GPIO, INT1SET) = (ui64Interrupt >> 32);
|
||||
AM_REG(GPIO, INT0SET) = (ui64Interrupt & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set selected GPIO Interrupts.
|
||||
//!
|
||||
//! @param bEnabledOnly - return the status of only the enabled interrupts.
|
||||
//!
|
||||
//! Use this function to set the GPIO interrupts.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint64_t
|
||||
am_hal_gpio_int_status_get(bool bEnabledOnly)
|
||||
{
|
||||
uint64_t u64RetVal, u64Mask;
|
||||
//
|
||||
// Combine upper or lower GPIO words into one 64 bit return value.
|
||||
//
|
||||
if (bEnabledOnly)
|
||||
{
|
||||
u64RetVal = ((uint64_t) AM_REGn(GPIO, 0, INT1EN)) << 32;
|
||||
u64RetVal |= ((uint64_t) AM_REGn(GPIO, 0, INT0EN)) << 0;
|
||||
u64Mask = ((uint64_t) AM_REGn(GPIO, 0, INT1STAT)) << 32;
|
||||
u64Mask |= ((uint64_t) AM_REGn(GPIO, 0, INT0STAT)) << 0;
|
||||
return u64RetVal & u64Mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
u64RetVal = ((uint64_t) AM_REGn(GPIO, 0, INT1STAT)) << 32;
|
||||
u64RetVal |= ((uint64_t) AM_REGn(GPIO, 0, INT0STAT)) << 0;
|
||||
return u64RetVal;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Convenience function for responding to pin interrupts.
|
||||
//!
|
||||
//! @param ui64Status is the interrupt status as returned by
|
||||
//! am_hal_gpio_int_status_get()
|
||||
//!
|
||||
//! This function may be called from am_hal_gpio_isr() to read the status of
|
||||
//! the GPIO interrupts, determine which pin(s) caused the most recent
|
||||
//! interrupt, and call an interrupt handler function to respond. The interrupt
|
||||
//! handler to be called must be first registered with the
|
||||
//! am_hal_gpio_int_register() function.
|
||||
//!
|
||||
//! In the event that multiple GPIO interrupts are active, the corresponding
|
||||
//! interrupt handlers will be called in numerical order by GPIO number
|
||||
//! starting with the lowest GPIO number.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_gpio_int_service(uint64_t ui64Status)
|
||||
{
|
||||
uint32_t ui32Status;
|
||||
uint32_t ui32Clz;
|
||||
|
||||
am_hal_gpio_handler_t pfnHandler;
|
||||
|
||||
//
|
||||
// Handle any active interrupts in the lower 32 bits
|
||||
//
|
||||
ui32Status = (uint32_t) ui64Status;
|
||||
while ( ui32Status )
|
||||
{
|
||||
//
|
||||
// Pick one of any remaining active interrupt bits
|
||||
//
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
ui32Clz = __CLZ(ui32Status);
|
||||
#else
|
||||
ui32Clz = __builtin_clz(ui32Status);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Turn off the bit we picked in the working copy
|
||||
//
|
||||
ui32Status &= ~(0x80000000 >> ui32Clz);
|
||||
|
||||
//
|
||||
// Check the bit handler table to see if there is an interrupt handler
|
||||
// registered for this particular bit.
|
||||
//
|
||||
pfnHandler = am_hal_gpio_ppfnHandlers[31 - ui32Clz];
|
||||
if ( pfnHandler )
|
||||
{
|
||||
//
|
||||
// If we found an interrupt handler routine, call it now.
|
||||
//
|
||||
pfnHandler();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Handle any active interrupts in the upper 32 bits
|
||||
//
|
||||
ui32Status = (uint32_t) (ui64Status >> 32);
|
||||
while ( ui32Status )
|
||||
{
|
||||
//
|
||||
// Pick one of any remaining active interrupt bits
|
||||
//
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
ui32Clz = __CLZ(ui32Status);
|
||||
#else
|
||||
ui32Clz = __builtin_clz(ui32Status);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Turn off the bit we picked in the working copy
|
||||
//
|
||||
ui32Status &= ~(0x80000000 >> ui32Clz);
|
||||
|
||||
//
|
||||
// Check the bit handler table to see if there is an interrupt handler
|
||||
// registered for this particular bit.
|
||||
//
|
||||
pfnHandler = am_hal_gpio_ppfnHandlers[63 - ui32Clz];
|
||||
if ( pfnHandler )
|
||||
{
|
||||
//
|
||||
// If we found an interrupt handler routine, call it now.
|
||||
//
|
||||
pfnHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Register an interrupt handler for an individual GPIO pin.
|
||||
//!
|
||||
//! @param ui32GPIONumber - GPIO number to assign this interrupt handler to.
|
||||
//! @param pfnHandler - Function to call when this GPIO interrupt is received.
|
||||
//!
|
||||
//! This function allows the caller to specify a function that should be called
|
||||
//! any time a GPIO interrupt is received on a particular pin. Registering an
|
||||
//! interrupt handler using this function adds the function pointer to an array
|
||||
//! in SRAM. This interrupt handler will be called by am_hal_gpio_int_service()
|
||||
//! whenever the ui64Status parameter indicates that the corresponding pin is
|
||||
//! asserting it's interrupt.
|
||||
//!
|
||||
//! To remove an interrupt handler that has already been registered, the
|
||||
//! pfnHandler parameter may be set to zero.
|
||||
//!
|
||||
//! @note This function will not have any effect unless the
|
||||
//! am_hal_gpio_int_service() function is being used.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_gpio_int_register(uint32_t ui32GPIONumber,
|
||||
am_hal_gpio_handler_t pfnHandler)
|
||||
{
|
||||
//
|
||||
// Check to make sure the GPIO number is valid. (Debug builds only)
|
||||
//
|
||||
am_hal_debug_assert_msg(ui32GPIONumber <= 64, "GPIO number out of range.");
|
||||
|
||||
am_hal_gpio_ppfnHandlers[ui32GPIONumber] = pfnHandler;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the state of one GPIO polarity bit.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//!
|
||||
//! This function gets the state of one GPIO polarity bit.
|
||||
//!
|
||||
//! @note When the bit is zero the interrupt polarity is rising edge.
|
||||
//! When the bit is one the interrupt polarity is falling edge.
|
||||
//!
|
||||
//! @return the current polarity.
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
am_hal_gpio_int_polarity_bit_get(uint32_t ui32BitNum)
|
||||
{
|
||||
//
|
||||
// Check the GPIO_CFGx register's interrupt polarity bit corresponding to
|
||||
// this pin number.
|
||||
//
|
||||
return (AM_REGVAL(AM_HAL_GPIO_CFG(ui32BitNum)) &
|
||||
AM_HAL_GPIO_POL_M(ui32BitNum));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,564 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_gpio.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the GPIO module.
|
||||
//!
|
||||
//! @addtogroup gpio1 GPIO
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef AM_HAL_GPIO_H
|
||||
#define AM_HAL_GPIO_H
|
||||
|
||||
// DEVICE ADDRESS IS 8-bits
|
||||
#define AM_HAL_GPIO_DEV_ADDR_8 (0)
|
||||
|
||||
// DEVICE ADDRESS IS 16-bits
|
||||
#define AM_HAL_GPIO_DEV_ADDR_16 (1)
|
||||
|
||||
// DEVICE OFFSET IS 8-bits
|
||||
#define AM_HAL_GPIO_DEV_OFFSET_8 (0x00000000)
|
||||
|
||||
// DEVICE OFFSET IS 16-bits
|
||||
#define AM_HAL_GPIO_DEV_OFFSET_16 (0x00010000)
|
||||
|
||||
// Maximum number of GPIOs on this device
|
||||
#define AM_HAL_GPIO_MAX_PADS (50)
|
||||
#define AM_HAL_GPIO_NUMWORDS ((AM_HAL_GPIO_MAX_PADS + 31) / 32)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name GPIO Pin defines
|
||||
//! @brief GPIO Pin defines for use with interrupt functions
|
||||
//!
|
||||
//! These macros may be used to with \e am_hal_gpio_int_x().
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_BIT(n) (((uint64_t) 0x1) << n)
|
||||
//! @}
|
||||
|
||||
//
|
||||
// AM_HAL_GPIO_MASKBIT(pMaskNm,n)
|
||||
// The pMaskNm parameter is not used for Apollo and is simply ignored.
|
||||
// n is the desired bitnumber.
|
||||
//
|
||||
#define AM_HAL_GPIO_MASKBIT(pMaskNm, n) (((uint64_t) 0x1) << n)
|
||||
#define AM_HAL_GPIO_MASKCREATE(MaskNm)
|
||||
#define AM_HAL_GPIO_MASKCLR(pMaskNm)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Input options.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_INPEN 0x00000002 // Enable input transistors.
|
||||
#define AM_HAL_GPIO_INCFG_RDZERO 0x00000100 // Disable input read registers.
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Output options
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_OUT_DISABLE 0x00000000
|
||||
#define AM_HAL_GPIO_OUT_PUSHPULL 0x00000200
|
||||
#define AM_HAL_GPIO_OUT_OPENDRAIN 0x00000400
|
||||
#define AM_HAL_GPIO_OUT_3STATE 0x00000600
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Interrupt polarity
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_FALLING 0x00000001
|
||||
#define AM_HAL_GPIO_RISING 0x00000000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Pad configuration options.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_POWERSOURCE 0x00000080
|
||||
#define AM_HAL_GPIO_POWERSINK 0x00000040
|
||||
#define AM_HAL_GPIO_HIGH_DRIVE 0x00000004
|
||||
#define AM_HAL_GPIO_LOW_DRIVE 0x00000000
|
||||
#define AM_HAL_GPIO_PULLUP 0x00000001
|
||||
#define AM_HAL_GPIO_PULL1_5K 0x00000001
|
||||
#define AM_HAL_GPIO_PULL6K 0x00000041
|
||||
#define AM_HAL_GPIO_PULL12K 0x00000081
|
||||
#define AM_HAL_GPIO_PULL24K 0x000000C1
|
||||
#define AM_HAL_GPIO_FUNC(x) ((x & 0x7) << 3)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Common pin configurations.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_DISABLE \
|
||||
(AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#define AM_HAL_GPIO_INPUT \
|
||||
(AM_HAL_GPIO_FUNC(3) | AM_HAL_GPIO_INPEN)
|
||||
|
||||
#define AM_HAL_GPIO_OUTPUT \
|
||||
(AM_HAL_GPIO_FUNC(3) | AM_HAL_GPIO_OUT_PUSHPULL)
|
||||
|
||||
#define AM_HAL_GPIO_OPENDRAIN \
|
||||
(AM_HAL_GPIO_FUNC(3) | AM_HAL_GPIO_OUT_OPENDRAIN | AM_HAL_GPIO_INPEN)
|
||||
|
||||
#define AM_HAL_GPIO_3STATE \
|
||||
(AM_HAL_GPIO_FUNC(3) | AM_HAL_GPIO_OUT_3STATE)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PADREG helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_PADREG(n) \
|
||||
(AM_REG_GPIOn(0) + AM_REG_GPIO_PADREGA_O + (n & 0xFC))
|
||||
|
||||
#define AM_HAL_GPIO_PADREG_S(n) \
|
||||
(((uint32_t)(n) % 4) << 3)
|
||||
|
||||
#define AM_HAL_GPIO_PADREG_M(n) \
|
||||
((uint32_t) 0xFF << AM_HAL_GPIO_PADREG_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_PADREG_FIELD(n, configval) \
|
||||
(((uint32_t)(configval) & 0xFF) << AM_HAL_GPIO_PADREG_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_PADREG_W(n, configval) \
|
||||
AM_REGVAL(AM_HAL_GPIO_PADREG(n)) = \
|
||||
(AM_HAL_GPIO_PADREG_FIELD(n, configval) | \
|
||||
(AM_REGVAL(AM_HAL_GPIO_PADREG(n)) & ~AM_HAL_GPIO_PADREG_M(n)))
|
||||
|
||||
#define AM_HAL_GPIO_PADREG_R(n) \
|
||||
((AM_REGVAL(AM_HAL_GPIO_PADREG(n)) & AM_HAL_GPIO_PADREG_M(n)) >> \
|
||||
AM_HAL_GPIO_PADREG_S(n))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CFG helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_CFG(n) \
|
||||
(AM_REG_GPIOn(0) + AM_REG_GPIO_CFGA_O + ((n & 0xF8) >> 1))
|
||||
|
||||
#define AM_HAL_GPIO_CFG_S(n) \
|
||||
(((uint32_t)(n) % 8) << 2)
|
||||
|
||||
#define AM_HAL_GPIO_CFG_M(n) \
|
||||
((uint32_t) 0x7 << AM_HAL_GPIO_CFG_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_CFG_FIELD(n, configval) \
|
||||
((((uint32_t)(configval) & 0x700) >> 8) << AM_HAL_GPIO_CFG_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_CFG_W(n, configval) \
|
||||
AM_REGVAL(AM_HAL_GPIO_CFG(n)) = \
|
||||
(AM_HAL_GPIO_CFG_FIELD(n, configval) | \
|
||||
(AM_REGVAL(AM_HAL_GPIO_CFG(n)) & ~AM_HAL_GPIO_CFG_M(n)))
|
||||
|
||||
#define AM_HAL_GPIO_CFG_R(n) \
|
||||
((AM_REGVAL(AM_HAL_GPIO_CFG(n)) & AM_HAL_GPIO_CFG_M(n)) >> \
|
||||
AM_HAL_GPIO_CFG_S(n))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Polarity helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_POL_S(n) \
|
||||
((((uint32_t)(n) % 8) << 2) + 3)
|
||||
|
||||
#define AM_HAL_GPIO_POL_M(n) \
|
||||
((uint32_t) 0x1 << AM_HAL_GPIO_POL_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_POL_FIELD(n, polarity) \
|
||||
(((uint32_t)(polarity) & 0x1) << AM_HAL_GPIO_POL_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_POL_W(n, polarity) \
|
||||
AM_REGVAL(AM_HAL_GPIO_CFG(n)) = \
|
||||
(AM_HAL_GPIO_POL_FIELD(n, polarity) | \
|
||||
(AM_REGVAL(AM_HAL_GPIO_CFG(n)) & ~AM_HAL_GPIO_POL_M(n)))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RD helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_RD_REG(n) \
|
||||
(AM_REG_GPIOn(0) + AM_REG_GPIO_RDA_O + (((uint32_t)(n) & 0x20) >> 3))
|
||||
|
||||
#define AM_HAL_GPIO_RD_S(n) \
|
||||
((uint32_t)(n) % 32)
|
||||
|
||||
#define AM_HAL_GPIO_RD_M(n) \
|
||||
((uint32_t) 0x1 << AM_HAL_GPIO_RD_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_RD(n) \
|
||||
AM_REGVAL(AM_HAL_GPIO_RD_REG(n))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WT helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_WT_REG(n) \
|
||||
(AM_REG_GPIOn(0) + AM_REG_GPIO_WTA_O + (((uint32_t)(n) & 0x20) >> 3))
|
||||
|
||||
#define AM_HAL_GPIO_WT_S(n) \
|
||||
((uint32_t)(n) % 32)
|
||||
|
||||
#define AM_HAL_GPIO_WT_M(n) \
|
||||
((uint32_t) 0x1 << AM_HAL_GPIO_WT_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_WT(n) \
|
||||
AM_REGVAL(AM_HAL_GPIO_WT_REG(n))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WTS helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_WTS_REG(n) \
|
||||
(AM_REG_GPIOn(0) + AM_REG_GPIO_WTSA_O + (((uint32_t)(n) & 0x20) >> 3))
|
||||
|
||||
#define AM_HAL_GPIO_WTS_S(n) \
|
||||
((uint32_t)(n) % 32)
|
||||
|
||||
#define AM_HAL_GPIO_WTS_M(n) \
|
||||
((uint32_t) 0x1 << AM_HAL_GPIO_WTS_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_WTS(n) \
|
||||
AM_REGVAL(AM_HAL_GPIO_WTS_REG(n))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WTC helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_WTC_REG(n) \
|
||||
(AM_REG_GPIOn(0) + AM_REG_GPIO_WTCA_O + (((uint32_t)(n) & 0x20) >> 3))
|
||||
|
||||
#define AM_HAL_GPIO_WTC_S(n) \
|
||||
((uint32_t)(n) % 32)
|
||||
|
||||
#define AM_HAL_GPIO_WTC_M(n) \
|
||||
((uint32_t) 0x1 << AM_HAL_GPIO_WTC_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_WTC(n) \
|
||||
AM_REGVAL(AM_HAL_GPIO_WTC_REG(n))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// EN helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_EN_REG(n) \
|
||||
(AM_REG_GPIOn(0) + AM_REG_GPIO_ENA_O + (((uint32_t)(n) & 0x20) >> 3))
|
||||
|
||||
#define AM_HAL_GPIO_EN_S(n) \
|
||||
((uint32_t)(n) % 32)
|
||||
|
||||
#define AM_HAL_GPIO_EN_M(n) \
|
||||
((uint32_t) 0x1 << AM_HAL_GPIO_EN_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_EN(n) \
|
||||
AM_REGVAL(AM_HAL_GPIO_EN_REG(n))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ENS helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_ENS_REG(n) \
|
||||
(AM_REG_GPIOn(0) + AM_REG_GPIO_ENSA_O + (((uint32_t)(n) & 0x20) >> 3))
|
||||
|
||||
#define AM_HAL_GPIO_ENS_S(n) \
|
||||
((uint32_t)(n) % 32)
|
||||
|
||||
#define AM_HAL_GPIO_ENS_M(n) \
|
||||
((uint32_t) 0x1 << AM_HAL_GPIO_ENS_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_ENS(n) \
|
||||
AM_REGVAL(AM_HAL_GPIO_ENS_REG(n))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ENC helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_GPIO_ENC_REG(n) \
|
||||
(AM_REG_GPIOn(0) + AM_REG_GPIO_ENCA_O + (((uint32_t)(n) & 0x20) >> 3))
|
||||
|
||||
#define AM_HAL_GPIO_ENC_S(n) \
|
||||
((uint32_t)(n) % 32)
|
||||
|
||||
#define AM_HAL_GPIO_ENC_M(n) \
|
||||
((uint32_t) 0x1 << AM_HAL_GPIO_ENC_S(n))
|
||||
|
||||
#define AM_HAL_GPIO_ENC(n) \
|
||||
AM_REGVAL(AM_HAL_GPIO_ENC_REG(n))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configure the GPIO PAD MUX & GPIO PIN Configurations
|
||||
//!
|
||||
//! @param ui32PinNumber - GPIO pin number.
|
||||
//! @param ui32Config - Configuration options.
|
||||
//!
|
||||
//! This function applies the settings for a single GPIO. For a list of valid
|
||||
//! options please see the top of this file (am_hal_gpio.h) and am_hal_pin.h.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_gpio_pin_config(ui32PinNumber, ui32Config) \
|
||||
do \
|
||||
{ \
|
||||
if ( (int32_t)(ui32PinNumber) < 0 ) \
|
||||
{ \
|
||||
break; \
|
||||
} \
|
||||
\
|
||||
AM_REGn(GPIO, 0, PADKEY) = AM_REG_GPIO_PADKEY_KEYVAL; \
|
||||
\
|
||||
AM_HAL_GPIO_CFG_W(ui32PinNumber, ui32Config); \
|
||||
AM_HAL_GPIO_PADREG_W(ui32PinNumber, ui32Config); \
|
||||
\
|
||||
AM_REGn(GPIO, 0, PADKEY) = 0; \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set the state of one GPIO polarity bit.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//! @param ui32Polarity - Desired state.
|
||||
//!
|
||||
//! This function sets the state of one GPIO polarity bit to a supplied value.
|
||||
//! The ui32Polarity parameter should be one of the following values:
|
||||
//!
|
||||
//! AM_HAL_GPIO_FALLING
|
||||
//! AM_HAL_GPIO_RISING
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_gpio_int_polarity_bit_set(ui32PinNumber, ui32Polarity) \
|
||||
do \
|
||||
{ \
|
||||
if ( (int32_t)(ui32PinNumber) < 0 ) \
|
||||
{ \
|
||||
break; \
|
||||
} \
|
||||
\
|
||||
AM_REGn(GPIO, 0, PADKEY) = AM_REG_GPIO_PADKEY_KEYVAL; \
|
||||
AM_HAL_GPIO_POL_W(ui32PinNumber, ui32Polarity); \
|
||||
AM_REGn(GPIO, 0, PADKEY) = 0; \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the state of one GPIO from the INPUT READ REGISTER.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//!
|
||||
//! This function retrieves the state of one GPIO from the INPUT READ
|
||||
//! REGISTER.
|
||||
//!
|
||||
//! @return the state for the requested GPIO.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_gpio_input_bit_read(ui32BitNum) \
|
||||
((AM_HAL_GPIO_RD(ui32BitNum) & AM_HAL_GPIO_RD_M(ui32BitNum)) != 0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the state of one GPIO in the DATA OUTPUT REGISTER
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//!
|
||||
//! This function retrieves the state of one GPIO in the DATA OUTPUT REGISTER.
|
||||
//!
|
||||
//! @return the state for the requested GPIO or -1 for error.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_gpio_out_bit_read(ui32BitNum) \
|
||||
((AM_HAL_GPIO_WT(ui32BitNum) & AM_HAL_GPIO_WT_M(ui32BitNum)) != 0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set the output state high for one GPIO.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//!
|
||||
//! This function sets the output state to high for one GPIO.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_gpio_out_bit_set(ui32BitNum) \
|
||||
AM_HAL_GPIO_WTS(ui32BitNum) = AM_HAL_GPIO_WTS_M(ui32BitNum)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Sets the output state to low for one GPIO.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//!
|
||||
//! This function sets the output state to low for one GPIO.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_gpio_out_bit_clear(ui32BitNum) \
|
||||
AM_HAL_GPIO_WTC(ui32BitNum) = AM_HAL_GPIO_WTC_M(ui32BitNum)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Sets the output state to ui32Value for one GPIO.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//! @param ui32Value - Desired output state.
|
||||
//!
|
||||
//! This function sets the output state to ui32Value for one GPIO.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_gpio_out_bit_replace(ui32BitNum, ui32Value) \
|
||||
AM_HAL_GPIO_WT(ui32BitNum) = ui32Value ? \
|
||||
(AM_HAL_GPIO_WT(ui32BitNum) | AM_HAL_GPIO_WT_M(ui32BitNum)) : \
|
||||
(AM_HAL_GPIO_WT(ui32BitNum) & ~AM_HAL_GPIO_WT_M(ui32BitNum))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Toggle the output state of one GPIO.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//!
|
||||
//! This function toggles the output state of one GPIO.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_gpio_out_bit_toggle(ui32BitNum) \
|
||||
AM_HAL_GPIO_WT(ui32BitNum) = (AM_HAL_GPIO_WT(ui32BitNum) ^ \
|
||||
AM_HAL_GPIO_WT_M(ui32BitNum))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Sets the output enable for one GPIO.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//!
|
||||
//! This function sets the output enable for one GPIO.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_gpio_out_enable_bit_set(ui32BitNum) \
|
||||
AM_HAL_GPIO_ENS(ui32BitNum) = AM_HAL_GPIO_ENS_M(ui32BitNum)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clears the output enable for one GPIO.
|
||||
//!
|
||||
//! @param ui32BitNum - GPIO number.
|
||||
//!
|
||||
//! This function clears the output enable for one GPIO.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_gpio_out_enable_bit_clear(ui32BitNum) \
|
||||
AM_HAL_GPIO_ENC(ui32BitNum) = AM_HAL_GPIO_ENC_M(ui32BitNum)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Function pointer type for GPIO interrupt handlers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (*am_hal_gpio_handler_t)(void);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern uint32_t am_hal_gpio_pin_config_read(uint32_t ui32PinNumber);
|
||||
extern uint64_t am_hal_gpio_input_read(void);
|
||||
extern uint64_t am_hal_gpio_out_read(void);
|
||||
extern uint32_t am_hal_gpio_out_enable_bit_get(uint32_t ui32BitNum);
|
||||
extern uint64_t am_hal_gpio_out_enable_get(void);
|
||||
extern void am_hal_gpio_int_enable(uint64_t ui64Interrupt);
|
||||
extern uint64_t am_hal_gpio_int_enable_get(void);
|
||||
extern void am_hal_gpio_int_disable(uint64_t ui64Interrupt);
|
||||
extern void am_hal_gpio_int_clear(uint64_t ui64Interrupt);
|
||||
extern void am_hal_gpio_int_set(uint64_t ui64Interrupt);
|
||||
extern uint64_t am_hal_gpio_int_status_get(bool bEnabledOnly);
|
||||
extern void am_hal_gpio_int_service(uint64_t ui64Status);
|
||||
extern void am_hal_gpio_int_register(uint32_t ui32GPIONumber,
|
||||
am_hal_gpio_handler_t pfnHandler);
|
||||
|
||||
extern bool am_hal_gpio_int_polarity_bit_get(uint32_t ui32BitNum);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_GPIO_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,759 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_i2c_bit_bang.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief I2C bit bang module.
|
||||
//!
|
||||
//! These functions implement the I2C bit bang utility
|
||||
//! It implements an I2C interface at close to 200 kHz
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "am_mcu_apollo.h"
|
||||
#include "am_hal_i2c_bit_bang.h"
|
||||
|
||||
// Max number of clock cycles to wait for clock stretch
|
||||
#define I2C_BB_MAX_CLOCK_STRETCH_WAIT 100
|
||||
|
||||
#define I2C_BB_DESIRED_FREQ_HZ 200000
|
||||
|
||||
#define I2C_BB_CYCLES_PER_DELAY_COUNT 3
|
||||
#define I2C_BB_ONE_BIT_TIME_IN_CYCLES (AM_HAL_CLKGEN_FREQ_MAX_HZ/I2C_BB_DESIRED_FREQ_HZ)
|
||||
#define I2C_BB_ONE_BIT_TIME_IN_DELAY_COUNT (I2C_BB_ONE_BIT_TIME_IN_CYCLES/I2C_BB_CYCLES_PER_DELAY_COUNT)
|
||||
|
||||
// Number of loops (each worth 3 cycles) needed to delay for defined time
|
||||
// This is imprecise, as there is a setup time as well which is not accounted
|
||||
// for
|
||||
// One Bit time = 120 Cycles (200 kHz @ 24 MHz)
|
||||
#define HALF_BIT_TIME (I2C_BB_ONE_BIT_TIME_IN_DELAY_COUNT/2)
|
||||
#define QUARTER_BIT_TIME (I2C_BB_ONE_BIT_TIME_IN_DELAY_COUNT/4)
|
||||
#define ASM_DELAY am_hal_flash_delay
|
||||
|
||||
// Empirically determined adjustments to account for the fact that there is a
|
||||
// variable time spent in actual processing as well, and hence we need not delay
|
||||
// for the full time. This processing time is variable based on exact processing
|
||||
// needed at various times, and will also vary based on compiler type and
|
||||
// optimization levels
|
||||
#define I2C_BB_TIMER_ADJUST 6 // Can not be more than QUARTER_BIT_TIME - 1
|
||||
#define I2C_BB_TIMER_HI_ADJUST 15 // Can not be more than HALF_BIT_TIME - 1
|
||||
#define I2C_BB_TIMER_LO_ADJUST 13 // Can not be more than HALF_BIT_TIME - 1
|
||||
|
||||
// Wait till it is time to end the SCL Hi Period
|
||||
#define WAIT_I2C_CLOCK_HI_PERIOD() ASM_DELAY(HALF_BIT_TIME - I2C_BB_TIMER_HI_ADJUST)
|
||||
// Wait till it is time to end the SCL Lo Period
|
||||
#define WAIT_I2C_CLOCK_LOW_PERIOD() ASM_DELAY(HALF_BIT_TIME - I2C_BB_TIMER_LO_ADJUST)
|
||||
// Delay for Quarter Clock
|
||||
#define WAIT_FOR_QUARTER_I2C_CLOCK() ASM_DELAY(QUARTER_BIT_TIME - I2C_BB_TIMER_ADJUST)
|
||||
#define WRITE_SCL_LO() \
|
||||
do { \
|
||||
AM_REGVAL(am_hal_i2c_bit_bang_priv.sck_reg_clr_addr) = (am_hal_i2c_bit_bang_priv.sck_reg_val); \
|
||||
} while(0)
|
||||
|
||||
#define PULL_SCL_HI() \
|
||||
do { \
|
||||
AM_REGVAL(am_hal_i2c_bit_bang_priv.sck_reg_set_addr) = (am_hal_i2c_bit_bang_priv.sck_reg_val); \
|
||||
} while(0)
|
||||
|
||||
#define GET_SCL() (AM_REGVAL(am_hal_i2c_bit_bang_priv.sck_reg_read_addr) & (am_hal_i2c_bit_bang_priv.sck_reg_val))
|
||||
#define GET_SDA() (AM_REGVAL(am_hal_i2c_bit_bang_priv.sda_reg_read_addr) & (am_hal_i2c_bit_bang_priv.sda_reg_val))
|
||||
|
||||
#define WRITE_SDA_LO() \
|
||||
do { \
|
||||
AM_REGVAL(am_hal_i2c_bit_bang_priv.sda_reg_clr_addr) = (am_hal_i2c_bit_bang_priv.sda_reg_val); \
|
||||
} while(0)
|
||||
|
||||
#define PULL_SDA_HI() \
|
||||
do { \
|
||||
AM_REGVAL(am_hal_i2c_bit_bang_priv.sda_reg_set_addr) = (am_hal_i2c_bit_bang_priv.sda_reg_val); \
|
||||
} while(0)
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// I2C Bit Bang Private Data Structure
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct am_util_bit_bang_priv
|
||||
{
|
||||
bool start_flag;
|
||||
uint32_t sck_gpio_number;
|
||||
uint32_t sda_gpio_number;
|
||||
uint32_t sck_reg_set_addr;
|
||||
uint32_t sck_reg_clr_addr;
|
||||
uint32_t sck_reg_read_addr;
|
||||
uint32_t sck_reg_val;
|
||||
uint32_t sda_reg_set_addr;
|
||||
uint32_t sda_reg_clr_addr;
|
||||
uint32_t sda_reg_read_addr;
|
||||
uint32_t sda_reg_val;
|
||||
} am_hal_i2c_bit_bang_priv_t;
|
||||
static am_hal_i2c_bit_bang_priv_t am_hal_i2c_bit_bang_priv;
|
||||
|
||||
//
|
||||
// Wait for any stretched clock to go high
|
||||
// If it times out - return failure
|
||||
//
|
||||
static inline bool
|
||||
i2c_pull_and_wait_scl_hi(void)
|
||||
{
|
||||
// Maximum time to wait for clock stretching
|
||||
uint32_t maxLoop = 4*I2C_BB_MAX_CLOCK_STRETCH_WAIT + 1;
|
||||
// Pull SCL High
|
||||
PULL_SCL_HI();
|
||||
// Poll for SCL to check for clock stretching
|
||||
while (!GET_SCL())
|
||||
{
|
||||
if (--maxLoop == 0)
|
||||
{
|
||||
// timeout!
|
||||
return true;
|
||||
}
|
||||
WAIT_FOR_QUARTER_I2C_CLOCK();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Initialize i2c bit bang private data structure
|
||||
//!
|
||||
//! @param sck_gpio_number is the GPIO # for the I2C SCK clock pin
|
||||
//! @param sda_gpio_number is the GPIO # for the I2C SDA data pin
|
||||
//!
|
||||
//! This function initializes the I2C bit bang utility's internal data struct.
|
||||
//!
|
||||
//! returns None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
am_hal_i2c_bit_bang_enum_e
|
||||
am_hal_i2c_bit_bang_init(uint32_t sck_gpio_number,
|
||||
uint32_t sda_gpio_number)
|
||||
{
|
||||
int i;
|
||||
//
|
||||
// remember GPIO pin assignments for I2C bus signals
|
||||
//
|
||||
am_hal_i2c_bit_bang_priv.sck_gpio_number = sck_gpio_number;
|
||||
am_hal_i2c_bit_bang_priv.sda_gpio_number = sda_gpio_number;
|
||||
|
||||
am_hal_i2c_bit_bang_priv.sck_reg_set_addr = AM_HAL_GPIO_WTS_REG(sck_gpio_number);
|
||||
am_hal_i2c_bit_bang_priv.sck_reg_clr_addr = AM_HAL_GPIO_WTC_REG(sck_gpio_number);
|
||||
am_hal_i2c_bit_bang_priv.sck_reg_read_addr = AM_HAL_GPIO_RD_REG(sck_gpio_number);
|
||||
am_hal_i2c_bit_bang_priv.sck_reg_val = AM_HAL_GPIO_WTC_M(sck_gpio_number);
|
||||
am_hal_i2c_bit_bang_priv.sda_reg_set_addr = AM_HAL_GPIO_WTS_REG(sda_gpio_number);
|
||||
am_hal_i2c_bit_bang_priv.sda_reg_clr_addr = AM_HAL_GPIO_WTC_REG(sda_gpio_number);
|
||||
am_hal_i2c_bit_bang_priv.sda_reg_read_addr = AM_HAL_GPIO_RD_REG(sda_gpio_number);
|
||||
am_hal_i2c_bit_bang_priv.sda_reg_val = AM_HAL_GPIO_WTC_M(sda_gpio_number);
|
||||
|
||||
//
|
||||
// Set SCK GPIO data bit high so we aren't pulling down the clock
|
||||
//
|
||||
am_hal_gpio_out_bit_set(sck_gpio_number);
|
||||
//
|
||||
// Set up SCK GPIO configuration bi-direction, input
|
||||
//
|
||||
am_hal_gpio_pin_config(sck_gpio_number, AM_HAL_PIN_OPENDRAIN | AM_HAL_GPIO_INPEN);
|
||||
|
||||
//
|
||||
// Set SDA GPIO data bit high so we aren't pulling down the data line
|
||||
//
|
||||
am_hal_gpio_out_bit_set(sda_gpio_number);
|
||||
//
|
||||
// Set up SDA GPIO configuration bi-direction, input
|
||||
//
|
||||
am_hal_gpio_pin_config(sda_gpio_number, AM_HAL_PIN_OPENDRAIN | AM_HAL_GPIO_INPEN);
|
||||
|
||||
// Now make sure we have control of the clock line
|
||||
//
|
||||
// Wait for any stretched clock to go high. Return if still not high
|
||||
//
|
||||
if (i2c_pull_and_wait_scl_hi())
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT;
|
||||
}
|
||||
if (!GET_SDA())
|
||||
{
|
||||
// If previous transaction did not finish - SDA may be pulled low for a Read.
|
||||
// If so - need to flush out the data (max 8 bits) & NACK
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
//
|
||||
// Pull down on clock line
|
||||
//
|
||||
WRITE_SCL_LO();
|
||||
//
|
||||
// Delay for 1/2 bit cell time to start the clock and let peer write on SDA
|
||||
//
|
||||
WAIT_I2C_CLOCK_LOW_PERIOD();
|
||||
if (i2c_pull_and_wait_scl_hi())
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT;
|
||||
}
|
||||
if (GET_SDA())
|
||||
{
|
||||
// Send START/STOP to clear the bus
|
||||
//
|
||||
// Delay for 1/4 bit cell time
|
||||
//
|
||||
WAIT_FOR_QUARTER_I2C_CLOCK();
|
||||
WRITE_SDA_LO();
|
||||
//
|
||||
// Delay for 1/4 bit cell time
|
||||
//
|
||||
WAIT_FOR_QUARTER_I2C_CLOCK();
|
||||
//
|
||||
// Pull down on clock line
|
||||
//
|
||||
WRITE_SCL_LO();
|
||||
//
|
||||
// Delay for 1/2 bit cell time to start the clock and let peer write on SDA
|
||||
//
|
||||
WAIT_I2C_CLOCK_LOW_PERIOD();
|
||||
//
|
||||
// Release the clock line
|
||||
//
|
||||
PULL_SCL_HI();
|
||||
//
|
||||
// Delay for 1/4 bit cell time
|
||||
//
|
||||
WAIT_FOR_QUARTER_I2C_CLOCK();
|
||||
PULL_SDA_HI();
|
||||
//
|
||||
// Delay for 1/4 bit cell time
|
||||
//
|
||||
WAIT_FOR_QUARTER_I2C_CLOCK();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 9)
|
||||
{
|
||||
// It is it still stuck after 9 clocks - something is wrong. Need to bail out
|
||||
return AM_HAL_I2C_BIT_BANG_DATA_TIMEOUT;
|
||||
}
|
||||
}
|
||||
return AM_HAL_I2C_BIT_BANG_SUCCESS;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Receive one data byte from an I2C device
|
||||
//!
|
||||
//! This function handles sending one byte to a slave device
|
||||
//! bNack defines if we should send an ACK or NACK
|
||||
//!
|
||||
//! returns the byte received
|
||||
//
|
||||
//*****************************************************************************
|
||||
static inline am_hal_i2c_bit_bang_enum_e
|
||||
i2c_receive_byte(uint8_t *pRxByte, bool bNack)
|
||||
{
|
||||
int i;
|
||||
uint8_t data_byte = 0;
|
||||
|
||||
//
|
||||
// Loop through receiving 8 bits
|
||||
//
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
//
|
||||
// Pull down on clock line
|
||||
//
|
||||
WRITE_SCL_LO();
|
||||
|
||||
//
|
||||
// release the data line from from the previous ACK
|
||||
//
|
||||
PULL_SDA_HI();
|
||||
|
||||
//
|
||||
// Delay for 1/2 bit cell time to start the clock and let peer write on SDA
|
||||
//
|
||||
WAIT_I2C_CLOCK_LOW_PERIOD();
|
||||
|
||||
if (i2c_pull_and_wait_scl_hi())
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT;
|
||||
}
|
||||
//
|
||||
// grab the data bit here
|
||||
//
|
||||
if ( GET_SDA() )
|
||||
{
|
||||
//
|
||||
// set the bit in the data byte to be returned
|
||||
//
|
||||
data_byte |= (0x80 >> i);
|
||||
}
|
||||
|
||||
//
|
||||
// Delay for 1/2 bit cell time while clock is high
|
||||
//
|
||||
WAIT_I2C_CLOCK_HI_PERIOD();
|
||||
}
|
||||
|
||||
*pRxByte = data_byte;
|
||||
//
|
||||
// Pull down on clock line
|
||||
//
|
||||
WRITE_SCL_LO();
|
||||
|
||||
//
|
||||
// pull the data line down so we can ACK/NAK the byte we just received
|
||||
//
|
||||
if (bNack)
|
||||
{
|
||||
//
|
||||
// Pull up on data line with clock low to indicate NAK
|
||||
//
|
||||
PULL_SDA_HI();
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Pull down on data line with clock low to indicate ACK
|
||||
//
|
||||
WRITE_SDA_LO();
|
||||
}
|
||||
//
|
||||
// Delay for 1/2 bit cell time before sending ACK to device
|
||||
//
|
||||
WAIT_I2C_CLOCK_LOW_PERIOD();
|
||||
|
||||
if (i2c_pull_and_wait_scl_hi())
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT;
|
||||
}
|
||||
//
|
||||
// Delay for 1/2 bit cell time while clock is high to le peer sample the ACK/NAK
|
||||
//
|
||||
WAIT_I2C_CLOCK_HI_PERIOD();
|
||||
//
|
||||
// Give the received data byte back to them
|
||||
//
|
||||
return AM_HAL_I2C_BIT_BANG_SUCCESS;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Send one data bytes to an I2C device
|
||||
//!
|
||||
//! @param one_byte the byte to send, could be address could be data
|
||||
//!
|
||||
//! This function handles sending one byte to a slave device
|
||||
//! Starts with 0 clock and runs till full cycle
|
||||
//!
|
||||
//! returns I2C BB ENUM
|
||||
//! {
|
||||
//! AM_HAL_I2C_BIT_BANG_SUCCESS,
|
||||
//! AM_HAL_I2C_BIT_BANG_ADDRESS_NAKED
|
||||
//! }
|
||||
//
|
||||
//*****************************************************************************
|
||||
static inline am_hal_i2c_bit_bang_enum_e
|
||||
i2c_send_byte(uint8_t one_byte)
|
||||
{
|
||||
int i;
|
||||
bool data_naked = false;
|
||||
|
||||
//
|
||||
// Loop through sending 8 bits
|
||||
//
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
//
|
||||
// Pull down on clock line
|
||||
//
|
||||
WRITE_SCL_LO();
|
||||
|
||||
//
|
||||
// output the next data bit
|
||||
//
|
||||
if ( one_byte & (0x80 >> i) )
|
||||
{
|
||||
PULL_SDA_HI();
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE_SDA_LO();
|
||||
}
|
||||
|
||||
//
|
||||
// Delay for 1/2 bit cell time to start the clock
|
||||
//
|
||||
WAIT_I2C_CLOCK_LOW_PERIOD();
|
||||
|
||||
if (i2c_pull_and_wait_scl_hi())
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT;
|
||||
}
|
||||
//
|
||||
// Delay for 1/2 bit cell time while clock is high
|
||||
//
|
||||
WAIT_I2C_CLOCK_HI_PERIOD();
|
||||
}
|
||||
|
||||
//
|
||||
// Pull down on clock line
|
||||
//
|
||||
WRITE_SCL_LO();
|
||||
|
||||
//
|
||||
// Delay for 1/2 bit cell time to start the clock
|
||||
//
|
||||
WAIT_I2C_CLOCK_LOW_PERIOD();
|
||||
|
||||
if (i2c_pull_and_wait_scl_hi())
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT;
|
||||
}
|
||||
//
|
||||
// Grab the state of the ACK bit and return it
|
||||
//
|
||||
data_naked = GET_SDA();
|
||||
//
|
||||
// Delay for 1/2 bit cell time to complete the high period
|
||||
//
|
||||
WAIT_I2C_CLOCK_HI_PERIOD();
|
||||
if ( data_naked )
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_DATA_NAKED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Receive a string of data bytes from an I2C device
|
||||
//!
|
||||
//! @param address (only 8 bit I2C addresses are supported)
|
||||
//! LSB is I2C R/W
|
||||
//! @param number_of_bytes to transfer (# payload bytes)
|
||||
//! @param pData pointer to data buffer to receive payload
|
||||
//!
|
||||
//! This function handles receiving a payload from a slave device
|
||||
//!
|
||||
//! returns ENUM{AM_HAL_I2C_BIT_BANG_SUCCESS,AM_HAL_I2C_BIT_BANG_ADDRESS_NAKED}
|
||||
//
|
||||
//*****************************************************************************
|
||||
am_hal_i2c_bit_bang_enum_e
|
||||
am_hal_i2c_bit_bang_receive(uint8_t address, uint32_t number_of_bytes,
|
||||
uint8_t *pData, uint8_t ui8Offset,
|
||||
bool bUseOffset, bool bNoStop)
|
||||
{
|
||||
uint32_t ui32I;
|
||||
am_hal_i2c_bit_bang_enum_e status = AM_HAL_I2C_BIT_BANG_SUCCESS;
|
||||
|
||||
|
||||
if (i2c_pull_and_wait_scl_hi())
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT;
|
||||
}
|
||||
//
|
||||
// Pull down on data line with clock high --> START CONDITION
|
||||
//
|
||||
WRITE_SDA_LO();
|
||||
|
||||
//
|
||||
// Delay for 1/2 bit cell time to start the clock
|
||||
//
|
||||
WAIT_I2C_CLOCK_HI_PERIOD();
|
||||
|
||||
//
|
||||
// send the address byte and wait for the ACK/NAK
|
||||
//
|
||||
status = i2c_send_byte(address);
|
||||
if ( status != AM_HAL_I2C_BIT_BANG_SUCCESS )
|
||||
{
|
||||
if ( status == AM_HAL_I2C_BIT_BANG_DATA_NAKED)
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_ADDRESS_NAKED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
if ( bUseOffset )
|
||||
{
|
||||
status = i2c_send_byte(ui8Offset);
|
||||
if ( status != AM_HAL_I2C_BIT_BANG_SUCCESS )
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// receive the requested number of data bytes
|
||||
//
|
||||
for (ui32I = 0; ui32I < number_of_bytes - 1; ui32I++)
|
||||
{
|
||||
//
|
||||
// receive the data bytes and send ACK for each one
|
||||
//
|
||||
status = i2c_receive_byte(pData, false);
|
||||
if (status != AM_HAL_I2C_BIT_BANG_SUCCESS)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
pData++;
|
||||
}
|
||||
// Send NAK for the last byte
|
||||
status = i2c_receive_byte(pData, true);
|
||||
if (status != AM_HAL_I2C_BIT_BANG_SUCCESS)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
//********************
|
||||
// Send stop condition
|
||||
//********************
|
||||
//
|
||||
// Pull down on clock line
|
||||
//
|
||||
WRITE_SCL_LO();
|
||||
|
||||
//
|
||||
// Delay for 1/4 bit cell time
|
||||
//
|
||||
WAIT_FOR_QUARTER_I2C_CLOCK();
|
||||
|
||||
|
||||
if (!bNoStop)
|
||||
{
|
||||
//
|
||||
// Pull down on data line with clock low
|
||||
//
|
||||
WRITE_SDA_LO();
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Release data line with clock low itself, as we are not sending STOP
|
||||
//
|
||||
PULL_SDA_HI();
|
||||
}
|
||||
//
|
||||
//
|
||||
// Delay for 1/4 bit cell time
|
||||
//
|
||||
WAIT_FOR_QUARTER_I2C_CLOCK();
|
||||
|
||||
if (i2c_pull_and_wait_scl_hi())
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT;
|
||||
}
|
||||
//
|
||||
// Delay for 1/2 bit cell time while clock is high
|
||||
//
|
||||
WAIT_I2C_CLOCK_HI_PERIOD();
|
||||
|
||||
if (!bNoStop)
|
||||
{
|
||||
//
|
||||
// release data line with clock high --> STOP CONDITION
|
||||
//
|
||||
PULL_SDA_HI();
|
||||
}
|
||||
|
||||
//
|
||||
// message successfully received (how could we fail???)
|
||||
//
|
||||
return AM_HAL_I2C_BIT_BANG_SUCCESS;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Send a string of data bytes to an I2C device
|
||||
//!
|
||||
//! @param address (only 8 bit I2C addresses are supported)
|
||||
//! LSB is I2C R/W
|
||||
//! @param number_of_bytes to transfer (# payload bytes)
|
||||
//! @param pData pointer to data buffer containing payload
|
||||
//!
|
||||
//! This function handles sending a payload to a slave device
|
||||
//!
|
||||
//! returns ENUM {AM_HAL_I2C_BIT_BANG_SUCCESS, AM_HAL_I2C_BIT_BANG_DATA_NAKED,
|
||||
//! AM_HAL_I2C_BIT_BANG_ADDRESS_NAKED}
|
||||
//
|
||||
//*****************************************************************************
|
||||
am_hal_i2c_bit_bang_enum_e
|
||||
am_hal_i2c_bit_bang_send(uint8_t address, uint32_t number_of_bytes,
|
||||
uint8_t *pData, uint8_t ui8Offset,
|
||||
bool bUseOffset, bool bNoStop)
|
||||
{
|
||||
uint32_t ui32I;
|
||||
am_hal_i2c_bit_bang_enum_e status;
|
||||
bool data_naked = false;
|
||||
|
||||
if (i2c_pull_and_wait_scl_hi())
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT;
|
||||
}
|
||||
//
|
||||
// Pull down on data line with clock high --> START CONDITION
|
||||
//
|
||||
WRITE_SDA_LO();
|
||||
|
||||
//
|
||||
// Delay for 1/2 bit cell time to start the clock
|
||||
//
|
||||
WAIT_I2C_CLOCK_HI_PERIOD();
|
||||
|
||||
//
|
||||
// send the address byte and wait for the ACK/NAK
|
||||
//
|
||||
status = i2c_send_byte(address);
|
||||
if ( status != AM_HAL_I2C_BIT_BANG_SUCCESS )
|
||||
{
|
||||
if ( status == AM_HAL_I2C_BIT_BANG_DATA_NAKED)
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_ADDRESS_NAKED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
if ( bUseOffset )
|
||||
{
|
||||
status = i2c_send_byte(ui8Offset);
|
||||
if ( status != AM_HAL_I2C_BIT_BANG_SUCCESS )
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// send the requested number of data bytes
|
||||
//
|
||||
for (ui32I = 0; ui32I < number_of_bytes; ui32I++)
|
||||
{
|
||||
//
|
||||
// send out the data bytes while watching for premature NAK
|
||||
//
|
||||
status = i2c_send_byte(*pData++);
|
||||
if (status != AM_HAL_I2C_BIT_BANG_SUCCESS)
|
||||
{
|
||||
if (status == AM_HAL_I2C_BIT_BANG_DATA_NAKED)
|
||||
{
|
||||
if (ui32I != (number_of_bytes-1))
|
||||
{
|
||||
data_naked = true;
|
||||
// TODO - should we be sending the STOP bit in this case regardless of bNoStop?
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = AM_HAL_I2C_BIT_BANG_SUCCESS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//********************
|
||||
// Send stop condition
|
||||
//********************
|
||||
|
||||
//
|
||||
// Pull down on clock line
|
||||
//
|
||||
WRITE_SCL_LO();
|
||||
|
||||
//
|
||||
// Delay for 1/4 bit cell time
|
||||
//
|
||||
WAIT_FOR_QUARTER_I2C_CLOCK();
|
||||
|
||||
|
||||
if (!bNoStop)
|
||||
{
|
||||
//
|
||||
// Pull down on data line with clock low
|
||||
//
|
||||
WRITE_SDA_LO();
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Release data line with clock low itself, as we are not sending STOP
|
||||
//
|
||||
PULL_SDA_HI();
|
||||
}
|
||||
|
||||
//
|
||||
// Delay for 1/4 bit cell time
|
||||
//
|
||||
WAIT_FOR_QUARTER_I2C_CLOCK();
|
||||
|
||||
if (i2c_pull_and_wait_scl_hi())
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT;
|
||||
}
|
||||
if (!bNoStop)
|
||||
{
|
||||
//
|
||||
// release data line with clock high --> STOP CONDITION
|
||||
//
|
||||
PULL_SDA_HI();
|
||||
}
|
||||
|
||||
//
|
||||
// Delay for 1/2 bit cell time while clock is high
|
||||
//
|
||||
WAIT_I2C_CLOCK_HI_PERIOD();
|
||||
|
||||
if ( data_naked )
|
||||
{
|
||||
return AM_HAL_I2C_BIT_BANG_DATA_NAKED; // if it happens early
|
||||
}
|
||||
|
||||
//
|
||||
// message successfully sent
|
||||
//
|
||||
return AM_HAL_I2C_BIT_BANG_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_i2c_bit_bang.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief I2C bit bang module.
|
||||
//!
|
||||
//! These functions implement the I2C bit bang utility
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_I2C_BIT_BANG_H
|
||||
#define AM_HAL_I2C_BIT_BANG_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Enumerated return constants
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
AM_HAL_I2C_BIT_BANG_SUCCESS = 0,
|
||||
AM_HAL_I2C_BIT_BANG_ADDRESS_NAKED,
|
||||
AM_HAL_I2C_BIT_BANG_DATA_NAKED,
|
||||
AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT,
|
||||
AM_HAL_I2C_BIT_BANG_DATA_TIMEOUT,
|
||||
AM_HAL_I2C_BIT_BANG_STATUS_MAX,
|
||||
}am_hal_i2c_bit_bang_enum_e;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern am_hal_i2c_bit_bang_enum_e am_hal_i2c_bit_bang_init(uint32_t sck_gpio_number,
|
||||
uint32_t sda_gpio_number);
|
||||
|
||||
extern am_hal_i2c_bit_bang_enum_e am_hal_i2c_bit_bang_send(uint8_t address,
|
||||
uint32_t number_of_bytes,
|
||||
uint8_t *pData,
|
||||
uint8_t ui8Offset,
|
||||
bool bUseOffset,
|
||||
bool bNoStop);
|
||||
|
||||
extern am_hal_i2c_bit_bang_enum_e am_hal_i2c_bit_bang_receive(uint8_t address,
|
||||
uint32_t number_of_bytes,
|
||||
uint8_t *pData,
|
||||
uint8_t ui8Offset,
|
||||
bool bUseOffset,
|
||||
bool bNoStop);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AM_HAL_I2C_BIT_BANG_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,439 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_interrupt.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Helper functions supporting interrupts and NVIC operation.
|
||||
//!
|
||||
//! These functions may be used for NVIC-level interrupt configuration.
|
||||
//!
|
||||
//! @addtogroup interrupt1 Interrupt (ARM NVIC support functions)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable an interrupt.
|
||||
//!
|
||||
//! @param ui32Interrupt The ISR number of the interrupt to be enabled.
|
||||
//!
|
||||
//! This function enables an interrupt signal to the NVIC based on the provided
|
||||
//! ISR number.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_interrupt_enable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Check to see what type of interrupt this is.
|
||||
//
|
||||
if ( ui32Interrupt > 15 )
|
||||
{
|
||||
//
|
||||
// If this ISR number corresponds to a "normal" peripheral interrupt,
|
||||
// enable it using the NVIC register.
|
||||
//
|
||||
AM_REG(NVIC, ISER0) = 0x1 << ((ui32Interrupt - 16) & 0x1F);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// If this is an ARM internal interrupt number, route it to the
|
||||
// appropriate enable register.
|
||||
//
|
||||
switch(ui32Interrupt)
|
||||
{
|
||||
case AM_HAL_INTERRUPT_BUSFAULT:
|
||||
AM_BFW(SYSCTRL, SHCSR, BUSFAULTENA, 1);
|
||||
break;
|
||||
|
||||
case AM_HAL_INTERRUPT_USAGEFAULT:
|
||||
AM_BFW(SYSCTRL, SHCSR, USAGEFAULTENA, 1);
|
||||
break;
|
||||
|
||||
case AM_HAL_INTERRUPT_MPUFAULT:
|
||||
AM_BFW(SYSCTRL, SHCSR, MEMFAULTENA, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable an interrupt.
|
||||
//!
|
||||
//! @param ui32Interrupt The ISR number of the interrupt to be disabled.
|
||||
//!
|
||||
//! This function disables an interrupt signal to the NVIC based on the
|
||||
//! provided ISR number.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_interrupt_disable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Check to see what type of interrupt this is.
|
||||
//
|
||||
if ( ui32Interrupt > 15 )
|
||||
{
|
||||
//
|
||||
// If this ISR number corresponds to a "normal" peripheral interrupt,
|
||||
// disable it using the NVIC register.
|
||||
//
|
||||
AM_REG(NVIC, ICER0) = 0x1 << ((ui32Interrupt - 16) & 0x1F);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// If this is an ARM internal interrupt number, route it to the
|
||||
// appropriate enable register.
|
||||
//
|
||||
switch(ui32Interrupt)
|
||||
{
|
||||
case AM_HAL_INTERRUPT_BUSFAULT:
|
||||
AM_BFW(SYSCTRL, SHCSR, BUSFAULTENA, 0);
|
||||
break;
|
||||
|
||||
case AM_HAL_INTERRUPT_USAGEFAULT:
|
||||
AM_BFW(SYSCTRL, SHCSR, USAGEFAULTENA, 0);
|
||||
break;
|
||||
|
||||
case AM_HAL_INTERRUPT_MPUFAULT:
|
||||
AM_BFW(SYSCTRL, SHCSR, MEMFAULTENA, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set the priority of an interrupt vector.
|
||||
//!
|
||||
//! @param ui32Interrupt is the ISR number of the interrupt to change.
|
||||
//! @param ui32Priority is the new ISR priority value.
|
||||
//!
|
||||
//! This function changes the priority value in the NVIC for the given
|
||||
//! interrupt vector number.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_interrupt_priority_set(uint32_t ui32Interrupt, uint32_t ui32Priority)
|
||||
{
|
||||
volatile uint32_t *pui32PriorityReg;
|
||||
volatile uint32_t ui32OldPriority;
|
||||
uint32_t ui32Shift;
|
||||
|
||||
//
|
||||
// Find the correct priority register.
|
||||
//
|
||||
pui32PriorityReg = (volatile uint32_t *) AM_REG_NVIC_IPR0_O;
|
||||
pui32PriorityReg += ((ui32Interrupt - 16) >> 2);
|
||||
|
||||
//
|
||||
// Find the correct shift value.
|
||||
//
|
||||
ui32Shift = (((ui32Interrupt - 16) & 0x3) * 8);
|
||||
|
||||
//
|
||||
// Mask out the old priority.
|
||||
//
|
||||
ui32OldPriority = *pui32PriorityReg;
|
||||
ui32OldPriority &= ~(0xFF << ui32Shift);
|
||||
|
||||
//
|
||||
// OR in the new priority.
|
||||
//
|
||||
*pui32PriorityReg = ui32OldPriority | (ui32Priority << ui32Shift);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set a pending interrupt bit in the NVIC (Software Interrupt)
|
||||
//!
|
||||
//! @param ui32Interrupt is the ISR number of the interrupt to change.
|
||||
//!
|
||||
//! This function sets the specified bit in the Interrupt Set Pending (ISPR0)
|
||||
//! register. For future MCUs there may be more than one ISPR.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void am_hal_interrupt_pend_set(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Check to see if the specified interrupt is valid for this MCU
|
||||
//
|
||||
if ( ui32Interrupt > AM_HAL_INTERRUPT_MAX )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check to see what type of interrupt this is.
|
||||
//
|
||||
if ( ui32Interrupt > 15 )
|
||||
{
|
||||
//
|
||||
// If this ISR number corresponds to a "normal" peripheral interrupt,
|
||||
// disable it using the NVIC register.
|
||||
//
|
||||
AM_REG(NVIC, ISPR0) = 0x1 << ((ui32Interrupt - 16) & 0x1F);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clear a pending interrupt bit in the NVIC without servicing it
|
||||
//!
|
||||
//! @param ui32Interrupt is the ISR number of the interrupt to change.
|
||||
//!
|
||||
//! This function clears the specified bit in the Interrupt Clear Pending
|
||||
//! (ICPR0) register. For future MCUs there may be more than one ICPR. This
|
||||
//! function is useful immediately following a WFI before interrupts are
|
||||
//! re-enabled.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void am_hal_interrupt_pend_clear(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Check to see if the specified interrupt is valid for this MCU
|
||||
//
|
||||
if ( ui32Interrupt > AM_HAL_INTERRUPT_MAX )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check to see what type of interrupt this is.
|
||||
//
|
||||
if ( ui32Interrupt > 15 )
|
||||
{
|
||||
//
|
||||
// If this ISR number corresponds to a "normal" peripheral interrupt,
|
||||
// disable it using the NVIC register.
|
||||
//
|
||||
AM_REG(NVIC, ICPR0) = 0x1 << ((ui32Interrupt - 16) & 0x1F);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Globally enable interrupt service routines
|
||||
//!
|
||||
//! This function allows interrupt signals from the NVIC to trigger ISR entry
|
||||
//! in the CPU. This function must be called if interrupts are to be serviced
|
||||
//! in software.
|
||||
//!
|
||||
//! @return 1 if interrupts were previously disabled, 0 otherwise.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
__asm uint32_t
|
||||
am_hal_interrupt_master_enable(void)
|
||||
{
|
||||
mrs r0, PRIMASK
|
||||
cpsie i
|
||||
bx lr
|
||||
}
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
uint32_t __attribute__((naked))
|
||||
am_hal_interrupt_master_enable(void)
|
||||
{
|
||||
__asm(" mrs r0, PRIMASK");
|
||||
__asm(" cpsie i");
|
||||
__asm(" bx lr");
|
||||
}
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
uint32_t __attribute__((naked))
|
||||
am_hal_interrupt_master_enable(void)
|
||||
{
|
||||
__asm(" mrs r0, PRIMASK");
|
||||
__asm(" cpsie i");
|
||||
__asm(" bx lr");
|
||||
}
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma diag_suppress = Pe940 // Suppress IAR compiler warning about missing
|
||||
// return statement on a non-void function
|
||||
__stackless uint32_t
|
||||
am_hal_interrupt_master_enable(void)
|
||||
{
|
||||
__asm(" mrs r0, PRIMASK");
|
||||
__asm(" cpsie i");
|
||||
__asm(" bx lr");
|
||||
}
|
||||
#pragma diag_default = Pe940 // Restore IAR compiler warning
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Globally disable interrupt service routines
|
||||
//!
|
||||
//! This function prevents interrupt signals from the NVIC from triggering ISR
|
||||
//! entry in the CPU. This will effectively stop incoming interrupt sources
|
||||
//! from triggering their corresponding ISRs.
|
||||
//!
|
||||
//! @note Any external interrupt signal that occurs while the master interrupt
|
||||
//! disable is active will still reach the "pending" state in the NVIC, but it
|
||||
//! will not be allowed to reach the "active" state or trigger the
|
||||
//! corresponding ISR. Instead, these interrupts are essentially "queued" until
|
||||
//! the next time the master interrupt enable instruction is executed. At that
|
||||
//! time, the interrupt handlers will be executed in order of decreasing
|
||||
//! priority.
|
||||
//!
|
||||
//! @return 1 if interrupts were previously disabled, 0 otherwise.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
__asm uint32_t
|
||||
am_hal_interrupt_master_disable(void)
|
||||
{
|
||||
mrs r0, PRIMASK
|
||||
cpsid i
|
||||
bx lr
|
||||
}
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
uint32_t __attribute__((naked))
|
||||
am_hal_interrupt_master_disable(void)
|
||||
{
|
||||
__asm(" mrs r0, PRIMASK");
|
||||
__asm(" cpsid i");
|
||||
__asm(" bx lr");
|
||||
}
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
uint32_t __attribute__((naked))
|
||||
am_hal_interrupt_master_disable(void)
|
||||
{
|
||||
__asm(" mrs r0, PRIMASK");
|
||||
__asm(" cpsid i");
|
||||
__asm(" bx lr");
|
||||
}
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma diag_suppress = Pe940 // Suppress IAR compiler warning about missing
|
||||
// return statement on a non-void function
|
||||
__stackless uint32_t
|
||||
am_hal_interrupt_master_disable(void)
|
||||
{
|
||||
__asm(" mrs r0, PRIMASK");
|
||||
__asm(" cpsid i");
|
||||
__asm(" bx lr");
|
||||
}
|
||||
#pragma diag_default = Pe940 // Restore IAR compiler warning
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Sets the master interrupt state based on the input.
|
||||
//!
|
||||
//! @param ui32InterruptState - Desired PRIMASK value.
|
||||
//!
|
||||
//! This function directly writes the PRIMASK register in the ARM core. A value
|
||||
//! of 1 will disable interrupts, while a value of zero will enable them.
|
||||
//!
|
||||
//! This function may be used along with am_hal_interrupt_master_disable() to
|
||||
//! implement a nesting critical section. To do this, call
|
||||
//! am_hal_interrupt_master_disable() to start the critical section, and save
|
||||
//! its return value. To complete the critical section, call
|
||||
//! am_hal_interrupt_master_set() using the saved return value as \e
|
||||
//! ui32InterruptState. This will safely restore PRIMASK to the value it
|
||||
//! contained just before the start of the critical section.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
__asm void
|
||||
am_hal_interrupt_master_set(uint32_t ui32InterruptState)
|
||||
{
|
||||
msr PRIMASK, r0
|
||||
bx lr
|
||||
}
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
void __attribute__((naked))
|
||||
am_hal_interrupt_master_set(uint32_t ui32InterruptState)
|
||||
{
|
||||
__asm(" msr PRIMASK, r0");
|
||||
__asm(" bx lr");
|
||||
}
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
void __attribute__((naked))
|
||||
am_hal_interrupt_master_set(uint32_t ui32InterruptState)
|
||||
{
|
||||
__asm(" msr PRIMASK, r0");
|
||||
__asm(" bx lr");
|
||||
}
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma diag_suppress = Pe940 // Suppress IAR compiler warning about missing
|
||||
// return statement on a non-void function
|
||||
__stackless void
|
||||
am_hal_interrupt_master_set(uint32_t ui32InterruptState)
|
||||
{
|
||||
__asm(" msr PRIMASK, r0");
|
||||
__asm(" bx lr");
|
||||
}
|
||||
#pragma diag_default = Pe940 // Restore IAR compiler warning
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,145 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_interrupt.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Helper functions supporting interrupts and NVIC operation.
|
||||
//!
|
||||
//! These functions may be used for NVIC-level interrupt configuration.
|
||||
//!
|
||||
//! @addtogroup interrupt1 Interrupt (ARM NVIC support functions)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_INTERRUPT_H
|
||||
#define AM_HAL_INTERRUPT_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name ISR number macros.
|
||||
//! @brief ISR macros.
|
||||
//!
|
||||
//! These macros are used for all ui32Interrupt arguments in this module.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Hardware interrupts
|
||||
//
|
||||
#define AM_HAL_INTERRUPT_MAX (31) //AM_HAL_INTERRUPT_SOFTWARE15
|
||||
#define AM_HAL_INTERRUPT_RESET 1
|
||||
#define AM_HAL_INTERRUPT_NMI 2
|
||||
#define AM_HAL_INTERRUPT_HARDFAULT 3
|
||||
#define AM_HAL_INTERRUPT_MPUFAULT 4
|
||||
#define AM_HAL_INTERRUPT_BUSFAULT 5
|
||||
#define AM_HAL_INTERRUPT_USAGEFAULT 6
|
||||
|
||||
#define AM_HAL_INTERRUPT_SVCALL 11
|
||||
#define AM_HAL_INTERRUPT_DEBUGMON 12
|
||||
#define AM_HAL_INTERRUPT_PENDSV 14
|
||||
#define AM_HAL_INTERRUPT_SYSTICK 15
|
||||
|
||||
//
|
||||
// Begin IRQs
|
||||
//
|
||||
#define AM_HAL_INTERRUPT_BROWNOUT 16
|
||||
#define AM_HAL_INTERRUPT_WATCHDOG 17
|
||||
#define AM_HAL_INTERRUPT_CLKGEN 18
|
||||
#define AM_HAL_INTERRUPT_VCOMP 19
|
||||
#define AM_HAL_INTERRUPT_IOSLAVE 20
|
||||
#define AM_HAL_INTERRUPT_IOSACC 21
|
||||
#define AM_HAL_INTERRUPT_IOMASTER0 22
|
||||
#define AM_HAL_INTERRUPT_IOMASTER1 23
|
||||
#define AM_HAL_INTERRUPT_ADC 24
|
||||
#define AM_HAL_INTERRUPT_GPIO 25
|
||||
#define AM_HAL_INTERRUPT_CTIMER 26
|
||||
#define AM_HAL_INTERRUPT_UART 27
|
||||
#define AM_HAL_INTERRUPT_SOFTWARE12 28
|
||||
#define AM_HAL_INTERRUPT_SOFTWARE13 29
|
||||
#define AM_HAL_INTERRUPT_SOFTWARE14 30
|
||||
#define AM_HAL_INTERRUPT_SOFTWARE15 31
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Interrupt priority
|
||||
//!
|
||||
//! This macro is made to be used with the \e am_hal_interrupt_priority_set()
|
||||
//! function. It converts a priority number to the format used by the ARM
|
||||
//! standard priority register, where only the top 3 bits are used.
|
||||
//!
|
||||
//! For example, AM_HAL_INTERRUPT_PRIORITY(1) yields a value of 0x20.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_INTERRUPT_PRIORITY(n) (((uint32_t)(n) & 0x7) << 5)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_interrupt_enable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_interrupt_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_interrupt_pend_set(uint32_t ui32Interrupt);
|
||||
extern void am_hal_interrupt_pend_clear(uint32_t ui32Interrupt);
|
||||
extern void am_hal_interrupt_priority_set(uint32_t ui32Interrupt,
|
||||
uint32_t ui32Priority);
|
||||
extern uint32_t am_hal_interrupt_master_disable(void);
|
||||
extern uint32_t am_hal_interrupt_master_enable(void);
|
||||
extern void am_hal_interrupt_master_set(uint32_t ui32InterruptState);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_INTERRUPT_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,591 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_iom.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the IO Master module
|
||||
//!
|
||||
//! @addtogroup iom1 IO Master (SPI/I2C)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef AM_HAL_IOM_H
|
||||
#define AM_HAL_IOM_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These function-like macros stub out these functions for Apollo.
|
||||
//
|
||||
#define am_hal_iom_pwrctrl_enable(ui32Module)
|
||||
#define am_hal_iom_pwrctrl_disable(ui32Module)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name IOM Clock Frequencies
|
||||
//! @brief Macro definitions for common SPI and I2C clock frequencies.
|
||||
//!
|
||||
//! These macros may be used with the am_hal_iom_config_t structure to set the
|
||||
//! clock frequency of the serial interfaces. This list is not exhaustive by
|
||||
//! any means. If you would like to use a different clock frequency, use the
|
||||
//! exact CLKCFG register value corresponding to your desired frequency. Please
|
||||
//! see the datasheet for more information about the CLKCFG register.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOM_8MHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(1) | AM_REG_IOMSTR_CLKCFG_DIV3(1))
|
||||
|
||||
#define AM_HAL_IOM_6MHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(3))
|
||||
|
||||
#define AM_HAL_IOM_4MHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(2) | AM_REG_IOMSTR_CLKCFG_DIV3(1))
|
||||
|
||||
#define AM_HAL_IOM_3MHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(4))
|
||||
|
||||
#define AM_HAL_IOM_2MHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(3) | AM_REG_IOMSTR_CLKCFG_DIV3(1))
|
||||
|
||||
#define AM_HAL_IOM_1_5MHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(5))
|
||||
|
||||
#define AM_HAL_IOM_1MHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(4) | AM_REG_IOMSTR_CLKCFG_DIV3(1))
|
||||
|
||||
#define AM_HAL_IOM_750KHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(6))
|
||||
|
||||
#define AM_HAL_IOM_500KHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(5) | AM_REG_IOMSTR_CLKCFG_DIV3(1))
|
||||
|
||||
#define AM_HAL_IOM_400KHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(2) | AM_REG_IOMSTR_CLKCFG_DIV3(1) | \
|
||||
AM_REG_IOMSTR_CLKCFG_TOTPER(9) | AM_REG_IOMSTR_CLKCFG_LOWPER(4) | \
|
||||
AM_REG_IOMSTR_CLKCFG_DIVEN(1))
|
||||
|
||||
#define AM_HAL_IOM_375KHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(0))
|
||||
|
||||
#define AM_HAL_IOM_250KHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(6) | AM_REG_IOMSTR_CLKCFG_DIV3(1))
|
||||
|
||||
#define AM_HAL_IOM_125KHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(0) | AM_REG_IOMSTR_CLKCFG_DIV3(1))
|
||||
|
||||
#define AM_HAL_IOM_100KHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(4) | AM_REG_IOMSTR_CLKCFG_DIV3(1) | \
|
||||
AM_REG_IOMSTR_CLKCFG_TOTPER(9) | AM_REG_IOMSTR_CLKCFG_LOWPER(4) | \
|
||||
AM_REG_IOMSTR_CLKCFG_DIVEN(1))
|
||||
|
||||
#define AM_HAL_IOM_50KHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(4) | AM_REG_IOMSTR_CLKCFG_DIV3(1) | \
|
||||
AM_REG_IOMSTR_CLKCFG_TOTPER(19) | AM_REG_IOMSTR_CLKCFG_LOWPER(9) | \
|
||||
AM_REG_IOMSTR_CLKCFG_DIVEN(1))
|
||||
|
||||
#define AM_HAL_IOM_10KHZ \
|
||||
(AM_REG_IOMSTR_CLKCFG_FSEL(4) | AM_REG_IOMSTR_CLKCFG_DIV3(1) | \
|
||||
AM_REG_IOMSTR_CLKCFG_TOTPER(99) | AM_REG_IOMSTR_CLKCFG_LOWPER(49) | \
|
||||
AM_REG_IOMSTR_CLKCFG_DIVEN(1))
|
||||
//! @}
|
||||
|
||||
// Hardware FIFO Size
|
||||
#define AM_HAL_IOM_MAX_FIFO_SIZE 64
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name IOM Physical Protocols
|
||||
//! @brief Macro Definitions for general IOM configuration.
|
||||
//!
|
||||
//! These macros may be used with the am_hal_iom_config_t structure to set the
|
||||
//! operating parameters of each serial IO master module. Choose SPIMODE to
|
||||
//! select the SPI interface, or I2CMODE to select the I2C interface.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOM_SPIMODE AM_REG_IOMSTR_CFG_IFCSEL(1)
|
||||
#define AM_HAL_IOM_I2CMODE AM_REG_IOMSTR_CFG_IFCSEL(0)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name IOM Operations
|
||||
//! @brief Macro definitions used for ui32Operation parameters.
|
||||
//!
|
||||
//! These macros may be used to specify which action an IOM command will
|
||||
//! execute. The 'OFFSET' operations will cause the IOM hardware to transmit the
|
||||
//! provided 1-byte 'offset' before executing the rest of the command.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOM_WRITE 0x00000000
|
||||
#define AM_HAL_IOM_READ 0x80000000
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Command Options
|
||||
//! @brief Macro definitions used for ui32Options parameters.
|
||||
//!
|
||||
//! These macros are all related to SPI or I2C command words. They can be used
|
||||
//! to set specific options on a per-transaction basis.
|
||||
//!
|
||||
//! - CS_LOW - Do not raise the CS signal at the end of this SPI command.
|
||||
//! - NO_STOP - Do not release the I2C bus with a STOP bit after this command.
|
||||
//! - LSB_FIRST - Reverse the payload bits of this command.
|
||||
//! - 10BIT_ADDRESS - (I2C only) use a 10-bit I2C address protocol.
|
||||
//! - RAW - Don't use an offset byte.
|
||||
//! - OFFSET() - Send this 1-byte offset as the first byte of the transaction.
|
||||
//! This can be used to access "registers" in external I2C devices, or add a
|
||||
//! 1-byte write to the beginning of a SPI write or read command. See
|
||||
//! "normal mode" operation in the I2C/SPI Master section of the datasheet
|
||||
//! for more information on this parameter.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOM_CS_LOW 0x10000000
|
||||
#define AM_HAL_IOM_NO_STOP 0x10000000
|
||||
#define AM_HAL_IOM_LSB_FIRST 0x08000000
|
||||
#define AM_HAL_IOM_10BIT_ADDRESS 0x04000000
|
||||
#define AM_HAL_IOM_RAW 0x40000000
|
||||
#define AM_HAL_IOM_OFFSET(n) (((n) << 8) & 0x0000FF00)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name IOM Interrupts
|
||||
//! @brief Macro definitions for IOM interrupt status bits.
|
||||
//!
|
||||
//! These macros correspond to the bits in the IOM interrupt status register.
|
||||
//! They may be used with any of the \e am_hal_iom_int_x() functions.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOM_INT_ARB AM_REG_IOMSTR_INTEN_ARB_M
|
||||
#define AM_HAL_IOM_INT_STOP AM_REG_IOMSTR_INTEN_STOP_M
|
||||
#define AM_HAL_IOM_INT_START AM_REG_IOMSTR_INTEN_START_M
|
||||
#define AM_HAL_IOM_INT_ICMD AM_REG_IOMSTR_INTEN_ICMD_M
|
||||
#define AM_HAL_IOM_INT_IACC AM_REG_IOMSTR_INTEN_IACC_M
|
||||
#define AM_HAL_IOM_INT_WTLEN AM_REG_IOMSTR_INTEN_WTLEN_M
|
||||
#define AM_HAL_IOM_INT_NAK AM_REG_IOMSTR_INTEN_NAK_M
|
||||
#define AM_HAL_IOM_INT_FOVFL AM_REG_IOMSTR_INTEN_FOVFL_M
|
||||
#define AM_HAL_IOM_INT_FUNDFL AM_REG_IOMSTR_INTEN_FUNDFL_M
|
||||
#define AM_HAL_IOM_INT_THR AM_REG_IOMSTR_INTEN_THR_M
|
||||
#define AM_HAL_IOM_INT_CMDCMP AM_REG_IOMSTR_INTEN_CMDCMP_M
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name IOM function errors
|
||||
//! @brief Return values for IOM HAL function errors, such as with the function
|
||||
//! am_hal_iom_error_status_get().
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOM_ERR_INVALID_MODULE (1 << 30)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Software IOM modules
|
||||
//! @brief Macro definitions for using the software I2C interface.
|
||||
//!
|
||||
//! Use this macro as the module number for standard IOM functions to emulate
|
||||
//! them using the bit-banged i2c interface.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOM_I2CBB_MODULE AM_REG_IOMSTR_NUM_MODULES
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Union type for a word-aligned, byte-addressable array.
|
||||
//!
|
||||
//! This is a convenience macro that may be used to define byte-addressable
|
||||
//! arrays with 32-bit alignment. This allows the programmer to define SPI or
|
||||
//! I2C transactions as a series of 8-bit values, but also write them to the
|
||||
//! IOM FIFO efficiently as a series of 32-bit values.
|
||||
//!
|
||||
//! Example usage:
|
||||
//!
|
||||
//! @code
|
||||
//! //
|
||||
//! // Declare a buffer array with at least 3-bytes worth of space.
|
||||
//! //
|
||||
//! am_hal_iom_buffer(3) sBuffer;
|
||||
//!
|
||||
//! //
|
||||
//! // Populate the buffer with a 3-byte command.
|
||||
//! //
|
||||
//! sBuffer.bytes[0] = 's';
|
||||
//! sBuffer.bytes[1] = 'p';
|
||||
//! sBuffer.bytes[2] = 'i';
|
||||
//!
|
||||
//! //
|
||||
//! // Send the buffer over the spi interface.
|
||||
//! //
|
||||
//! am_hal_iom_spi_write(psDevice, sBuffer.words, 3, 0);
|
||||
//!
|
||||
//! @endcode
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_iom_buffer(A) \
|
||||
union \
|
||||
{ \
|
||||
uint32_t words[(A + 3) >> 2]; \
|
||||
uint8_t bytes[A]; \
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configuration structure for the IO master module.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! @brief Selects the physical protocol for the IO master module. Choose
|
||||
//! either AM_HAL_IOM_SPIMODE or AM_HAL_IOM_I2CMODE.
|
||||
//
|
||||
uint32_t ui32InterfaceMode;
|
||||
|
||||
//
|
||||
//! @brief Selects the output clock frequency for SPI or I2C mode. Choose
|
||||
//! one of the AM_HAL_IOM_nMHZ or AM_HAL_IOM_nKHZ macros.
|
||||
//
|
||||
uint32_t ui32ClockFrequency;
|
||||
|
||||
//
|
||||
//! Select the SPI clock phase (unused in I2C mode).
|
||||
//
|
||||
bool bSPHA;
|
||||
|
||||
//
|
||||
//! Select the SPI clock polarity (unused in I2C mode).
|
||||
//
|
||||
bool bSPOL;
|
||||
|
||||
//
|
||||
//! @brief Select the FIFO write threshold.
|
||||
//!
|
||||
//! The IOM controller will generate a processor interrupt when the number
|
||||
//! of entries in the FIFO goes *below* this number.
|
||||
//
|
||||
uint8_t ui8WriteThreshold;
|
||||
|
||||
//
|
||||
//! @brief Select the FIFO read threshold.
|
||||
//!
|
||||
//! The IOM controller will generate a processor interrupt when the number
|
||||
//! of entries in the FIFO grows *larger* than this number.
|
||||
//
|
||||
uint8_t ui8ReadThreshold;
|
||||
}
|
||||
am_hal_iom_config_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Configuration structure for an individual SPI device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! IOM module to use for communicating with this device.
|
||||
//
|
||||
uint32_t ui32Module;
|
||||
|
||||
//
|
||||
//! Chip select signal that should be used for this device.
|
||||
//
|
||||
uint32_t ui32ChipSelect;
|
||||
|
||||
//
|
||||
//! Additional options that will ALWAYS be ORed into the command word.
|
||||
//
|
||||
uint32_t ui32Options;
|
||||
}
|
||||
am_hal_iom_spi_device_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Configuration structure for an individual I2C device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! IOM module to use for communicating with this device.
|
||||
//
|
||||
uint32_t ui32Module;
|
||||
|
||||
//
|
||||
//! I2C address associated with this device.
|
||||
//
|
||||
uint32_t ui32BusAddress;
|
||||
|
||||
//
|
||||
//! Additional options that will ALWAYS be ORed into the command word.
|
||||
//
|
||||
uint32_t ui32Options;
|
||||
}
|
||||
am_hal_iom_i2c_device_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Typedef for non-blocking function callbacks.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (*am_hal_iom_callback_t)(void);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Typedef for a function that waits until the IOM queue is empty.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (*am_hal_iom_queue_flush_t)(uint32_t);
|
||||
|
||||
extern am_hal_iom_queue_flush_t am_hal_iom_queue_flush;
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Operations
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOM_QUEUE_SPI_WRITE 0
|
||||
#define AM_HAL_IOM_QUEUE_SPI_READ 1
|
||||
#define AM_HAL_IOM_QUEUE_I2C_WRITE 2
|
||||
#define AM_HAL_IOM_QUEUE_I2C_READ 3
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Structure to hold IOM operations.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ui32Operation;
|
||||
uint32_t ui32Module;
|
||||
uint32_t ui32ChipSelect;
|
||||
uint32_t *pui32Data;
|
||||
uint32_t ui32NumBytes;
|
||||
uint32_t ui32Options;
|
||||
am_hal_iom_callback_t pfnCallback;
|
||||
}
|
||||
am_hal_iom_queue_entry_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Global variables
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern uint32_t g_iom_error_status;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_iom_config(uint32_t ui32Module,
|
||||
const am_hal_iom_config_t *psConfig);
|
||||
extern void am_hal_iom_enable(uint32_t ui32Module);
|
||||
extern void am_hal_iom_disable(uint32_t ui32Module);
|
||||
extern void am_hal_iom_spi_write(uint32_t ui32Module, uint32_t ui32ChipSelect,
|
||||
uint32_t *pui32Data, uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options);
|
||||
extern void am_hal_iom_spi_read(uint32_t ui32Module, uint32_t ui32ChipSelect,
|
||||
uint32_t *pui32Data, uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options);
|
||||
extern uint32_t am_hal_iom_spi_write_nq(uint32_t ui32Module, uint32_t ui32ChipSelect,
|
||||
uint32_t *pui32Data, uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options);
|
||||
extern uint32_t am_hal_iom_spi_read_nq(uint32_t ui32Module, uint32_t ui32ChipSelect,
|
||||
uint32_t *pui32Data, uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options);
|
||||
extern void am_hal_iom_spi_write_nb(uint32_t ui32Module, uint32_t ui32ChipSelect,
|
||||
uint32_t *pui32Data, uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options,
|
||||
am_hal_iom_callback_t pfnCallback);
|
||||
extern uint32_t am_hal_iom_spi_read_nb(uint32_t ui32Module, uint32_t ui32ChipSelect,
|
||||
uint32_t *pui32Data, uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options,
|
||||
am_hal_iom_callback_t pfnCallback);
|
||||
extern void am_hal_iom_spi_cmd_run(uint32_t ui32Operation,
|
||||
uint32_t ui32Module,
|
||||
uint32_t ui32ChipSelect,
|
||||
uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options);
|
||||
extern void am_hal_iom_i2c_write(uint32_t ui32Module,
|
||||
uint32_t ui32BusAddress,
|
||||
uint32_t *pui32Data,
|
||||
uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options);
|
||||
extern void am_hal_iom_i2c_read(uint32_t ui32Module,
|
||||
uint32_t ui32BusAddress,
|
||||
uint32_t *pui32Data,
|
||||
uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options);
|
||||
extern uint32_t am_hal_iom_i2c_write_nq(uint32_t ui32Module,
|
||||
uint32_t ui32BusAddress,
|
||||
uint32_t *pui32Data,
|
||||
uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options);
|
||||
extern uint32_t am_hal_iom_i2c_read_nq(uint32_t ui32Module,
|
||||
uint32_t ui32BusAddress,
|
||||
uint32_t *pui32Data,
|
||||
uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options);
|
||||
extern void am_hal_iom_i2c_write_nb(uint32_t ui32Module,
|
||||
uint32_t ui32BusAddress,
|
||||
uint32_t *pui32Data,
|
||||
uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options,
|
||||
am_hal_iom_callback_t pfnCallback);
|
||||
extern void am_hal_iom_i2c_read_nb(uint32_t ui32Module,
|
||||
uint32_t ui32BusAddress,
|
||||
uint32_t *pui32Data,
|
||||
uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options,
|
||||
am_hal_iom_callback_t pfnCallback);
|
||||
extern void am_hal_iom_i2c_cmd_run(uint32_t ui32Operation,
|
||||
uint32_t ui32Module,
|
||||
uint32_t ui32BusAddress,
|
||||
uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options);
|
||||
extern void am_hal_iom_command_repeat_set(uint32_t ui32Module,
|
||||
uint32_t ui32CmdCount);
|
||||
extern uint32_t am_hal_iom_status_get(uint32_t ui32Module);
|
||||
extern uint32_t am_hal_iom_error_status_get(uint32_t ui32Module);
|
||||
extern uint32_t am_hal_iom_fifo_write(uint32_t ui32Module, uint32_t *pui32Data,
|
||||
uint32_t ui32NumBytes);
|
||||
extern uint32_t am_hal_iom_fifo_read(uint32_t ui32Module, uint32_t *pui32Data,
|
||||
uint32_t ui32NumBytes);
|
||||
extern uint8_t am_hal_iom_fifo_empty_slots(uint32_t ui32Module);
|
||||
extern uint8_t am_hal_iom_fifo_full_slots(uint32_t ui32Module);
|
||||
extern void am_hal_iom_poll_complete(uint32_t ui32Module);
|
||||
extern void am_hal_iom_int_service(uint32_t ui32Module, uint32_t ui32Status);
|
||||
extern void am_hal_iom_int_enable(uint32_t ui32Module, uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_iom_int_enable_get(uint32_t ui32Module);
|
||||
extern void am_hal_iom_int_disable(uint32_t ui32Module, uint32_t ui32Interrupt);
|
||||
extern void am_hal_iom_int_clear(uint32_t ui32Module, uint32_t ui32Interrupt);
|
||||
extern void am_hal_iom_int_set(uint32_t ui32Module, uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_iom_int_status_get(uint32_t ui32Module, bool bEnabledOnly);
|
||||
extern void am_hal_iom_queue_init(uint32_t ui32ModuleNum,
|
||||
am_hal_iom_queue_entry_t *psQueueMemory,
|
||||
uint32_t ui32QueueMemSize);
|
||||
extern uint32_t am_hal_iom_queue_length_get(uint32_t ui32Module);
|
||||
extern void am_hal_iom_sleeping_queue_flush(uint32_t ui32Module);
|
||||
extern void am_hal_iom_queue_spi_write(uint32_t ui32Module, uint32_t ui32ChipSelect,
|
||||
uint32_t *pui32Data, uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options,
|
||||
am_hal_iom_callback_t pfnCallback);
|
||||
extern void am_hal_iom_queue_spi_read(uint32_t ui32Module, uint32_t ui32ChipSelect,
|
||||
uint32_t *pui32Data, uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options,
|
||||
am_hal_iom_callback_t pfnCallback);
|
||||
extern void am_hal_iom_queue_i2c_write(uint32_t ui32Module, uint32_t ui32BusAddress,
|
||||
uint32_t *pui32Data, uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options,
|
||||
am_hal_iom_callback_t pfnCallback);
|
||||
extern void am_hal_iom_queue_i2c_read(uint32_t ui32Module, uint32_t ui32BusAddress,
|
||||
uint32_t *pui32Data, uint32_t ui32NumBytes,
|
||||
uint32_t ui32Options,
|
||||
am_hal_iom_callback_t pfnCallback);
|
||||
extern void am_hal_iom_queue_start_next_msg(uint32_t ui32Module);
|
||||
extern void am_hal_iom_queue_service(uint32_t ui32Module, uint32_t ui32Status);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Helper functions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_IOMASTER_ISR_QUEUE(x) \
|
||||
void am_iomaster##x##_isr(void) \
|
||||
{ \
|
||||
uint32_t ui32IntStatus; \
|
||||
g_iom_error_status = am_hal_iom_error_status_get(x); \
|
||||
ui32IntStatus = am_hal_iom_int_status_get(x, false); \
|
||||
am_hal_iom_int_clear(x, ui32IntStatus); \
|
||||
am_hal_iom_queue_service(x, ui32IntStatus); \
|
||||
}
|
||||
|
||||
#define AM_IOMASTER_ISR_NB(x) \
|
||||
void am_iomaster##x##_isr(void) \
|
||||
{ \
|
||||
uint32_t ui32IntStatus; \
|
||||
g_iom_error_status = am_hal_iom_error_status_get(x); \
|
||||
ui32IntStatus = am_hal_iom_int_status_get(x, false); \
|
||||
am_hal_iom_int_clear(x, ui32IntStatus); \
|
||||
am_hal_iom_int_service(x, ui32IntStatus); \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_IOM_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,358 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_ios.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the IO Slave module
|
||||
//!
|
||||
//! @addtogroup ios1 IO Slave (SPI/I2C)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_IOS_H
|
||||
#define AM_HAL_IOS_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Interface Configuration
|
||||
//! @brief Macro definitions for configuring the physical interface of the IO
|
||||
//! Slave
|
||||
//!
|
||||
//! These macros may be used with the am_hal_ios_config_t structure to set the
|
||||
//! physical parameters of the SPI/I2C slave module.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOS_USE_SPI AM_REG_IOSLAVE_CFG_IFCSEL_SPI
|
||||
#define AM_HAL_IOS_SPIMODE_0 AM_REG_IOSLAVE_CFG_SPOL_SPI_MODES_0_3
|
||||
#define AM_HAL_IOS_SPIMODE_1 AM_REG_IOSLAVE_CFG_SPOL_SPI_MODES_1_2
|
||||
#define AM_HAL_IOS_SPIMODE_2 AM_REG_IOSLAVE_CFG_SPOL_SPI_MODES_1_2
|
||||
#define AM_HAL_IOS_SPIMODE_3 AM_REG_IOSLAVE_CFG_SPOL_SPI_MODES_0_3
|
||||
|
||||
#define AM_HAL_IOS_USE_I2C AM_REG_IOSLAVE_CFG_IFCSEL_I2C
|
||||
#define AM_HAL_IOS_I2C_ADDRESS(n) AM_REG_IOSLAVE_CFG_I2CADDR(n)
|
||||
|
||||
#define AM_HAL_IOS_LSB_FIRST AM_REG_IOSLAVE_CFG_LSB(1)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Register Access Interrupts
|
||||
//! @brief Macro definitions for register access interrupts.
|
||||
//!
|
||||
//! These macros may be used with any of the
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOS_ACCESS_INT_00 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 31)
|
||||
#define AM_HAL_IOS_ACCESS_INT_01 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 30)
|
||||
#define AM_HAL_IOS_ACCESS_INT_02 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 29)
|
||||
#define AM_HAL_IOS_ACCESS_INT_03 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 28)
|
||||
#define AM_HAL_IOS_ACCESS_INT_04 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 27)
|
||||
#define AM_HAL_IOS_ACCESS_INT_05 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 26)
|
||||
#define AM_HAL_IOS_ACCESS_INT_06 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 25)
|
||||
#define AM_HAL_IOS_ACCESS_INT_07 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 24)
|
||||
#define AM_HAL_IOS_ACCESS_INT_08 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 23)
|
||||
#define AM_HAL_IOS_ACCESS_INT_09 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 22)
|
||||
#define AM_HAL_IOS_ACCESS_INT_0A AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 21)
|
||||
#define AM_HAL_IOS_ACCESS_INT_0B AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 20)
|
||||
#define AM_HAL_IOS_ACCESS_INT_0C AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 19)
|
||||
#define AM_HAL_IOS_ACCESS_INT_0D AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 18)
|
||||
#define AM_HAL_IOS_ACCESS_INT_0E AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 17)
|
||||
#define AM_HAL_IOS_ACCESS_INT_0F AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 16)
|
||||
#define AM_HAL_IOS_ACCESS_INT_13 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 15)
|
||||
#define AM_HAL_IOS_ACCESS_INT_17 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 14)
|
||||
#define AM_HAL_IOS_ACCESS_INT_1B AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 13)
|
||||
#define AM_HAL_IOS_ACCESS_INT_1F AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 12)
|
||||
#define AM_HAL_IOS_ACCESS_INT_23 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 11)
|
||||
#define AM_HAL_IOS_ACCESS_INT_27 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 10)
|
||||
#define AM_HAL_IOS_ACCESS_INT_2B AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 9)
|
||||
#define AM_HAL_IOS_ACCESS_INT_2F AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 8)
|
||||
#define AM_HAL_IOS_ACCESS_INT_33 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 7)
|
||||
#define AM_HAL_IOS_ACCESS_INT_37 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 6)
|
||||
#define AM_HAL_IOS_ACCESS_INT_3B AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 5)
|
||||
#define AM_HAL_IOS_ACCESS_INT_3F AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 4)
|
||||
#define AM_HAL_IOS_ACCESS_INT_43 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 3)
|
||||
#define AM_HAL_IOS_ACCESS_INT_47 AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 2)
|
||||
#define AM_HAL_IOS_ACCESS_INT_4B AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 1)
|
||||
#define AM_HAL_IOS_ACCESS_INT_4F AM_REG_IOSLAVE_REGACCINTEN_REGACC((uint32_t)1 << 0)
|
||||
#define AM_HAL_IOS_ACCESS_INT_ALL 0xFFFFFFFF
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name I/O Slave Interrupts
|
||||
//! @brief Macro definitions for I/O slave (IOS) interrupts.
|
||||
//!
|
||||
//! These macros may be used with any of the
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOS_INT_FSIZE AM_REG_IOSLAVE_INTEN_FSIZE_M
|
||||
#define AM_HAL_IOS_INT_FOVFL AM_REG_IOSLAVE_INTEN_FOVFL_M
|
||||
#define AM_HAL_IOS_INT_FUNDFL AM_REG_IOSLAVE_INTEN_FUNDFL_M
|
||||
#define AM_HAL_IOS_INT_FRDERR AM_REG_IOSLAVE_INTEN_FRDERR_M
|
||||
#define AM_HAL_IOS_INT_GENAD AM_REG_IOSLAVE_INTEN_GENAD_M
|
||||
#define AM_HAL_IOS_INT_IOINTW AM_REG_IOSLAVE_INTEN_IOINTW_M
|
||||
#define AM_HAL_IOS_INT_ALL 0xFFFFFFFF
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name I/O Slave Interrupts triggers
|
||||
//! @brief Macro definitions for I/O slave (IOS) interrupts.
|
||||
//!
|
||||
//! These macros may be used with am_hal_ios_int_set and am_hal_ios_int_clear
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_IOS_IOINTCTL_INT0 (0x01)
|
||||
#define AM_HAL_IOS_IOINTCTL_INT1 (0x02)
|
||||
#define AM_HAL_IOS_IOINTCTL_INT2 (0x04)
|
||||
#define AM_HAL_IOS_IOINTCTL_INT3 (0x08)
|
||||
#define AM_HAL_IOS_IOINTCTL_INT4 (0x10)
|
||||
#define AM_HAL_IOS_IOINTCTL_INT5 (0x20)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External variable definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief LRAM pointer
|
||||
//!
|
||||
//! Pointer to the base of the IO Slave LRAM.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern volatile uint8_t * const am_hal_ios_pui8LRAM;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configuration structure for the IO slave module.
|
||||
//!
|
||||
//! This structure may be used along with the am_hal_ios_config() function to
|
||||
//! select key parameters of the IO Slave module. See the descriptions of each
|
||||
//! parameter within this structure for more information on what they control.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! Interface Selection
|
||||
//!
|
||||
//! This word selects the physical behavior of the IO Slave port. For SPI
|
||||
//! mode, this word should be the logical OR of one or more of the
|
||||
//! following:
|
||||
//!
|
||||
//! AM_HAL_IOS_USE_SPI
|
||||
//! AM_HAL_IOS_SPIMODE_0
|
||||
//! AM_HAL_IOS_SPIMODE_1
|
||||
//! AM_HAL_IOS_SPIMODE_2
|
||||
//! AM_HAL_IOS_SPIMODE_3
|
||||
//!
|
||||
//! For I2C mode, use the logical OR of one or more of these values instead
|
||||
//! (where n is the 7 or 10-bit I2C address to use):
|
||||
//!
|
||||
//! AM_HAL_IOS_USE_I2C
|
||||
//! AM_HAL_IOS_I2C_ADDRESS(n)
|
||||
//!
|
||||
//! Also, in any mode, you may OR in this value to reverse the order of
|
||||
//! incoming data bits.
|
||||
//!
|
||||
//! AM_HAL_IOS_LSB_FIRST
|
||||
//
|
||||
uint32_t ui32InterfaceSelect;
|
||||
|
||||
//
|
||||
//! Read-Only section
|
||||
//!
|
||||
//! The IO Slave LRAM is split into three main sections. The first section
|
||||
//! is a "Direct Write" section, which may be accessed for reads or write
|
||||
//! either directly through the Apollo CPU, or over the SPI/I2C bus. The
|
||||
//! "Direct Write" section always begins at LRAM offset 0x0. At the end of
|
||||
//! the normal "Direct Write" space, there is a "Read Only" space, which is
|
||||
//! read/write accessible to the Apollo CPU, but read-only over the I2C/SPI
|
||||
//! Bus. This word selects the base address of this "Read Only" space.
|
||||
//!
|
||||
//! This value may be set to any multiple of 8 between 0x0 and 0x78,
|
||||
//! inclusive. For the configuration to be valid, \e ui32ROBase must also
|
||||
//! be less than or equal to \e ui32FIFOBase
|
||||
//!
|
||||
//! @note The address given here is in units of BYTES. Since the location
|
||||
//! of the "Read Only" space may only be set in 8-byte increments, this
|
||||
//! value must be a multiple of 8.
|
||||
//!
|
||||
//! For the avoidance of doubt this means 0x80 is 128 bytes. These functions
|
||||
//! will shift right by 8 internally.
|
||||
//
|
||||
uint32_t ui32ROBase;
|
||||
|
||||
//
|
||||
//! FIFO section
|
||||
//!
|
||||
//! After the "Direct Access" and "Read Only" sections is a section of LRAM
|
||||
//! allocated to a FIFO. This section is accessible by the Apollo CPU
|
||||
//! through the FIFO control registers, and accessible on the SPI/I2C bus
|
||||
//! through the 0x7F address. This word selects the base address of the
|
||||
//! FIFO space. The FIFO will extend from the address specified here to the
|
||||
//! address specified in \e ui32RAMBase.
|
||||
//!
|
||||
//! This value may be set to any multiple of 8 between 0x0 and 0x78,
|
||||
//! inclusive. For the configuration to be valid, \e ui32FIFOBase must also
|
||||
//! be greater than or equal to \e ui32ROBase.
|
||||
//!
|
||||
//! @note The address given here is in units of BYTES. Since the location
|
||||
//! of the "FIFO" space may only be set in 8-byte increments, this value
|
||||
//! must be a multiple of 8.
|
||||
//!
|
||||
//! For the avoidance of doubt this means 0x80 is 128 bytes. These functions
|
||||
//! will shift right by 8 internally.
|
||||
//
|
||||
uint32_t ui32FIFOBase;
|
||||
|
||||
//
|
||||
//! RAM section
|
||||
//!
|
||||
//! At the end of the IOS LRAM, the user may allocate a "RAM" space that
|
||||
//! can only be accessed by the Apollo CPU. This space will not interact
|
||||
//! with the SPI/I2C bus at all, and may be used as general-purpose memory.
|
||||
//! Unlike normal SRAM, this section of LRAM will retain its state through
|
||||
//! Deep Sleep, so it may be used as a data retention space for
|
||||
//! ultra-low-power applications.
|
||||
//!
|
||||
//! This value may be set to any multiple of 8 between 0x0 and 0x100,
|
||||
//! inclusive. For the configuration to be valid, \e ui32RAMBase must also
|
||||
//! be greater than or equal to \e ui32FIFOBase.
|
||||
//!
|
||||
//! @note The address given here is in units of BYTES. Since the location
|
||||
//! of the "FIFO" space may only be set in 8-byte increments, this value
|
||||
//! must be a multiple of 8.
|
||||
//!
|
||||
//! For the avoidance of doubt this means 0x80 is 128 bytes. These functions
|
||||
//! will shift right by 8 internally.
|
||||
//
|
||||
uint32_t ui32RAMBase;
|
||||
|
||||
//
|
||||
//! FIFO threshold
|
||||
//!
|
||||
//! The IO Slave module will trigger an interrupt when the number of
|
||||
//! entries in the FIFO drops below this number of bytes.
|
||||
//
|
||||
uint32_t ui32FIFOThreshold;
|
||||
|
||||
//
|
||||
// Pointer to an SRAM
|
||||
//
|
||||
uint8_t *pui8SRAMBuffer;
|
||||
}
|
||||
am_hal_ios_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_ios_enable(uint32_t ui32Module);
|
||||
extern void am_hal_ios_disable(uint32_t ui32Module);
|
||||
|
||||
// these interrupts drive the HOST side IOS interrupt pins
|
||||
extern void am_hal_ios_host_int_set(uint32_t ui32Interrupt);
|
||||
extern void am_hal_ios_host_int_clear(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_ios_host_int_get(void);
|
||||
extern uint32_t am_hal_ios_host_int_enable_get(void);
|
||||
|
||||
extern void am_hal_ios_lram_write(uint32_t ui32Offset, uint8_t ui8Value);
|
||||
extern uint8_t am_hal_ios_lram_read(uint32_t ui32Offset);
|
||||
|
||||
// the following interrupts go back to the NVIC
|
||||
extern void am_hal_ios_config(am_hal_ios_config_t *psConfig);
|
||||
extern void am_hal_ios_access_int_enable(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_ios_access_int_enable_get(void);
|
||||
extern void am_hal_ios_access_int_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_ios_access_int_clear(uint32_t ui32Interrupt);
|
||||
extern void am_hal_ios_access_int_set(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_ios_access_int_status_get(bool bEnabledOnly);
|
||||
extern void am_hal_ios_int_enable(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_ios_int_enable_get(void);
|
||||
extern void am_hal_ios_int_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_ios_int_clear(uint32_t ui32Interrupt);
|
||||
extern void am_hal_ios_int_set(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_ios_int_status_get(bool bEnabledOnly);
|
||||
|
||||
extern void am_hal_ios_fifo_buffer_init(uint8_t *pui8Buffer, uint32_t ui32NumBytes);
|
||||
extern uint32_t am_hal_ios_fifo_space_left(void);
|
||||
extern uint32_t am_hal_ios_fifo_space_used(void);
|
||||
extern void am_hal_ios_fifo_service(uint32_t ui32Status);
|
||||
// Returns the number of bytes actually written
|
||||
extern uint32_t am_hal_ios_fifo_write(uint8_t *pui8Data, uint32_t ui32NumBytes);
|
||||
extern void am_hal_ios_fifo_write_simple(uint8_t *pui8Data,
|
||||
uint32_t ui32NumBytes);
|
||||
extern void am_hal_ios_fifo_ptr_set(uint32_t ui32Offset);
|
||||
extern void am_hal_ios_update_fifoctr(void);
|
||||
|
||||
extern void am_hal_ios_read_poll_complete(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_IOS_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,458 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_itm.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for operating the instrumentation trace macrocell
|
||||
//!
|
||||
//! @addtogroup itm1 Instrumentation Trace Macrocell (ITM)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enables the ITM
|
||||
//!
|
||||
//! This function enables the ARM ITM by setting the TRCENA bit in the DEMCR
|
||||
//! register.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_itm_enable(void)
|
||||
{
|
||||
if (g_ui32HALflags & AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_M)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// To be able to access ITM registers, set the Trace Enable bit
|
||||
// in the Debug Exception and Monitor Control Register (DEMCR).
|
||||
//
|
||||
AM_REG(SYSCTRL, DEMCR) |= AM_REG_SYSCTRL_DEMCR_TRCENA(1);
|
||||
while ( !(AM_REG(SYSCTRL, DEMCR) & AM_REG_SYSCTRL_DEMCR_TRCENA(1)) );
|
||||
|
||||
//
|
||||
// Write the key to the ITM Lock Access register to unlock the ITM_TCR.
|
||||
//
|
||||
AM_REGVAL(AM_REG_ITM_LOCKAREG_O) = AM_REG_ITM_LOCKAREG_KEYVAL;
|
||||
|
||||
//
|
||||
// Set the enable bits in the ITM trace enable register, and the ITM
|
||||
// control registers to enable trace data output.
|
||||
//
|
||||
AM_REGVAL(AM_REG_ITM_TPR_O) = 0x0000000f;
|
||||
AM_REGVAL(AM_REG_ITM_TER_O) = 0xffffffff;
|
||||
|
||||
//
|
||||
// Write to the ITM control and status register.
|
||||
//
|
||||
AM_REGVAL(AM_REG_ITM_TCR_O) =
|
||||
AM_WRITE_SM(AM_REG_ITM_TCR_ATB_ID, 0x15) |
|
||||
AM_WRITE_SM(AM_REG_ITM_TCR_TS_FREQ, 1) |
|
||||
AM_WRITE_SM(AM_REG_ITM_TCR_TS_PRESCALE, 1) |
|
||||
AM_WRITE_SM(AM_REG_ITM_TCR_SWV_ENABLE, 1) |
|
||||
AM_WRITE_SM(AM_REG_ITM_TCR_DWT_ENABLE, 0) |
|
||||
AM_WRITE_SM(AM_REG_ITM_TCR_SYNC_ENABLE, 0) |
|
||||
AM_WRITE_SM(AM_REG_ITM_TCR_TS_ENABLE, 0) |
|
||||
AM_WRITE_SM(AM_REG_ITM_TCR_ITM_ENABLE, 1);
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disables the ITM
|
||||
//!
|
||||
//! This function completely disables the ARM ITM by resetting the TRCENA bit
|
||||
//! in the DEMCR register.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_itm_disable(void)
|
||||
{
|
||||
|
||||
if (g_ui32HALflags & AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_M)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure the ITM_TCR is unlocked.
|
||||
//
|
||||
AM_REGVAL(AM_REG_ITM_LOCKAREG_O) = AM_REG_ITM_LOCKAREG_KEYVAL;
|
||||
|
||||
//
|
||||
// Make sure the ITM/TPIU is not busy.
|
||||
//
|
||||
while ( AM_REG(ITM, TCR) & AM_REG_ITM_TCR_BUSY(1) );
|
||||
|
||||
//
|
||||
// Disable the ITM.
|
||||
//
|
||||
for (int ix = 0; ix < 100; ix++)
|
||||
{
|
||||
AM_REG(ITM, TCR) &= ~AM_REG_ITM_TCR_ITM_ENABLE(1);
|
||||
while ( AM_REG(ITM, TCR) & (AM_REG_ITM_TCR_ITM_ENABLE(1) | AM_REG_ITM_TCR_BUSY(1)) );
|
||||
}
|
||||
|
||||
//
|
||||
// Reset the TRCENA bit in the DEMCR register, which should disable the ITM
|
||||
// for operation.
|
||||
//
|
||||
AM_REG(SYSCTRL, DEMCR) &= ~AM_REG_SYSCTRL_DEMCR_TRCENA(1);
|
||||
|
||||
//
|
||||
// Disable the TPIU clock source in MCU control.
|
||||
//
|
||||
AM_REG(MCUCTRL, TPIUCTRL) = AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_0MHz |
|
||||
AM_REG_MCUCTRL_TPIUCTRL_ENABLE_DIS;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Checks if itm is busy and provides a delay to fluch the fifo
|
||||
//!
|
||||
//! This function disables the ARM ITM by resetting the TRCENA bit in the DEMCR
|
||||
//! register.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_itm_not_busy(void)
|
||||
{
|
||||
//
|
||||
// Make sure the ITM/TPIU is not busy.
|
||||
//
|
||||
while (AM_REG(ITM, TCR) & AM_REG_ITM_TCR_BUSY(1));
|
||||
|
||||
// wait for 50us for the data to flush out
|
||||
am_hal_flash_delay(FLASH_CYCLES_US(50));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enables tracing on a given set of ITM ports
|
||||
//!
|
||||
//! @param ui8portNum - Set ports to be enabled
|
||||
//!
|
||||
//! Enables tracing on the ports referred to by \e ui8portNum by writing the
|
||||
//! associated bit in the Trace Privilege Register in the ITM. The value for
|
||||
//! ui8portNum should be the logical OR one or more of the following values:
|
||||
//!
|
||||
//! \e ITM_PRIVMASK_0_7 - enable ports 0 through 7
|
||||
//! \e ITM_PRIVMASK_8_15 - enable ports 8 through 15
|
||||
//! \e ITM_PRIVMASK_16_23 - enable ports 16 through 23
|
||||
//! \e ITM_PRIVMASK_24_31 - enable ports 24 through 31
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_itm_trace_port_enable(uint8_t ui8portNum)
|
||||
{
|
||||
AM_REGVAL(AM_REG_ITM_TPR_O) |= (0x00000001 << (ui8portNum>>3));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable tracing on the given ITM stimulus port.
|
||||
//!
|
||||
//! @param ui8portNum
|
||||
//!
|
||||
//! Disables tracing on the ports referred to by \e ui8portNum by writing the
|
||||
//! associated bit in the Trace Privilege Register in the ITM. The value for
|
||||
//! ui8portNum should be the logical OR one or more of the following values:
|
||||
//!
|
||||
//! \e ITM_PRIVMASK_0_7 - disable ports 0 through 7
|
||||
//! \e ITM_PRIVMASK_8_15 - disable ports 8 through 15
|
||||
//! \e ITM_PRIVMASK_16_23 - disable ports 16 through 23
|
||||
//! \e ITM_PRIVMASK_24_31 - disable ports 24 through 31
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_itm_trace_port_disable(uint8_t ui8portNum)
|
||||
{
|
||||
AM_REGVAL(AM_REG_ITM_TPR_O) &= ~(0x00000001 << (ui8portNum >> 3));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Poll the given ITM stimulus register until not busy.
|
||||
//!
|
||||
//! @param ui32StimReg - stimulus register
|
||||
//!
|
||||
//! @return true if not busy, false if busy (timed out or other error).
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
am_hal_itm_stimulus_not_busy(uint32_t ui32StimReg)
|
||||
{
|
||||
uint32_t ui32StimAddr = (AM_REG_ITM_STIM0_O + (4 * ui32StimReg));
|
||||
|
||||
//
|
||||
// Busy waiting until it is available, non-zero means ready.
|
||||
//
|
||||
while (!AM_REGVAL(ui32StimAddr));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Writes a 32-bit value to the given ITM stimulus register.
|
||||
//!
|
||||
//! @param ui32StimReg - stimulus register
|
||||
//! @param ui32Value - value to be written.
|
||||
//!
|
||||
//! Write a word to the desired stimulus register.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_itm_stimulus_reg_word_write(uint32_t ui32StimReg, uint32_t ui32Value)
|
||||
{
|
||||
uint32_t ui32StimAddr;
|
||||
|
||||
ui32StimAddr = (AM_REG_ITM_STIM0_O + (4 * ui32StimReg));
|
||||
|
||||
//
|
||||
// Busy waiting until it is available, non-zero means ready
|
||||
//
|
||||
while (!AM_REGVAL(ui32StimAddr));
|
||||
|
||||
//
|
||||
// Write the register.
|
||||
//
|
||||
AM_REGVAL(ui32StimAddr) = ui32Value;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Writes a short to the given ITM stimulus register.
|
||||
//!
|
||||
//! @param ui32StimReg - stimulus register
|
||||
//! @param ui16Value - short to be written.
|
||||
//!
|
||||
//! Write a short to the desired stimulus register.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_itm_stimulus_reg_short_write(uint32_t ui32StimReg, uint16_t ui16Value)
|
||||
{
|
||||
uint32_t ui32StimAddr;
|
||||
|
||||
ui32StimAddr = (AM_REG_ITM_STIM0_O + (4 * ui32StimReg));
|
||||
|
||||
//
|
||||
// Busy waiting until it is available non-zero means ready
|
||||
//
|
||||
while (!AM_REGVAL(ui32StimAddr));
|
||||
|
||||
//
|
||||
// Write the register.
|
||||
//
|
||||
*((volatile uint16_t *) ui32StimAddr) = ui16Value;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Writes a byte to the given ITM stimulus register.
|
||||
//!
|
||||
//! @param ui32StimReg - stimulus register
|
||||
//! @param ui8Value - byte to be written.
|
||||
//!
|
||||
//! Write a byte to the desired stimulus register.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_itm_stimulus_reg_byte_write(uint32_t ui32StimReg, uint8_t ui8Value)
|
||||
{
|
||||
uint32_t ui32StimAddr;
|
||||
|
||||
ui32StimAddr = (AM_REG_ITM_STIM0_O + (4 * ui32StimReg));
|
||||
|
||||
//
|
||||
// Busy waiting until it is available (non-zero means ready)
|
||||
//
|
||||
while (!AM_REGVAL(ui32StimAddr));
|
||||
|
||||
//
|
||||
// Write the register.
|
||||
//
|
||||
*((volatile uint8_t *) ui32StimAddr) = ui8Value;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Sends a Sync Packet.
|
||||
//!
|
||||
//! Sends a sync packet. This can be useful for external software should it
|
||||
//! become out of sync with the ITM stream.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_itm_sync_send(void)
|
||||
{
|
||||
//
|
||||
// Write the register.
|
||||
//
|
||||
am_hal_itm_stimulus_reg_word_write(AM_HAL_ITM_SYNC_REG,
|
||||
AM_HAL_ITM_SYNC_VAL);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Poll the print stimulus registers until not busy.
|
||||
//!
|
||||
//! @return true if not busy, false if busy (timed out or other error).
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
am_hal_itm_print_not_busy(void)
|
||||
{
|
||||
//
|
||||
// Poll stimulus register allocated for printing.
|
||||
//
|
||||
am_hal_itm_stimulus_not_busy(0);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Prints a char string out of the ITM.
|
||||
//!
|
||||
//! @param pcString pointer to the character sting
|
||||
//!
|
||||
//! This function prints a sting out of the ITM.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_itm_print(char *pcString)
|
||||
{
|
||||
uint32_t ui32Message = 0;
|
||||
uint32_t ui32Length = 0;
|
||||
uint32_t ui32Idx;
|
||||
|
||||
//
|
||||
// Determine the length of the string.
|
||||
//
|
||||
while (*(pcString + ui32Length))
|
||||
{
|
||||
ui32Length++;
|
||||
}
|
||||
|
||||
//
|
||||
// If there is no longer a word left, empty out the remaining characters.
|
||||
//
|
||||
while (ui32Length)
|
||||
{
|
||||
if (AM_HAL_ITM_PRINT_NUM_BYTES == 4 && ui32Length >= 4)
|
||||
{
|
||||
for (ui32Idx = 4; ui32Idx < 8; ui32Idx++)
|
||||
{
|
||||
ui32Message |= *pcString++ << ((ui32Idx - 4) << 3);
|
||||
|
||||
//
|
||||
// Subtract from length.
|
||||
//
|
||||
ui32Length--;
|
||||
}
|
||||
|
||||
//
|
||||
// Print string out the ITM.
|
||||
//
|
||||
am_hal_itm_stimulus_reg_word_write(0, ui32Message);
|
||||
|
||||
//
|
||||
// Clear Message.
|
||||
//
|
||||
ui32Message = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Print string out the ITM.
|
||||
//
|
||||
am_hal_itm_stimulus_reg_byte_write(0, (uint8_t)*pcString++);
|
||||
|
||||
//
|
||||
// Subtract from length.
|
||||
//
|
||||
ui32Length--;
|
||||
}
|
||||
}
|
||||
}
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,110 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_itm.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the ARM ITM.
|
||||
//!
|
||||
//! @addtogroup itm1 Instrumentation Trace Macrocell (ITM)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef AM_HAL_ITM_H
|
||||
#define AM_HAL_ITM_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Sync Packet Defines
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ITM_SYNC_REG 23
|
||||
#define AM_HAL_ITM_SYNC_VAL 0xF8F8F8F8
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PrintF Setup
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ITM_PRINT_NUM_BYTES 1
|
||||
#define AM_HAL_ITM_PRINT_NUM_REGS 1
|
||||
|
||||
extern uint32_t am_hal_itm_print_registers[AM_HAL_ITM_PRINT_NUM_REGS];
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_itm_enable(void);
|
||||
extern void am_hal_itm_disable(void);
|
||||
extern void am_hal_itm_not_busy(void);
|
||||
extern void am_hal_itm_sync_send(void);
|
||||
extern void am_hal_itm_trace_port_enable(uint8_t ui8portNum);
|
||||
extern void am_hal_itm_trace_port_disable(uint8_t ui8portNum);
|
||||
extern bool am_hal_itm_stimulus_not_busy(uint32_t ui32StimReg);
|
||||
extern void am_hal_itm_stimulus_reg_word_write(uint32_t ui32StimReg,
|
||||
uint32_t ui32Value);
|
||||
extern void am_hal_itm_stimulus_reg_short_write(uint32_t ui32StimReg,
|
||||
uint16_t ui16Value);
|
||||
extern void am_hal_itm_stimulus_reg_byte_write(uint32_t ui32StimReg,
|
||||
uint8_t ui8Value);
|
||||
extern bool am_hal_itm_print_not_busy(void);
|
||||
extern void am_hal_itm_print(char *pcString);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_ITM_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,431 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_mcuctrl.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the MCUCTRL.
|
||||
//!
|
||||
//! @addtogroup mcuctrl1 MCU Control (MCUCTRL)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Global Variables.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const uint32_t am_hal_mcuctrl_flash_size[] =
|
||||
{
|
||||
1 << 15, /* 0x0 0x008000 32k */
|
||||
1 << 16, /* 0x1 0x010000 64k */
|
||||
1 << 17, /* 0x2 0x020000 128k */
|
||||
1 << 18, /* 0x3 0x040000 256k */
|
||||
1 << 19, /* 0x4 0x080000 512k */
|
||||
1 << 20, /* 0x5 0x100000 1024k */
|
||||
1 << 21, /* 0x6 0x200000 2048k */
|
||||
0, /* 0x7 Invalid */
|
||||
0, /* 0x8 Invalid */
|
||||
0, /* 0x9 Invalid */
|
||||
0, /* 0xA Invalid */
|
||||
0, /* 0xB Invalid */
|
||||
0, /* 0xC Invalid */
|
||||
0, /* 0xD Invalid */
|
||||
0, /* 0xE Invalid */
|
||||
1 << 14 /* 0xF 0x004000 16k */
|
||||
};
|
||||
|
||||
const uint32_t am_hal_mcuctrl_sram_size[] =
|
||||
{
|
||||
1 << 15, /* 0x0 0x008000 32k */
|
||||
1 << 16, /* 0x1 0x010000 64k */
|
||||
1 << 17, /* 0x2 0x020000 128k */
|
||||
1 << 18, /* 0x3 0x040000 256k */
|
||||
1 << 19, /* 0x4 0x080000 512k */
|
||||
1 << 20, /* 0x5 0x100000 1024k */
|
||||
1 << 21, /* 0x6 0x200000 2048k */
|
||||
0, /* 0x7 Invalid */
|
||||
0, /* 0x8 Invalid */
|
||||
0, /* 0x9 Invalid */
|
||||
0, /* 0xA Invalid */
|
||||
0, /* 0xB Invalid */
|
||||
0, /* 0xC Invalid */
|
||||
0, /* 0xD Invalid */
|
||||
0, /* 0xE Invalid */
|
||||
1 << 14 /* 0xF 0x004000 16k */
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Gets all relevant device information.
|
||||
//!
|
||||
//! @param psDevice is a pointer to a structure that will be used to store all
|
||||
//! device info.
|
||||
//!
|
||||
//! This function gets the device part number, chip IDs, and revision and
|
||||
//! stores them in the passed structure.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_mcuctrl_device_info_get(am_hal_mcuctrl_device_t *psDevice)
|
||||
{
|
||||
//
|
||||
// Read the Part Number.
|
||||
//
|
||||
psDevice->ui32ChipPN = AM_REG(MCUCTRL, CHIP_INFO);
|
||||
|
||||
//
|
||||
// Read the Chip ID0.
|
||||
//
|
||||
psDevice->ui32ChipID0 = AM_REG(MCUCTRL, CHIPID0);
|
||||
|
||||
//
|
||||
// Read the Chip ID1.
|
||||
//
|
||||
psDevice->ui32ChipID1 = AM_REG(MCUCTRL, CHIPID1);
|
||||
|
||||
//
|
||||
// Read the Chip Revision.
|
||||
//
|
||||
psDevice->ui32ChipRev = AM_REG(MCUCTRL, CHIPREV);
|
||||
|
||||
//
|
||||
// Qualified from Part Number.
|
||||
//
|
||||
psDevice->ui32Qualified = AM_BFR(MCUCTRL, CHIP_INFO, QUAL);
|
||||
|
||||
//
|
||||
// Flash size from Part Number.
|
||||
//
|
||||
psDevice->ui32FlashSize =
|
||||
am_hal_mcuctrl_flash_size[AM_BFR(MCUCTRL, CHIP_INFO, FLASH)];
|
||||
|
||||
//
|
||||
// SRAM size from Part Number.
|
||||
//
|
||||
psDevice->ui32SRAMSize =
|
||||
am_hal_mcuctrl_sram_size[AM_BFR(MCUCTRL, CHIP_INFO, RAM)];
|
||||
|
||||
//
|
||||
// Now, let's look at the JEDEC info.
|
||||
// The full partnumber is 12 bits total, but is scattered across 2 registers.
|
||||
// Bits [11:8] are 0xE.
|
||||
// Bits [7:4] are 0xE for Apollo, 0xD for Apollo2.
|
||||
// Bits [3:0] are defined differently for Apollo and Apollo2.
|
||||
// For Apollo, the low nibble is 0x0.
|
||||
// For Apollo2, the low nibble indicates flash and SRAM size.
|
||||
//
|
||||
psDevice->ui32JedecPN = (AM_BFR(JEDEC, PID0, PNL8) << 0);
|
||||
psDevice->ui32JedecPN |= (AM_BFR(JEDEC, PID1, PNH4) << 8);
|
||||
|
||||
//
|
||||
// JEPID is the JEP-106 Manufacturer ID Code, which is assigned to Ambiq as
|
||||
// 0x1B, with parity bit is 0x9B. It is 8 bits located across 2 registers.
|
||||
//
|
||||
psDevice->ui32JedecJEPID = (AM_BFR(JEDEC, PID1, JEPIDL) << 0);
|
||||
psDevice->ui32JedecJEPID |= (AM_BFR(JEDEC, PID2, JEPIDH) << 4);
|
||||
|
||||
//
|
||||
// CHIPREV is 8 bits located across 2 registers.
|
||||
//
|
||||
psDevice->ui32JedecCHIPREV = (AM_BFR(JEDEC, PID2, CHIPREVH4) << 4);
|
||||
psDevice->ui32JedecCHIPREV |= (AM_BFR(JEDEC, PID3, CHIPREVL4) << 0);
|
||||
|
||||
//
|
||||
// Let's get the Coresight ID (32-bits across 4 registers)
|
||||
// For Apollo and Apollo2, it's expected to be 0xB105100D.
|
||||
//
|
||||
psDevice->ui32JedecCID = (AM_BFR(JEDEC, CID3, CID) << 24);
|
||||
psDevice->ui32JedecCID |= (AM_BFR(JEDEC, CID2, CID) << 16);
|
||||
psDevice->ui32JedecCID |= (AM_BFR(JEDEC, CID1, CID) << 8);
|
||||
psDevice->ui32JedecCID |= (AM_BFR(JEDEC, CID0, CID) << 0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enables the fault capture registers.
|
||||
//!
|
||||
//! This function enables the DCODEFAULTADDR and ICODEFAULTADDR registers.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_mcuctrl_fault_capture_enable(void)
|
||||
{
|
||||
//
|
||||
// Enable the Fault Capture registers.
|
||||
//
|
||||
AM_BFW(MCUCTRL, FAULTCAPTUREEN, ENABLE, 1);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disables the fault capture registers.
|
||||
//!
|
||||
//! This function disables the DCODEFAULTADDR and ICODEFAULTADDR registers.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_mcuctrl_fault_capture_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the Fault Capture registers.
|
||||
//
|
||||
AM_BFW(MCUCTRL, FAULTCAPTUREEN, ENABLE, 0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Gets the fault status and capture registers.
|
||||
//!
|
||||
//! @param psFault is a pointer to a structure that will be used to store all
|
||||
//! fault info.
|
||||
//!
|
||||
//! This function gets the status of the ICODE, DCODE, and SYS bus faults and
|
||||
//! the addresses associated with the fault.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_mcuctrl_fault_status(am_hal_mcuctrl_fault_t *psFault)
|
||||
{
|
||||
uint32_t ui32FaultStat;
|
||||
|
||||
//
|
||||
// Read the Fault Status Register.
|
||||
//
|
||||
ui32FaultStat = AM_REG(MCUCTRL, FAULTSTATUS);
|
||||
psFault->bICODE = (ui32FaultStat & AM_REG_MCUCTRL_FAULTSTATUS_ICODE_M);
|
||||
psFault->bDCODE = (ui32FaultStat & AM_REG_MCUCTRL_FAULTSTATUS_DCODE_M);
|
||||
psFault->bSYS = (ui32FaultStat & AM_REG_MCUCTRL_FAULTSTATUS_SYS_M);
|
||||
|
||||
//
|
||||
// Read the DCODE fault capture address register.
|
||||
//
|
||||
psFault->ui32DCODE = AM_REG(MCUCTRL, DCODEFAULTADDR);
|
||||
|
||||
//
|
||||
// Read the ICODE fault capture address register.
|
||||
//
|
||||
psFault->ui32ICODE |= AM_REG(MCUCTRL, ICODEFAULTADDR);
|
||||
|
||||
//
|
||||
// Read the ICODE fault capture address register.
|
||||
//
|
||||
psFault->ui32SYS |= AM_REG(MCUCTRL, SYSFAULTADDR);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set power state of the flash.
|
||||
//!
|
||||
//! @param ui32FlashPower is the desired flash power configuration.
|
||||
//!
|
||||
//! This function sets the device power state for the flash banks.
|
||||
//!
|
||||
//! Valid values for ui32FlashPower are:
|
||||
//!
|
||||
//! AM_HAL_MCUCTRL_FLASH_POWER_DOWN_NONE
|
||||
//! AM_HAL_MCUCTRL_FLASH_POWER_DOWN_0
|
||||
//! AM_HAL_MCUCTRL_FLASH_POWER_DOWN_1
|
||||
//! AM_HAL_MCUCTRL_FLASH_POWER_DOWN_ALL
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_mcuctrl_flash_power_set(uint32_t ui32FlashPower)
|
||||
{
|
||||
//
|
||||
// Write desired flash power state.
|
||||
//
|
||||
AM_REG(MCUCTRL, FLASHPWRDIS) = ui32FlashPower;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set power state of the SRAM.
|
||||
//!
|
||||
//! @param ui32SRAMPower is the desired SRAM power configuration.
|
||||
//! @param ui32SRAMPowerDeepSleep is the desired SRAM power configuration in
|
||||
//! deep sleep.
|
||||
//!
|
||||
//! This function sets the device power state for the SRAM banks.
|
||||
//!
|
||||
//! Valid values for ui32SRAMPower and ui32SRAMPowerDeepSleep are:
|
||||
//!
|
||||
//! AM_HAL_MCUCTRL_SRAM_POWER_DOWN_NONE
|
||||
//! AM_HAL_MCUCTRL_SRAM_POWER_DOWN_1
|
||||
//! AM_HAL_MCUCTRL_SRAM_POWER_DOWN_2
|
||||
//! AM_HAL_MCUCTRL_SRAM_POWER_DOWN_3
|
||||
//! AM_HAL_MCUCTRL_SRAM_POWER_DOWN_4
|
||||
//! AM_HAL_MCUCTRL_SRAM_POWER_DOWN_5
|
||||
//! AM_HAL_MCUCTRL_SRAM_POWER_DOWN_6
|
||||
//! AM_HAL_MCUCTRL_SRAM_POWER_DOWN_7
|
||||
//! AM_HAL_MCUCTRL_SRAM_POWER_DOWN_ALL
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_mcuctrl_sram_power_set(uint32_t ui32SRAMPower,
|
||||
uint32_t ui32SRAMPowerDeepSleep)
|
||||
{
|
||||
//
|
||||
// Write desired SRAM power state.
|
||||
//
|
||||
AM_REG(MCUCTRL, SRAMPWRDIS) = ui32SRAMPower;
|
||||
|
||||
//
|
||||
// Write desired SRAM deep sleep power state.
|
||||
//
|
||||
AM_REG(MCUCTRL, SRAMPWDINSLEEP) = ui32SRAMPowerDeepSleep;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the Bandgap.
|
||||
//!
|
||||
//! This function enables the Bandgap.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_mcuctrl_bandgap_enable(void)
|
||||
{
|
||||
//
|
||||
// Enable the Bandgap in the MCUCTRL.
|
||||
//
|
||||
AM_REG(MCUCTRL, BANDGAPEN) = AM_REG_MCUCTRL_BANDGAPEN_BGPEN_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the Bandgap.
|
||||
//!
|
||||
//! This function disables the Bandgap.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_mcuctrl_bandgap_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the Bandgap in the MCUCTRL.
|
||||
//
|
||||
AM_REG(MCUCTRL, BANDGAPEN) = ~AM_REG_MCUCTRL_BANDGAPEN_BGPEN_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the core and memory buck converters.
|
||||
//!
|
||||
//! This function enables the core and memory buck converters.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_mcuctrl_bucks_enable(void)
|
||||
{
|
||||
//
|
||||
// Enable the core buck converter in the MCUCTRL.
|
||||
//
|
||||
AM_BFW(MCUCTRL, SUPPLYSRC, COREBUCKEN, 1);
|
||||
|
||||
//
|
||||
// Enable the SRAM buck converter in the MCUCTRL.
|
||||
//
|
||||
AM_BFW(MCUCTRL, SUPPLYSRC, MEMBUCKEN, 1);
|
||||
|
||||
//
|
||||
// Poll until core buck is enabled.
|
||||
//
|
||||
while( !AM_BFR(MCUCTRL, SUPPLYSTATUS, COREBUCKON) );
|
||||
|
||||
//
|
||||
// Poll until SRAM buck is enabled.
|
||||
//
|
||||
while( !AM_BFR(MCUCTRL, SUPPLYSTATUS, MEMBUCKON) );
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the core and memory buck converters.
|
||||
//!
|
||||
//! This function disables the core and memory buck converters.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_mcuctrl_bucks_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the core buck converter in the MCUCTRL.
|
||||
//
|
||||
AM_BFW(MCUCTRL, SUPPLYSRC, COREBUCKEN, 0);
|
||||
|
||||
//
|
||||
// Disable the SRAM buck converter in the MCUCTRL.
|
||||
//
|
||||
AM_BFW(MCUCTRL, SUPPLYSRC, MEMBUCKEN, 0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,219 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_mcuctrl.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the MCUCTRL.
|
||||
//!
|
||||
//! @addtogroup mcuctrl1 MCU Control (MCUCTRL)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_MCUCTRL_H
|
||||
#define AM_HAL_MCUCTRL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Apollo Number Decode.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern const uint32_t am_hal_mcuctrl_flash_size[];
|
||||
extern const uint32_t am_hal_mcuctrl_sram_size[];
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// FLASH Bank Power defines.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_MCUCTRL_FLASH_POWER_DOWN_NONE 0x0
|
||||
#define AM_HAL_MCUCTRL_FLASH_POWER_DOWN_0 0x1
|
||||
#define AM_HAL_MCUCTRL_FLASH_POWER_DOWN_1 0x2
|
||||
#define AM_HAL_MCUCTRL_FLASH_POWER_DOWN_ALL 0x3
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SRAM Bank Power defines.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_MCUCTRL_SRAM_POWER_DOWN_NONE 0x0
|
||||
#define AM_HAL_MCUCTRL_SRAM_POWER_DOWN_0 0x1
|
||||
#define AM_HAL_MCUCTRL_SRAM_POWER_DOWN_1 0x2
|
||||
#define AM_HAL_MCUCTRL_SRAM_POWER_DOWN_2 0x4
|
||||
#define AM_HAL_MCUCTRL_SRAM_POWER_DOWN_3 0x8
|
||||
#define AM_HAL_MCUCTRL_SRAM_POWER_DOWN_4 0x10
|
||||
#define AM_HAL_MCUCTRL_SRAM_POWER_DOWN_5 0x20
|
||||
#define AM_HAL_MCUCTRL_SRAM_POWER_DOWN_6 0x40
|
||||
#define AM_HAL_MCUCTRL_SRAM_POWER_DOWN_7 0x80
|
||||
#define AM_HAL_MCUCTRL_SRAM_POWER_DOWN_ALL 0xFF
|
||||
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! MCUCTRL device structure
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! Device part number. (BCD format)
|
||||
//
|
||||
uint32_t ui32ChipPN;
|
||||
|
||||
//
|
||||
//! Unique Chip ID 0.
|
||||
//
|
||||
uint32_t ui32ChipID0;
|
||||
|
||||
//
|
||||
//! Unique Chip ID 1.
|
||||
//
|
||||
uint32_t ui32ChipID1;
|
||||
|
||||
//
|
||||
//! Chip Revision.
|
||||
//
|
||||
uint32_t ui32ChipRev;
|
||||
|
||||
//
|
||||
//! Vendor ID.
|
||||
//
|
||||
uint32_t ui32VendorID;
|
||||
|
||||
//
|
||||
//! Qualified chip.
|
||||
//
|
||||
uint32_t ui32Qualified;
|
||||
|
||||
//
|
||||
//! Flash Size.
|
||||
//
|
||||
uint32_t ui32FlashSize;
|
||||
|
||||
//
|
||||
//! SRAM Size.
|
||||
//
|
||||
uint32_t ui32SRAMSize;
|
||||
|
||||
//
|
||||
// JEDEC chip info
|
||||
//
|
||||
uint32_t ui32JedecPN;
|
||||
uint32_t ui32JedecJEPID;
|
||||
uint32_t ui32JedecCHIPREV;
|
||||
uint32_t ui32JedecCID;
|
||||
}
|
||||
am_hal_mcuctrl_device_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! MCUCTRL fault structure
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! ICODE bus fault occurred.
|
||||
//
|
||||
bool bICODE;
|
||||
|
||||
//
|
||||
//! ICODE bus fault address.
|
||||
//
|
||||
uint32_t ui32ICODE;
|
||||
|
||||
//
|
||||
//! DCODE bus fault occurred.
|
||||
//
|
||||
bool bDCODE;
|
||||
|
||||
//
|
||||
//! DCODE bus fault address.
|
||||
//
|
||||
uint32_t ui32DCODE;
|
||||
|
||||
//
|
||||
//! SYS bus fault occurred.
|
||||
//
|
||||
bool bSYS;
|
||||
|
||||
//
|
||||
//! SYS bus fault address.
|
||||
//
|
||||
uint32_t ui32SYS;
|
||||
}
|
||||
am_hal_mcuctrl_fault_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_mcuctrl_device_info_get(am_hal_mcuctrl_device_t *psDevice);
|
||||
extern void am_hal_mcuctrl_fault_capture_enable(void);
|
||||
extern void am_hal_mcuctrl_fault_capture_disable(void);
|
||||
extern void am_hal_mcuctrl_fault_status(am_hal_mcuctrl_fault_t *psFault);
|
||||
extern void am_hal_mcuctrl_flash_power_set(uint32_t ui32FlashPower);
|
||||
extern void am_hal_mcuctrl_sram_power_set(uint32_t ui32SRAMPower,
|
||||
uint32_t ui32SRAMPowerDeepSleep);
|
||||
extern void am_hal_mcuctrl_bandgap_enable(void);
|
||||
extern void am_hal_mcuctrl_bandgap_disable(void);
|
||||
extern void am_hal_mcuctrl_bucks_enable(void);
|
||||
extern void am_hal_mcuctrl_bucks_disable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_MCUCTRL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,349 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_otp.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for handling the OTP interface.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#include "am_mcu_apollo.h"
|
||||
#include "am_hal_flash.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Check if debugger is currently locked out.
|
||||
//!
|
||||
//! @param None.
|
||||
//!
|
||||
//! Determine if the debugger is already locked out.
|
||||
//!
|
||||
//! @return non-zero if debugger is currently locked out.
|
||||
//! Specifically:
|
||||
//! 0 = debugger is not locked out.
|
||||
//! 1 = debugger is locked out.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
am_hal_otp_is_debugger_lockedout(void)
|
||||
{
|
||||
uint32_t u32Val, uBF;
|
||||
|
||||
//
|
||||
// Get current value of the debugger port word
|
||||
//
|
||||
u32Val = am_hal_flash_load_ui32(AM_HAL_OTP_DBGRPROT_ADDR);
|
||||
|
||||
//
|
||||
// Check if already locked out.
|
||||
//
|
||||
uBF = AM_READ_SM(AM_OTP_DBGR_LOCKOUT, u32Val);
|
||||
switch ( uBF )
|
||||
{
|
||||
case 0xF:
|
||||
return 0;
|
||||
case 0xA:
|
||||
return 1;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Lock out debugger access.
|
||||
//!
|
||||
//! @param None.
|
||||
//!
|
||||
//! This function locks out access by a debugger.
|
||||
//!
|
||||
//! @return 0 if lockout was successful or if lockout was already enabled.
|
||||
//! Low byte=0xff, byte 1 contains current value of lockout.
|
||||
//! Else, return value from HAL programming function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
am_hal_otp_debugger_lockout(void)
|
||||
{
|
||||
uint32_t u32Val;
|
||||
int iRet;
|
||||
|
||||
iRet = am_hal_otp_is_debugger_lockedout();
|
||||
if ( iRet == 1 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if ( iRet != 0 )
|
||||
{
|
||||
//
|
||||
// Uh-oh, something's weird.
|
||||
// We're locked out but not in the expected way.
|
||||
// Return as an error with the current (non-0xF) value encoded in
|
||||
// byte 1.
|
||||
//
|
||||
return (iRet << 8) | 0xff;
|
||||
}
|
||||
|
||||
u32Val = am_hal_flash_load_ui32(AM_HAL_OTP_DBGRPROT_ADDR);
|
||||
|
||||
//
|
||||
// Modify the appropriate bitfield for debugger lockout.
|
||||
//
|
||||
u32Val &= ~AM_OTP_DBGR_LOCKOUT_M;
|
||||
u32Val |= AM_WRITE_SM(AM_OTP_DBGR_LOCKOUT, 0xA);
|
||||
iRet = am_hal_flash_program_otp(AM_HAL_FLASH_OTP_KEY,
|
||||
0,
|
||||
&u32Val,
|
||||
AM_HAL_OTP_DBGR_O / 4,
|
||||
1);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Lock out SRAM access.
|
||||
//!
|
||||
//! @param None.
|
||||
//!
|
||||
//! This function locks out access by a debugger to SRAM.
|
||||
//!
|
||||
//! @return 0 if lockout was successful or if lockout was already enabled.
|
||||
//! Low byte=0xff, byte 1 contains current value of lockout.
|
||||
//! Else, return value from HAL programming function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
am_hal_otp_sram_lockout(void)
|
||||
{
|
||||
uint32_t u32Val;
|
||||
int iRet;
|
||||
|
||||
//
|
||||
// Get current value of the debugger port word
|
||||
//
|
||||
u32Val = am_hal_flash_load_ui32(AM_HAL_OTP_DBGRPROT_ADDR);
|
||||
|
||||
//
|
||||
// Check if SRAM already locked out.
|
||||
//
|
||||
if ( AM_READ_SM(AM_OTP_SRAM_LOCKOUT, u32Val) == 0xA )
|
||||
{
|
||||
//
|
||||
// Already done, return with no error.
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Check for invalid value (which is effectively already locked out).
|
||||
//
|
||||
if ( AM_READ_SM(AM_OTP_SRAM_LOCKOUT, u32Val) != 0xF )
|
||||
{
|
||||
//
|
||||
// Uh-oh, something's wrong.
|
||||
// Return as an error with the current (non-0xF) value encoded in
|
||||
// byte 1.
|
||||
//
|
||||
return (AM_READ_SM(AM_OTP_SRAM_LOCKOUT, u32Val) << 8) | 0xff;
|
||||
}
|
||||
|
||||
//
|
||||
// Modify the appropriate bitfield for SRAM access lockout.
|
||||
//
|
||||
u32Val &= ~AM_OTP_SRAM_LOCKOUT_M;
|
||||
u32Val |= AM_WRITE_SM(AM_OTP_SRAM_LOCKOUT, 0xA);
|
||||
iRet = am_hal_flash_program_otp(AM_HAL_FLASH_OTP_KEY,
|
||||
0,
|
||||
&u32Val,
|
||||
AM_HAL_OTP_DBGR_O / 4,
|
||||
1);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set copy (read) protection.
|
||||
//!
|
||||
//! @param @u32BegAddr The beginning address to be copy protected.
|
||||
//! @u32EndAddr The ending address to be copy protected.
|
||||
//!
|
||||
//! @note For Apollo, the u32BegAddr parameter should be on a 16KB boundary, and
|
||||
//! the u32EndAddr parameter should be on a (16KB-1) boundary. Otherwise
|
||||
//! both parameters will be truncated/expanded to do so.
|
||||
//! For example, if u32BegAddr=0x1000 and u32EndAddr=0xC200, the actual
|
||||
//! range that protected is: 0x0 - 0xFFFF.
|
||||
//!
|
||||
//! This function enables copy protection on a given flash address range.
|
||||
//!
|
||||
//! @return 0 if copy protection was successfully enabled.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
am_hal_otp_set_copy_protection(uint32_t u32BegAddr, uint32_t u32EndAddr)
|
||||
{
|
||||
int iRet;
|
||||
uint32_t u32BfMask, u32Val;
|
||||
|
||||
//
|
||||
// Validate the parameters.
|
||||
//
|
||||
if ( (u32BegAddr > u32EndAddr) ||
|
||||
(u32EndAddr > (AM_HAL_FLASH_ADDR + AM_HAL_FLASH_TOTAL_SIZE - 1)) )
|
||||
{
|
||||
//
|
||||
// Invalid arguments.
|
||||
//
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Force given addresses to appropriate boundaries.
|
||||
//
|
||||
u32BegAddr &= ~(AM_HAL_OTP_CHUNKSIZE-1);
|
||||
u32EndAddr |= (AM_HAL_OTP_CHUNKSIZE-1);
|
||||
|
||||
//
|
||||
// Create the bitmask for the protection word.
|
||||
//
|
||||
u32BfMask = AM_HAL_OTP_PROT_M(u32BegAddr, u32EndAddr);
|
||||
|
||||
//
|
||||
// Now, set the mask in the copy-protection OTP.
|
||||
//
|
||||
iRet = am_hal_flash_program_otp(AM_HAL_FLASH_OTP_KEY,
|
||||
0,
|
||||
&u32BfMask,
|
||||
AM_HAL_OTP_COPYPROT_O / 4,
|
||||
1);
|
||||
|
||||
//
|
||||
// Now, read it back and make sure we cleared the bits we intended to clear.
|
||||
//
|
||||
u32Val = am_hal_flash_load_ui32(AM_HAL_OTP_COPYPROT_ADDR);
|
||||
if ( (u32Val & u32BfMask) != u32BfMask )
|
||||
{
|
||||
//
|
||||
// Something went awry. Not all the intended bits were set to 0
|
||||
// during the programming cycle. Return an error.
|
||||
//
|
||||
iRet = 0xff;
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set write protection.
|
||||
//!
|
||||
//! @param @u32BegAddr The beginning address to be write protected.
|
||||
//! @u32EndAddr The ending address to be write protected.
|
||||
//!
|
||||
//! @note For Apollo, the u32BegAddr parameter should be on a 16KB boundary, and
|
||||
//! the u32EndAddr parameter should be on a (16KB-1) boundary. Otherwise
|
||||
//! both parameters will be truncated/expanded to do so.
|
||||
//! For example, if u32BegAddr=0x1000 and u32EndAddr=0xC200, the actual
|
||||
//! range that protected is: 0x0 - 0xFFFF.
|
||||
//!
|
||||
//! This function enables write protection on a given flash address range.
|
||||
//!
|
||||
//! @return 0 if write protection was successfully enabled.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int
|
||||
am_hal_otp_set_write_protection(uint32_t u32BegAddr, uint32_t u32EndAddr)
|
||||
{
|
||||
int iRet;
|
||||
uint32_t u32BfMask, u32Val;
|
||||
|
||||
//
|
||||
// Validate the parameters.
|
||||
//
|
||||
if ( (u32BegAddr > u32EndAddr) ||
|
||||
(u32EndAddr > (AM_HAL_FLASH_ADDR + AM_HAL_FLASH_TOTAL_SIZE - 1)) )
|
||||
{
|
||||
//
|
||||
// Invalid arguments.
|
||||
//
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Force given addresses to appropriate boundaries.
|
||||
//
|
||||
u32BegAddr &= ~(AM_HAL_OTP_CHUNKSIZE-1);
|
||||
u32EndAddr |= (AM_HAL_OTP_CHUNKSIZE-1);
|
||||
|
||||
//
|
||||
// Create the bitmask for the protection word.
|
||||
//
|
||||
u32BfMask = AM_HAL_OTP_PROT_M(u32BegAddr, u32EndAddr);
|
||||
|
||||
//
|
||||
// Now, set the mask in the write-protection OTP.
|
||||
//
|
||||
iRet = am_hal_flash_program_otp(AM_HAL_FLASH_OTP_KEY,
|
||||
0,
|
||||
&u32BfMask,
|
||||
AM_HAL_OTP_WRITPROT_O / 4,
|
||||
1);
|
||||
|
||||
//
|
||||
// Now, read it back and make sure we cleared the bits we intended to clear.
|
||||
//
|
||||
u32Val = am_hal_flash_load_ui32(AM_HAL_OTP_WRITPROT_ADDR);
|
||||
if ( (u32Val & u32BfMask) != u32BfMask )
|
||||
{
|
||||
//
|
||||
// Something went awry. Not all the intended bits were set to 0
|
||||
// during the programming cycle. Return an error.
|
||||
//
|
||||
iRet = 0xff;
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,129 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_otp.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for handling the OTP interface.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_OTP_H
|
||||
#define AM_HAL_OTP_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Define some OTP values and macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_OTP_DBGR_O 0
|
||||
#define AM_HAL_OTP_WRITPROT_O 4
|
||||
#define AM_HAL_OTP_COPYPROT_O 8
|
||||
|
||||
#define AM_HAL_OTP_ADDR 0x50020400
|
||||
#define AM_HAL_OTP_DBGRPROT_ADDR (AM_HAL_OTP_ADDR + AM_HAL_OTP_DBGR_O)
|
||||
#define AM_HAL_OTP_WRITPROT_ADDR (AM_HAL_OTP_ADDR + AM_HAL_OTP_WRITPROT_O)
|
||||
#define AM_HAL_OTP_COPYPROT_ADDR (AM_HAL_OTP_ADDR + AM_HAL_OTP_COPYPROT_O)
|
||||
|
||||
#define AM_HAL_OTP_CHUNKSIZE (16*1024)
|
||||
|
||||
//
|
||||
// AM_HAL_OTP_CHUNK2ADDR: Convert a chunk number to an address
|
||||
// AM_HAL_OTP_CHUNK2INST: Convert a chunk number to an instance number
|
||||
//
|
||||
#define AM_HAL_OTP_CHUNK2ADDR(n) (AM_HAL_FLASH_ADDR + (n << 14))
|
||||
#define AM_HAL_OTP_CHUNK2INST(n) ((n >> 4) & 1)
|
||||
|
||||
//
|
||||
// Debugger port lockout macros.
|
||||
//
|
||||
#define AM_OTP_DBGR_LOCKOUT_S (0)
|
||||
#define AM_OTP_DBGR_LOCKOUT_M (0xf << AM_OTP_DBGR_LOCKOUT_S)
|
||||
#define AM_OTP_STRM_LOCKOUT_S (4)
|
||||
#define AM_OTP_STRM_LOCKOUT_M (0xf << AM_OTP_STRM_LOCKOUT_S)
|
||||
#define AM_OTP_SRAM_LOCKOUT_S (8)
|
||||
#define AM_OTP_SRAM_LOCKOUT_M (0xf << AM_OTP_SRAM_LOCKOUT_S)
|
||||
|
||||
//
|
||||
// Define a macro which will compute the appropriate bitmask for setting
|
||||
// copy or write protection for a given range of addresses.
|
||||
// Important note: The begaddr and endaddr parameters will be truncated/
|
||||
// expanded to include the entire 16KB chunk of memory in which it resides.
|
||||
//
|
||||
#define AM_HAL_OTP_PROT_M(begaddr, endaddr) \
|
||||
~( (AM_HAL_OTP_PROT_W((begaddr), (endaddr)) < 32) ? \
|
||||
(((1 << AM_HAL_OTP_PROT_W((begaddr), (endaddr)))-1) << (((begaddr) & ~(AM_HAL_OTP_CHUNKSIZE-1))/AM_HAL_OTP_CHUNKSIZE) ) : \
|
||||
0xffffffff )
|
||||
|
||||
//
|
||||
// Macro to determine the width in chunks.
|
||||
// Note that the address parameters are truncated/expanded to 16KB chunks.
|
||||
//
|
||||
#define AM_HAL_OTP_PROT_W(begaddr, endaddr) \
|
||||
( ( ( ((endaddr) | (AM_HAL_OTP_CHUNKSIZE-1)) - ((begaddr) & ~(AM_HAL_OTP_CHUNKSIZE-1)) ) / AM_HAL_OTP_CHUNKSIZE) + 1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern int am_hal_otp_is_debugger_lockedout(void);
|
||||
extern int am_hal_otp_debugger_lockout(void);
|
||||
extern int am_hal_otp_sram_lockout(void);
|
||||
extern int am_hal_otp_set_copy_protection(uint32_t u32BegAddr, uint32_t u32EndAddr);
|
||||
extern int am_hal_otp_set_write_protection(uint32_t u32BegAddr, uint32_t u32EndAddr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_OTP_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_pin.h
|
||||
//! @file
|
||||
//! @brief Macros for configuring specific pins.
|
||||
//!
|
||||
//! @addtogroup pin1 PIN definitions for Apollo1.
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef AM_HAL_PIN_H
|
||||
#define AM_HAL_PIN_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Pin definition helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_PIN_DIR_INPUT (AM_HAL_GPIO_INPEN)
|
||||
#define AM_HAL_PIN_DIR_OUTPUT (AM_HAL_GPIO_OUT_PUSHPULL)
|
||||
#define AM_HAL_PIN_DIR_OPENDRAIN (AM_HAL_GPIO_OUT_OPENDRAIN)
|
||||
#define AM_HAL_PIN_DIR_3STATE (AM_HAL_GPIO_OUT_3STATE)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Pin definition helper macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_PIN_DISABLE (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_INPUT (AM_HAL_GPIO_FUNC(3) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_OUTPUT (AM_HAL_GPIO_FUNC(3) | AM_HAL_PIN_DIR_OUTPUT)
|
||||
#define AM_HAL_PIN_OPENDRAIN (AM_HAL_GPIO_FUNC(3) | AM_HAL_PIN_DIR_OPENDRAIN)
|
||||
#define AM_HAL_PIN_3STATE (AM_HAL_GPIO_FUNC(3) | AM_HAL_PIN_DIR_3STATE)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Pin definition macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_PIN_0_SLSCL (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_0_SLSCK (AM_HAL_GPIO_FUNC(1) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_0_UARTTX (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_0_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_0_M0SCK_LOOP (AM_HAL_GPIO_FUNC(4))
|
||||
#define AM_HAL_PIN_0_M1SCK_LOOP (AM_HAL_GPIO_FUNC(5))
|
||||
#define AM_HAL_PIN_0_M0SCL_LOOP (AM_HAL_GPIO_FUNC(6))
|
||||
#define AM_HAL_PIN_0_M1SCL_LOOP (AM_HAL_GPIO_FUNC(7))
|
||||
|
||||
#define AM_HAL_PIN_1_SLSDA (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_OPENDRAIN | AM_HAL_GPIO_INPEN)
|
||||
#define AM_HAL_PIN_1_SLMISO (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_1_UARTRX (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_1_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_1_M0MISO_LOOP (AM_HAL_GPIO_FUNC(4))
|
||||
#define AM_HAL_PIN_1_M1MISO_LOOP (AM_HAL_GPIO_FUNC(5))
|
||||
#define AM_HAL_PIN_1_M0SDA_LOOP (AM_HAL_GPIO_FUNC(6))
|
||||
#define AM_HAL_PIN_1_M1SDA_LOOP (AM_HAL_GPIO_FUNC(7))
|
||||
|
||||
#define AM_HAL_PIN_2_SLWIR3 (AM_HAL_GPIO_FUNC(0) | AM_HAL_GPIO_INPEN)
|
||||
#define AM_HAL_PIN_2_SLMOSI (AM_HAL_GPIO_FUNC(1) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_2_CLKOUT (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_2_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_2_M0MOSI_LOOP (AM_HAL_GPIO_FUNC(4))
|
||||
#define AM_HAL_PIN_2_M1MOSI_LOOP (AM_HAL_GPIO_FUNC(5))
|
||||
#define AM_HAL_PIN_2_M0WIR3_LOOP (AM_HAL_GPIO_FUNC(6))
|
||||
#define AM_HAL_PIN_2_M1WIR3_LOOP (AM_HAL_GPIO_FUNC(7))
|
||||
|
||||
#define AM_HAL_PIN_3_TRIG0 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_3_SLnCE (AM_HAL_GPIO_FUNC(1) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_3_M1nCE4 (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_3_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_3_M0nCE_LOOP (AM_HAL_GPIO_FUNC(4))
|
||||
#define AM_HAL_PIN_3_M1nCE_LOOP (AM_HAL_GPIO_FUNC(5))
|
||||
// PSOURCE usage in pushpull: GPIOWT=1 to activate the power switch, GPIOWT=0 to disable
|
||||
#define AM_HAL_PIN_3_PSOURCE (AM_HAL_GPIO_FUNC(3) | AM_HAL_PIN_DIR_OUTPUT | AM_HAL_GPIO_POWERSOURCE)
|
||||
|
||||
#define AM_HAL_PIN_4_TRIG1 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_4_SLINT (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_4_M0nCE5 (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_4_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_4_SLINTGP_LOOP (AM_HAL_GPIO_FUNC(4))
|
||||
#define AM_HAL_PIN_4_SWO (AM_HAL_GPIO_FUNC(5))
|
||||
#define AM_HAL_PIN_4_CLKOUT (AM_HAL_GPIO_FUNC(6))
|
||||
// PSOURCE usage in pushpull: GPIOWT=1 to activate the power switch, GPIOWT=0 to disable
|
||||
#define AM_HAL_PIN_4_PSOURCE (AM_HAL_GPIO_FUNC(3) | AM_HAL_PIN_DIR_OUTPUT | AM_HAL_GPIO_POWERSOURCE)
|
||||
|
||||
#define AM_HAL_PIN_5_M0SCL (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_OPENDRAIN | AM_HAL_GPIO_INPEN)
|
||||
#define AM_HAL_PIN_5_M0SCK (AM_HAL_GPIO_FUNC(1) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_5_UARTS (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_5_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_5_M0SCK_LOOP (AM_HAL_GPIO_FUNC(4))
|
||||
#define AM_HAL_PIN_5_M0SCL_LOOP (AM_HAL_GPIO_FUNC(6))
|
||||
|
||||
#define AM_HAL_PIN_6_M0SDA (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_OPENDRAIN | AM_HAL_GPIO_INPEN)
|
||||
#define AM_HAL_PIN_6_M0MISO (AM_HAL_GPIO_FUNC(1) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_6_UACTS (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_6_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_6_SLMISO_LOOP (AM_HAL_GPIO_FUNC(4))
|
||||
#define AM_HAL_PIN_6_SLSDA_LOOP (AM_HAL_GPIO_FUNC(6))
|
||||
|
||||
#define AM_HAL_PIN_7_M0WIR3 (AM_HAL_GPIO_FUNC(0) | AM_HAL_GPIO_INPEN)
|
||||
#define AM_HAL_PIN_7_M0MOSI (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_7_CLKOUT (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_7_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_7_SLWIR3_LOOP (AM_HAL_GPIO_FUNC(6))
|
||||
|
||||
#define AM_HAL_PIN_8_M1SCL (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_OPENDRAIN | AM_HAL_GPIO_INPEN)
|
||||
#define AM_HAL_PIN_8_M1SCK (AM_HAL_GPIO_FUNC(1) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_8_M0nCE4 (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_8_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_8_M1SCK_LOOP (AM_HAL_GPIO_FUNC(5))
|
||||
#define AM_HAL_PIN_8_M1SCL_LOOP (AM_HAL_GPIO_FUNC(7))
|
||||
|
||||
#define AM_HAL_PIN_9_M1SDA (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_OPENDRAIN | AM_HAL_GPIO_INPEN)
|
||||
#define AM_HAL_PIN_9_M1MISO (AM_HAL_GPIO_FUNC(1) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_9_M0nCE5 (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_9_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_9_SLMISO_LOOP (AM_HAL_GPIO_FUNC(5))
|
||||
#define AM_HAL_PIN_9_SLSDA_LOOP (AM_HAL_GPIO_FUNC(7))
|
||||
|
||||
#define AM_HAL_PIN_10_M1WIR3 (AM_HAL_GPIO_FUNC(0) | AM_HAL_GPIO_INPEN)
|
||||
#define AM_HAL_PIN_10_M1MOSI (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_10_M0nCE6 (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_10_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_10_EXTHFA (AM_HAL_GPIO_FUNC(5) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_10_SLWIR3_LOOP (AM_HAL_GPIO_FUNC(7))
|
||||
|
||||
#define AM_HAL_PIN_11_RESERVED (AM_HAL_GPIO_FUNC(0))
|
||||
#define AM_HAL_PIN_11_M0nCE0 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_11_CLKOUT (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_11_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
// PSINK usage: GPIOWT=0 to activate the power switch, GPIOWT=1 to disable
|
||||
#define AM_HAL_PIN_11_PSINK (AM_HAL_GPIO_FUNC(3) | AM_HAL_PIN_DIR_OPENDRAIN | AM_HAL_GPIO_POWERSINK)
|
||||
|
||||
#define AM_HAL_PIN_12_ADC0 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_12_M1nCE0 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_12_TCTA0 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_12_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#define AM_HAL_PIN_13_ADC1 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_13_M1nCE1 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_13_TCTB0 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_13_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_13_EXTHFB (AM_HAL_GPIO_FUNC(5) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_13_SWO (AM_HAL_GPIO_FUNC(6))
|
||||
|
||||
#define AM_HAL_PIN_14_ADC2 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_14_M1nCE2 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_14_UARTTX (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_14_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_14_EXTHFS (AM_HAL_GPIO_FUNC(5) | AM_HAL_PIN_DIR_INPUT)
|
||||
|
||||
#define AM_HAL_PIN_15_ADC3 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_15_M1nCE3 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_15_UARTRX (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_15_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_15_EXTXT (AM_HAL_GPIO_FUNC(5) | AM_HAL_PIN_DIR_INPUT)
|
||||
|
||||
#define AM_HAL_PIN_16_ADCREF (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_16_M0nCE4 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_16_TRIG2 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_16_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#define AM_HAL_PIN_17_CMPAD0 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_17_M0nCE1 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_17_TRIG3 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_17_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#define AM_HAL_PIN_17_EXTLF (AM_HAL_GPIO_FUNC(5) | AM_HAL_PIN_DIR_INPUT)
|
||||
|
||||
#define AM_HAL_PIN_18_CMPAD1 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_18_M0nCE2 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_18_TCTA1 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_18_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#define AM_HAL_PIN_19_CMPRF0 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_19_M0nCE3 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_19_TCTB1 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_19_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#define AM_HAL_PIN_20_SWDCK (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_20_M1nCE5 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_20_TCTA2 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_20_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#define AM_HAL_PIN_21_SWDIO (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_21_M1nCE6 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_21_TCTB2 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_21_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_22_UARTTX (AM_HAL_GPIO_FUNC(0))
|
||||
#define AM_HAL_PIN_22_M1nCE7 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_22_TCTA3 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_22_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_23_UARTRX (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_23_M0nCE0 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_23_TCTB3 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_23_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_24_M0nCE1 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_24_CLKOUT (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_24_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_25_EXTXT (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_25_M0nCE2 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_25_TCTA0 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_25_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_26_EXTLF (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_26_M0nCE3 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_26_TCTB0 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_26_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_27_EXTHF (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_27_M1nCE4 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_27_TCTA1 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_27_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_28_M1nCE5 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_28_TCTB1 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_28_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#define AM_HAL_PIN_29_ADC4 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_29_M1nCE6 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_29_TCTA2 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_29_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_30_ADC5 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_30_M1nCE7 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_30_TCTB2 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_30_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#define AM_HAL_PIN_31_ADC6 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_31_M0nCE4 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_31_TCTA3 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_31_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_32_ADC7 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_32_M0nCE5 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_32_TCTB3 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_32_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_33_CMPRF1 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_33_M0nCE6 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_33_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_34_CMPRF2 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_34_M0nCE7 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_34_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#define AM_HAL_PIN_35_M1nCE0 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_35_UARTTX (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_35_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#define AM_HAL_PIN_36_M1nCE1 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_36_UARTRX (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_36_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_37_TRIG0 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_37_M1nCE2 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_37_UARTS (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_37_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_38_TRIG1 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_38_M1nCE3 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_38_UACTS (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_38_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_39_TRIG2 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_39_UARTTX (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_39_CLKOUT (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_39_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_40_TRIG3 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_40_UARTRX (AM_HAL_GPIO_FUNC(1) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_40_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#define AM_HAL_PIN_41_TRIG4 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_41_SWO (AM_HAL_GPIO_FUNC(2))
|
||||
#define AM_HAL_PIN_41_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_42_TRIG5 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_42_M0nCE0 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_42_TCTA0 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_42_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_43_TRIG6 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_43_M0nCE1 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_43_TCTB0 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_43_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_44_TRIG7 (AM_HAL_GPIO_FUNC(0) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_44_M0nCE2 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_44_TCTA1 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_44_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_45_M0nCE3 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_45_TCTB1 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_45_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_46_M0nCE4 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_46_TCTA2 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_46_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_47_M0nCE5 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_47_TCTB2 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_47_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_48_M0nCE6 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_48_TCTA3 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_48_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#if defined (AM_PACKAGE_BGA)
|
||||
#define AM_HAL_PIN_49_M0nCE7 (AM_HAL_GPIO_FUNC(1))
|
||||
#define AM_HAL_PIN_49_TCTB3 (AM_HAL_GPIO_FUNC(2) | AM_HAL_PIN_DIR_INPUT)
|
||||
#define AM_HAL_PIN_49_GPIO (AM_HAL_GPIO_FUNC(3))
|
||||
#endif // defined (AM_PACKAGE_BGA)
|
||||
|
||||
#endif // AM_HAL_PIN_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,118 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_pwrctrl.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Function stubs for accessing and configuring the PWR controller.
|
||||
//!
|
||||
//! @addtogroup pwrctrl1 Power Control
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_PWRCTRL_H
|
||||
#define AM_HAL_PWRCTRL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Peripheral enable bits for am_hal_pwrctrl_periph_enable/disable()
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_PWRCTRL_ADC AM_REG_PWRCTRL_DEVICEEN_ADC_EN
|
||||
#define AM_HAL_PWRCTRL_IOM0 AM_REG_PWRCTRL_DEVICEEN_IO_MASTER0_EN
|
||||
#define AM_HAL_PWRCTRL_IOM1 AM_REG_PWRCTRL_DEVICEEN_IO_MASTER1_EN
|
||||
#define AM_HAL_PWRCTRL_IOM2 AM_REG_PWRCTRL_DEVICEEN_IO_MASTER2_EN
|
||||
#define AM_HAL_PWRCTRL_IOM3 AM_REG_PWRCTRL_DEVICEEN_IO_MASTER3_EN
|
||||
#define AM_HAL_PWRCTRL_IOM4 AM_REG_PWRCTRL_DEVICEEN_IO_MASTER4_EN
|
||||
#define AM_HAL_PWRCTRL_IOM5 AM_REG_PWRCTRL_DEVICEEN_IO_MASTER5_EN
|
||||
#define AM_HAL_PWRCTRL_IOS AM_REG_PWRCTRL_DEVICEEN_IO_SLAVE_EN
|
||||
#define AM_HAL_PWRCTRL_PDM AM_REG_PWRCTRL_DEVICEEN_PDM_EN
|
||||
#define AM_HAL_PWRCTRL_UART0 AM_REG_PWRCTRL_DEVICEEN_UART0_EN
|
||||
#define AM_HAL_PWRCTRL_UART1 AM_REG_PWRCTRL_DEVICEEN_UART1_EN
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro to set the appropriate IOM peripheral when using
|
||||
// am_hal_pwrctrl_periph_enable()/disable().
|
||||
// For Apollo2, the module argument must resolve to be a value from 0-5.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_PWRCTRL_IOM(module)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro to set the appropriate UART peripheral when using
|
||||
// am_hal_pwrctrl_periph_enable()/disable().
|
||||
// For Apollo2, the module argument must resolve to be a value from 0-1.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_PWRCTRL_UART(module)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_pwrctrl_periph_enable(x)
|
||||
#define am_hal_pwrctrl_periph_disable(x)
|
||||
#define am_hal_pwrctrl_memory_enable(x)
|
||||
#define am_hal_pwrctrl_bucks_enable am_hal_mcuctrl_bucks_enable
|
||||
#define am_hal_pwrctrl_bucks_disable am_hal_mcuctrl_bucks_disable
|
||||
#define am_hal_pwrctrl_low_power_init(x)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_PWRCTRL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,289 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_queue.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for implementing a queue system.
|
||||
//!
|
||||
//! @addtogroup Miscellaneous1 Software Features (MISC)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Initializes a queue.
|
||||
//!
|
||||
//! @param psQueue - Pointer to a queue structure.
|
||||
//! @param pvData - Pointer to a memory location to be used for data storage.
|
||||
//! @param ui32ItemSize - Number of bytes per item in the queue.
|
||||
//! @param ui32ArraySize - Number of bytes in the data array.
|
||||
//!
|
||||
//! This function initializes the members of a queue structure and attaches it
|
||||
//! to an array of memory that it can use for storage. This function should be
|
||||
//! called before the queue is used.
|
||||
//!
|
||||
//! In this example, we are creating a queue that can hold 1024 32-bit
|
||||
//! integers. The integers themselves will be stored in the array named
|
||||
//! pui32WorkingSpace, while information about the queue itself will be stored
|
||||
//! in sDataQueue.
|
||||
//!
|
||||
//! @note The caller should not modify any of the members of am_hal_queue_t
|
||||
//! structures. The queue API will handle these members in a thread-safe way.
|
||||
//!
|
||||
//! @note The queue will remember what size data is in it. Other queue API
|
||||
//! functions will perform transfers in units of "items" where one "item" is
|
||||
//! the number of bytes you specify in the \e ui32ItemSize argument upon
|
||||
//! initialization.
|
||||
//!
|
||||
//! Example usage:
|
||||
//!
|
||||
//! @code
|
||||
//!
|
||||
//! //
|
||||
//! // Declare a queue structure and an array of bytes we can use to store
|
||||
//! // data.
|
||||
//! //
|
||||
//! am_hal_queue_t sDataQueue;
|
||||
//! uint32_t pui32WorkingSpace[1024];
|
||||
//!
|
||||
//! //
|
||||
//! // Attach the queue structure to the working memory.
|
||||
//! //
|
||||
//! am_hal_queue_init(&sDataQueue, pui8WorkingSpace, sizeof(uint32_t)
|
||||
//! sizeof(pui32WorkingSpace));
|
||||
//!
|
||||
//! @endcode
|
||||
//!
|
||||
//! The am_hal_queue_from_array macro is a convenient shorthand for this
|
||||
//! operation. The code below does the same thing as the code above.
|
||||
//!
|
||||
//! @code
|
||||
//!
|
||||
//! //
|
||||
//! // Declare a queue structure and an array of bytes we can use to store
|
||||
//! // data.
|
||||
//! //
|
||||
//! am_hal_queue_t sDataQueue;
|
||||
//! uint32_t pui32WorkingSpace[1024];
|
||||
//!
|
||||
//! //
|
||||
//! // Attach the queue structure to the working memory.
|
||||
//! //
|
||||
//! am_hal_queue_from_array(&sDataQueue, pui8WorkingSpace);
|
||||
//!
|
||||
//! @endcode
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_queue_init(am_hal_queue_t *psQueue, void *pvData, uint32_t ui32ItemSize,
|
||||
uint32_t ui32ArraySize)
|
||||
{
|
||||
psQueue->ui32WriteIndex = 0;
|
||||
psQueue->ui32ReadIndex = 0;
|
||||
psQueue->ui32Length = 0;
|
||||
psQueue->ui32Capacity = ui32ArraySize;
|
||||
psQueue->ui32ItemSize = ui32ItemSize;
|
||||
psQueue->pui8Data = (uint8_t *) pvData;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Adds an item to the Queue
|
||||
//!
|
||||
//! @param psQueue - Pointer to a queue structure.
|
||||
//! @param pvSource - Pointer to the data to be added.
|
||||
//! @param ui32NumItems - Number of items to be added.
|
||||
//!
|
||||
//! This function will copy the data pointed to by pvSource into the queue. The
|
||||
//! \e ui32NumItems term specifies the number of items to be copied from \e
|
||||
//! pvSource. The size of an "item" depends on how the queue was initialized.
|
||||
//! Please see am_hal_queue_init() for more information on this.
|
||||
//!
|
||||
//! @return true if the add operation was successful, or false if the queue
|
||||
//! didn't have enough space.
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
am_hal_queue_item_add(am_hal_queue_t *psQueue, const void *pvSource, uint32_t ui32NumItems)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t *pui8Source;
|
||||
uint32_t ui32Bytes = ui32NumItems * psQueue->ui32ItemSize;
|
||||
bool bSuccess = false;
|
||||
uint32_t ui32Primask;
|
||||
|
||||
pui8Source = (uint8_t *) pvSource;
|
||||
|
||||
ui32Primask = am_hal_interrupt_master_disable();
|
||||
|
||||
//
|
||||
// Check to make sure that the buffer isn't already full
|
||||
//
|
||||
if ( am_hal_queue_space_left(psQueue) >= ui32Bytes )
|
||||
{
|
||||
//
|
||||
// Loop over the bytes in the source array.
|
||||
//
|
||||
for ( i = 0; i < ui32Bytes; i++ )
|
||||
{
|
||||
//
|
||||
// Write the value to the buffer.
|
||||
//
|
||||
psQueue->pui8Data[psQueue->ui32WriteIndex] = pui8Source[i];
|
||||
|
||||
//
|
||||
// Advance the write index, making sure to wrap if necessary.
|
||||
//
|
||||
psQueue->ui32WriteIndex = ((psQueue->ui32WriteIndex + 1) %
|
||||
psQueue->ui32Capacity);
|
||||
}
|
||||
|
||||
//
|
||||
// Update the length value appropriately.
|
||||
//
|
||||
psQueue->ui32Length += ui32Bytes;
|
||||
|
||||
//
|
||||
// Report a success.
|
||||
//
|
||||
bSuccess = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// The buffer can't fit the amount of data requested. Return a
|
||||
// failure.
|
||||
//
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
am_hal_interrupt_master_set(ui32Primask);
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Removes an item from the Queue
|
||||
//!
|
||||
//! @param psQueue - Pointer to a queue structure.
|
||||
//! @param pvDest - Pointer to the data to be added.
|
||||
//! @param ui32NumItems - Number of items to be added.
|
||||
//!
|
||||
//! This function will copy the data from the queue into the memory pointed to
|
||||
//! by pvDest. The \e ui32NumItems term specifies the number of items to be
|
||||
//! copied from the queue. The size of an "item" depends on how the queue was
|
||||
//! initialized. Please see am_hal_queue_init() for more information on this.
|
||||
//!
|
||||
//! @return true if we were able to pull the requested number of items from the
|
||||
//! queue, or false if the queue didn't have that many items to pull.
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
am_hal_queue_item_get(am_hal_queue_t *psQueue, void *pvDest, uint32_t ui32NumItems)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t *pui8Dest;
|
||||
uint32_t ui32Bytes = ui32NumItems * psQueue->ui32ItemSize;
|
||||
bool bSuccess = false;
|
||||
uint32_t ui32Primask;
|
||||
|
||||
pui8Dest = (uint8_t *) pvDest;
|
||||
|
||||
ui32Primask = am_hal_interrupt_master_disable();
|
||||
|
||||
//
|
||||
// Check to make sure that the buffer isn't empty
|
||||
//
|
||||
if ( am_hal_queue_data_left(psQueue) >= ui32Bytes )
|
||||
{
|
||||
//
|
||||
// Loop over the bytes in the destination array.
|
||||
//
|
||||
for ( i = 0; i < ui32Bytes; i++ )
|
||||
{
|
||||
//
|
||||
// Grab the next value from the buffer.
|
||||
//
|
||||
pui8Dest[i] = psQueue->pui8Data[psQueue->ui32ReadIndex];
|
||||
|
||||
//
|
||||
// Advance the read index, wrapping if needed.
|
||||
//
|
||||
psQueue->ui32ReadIndex = ((psQueue->ui32ReadIndex + 1) %
|
||||
psQueue->ui32Capacity);
|
||||
}
|
||||
|
||||
//
|
||||
// Adjust the length value to reflect the change.
|
||||
//
|
||||
psQueue->ui32Length -= ui32Bytes;
|
||||
|
||||
//
|
||||
// Report a success.
|
||||
//
|
||||
bSuccess = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// If the buffer didn't have enough data, just return false.
|
||||
//
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
am_hal_interrupt_master_set(ui32Primask);
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,126 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_queue.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for implementing a queue system.
|
||||
//!
|
||||
//! @addtogroup Miscellaneous1 Software Features (MISC)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_QUEUE_H
|
||||
#define AM_HAL_QUEUE_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief A data structure that will operate as a queue.
|
||||
//!
|
||||
//! This data structure holds information necessary for operating a thread-safe
|
||||
//! queue. When declaring a structure of type am_hal_queue_t, you will also need
|
||||
//! to provide some working memory for the queue to use. For more information on
|
||||
//! setting up and using the am_hal_queue_t structure, please see the
|
||||
//! documentation for am_hal_queue_init().
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ui32WriteIndex;
|
||||
uint32_t ui32ReadIndex;
|
||||
uint32_t ui32Length;
|
||||
uint32_t ui32Capacity;
|
||||
uint32_t ui32ItemSize;
|
||||
uint8_t *pui8Data;
|
||||
}
|
||||
am_hal_queue_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Function-like macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_queue_empty(psQueue) \
|
||||
((psQueue)->ui32Length == 0)
|
||||
|
||||
#define am_hal_queue_full(psQueue) \
|
||||
((psQueue)->ui32Length == (psQueue)->ui32Capacity)
|
||||
|
||||
#define am_hal_queue_space_left(psQueue) \
|
||||
((psQueue)->ui32Capacity - (psQueue)->ui32Length)
|
||||
|
||||
#define am_hal_queue_data_left(psQueue) \
|
||||
((psQueue)->ui32Length)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Use this to make sure you get the size parameters right.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_queue_from_array(queue, array) \
|
||||
am_hal_queue_init((queue), (array), sizeof((array)[0]), sizeof(array))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_queue_init(am_hal_queue_t *psQueue, void *pvData, uint32_t ui32ItemSize, uint32_t ui32ArraySize);
|
||||
extern bool am_hal_queue_item_add(am_hal_queue_t *psQueue, const void *pvSource, uint32_t ui32NumItems);
|
||||
extern bool am_hal_queue_item_get(am_hal_queue_t *psQueue, void *pvDest, uint32_t ui32NumItems);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_QUEUE_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,163 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_reset.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Hardware abstraction layer for the Reset Generator module.
|
||||
//!
|
||||
//! @addtogroup rstgen1 Reset Generator (RSTGEN)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configure the Reset Generator.
|
||||
//!
|
||||
//! @param ui32Config - Or together the supplied macros to enable
|
||||
//! configurations to obtain the desired reset generator settings.
|
||||
//!
|
||||
//! This function will set the reset generator's configuration register based on
|
||||
//! the user's desired settings listed in the supplied arugment.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_reset_init(uint32_t ui32Config)
|
||||
{
|
||||
//
|
||||
// Write the configuration to the reset generator
|
||||
//
|
||||
AM_REG(RSTGEN, CFG) = ui32Config;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Issue a POR (Apollo's last stage interrupt).
|
||||
//!
|
||||
//! This function will issue a POR reset.
|
||||
//! The Apollo chip has numerous stages of reset. POR is the last and is also
|
||||
//! the reset invoked by the chip's reset pin, the watchdog timer, the AIRCR
|
||||
//! reset, and the SWD debugger requested interrupt.
|
||||
//!
|
||||
//! The Debug Access Port in the M4 is not cleared by this reset.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void am_hal_reset_por(void)
|
||||
{
|
||||
//
|
||||
// Write the POR key to the software POR register.
|
||||
//
|
||||
AM_REG(RSTGEN, SWPOR) =
|
||||
AM_REG_RSTGEN_SWPOR_SWPORKEY(AM_REG_RSTGEN_SWPOR_SWPORKEY_KEYVALUE);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Issue a POI (Apollo's second stage interrupt).
|
||||
//!
|
||||
//! This function will issue a POI reset.
|
||||
//! The Apollo chip has numerous stages of reset. POI is the second stage.
|
||||
//! A few modules are reset by POI that are not reset by POR, notably POI
|
||||
//! causes the shadow registers to be reloaded from the OTP. A full power
|
||||
//! cycle or POI should be used after writing new flash, debug or SRAM
|
||||
//! protection bits into the OTP for these protections to take effect.
|
||||
//!
|
||||
//! The Debug Access Port in the M4 is not cleared by this reset.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void am_hal_reset_poi(void)
|
||||
{
|
||||
//
|
||||
// Write the POI key to the software POI register.
|
||||
//
|
||||
AM_REG(RSTGEN, SWPOI) =
|
||||
AM_REG_RSTGEN_SWPOI_SWPOIKEY(AM_REG_RSTGEN_SWPOI_SWPOIKEY_KEYVALUE);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Retrieve the status bits from the reset generator.
|
||||
//!
|
||||
//! This function will get the status bits from the reset generator.
|
||||
//! These bits are sticky and show the accumulation of reset types that the
|
||||
//! Apollo chip has experienced since power on. One should clear these out
|
||||
//! after reading them.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t am_hal_reset_status_get(void)
|
||||
{
|
||||
//
|
||||
// Retrieve the reset generator status bits
|
||||
//
|
||||
return AM_REG(RSTGEN, STAT);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clear ALL of the status bits in the reset generator.
|
||||
//!
|
||||
//! This function will clear all status bits in the reset generator status.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void am_hal_reset_status_clear(void)
|
||||
{
|
||||
AM_REG(RSTGEN, CLRSTAT) = AM_REG_RSTGEN_CLRSTAT_CLRSTAT(1);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,122 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_reset.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Hardware abstraction layer for the Reset Generator module.
|
||||
//!
|
||||
//! @addtogroup wdt1 Watchdog Timer (RSTGEN)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_RSTGEN_H
|
||||
#define AM_HAL_RSTGEN_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Reset Generator Configuration
|
||||
//! @brief These macros may be used to set the reset generator's configuration.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_RESET_CFG_WDT_RESET_ENABLE (AM_REG_RSTGEN_CFG_WDREN(1))
|
||||
// Brown out high (2.1v) reset enable.
|
||||
#define AM_HAL_RESET_CFG_BOD_HIGH_RESET_ENABLE (AM_REG_RSTGEN_CFG_BODHREN(1))
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Reset Generator Status Bit Masks
|
||||
//! @brief These macros may be used to determine which type(s) of resets have
|
||||
//! been seen.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Reset was initiated by a Watchdog Timer Reset.
|
||||
#define AM_HAL_RESET_STAT_WDT (AM_REG_RSTGEN_STAT_WDRSTAT_M)
|
||||
|
||||
// Reset was a initiated by Debugger Reset.
|
||||
#define AM_HAL_RESET_STAT_DEBUG (AM_REG_RSTGEN_STAT_DBGRSTAT_M)
|
||||
|
||||
// Reset was a initiated by Software POI Reset.
|
||||
#define AM_HAL_RESET_STAT_POI (AM_REG_RSTGEN_STAT_POIRSTAT_M)
|
||||
|
||||
// Reset was a initiated by Software POR or AIRCR Reset.
|
||||
#define AM_HAL_RESET_STAT_SOFTWARE (AM_REG_RSTGEN_STAT_SWRSTAT_M)
|
||||
|
||||
// Reset was initiated by a Brown-Out Reset.
|
||||
#define AM_HAL_RESET_STAT_BOD (AM_REG_RSTGEN_STAT_BORSTAT_M)
|
||||
|
||||
// Reset was initiated by a Power Cycle
|
||||
#define AM_HAL_RESET_STAT_POWER_CYCLE (AM_REG_RSTGEN_STAT_PORSTAT_M)
|
||||
|
||||
// Reset was initiated by an External Reset.
|
||||
#define AM_HAL_RESET_STAT_EXTERNAL (AM_REG_RSTGEN_STAT_EXRSTAT_M)
|
||||
//! @}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_reset_init(uint32_t ui32Config);
|
||||
extern void am_hal_reset_por(void);
|
||||
extern void am_hal_reset_poi(void);
|
||||
extern uint32_t am_hal_reset_status_get(void);
|
||||
extern void am_hal_reset_status_clear(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_RSTGEN_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,682 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_rtc.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the Real-Time Clock (RTC).
|
||||
//!
|
||||
//! @addtogroup rtc1 Real-Time Clock (RTC)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Converts a Binary Coded Decimal (BCD) byte to its Decimal form.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint8_t
|
||||
bcd_to_dec(uint8_t ui8BCDByte)
|
||||
{
|
||||
return (((ui8BCDByte & 0xF0) >> 4) * 10) + (ui8BCDByte & 0x0F);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Converts a Decimal byte to its Binary Coded Decimal (BCD) form.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint8_t
|
||||
dec_to_bcd(uint8_t ui8DecimalByte)
|
||||
{
|
||||
return (((ui8DecimalByte / 10) << 4) | (ui8DecimalByte % 10));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Selects the clock source for the RTC.
|
||||
//!
|
||||
//! @param ui32OSC the clock source for the RTC.
|
||||
//!
|
||||
//! This function selects the clock source for the RTC.
|
||||
//!
|
||||
//! Valid values for ui32OSC are:
|
||||
//!
|
||||
//! AM_HAL_RTC_OSC_LFRC
|
||||
//! AM_HAL_RTC_OSC_XT
|
||||
//!
|
||||
//! @return None
|
||||
//!
|
||||
//! @note After selection of the RTC oscillator, a 2 second delay occurs before
|
||||
//! the new setting is reflected in status. Therefore the CLKGEN.STATUS.OMODE
|
||||
//! bit will not reflect the new status until after the 2s wait period.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_osc_select(uint32_t ui32OSC)
|
||||
{
|
||||
//
|
||||
// Set XT if flag is set.
|
||||
// Otherwise configure for LFRC.
|
||||
//
|
||||
if (ui32OSC)
|
||||
{
|
||||
AM_REG(CLKGEN, OCTRL) |= AM_REG_CLKGEN_OCTRL_OSEL_M;
|
||||
}
|
||||
else
|
||||
{
|
||||
AM_REG(CLKGEN, OCTRL) &= ~AM_REG_CLKGEN_OCTRL_OSEL_M;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable/Start the RTC oscillator.
|
||||
//!
|
||||
//! Starts the RTC oscillator.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_osc_enable(void)
|
||||
{
|
||||
//
|
||||
// Start the RTC Oscillator.
|
||||
//
|
||||
AM_BFW(RTC, RTCCTL, RSTOP, 0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable/Stop the RTC oscillator.
|
||||
//!
|
||||
//! Stops the RTC oscillator.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_osc_disable(void)
|
||||
{
|
||||
//
|
||||
// Stop the RTC Oscillator.
|
||||
//
|
||||
AM_BFW(RTC, RTCCTL, RSTOP, 1);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configures the RTC for 12 or 24 hour time keeping.
|
||||
//!
|
||||
//! @param b12Hour - A 'true' configures the RTC for 12 hour time keeping.
|
||||
//!
|
||||
//! Configures the RTC for 12 (true) or 24 (false) hour time keeping.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_time_12hour(bool b12Hour)
|
||||
{
|
||||
AM_BFW(RTC, RTCCTL, HR1224, b12Hour);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable selected RTC interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - desired interrupts
|
||||
//!
|
||||
//! Enables the RTC interrupts.
|
||||
//!
|
||||
//! ui32Interrupt should be an OR of the following:
|
||||
//!
|
||||
//! AM_HAL_RTC_INT_ALM
|
||||
//! AM_HAL_RTC_INT_OF
|
||||
//! AM_HAL_RTC_INT_ACC
|
||||
//! AM_HAL_RTC_INT_ACF
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_int_enable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Enable the interrupts.
|
||||
//
|
||||
AM_REG(RTC, INTEN) |= ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return the enabled RTC interrupts.
|
||||
//!
|
||||
//! Returns the enabled RTC interrupts.
|
||||
//!
|
||||
//! @return enabled RTC interrupts. Return is a logical or of:
|
||||
//!
|
||||
//! AM_HAL_RTC_INT_ALM
|
||||
//! AM_HAL_RTC_INT_OF
|
||||
//! AM_HAL_RTC_INT_ACC
|
||||
//! AM_HAL_RTC_INT_ACF
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_rtc_int_enable_get(void)
|
||||
{
|
||||
//
|
||||
// Read the RTC interrupt enable register, and return its contents.
|
||||
//
|
||||
return AM_REG(RTC, INTEN);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable selected RTC interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - desired interrupts
|
||||
//!
|
||||
//! Disables the RTC interrupts.
|
||||
//!
|
||||
//! ui32Interrupt should be an OR of the following:
|
||||
//!
|
||||
//! AM_HAL_RTC_INT_ALM
|
||||
//! AM_HAL_RTC_INT_OF
|
||||
//! AM_HAL_RTC_INT_ACC
|
||||
//! AM_HAL_RTC_INT_ACF
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_int_disable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Disable the interrupts.
|
||||
//
|
||||
AM_REG(RTC, INTEN) &= ~ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Sets the selected RTC interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - desired interrupts
|
||||
//!
|
||||
//! Sets the RTC interrupts causing them to immediately trigger.
|
||||
//!
|
||||
//! ui32Interrupt should be an OR of the following:
|
||||
//!
|
||||
//! AM_HAL_RTC_INT_ALM
|
||||
//! AM_HAL_RTC_INT_OF
|
||||
//! AM_HAL_RTC_INT_ACC
|
||||
//! AM_HAL_RTC_INT_ACF
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_int_set(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Set the interrupts.
|
||||
//
|
||||
AM_REG(RTC, INTSET) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clear selected RTC interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - desired interrupts
|
||||
//!
|
||||
//! Clears the RTC interrupts.
|
||||
//!
|
||||
//! ui32Interrupt should be an OR of the following:
|
||||
//!
|
||||
//! AM_HAL_RTC_INT_ALM
|
||||
//! AM_HAL_RTC_INT_OF
|
||||
//! AM_HAL_RTC_INT_ACC
|
||||
//! AM_HAL_RTC_INT_ACF
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_int_clear(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Clear the interrupts.
|
||||
//
|
||||
AM_REG(RTC, INTCLR) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Returns the RTC interrupt status.
|
||||
//!
|
||||
//! @param bEnabledOnly - return the status of only the enabled interrupts.
|
||||
//!
|
||||
//! Returns the RTC interrupt status.
|
||||
//!
|
||||
//! @return Bitwise representation of the current interrupt status.
|
||||
//!
|
||||
//! The return value will be the logical OR of one or more of the following
|
||||
//! values:
|
||||
//!
|
||||
//! AM_HAL_RTC_INT_ALM
|
||||
//! AM_HAL_RTC_INT_OF
|
||||
//! AM_HAL_RTC_INT_ACC
|
||||
//! AM_HAL_RTC_INT_ACF
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_rtc_int_status_get(bool bEnabledOnly)
|
||||
{
|
||||
//
|
||||
// Get the interrupt status.
|
||||
//
|
||||
if (bEnabledOnly)
|
||||
{
|
||||
uint32_t u32RetVal;
|
||||
u32RetVal = AM_REG(RTC, INTSTAT);
|
||||
u32RetVal &= AM_REG(RTC, INTEN);
|
||||
return u32RetVal &
|
||||
(AM_HAL_RTC_INT_ALM | AM_HAL_RTC_INT_OF |
|
||||
AM_HAL_RTC_INT_ACC | AM_HAL_RTC_INT_ACF);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (AM_REG(RTC, INTSTAT) & (AM_HAL_RTC_INT_ALM |
|
||||
AM_HAL_RTC_INT_OF |
|
||||
AM_HAL_RTC_INT_ACC |
|
||||
AM_HAL_RTC_INT_ACF));
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set the Real Time Clock counter registers.
|
||||
//!
|
||||
//! @param *pTime - A pointer to the time structure.
|
||||
//!
|
||||
//! Sets the RTC counter registers to the supplied values.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_time_set(am_hal_rtc_time_t *pTime)
|
||||
{
|
||||
//
|
||||
// Enable writing to the counters.
|
||||
//
|
||||
AM_BFW(RTC, RTCCTL, WRTC, 1);
|
||||
|
||||
//
|
||||
// Write the RTCLOW register.
|
||||
//
|
||||
AM_REG(RTC, CTRLOW) =
|
||||
AM_REG_RTC_CTRLOW_CTRHR(dec_to_bcd(pTime->ui32Hour)) |
|
||||
AM_REG_RTC_CTRLOW_CTRMIN(dec_to_bcd(pTime->ui32Minute)) |
|
||||
AM_REG_RTC_CTRLOW_CTRSEC(dec_to_bcd(pTime->ui32Second)) |
|
||||
AM_REG_RTC_CTRLOW_CTR100(dec_to_bcd(pTime->ui32Hundredths));
|
||||
|
||||
//
|
||||
// Write the RTCUP register.
|
||||
//
|
||||
AM_REG(RTC, CTRUP) =
|
||||
AM_REG_RTC_CTRUP_CEB((pTime->ui32CenturyEnable)) |
|
||||
AM_REG_RTC_CTRUP_CB((pTime->ui32Century)) |
|
||||
AM_REG_RTC_CTRUP_CTRWKDY((pTime->ui32Weekday)) |
|
||||
AM_REG_RTC_CTRUP_CTRYR(dec_to_bcd((pTime->ui32Year))) |
|
||||
AM_REG_RTC_CTRUP_CTRMO(dec_to_bcd((pTime->ui32Month))) |
|
||||
AM_REG_RTC_CTRUP_CTRDATE(dec_to_bcd((pTime->ui32DayOfMonth)));
|
||||
|
||||
//
|
||||
// Disable writing to the counters.
|
||||
//
|
||||
AM_BFW(RTC, RTCCTL, WRTC, 0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the Real Time Clock current time.
|
||||
//!
|
||||
//! @param *pTime - A pointer to the time structure to store the current time.
|
||||
//!
|
||||
//! Gets the RTC's current time
|
||||
//!
|
||||
//! @return 0 for success and 1 for error.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_rtc_time_get(am_hal_rtc_time_t *pTime)
|
||||
{
|
||||
uint32_t ui32RTCLow, ui32RTCUp, ui32Value;
|
||||
|
||||
//
|
||||
// Read the upper and lower RTC registers.
|
||||
//
|
||||
ui32RTCLow = AM_REG(RTC, CTRLOW);
|
||||
ui32RTCUp = AM_REG(RTC, CTRUP);
|
||||
|
||||
//
|
||||
// Break out the lower word.
|
||||
//
|
||||
ui32Value =
|
||||
((ui32RTCLow & AM_REG_RTC_CTRLOW_CTRHR_M) >> AM_REG_RTC_CTRLOW_CTRHR_S);
|
||||
pTime->ui32Hour = bcd_to_dec(ui32Value);
|
||||
|
||||
ui32Value =
|
||||
((ui32RTCLow & AM_REG_RTC_CTRLOW_CTRMIN_M) >> AM_REG_RTC_CTRLOW_CTRMIN_S);
|
||||
pTime->ui32Minute = bcd_to_dec(ui32Value);
|
||||
|
||||
ui32Value =
|
||||
((ui32RTCLow & AM_REG_RTC_CTRLOW_CTRSEC_M) >> AM_REG_RTC_CTRLOW_CTRSEC_S);
|
||||
pTime->ui32Second = bcd_to_dec(ui32Value);
|
||||
|
||||
ui32Value =
|
||||
((ui32RTCLow & AM_REG_RTC_CTRLOW_CTR100_M) >> AM_REG_RTC_CTRLOW_CTR100_S);
|
||||
pTime->ui32Hundredths = bcd_to_dec(ui32Value);
|
||||
|
||||
//
|
||||
// Break out the upper word.
|
||||
//
|
||||
pTime->ui32ReadError =
|
||||
((ui32RTCUp & AM_REG_RTC_CTRUP_CTERR_M) >> AM_REG_RTC_CTRUP_CTERR_S);
|
||||
|
||||
pTime->ui32CenturyEnable =
|
||||
((ui32RTCUp & AM_REG_RTC_CTRUP_CEB_M) >> AM_REG_RTC_CTRUP_CEB_S);
|
||||
|
||||
pTime->ui32Century =
|
||||
((ui32RTCUp & AM_REG_RTC_CTRUP_CB_M) >> AM_REG_RTC_CTRUP_CB_S);
|
||||
|
||||
ui32Value =
|
||||
((ui32RTCUp & AM_REG_RTC_CTRUP_CTRWKDY_M) >> AM_REG_RTC_CTRUP_CTRWKDY_S);
|
||||
pTime->ui32Weekday = bcd_to_dec(ui32Value);
|
||||
|
||||
ui32Value =
|
||||
((ui32RTCUp & AM_REG_RTC_CTRUP_CTRYR_M) >> AM_REG_RTC_CTRUP_CTRYR_S);
|
||||
pTime->ui32Year = bcd_to_dec(ui32Value);
|
||||
|
||||
ui32Value =
|
||||
((ui32RTCUp & AM_REG_RTC_CTRUP_CTRMO_M) >> AM_REG_RTC_CTRUP_CTRMO_S);
|
||||
pTime->ui32Month = bcd_to_dec(ui32Value);
|
||||
|
||||
ui32Value =
|
||||
((ui32RTCUp & AM_REG_RTC_CTRUP_CTRDATE_M) >> AM_REG_RTC_CTRUP_CTRDATE_S);
|
||||
pTime->ui32DayOfMonth = bcd_to_dec(ui32Value);
|
||||
|
||||
//
|
||||
// Was there a read error?
|
||||
//
|
||||
if (pTime->ui32ReadError)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Sets the alarm repeat interval.
|
||||
//!
|
||||
//! @param ui32RepeatInterval the desired repeat interval.
|
||||
//!
|
||||
//! Sets the alarm repeat interval.
|
||||
//!
|
||||
//! Valid values for ui32RepeatInterval:
|
||||
//!
|
||||
//! AM_HAL_RTC_ALM_RPT_DIS
|
||||
//! AM_HAL_RTC_ALM_RPT_YR
|
||||
//! AM_HAL_RTC_ALM_RPT_MTH
|
||||
//! AM_HAL_RTC_ALM_RPT_WK
|
||||
//! AM_HAL_RTC_ALM_RPT_DAY
|
||||
//! AM_HAL_RTC_ALM_RPT_HR
|
||||
//! AM_HAL_RTC_ALM_RPT_MIN
|
||||
//! AM_HAL_RTC_ALM_RPT_SEC
|
||||
//! AM_HAL_RTC_ALM_RPT_10TH
|
||||
//! AM_HAL_RTC_ALM_RPT_100TH
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_alarm_interval_set(uint32_t ui32RepeatInterval)
|
||||
{
|
||||
uint32_t ui32RptInt, ui32Alm100, ui32Value;
|
||||
|
||||
switch (ui32RepeatInterval)
|
||||
{
|
||||
//
|
||||
// If repeat every 10th set RPT and ALM100 field accordinly
|
||||
//
|
||||
case AM_HAL_RTC_ALM_RPT_10TH:
|
||||
ui32RptInt = AM_HAL_RTC_ALM_RPT_SEC;
|
||||
ui32Alm100 = AM_HAL_RTC_ALM100_10TH;
|
||||
break;
|
||||
//
|
||||
// If repeat every 100th set RPT and ALM100 field accordinly
|
||||
//
|
||||
case AM_HAL_RTC_ALM_RPT_100TH:
|
||||
ui32RptInt = AM_HAL_RTC_ALM_RPT_SEC;
|
||||
ui32Alm100 = AM_HAL_RTC_ALM100_100TH;
|
||||
break;
|
||||
//
|
||||
// Otherwise set RPT as value passed. ALM100 values need to be 0xnn
|
||||
// in this setting where n = 0-9.
|
||||
//
|
||||
default:
|
||||
//
|
||||
// Get the current value of the ALM100 field.
|
||||
//
|
||||
ui32Value = AM_BFR(RTC, ALMLOW, ALM100);
|
||||
|
||||
//
|
||||
// If ALM100 was previous EVERY_10TH or EVERY_100TH reset to zero
|
||||
// otherwise keep previous setting.
|
||||
//
|
||||
ui32Alm100 = ui32Value >= 0xF0 ? 0 : ui32Value;
|
||||
|
||||
//
|
||||
// Set RPT value to value passed.
|
||||
//
|
||||
ui32RptInt = ui32RepeatInterval;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Write the interval to the register.
|
||||
//
|
||||
AM_BFW(RTC, RTCCTL, RPT, ui32RptInt);
|
||||
|
||||
//
|
||||
// Write the Alarm 100 bits in the ALM100 register.
|
||||
//
|
||||
AM_BFW(RTC, ALMLOW, ALM100, ui32Alm100);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Sets the RTC's Alarm.
|
||||
//!
|
||||
//! @param *pTime - A pointer to the time structure.
|
||||
//! @param ui32RepeatInterval - the desired alarm repeat interval.
|
||||
//!
|
||||
//! Set the Real Time Clock Alarm Parameters.
|
||||
//!
|
||||
//! Valid values for ui32RepeatInterval:
|
||||
//!
|
||||
//! AM_HAL_RTC_ALM_RPT_DIS
|
||||
//! AM_HAL_RTC_ALM_RPT_YR
|
||||
//! AM_HAL_RTC_ALM_RPT_MTH
|
||||
//! AM_HAL_RTC_ALM_RPT_WK
|
||||
//! AM_HAL_RTC_ALM_RPT_DAY
|
||||
//! AM_HAL_RTC_ALM_RPT_HR
|
||||
//! AM_HAL_RTC_ALM_RPT_MIN
|
||||
//! AM_HAL_RTC_ALM_RPT_SEC
|
||||
//! AM_HAL_RTC_ALM_RPT_10TH
|
||||
//! AM_HAL_RTC_ALM_RPT_EVERY_100TH
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_alarm_set(am_hal_rtc_time_t *pTime, uint32_t ui32RepeatInterval)
|
||||
{
|
||||
uint8_t ui8Value = 0;
|
||||
|
||||
//
|
||||
// Write the interval to the register.
|
||||
//
|
||||
AM_REG(RTC, RTCCTL) |=
|
||||
AM_REG_RTC_RTCCTL_RPT(ui32RepeatInterval > 0x7 ? 0x7 : ui32RepeatInterval);
|
||||
|
||||
//
|
||||
// Check if the interval is 10th or every 100th and track it in ui8Value.
|
||||
//
|
||||
if (ui32RepeatInterval == AM_HAL_RTC_ALM_RPT_10TH)
|
||||
{
|
||||
ui8Value = 0xF0;
|
||||
}
|
||||
else if (ui32RepeatInterval == AM_HAL_RTC_ALM_RPT_100TH)
|
||||
{
|
||||
ui8Value = 0xFF;
|
||||
}
|
||||
|
||||
//
|
||||
// Write the ALMUP register.
|
||||
//
|
||||
AM_REG(RTC, ALMUP) =
|
||||
AM_REG_RTC_ALMUP_ALMWKDY((pTime->ui32Weekday)) |
|
||||
AM_REG_RTC_ALMUP_ALMMO(dec_to_bcd((pTime->ui32Month))) |
|
||||
AM_REG_RTC_ALMUP_ALMDATE(dec_to_bcd((pTime->ui32DayOfMonth)));
|
||||
|
||||
//
|
||||
// Write the ALMLOW register.
|
||||
//
|
||||
AM_REG(RTC, ALMLOW) =
|
||||
AM_REG_RTC_ALMLOW_ALMHR(dec_to_bcd(pTime->ui32Hour)) |
|
||||
AM_REG_RTC_ALMLOW_ALMMIN(dec_to_bcd(pTime->ui32Minute)) |
|
||||
AM_REG_RTC_ALMLOW_ALMSEC(dec_to_bcd(pTime->ui32Second)) |
|
||||
AM_REG_RTC_ALMLOW_ALM100(dec_to_bcd(pTime->ui32Hundredths) | ui8Value);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the Real Time Clock Alarm Parameters
|
||||
//!
|
||||
//! @param *pTime - A pointer to the time structure to store the current alarm.
|
||||
//!
|
||||
//! Gets the RTC's Alarm time
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_rtc_alarm_get(am_hal_rtc_time_t *pTime)
|
||||
{
|
||||
uint32_t ui32ALMLow, ui32ALMUp, ui32Value;
|
||||
|
||||
//
|
||||
// Read the upper and lower RTC registers.
|
||||
//
|
||||
ui32ALMLow = AM_REG(RTC, ALMLOW);
|
||||
ui32ALMUp = AM_REG(RTC, ALMUP);
|
||||
|
||||
//
|
||||
// Break out the lower word.
|
||||
//
|
||||
ui32Value =
|
||||
((ui32ALMLow & AM_REG_RTC_ALMLOW_ALMHR_M) >> AM_REG_RTC_ALMLOW_ALMHR_S);
|
||||
pTime->ui32Hour = bcd_to_dec(ui32Value);
|
||||
|
||||
ui32Value =
|
||||
((ui32ALMLow & AM_REG_RTC_ALMLOW_ALMMIN_M) >> AM_REG_RTC_ALMLOW_ALMMIN_S);
|
||||
pTime->ui32Minute = bcd_to_dec(ui32Value);
|
||||
|
||||
ui32Value =
|
||||
((ui32ALMLow & AM_REG_RTC_ALMLOW_ALMSEC_M) >> AM_REG_RTC_ALMLOW_ALMSEC_S);
|
||||
pTime->ui32Second = bcd_to_dec(ui32Value);
|
||||
|
||||
ui32Value =
|
||||
((ui32ALMLow & AM_REG_RTC_ALMLOW_ALM100_M) >> AM_REG_RTC_ALMLOW_ALM100_S);
|
||||
pTime->ui32Hundredths = bcd_to_dec(ui32Value);
|
||||
|
||||
//
|
||||
// Break out the upper word.
|
||||
//
|
||||
pTime->ui32ReadError = 0;
|
||||
pTime->ui32CenturyEnable = 0;
|
||||
pTime->ui32Century = 0;
|
||||
|
||||
ui32Value =
|
||||
((ui32ALMUp & AM_REG_RTC_ALMUP_ALMWKDY_M) >> AM_REG_RTC_ALMUP_ALMWKDY_S);
|
||||
pTime->ui32Weekday = bcd_to_dec(ui32Value);
|
||||
|
||||
pTime->ui32Year = 0;
|
||||
|
||||
ui32Value =
|
||||
((ui32ALMUp & AM_REG_RTC_ALMUP_ALMMO_M) >> AM_REG_RTC_ALMUP_ALMMO_S);
|
||||
pTime->ui32Month = bcd_to_dec(ui32Value);
|
||||
|
||||
ui32Value =
|
||||
((ui32ALMUp & AM_REG_RTC_ALMUP_ALMDATE_M) >> AM_REG_RTC_ALMUP_ALMDATE_S);
|
||||
pTime->ui32DayOfMonth = bcd_to_dec(ui32Value);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,188 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_rtc.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing and accessing the Real-Time Clock (RTC).
|
||||
//!
|
||||
//! @addtogroup rtc1 Real-Time Clock (RTC)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_RTC_H
|
||||
#define AM_HAL_RTC_H
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name OSC Start and Stop
|
||||
//! @brief OSC Start and Stop defines.
|
||||
//!
|
||||
//! OSC Start and Stop defines to be used with \e am_hal_clkgen_osc_x().
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_RTC_OSC_LFRC 0x1
|
||||
#define AM_HAL_RTC_OSC_XT 0x0
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name RTC Interrupts
|
||||
//! @brief Macro definitions for RTC interrupt status bits.
|
||||
//!
|
||||
//! These macros correspond to the bits in the RTC interrupt status register.
|
||||
//! They may be used with any of the \e am_hal_rtc_int_x() functions.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_RTC_INT_ALM AM_REG_RTC_INTEN_ALM_M
|
||||
#define AM_HAL_RTC_INT_OF AM_REG_RTC_INTEN_OF_M
|
||||
#define AM_HAL_RTC_INT_ACC AM_REG_RTC_INTEN_ACC_M
|
||||
#define AM_HAL_RTC_INT_ACF AM_REG_RTC_INTEN_ACF_M
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name RTC Alarm Repeat Interval.
|
||||
//! @brief Macro definitions for the RTC alarm repeat interval.
|
||||
//!
|
||||
//! These macros correspond to the RPT bits in the RTCCTL register.
|
||||
//! They may be used with the \e am_hal_rtc_alarm_interval_set() function.
|
||||
//!
|
||||
//! Note: AM_HAL_RTC_ALM_RPT_10TH and AM_HAL_RTC_ALM_RPT_100TH do not
|
||||
//! correspond to the RPT bits but are used in conjunction with setting the
|
||||
//! ALM100 bits in the ALMLOW register.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_RTC_ALM_RPT_DIS 0x0
|
||||
#define AM_HAL_RTC_ALM_RPT_YR 0x1
|
||||
#define AM_HAL_RTC_ALM_RPT_MTH 0x2
|
||||
#define AM_HAL_RTC_ALM_RPT_WK 0x3
|
||||
#define AM_HAL_RTC_ALM_RPT_DAY 0x4
|
||||
#define AM_HAL_RTC_ALM_RPT_HR 0x5
|
||||
#define AM_HAL_RTC_ALM_RPT_MIN 0x6
|
||||
#define AM_HAL_RTC_ALM_RPT_SEC 0x7
|
||||
#define AM_HAL_RTC_ALM_RPT_10TH 0x8
|
||||
#define AM_HAL_RTC_ALM_RPT_100TH 0x9
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name RTC Alarm 100 Interval.
|
||||
//! @brief Macro definitions for the RTC alarm ms intervals.
|
||||
//!
|
||||
//! These macros are used inside the #am_hal_rtc_alarm_interval_set function
|
||||
//! when 10ms and 100ms repeated alarm intervals are desired.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_RTC_ALM100_DEFAULT 0x00
|
||||
#define AM_HAL_RTC_ALM100_10TH 0xF0
|
||||
#define AM_HAL_RTC_ALM100_100TH 0xFF
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief The basic time structure used by the HAL for RTC interaction.
|
||||
//!
|
||||
//! All values are positive whole numbers. The HAL routines convert back and
|
||||
//! forth to BCD.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct am_hal_rtc_time_struct
|
||||
{
|
||||
uint32_t ui32ReadError;
|
||||
uint32_t ui32CenturyEnable;
|
||||
uint32_t ui32Weekday;
|
||||
uint32_t ui32Century;
|
||||
uint32_t ui32Year;
|
||||
uint32_t ui32Month;
|
||||
uint32_t ui32DayOfMonth;
|
||||
uint32_t ui32Hour;
|
||||
uint32_t ui32Minute;
|
||||
uint32_t ui32Second;
|
||||
uint32_t ui32Hundredths;
|
||||
}am_hal_rtc_time_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_rtc_osc_select(uint32_t ui32OSC);
|
||||
extern void am_hal_rtc_osc_enable(void);
|
||||
extern void am_hal_rtc_osc_disable(void);
|
||||
extern void am_hal_rtc_time_12hour(bool b12Hour);
|
||||
extern void am_hal_rtc_time_set(am_hal_rtc_time_t *pTime);
|
||||
extern uint32_t am_hal_rtc_time_get(am_hal_rtc_time_t *pTime);
|
||||
extern void am_hal_rtc_alarm_interval_set(uint32_t ui32RepeatInterval);
|
||||
extern void am_hal_rtc_alarm_set(am_hal_rtc_time_t *pTime,
|
||||
uint32_t ui32RepeatInterval);
|
||||
extern void am_hal_rtc_alarm_get(am_hal_rtc_time_t *pTime);
|
||||
extern void am_hal_rtc_int_enable(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_rtc_int_enable_get(void);
|
||||
extern void am_hal_rtc_int_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_rtc_int_clear(uint32_t ui32Interrupt);
|
||||
extern void am_hal_rtc_int_set(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_rtc_int_status_get(bool bEnabledOnly);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_RTC_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,288 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_sysctrl.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the M4F system control registers
|
||||
//!
|
||||
//! @addtogroup sysctrl1 System Control (SYSCTRL)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Place the core into sleep or deepsleep.
|
||||
//!
|
||||
//! @param bSleepDeep - False for Normal or True Deep sleep.
|
||||
//!
|
||||
//! This function puts the MCU to sleep or deepsleep depending on bSleepDeep.
|
||||
//!
|
||||
//! Valid values for bSleepDeep are:
|
||||
//!
|
||||
//! AM_HAL_SYSCTRL_SLEEP_NORMAL
|
||||
//! AM_HAL_SYSCTRL_SLEEP_DEEP
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_sysctrl_sleep(bool bSleepDeep)
|
||||
{
|
||||
//
|
||||
// If the user selected DEEPSLEEP and the TPIU is off, attempt to enter
|
||||
// DEEP SLEEP.
|
||||
//
|
||||
if ((bSleepDeep == AM_HAL_SYSCTRL_SLEEP_DEEP) &&
|
||||
(AM_BFM(MCUCTRL, TPIUCTRL, ENABLE) == AM_REG_MCUCTRL_TPIUCTRL_ENABLE_DIS))
|
||||
{
|
||||
//
|
||||
// Prepare the core for deepsleep (write 1 to the DEEPSLEEP bit).
|
||||
//
|
||||
AM_BFW(SYSCTRL, SCR, SLEEPDEEP, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
AM_BFW(SYSCTRL, SCR, SLEEPDEEP, 0);
|
||||
}
|
||||
|
||||
//
|
||||
// Before executing WFI, flush any buffered core and peripheral writes.
|
||||
//
|
||||
AM_ASM_DSB
|
||||
|
||||
//
|
||||
// Go to sleep.
|
||||
//
|
||||
AM_ASM_WFI;
|
||||
|
||||
//
|
||||
// Upon wake, execute the Instruction Sync Barrier instruction.
|
||||
//
|
||||
AM_ASM_ISB
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Place the core into the deepest sleep state possible
|
||||
//!
|
||||
//! This function puts the MCU to sleep or deepsleep depending on which
|
||||
//! peripherals are on. If the UART or either IOM module is enabled, the MCU
|
||||
//! will be placed into normal sleep. Otherwise, the MCU will go to deep sleep.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_sysctrl_sleep_auto(void)
|
||||
{
|
||||
//
|
||||
// If any of the HFRC peripherals are on, go to normal sleep. Otherwise go
|
||||
// to deep sleep.
|
||||
//
|
||||
if (AM_BFM(MCUCTRL, TPIUCTRL, ENABLE) || AM_BFMn(IOMSTR, 0, CFG, IFCEN) ||
|
||||
AM_BFMn(IOMSTR, 1, CFG, IFCEN) || AM_REG(CLKGEN, UARTEN))
|
||||
{
|
||||
AM_BFW(SYSCTRL, SCR, SLEEPDEEP, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
AM_BFW(SYSCTRL, SCR, SLEEPDEEP, 0);
|
||||
}
|
||||
|
||||
//
|
||||
// Before executing WFI, flush any buffered core and peripheral writes.
|
||||
//
|
||||
AM_ASM_DSB
|
||||
|
||||
//
|
||||
// Go to sleep.
|
||||
//
|
||||
AM_ASM_WFI;
|
||||
|
||||
//
|
||||
// Upon wake, execute the Instruction Sync Barrier instruction.
|
||||
//
|
||||
AM_ASM_ISB
|
||||
}
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the floating point module.
|
||||
//!
|
||||
//! Call this function to enable the ARM hardware floating point module.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_sysctrl_fpu_enable(void)
|
||||
{
|
||||
//
|
||||
// Enable access to the FPU in both privileged and user modes.
|
||||
// NOTE: Write 0s to all reserved fields in this register.
|
||||
//
|
||||
AM_REG(SYSCTRL, CPACR) = (AM_REG_SYSCTRL_CPACR_CP11(0x3) |
|
||||
AM_REG_SYSCTRL_CPACR_CP10(0x3));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the floating point module.
|
||||
//!
|
||||
//! Call this function to disable the ARM hardware floating point module.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_sysctrl_fpu_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable access to the FPU in both privileged and user modes.
|
||||
// NOTE: Write 0s to all reserved fields in this register.
|
||||
//
|
||||
AM_REG(SYSCTRL, CPACR) = 0x00000000 &
|
||||
~(AM_REG_SYSCTRL_CPACR_CP11(0x3) |
|
||||
AM_REG_SYSCTRL_CPACR_CP10(0x3));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable stacking of FPU registers on exception entry.
|
||||
//!
|
||||
//! @param bLazy - Set to "true" to enable "lazy stacking".
|
||||
//!
|
||||
//! This function allows the core to save floating-point information to the
|
||||
//! stack on exception entry. Setting the bLazy option enables "lazy stacking"
|
||||
//! for interrupt handlers. Normally, mixing floating-point code and interrupt
|
||||
//! driven routines causes increased interrupt latency, because the core must
|
||||
//! save extra information to the stack upon exception entry. With the lazy
|
||||
//! stacking option enabled, the core will skip the saving of floating-point
|
||||
//! registers when possible, reducing average interrupt latency.
|
||||
//!
|
||||
//! @note At reset of the Cortex M4, the ASPEN and LSPEN bits are set to 1,
|
||||
//! enabling Lazy mode by default. Therefore this function will generally
|
||||
//! only have an affect when setting for full-context save (or when switching
|
||||
//! from full-context to lazy mode).
|
||||
//!
|
||||
//! @note See also:
|
||||
//! infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0298a/DAFGGBJD.html
|
||||
//!
|
||||
//! @note Three valid FPU context saving modes are possible.
|
||||
//! 1. Lazy ASPEN=1 LSPEN=1 am_hal_sysctrl_fpu_stacking_enable(true)
|
||||
//! and default.
|
||||
//! 2. Full-context ASPEN=1 LSPEN=0 am_hal_sysctrl_fpu_stacking_enable(false)
|
||||
//! 3. No FPU state ASPEN=0 LSPEN=0 am_hal_sysctrl_fpu_stacking_disable()
|
||||
//! 4. Invalid ASPEN=0 LSPEN=1
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_sysctrl_fpu_stacking_enable(bool bLazy)
|
||||
{
|
||||
#define SYSCTRL_FPCCR_LAZY (AM_REG_SYSCTRL_FPCCR_ASPEN_M | AM_REG_SYSCTRL_FPCCR_LSPEN_M)
|
||||
|
||||
uint32_t ui32fpccr;
|
||||
|
||||
//
|
||||
// Set the requested FPU stacking mode in ISRs.
|
||||
//
|
||||
AM_CRITICAL_BEGIN
|
||||
ui32fpccr = AM_REG(SYSCTRL, FPCCR);
|
||||
ui32fpccr &= ~(SYSCTRL_FPCCR_LAZY);
|
||||
ui32fpccr |= (bLazy ? SYSCTRL_FPCCR_LAZY : AM_REG_SYSCTRL_FPCCR_ASPEN_M);
|
||||
AM_REG(SYSCTRL, FPCCR) = ui32fpccr;
|
||||
AM_CRITICAL_END
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable FPU register stacking on exception entry.
|
||||
//!
|
||||
//! This function disables all stacking of floating point registers for
|
||||
//! interrupt handlers. This mode should only be used when it is absolutely
|
||||
//! known that no FPU instructions will be executed in an ISR.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_sysctrl_fpu_stacking_disable(void)
|
||||
{
|
||||
//
|
||||
// Completely disable FPU context save on entry to ISRs.
|
||||
//
|
||||
AM_CRITICAL_BEGIN
|
||||
AM_REG(SYSCTRL, FPCCR) &= ~SYSCTRL_FPCCR_LAZY;
|
||||
AM_CRITICAL_END
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Issue a system wide reset using the AIRCR bit in the M4 system ctrl.
|
||||
//!
|
||||
//! This function issues a system wide reset (Apollo POR level reset).
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_sysctrl_reset(void)
|
||||
{
|
||||
//
|
||||
// Set the system reset bit in the AIRCR register
|
||||
//
|
||||
AM_REG(SYSCTRL, AIRCR) = AM_REG_SYSCTRL_AIRCR_VECTKEY(0x5FA) |
|
||||
AM_REG_SYSCTRL_AIRCR_SYSRESETREQ(1);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,108 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_sysctrl.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the M4F system control registers
|
||||
//!
|
||||
//! @addtogroup sysctrl1 System Control (SYSCTRL)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_SYSCTRL_H
|
||||
#define AM_HAL_SYSCTRL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Definitions for sleep mode parameter
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_SYSCTRL_SLEEP_DEEP true
|
||||
#define AM_HAL_SYSCTRL_SLEEP_NORMAL false
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macros to make intrinsics a little easier.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
#define am_wfi() __wfi();
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
#define am_wfi() __asm(" wfi")
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
#define am_wfi() __asm(" wfi")
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#define am_wfi() asm(" wfi")
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_sysctrl_sleep(bool bSleepDeep);
|
||||
extern void am_hal_sysctrl_sleep_auto(void);
|
||||
extern void am_hal_sysctrl_fpu_enable(void);
|
||||
extern void am_hal_sysctrl_fpu_disable(void);
|
||||
extern void am_hal_sysctrl_fpu_stacking_enable(bool bLazy);
|
||||
extern void am_hal_sysctrl_fpu_stacking_disable(void);
|
||||
extern void am_hal_sysctrl_aircr_reset(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_SYSCTRL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
@@ -0,0 +1,353 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_systick.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the SYSTICK
|
||||
//!
|
||||
//! @addtogroup systick1 System Timer (SYSTICK)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SYSTICK_MAX_TICKS ((1 << 24)-1)
|
||||
#define MAX_U32 (0xffffffff)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Start the SYSTICK.
|
||||
//!
|
||||
//! This function starts the systick timer.
|
||||
//!
|
||||
//! @note This timer does not run in deep-sleep mode as it runs from the core
|
||||
//! clock, which is gated in deep-sleep. If a timer is needed in deep-sleep use
|
||||
//! one of the ctimers instead. Also to note is this timer will consume higher
|
||||
//! power than the ctimers.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_systick_start(void)
|
||||
{
|
||||
//
|
||||
// Start the systick timer.
|
||||
//
|
||||
AM_REG(SYSTICK, SYSTCSR) |= AM_REG_SYSTICK_SYSTCSR_ENABLE_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Stop the SYSTICK.
|
||||
//!
|
||||
//! This function stops the systick timer.
|
||||
//!
|
||||
//! @note This timer does not run in deep-sleep mode as it runs from the core
|
||||
//! clock, which is gated in deep-sleep. If a timer is needed in deep-sleep use
|
||||
//! one of the ctimers instead. Also to note is this timer will consume higher
|
||||
//! power than the ctimers.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_systick_stop(void)
|
||||
{
|
||||
//
|
||||
// Stop the systick timer.
|
||||
//
|
||||
AM_REG(SYSTICK, SYSTCSR) &= ~AM_REG_SYSTICK_SYSTCSR_ENABLE_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the interrupt in the SYSTICK.
|
||||
//!
|
||||
//! This function enables the interupt in the systick timer.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_systick_int_enable(void)
|
||||
{
|
||||
//
|
||||
// Enable the systick timer interrupt.
|
||||
//
|
||||
AM_REG(SYSTICK, SYSTCSR) |= AM_REG_SYSTICK_SYSTCSR_TICKINT_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the interrupt in the SYSTICK.
|
||||
//!
|
||||
//! This function disables the interupt in the systick timer.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_systick_int_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the systick timer interrupt.
|
||||
//
|
||||
AM_REG(SYSTICK, SYSTCSR) &= ~AM_REG_SYSTICK_SYSTCSR_TICKINT_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Reads the interrupt status.
|
||||
//!
|
||||
//! This function reads the interrupt status in the systick timer.
|
||||
//!
|
||||
//! @return the interrupt status.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_systick_int_status_get(void)
|
||||
{
|
||||
//
|
||||
// Return the systick timer interrupt status.
|
||||
//
|
||||
return AM_REG(SYSTICK, SYSTCSR) & AM_REG_SYSTICK_SYSTCSR_COUNTFLAG_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Reset the interrupt in the SYSTICK.
|
||||
//!
|
||||
//! This function resets the systick timer by clearing out the configuration
|
||||
//! register.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_systick_reset(void)
|
||||
{
|
||||
//
|
||||
// Reset the systick timer interrupt.
|
||||
//
|
||||
AM_REG(SYSTICK, SYSTCSR) = 0x0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Load the value into the SYSTICK.
|
||||
//!
|
||||
//! @param ui32LoadVal the desired load value for the systick. Maximum value is
|
||||
//! 0x00FF.FFFF.
|
||||
//!
|
||||
//! This function loads the desired value into the systick timer.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_systick_load(uint32_t ui32LoadVal)
|
||||
{
|
||||
//
|
||||
// The proper SysTick initialization sequence is: (p 4-36 of the M4 UG).
|
||||
// 1. Program reload value
|
||||
// 2. Clear current value
|
||||
// 3. Program CSR
|
||||
// Write the given value to the reload register.
|
||||
// Write the Current Value Register to clear it to 0.
|
||||
//
|
||||
AM_REG(SYSTICK, SYSTRVR) = ui32LoadVal;
|
||||
AM_REG(SYSTICK, SYSTCVR) = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the current count value in the SYSTICK.
|
||||
//!
|
||||
//! This function gets the current count value in the systick timer.
|
||||
//!
|
||||
//! @return Current count value.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_systick_count(void)
|
||||
{
|
||||
//
|
||||
// Return the current systick timer count value.
|
||||
//
|
||||
return AM_REG(SYSTICK, SYSTCVR);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Wait the specified number of ticks.
|
||||
//!
|
||||
//! This function delays for the given number of SysTick ticks.
|
||||
//!
|
||||
//! @note If the SysTick timer is being used elsewhere, it will be corrupted
|
||||
//! by calling this function.
|
||||
//!
|
||||
//! @return 0 if successful.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_systick_wait_ticks(uint32_t ui32Ticks)
|
||||
{
|
||||
|
||||
if ( ui32Ticks == 0 )
|
||||
{
|
||||
ui32Ticks++; // Make sure we get the COUNTFLAG
|
||||
}
|
||||
|
||||
//
|
||||
// The proper SysTick initialization sequence is: (p 4-36 of the M4 UG).
|
||||
// 1. Program reload value
|
||||
// 2. Clear current value
|
||||
// 3. Program CSR
|
||||
//
|
||||
// Set the reload value to the required number of ticks.
|
||||
//
|
||||
AM_REG(SYSTICK, SYSTRVR) = ui32Ticks;
|
||||
|
||||
//
|
||||
// Clear the current count.
|
||||
//
|
||||
AM_REG(SYSTICK, SYSTCVR) = 0x0;
|
||||
|
||||
//
|
||||
// Set to use the processor clock, but don't cause an exception (we'll poll).
|
||||
//
|
||||
AM_REG(SYSTICK, SYSTCSR) = AM_REG_SYSTICK_SYSTCSR_ENABLE_M;
|
||||
|
||||
//
|
||||
// Poll till done
|
||||
//
|
||||
while ( !(AM_REG(SYSTICK, SYSTCSR) & AM_REG_SYSTICK_SYSTCSR_COUNTFLAG_M) );
|
||||
|
||||
//
|
||||
// And disable systick before exiting.
|
||||
//
|
||||
AM_REG(SYSTICK, SYSTCSR) = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Delay the specified number of microseconds.
|
||||
//!
|
||||
//! This function will use the SysTick timer to delay until the specified
|
||||
//! number of microseconds have elapsed. It uses the processor clocks and
|
||||
//! takes into account the current CORESEL setting.
|
||||
//!
|
||||
//! @note If the SysTick timer is being used elsewhere, it will be corrupted
|
||||
//! by calling this function.
|
||||
//!
|
||||
//! @return Total number of SysTick ticks delayed.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_systick_delay_us(uint32_t ui32NumUs)
|
||||
{
|
||||
uint32_t ui32nLoops, ui32Ticks, uRet;
|
||||
uint32_t ui32ClkFreq, ui32TicksPerMHz;
|
||||
uint32_t ui32CoreSel = AM_BFR(CLKGEN, CCTRL, CORESEL);
|
||||
|
||||
ui32nLoops = 0;
|
||||
if ( (ui32CoreSel <= AM_HAL_CLKGEN_CORESEL_MAXDIV) && (ui32NumUs >= 2) )
|
||||
{
|
||||
//
|
||||
// Determine clock freq, then whether we need more than 1 iteration.
|
||||
//
|
||||
ui32ClkFreq = AM_HAL_CLKGEN_FREQ_MAX_MHZ >> ui32CoreSel;
|
||||
if ( ui32CoreSel > 1 )
|
||||
{
|
||||
ui32ClkFreq = AM_HAL_CLKGEN_FREQ_MAX_MHZ / (ui32CoreSel + 1);
|
||||
}
|
||||
|
||||
ui32TicksPerMHz = SYSTICK_MAX_TICKS / ui32ClkFreq;
|
||||
if ( ui32NumUs > ui32TicksPerMHz )
|
||||
{
|
||||
//
|
||||
// Get number of required loops, as well as additional ticks.
|
||||
//
|
||||
ui32nLoops = ui32NumUs / ui32TicksPerMHz;
|
||||
ui32NumUs = ui32NumUs % ui32TicksPerMHz;
|
||||
}
|
||||
|
||||
//
|
||||
// Compute the number of ticks required.
|
||||
// Allow for about 2us of call overhead.
|
||||
//
|
||||
ui32Ticks = (ui32NumUs - 2) * ui32ClkFreq;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui32Ticks = 1;
|
||||
}
|
||||
|
||||
uRet = (ui32nLoops * SYSTICK_MAX_TICKS) + ui32Ticks;
|
||||
while ( ui32nLoops )
|
||||
{
|
||||
am_hal_systick_wait_ticks(SYSTICK_MAX_TICKS);
|
||||
ui32nLoops--;
|
||||
}
|
||||
am_hal_systick_wait_ticks(ui32Ticks);
|
||||
|
||||
return uRet;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,86 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_systick.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the SYSTICK.
|
||||
//!
|
||||
//! @addtogroup systick1 System Timer (SYSTICK)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_SYSTICK_H
|
||||
#define AM_HAL_SYSTICK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_systick_start(void);
|
||||
extern void am_hal_systick_stop(void);
|
||||
extern void am_hal_systick_int_enable(void);
|
||||
extern void am_hal_systick_int_disable(void);
|
||||
extern uint32_t am_hal_systick_int_status_get(void);
|
||||
extern void am_hal_systick_reset(void);
|
||||
extern void am_hal_systick_load(uint32_t ui32LoadVal);
|
||||
extern uint32_t am_hal_systick_count(void);
|
||||
extern uint32_t am_hal_systick_wait_ticks(uint32_t u32Ticks);
|
||||
extern uint32_t am_hal_systick_delay_us(uint32_t u32NumUs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_SYSTICK_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,390 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_tpiu.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Support functions for the ARM TPIU module
|
||||
//!
|
||||
//! Provides support functions for configuring the ARM TPIU module
|
||||
//!
|
||||
//! @addtogroup tpiu1 Trace Port Interface Unit (TPIU)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the clock to the TPIU module.
|
||||
//!
|
||||
//! This function enables the clock to the TPIU module.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_tpiu_clock_enable(void)
|
||||
{
|
||||
//
|
||||
// Enable the TPIU clock
|
||||
//
|
||||
AM_REG(MCUCTRL, TPIUCTRL) |= AM_REG_MCUCTRL_TPIUCTRL_ENABLE_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the clock to the TPIU module.
|
||||
//!
|
||||
//! This function disables the clock to the TPIU module.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_tpiu_clock_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the TPIU clock
|
||||
//
|
||||
AM_REG(MCUCTRL, TPIUCTRL) &= ~AM_REG_MCUCTRL_TPIUCTRL_ENABLE_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set the output port width of the TPIU
|
||||
//!
|
||||
//! @param ui32PortWidth - The desired port width (in bits)
|
||||
//!
|
||||
//! This function uses the TPIU_CSPSR register to set the desired output port
|
||||
//! width of the TPIU.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_tpiu_port_width_set(uint32_t ui32PortWidth)
|
||||
{
|
||||
AM_REG(TPIU, CSPSR) = 1 << (ui32PortWidth - 1);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Read the supported_output port width of the TPIU
|
||||
//!
|
||||
//! This function uses the \e TPIU_SSPSR register to set the supported output
|
||||
//! port widths of the TPIU.
|
||||
//!
|
||||
//! @return Current width of the TPIU output port
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_tpiu_supported_port_width_get(void)
|
||||
{
|
||||
uint32_t i, ui32WidthValue;
|
||||
|
||||
//
|
||||
// Read the supported width register.
|
||||
//
|
||||
ui32WidthValue = AM_REG(TPIU, SSPSR);
|
||||
|
||||
//
|
||||
// The register value is encoded in a one-hot format, so the position of
|
||||
// the single set bit determines the actual width of the port.
|
||||
//
|
||||
for (i = 1; i < 32; i++)
|
||||
{
|
||||
//
|
||||
// Check each bit for a '1'. When we find it, our current loop index
|
||||
// will be equal to the port width.
|
||||
//
|
||||
if (ui32WidthValue == (0x1 << (i - 1)))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// We should never get here, but if we do, just return the smallest
|
||||
// possible value for a supported trace port width.
|
||||
//
|
||||
return 1;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Read the output port width of the TPIU
|
||||
//!
|
||||
//! This function uses the \e TPIU_CSPSR register to set the desired output
|
||||
//! port width of the TPIU.
|
||||
//!
|
||||
//! @return Current width of the TPIU output port
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_tpiu_port_width_get(void)
|
||||
{
|
||||
uint32_t ui32Temp;
|
||||
uint32_t ui32Width;
|
||||
|
||||
ui32Width = 1;
|
||||
ui32Temp = AM_REG(TPIU, CSPSR);
|
||||
|
||||
while ( !(ui32Temp & 1) )
|
||||
{
|
||||
ui32Temp = ui32Temp >> 1;
|
||||
ui32Width++;
|
||||
|
||||
if (ui32Width > 32)
|
||||
{
|
||||
ui32Width = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Current width of the TPIU output port.
|
||||
//
|
||||
return ui32Width;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configure the TPIU based on the values in the configuration struct.
|
||||
//!
|
||||
//! @param psConfig - pointer to an tTPIUConfig structure containing the
|
||||
//! desired configuration information.
|
||||
//!
|
||||
//! This function reads the provided configuration structure, and sets the
|
||||
//! relevant TPIU registers to achieve the desired configuration.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_tpiu_configure(am_hal_tpiu_config_t *psConfig)
|
||||
{
|
||||
//
|
||||
// Set the clock freq in the MCUCTRL register.
|
||||
//
|
||||
AM_REG(MCUCTRL, TPIUCTRL) |= psConfig->ui32TraceClkIn;
|
||||
|
||||
//
|
||||
// Set the desired protocol.
|
||||
//
|
||||
AM_REG(TPIU, SPPR) = psConfig->ui32PinProtocol;
|
||||
|
||||
//
|
||||
// Set the parallel port width. This may be redundant if the user has
|
||||
// selected a serial protocol, but we'll set it anyway.
|
||||
//
|
||||
AM_REG(TPIU, CSPSR) = (1 << (psConfig->ui32ParallelPortSize - 1));
|
||||
|
||||
//
|
||||
// Set the clock prescaler.
|
||||
//
|
||||
AM_REG(TPIU, ACPR) = psConfig->ui32ClockPrescaler;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enables the TPIU
|
||||
//!
|
||||
//! This function enables the ARM TPIU by setting the TPIU registers and then
|
||||
//! enabling the TPIU clock source in MCU control register.
|
||||
//!
|
||||
//! @param psConfig - structure for configuration.
|
||||
//! If ui32SetItmBaud, the other structure members are used to set the
|
||||
//! TPIU configuration.
|
||||
//! But for simplicity, ui32SetItmBaud can be set to one of the
|
||||
//! following, in which case all other structure members are ignored.
|
||||
//! In this case, the given BAUD rate is based on a div-by-8 HFRC clock.
|
||||
//! AM_HAL_TPIU_BAUD_57600
|
||||
//! AM_HAL_TPIU_BAUD_115200
|
||||
//! AM_HAL_TPIU_BAUD_230400
|
||||
//! AM_HAL_TPIU_BAUD_460800
|
||||
//! AM_HAL_TPIU_BAUD_500000
|
||||
//! AM_HAL_TPIU_BAUD_1M
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_tpiu_enable(am_hal_tpiu_config_t *psConfig)
|
||||
{
|
||||
uint32_t ui32HFRC, ui32SWOscaler, ui32ITMbitrate;
|
||||
|
||||
ui32ITMbitrate = psConfig->ui32SetItmBaud;
|
||||
|
||||
//
|
||||
// TPIU formatter & flush control register.
|
||||
//
|
||||
AM_REG(TPIU, FFCR) = 0;
|
||||
|
||||
if ( ui32ITMbitrate )
|
||||
{
|
||||
//
|
||||
// Set the Current Parallel Port Size (note - only 1 bit can be set).
|
||||
//
|
||||
AM_REG(TPIU, CSPSR) = AM_REG_TPIU_CSPSR_CWIDTH_1BIT;
|
||||
|
||||
//
|
||||
// Use some default assumptions to set the ITM frequency.
|
||||
//
|
||||
if ( (ui32ITMbitrate < AM_HAL_TPIU_BAUD_57600 ) ||
|
||||
(ui32ITMbitrate > AM_HAL_TPIU_BAUD_2M ) )
|
||||
{
|
||||
ui32ITMbitrate = AM_HAL_TPIU_BAUD_DEFAULT;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the current HFRC frequency.
|
||||
//
|
||||
ui32HFRC = am_hal_clkgen_sysclk_get();
|
||||
|
||||
//
|
||||
// Compute the SWO scaler value.
|
||||
//
|
||||
if ( ui32HFRC != 0xFFFFFFFF )
|
||||
{
|
||||
ui32SWOscaler = ((ui32HFRC / 8) / ui32ITMbitrate) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui32SWOscaler = ( (AM_HAL_CLKGEN_FREQ_MAX_HZ / 8) /
|
||||
AM_HAL_TPIU_BAUD_DEFAULT ) - 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Set the scaler value.
|
||||
//
|
||||
AM_REG(TPIU, ACPR) = AM_REG_TPIU_ACPR_SWOSCALER(ui32SWOscaler);
|
||||
|
||||
//
|
||||
// Set for UART mode
|
||||
//
|
||||
AM_REG(TPIU, SPPR) = AM_REG_TPIU_SPPR_TXMODE_UART;
|
||||
|
||||
//
|
||||
// Make sure we are not in test mode (important for proper deep sleep
|
||||
// operation).
|
||||
//
|
||||
AM_REG(TPIU, ITCTRL) = AM_REG_TPIU_ITCTRL_MODE_NORMAL;
|
||||
|
||||
//
|
||||
// Enable the TPIU clock source in MCU control.
|
||||
// Set TPIU clock for HFRC/8 (3 MHz) operation.
|
||||
//
|
||||
AM_REGn(MCUCTRL, 0, TPIUCTRL) = AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_3MHZ |
|
||||
AM_REG_MCUCTRL_TPIUCTRL_ENABLE_EN;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Set the configuration according to the structure values.
|
||||
//
|
||||
|
||||
//
|
||||
// Set the Asynchronous Clock Prescaler Register.
|
||||
//
|
||||
AM_REG(TPIU, ACPR) = psConfig->ui32ClockPrescaler;
|
||||
|
||||
//
|
||||
// Set the Selected Pin Protocol Register.
|
||||
// e.g. AM_REG_TPIU_SPPR_TXMODE_UART
|
||||
//
|
||||
AM_REG(TPIU, SPPR) = psConfig->ui32PinProtocol;
|
||||
|
||||
//
|
||||
// Set the Current Parallel Port Size (note - only 1 bit can be set).
|
||||
// This may be redundant if the user has selected a serial protocol,
|
||||
// but we'll set it anyway.
|
||||
//
|
||||
AM_REG(TPIU, CSPSR) = (1 << (psConfig->ui32ParallelPortSize - 1));
|
||||
|
||||
//
|
||||
// Make sure we are not in test mode (important for proper deep sleep
|
||||
// operation).
|
||||
//
|
||||
AM_REG(TPIU, ITCTRL) = AM_REG_TPIU_ITCTRL_MODE_NORMAL;
|
||||
|
||||
//
|
||||
// Set the clock freq and enable fields in the MCUCTRL register.
|
||||
//
|
||||
AM_REG(MCUCTRL, TPIUCTRL) = psConfig->ui32TraceClkIn;
|
||||
}
|
||||
|
||||
//
|
||||
// wait for 50us for the data to flush out
|
||||
//
|
||||
am_hal_flash_delay(FLASH_CYCLES_US(50));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disables the TPIU
|
||||
//!
|
||||
//! This function disables the ARM TPIU by disabling the TPIU clock source
|
||||
//! in MCU control register.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_tpiu_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the TPIU clock source in MCU control.
|
||||
//
|
||||
AM_REG(MCUCTRL, TPIUCTRL) = AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_0MHz |
|
||||
AM_REG_MCUCTRL_TPIUCTRL_ENABLE_DIS;
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,196 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_tpiu.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Definitions and structures for working with the TPIU.
|
||||
//!
|
||||
//! @addtogroup tpiu1 Trace Port Interface Unit (TPIU)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_TPIU_H
|
||||
#define AM_HAL_TPIU_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU bit rate defines.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_TPIU_BAUD_57600 (115200 / 2)
|
||||
#define AM_HAL_TPIU_BAUD_115200 (115200 * 1)
|
||||
#define AM_HAL_TPIU_BAUD_230400 (115200 * 2)
|
||||
#define AM_HAL_TPIU_BAUD_460800 (115200 * 4)
|
||||
#define AM_HAL_TPIU_BAUD_500000 (1000000 / 2)
|
||||
#define AM_HAL_TPIU_BAUD_1M (1000000 * 1)
|
||||
#define AM_HAL_TPIU_BAUD_2M (1000000 * 2)
|
||||
#define AM_HAL_TPIU_BAUD_DEFAULT (AM_HAL_TPIU_BAUD_1M)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU register defines.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_TPIU_SSPSR 0xE0040000 //! Supported Parallel Port Sizes
|
||||
#define AM_HAL_TPIU_CSPSR 0xE0040004 //! Current Parallel Port Size
|
||||
#define AM_HAL_TPIU_ACPR 0xE0040010 //! Asynchronous Clock Prescaler
|
||||
#define AM_HAL_TPIU_SPPR 0xE00400F0 //! Selected Pin Protocol
|
||||
#define AM_HAL_TPIU_TYPE 0xE0040FC8 //! TPIU Type
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU ACPR defines.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_TPIU_ACPR_SWOSCALER_M 0x0000FFFF //! SWO baud rate prescalar
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU_SPPR TXMODE defines.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_TPIU_SPPR_PARALLEL 0x00000000
|
||||
#define AM_HAL_TPIU_SPPR_MANCHESTER 0x00000001
|
||||
#define AM_HAL_TPIU_SPPR_NRZ 0x00000002
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU Type defines
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_TPIU_TYPE_NRZVALID 0x00000800
|
||||
#define AM_HAL_TPIU_TYPE_MANCVALID 0x00000400
|
||||
#define AM_HAL_TPIU_TYPE_PTINVALID 0x00000200
|
||||
#define AM_HAL_TPIU_TYPE_FIFOSZ_M 0x000001C0
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU Clock defines
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_TPIU_TRACECLKIN_6MHZ AM_REG_MCUCTRL_TPIUCTRL_TPIUCLKSEL(0)
|
||||
#define AM_HAL_TPIU_TRACECLKIN_3MHZ AM_REG_MCUCTRL_TPIUCTRL_TPIUCLKSEL(1)
|
||||
#define AM_HAL_TPIU_TRACECLKIN_1_5MHZ AM_REG_MCUCTRL_TPIUCTRL_TPIUCLKSEL(2)
|
||||
#define AM_HAL_TPIU_TRACECLKIN_750KHZ AM_REG_MCUCTRL_TPIUCTRL_TPIUCLKSEL(3)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Structure used for configuring the TPIU
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// If ui32SetItmBaud is non-zero, the ITM frequency is set to the given
|
||||
// frequency, and is based on a divide-by-8 HFRC TPIU clock.
|
||||
// If zero, other structure members are used to set the TPIU configuration.
|
||||
//
|
||||
uint32_t ui32SetItmBaud;
|
||||
|
||||
//
|
||||
//! MCU Control TRACECLKIN clock freq.
|
||||
//!
|
||||
//! Valid values for ui32TraceClkIn are:
|
||||
//!
|
||||
//! AM_HAL_TPIU_TRACECLKIN_6MHZ
|
||||
//! AM_HAL_TPIU_TRACECLKIN_3MHZ
|
||||
//! AM_HAL_TPIU_TRACECLKIN_1_5MHZ
|
||||
//! AM_HAL_TPIU_TRACECLKIN_750KHZ
|
||||
//
|
||||
uint32_t ui32TraceClkIn;
|
||||
|
||||
//
|
||||
//! Protocol to use for the TPIU
|
||||
//!
|
||||
//! Valid values for ui32PinProtocol are:
|
||||
//!
|
||||
//! AM_HAL_TPIU_SPPR_PARALLEL
|
||||
//! AM_HAL_TPIU_SPPR_MANCHESTER
|
||||
//! AM_HAL_TPIU_SPPR_NRZ
|
||||
//
|
||||
uint32_t ui32PinProtocol;
|
||||
|
||||
//
|
||||
//! Desired width of the TPIU parallel port
|
||||
//
|
||||
uint32_t ui32ParallelPortSize;
|
||||
|
||||
//
|
||||
//! Desired Clock prescaler value
|
||||
//
|
||||
uint32_t ui32ClockPrescaler;
|
||||
}
|
||||
am_hal_tpiu_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_tpiu_clock_enable(void);
|
||||
extern void am_hal_tpiu_clock_disable(void);
|
||||
extern void am_hal_tpiu_port_width_set(uint32_t ui32PortWidth);
|
||||
extern uint32_t am_hal_tpiu_supported_port_width_get(void);
|
||||
extern uint32_t am_hal_tpiu_port_width_get(void);
|
||||
extern void am_hal_tpiu_configure(am_hal_tpiu_config_t *psConfig);
|
||||
extern void am_hal_tpiu_enable(am_hal_tpiu_config_t *psConfig);
|
||||
extern void am_hal_tpiu_disable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_TPIU_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,349 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_uart.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the UART.
|
||||
//!
|
||||
//! @addtogroup uart1 UART
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_UART_H
|
||||
#define AM_HAL_UART_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name UART Interrupts
|
||||
//! @brief Macro definitions for UART FIFO levels.
|
||||
//!
|
||||
//! They may be used with the \e am_hal_uart_fifo_config() function.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_UART_INT_OVER_RUN AM_REG_UART_IER_OEIM_M
|
||||
#define AM_HAL_UART_INT_BREAK_ERR AM_REG_UART_IER_BEIM_M
|
||||
#define AM_HAL_UART_INT_PARITY_ERR AM_REG_UART_IER_PEIM_M
|
||||
#define AM_HAL_UART_INT_FRAME_ERR AM_REG_UART_IER_FEIM_M
|
||||
#define AM_HAL_UART_INT_RX_TMOUT AM_REG_UART_IER_RTIM_M
|
||||
#define AM_HAL_UART_INT_TX AM_REG_UART_IER_TXIM_M
|
||||
#define AM_HAL_UART_INT_RX AM_REG_UART_IER_RXIM_M
|
||||
#define AM_HAL_UART_INT_DSRM AM_REG_UART_IER_DSRMIM_M
|
||||
#define AM_HAL_UART_INT_DCDM AM_REG_UART_IER_DCDMIM_M
|
||||
#define AM_HAL_UART_INT_CTSM AM_REG_UART_IER_CTSMIM_M
|
||||
#define AM_HAL_UART_INT_RIM AM_REG_UART_IER_RIMIM_M
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name UART FIFO Levels
|
||||
//! @brief Macro definitions for RTV interrupt status bits.
|
||||
//!
|
||||
//! These macros correspond to the bits in the UART interrupt status register.
|
||||
//! They may be used with any of the \e am_hal_uart_int_x() functions.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
//TX
|
||||
#define AM_HAL_UART_TX_FIFO_1_8 AM_REG_UART_IFLS_TXIFLSEL(0)
|
||||
#define AM_HAL_UART_TX_FIFO_1_4 AM_REG_UART_IFLS_TXIFLSEL(1)
|
||||
#define AM_HAL_UART_TX_FIFO_1_2 AM_REG_UART_IFLS_TXIFLSEL(2)
|
||||
#define AM_HAL_UART_TX_FIFO_3_4 AM_REG_UART_IFLS_TXIFLSEL(3)
|
||||
#define AM_HAL_UART_TX_FIFO_7_8 AM_REG_UART_IFLS_TXIFLSEL(4)
|
||||
// RX
|
||||
#define AM_HAL_UART_RX_FIFO_1_8 AM_REG_UART_IFLS_RXIFLSEL(0)
|
||||
#define AM_HAL_UART_RX_FIFO_1_4 AM_REG_UART_IFLS_RXIFLSEL(1)
|
||||
#define AM_HAL_UART_RX_FIFO_1_2 AM_REG_UART_IFLS_RXIFLSEL(2)
|
||||
#define AM_HAL_UART_RX_FIFO_3_4 AM_REG_UART_IFLS_RXIFLSEL(3)
|
||||
#define AM_HAL_UART_RX_FIFO_7_8 AM_REG_UART_IFLS_RXIFLSEL(4)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name UART Status Register
|
||||
//! @brief Macro definitions for UART Status Register Bits.
|
||||
//!
|
||||
//! They may be used with the \e am_hal_uart_status_get() function.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This is the overrun error indicator.
|
||||
#define AM_HAL_UART_RSR_OVERRUN_NOERR AM_REG_UART_RSR_OESTAT_NOERR
|
||||
#define AM_HAL_UART_RSR_OVERRUN_ERROR AM_REG_UART_RSR_OESTAT_ERR
|
||||
|
||||
// This is the break error indicator.
|
||||
#define AM_HAL_UART_RSR_BREAK_NOERR AM_REG_UART_RSR_BESTAT_NOERR
|
||||
#define AM_HAL_UART_RSR_BREAK_ERROR AM_REG_UART_RSR_BESTAT_ERR
|
||||
|
||||
// This is the parity error indicator.
|
||||
#define AM_HAL_UART_RSR_PARITY_NOERR AM_REG_UART_RSR_PESTAT_NOERR
|
||||
#define AM_HAL_UART_RSR_PARITY_ERROR AM_REG_UART_RSR_PESTAT_ERR
|
||||
|
||||
// This is the framing error indicator.
|
||||
#define AM_HAL_UART_RSR_FRAME_ERROR_NOERR AM_REG_UART_RSR_FESTAT_NOERR
|
||||
#define AM_HAL_UART_RSR_FRAME_ERROR_ERROR AM_REG_UART_RSR_FESTAT_ERR
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name UART Flag Register
|
||||
//! @brief Macro definitions for UART Flag Register Bits.
|
||||
//!
|
||||
//! They may be used with the \e am_hal_uart_flags_get() function.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_UART_FR_RING AM_REG_UART_FR_RI_M
|
||||
#define AM_HAL_UART_FR_TX_EMPTY AM_REG_UART_FR_TXFE_XMTFIFO_EMPTY
|
||||
#define AM_HAL_UART_FR_RX_FULL AM_REG_UART_FR_RXFF_RCVFIFO_FULL
|
||||
#define AM_HAL_UART_FR_TX_FULL AM_REG_UART_FR_TXFF_XMTFIFO_FULL
|
||||
#define AM_HAL_UART_FR_RX_EMPTY AM_REG_UART_FR_RXFE_RCVFIFO_EMPTY
|
||||
#define AM_HAL_UART_FR_BUSY AM_REG_UART_FR_BUSY_BUSY
|
||||
#define AM_HAL_UART_FR_DCD_DETECTED AM_REG_UART_FR_DCD_DETECTED
|
||||
#define AM_HAL_UART_FR_DSR_READY AM_REG_UART_FR_DSR_READY
|
||||
#define AM_HAL_UART_FR_CTS AM_REG_UART_FR_CTS_M
|
||||
//! @}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name UART Config Macros
|
||||
//! @brief Macro definitions for available Data bits.
|
||||
//!
|
||||
//! They may be used with the \e am_hal_uart_config_t structure used by \e
|
||||
//! am_hal_uart_config().
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Data bits defines.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_UART_DATA_BITS_8 AM_REG_UART_LCRH_WLEN(3)
|
||||
#define AM_HAL_UART_DATA_BITS_7 AM_REG_UART_LCRH_WLEN(2)
|
||||
#define AM_HAL_UART_DATA_BITS_6 AM_REG_UART_LCRH_WLEN(1)
|
||||
#define AM_HAL_UART_DATA_BITS_5 0
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Parity defines.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_UART_PARITY_NONE 0
|
||||
#define AM_HAL_UART_PARITY_ODD AM_REG_UART_LCRH_PEN_M
|
||||
#define AM_HAL_UART_PARITY_EVEN AM_REG_UART_LCRH_PEN_M | \
|
||||
AM_REG_UART_LCRH_EPS_M
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Flow control defines.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_UART_FLOW_CTRL_NONE 0
|
||||
#define AM_HAL_UART_FLOW_CTRL_RTS_CTS AM_REG_UART_CR_CTSEN_M | \
|
||||
AM_REG_UART_CR_RTSEN_M
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! UART configuration structure
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! Desired Baudrate for the UART.
|
||||
//
|
||||
uint32_t ui32BaudRate;
|
||||
|
||||
//
|
||||
//! Number of data bits.
|
||||
//!
|
||||
//! Valid values for ui32DataBits are:
|
||||
//!
|
||||
//! AM_HAL_UART_DATA_BITS_8
|
||||
//! AM_HAL_UART_DATA_BITS_7
|
||||
//! AM_HAL_UART_DATA_BITS_6
|
||||
//! AM_HAL_UART_DATA_BITS_5
|
||||
//
|
||||
uint32_t ui32DataBits;
|
||||
|
||||
//
|
||||
//! Use two stop bits.
|
||||
//
|
||||
bool bTwoStopBits;
|
||||
|
||||
//
|
||||
//! Parity.
|
||||
//!
|
||||
//! Valid values for ui32Parity are:
|
||||
//!
|
||||
//! AM_HAL_UART_PARITY_NONE
|
||||
//! AM_HAL_UART_PARITY_ODD
|
||||
//! AM_HAL_UART_PARITY_EVEN
|
||||
//
|
||||
uint32_t ui32Parity;
|
||||
|
||||
//
|
||||
//! Flow control.
|
||||
//!
|
||||
//! Valid values for ui32FlowCtrl are:
|
||||
//!
|
||||
//! AM_HAL_UART_FLOW_CTRL_NONE
|
||||
//! AM_HAL_UART_FLOW_CTRL_RTS_CTS
|
||||
//
|
||||
uint32_t ui32FlowCtrl;
|
||||
}
|
||||
am_hal_uart_config_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Function-like macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_uart_ring_buffer_empty(psBuffer) \
|
||||
((psBuffer)->ui32Length == 0)
|
||||
|
||||
#define am_hal_uart_ring_buffer_full(psBuffer) \
|
||||
((psBuffer)->ui32Length == (psBuffer)->ui32Capacity)
|
||||
|
||||
#define am_hal_uart_ring_buffer_data_left(psBuffer) \
|
||||
((psBuffer)->ui32Length)
|
||||
|
||||
#define am_hal_uart_pwrctrl_enable(ui32Module)
|
||||
#define am_hal_uart_pwrctrl_disable(ui32Module)
|
||||
#define am_hal_uart_power_on_restore(ui32Module)
|
||||
#define am_hal_uart_power_off_save(ui32Module)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART ring buffer type.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
volatile uint8_t *pui8Data;
|
||||
volatile uint32_t ui32WriteIndex;
|
||||
volatile uint32_t ui32ReadIndex;
|
||||
volatile uint32_t ui32Length;
|
||||
volatile uint32_t ui32Capacity;
|
||||
}
|
||||
am_hal_uart_ring_buffer_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_uart_config(uint32_t ui32Module,
|
||||
am_hal_uart_config_t *psConfig);
|
||||
extern uint32_t am_hal_uart_status_get(uint32_t ui32Module);
|
||||
extern uint32_t am_hal_uart_int_status_get(uint32_t ui32Module,
|
||||
bool bEnabledOnly);
|
||||
extern void am_hal_uart_int_clear(uint32_t ui32Module,
|
||||
uint32_t ui32Interrupt);
|
||||
extern void am_hal_uart_int_disable(uint32_t ui32Module,
|
||||
uint32_t ui32Interrupt);
|
||||
extern void am_hal_uart_int_enable(uint32_t ui32Module,
|
||||
uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_uart_int_enable_get(uint32_t ui32Module);
|
||||
extern void am_hal_uart_enable(uint32_t ui32Module);
|
||||
extern void am_hal_uart_disable(uint32_t ui32Module);
|
||||
extern void am_hal_uart_clock_enable(uint32_t ui32Module);
|
||||
extern void am_hal_uart_clock_disable(uint32_t ui32Module);
|
||||
extern void am_hal_uart_fifo_config(uint32_t ui32Module, uint32_t ui32LvlCfg);
|
||||
extern uint32_t am_hal_uart_flags_get(uint32_t ui32Module);
|
||||
|
||||
// rx/tx polled
|
||||
extern void am_hal_uart_char_transmit_polled(uint32_t ui32Module,
|
||||
char cChar);
|
||||
extern void am_hal_uart_string_transmit_polled(uint32_t ui32Module,
|
||||
char *pcString);
|
||||
extern void am_hal_uart_char_receive_polled(uint32_t ui32Module,
|
||||
char *pcChar);
|
||||
extern void am_hal_uart_line_receive_polled(uint32_t ui32Module,
|
||||
uint32_t ui32MaxChars,
|
||||
char *pcChar);
|
||||
|
||||
// rx/tx buffered
|
||||
extern void am_hal_uart_init_buffered(uint32_t ui32Module,
|
||||
uint8_t *pui8RxArray,
|
||||
uint32_t ui32RxSize,
|
||||
uint8_t *pui8TxArray,
|
||||
uint32_t ui32TxSize);
|
||||
extern void am_hal_uart_get_status_buffered(uint32_t ui32Module,
|
||||
uint32_t *pui32RxSize,
|
||||
uint32_t *pui32TxSize);
|
||||
extern void am_hal_uart_service_buffered(uint32_t ui32Module,
|
||||
uint32_t ui32Status);
|
||||
extern void am_hal_uart_char_transmit_buffered(uint32_t ui32Module,
|
||||
char cChar);
|
||||
extern void am_hal_uart_string_transmit_buffered(uint32_t ui32Module,
|
||||
char *pcString);
|
||||
extern uint32_t am_hal_uart_char_receive_buffered(uint32_t ui32Module,
|
||||
char *pcString,
|
||||
uint32_t ui32MaxChars);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_UART_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,290 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_vcomp.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for operating the on-chip Voltage Comparator
|
||||
//!
|
||||
//! @addtogroup vcomp1 Voltage Comparator (VCOMP)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configure the Voltage Comparator module.
|
||||
//!
|
||||
//! @param psConfig is a structure containing configuration information for the
|
||||
//! voltage comparator.
|
||||
//!
|
||||
//! This function configures the positive and negative input signals for the
|
||||
//! voltage comparator.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_vcomp_config(const am_hal_vcomp_config_t *psConfig)
|
||||
{
|
||||
//
|
||||
// The configuration word should be a simple OR of the components of the
|
||||
// configuration structure.
|
||||
//
|
||||
AM_REG(VCOMP, CFG) = (psConfig->ui32LevelSelect |
|
||||
psConfig->ui32PosInput |
|
||||
psConfig->ui32NegInput);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set the Voltage Comparator DAC Level Select in Configuration Reg.
|
||||
//!
|
||||
//! @param ui32Level - DAC voltage selector (use macros enumerations)
|
||||
//!
|
||||
//! This function sets the DAC level select in the configuration register.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_vcomp_dac_level_set(uint32_t ui32Level)
|
||||
{
|
||||
//
|
||||
// Insert the supplied level into the vcomp configuration register
|
||||
//
|
||||
AM_BFW(VCOMP, CFG, LVLSEL, ui32Level >> AM_REG_VCOMP_CFG_LVLSEL_S);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Read the state of the voltage comparator.
|
||||
//!
|
||||
//! This function extracts the comparator state from the status register.
|
||||
//!
|
||||
//! @return the voltage comparator state
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
am_hal_vcomp_read(void)
|
||||
{
|
||||
return (AM_BFR(VCOMP, STAT, CMPOUT) == 1);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the voltage comparator.
|
||||
//!
|
||||
//! This function powers up the voltage comparator.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_vcomp_enable(void)
|
||||
{
|
||||
AM_REG(VCOMP, PWDKEY) = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the voltage comparator.
|
||||
//!
|
||||
//! This function powers down the voltage comparator.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_vcomp_disable(void)
|
||||
{
|
||||
AM_REG(VCOMP, PWDKEY) = AM_REG_VCOMP_PWDKEY_KEYVAL;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Read the state of the voltage comparator interrupt status bits.
|
||||
//!
|
||||
//! @param bEnabledOnly - return the status of only the enabled interrupts.
|
||||
//!
|
||||
//! This function extracts the interrupt status bits and returns the raw or
|
||||
//! only the enabled based on bEnabledOnly.
|
||||
//!
|
||||
//! @return Bitwise representation of the current interrupt status.
|
||||
//!
|
||||
//! The return value will be the logical OR of one or more of the following
|
||||
//! values:
|
||||
//!
|
||||
//! AM_HAL_VCOMP_INT_OUTHI
|
||||
//! AM_HAL_VCOMP_INT_OUTLO
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_vcomp_int_status_get(bool bEnabledOnly)
|
||||
{
|
||||
if (bEnabledOnly)
|
||||
{
|
||||
uint32_t u32RetVal = AM_REG(VCOMP, INTSTAT);
|
||||
return u32RetVal & AM_REG(VCOMP, INTEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AM_REG(VCOMP, INTSTAT);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set the state of the voltage comparator interrupt status bits.
|
||||
//!
|
||||
//! @param ui32Interrupt - interrupts to be set.
|
||||
//!
|
||||
//! This function sets the specified interrupt status bits.
|
||||
//!
|
||||
//! ui32Interrupt should be a logical or of:
|
||||
//!
|
||||
//! AM_HAL_VCOMP_INT_OUTHI
|
||||
//! AM_HAL_VCOMP_INT_OUTLO
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_vcomp_int_set(uint32_t ui32Interrupt)
|
||||
{
|
||||
AM_REG(VCOMP, INTSET) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clear the state of the voltage comparator interrupt status bits.
|
||||
//!
|
||||
//! @param ui32Interrupt - interrupts to be cleared.
|
||||
//!
|
||||
//! This function clears the specified interrupt status bits.
|
||||
//!
|
||||
//! ui32Interrupt should be a logical or of:
|
||||
//!
|
||||
//! AM_HAL_VCOMP_INT_OUTHI
|
||||
//! AM_HAL_VCOMP_INT_OUTLO
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_vcomp_int_clear(uint32_t ui32Interrupt)
|
||||
{
|
||||
AM_REG(VCOMP, INTCLR) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the voltage comparator interrupt status bits.
|
||||
//!
|
||||
//! @param ui32Interrupt - interrupts to be enabled.
|
||||
//!
|
||||
//! This function enables desired interrupt status bits.
|
||||
//!
|
||||
//! ui32Interrupt should be a logical or of:
|
||||
//!
|
||||
//! AM_HAL_VCOMP_INT_OUTHI
|
||||
//! AM_HAL_VCOMP_INT_OUTLO
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_vcomp_int_enable(uint32_t ui32Interrupt)
|
||||
{
|
||||
AM_REG(VCOMP, INTEN) |= ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return the enabled, voltage comparator interrupt status bits.
|
||||
//!
|
||||
//! This function returns the enabled interrupt status bits
|
||||
//!
|
||||
//! @return returns the enabled interrupt status bits. The return is a logical
|
||||
//! or of:
|
||||
//!
|
||||
//! AM_HAL_VCOMP_INT_OUTHI
|
||||
//! AM_HAL_VCOMP_INT_OUTLO
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_vcomp_int_enable_get(void)
|
||||
{
|
||||
return AM_REG(VCOMP, INTEN);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the voltage comparator interrupt status bits.
|
||||
//!
|
||||
//! @param ui32Interrupt - interrupts to be disabled.
|
||||
//!
|
||||
//! This function disables desired interrupt status bits.
|
||||
//!
|
||||
//! ui32Interrupt should be a logical or of:
|
||||
//!
|
||||
//! AM_HAL_VCOMP_INT_OUTHI
|
||||
//! AM_HAL_VCOMP_INT_OUTLO
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_vcomp_int_disable(uint32_t ui32Interrupt)
|
||||
{
|
||||
AM_REG(VCOMP, INTEN) &= ~ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,179 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_vcomp.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for operating the on-chip Voltage Comparator
|
||||
//!
|
||||
//! @addtogroup vcomp1 Voltage Comparator (VCOMP)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_VCOMP_H
|
||||
#define AM_HAL_VCOMP_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Positive Input Selection
|
||||
//! @brief Use these macros to determine the positive input to the comparator.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_VCOMP_PSEL_VDDADJ AM_REG_VCOMP_CFG_PSEL_VDDADJ
|
||||
#define AM_HAL_VCOMP_PSEL_VTEMP AM_REG_VCOMP_CFG_PSEL_VTEMP
|
||||
#define AM_HAL_VCOMP_PSEL_VEXT1 AM_REG_VCOMP_CFG_PSEL_VEXT1
|
||||
#define AM_HAL_VCOMP_PSEL_VEXT2 AM_REG_VCOMP_CFG_PSEL_VEXT2
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Negative Input Selection
|
||||
//! @brief Use these macros to determine the negative input to the comparator.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_VCOMP_NSEL_VREFEXT1 AM_REG_VCOMP_CFG_NSEL_VREFEXT1
|
||||
#define AM_HAL_VCOMP_NSEL_VREFEXT2 AM_REG_VCOMP_CFG_NSEL_VREFEXT2
|
||||
#define AM_HAL_VCOMP_NSEL_VREFEXT3 AM_REG_VCOMP_CFG_NSEL_VREFEXT3
|
||||
#define AM_HAL_VCOMP_NSEL_DAC_LEVEL AM_REG_VCOMP_CFG_NSEL_DAC
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Negative Input DAC Selectioin
|
||||
//! @brief Use these macros to determine the NSEL DAC voltage setting
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_0_58V AM_REG_VCOMP_CFG_LVLSEL_0P58V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_0_77V AM_REG_VCOMP_CFG_LVLSEL_0P77V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_0_97V AM_REG_VCOMP_CFG_LVLSEL_0P97V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_1_16V AM_REG_VCOMP_CFG_LVLSEL_1P16V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_1_35V AM_REG_VCOMP_CFG_LVLSEL_1P35V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_1_55V AM_REG_VCOMP_CFG_LVLSEL_1P55V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_1_74V AM_REG_VCOMP_CFG_LVLSEL_1P74V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_1_93V AM_REG_VCOMP_CFG_LVLSEL_1P93V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_2_13V AM_REG_VCOMP_CFG_LVLSEL_2P13V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_2_32V AM_REG_VCOMP_CFG_LVLSEL_2P32V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_2_51V AM_REG_VCOMP_CFG_LVLSEL_2P51V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_2_71V AM_REG_VCOMP_CFG_LVLSEL_2P71V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_2_90V AM_REG_VCOMP_CFG_LVLSEL_2P90V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_3_09V AM_REG_VCOMP_CFG_LVLSEL_3P09V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_3_29V AM_REG_VCOMP_CFG_LVLSEL_3P29V
|
||||
#define AM_HAL_VCOMP_DAC_LVLSEL_3_48V AM_REG_VCOMP_CFG_LVLSEL_3P48V
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Interrupt Status Bits
|
||||
//! @brief Interrupt Status Bits for enable/disble use
|
||||
//!
|
||||
//! These macros may be used to set and clear interrupt bits
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_VCOMP_INT_OUTHI AM_REG_VCOMP_INTEN_OUTHI_M
|
||||
#define AM_HAL_VCOMP_INT_OUTLO AM_REG_VCOMP_INTEN_OUTLOW_M
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configuration struct
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The DAC level setting
|
||||
//
|
||||
uint32_t ui32LevelSelect;
|
||||
|
||||
//
|
||||
//! The "positive" comparator input channel
|
||||
//!
|
||||
//! This channel is usually used as the signal to be monitored.
|
||||
//
|
||||
uint32_t ui32PosInput;
|
||||
|
||||
//
|
||||
//! The "negative" comparator input channel
|
||||
//!
|
||||
//! This channel is usually used as the reference signal.
|
||||
//
|
||||
uint32_t ui32NegInput;
|
||||
}
|
||||
am_hal_vcomp_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_vcomp_config(const am_hal_vcomp_config_t *psConfig);
|
||||
extern void am_hal_vcomp_dac_level_set(uint32_t ui3Level);
|
||||
extern bool am_hal_vcomp_read(void);
|
||||
extern void am_hal_vcomp_enable(void);
|
||||
extern void am_hal_vcomp_disable(void);
|
||||
extern void am_hal_vcomp_int_enable(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_vcomp_int_enable_get(void);
|
||||
extern void am_hal_vcomp_int_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_vcomp_int_clear(uint32_t ui32Interrupt);
|
||||
extern void am_hal_vcomp_int_set(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_vcomp_int_status_get(bool bEnabledOnly);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_VCOMP_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,327 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_wdt.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Hardware abstraction layer for the Watchdog Timer module.
|
||||
//!
|
||||
//! @addtogroup wdt1 Watchdog Timer (WDT)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Dummy variable used to allow reads of WDT registers without triggering
|
||||
// compiler warnings.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static volatile uint32_t g_ui32Bugfix;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configure the watchdog timer.
|
||||
//!
|
||||
//! @param psConfig - pointer to a configuration structure containing the
|
||||
//! desired watchdog settings.
|
||||
//!
|
||||
//! This function will set the watchdog configuration register based on the
|
||||
//! user's desired settings listed in the structure referenced by psConfig. If
|
||||
//! the structure indicates that watchdog interrupts are desired, this function
|
||||
//! will also set the interrupt enable bit in the configuration register.
|
||||
//!
|
||||
//! @note In order to actually receive watchdog interrupt and/or watchdog reset
|
||||
//! events, the caller will also need to make sure that the watchdog interrupt
|
||||
//! vector is enabled in the ARM NVIC, and that watchdog resets are enabled in
|
||||
//! the reset generator module. Otherwise, the watchdog-generated interrupt and
|
||||
//! reset events will have no effect.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_wdt_init(am_hal_wdt_config_t *psConfig)
|
||||
{
|
||||
uint32_t ui32ConfigVal;
|
||||
uint16_t ui16IntCount, ui16ResetCount;
|
||||
bool bResetEnabled = psConfig->ui32Config & AM_HAL_WDT_ENABLE_RESET;
|
||||
bool bInterruptEnabled = psConfig->ui32Config
|
||||
& AM_HAL_WDT_ENABLE_INTERRUPT;
|
||||
|
||||
//
|
||||
// Read the desired settings from the psConfig structure.
|
||||
//
|
||||
ui16IntCount = psConfig->ui16InterruptCount;
|
||||
ui16ResetCount = psConfig->ui16ResetCount;
|
||||
|
||||
//
|
||||
// Write the interrupt and reset count values to a temporary variable.
|
||||
//
|
||||
ui32ConfigVal = psConfig->ui32Config;
|
||||
ui32ConfigVal |= AM_WRITE_SM(AM_REG_WDT_CFG_INTVAL, ui16IntCount);
|
||||
ui32ConfigVal |= AM_WRITE_SM(AM_REG_WDT_CFG_RESVAL, ui16ResetCount);
|
||||
|
||||
//
|
||||
// If interrupts should be enabled, set the appropriate bit in the
|
||||
// temporary variable. Also, enable the interrupt in INTEN register in the
|
||||
// watchdog module.
|
||||
//
|
||||
if ( bInterruptEnabled )
|
||||
{
|
||||
//
|
||||
// Enable the watchdog interrupt if the configuration calls for them.
|
||||
//
|
||||
AM_REGn(WDT, 0, INTEN) |= AM_REG_WDT_INTEN_WDTINT_M;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Disable the watchdog interrupt if the configuration doesn't call for
|
||||
// watchdog interrupts.
|
||||
//
|
||||
AM_REGn(WDT, 0, INTEN) &= ~AM_REG_WDT_INTEN_WDTINT_M;
|
||||
}
|
||||
|
||||
//
|
||||
// If resets should be enabled, set the appropriate bit in the temporary
|
||||
// variable.
|
||||
//
|
||||
if ( bResetEnabled )
|
||||
{
|
||||
|
||||
//
|
||||
// Also enable watchdog resets in the reset module.
|
||||
//
|
||||
AM_REG(RSTGEN, CFG) |= AM_REG_RSTGEN_CFG_WDREN_M;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Disable watchdog resets in the reset module.
|
||||
//
|
||||
AM_REG(RSTGEN, CFG) &= ~AM_REG_RSTGEN_CFG_WDREN_M;
|
||||
}
|
||||
|
||||
//
|
||||
// Write the saved value to the watchdog configuration register.
|
||||
//
|
||||
AM_REGn(WDT, 0, CFG) = ui32ConfigVal;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Starts the watchdog timer.
|
||||
//!
|
||||
//! Enables the watchdog timer tick using the 'enable' bit in the watchdog
|
||||
//! configuration register. This function does not perform any locking of the
|
||||
//! watchdog timer, so it can be disabled or reconfigured later.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_wdt_start(void)
|
||||
{
|
||||
//
|
||||
// Make sure the watchdog timer is in the "reset" state, and then set the
|
||||
// enable bit to start counting.
|
||||
//
|
||||
AM_REGn(WDT, 0, CFG) |= AM_REG_WDT_CFG_WDTEN_M;
|
||||
AM_REGn(WDT, 0, RSTRT) = AM_REG_WDT_RSTRT_RSTRT_KEYVALUE;
|
||||
|
||||
//
|
||||
// Bug workaround for all Apollo silicon.
|
||||
//
|
||||
g_ui32Bugfix = AM_REGn(WDT, 0, RSTRT);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Stops the watchdog timer.
|
||||
//!
|
||||
//! Disables the watchdog timer tick by clearing the 'enable' bit in the
|
||||
//! watchdog configuration register.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_wdt_halt(void)
|
||||
{
|
||||
|
||||
//
|
||||
// Clear the watchdog enable bit.
|
||||
//
|
||||
AM_REGn(WDT, 0, CFG) &= ~AM_REG_WDT_CFG_WDTEN_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Locks the watchdog configuration and starts the watchdog timer.
|
||||
//!
|
||||
//! This function sets the watchdog "lock" register, which prevents software
|
||||
//! from re-configuring the watchdog. This action will also set the enable bit
|
||||
//! for the watchdog timer, so it will start counting immediately.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_wdt_lock_and_start(void)
|
||||
{
|
||||
//
|
||||
// Write the 'key' value to the watchdog lock register.
|
||||
//
|
||||
AM_REGn(WDT, 0, LOCK) = AM_REG_WDT_LOCK_LOCK_KEYVALUE;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Read the state of the wdt interrupt status.
|
||||
//!
|
||||
//! @param bEnabledOnly - return the status of only the enabled interrupts.
|
||||
//!
|
||||
//! This function extracts the interrupt status bits and returns the enabled or
|
||||
//! raw based on bEnabledOnly.
|
||||
//!
|
||||
//! @return WDT interrupt status.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_wdt_int_status_get(bool bEnabledOnly)
|
||||
{
|
||||
if (bEnabledOnly)
|
||||
{
|
||||
uint32_t u32RetVal = AM_REG(WDT, INTSTAT);
|
||||
return u32RetVal & AM_REG(WDT, INTEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AM_REG(WDT, INTSTAT);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set the state of the wdt interrupt status bit.
|
||||
//!
|
||||
//! This function sets the interrupt bit.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_wdt_int_set(void)
|
||||
{
|
||||
AM_REG(WDT, INTSET) = AM_REG_WDT_INTSET_WDTINT_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clear the state of the wdt interrupt status bit.
|
||||
//!
|
||||
//! This function clear the interrupt bit.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_wdt_int_clear(void)
|
||||
{
|
||||
AM_REGn(WDT, 0, INTCLR) = AM_REG_WDT_INTCLR_WDTINT_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the wdt interrupt.
|
||||
//!
|
||||
//! This function enable the interrupt.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_wdt_int_enable(void)
|
||||
{
|
||||
AM_REG(WDT, INTEN) |= AM_REG_WDT_INTEN_WDTINT_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return the enabled WDT interrupts.
|
||||
//!
|
||||
//! This function returns the enabled WDT interrupts.
|
||||
//!
|
||||
//! @return enabled WDT interrupts.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_wdt_int_enable_get(void)
|
||||
{
|
||||
return AM_REG(WDT, INTEN);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the wdt interrupt.
|
||||
//!
|
||||
//! This function disablee the interrupt.
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_wdt_int_disable(void)
|
||||
{
|
||||
AM_REG(WDT, INTEN) &= ~AM_REG_WDT_INTEN_WDTINT_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,170 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_wdt.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Hardware abstraction layer for the Watchdog Timer module.
|
||||
//!
|
||||
//! @addtogroup wdt1 Watchdog Timer (WDT)
|
||||
//! @ingroup apollo1hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_WDT_H
|
||||
#define AM_HAL_WDT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name WDT Enable Reset in the WDT Configuration.
|
||||
//! @brief Macro definitions for WDT Reset Enable.
|
||||
//!
|
||||
//! These macros may be used with the am_hal_wdt_config_t structure to enable
|
||||
//! the watch dog timer to generate resets to the chip.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_WDT_ENABLE_RESET AM_REG_WDT_CFG_RESEN(1)
|
||||
#define AM_HAL_WDT_DISABLE_RESET AM_REG_WDT_CFG_RESEN(0)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name WDT Enable Interrupt Generation from the WDT Configuration.
|
||||
//! @brief Macro definitions for WDT Interrupt Enable.
|
||||
//!
|
||||
//! These macros may be used with the am_hal_wdt_config_t structure to enable
|
||||
//! the watch dog timer to generate generate WDT interrupts.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_WDT_ENABLE_INTERRUPT AM_REG_WDT_CFG_INTEN(1)
|
||||
#define AM_HAL_WDT_DISABLE_INTERRUPT AM_REG_WDT_CFG_INTEN(0)
|
||||
//! @}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Watchdog timer configuration structure.
|
||||
//!
|
||||
//! This structure is made to be used with the am_hal_wdt_init() function. It
|
||||
//! describes the configuration of the watchdog timer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//! Configuration Values for watchdog timer
|
||||
//! event is generated.
|
||||
uint32_t ui32Config;
|
||||
|
||||
//! Number of watchdog timer ticks allowed before a watchdog interrupt
|
||||
//! event is generated.
|
||||
uint16_t ui16InterruptCount;
|
||||
|
||||
//! Number of watchdog timer ticks allowed before the watchdog will issue a
|
||||
//! system reset.
|
||||
uint16_t ui16ResetCount;
|
||||
}
|
||||
am_hal_wdt_config_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Restarts the watchdog timer ("Pets" the dog)
|
||||
//!
|
||||
//! This function restarts the watchdog timer from the beginning, preventing
|
||||
//! any interrupt or reset even from occuring until the next time the watchdog
|
||||
//! timer expires.
|
||||
//!
|
||||
//! @note This function includes a workaround for Rev A. silicon, where the
|
||||
//! WDT_RSTRT register must be read back in order to function correctly.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define am_hal_wdt_restart() \
|
||||
do \
|
||||
{ \
|
||||
AM_REGn(WDT, 0, RSTRT) = AM_REG_WDT_RSTRT_RSTRT_KEYVALUE; \
|
||||
(void)AM_REGn(WDT, 0, RSTRT); \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_wdt_init(am_hal_wdt_config_t *psConfig);
|
||||
extern void am_hal_wdt_start(void);
|
||||
extern void am_hal_wdt_halt(void);
|
||||
extern void am_hal_wdt_lock_and_start(void);
|
||||
extern void am_hal_wdt_int_enable(void);
|
||||
extern uint32_t am_hal_wdt_int_enable_get(void);
|
||||
extern void am_hal_wdt_int_disable(void);
|
||||
extern void am_hal_wdt_int_clear(void);
|
||||
extern void am_hal_wdt_int_set(void);
|
||||
extern uint32_t am_hal_wdt_int_status_get(bool bEnabledOnly);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_WDT_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,164 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# Makefile - Rules for building the libraries, examples and docs.
|
||||
#
|
||||
# Copyright (c) 2020, Ambiq Micro
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# Third party software included in this distribution is subject to the
|
||||
# additional license terms as defined in the /docs/licenses directory.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
#
|
||||
#******************************************************************************
|
||||
TARGET := libam_hal
|
||||
COMPILERNAME := gcc
|
||||
PROJECT := libam_hal_gcc
|
||||
CONFIG := bin
|
||||
|
||||
SHELL:=/bin/bash
|
||||
#### Setup ####
|
||||
|
||||
TOOLCHAIN ?= arm-none-eabi
|
||||
PART = apollo
|
||||
CPU = cortex-m4
|
||||
FPU = fpv4-sp-d16
|
||||
#FABI = softfp
|
||||
FABI = hard
|
||||
|
||||
#### Required Executables ####
|
||||
CC = $(TOOLCHAIN)-gcc
|
||||
GCC = $(TOOLCHAIN)-gcc
|
||||
CPP = $(TOOLCHAIN)-cpp
|
||||
LD = $(TOOLCHAIN)-ld
|
||||
CP = $(TOOLCHAIN)-objcopy
|
||||
OD = $(TOOLCHAIN)-objdump
|
||||
RD = $(TOOLCHAIN)-readelf
|
||||
AR = $(TOOLCHAIN)-ar
|
||||
SIZE = $(TOOLCHAIN)-size
|
||||
RM = $(shell which rm 2>/dev/null)
|
||||
|
||||
EXECUTABLES = CC LD CP OD AR RD SIZE GCC
|
||||
K := $(foreach exec,$(EXECUTABLES),\
|
||||
$(if $(shell which $($(exec)) 2>/dev/null),,\
|
||||
$(info $(exec) not found on PATH ($($(exec))).)$(exec)))
|
||||
$(if $(strip $(value K)),$(info Required Program(s) $(strip $(value K)) not found))
|
||||
|
||||
ifneq ($(strip $(value K)),)
|
||||
all clean:
|
||||
$(info Tools $(TOOLCHAIN)-$(COMPILERNAME) not installed.)
|
||||
$(RM) -rf bin
|
||||
else
|
||||
|
||||
DEFINES = -DAM_PART_APOLLO
|
||||
DEFINES+= -DAM_DEBUG_ASSERT
|
||||
DEFINES+= -Dgcc
|
||||
|
||||
INCLUDES = -I../../../../mcu/apollo
|
||||
|
||||
VPATH = ..
|
||||
|
||||
SRC = am_hal_adc.c
|
||||
SRC += am_hal_clkgen.c
|
||||
SRC += am_hal_ctimer.c
|
||||
SRC += am_hal_debug.c
|
||||
SRC += am_hal_flash.c
|
||||
SRC += am_hal_global.c
|
||||
SRC += am_hal_gpio.c
|
||||
SRC += am_hal_i2c_bit_bang.c
|
||||
SRC += am_hal_interrupt.c
|
||||
SRC += am_hal_iom.c
|
||||
SRC += am_hal_ios.c
|
||||
SRC += am_hal_itm.c
|
||||
SRC += am_hal_mcuctrl.c
|
||||
SRC += am_hal_otp.c
|
||||
SRC += am_hal_queue.c
|
||||
SRC += am_hal_reset.c
|
||||
SRC += am_hal_rtc.c
|
||||
SRC += am_hal_sysctrl.c
|
||||
SRC += am_hal_systick.c
|
||||
SRC += am_hal_tpiu.c
|
||||
SRC += am_hal_uart.c
|
||||
SRC += am_hal_vcomp.c
|
||||
SRC += am_hal_wdt.c
|
||||
|
||||
CSRC = $(filter %.c,$(SRC))
|
||||
ASRC = $(filter %.s,$(SRC))
|
||||
|
||||
OBJS = $(CSRC:%.c=$(CONFIG)/%.o)
|
||||
OBJS+= $(ASRC:%.s=$(CONFIG)/%.o)
|
||||
|
||||
DEPS = $(CSRC:%.c=$(CONFIG)/%.d)
|
||||
DEPS+= $(ASRC:%.s=$(CONFIG)/%.d)
|
||||
|
||||
CFLAGS = -mthumb -mcpu=$(CPU) -mfpu=$(FPU) -mfloat-abi=$(FABI)
|
||||
CFLAGS+= -ffunction-sections -fdata-sections
|
||||
CFLAGS+= -MMD -MP -std=c99 -Wall
|
||||
# Libraries O3 for production, examples O0 for debug.
|
||||
CFLAGS+= -O3
|
||||
CFLAGS+= $(DEFINES)
|
||||
CFLAGS+= $(INCLUDES)
|
||||
CFLAGS+=
|
||||
|
||||
# Additional user specified CFLAGS
|
||||
CFLAGS+=$(EXTRA_CFLAGS)
|
||||
|
||||
ODFLAGS = -S
|
||||
|
||||
#### Rules ####
|
||||
all: directories $(CONFIG)/$(TARGET).a
|
||||
|
||||
directories: $(CONFIG)
|
||||
|
||||
$(CONFIG):
|
||||
@mkdir -p $@
|
||||
|
||||
$(CONFIG)/%.o: %.c $(CONFIG)/%.d $(INCS)
|
||||
@echo " Compiling $(COMPILERNAME) $<" ;\
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
$(CONFIG)/%.o: %.s $(CONFIG)/%.d $(INCS)
|
||||
@echo " Assembling $(COMPILERNAME) $<" ;\
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
$(CONFIG)/$(TARGET).a: $(OBJS)
|
||||
@echo " Library $(COMPILERNAME) $@" ;\
|
||||
$(AR) rsvc $@ $(OBJS)
|
||||
|
||||
clean:
|
||||
@echo "Cleaning..." ;\
|
||||
$(RM) -f $(OBJS) $(DEPS) \
|
||||
$(CONFIG)/$(TARGET).a
|
||||
|
||||
$(CONFIG)/%.d: ;
|
||||
|
||||
# Automatically include any generated dependencies
|
||||
-include $(DEPS)
|
||||
endif
|
||||
.PHONY: all clean directories
|
||||
@@ -0,0 +1,102 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# Makefile - Rules for building the libraries, examples and docs.
|
||||
#
|
||||
# Copyright (c) 2020, Ambiq Micro
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# Third party software included in this distribution is subject to the
|
||||
# additional license terms as defined in the /docs/licenses directory.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
#
|
||||
#******************************************************************************
|
||||
TARGET := libam_hal
|
||||
COMPILERNAME := iar
|
||||
PROJECT := libam_hal_iar
|
||||
CONFIG := bin
|
||||
AM_SoftwareRoot ?= ../../..
|
||||
|
||||
SHELL:=/bin/bash
|
||||
#### Required Executables ####
|
||||
K := $(shell type -p IarBuild.exe)
|
||||
RM = $(shell which rm 2>/dev/null)
|
||||
|
||||
ifeq ($(K),)
|
||||
all clean:
|
||||
$(info Tools w/$(COMPILERNAME) not installed.)
|
||||
$(RM) -rf bin
|
||||
else
|
||||
|
||||
LIBS = ${libraries}
|
||||
INCS = ${incs}
|
||||
|
||||
all: directories $(CONFIG)/$(TARGET).a
|
||||
|
||||
# Source Dependencies must be defined before they are used.
|
||||
SRCS = .././am_hal_adc.c
|
||||
SRCS += .././am_hal_clkgen.c
|
||||
SRCS += .././am_hal_ctimer.c
|
||||
SRCS += .././am_hal_debug.c
|
||||
SRCS += .././am_hal_flash.c
|
||||
SRCS += .././am_hal_global.c
|
||||
SRCS += .././am_hal_gpio.c
|
||||
SRCS += .././am_hal_i2c_bit_bang.c
|
||||
SRCS += .././am_hal_interrupt.c
|
||||
SRCS += .././am_hal_iom.c
|
||||
SRCS += .././am_hal_ios.c
|
||||
SRCS += .././am_hal_itm.c
|
||||
SRCS += .././am_hal_mcuctrl.c
|
||||
SRCS += .././am_hal_otp.c
|
||||
SRCS += .././am_hal_queue.c
|
||||
SRCS += .././am_hal_reset.c
|
||||
SRCS += .././am_hal_rtc.c
|
||||
SRCS += .././am_hal_sysctrl.c
|
||||
SRCS += .././am_hal_systick.c
|
||||
SRCS += .././am_hal_tpiu.c
|
||||
SRCS += .././am_hal_uart.c
|
||||
SRCS += .././am_hal_vcomp.c
|
||||
SRCS += .././am_hal_wdt.c
|
||||
|
||||
$(CONFIG)/$(TARGET).a: $(LIBS) $(INCS) $(SRCS)
|
||||
IarBuild.exe libam_hal.ewp -make Debug -log info
|
||||
|
||||
directories: $(CONFIG)
|
||||
|
||||
$(CONFIG):
|
||||
@mkdir -p $@
|
||||
|
||||
# BSP's need this.
|
||||
|
||||
clean:
|
||||
@echo Cleaning... ;\
|
||||
IarBuild.exe libam_hal.ewp -clean Debug -log all
|
||||
|
||||
endif
|
||||
.PHONY: all clean directories
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\libam_hal.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# Makefile - Rules for building the libraries, examples and docs.
|
||||
#
|
||||
# Copyright (c) 2020, Ambiq Micro
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# Third party software included in this distribution is subject to the
|
||||
# additional license terms as defined in the /docs/licenses directory.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
#
|
||||
#******************************************************************************
|
||||
TARGET := libam_hal
|
||||
COMPILERNAME := Keil
|
||||
PROJECT := libam_hal_Keil
|
||||
CONFIG := bin
|
||||
AM_SoftwareRoot ?= ../../../..
|
||||
|
||||
SHELL:=/bin/bash
|
||||
#### Required Executables ####
|
||||
K := $(shell type -p UV4.exe)
|
||||
RM := $(shell which rm 2>/dev/null)
|
||||
|
||||
ifeq ($(K),)
|
||||
all clean:
|
||||
$(info Tools w/$(COMPILERNAME) not installed.)
|
||||
$(RM) -rf bin
|
||||
else
|
||||
|
||||
LIBS =
|
||||
INCS = ../../../../mcu/apollo
|
||||
|
||||
all: directories $(CONFIG)/$(TARGET).lib
|
||||
|
||||
# Source Dependencies must be defined before they are used.
|
||||
SRCS = .././am_hal_adc.c
|
||||
SRCS += .././am_hal_clkgen.c
|
||||
SRCS += .././am_hal_ctimer.c
|
||||
SRCS += .././am_hal_debug.c
|
||||
SRCS += .././am_hal_flash.c
|
||||
SRCS += .././am_hal_global.c
|
||||
SRCS += .././am_hal_gpio.c
|
||||
SRCS += .././am_hal_i2c_bit_bang.c
|
||||
SRCS += .././am_hal_interrupt.c
|
||||
SRCS += .././am_hal_iom.c
|
||||
SRCS += .././am_hal_ios.c
|
||||
SRCS += .././am_hal_itm.c
|
||||
SRCS += .././am_hal_mcuctrl.c
|
||||
SRCS += .././am_hal_otp.c
|
||||
SRCS += .././am_hal_queue.c
|
||||
SRCS += .././am_hal_reset.c
|
||||
SRCS += .././am_hal_rtc.c
|
||||
SRCS += .././am_hal_sysctrl.c
|
||||
SRCS += .././am_hal_systick.c
|
||||
SRCS += .././am_hal_tpiu.c
|
||||
SRCS += .././am_hal_uart.c
|
||||
SRCS += .././am_hal_vcomp.c
|
||||
SRCS += .././am_hal_wdt.c
|
||||
|
||||
$(CONFIG)/$(TARGET).lib: $(LIBS) $(INCS) $(SRCS)
|
||||
UV4.exe -b -t "libam_hal" libam_hal.uvprojx -j0 || [ $$? -eq 1 ]
|
||||
|
||||
directories: $(CONFIG)
|
||||
|
||||
$(CONFIG):
|
||||
@mkdir -p $@
|
||||
|
||||
# BSP's need this.
|
||||
|
||||
clean:
|
||||
@echo Cleaning... ;\
|
||||
$(RM) -rf $(CONFIG)
|
||||
|
||||
endif
|
||||
.PHONY: all clean directories
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,572 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
|
||||
|
||||
<SchemaVersion>1.0</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Extensions>
|
||||
<cExt>*.c</cExt>
|
||||
<aExt>*.s*; *.src; *.a*</aExt>
|
||||
<oExt>*.obj</oExt>
|
||||
<lExt>*.lib</lExt>
|
||||
<tExt>*.txt; *.h; *.inc</tExt>
|
||||
<pExt>*.plm</pExt>
|
||||
<CppX>*.cpp</CppX>
|
||||
<nMigrate>0</nMigrate>
|
||||
</Extensions>
|
||||
|
||||
<DaveTm>
|
||||
<dwLowDateTime>0</dwLowDateTime>
|
||||
<dwHighDateTime>0</dwHighDateTime>
|
||||
</DaveTm>
|
||||
|
||||
<Target>
|
||||
<TargetName>libam_hal</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<TargetOption>
|
||||
<CLKADS>24000000</CLKADS>
|
||||
<OPTTT>
|
||||
<gFlags>1</gFlags>
|
||||
<BeepAtEnd>1</BeepAtEnd>
|
||||
<RunSim>0</RunSim>
|
||||
<RunTarget>1</RunTarget>
|
||||
<RunAbUc>0</RunAbUc>
|
||||
</OPTTT>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<FlashByte>65535</FlashByte>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
</OPTHX>
|
||||
<OPTLEX>
|
||||
<PageWidth>79</PageWidth>
|
||||
<PageLength>66</PageLength>
|
||||
<TabStop>8</TabStop>
|
||||
<ListingPath>.\Listings\</ListingPath>
|
||||
</OPTLEX>
|
||||
<ListingPage>
|
||||
<CreateCListing>1</CreateCListing>
|
||||
<CreateAListing>1</CreateAListing>
|
||||
<CreateLListing>1</CreateLListing>
|
||||
<CreateIListing>0</CreateIListing>
|
||||
<AsmCond>1</AsmCond>
|
||||
<AsmSymb>1</AsmSymb>
|
||||
<AsmXref>0</AsmXref>
|
||||
<CCond>1</CCond>
|
||||
<CCode>0</CCode>
|
||||
<CListInc>0</CListInc>
|
||||
<CSymb>0</CSymb>
|
||||
<LinkerCodeListing>0</LinkerCodeListing>
|
||||
</ListingPage>
|
||||
<OPTXL>
|
||||
<LMap>1</LMap>
|
||||
<LComments>1</LComments>
|
||||
<LGenerateSymbols>1</LGenerateSymbols>
|
||||
<LLibSym>1</LLibSym>
|
||||
<LLines>1</LLines>
|
||||
<LLocSym>1</LLocSym>
|
||||
<LPubSym>1</LPubSym>
|
||||
<LXref>0</LXref>
|
||||
<LExpSel>0</LExpSel>
|
||||
</OPTXL>
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>255</CpuCode>
|
||||
<DebugOpt>
|
||||
<uSim>0</uSim>
|
||||
<uTrg>1</uTrg>
|
||||
<sLdApp>1</sLdApp>
|
||||
<sGomain>1</sGomain>
|
||||
<sRbreak>1</sRbreak>
|
||||
<sRwatch>1</sRwatch>
|
||||
<sRmem>1</sRmem>
|
||||
<sRfunc>1</sRfunc>
|
||||
<sRbox>1</sRbox>
|
||||
<tLdApp>0</tLdApp>
|
||||
<tGomain>0</tGomain>
|
||||
<tRbreak>1</tRbreak>
|
||||
<tRwatch>1</tRwatch>
|
||||
<tRmem>1</tRmem>
|
||||
<tRfunc>0</tRfunc>
|
||||
<tRbox>1</tRbox>
|
||||
<tRtrace>1</tRtrace>
|
||||
<sRSysVw>1</sRSysVw>
|
||||
<tRSysVw>1</tRSysVw>
|
||||
<sRunDeb>0</sRunDeb>
|
||||
<sLrtime>0</sLrtime>
|
||||
<bEvRecOn>1</bEvRecOn>
|
||||
<nTsel>3</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
<sDlgPa></sDlgPa>
|
||||
<sIfile></sIfile>
|
||||
<tDll></tDll>
|
||||
<tDllPa></tDllPa>
|
||||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile>.\Dbg_RAM.ini</tIfile>
|
||||
<pMon>Segger\JL2CM3.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGUARM</Key>
|
||||
<Name>/</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>JL2CM3</Key>
|
||||
<Name>-U483025288 -O462 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO1 -TC3000000 -TP21 -TDS2 -TDT0 -TDC1F -TIE1 -TIP8 -TB1 -TFE0 -FO7 -FD10000000 -FC4000 -FN1 -FF0Apollo.FLM -FS00 -FL080000 -FP0($Device:APOLLO512-KBR$Flash\Apollo.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMRTXEVENTFLAGS</Key>
|
||||
<Name>-L70 -Z18 -C0 -M0 -T1</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGTARM</Key>
|
||||
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMDBGFLAGS</Key>
|
||||
<Name></Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DbgCM</Key>
|
||||
<Name>-U-O206 -O206 -S2 -C0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO1 -TC3000000 -TP21 -TDS2 -TDT0 -TDC1F -TIE1 -TIP8 -FO7 -FD10000000 -FC4000 -FN1 -FF0Apollo -FS00 -FL080000</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>UL2CM3</Key>
|
||||
<Name>-UV0236LFE -O462 -S0 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO1 -TC3000000 -TP21 -TDS8002 -TDT0 -TDC1F -TIE1 -TIP8 -FO7 -FD10000000 -FC4000 -FN1 -FF0Apollo.FLM -FS00 -FL080000 -FP0($$Device:Apollo_512_BGA$Flash\Apollo.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
</Tracepoint>
|
||||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>1</periodic>
|
||||
<aLwin>1</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
<aPa>0</aPa>
|
||||
<viewmode>1</viewmode>
|
||||
<vrSel>0</vrSel>
|
||||
<aSym>0</aSym>
|
||||
<aTbox>0</aTbox>
|
||||
<AscS1>0</AscS1>
|
||||
<AscS2>0</AscS2>
|
||||
<AscS3>0</AscS3>
|
||||
<aSer3>0</aSer3>
|
||||
<eProf>0</eProf>
|
||||
<aLa>0</aLa>
|
||||
<aPa1>0</aPa1>
|
||||
<AscS4>0</AscS4>
|
||||
<aSer4>1</aSer4>
|
||||
<StkLoc>0</StkLoc>
|
||||
<TrcWin>0</TrcWin>
|
||||
<newCpu>0</newCpu>
|
||||
<uProt>0</uProt>
|
||||
</DebugFlag>
|
||||
<LintExecutable></LintExecutable>
|
||||
<LintConfigFile></LintConfigFile>
|
||||
<bLintAuto>0</bLintAuto>
|
||||
<Lin2Executable></Lin2Executable>
|
||||
<Lin2ConfigFile></Lin2ConfigFile>
|
||||
<bLin2Auto>0</bLin2Auto>
|
||||
<bAutoGenD>0</bAutoGenD>
|
||||
<bAuto2GenD>0</bAuto2GenD>
|
||||
</TargetOption>
|
||||
</Target>
|
||||
|
||||
<Group>
|
||||
<GroupName>source_files</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>1</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_adc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_adc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>2</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_clkgen.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_clkgen.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>3</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_ctimer.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_ctimer.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_debug.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_debug.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_flash.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_flash.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_global.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_global.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_gpio.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_gpio.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_i2c_bit_bang.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_i2c_bit_bang.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_interrupt.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_interrupt.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_iom.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_iom.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_ios.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_ios.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_itm.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_itm.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_mcuctrl.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_mcuctrl.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_otp.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_otp.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_queue.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_queue.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_reset.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_reset.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_rtc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_rtc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_sysctrl.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_sysctrl.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_systick.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_systick.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_tpiu.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_tpiu.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_uart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_uart.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_vcomp.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_vcomp.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.././am_hal_wdt.c</PathWithFileName>
|
||||
<FilenameWithoutPath>am_hal_wdt.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
</ProjectOpt>
|
||||
|
||||
@@ -0,0 +1,510 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>libam_hal</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pArmCC></pArmCC>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>APOLLO512-KBR</Device>
|
||||
<Vendor>Ambiq Micro</Vendor>
|
||||
<PackID>AmbiqMicro.Apollo_DFP.1.0.0</PackID>
|
||||
<PackURL>http://s3.asia.ambiqmicro.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x10000000,0x10000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD10000000 -FC2000 -FN1 -FF0Apollo -FS00 -FL010000 -FP0($Device:APOLLO512-KBR$Flash\Apollo.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:APOLLO512-KBR$Device\Include\Apollo.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>$$Device:APOLLO512-KBR$SVD\apollo.svd</SFDFile>
|
||||
<bCustSvd>0</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\bin\</OutputDirectory>
|
||||
<OutputName>libam_hal</OutputName>
|
||||
<CreateExecutable>0</CreateExecutable>
|
||||
<CreateLib>1</CreateLib>
|
||||
<CreateHexFile>0</CreateHexFile>
|
||||
<DebugInformation>0</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\Listings\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> -MPU</SimDllArguments>
|
||||
<SimDlgDll>DCM.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM4</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> -MPU</TargetDllArguments>
|
||||
<TargetDlgDll>TCM.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM4</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3></Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>1</AdsALst>
|
||||
<AdsACrf>1</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>1</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>1</AdsLsun>
|
||||
<AdsLven>1</AdsLven>
|
||||
<AdsLsxf>1</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M4"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>2</RvdsVP>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>0</useUlib>
|
||||
<EndSel>0</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x10000000</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x80000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x80000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x10000000</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>4</Optim>
|
||||
<oTime>1</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>2</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>1</v6Lang>
|
||||
<v6LangP>1</v6LangP>
|
||||
<vShortEn>1</vShortEn>
|
||||
<vShortWch>1</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define>AM_PART_APOLLO AM_DEBUG_ASSERT keil</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>../../../../mcu/apollo</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>0</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x0</TextAddressRange>
|
||||
<DataAddressRange>0x10000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile></ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc></Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>source_files</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>am_hal_adc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_adc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_clkgen.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_clkgen.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_ctimer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_ctimer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_debug.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_debug.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_global.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_global.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_i2c_bit_bang.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_i2c_bit_bang.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_interrupt.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_interrupt.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_iom.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_iom.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_ios.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_ios.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_itm.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_itm.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_mcuctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_mcuctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_otp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_otp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_reset.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_reset.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_rtc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_rtc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_sysctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_sysctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_systick.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_systick.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_tpiu.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_tpiu.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_vcomp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_vcomp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>am_hal_wdt.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../am_hal_wdt.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>lib</GroupName>
|
||||
<Files>
|
||||
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,922 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_adc.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the ADC module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_ADC_H
|
||||
#define AM_REG_ADC_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_ADC_NUM_MODULES 1
|
||||
#define AM_REG_ADCn(n) \
|
||||
(REG_ADC_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_ADC_CFG_O 0x00000000
|
||||
#define AM_REG_ADC_STAT_O 0x00000004
|
||||
#define AM_REG_ADC_SWT_O 0x00000008
|
||||
#define AM_REG_ADC_SL0CFG_O 0x0000000C
|
||||
#define AM_REG_ADC_SL1CFG_O 0x00000010
|
||||
#define AM_REG_ADC_SL2CFG_O 0x00000014
|
||||
#define AM_REG_ADC_SL3CFG_O 0x00000018
|
||||
#define AM_REG_ADC_SL4CFG_O 0x0000001C
|
||||
#define AM_REG_ADC_SL5CFG_O 0x00000020
|
||||
#define AM_REG_ADC_SL6CFG_O 0x00000024
|
||||
#define AM_REG_ADC_SL7CFG_O 0x00000028
|
||||
#define AM_REG_ADC_WLIM_O 0x0000002C
|
||||
#define AM_REG_ADC_FIFO_O 0x00000030
|
||||
#define AM_REG_ADC_INTEN_O 0x00000200
|
||||
#define AM_REG_ADC_INTSTAT_O 0x00000204
|
||||
#define AM_REG_ADC_INTCLR_O 0x00000208
|
||||
#define AM_REG_ADC_INTSET_O 0x0000020C
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_INTEN - ADC Interrupt registers: Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Window comparator voltage incursion interrupt.
|
||||
#define AM_REG_ADC_INTEN_WCINC_S 5
|
||||
#define AM_REG_ADC_INTEN_WCINC_M 0x00000020
|
||||
#define AM_REG_ADC_INTEN_WCINC(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
#define AM_REG_ADC_INTEN_WCINC_WCINCINT 0x00000020
|
||||
|
||||
// Window comparator voltage excursion interrupt.
|
||||
#define AM_REG_ADC_INTEN_WCEXC_S 4
|
||||
#define AM_REG_ADC_INTEN_WCEXC_M 0x00000010
|
||||
#define AM_REG_ADC_INTEN_WCEXC(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
#define AM_REG_ADC_INTEN_WCEXC_WCEXCINT 0x00000010
|
||||
|
||||
// FIFO 100 percent full interrupt.
|
||||
#define AM_REG_ADC_INTEN_FIFOOVR2_S 3
|
||||
#define AM_REG_ADC_INTEN_FIFOOVR2_M 0x00000008
|
||||
#define AM_REG_ADC_INTEN_FIFOOVR2(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
#define AM_REG_ADC_INTEN_FIFOOVR2_FIFOFULLINT 0x00000008
|
||||
|
||||
// FIFO 75 percent full interrupt.
|
||||
#define AM_REG_ADC_INTEN_FIFOOVR1_S 2
|
||||
#define AM_REG_ADC_INTEN_FIFOOVR1_M 0x00000004
|
||||
#define AM_REG_ADC_INTEN_FIFOOVR1(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_ADC_INTEN_FIFOOVR1_FIFO75INT 0x00000004
|
||||
|
||||
// ADC scan complete interrupt.
|
||||
#define AM_REG_ADC_INTEN_SCNCMP_S 1
|
||||
#define AM_REG_ADC_INTEN_SCNCMP_M 0x00000002
|
||||
#define AM_REG_ADC_INTEN_SCNCMP(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_INTEN_SCNCMP_SCNCMPINT 0x00000002
|
||||
|
||||
// ADC conversion complete interrupt.
|
||||
#define AM_REG_ADC_INTEN_CNVCMP_S 0
|
||||
#define AM_REG_ADC_INTEN_CNVCMP_M 0x00000001
|
||||
#define AM_REG_ADC_INTEN_CNVCMP(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_INTEN_CNVCMP_CNVCMPINT 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_INTSTAT - ADC Interrupt registers: Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Window comparator voltage incursion interrupt.
|
||||
#define AM_REG_ADC_INTSTAT_WCINC_S 5
|
||||
#define AM_REG_ADC_INTSTAT_WCINC_M 0x00000020
|
||||
#define AM_REG_ADC_INTSTAT_WCINC(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
#define AM_REG_ADC_INTSTAT_WCINC_WCINCINT 0x00000020
|
||||
|
||||
// Window comparator voltage excursion interrupt.
|
||||
#define AM_REG_ADC_INTSTAT_WCEXC_S 4
|
||||
#define AM_REG_ADC_INTSTAT_WCEXC_M 0x00000010
|
||||
#define AM_REG_ADC_INTSTAT_WCEXC(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
#define AM_REG_ADC_INTSTAT_WCEXC_WCEXCINT 0x00000010
|
||||
|
||||
// FIFO 100 percent full interrupt.
|
||||
#define AM_REG_ADC_INTSTAT_FIFOOVR2_S 3
|
||||
#define AM_REG_ADC_INTSTAT_FIFOOVR2_M 0x00000008
|
||||
#define AM_REG_ADC_INTSTAT_FIFOOVR2(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
#define AM_REG_ADC_INTSTAT_FIFOOVR2_FIFOFULLINT 0x00000008
|
||||
|
||||
// FIFO 75 percent full interrupt.
|
||||
#define AM_REG_ADC_INTSTAT_FIFOOVR1_S 2
|
||||
#define AM_REG_ADC_INTSTAT_FIFOOVR1_M 0x00000004
|
||||
#define AM_REG_ADC_INTSTAT_FIFOOVR1(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_ADC_INTSTAT_FIFOOVR1_FIFO75INT 0x00000004
|
||||
|
||||
// ADC scan complete interrupt.
|
||||
#define AM_REG_ADC_INTSTAT_SCNCMP_S 1
|
||||
#define AM_REG_ADC_INTSTAT_SCNCMP_M 0x00000002
|
||||
#define AM_REG_ADC_INTSTAT_SCNCMP(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_INTSTAT_SCNCMP_SCNCMPINT 0x00000002
|
||||
|
||||
// ADC conversion complete interrupt.
|
||||
#define AM_REG_ADC_INTSTAT_CNVCMP_S 0
|
||||
#define AM_REG_ADC_INTSTAT_CNVCMP_M 0x00000001
|
||||
#define AM_REG_ADC_INTSTAT_CNVCMP(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_INTSTAT_CNVCMP_CNVCMPINT 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_INTCLR - ADC Interrupt registers: Clear
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Window comparator voltage incursion interrupt.
|
||||
#define AM_REG_ADC_INTCLR_WCINC_S 5
|
||||
#define AM_REG_ADC_INTCLR_WCINC_M 0x00000020
|
||||
#define AM_REG_ADC_INTCLR_WCINC(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
#define AM_REG_ADC_INTCLR_WCINC_WCINCINT 0x00000020
|
||||
|
||||
// Window comparator voltage excursion interrupt.
|
||||
#define AM_REG_ADC_INTCLR_WCEXC_S 4
|
||||
#define AM_REG_ADC_INTCLR_WCEXC_M 0x00000010
|
||||
#define AM_REG_ADC_INTCLR_WCEXC(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
#define AM_REG_ADC_INTCLR_WCEXC_WCEXCINT 0x00000010
|
||||
|
||||
// FIFO 100 percent full interrupt.
|
||||
#define AM_REG_ADC_INTCLR_FIFOOVR2_S 3
|
||||
#define AM_REG_ADC_INTCLR_FIFOOVR2_M 0x00000008
|
||||
#define AM_REG_ADC_INTCLR_FIFOOVR2(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
#define AM_REG_ADC_INTCLR_FIFOOVR2_FIFOFULLINT 0x00000008
|
||||
|
||||
// FIFO 75 percent full interrupt.
|
||||
#define AM_REG_ADC_INTCLR_FIFOOVR1_S 2
|
||||
#define AM_REG_ADC_INTCLR_FIFOOVR1_M 0x00000004
|
||||
#define AM_REG_ADC_INTCLR_FIFOOVR1(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_ADC_INTCLR_FIFOOVR1_FIFO75INT 0x00000004
|
||||
|
||||
// ADC scan complete interrupt.
|
||||
#define AM_REG_ADC_INTCLR_SCNCMP_S 1
|
||||
#define AM_REG_ADC_INTCLR_SCNCMP_M 0x00000002
|
||||
#define AM_REG_ADC_INTCLR_SCNCMP(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_INTCLR_SCNCMP_SCNCMPINT 0x00000002
|
||||
|
||||
// ADC conversion complete interrupt.
|
||||
#define AM_REG_ADC_INTCLR_CNVCMP_S 0
|
||||
#define AM_REG_ADC_INTCLR_CNVCMP_M 0x00000001
|
||||
#define AM_REG_ADC_INTCLR_CNVCMP(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_INTCLR_CNVCMP_CNVCMPINT 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_INTSET - ADC Interrupt registers: Set
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Window comparator voltage incursion interrupt.
|
||||
#define AM_REG_ADC_INTSET_WCINC_S 5
|
||||
#define AM_REG_ADC_INTSET_WCINC_M 0x00000020
|
||||
#define AM_REG_ADC_INTSET_WCINC(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
#define AM_REG_ADC_INTSET_WCINC_WCINCINT 0x00000020
|
||||
|
||||
// Window comparator voltage excursion interrupt.
|
||||
#define AM_REG_ADC_INTSET_WCEXC_S 4
|
||||
#define AM_REG_ADC_INTSET_WCEXC_M 0x00000010
|
||||
#define AM_REG_ADC_INTSET_WCEXC(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
#define AM_REG_ADC_INTSET_WCEXC_WCEXCINT 0x00000010
|
||||
|
||||
// FIFO 100 percent full interrupt.
|
||||
#define AM_REG_ADC_INTSET_FIFOOVR2_S 3
|
||||
#define AM_REG_ADC_INTSET_FIFOOVR2_M 0x00000008
|
||||
#define AM_REG_ADC_INTSET_FIFOOVR2(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
#define AM_REG_ADC_INTSET_FIFOOVR2_FIFOFULLINT 0x00000008
|
||||
|
||||
// FIFO 75 percent full interrupt.
|
||||
#define AM_REG_ADC_INTSET_FIFOOVR1_S 2
|
||||
#define AM_REG_ADC_INTSET_FIFOOVR1_M 0x00000004
|
||||
#define AM_REG_ADC_INTSET_FIFOOVR1(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_ADC_INTSET_FIFOOVR1_FIFO75INT 0x00000004
|
||||
|
||||
// ADC scan complete interrupt.
|
||||
#define AM_REG_ADC_INTSET_SCNCMP_S 1
|
||||
#define AM_REG_ADC_INTSET_SCNCMP_M 0x00000002
|
||||
#define AM_REG_ADC_INTSET_SCNCMP(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_INTSET_SCNCMP_SCNCMPINT 0x00000002
|
||||
|
||||
// ADC conversion complete interrupt.
|
||||
#define AM_REG_ADC_INTSET_CNVCMP_S 0
|
||||
#define AM_REG_ADC_INTSET_CNVCMP_M 0x00000001
|
||||
#define AM_REG_ADC_INTSET_CNVCMP(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_INTSET_CNVCMP_CNVCMPINT 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_CFG - Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Select the source and frequency for the ADC clock. All values not enumerated
|
||||
// below are undefined.
|
||||
#define AM_REG_ADC_CFG_CLKSEL_S 24
|
||||
#define AM_REG_ADC_CFG_CLKSEL_M 0x07000000
|
||||
#define AM_REG_ADC_CFG_CLKSEL(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
#define AM_REG_ADC_CFG_CLKSEL_OFF 0x00000000
|
||||
#define AM_REG_ADC_CFG_CLKSEL_12MHZ 0x01000000
|
||||
#define AM_REG_ADC_CFG_CLKSEL_6MHZ 0x02000000
|
||||
#define AM_REG_ADC_CFG_CLKSEL_3MHZ 0x03000000
|
||||
#define AM_REG_ADC_CFG_CLKSEL_1_5MHZ 0x04000000
|
||||
|
||||
// This bit selects the ADC trigger polarity for external off chip triggers.
|
||||
#define AM_REG_ADC_CFG_TRIGPOL_S 20
|
||||
#define AM_REG_ADC_CFG_TRIGPOL_M 0x00100000
|
||||
#define AM_REG_ADC_CFG_TRIGPOL(n) (((uint32_t)(n) << 20) & 0x00100000)
|
||||
#define AM_REG_ADC_CFG_TRIGPOL_RISING_EDGE 0x00000000
|
||||
#define AM_REG_ADC_CFG_TRIGPOL_FALLING_EDGE 0x00100000
|
||||
|
||||
// Select the ADC trigger source.
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_S 16
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_M 0x000F0000
|
||||
#define AM_REG_ADC_CFG_TRIGSEL(n) (((uint32_t)(n) << 16) & 0x000F0000)
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_EXT0 0x00000000
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_EXT1 0x00010000
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_EXT2 0x00020000
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_EXT3 0x00030000
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_EXT4 0x00040000
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_EXT5 0x00050000
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_EXT6 0x00060000
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_EXT7 0x00070000
|
||||
#define AM_REG_ADC_CFG_TRIGSEL_SWT 0x00080000
|
||||
|
||||
// Select the ADC reference voltage.
|
||||
#define AM_REG_ADC_CFG_REFSEL_S 8
|
||||
#define AM_REG_ADC_CFG_REFSEL_M 0x00000300
|
||||
#define AM_REG_ADC_CFG_REFSEL(n) (((uint32_t)(n) << 8) & 0x00000300)
|
||||
#define AM_REG_ADC_CFG_REFSEL_INTERNAL 0x00000000
|
||||
#define AM_REG_ADC_CFG_REFSEL_VDD 0x00000100
|
||||
#define AM_REG_ADC_CFG_REFSEL_ADCREF 0x00000200
|
||||
#define AM_REG_ADC_CFG_REFSEL_UNDEFINED 0x00000300
|
||||
|
||||
// Control 500 Ohm battery load resistor.
|
||||
#define AM_REG_ADC_CFG_BATTLOAD_S 7
|
||||
#define AM_REG_ADC_CFG_BATTLOAD_M 0x00000080
|
||||
#define AM_REG_ADC_CFG_BATTLOAD(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
#define AM_REG_ADC_CFG_BATTLOAD_DIS 0x00000000
|
||||
#define AM_REG_ADC_CFG_BATTLOAD_EN 0x00000080
|
||||
|
||||
// Select the sample rate mode. It adjusts the current in the ADC for higher
|
||||
// sample rates. A 12MHz ADC clock can result in a sample rate up to 1Msps
|
||||
// depending on the trigger or repeating mode rate. A 1.5MHz ADC clock can
|
||||
// result in a sample rate up 125K sps. NOTE: All other values not specified
|
||||
// below are undefined.
|
||||
#define AM_REG_ADC_CFG_OPMODE_S 5
|
||||
#define AM_REG_ADC_CFG_OPMODE_M 0x00000060
|
||||
#define AM_REG_ADC_CFG_OPMODE(n) (((uint32_t)(n) << 5) & 0x00000060)
|
||||
#define AM_REG_ADC_CFG_OPMODE_SAMPLE_RATE_LE_125KSPS 0x00000000
|
||||
#define AM_REG_ADC_CFG_OPMODE_SAMPLE_RATE_125K_1MSPS 0x00000040
|
||||
|
||||
// Select power mode to enter between active scans.
|
||||
#define AM_REG_ADC_CFG_LPMODE_S 3
|
||||
#define AM_REG_ADC_CFG_LPMODE_M 0x00000018
|
||||
#define AM_REG_ADC_CFG_LPMODE(n) (((uint32_t)(n) << 3) & 0x00000018)
|
||||
#define AM_REG_ADC_CFG_LPMODE_MODE0 0x00000000
|
||||
#define AM_REG_ADC_CFG_LPMODE_MODE1 0x00000008
|
||||
#define AM_REG_ADC_CFG_LPMODE_MODE2 0x00000010
|
||||
#define AM_REG_ADC_CFG_LPMODE_MODE_UNDEFINED 0x00000018
|
||||
|
||||
// This bit enables Repeating Scan Mode.
|
||||
#define AM_REG_ADC_CFG_RPTEN_S 2
|
||||
#define AM_REG_ADC_CFG_RPTEN_M 0x00000004
|
||||
#define AM_REG_ADC_CFG_RPTEN(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_ADC_CFG_RPTEN_SINGLE_SCAN 0x00000000
|
||||
#define AM_REG_ADC_CFG_RPTEN_REPEATING_SCAN 0x00000004
|
||||
|
||||
// This enables power to the temperature sensor module. After setting this bit,
|
||||
// the temperature sensor will remain powered down while the ADC is power is
|
||||
// disconnected (i.e, when the ADC PWDSTAT is 2'b10).
|
||||
#define AM_REG_ADC_CFG_TMPSPWR_S 1
|
||||
#define AM_REG_ADC_CFG_TMPSPWR_M 0x00000002
|
||||
#define AM_REG_ADC_CFG_TMPSPWR(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_CFG_TMPSPWR_DIS 0x00000000
|
||||
#define AM_REG_ADC_CFG_TMPSPWR_EN 0x00000002
|
||||
|
||||
// This bit enables the ADC module. While the ADC is enabled, the ADCCFG and
|
||||
// SLOT Configuration regsiter settings must remain stable and unchanged.
|
||||
#define AM_REG_ADC_CFG_ADCEN_S 0
|
||||
#define AM_REG_ADC_CFG_ADCEN_M 0x00000001
|
||||
#define AM_REG_ADC_CFG_ADCEN(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_CFG_ADCEN_DIS 0x00000000
|
||||
#define AM_REG_ADC_CFG_ADCEN_EN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_STAT - ADC Power Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Indicates the power-status of the ADC.
|
||||
#define AM_REG_ADC_STAT_PWDSTAT_S 0
|
||||
#define AM_REG_ADC_STAT_PWDSTAT_M 0x00000003
|
||||
#define AM_REG_ADC_STAT_PWDSTAT(n) (((uint32_t)(n) << 0) & 0x00000003)
|
||||
#define AM_REG_ADC_STAT_PWDSTAT_ON 0x00000000
|
||||
#define AM_REG_ADC_STAT_PWDSTAT_SWITCH_ON_SAR_OFF 0x00000001
|
||||
#define AM_REG_ADC_STAT_PWDSTAT_POWER_SWITCH_OFF 0x00000002
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_SWT - Software trigger
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Writing 0x37 to this register generates a software trigger.
|
||||
#define AM_REG_ADC_SWT_SWT_S 0
|
||||
#define AM_REG_ADC_SWT_SWT_M 0x000000FF
|
||||
#define AM_REG_ADC_SWT_SWT(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
#define AM_REG_ADC_SWT_SWT_GEN_SW_TRIGGER 0x00000037
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_SL0CFG - Slot 0 Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Select the number of measurements to average in the accumulate divide module
|
||||
// for this slot.
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0_S 24
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0_M 0x07000000
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0_AVG_1_MSRMT 0x00000000
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0_AVG_2_MSRMTS 0x01000000
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0_AVG_4_MSRMTS 0x02000000
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0_AVG_8_MSRMT 0x03000000
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0_AVG_16_MSRMTS 0x04000000
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0_AVG_32_MSRMTS 0x05000000
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0_AVG_64_MSRMTS 0x06000000
|
||||
#define AM_REG_ADC_SL0CFG_ADSEL0_AVG_128_MSRMTS 0x07000000
|
||||
|
||||
// Select the track and hold delay for this slot. NOTE: The track and hold
|
||||
// delay must be less than 50us for correct operation. When the ADC is
|
||||
// configured to use the 1.5Mhz clock, the track and hold delay cannot exceed 64
|
||||
// clocks.
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0_S 16
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0_M 0x00070000
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0(n) (((uint32_t)(n) << 16) & 0x00070000)
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0_1_ADC_CLK 0x00000000
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0_2_ADC_CLKS 0x00010000
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0_4_ADC_CLKS 0x00020000
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0_8_ADC_CLKS 0x00030000
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0_16_ADC_CLKS 0x00040000
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0_32_ADC_CLKS 0x00050000
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0_64_ADC_CLKS 0x00060000
|
||||
#define AM_REG_ADC_SL0CFG_THSEL0_128_ADC_CLKS 0x00070000
|
||||
|
||||
// Select one of the 13 channel inputs for this slot.
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_S 8
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_M 0x00000F00
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0(n) (((uint32_t)(n) << 8) & 0x00000F00)
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_EXT0 0x00000000
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_EXT1 0x00000100
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_EXT2 0x00000200
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_EXT3 0x00000300
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_EXT4 0x00000400
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_EXT5 0x00000500
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_EXT6 0x00000600
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_EXT7 0x00000700
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_TEMP 0x00000800
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_VDD 0x00000900
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_VSS 0x00000A00
|
||||
#define AM_REG_ADC_SL0CFG_CHSEL0_VBATT 0x00000C00
|
||||
|
||||
// This bit enables the window compare function for slot 0.
|
||||
#define AM_REG_ADC_SL0CFG_WCEN0_S 1
|
||||
#define AM_REG_ADC_SL0CFG_WCEN0_M 0x00000002
|
||||
#define AM_REG_ADC_SL0CFG_WCEN0(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_SL0CFG_WCEN0_WCEN 0x00000002
|
||||
|
||||
// This bit enables slot 0 for ADC conversions.
|
||||
#define AM_REG_ADC_SL0CFG_SLEN0_S 0
|
||||
#define AM_REG_ADC_SL0CFG_SLEN0_M 0x00000001
|
||||
#define AM_REG_ADC_SL0CFG_SLEN0(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_SL0CFG_SLEN0_SLEN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_SL1CFG - Slot 1 Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Select the number of measurements to average in the accumulate divide module
|
||||
// for this slot.
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1_S 24
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1_M 0x07000000
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1_AVG_1_MSRMT 0x00000000
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1_AVG_2_MSRMTS 0x01000000
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1_AVG_4_MSRMTS 0x02000000
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1_AVG_8_MSRMT 0x03000000
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1_AVG_16_MSRMTS 0x04000000
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1_AVG_32_MSRMTS 0x05000000
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1_AVG_64_MSRMTS 0x06000000
|
||||
#define AM_REG_ADC_SL1CFG_ADSEL1_AVG_128_MSRMTS 0x07000000
|
||||
|
||||
// Select the track and hold delay for this slot. NOTE: The track and hold
|
||||
// delay must be less than 50us for correct operation. When the ADC is
|
||||
// configured to use the 1.5 Mhz clock, the track and hold delay cannot exceed
|
||||
// 64 clocks.
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1_S 16
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1_M 0x00070000
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1(n) (((uint32_t)(n) << 16) & 0x00070000)
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1_1_ADC_CLK 0x00000000
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1_2_ADC_CLKS 0x00010000
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1_4_ADC_CLKS 0x00020000
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1_8_ADC_CLKS 0x00030000
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1_16_ADC_CLKS 0x00040000
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1_32_ADC_CLKS 0x00050000
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1_64_ADC_CLKS 0x00060000
|
||||
#define AM_REG_ADC_SL1CFG_THSEL1_128_ADC_CLKS 0x00070000
|
||||
|
||||
// Select one of the 13 channel inputs for this slot.
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_S 8
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_M 0x00000F00
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1(n) (((uint32_t)(n) << 8) & 0x00000F00)
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_EXT0 0x00000000
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_EXT1 0x00000100
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_EXT2 0x00000200
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_EXT3 0x00000300
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_EXT4 0x00000400
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_EXT5 0x00000500
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_EXT6 0x00000600
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_EXT7 0x00000700
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_TEMP 0x00000800
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_VDD 0x00000900
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_VSS 0x00000A00
|
||||
#define AM_REG_ADC_SL1CFG_CHSEL1_VBATT 0x00000C00
|
||||
|
||||
// This bit enables the window compare function for slot 1.
|
||||
#define AM_REG_ADC_SL1CFG_WCEN1_S 1
|
||||
#define AM_REG_ADC_SL1CFG_WCEN1_M 0x00000002
|
||||
#define AM_REG_ADC_SL1CFG_WCEN1(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_SL1CFG_WCEN1_WCEN 0x00000002
|
||||
|
||||
// This bit enables slot 1 for ADC conversions.
|
||||
#define AM_REG_ADC_SL1CFG_SLEN1_S 0
|
||||
#define AM_REG_ADC_SL1CFG_SLEN1_M 0x00000001
|
||||
#define AM_REG_ADC_SL1CFG_SLEN1(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_SL1CFG_SLEN1_SLEN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_SL2CFG - Slot 2 Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Select the number of measurements to average in the accumulate divide module
|
||||
// for this slot.
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2_S 24
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2_M 0x07000000
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2_AVG_1_MSRMT 0x00000000
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2_AVG_2_MSRMTS 0x01000000
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2_AVG_4_MSRMTS 0x02000000
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2_AVG_8_MSRMT 0x03000000
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2_AVG_16_MSRMTS 0x04000000
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2_AVG_32_MSRMTS 0x05000000
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2_AVG_64_MSRMTS 0x06000000
|
||||
#define AM_REG_ADC_SL2CFG_ADSEL2_AVG_128_MSRMTS 0x07000000
|
||||
|
||||
// Select the track and hold delay for this slot. NOTE: The track and hold
|
||||
// delay must be less than 50us for correct operation. When the ADC is
|
||||
// configured to use the 1.5Mhz clock, the track and hold delay cannot exceed 64
|
||||
// clocks.
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2_S 16
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2_M 0x00070000
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2(n) (((uint32_t)(n) << 16) & 0x00070000)
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2_1_ADC_CLK 0x00000000
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2_2_ADC_CLKS 0x00010000
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2_4_ADC_CLKS 0x00020000
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2_8_ADC_CLKS 0x00030000
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2_16_ADC_CLKS 0x00040000
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2_32_ADC_CLKS 0x00050000
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2_64_ADC_CLKS 0x00060000
|
||||
#define AM_REG_ADC_SL2CFG_THSEL2_128_ADC_CLKS 0x00070000
|
||||
|
||||
// Select one of the 13 channel inputs for this slot.
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_S 8
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_M 0x00000F00
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2(n) (((uint32_t)(n) << 8) & 0x00000F00)
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_EXT0 0x00000000
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_EXT1 0x00000100
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_EXT2 0x00000200
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_EXT3 0x00000300
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_EXT4 0x00000400
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_EXT5 0x00000500
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_EXT6 0x00000600
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_EXT7 0x00000700
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_TEMP 0x00000800
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_VDD 0x00000900
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_VSS 0x00000A00
|
||||
#define AM_REG_ADC_SL2CFG_CHSEL2_VBATT 0x00000C00
|
||||
|
||||
// This bit enables the window compare function for slot 2.
|
||||
#define AM_REG_ADC_SL2CFG_WCEN2_S 1
|
||||
#define AM_REG_ADC_SL2CFG_WCEN2_M 0x00000002
|
||||
#define AM_REG_ADC_SL2CFG_WCEN2(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_SL2CFG_WCEN2_WCEN 0x00000002
|
||||
|
||||
// This bit enables slot 2 for ADC conversions.
|
||||
#define AM_REG_ADC_SL2CFG_SLEN2_S 0
|
||||
#define AM_REG_ADC_SL2CFG_SLEN2_M 0x00000001
|
||||
#define AM_REG_ADC_SL2CFG_SLEN2(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_SL2CFG_SLEN2_SLEN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_SL3CFG - Slot 3 Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Select the number of measurements to average in the accumulate divide module
|
||||
// for this slot.
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3_S 24
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3_M 0x07000000
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3_AVG_1_MSRMT 0x00000000
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3_AVG_2_MSRMTS 0x01000000
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3_AVG_4_MSRMTS 0x02000000
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3_AVG_8_MSRMT 0x03000000
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3_AVG_16_MSRMTS 0x04000000
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3_AVG_32_MSRMTS 0x05000000
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3_AVG_64_MSRMTS 0x06000000
|
||||
#define AM_REG_ADC_SL3CFG_ADSEL3_AVG_128_MSRMTS 0x07000000
|
||||
|
||||
// Select the track and hold delay for this slot. NOTE: The track and hold
|
||||
// delay must be less than 50us for correct operation. When the ADC is
|
||||
// configured to use the 1.5Mhz clock, the track and hold delay cannot exceed 64
|
||||
// clocks.
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3_S 16
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3_M 0x00070000
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3(n) (((uint32_t)(n) << 16) & 0x00070000)
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3_1_ADC_CLK 0x00000000
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3_2_ADC_CLKS 0x00010000
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3_4_ADC_CLKS 0x00020000
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3_8_ADC_CLKS 0x00030000
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3_16_ADC_CLKS 0x00040000
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3_32_ADC_CLKS 0x00050000
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3_64_ADC_CLKS 0x00060000
|
||||
#define AM_REG_ADC_SL3CFG_THSEL3_128_ADC_CLKS 0x00070000
|
||||
|
||||
// Select one of the 13 channel inputs for this slot.
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_S 8
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_M 0x00000F00
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3(n) (((uint32_t)(n) << 8) & 0x00000F00)
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_EXT0 0x00000000
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_EXT1 0x00000100
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_EXT2 0x00000200
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_EXT3 0x00000300
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_EXT4 0x00000400
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_EXT5 0x00000500
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_EXT6 0x00000600
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_EXT7 0x00000700
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_TEMP 0x00000800
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_VDD 0x00000900
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_VSS 0x00000A00
|
||||
#define AM_REG_ADC_SL3CFG_CHSEL3_VBATT 0x00000C00
|
||||
|
||||
// This bit enables the window compare function for slot 3.
|
||||
#define AM_REG_ADC_SL3CFG_WCEN3_S 1
|
||||
#define AM_REG_ADC_SL3CFG_WCEN3_M 0x00000002
|
||||
#define AM_REG_ADC_SL3CFG_WCEN3(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_SL3CFG_WCEN3_WCEN 0x00000002
|
||||
|
||||
// This bit enables slot 3 for ADC conversions.
|
||||
#define AM_REG_ADC_SL3CFG_SLEN3_S 0
|
||||
#define AM_REG_ADC_SL3CFG_SLEN3_M 0x00000001
|
||||
#define AM_REG_ADC_SL3CFG_SLEN3(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_SL3CFG_SLEN3_SLEN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_SL4CFG - Slot 4 Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Select the number of measurements to average in the accumulate divide module
|
||||
// for this slot.
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4_S 24
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4_M 0x07000000
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4_AVG_1_MSRMT 0x00000000
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4_AVG_2_MSRMTS 0x01000000
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4_AVG_4_MSRMTS 0x02000000
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4_AVG_8_MSRMT 0x03000000
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4_AVG_16_MSRMTS 0x04000000
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4_AVG_32_MSRMTS 0x05000000
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4_AVG_64_MSRMTS 0x06000000
|
||||
#define AM_REG_ADC_SL4CFG_ADSEL4_AVG_128_MSRMTS 0x07000000
|
||||
|
||||
// Select the track and hold delay for this slot. NOTE: The track and hold
|
||||
// delay must be less than 50us for correct operation. When the ADC is
|
||||
// configured to use the 1.5Mhz clock, the track and hold delay cannot exceed 64
|
||||
// clocks.
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4_S 16
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4_M 0x00070000
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4(n) (((uint32_t)(n) << 16) & 0x00070000)
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4_1_ADC_CLK 0x00000000
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4_2_ADC_CLKS 0x00010000
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4_4_ADC_CLKS 0x00020000
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4_8_ADC_CLKS 0x00030000
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4_16_ADC_CLKS 0x00040000
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4_32_ADC_CLKS 0x00050000
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4_64_ADC_CLKS 0x00060000
|
||||
#define AM_REG_ADC_SL4CFG_THSEL4_128_ADC_CLKS 0x00070000
|
||||
|
||||
// Select one of the 13 channel inputs for this slot.
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_S 8
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_M 0x00000F00
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4(n) (((uint32_t)(n) << 8) & 0x00000F00)
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_EXT0 0x00000000
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_EXT1 0x00000100
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_EXT2 0x00000200
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_EXT3 0x00000300
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_EXT4 0x00000400
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_EXT5 0x00000500
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_EXT6 0x00000600
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_EXT7 0x00000700
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_TEMP 0x00000800
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_VDD 0x00000900
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_VSS 0x00000A00
|
||||
#define AM_REG_ADC_SL4CFG_CHSEL4_VBATT 0x00000C00
|
||||
|
||||
// This bit enables the window compare function for slot 4.
|
||||
#define AM_REG_ADC_SL4CFG_WCEN4_S 1
|
||||
#define AM_REG_ADC_SL4CFG_WCEN4_M 0x00000002
|
||||
#define AM_REG_ADC_SL4CFG_WCEN4(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_SL4CFG_WCEN4_WCEN 0x00000002
|
||||
|
||||
// This bit enables slot 4 for ADC conversions.
|
||||
#define AM_REG_ADC_SL4CFG_SLEN4_S 0
|
||||
#define AM_REG_ADC_SL4CFG_SLEN4_M 0x00000001
|
||||
#define AM_REG_ADC_SL4CFG_SLEN4(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_SL4CFG_SLEN4_SLEN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_SL5CFG - Slot 5 Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Select number of measurements to average in the accumulate divide module for
|
||||
// this slot.
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5_S 24
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5_M 0x07000000
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5_AVG_1_MSRMT 0x00000000
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5_AVG_2_MSRMTS 0x01000000
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5_AVG_4_MSRMTS 0x02000000
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5_AVG_8_MSRMT 0x03000000
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5_AVG_16_MSRMTS 0x04000000
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5_AVG_32_MSRMTS 0x05000000
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5_AVG_64_MSRMTS 0x06000000
|
||||
#define AM_REG_ADC_SL5CFG_ADSEL5_AVG_128_MSRMTS 0x07000000
|
||||
|
||||
// Select track and hold delay for this slot. NOTE: The track and hold delay
|
||||
// must be less than 50us for correct operation. When the ADC is configured to
|
||||
// use the 1.5Mhz clock, the track and hold delay cannot exceed 64 clocks.
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5_S 16
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5_M 0x00070000
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5(n) (((uint32_t)(n) << 16) & 0x00070000)
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5_1_ADC_CLK 0x00000000
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5_2_ADC_CLKS 0x00010000
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5_4_ADC_CLKS 0x00020000
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5_8_ADC_CLKS 0x00030000
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5_16_ADC_CLKS 0x00040000
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5_32_ADC_CLKS 0x00050000
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5_64_ADC_CLKS 0x00060000
|
||||
#define AM_REG_ADC_SL5CFG_THSEL5_128_ADC_CLKS 0x00070000
|
||||
|
||||
// Select one of the 13 channel inputs for this slot.
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_S 8
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_M 0x00000F00
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5(n) (((uint32_t)(n) << 8) & 0x00000F00)
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_EXT0 0x00000000
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_EXT1 0x00000100
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_EXT2 0x00000200
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_EXT3 0x00000300
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_EXT4 0x00000400
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_EXT5 0x00000500
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_EXT6 0x00000600
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_EXT7 0x00000700
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_TEMP 0x00000800
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_VDD 0x00000900
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_VSS 0x00000A00
|
||||
#define AM_REG_ADC_SL5CFG_CHSEL5_VBATT 0x00000C00
|
||||
|
||||
// This bit enables the window compare function for slot 5.
|
||||
#define AM_REG_ADC_SL5CFG_WCEN5_S 1
|
||||
#define AM_REG_ADC_SL5CFG_WCEN5_M 0x00000002
|
||||
#define AM_REG_ADC_SL5CFG_WCEN5(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_SL5CFG_WCEN5_WCEN 0x00000002
|
||||
|
||||
// This bit enables slot 5 for ADC conversions.
|
||||
#define AM_REG_ADC_SL5CFG_SLEN5_S 0
|
||||
#define AM_REG_ADC_SL5CFG_SLEN5_M 0x00000001
|
||||
#define AM_REG_ADC_SL5CFG_SLEN5(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_SL5CFG_SLEN5_SLEN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_SL6CFG - Slot 6 Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Select the number of measurements to average in the accumulate divide module
|
||||
// for this slot.
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6_S 24
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6_M 0x07000000
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6_AVG_1_MSRMT 0x00000000
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6_AVG_2_MSRMTS 0x01000000
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6_AVG_4_MSRMTS 0x02000000
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6_AVG_8_MSRMT 0x03000000
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6_AVG_16_MSRMTS 0x04000000
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6_AVG_32_MSRMTS 0x05000000
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6_AVG_64_MSRMTS 0x06000000
|
||||
#define AM_REG_ADC_SL6CFG_ADSEL6_AVG_128_MSRMTS 0x07000000
|
||||
|
||||
// Select track and hold delay for this slot. NOTE: The track and hold delay
|
||||
// must be less than 50us for correct operation. When the ADC is configured to
|
||||
// use the 1.5Mhz clock, the track and hold delay cannot exceed 64 clocks.
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6_S 16
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6_M 0x00070000
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6(n) (((uint32_t)(n) << 16) & 0x00070000)
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6_1_ADC_CLK 0x00000000
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6_2_ADC_CLKS 0x00010000
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6_4_ADC_CLKS 0x00020000
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6_8_ADC_CLKS 0x00030000
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6_16_ADC_CLKS 0x00040000
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6_32_ADC_CLKS 0x00050000
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6_64_ADC_CLKS 0x00060000
|
||||
#define AM_REG_ADC_SL6CFG_THSEL6_128_ADC_CLKS 0x00070000
|
||||
|
||||
// Select one of the 13 channel inputs for this slot.
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_S 8
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_M 0x00000F00
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6(n) (((uint32_t)(n) << 8) & 0x00000F00)
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_EXT0 0x00000000
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_EXT1 0x00000100
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_EXT2 0x00000200
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_EXT3 0x00000300
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_EXT4 0x00000400
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_EXT5 0x00000500
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_EXT6 0x00000600
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_EXT7 0x00000700
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_TEMP 0x00000800
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_VDD 0x00000900
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_VSS 0x00000A00
|
||||
#define AM_REG_ADC_SL6CFG_CHSEL6_VBATT 0x00000C00
|
||||
|
||||
// This bit enables the window compare function for slot 6.
|
||||
#define AM_REG_ADC_SL6CFG_WCEN6_S 1
|
||||
#define AM_REG_ADC_SL6CFG_WCEN6_M 0x00000002
|
||||
#define AM_REG_ADC_SL6CFG_WCEN6(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_SL6CFG_WCEN6_WCEN 0x00000002
|
||||
|
||||
// This bit enables slot 6 for ADC conversions.
|
||||
#define AM_REG_ADC_SL6CFG_SLEN6_S 0
|
||||
#define AM_REG_ADC_SL6CFG_SLEN6_M 0x00000001
|
||||
#define AM_REG_ADC_SL6CFG_SLEN6(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_SL6CFG_SLEN6_SLEN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_SL7CFG - Slot 7 Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Select the number of measurements to average in the accumulate divide module
|
||||
// for this slot.
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7_S 24
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7_M 0x07000000
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7_AVG_1_MSRMT 0x00000000
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7_AVG_2_MSRMTS 0x01000000
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7_AVG_4_MSRMTS 0x02000000
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7_AVG_8_MSRMT 0x03000000
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7_AVG_16_MSRMTS 0x04000000
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7_AVG_32_MSRMTS 0x05000000
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7_AVG_64_MSRMTS 0x06000000
|
||||
#define AM_REG_ADC_SL7CFG_ADSEL7_AVG_128_MSRMTS 0x07000000
|
||||
|
||||
// Select track and hold delay for this slot. NOTE: The track and hold delay
|
||||
// must be less than 50us for correct operation. When the ADC is configured to
|
||||
// use the 1.5Mhz clock, the track and hold delay cannot exceed 64 clocks.
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7_S 16
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7_M 0x00070000
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7(n) (((uint32_t)(n) << 16) & 0x00070000)
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7_1_ADC_CLK 0x00000000
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7_2_ADC_CLKS 0x00010000
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7_4_ADC_CLKS 0x00020000
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7_8_ADC_CLKS 0x00030000
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7_16_ADC_CLKS 0x00040000
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7_32_ADC_CLKS 0x00050000
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7_64_ADC_CLKS 0x00060000
|
||||
#define AM_REG_ADC_SL7CFG_THSEL7_128_ADC_CLKS 0x00070000
|
||||
|
||||
// Select one of the 13 channel inputs for this slot.
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_S 8
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_M 0x00000F00
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7(n) (((uint32_t)(n) << 8) & 0x00000F00)
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_EXT0 0x00000000
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_EXT1 0x00000100
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_EXT2 0x00000200
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_EXT3 0x00000300
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_EXT4 0x00000400
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_EXT5 0x00000500
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_EXT6 0x00000600
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_EXT7 0x00000700
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_TEMP 0x00000800
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_VDD 0x00000900
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_VSS 0x00000A00
|
||||
#define AM_REG_ADC_SL7CFG_CHSEL7_VBATT 0x00000C00
|
||||
|
||||
// This bit enables the window compare function for slot 7.
|
||||
#define AM_REG_ADC_SL7CFG_WCEN7_S 1
|
||||
#define AM_REG_ADC_SL7CFG_WCEN7_M 0x00000002
|
||||
#define AM_REG_ADC_SL7CFG_WCEN7(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_ADC_SL7CFG_WCEN7_WCEN 0x00000002
|
||||
|
||||
// This bit enables slot 7 for ADC conversions.
|
||||
#define AM_REG_ADC_SL7CFG_SLEN7_S 0
|
||||
#define AM_REG_ADC_SL7CFG_SLEN7_M 0x00000001
|
||||
#define AM_REG_ADC_SL7CFG_SLEN7(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_ADC_SL7CFG_SLEN7_SLEN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_WLIM - Window Comparator Limits Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Sets the upper limit for the wondow comparator.
|
||||
#define AM_REG_ADC_WLIM_ULIM_S 16
|
||||
#define AM_REG_ADC_WLIM_ULIM_M 0xFFFF0000
|
||||
#define AM_REG_ADC_WLIM_ULIM(n) (((uint32_t)(n) << 16) & 0xFFFF0000)
|
||||
|
||||
// Sets the lower limit for the wondow comparator.
|
||||
#define AM_REG_ADC_WLIM_LLIM_S 0
|
||||
#define AM_REG_ADC_WLIM_LLIM_M 0x0000FFFF
|
||||
#define AM_REG_ADC_WLIM_LLIM(n) (((uint32_t)(n) << 0) & 0x0000FFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ADC_FIFO - FIFO Data and Valid Count Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// RESERVED.
|
||||
#define AM_REG_ADC_FIFO_RSVD_27_S 27
|
||||
#define AM_REG_ADC_FIFO_RSVD_27_M 0xF8000000
|
||||
#define AM_REG_ADC_FIFO_RSVD_27(n) (((uint32_t)(n) << 27) & 0xF8000000)
|
||||
|
||||
// Slot number associated with this FIFO data.
|
||||
#define AM_REG_ADC_FIFO_SLOTNUM_S 24
|
||||
#define AM_REG_ADC_FIFO_SLOTNUM_M 0x07000000
|
||||
#define AM_REG_ADC_FIFO_SLOTNUM(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
|
||||
// RESERVED.
|
||||
#define AM_REG_ADC_FIFO_RSVD_20_S 20
|
||||
#define AM_REG_ADC_FIFO_RSVD_20_M 0x00F00000
|
||||
#define AM_REG_ADC_FIFO_RSVD_20(n) (((uint32_t)(n) << 20) & 0x00F00000)
|
||||
|
||||
// Number of valid entries in the ADC FIFO.
|
||||
#define AM_REG_ADC_FIFO_COUNT_S 16
|
||||
#define AM_REG_ADC_FIFO_COUNT_M 0x000F0000
|
||||
#define AM_REG_ADC_FIFO_COUNT(n) (((uint32_t)(n) << 16) & 0x000F0000)
|
||||
|
||||
// Oldest data in the FIFO.
|
||||
#define AM_REG_ADC_FIFO_DATA_S 0
|
||||
#define AM_REG_ADC_FIFO_DATA_M 0x0000FFFF
|
||||
#define AM_REG_ADC_FIFO_DATA(n) (((uint32_t)(n) << 0) & 0x0000FFFF)
|
||||
|
||||
#endif // AM_REG_ADC_H
|
||||
@@ -0,0 +1,79 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @file am_reg_base_addresses.h
|
||||
//!
|
||||
//! @brief Register defines for all module base addresses
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_BASE_ADDRESSES_H
|
||||
#define AM_REG_BASE_ADDRESSES_H
|
||||
|
||||
// ARM standard register space (needed for macros)
|
||||
#define REG_ITM_BASEADDR 0x00000000
|
||||
#define REG_JEDEC_BASEADDR 0x00000000
|
||||
#define REG_NVIC_BASEADDR 0x00000000
|
||||
#define REG_SYSCTRL_BASEADDR 0x00000000
|
||||
#define REG_SYSTICK_BASEADDR 0x00000000
|
||||
#define REG_TPIU_BASEADDR 0x00000000
|
||||
|
||||
// Peripheral register space
|
||||
#define REG_ADC_BASEADDR 0x50008000
|
||||
#define REG_CLKGEN_BASEADDR 0x40004000
|
||||
#define REG_MCUCTRL_BASEADDR 0x40020000
|
||||
#define REG_CTIMER_BASEADDR 0x40008000
|
||||
#define REG_GPIO_BASEADDR 0x40010000
|
||||
#define REG_IOMSTR0_BASEADDR 0x50004000
|
||||
#define REG_IOMSTR1_BASEADDR 0x50005000
|
||||
#define REG_IOMSTR_BASEADDR 0x50004000
|
||||
#define REG_IOSLAVE_BASEADDR 0x50000000
|
||||
#define REG_RSTGEN_BASEADDR 0x40000000
|
||||
#define REG_RTC_BASEADDR 0x40004040
|
||||
#define REG_UART_BASEADDR 0x4001C000
|
||||
#define REG_VCOMP_BASEADDR 0x4000C000
|
||||
#define REG_WDT_BASEADDR 0x40024000
|
||||
|
||||
|
||||
// SRAM address space
|
||||
#define SRAM_BASEADDR (0x10000000UL)
|
||||
|
||||
|
||||
#endif // AM_REG_BASE_ADDRESSES_H
|
||||
|
||||
@@ -0,0 +1,428 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_clkgen.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the CLKGEN module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_CLKGEN_H
|
||||
#define AM_REG_CLKGEN_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_CLKGEN_NUM_MODULES 1
|
||||
#define AM_REG_CLKGENn(n) \
|
||||
(REG_CLKGEN_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_CLKGEN_CALXT_O 0x00000000
|
||||
#define AM_REG_CLKGEN_CALRC_O 0x00000004
|
||||
#define AM_REG_CLKGEN_ACALCTR_O 0x00000008
|
||||
#define AM_REG_CLKGEN_OCTRL_O 0x0000000C
|
||||
#define AM_REG_CLKGEN_CLKOUT_O 0x00000010
|
||||
#define AM_REG_CLKGEN_CCTRL_O 0x00000018
|
||||
#define AM_REG_CLKGEN_STATUS_O 0x0000001C
|
||||
#define AM_REG_CLKGEN_HFADJ_O 0x00000020
|
||||
#define AM_REG_CLKGEN_HFVAL_O 0x00000024
|
||||
#define AM_REG_CLKGEN_CLOCKEN_O 0x00000028
|
||||
#define AM_REG_CLKGEN_UARTEN_O 0x0000002C
|
||||
#define AM_REG_CLKGEN_CLKKEY_O 0x00000014
|
||||
#define AM_REG_CLKGEN_INTEN_O 0x00000100
|
||||
#define AM_REG_CLKGEN_INTSTAT_O 0x00000104
|
||||
#define AM_REG_CLKGEN_INTCLR_O 0x00000108
|
||||
#define AM_REG_CLKGEN_INTSET_O 0x0000010C
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Key values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_CLKGEN_CLKKEY_KEYVAL 0x00000047
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_INTEN - CLKGEN Interrupt Register: Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// RTC Alarm interrupt
|
||||
#define AM_REG_CLKGEN_INTEN_ALM_S 3
|
||||
#define AM_REG_CLKGEN_INTEN_ALM_M 0x00000008
|
||||
#define AM_REG_CLKGEN_INTEN_ALM(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// XT Oscillator Fail interrupt
|
||||
#define AM_REG_CLKGEN_INTEN_OF_S 2
|
||||
#define AM_REG_CLKGEN_INTEN_OF_M 0x00000004
|
||||
#define AM_REG_CLKGEN_INTEN_OF(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Autocalibration Complete interrupt
|
||||
#define AM_REG_CLKGEN_INTEN_ACC_S 1
|
||||
#define AM_REG_CLKGEN_INTEN_ACC_M 0x00000002
|
||||
#define AM_REG_CLKGEN_INTEN_ACC(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Autocalibration Fail interrupt
|
||||
#define AM_REG_CLKGEN_INTEN_ACF_S 0
|
||||
#define AM_REG_CLKGEN_INTEN_ACF_M 0x00000001
|
||||
#define AM_REG_CLKGEN_INTEN_ACF(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_INTSTAT - CLKGEN Interrupt Register: Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// RTC Alarm interrupt
|
||||
#define AM_REG_CLKGEN_INTSTAT_ALM_S 3
|
||||
#define AM_REG_CLKGEN_INTSTAT_ALM_M 0x00000008
|
||||
#define AM_REG_CLKGEN_INTSTAT_ALM(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// XT Oscillator Fail interrupt
|
||||
#define AM_REG_CLKGEN_INTSTAT_OF_S 2
|
||||
#define AM_REG_CLKGEN_INTSTAT_OF_M 0x00000004
|
||||
#define AM_REG_CLKGEN_INTSTAT_OF(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Autocalibration Complete interrupt
|
||||
#define AM_REG_CLKGEN_INTSTAT_ACC_S 1
|
||||
#define AM_REG_CLKGEN_INTSTAT_ACC_M 0x00000002
|
||||
#define AM_REG_CLKGEN_INTSTAT_ACC(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Autocalibration Fail interrupt
|
||||
#define AM_REG_CLKGEN_INTSTAT_ACF_S 0
|
||||
#define AM_REG_CLKGEN_INTSTAT_ACF_M 0x00000001
|
||||
#define AM_REG_CLKGEN_INTSTAT_ACF(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_INTCLR - CLKGEN Interrupt Register: Clear
|
||||
//
|
||||
//*****************************************************************************
|
||||
// RTC Alarm interrupt
|
||||
#define AM_REG_CLKGEN_INTCLR_ALM_S 3
|
||||
#define AM_REG_CLKGEN_INTCLR_ALM_M 0x00000008
|
||||
#define AM_REG_CLKGEN_INTCLR_ALM(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// XT Oscillator Fail interrupt
|
||||
#define AM_REG_CLKGEN_INTCLR_OF_S 2
|
||||
#define AM_REG_CLKGEN_INTCLR_OF_M 0x00000004
|
||||
#define AM_REG_CLKGEN_INTCLR_OF(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Autocalibration Complete interrupt
|
||||
#define AM_REG_CLKGEN_INTCLR_ACC_S 1
|
||||
#define AM_REG_CLKGEN_INTCLR_ACC_M 0x00000002
|
||||
#define AM_REG_CLKGEN_INTCLR_ACC(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Autocalibration Fail interrupt
|
||||
#define AM_REG_CLKGEN_INTCLR_ACF_S 0
|
||||
#define AM_REG_CLKGEN_INTCLR_ACF_M 0x00000001
|
||||
#define AM_REG_CLKGEN_INTCLR_ACF(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_INTSET - CLKGEN Interrupt Register: Set
|
||||
//
|
||||
//*****************************************************************************
|
||||
// RTC Alarm interrupt
|
||||
#define AM_REG_CLKGEN_INTSET_ALM_S 3
|
||||
#define AM_REG_CLKGEN_INTSET_ALM_M 0x00000008
|
||||
#define AM_REG_CLKGEN_INTSET_ALM(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// XT Oscillator Fail interrupt
|
||||
#define AM_REG_CLKGEN_INTSET_OF_S 2
|
||||
#define AM_REG_CLKGEN_INTSET_OF_M 0x00000004
|
||||
#define AM_REG_CLKGEN_INTSET_OF(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Autocalibration Complete interrupt
|
||||
#define AM_REG_CLKGEN_INTSET_ACC_S 1
|
||||
#define AM_REG_CLKGEN_INTSET_ACC_M 0x00000002
|
||||
#define AM_REG_CLKGEN_INTSET_ACC(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Autocalibration Fail interrupt
|
||||
#define AM_REG_CLKGEN_INTSET_ACF_S 0
|
||||
#define AM_REG_CLKGEN_INTSET_ACF_M 0x00000001
|
||||
#define AM_REG_CLKGEN_INTSET_ACF(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_CALXT - XT Oscillator Control
|
||||
//
|
||||
//*****************************************************************************
|
||||
// XT Oscillator calibration value
|
||||
#define AM_REG_CLKGEN_CALXT_CALXT_S 0
|
||||
#define AM_REG_CLKGEN_CALXT_CALXT_M 0x000007FF
|
||||
#define AM_REG_CLKGEN_CALXT_CALXT(n) (((uint32_t)(n) << 0) & 0x000007FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_CALRC - RC Oscillator Control
|
||||
//
|
||||
//*****************************************************************************
|
||||
// LFRC Oscillator calibration value
|
||||
#define AM_REG_CLKGEN_CALRC_CALRC_S 0
|
||||
#define AM_REG_CLKGEN_CALRC_CALRC_M 0x0003FFFF
|
||||
#define AM_REG_CLKGEN_CALRC_CALRC(n) (((uint32_t)(n) << 0) & 0x0003FFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_ACALCTR - Autocalibration Counter
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Autocalibration Counter result.
|
||||
#define AM_REG_CLKGEN_ACALCTR_ACALCTR_S 0
|
||||
#define AM_REG_CLKGEN_ACALCTR_ACALCTR_M 0x00FFFFFF
|
||||
#define AM_REG_CLKGEN_ACALCTR_ACALCTR(n) (((uint32_t)(n) << 0) & 0x00FFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_OCTRL - Oscillator Control
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Autocalibration control
|
||||
#define AM_REG_CLKGEN_OCTRL_ACAL_S 8
|
||||
#define AM_REG_CLKGEN_OCTRL_ACAL_M 0x00000700
|
||||
#define AM_REG_CLKGEN_OCTRL_ACAL(n) (((uint32_t)(n) << 8) & 0x00000700)
|
||||
#define AM_REG_CLKGEN_OCTRL_ACAL_DIS 0x00000000
|
||||
#define AM_REG_CLKGEN_OCTRL_ACAL_1024SEC 0x00000200
|
||||
#define AM_REG_CLKGEN_OCTRL_ACAL_512SEC 0x00000300
|
||||
#define AM_REG_CLKGEN_OCTRL_ACAL_XTFREQ 0x00000600
|
||||
#define AM_REG_CLKGEN_OCTRL_ACAL_EXTFREQ 0x00000700
|
||||
|
||||
// Selects the RTC oscillator (1 => LFRC, 0 => XT)
|
||||
#define AM_REG_CLKGEN_OCTRL_OSEL_S 7
|
||||
#define AM_REG_CLKGEN_OCTRL_OSEL_M 0x00000080
|
||||
#define AM_REG_CLKGEN_OCTRL_OSEL(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
#define AM_REG_CLKGEN_OCTRL_OSEL_RTC_XT 0x00000000
|
||||
#define AM_REG_CLKGEN_OCTRL_OSEL_RTC_LFRC 0x00000080
|
||||
|
||||
// Oscillator switch on failure function
|
||||
#define AM_REG_CLKGEN_OCTRL_FOS_S 6
|
||||
#define AM_REG_CLKGEN_OCTRL_FOS_M 0x00000040
|
||||
#define AM_REG_CLKGEN_OCTRL_FOS(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
#define AM_REG_CLKGEN_OCTRL_FOS_DIS 0x00000000
|
||||
#define AM_REG_CLKGEN_OCTRL_FOS_EN 0x00000040
|
||||
|
||||
// Stop the LFRC Oscillator to the RTC
|
||||
#define AM_REG_CLKGEN_OCTRL_STOPRC_S 1
|
||||
#define AM_REG_CLKGEN_OCTRL_STOPRC_M 0x00000002
|
||||
#define AM_REG_CLKGEN_OCTRL_STOPRC(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_CLKGEN_OCTRL_STOPRC_EN 0x00000000
|
||||
#define AM_REG_CLKGEN_OCTRL_STOPRC_STOP 0x00000002
|
||||
|
||||
// Stop the XT Oscillator to the RTC
|
||||
#define AM_REG_CLKGEN_OCTRL_STOPXT_S 0
|
||||
#define AM_REG_CLKGEN_OCTRL_STOPXT_M 0x00000001
|
||||
#define AM_REG_CLKGEN_OCTRL_STOPXT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_CLKGEN_OCTRL_STOPXT_EN 0x00000000
|
||||
#define AM_REG_CLKGEN_OCTRL_STOPXT_STOP 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_CLKOUT - CLKOUT Frequency Select
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Enable the CLKOUT signal
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKEN_S 7
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKEN_M 0x00000080
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKEN(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKEN_DIS 0x00000000
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKEN_EN 0x00000080
|
||||
|
||||
// CLKOUT signal select
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_S 0
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_M 0x0000003F
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL(n) (((uint32_t)(n) << 0) & 0x0000003F)
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC 0x00000000
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV2 0x00000001
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV4 0x00000002
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV8 0x00000003
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV16 0x00000004
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV32 0x00000005
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_RTC_1Hz 0x00000010
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV2M 0x00000016
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XT 0x00000017
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_CG_100Hz 0x00000018
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC 0x00000019
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV2 0x0000001A
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV4 0x0000001B
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV8 0x0000001C
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV32 0x0000001D
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV64 0x0000001E
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV128 0x0000001F
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV256 0x00000020
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_FLASH_CLK 0x00000022
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV2 0x00000023
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV32 0x00000024
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV512 0x00000025
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV32K 0x00000026
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV256 0x00000027
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV8K 0x00000028
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV64K 0x00000029
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV16 0x0000002A
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV128 0x0000002B
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_1Hz 0x0000002C
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV4K 0x0000002D
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV1M 0x0000002E
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV64K 0x0000002F
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV16M 0x00000030
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV2M 0x00000031
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRCNE 0x00000032
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_HFRCNE_DIV8 0x00000033
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XTNE 0x00000035
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_XTNE_DIV16 0x00000036
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_LFRCNE_DIV32 0x00000037
|
||||
#define AM_REG_CLKGEN_CLKOUT_CKSEL_LFRCNE 0x00000039
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_CCTRL - HFRC Clock Control
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Flash Clock divisor
|
||||
#define AM_REG_CLKGEN_CCTRL_MEMSEL_S 3
|
||||
#define AM_REG_CLKGEN_CCTRL_MEMSEL_M 0x00000008
|
||||
#define AM_REG_CLKGEN_CCTRL_MEMSEL(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
#define AM_REG_CLKGEN_CCTRL_MEMSEL_HFRC_DIV25 0x00000000
|
||||
#define AM_REG_CLKGEN_CCTRL_MEMSEL_HFRC_DIV45 0x00000008
|
||||
|
||||
// Core Clock divisor
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL_S 0
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL_M 0x00000007
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL(n) (((uint32_t)(n) << 0) & 0x00000007)
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL_HFRC 0x00000000
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV2 0x00000001
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV3 0x00000002
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV4 0x00000003
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV5 0x00000004
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV6 0x00000005
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV7 0x00000006
|
||||
#define AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV8 0x00000007
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_STATUS - Clock Generator Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// XT Oscillator is enabled but not oscillating
|
||||
#define AM_REG_CLKGEN_STATUS_OSCF_S 1
|
||||
#define AM_REG_CLKGEN_STATUS_OSCF_M 0x00000002
|
||||
#define AM_REG_CLKGEN_STATUS_OSCF(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Current RTC oscillator (1 => LFRC, 0 => XT)
|
||||
#define AM_REG_CLKGEN_STATUS_OMODE_S 0
|
||||
#define AM_REG_CLKGEN_STATUS_OMODE_M 0x00000001
|
||||
#define AM_REG_CLKGEN_STATUS_OMODE(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_HFADJ - HFRC Adjustment
|
||||
//
|
||||
//*****************************************************************************
|
||||
// XT warmup period for HFRC adjustment
|
||||
#define AM_REG_CLKGEN_HFADJ_HFWARMUP_S 19
|
||||
#define AM_REG_CLKGEN_HFADJ_HFWARMUP_M 0x00080000
|
||||
#define AM_REG_CLKGEN_HFADJ_HFWARMUP(n) (((uint32_t)(n) << 19) & 0x00080000)
|
||||
#define AM_REG_CLKGEN_HFADJ_HFWARMUP_1SEC 0x00000000
|
||||
#define AM_REG_CLKGEN_HFADJ_HFWARMUP_2SEC 0x00080000
|
||||
|
||||
// Target HFRC adjustment value.
|
||||
#define AM_REG_CLKGEN_HFADJ_HFXTADJ_S 8
|
||||
#define AM_REG_CLKGEN_HFADJ_HFXTADJ_M 0x0007FF00
|
||||
#define AM_REG_CLKGEN_HFADJ_HFXTADJ(n) (((uint32_t)(n) << 8) & 0x0007FF00)
|
||||
|
||||
// Repeat period for HFRC adjustment
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK_S 1
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK_M 0x0000000E
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK(n) (((uint32_t)(n) << 1) & 0x0000000E)
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK_4SEC 0x00000000
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK_16SEC 0x00000002
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK_32SEC 0x00000004
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK_64SEC 0x00000006
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK_128SEC 0x00000008
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK_256SEC 0x0000000A
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK_512SEC 0x0000000C
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJCK_1024SEC 0x0000000E
|
||||
|
||||
// HFRC adjustment control
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJEN_S 0
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJEN_M 0x00000001
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJEN(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJEN_DIS 0x00000000
|
||||
#define AM_REG_CLKGEN_HFADJ_HFADJEN_EN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_HFVAL - HFADJ readback
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Current HFTUNE value
|
||||
#define AM_REG_CLKGEN_HFVAL_HFTUNERB_S 0
|
||||
#define AM_REG_CLKGEN_HFVAL_HFTUNERB_M 0x000007FF
|
||||
#define AM_REG_CLKGEN_HFVAL_HFTUNERB(n) (((uint32_t)(n) << 0) & 0x000007FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_CLOCKEN - Clock Enable Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Clock enable status
|
||||
#define AM_REG_CLKGEN_CLOCKEN_CLOCKEN_S 0
|
||||
#define AM_REG_CLKGEN_CLOCKEN_CLOCKEN_M 0xFFFFFFFF
|
||||
#define AM_REG_CLKGEN_CLOCKEN_CLOCKEN(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN_UARTEN - UART Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// UART system clock control
|
||||
#define AM_REG_CLKGEN_UARTEN_UARTEN_S 0
|
||||
#define AM_REG_CLKGEN_UARTEN_UARTEN_M 0x00000001
|
||||
#define AM_REG_CLKGEN_UARTEN_UARTEN(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_CLKGEN_UARTEN_UARTEN_DIS 0x00000000
|
||||
#define AM_REG_CLKGEN_UARTEN_UARTEN_EN 0x00000001
|
||||
|
||||
#endif // AM_REG_CLKGEN_H
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,505 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_iomstr.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the IOMSTR module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_IOMSTR_H
|
||||
#define AM_REG_IOMSTR_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR
|
||||
// Instance finder. (2 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_IOMSTR_NUM_MODULES 2
|
||||
#define AM_REG_IOMSTRn(n) \
|
||||
(REG_IOMSTR_BASEADDR + 0x00001000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_IOMSTR_FIFO_O 0x00000000
|
||||
#define AM_REG_IOMSTR_FIFOPTR_O 0x00000100
|
||||
#define AM_REG_IOMSTR_TLNGTH_O 0x00000104
|
||||
#define AM_REG_IOMSTR_FIFOTHR_O 0x00000108
|
||||
#define AM_REG_IOMSTR_CLKCFG_O 0x0000010C
|
||||
#define AM_REG_IOMSTR_CMD_O 0x00000110
|
||||
#define AM_REG_IOMSTR_CMDRPT_O 0x00000114
|
||||
#define AM_REG_IOMSTR_STATUS_O 0x00000118
|
||||
#define AM_REG_IOMSTR_CFG_O 0x0000011C
|
||||
#define AM_REG_IOMSTR_INTEN_O 0x00000200
|
||||
#define AM_REG_IOMSTR_INTSTAT_O 0x00000204
|
||||
#define AM_REG_IOMSTR_INTCLR_O 0x00000208
|
||||
#define AM_REG_IOMSTR_INTSET_O 0x0000020C
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_INTEN - IO Master Interrupts: Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This is the arbitration loss interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_ARB_S 10
|
||||
#define AM_REG_IOMSTR_INTEN_ARB_M 0x00000400
|
||||
#define AM_REG_IOMSTR_INTEN_ARB(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// This is the STOP command interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_STOP_S 9
|
||||
#define AM_REG_IOMSTR_INTEN_STOP_M 0x00000200
|
||||
#define AM_REG_IOMSTR_INTEN_STOP(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// This is the START command interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_START_S 8
|
||||
#define AM_REG_IOMSTR_INTEN_START_M 0x00000100
|
||||
#define AM_REG_IOMSTR_INTEN_START(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// This is the illegal command interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_ICMD_S 7
|
||||
#define AM_REG_IOMSTR_INTEN_ICMD_M 0x00000080
|
||||
#define AM_REG_IOMSTR_INTEN_ICMD(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// This is the illegal FIFO access interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_IACC_S 6
|
||||
#define AM_REG_IOMSTR_INTEN_IACC_M 0x00000040
|
||||
#define AM_REG_IOMSTR_INTEN_IACC(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
|
||||
// This is the write length mismatch interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_WTLEN_S 5
|
||||
#define AM_REG_IOMSTR_INTEN_WTLEN_M 0x00000020
|
||||
#define AM_REG_IOMSTR_INTEN_WTLEN(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// This is the I2C NAK interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_NAK_S 4
|
||||
#define AM_REG_IOMSTR_INTEN_NAK_M 0x00000010
|
||||
#define AM_REG_IOMSTR_INTEN_NAK(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// This is the Read FIFO Overflow interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_FOVFL_S 3
|
||||
#define AM_REG_IOMSTR_INTEN_FOVFL_M 0x00000008
|
||||
#define AM_REG_IOMSTR_INTEN_FOVFL(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// This is the Write FIFO Underflow interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_FUNDFL_S 2
|
||||
#define AM_REG_IOMSTR_INTEN_FUNDFL_M 0x00000004
|
||||
#define AM_REG_IOMSTR_INTEN_FUNDFL(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This is the FIFO Threshold interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_THR_S 1
|
||||
#define AM_REG_IOMSTR_INTEN_THR_M 0x00000002
|
||||
#define AM_REG_IOMSTR_INTEN_THR(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This is the Command Complete interrupt.
|
||||
#define AM_REG_IOMSTR_INTEN_CMDCMP_S 0
|
||||
#define AM_REG_IOMSTR_INTEN_CMDCMP_M 0x00000001
|
||||
#define AM_REG_IOMSTR_INTEN_CMDCMP(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_INTSTAT - IO Master Interrupts: Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This is the arbitration loss interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_ARB_S 10
|
||||
#define AM_REG_IOMSTR_INTSTAT_ARB_M 0x00000400
|
||||
#define AM_REG_IOMSTR_INTSTAT_ARB(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// This is the STOP command interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_STOP_S 9
|
||||
#define AM_REG_IOMSTR_INTSTAT_STOP_M 0x00000200
|
||||
#define AM_REG_IOMSTR_INTSTAT_STOP(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// This is the START command interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_START_S 8
|
||||
#define AM_REG_IOMSTR_INTSTAT_START_M 0x00000100
|
||||
#define AM_REG_IOMSTR_INTSTAT_START(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// This is the illegal command interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_ICMD_S 7
|
||||
#define AM_REG_IOMSTR_INTSTAT_ICMD_M 0x00000080
|
||||
#define AM_REG_IOMSTR_INTSTAT_ICMD(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// This is the illegal FIFO access interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_IACC_S 6
|
||||
#define AM_REG_IOMSTR_INTSTAT_IACC_M 0x00000040
|
||||
#define AM_REG_IOMSTR_INTSTAT_IACC(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
|
||||
// This is the write length mismatch interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_WTLEN_S 5
|
||||
#define AM_REG_IOMSTR_INTSTAT_WTLEN_M 0x00000020
|
||||
#define AM_REG_IOMSTR_INTSTAT_WTLEN(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// This is the I2C NAK interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_NAK_S 4
|
||||
#define AM_REG_IOMSTR_INTSTAT_NAK_M 0x00000010
|
||||
#define AM_REG_IOMSTR_INTSTAT_NAK(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// This is the Read FIFO Overflow interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_FOVFL_S 3
|
||||
#define AM_REG_IOMSTR_INTSTAT_FOVFL_M 0x00000008
|
||||
#define AM_REG_IOMSTR_INTSTAT_FOVFL(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// This is the Write FIFO Underflow interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_FUNDFL_S 2
|
||||
#define AM_REG_IOMSTR_INTSTAT_FUNDFL_M 0x00000004
|
||||
#define AM_REG_IOMSTR_INTSTAT_FUNDFL(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This is the FIFO Threshold interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_THR_S 1
|
||||
#define AM_REG_IOMSTR_INTSTAT_THR_M 0x00000002
|
||||
#define AM_REG_IOMSTR_INTSTAT_THR(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This is the Command Complete interrupt.
|
||||
#define AM_REG_IOMSTR_INTSTAT_CMDCMP_S 0
|
||||
#define AM_REG_IOMSTR_INTSTAT_CMDCMP_M 0x00000001
|
||||
#define AM_REG_IOMSTR_INTSTAT_CMDCMP(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_INTCLR - IO Master Interrupts: Clear
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This is the arbitration loss interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_ARB_S 10
|
||||
#define AM_REG_IOMSTR_INTCLR_ARB_M 0x00000400
|
||||
#define AM_REG_IOMSTR_INTCLR_ARB(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// This is the STOP command interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_STOP_S 9
|
||||
#define AM_REG_IOMSTR_INTCLR_STOP_M 0x00000200
|
||||
#define AM_REG_IOMSTR_INTCLR_STOP(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// This is the START command interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_START_S 8
|
||||
#define AM_REG_IOMSTR_INTCLR_START_M 0x00000100
|
||||
#define AM_REG_IOMSTR_INTCLR_START(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// This is the illegal command interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_ICMD_S 7
|
||||
#define AM_REG_IOMSTR_INTCLR_ICMD_M 0x00000080
|
||||
#define AM_REG_IOMSTR_INTCLR_ICMD(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// This is the illegal FIFO access interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_IACC_S 6
|
||||
#define AM_REG_IOMSTR_INTCLR_IACC_M 0x00000040
|
||||
#define AM_REG_IOMSTR_INTCLR_IACC(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
|
||||
// This is the write length mismatch interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_WTLEN_S 5
|
||||
#define AM_REG_IOMSTR_INTCLR_WTLEN_M 0x00000020
|
||||
#define AM_REG_IOMSTR_INTCLR_WTLEN(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// This is the I2C NAK interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_NAK_S 4
|
||||
#define AM_REG_IOMSTR_INTCLR_NAK_M 0x00000010
|
||||
#define AM_REG_IOMSTR_INTCLR_NAK(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// This is the Read FIFO Overflow interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_FOVFL_S 3
|
||||
#define AM_REG_IOMSTR_INTCLR_FOVFL_M 0x00000008
|
||||
#define AM_REG_IOMSTR_INTCLR_FOVFL(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// This is the Write FIFO Underflow interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_FUNDFL_S 2
|
||||
#define AM_REG_IOMSTR_INTCLR_FUNDFL_M 0x00000004
|
||||
#define AM_REG_IOMSTR_INTCLR_FUNDFL(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This is the FIFO Threshold interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_THR_S 1
|
||||
#define AM_REG_IOMSTR_INTCLR_THR_M 0x00000002
|
||||
#define AM_REG_IOMSTR_INTCLR_THR(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This is the Command Complete interrupt.
|
||||
#define AM_REG_IOMSTR_INTCLR_CMDCMP_S 0
|
||||
#define AM_REG_IOMSTR_INTCLR_CMDCMP_M 0x00000001
|
||||
#define AM_REG_IOMSTR_INTCLR_CMDCMP(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_INTSET - IO Master Interrupts: Set
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This is the arbitration loss interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_ARB_S 10
|
||||
#define AM_REG_IOMSTR_INTSET_ARB_M 0x00000400
|
||||
#define AM_REG_IOMSTR_INTSET_ARB(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// This is the STOP command interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_STOP_S 9
|
||||
#define AM_REG_IOMSTR_INTSET_STOP_M 0x00000200
|
||||
#define AM_REG_IOMSTR_INTSET_STOP(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// This is the START command interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_START_S 8
|
||||
#define AM_REG_IOMSTR_INTSET_START_M 0x00000100
|
||||
#define AM_REG_IOMSTR_INTSET_START(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// This is the illegal command interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_ICMD_S 7
|
||||
#define AM_REG_IOMSTR_INTSET_ICMD_M 0x00000080
|
||||
#define AM_REG_IOMSTR_INTSET_ICMD(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// This is the illegal FIFO access interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_IACC_S 6
|
||||
#define AM_REG_IOMSTR_INTSET_IACC_M 0x00000040
|
||||
#define AM_REG_IOMSTR_INTSET_IACC(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
|
||||
// This is the write length mismatch interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_WTLEN_S 5
|
||||
#define AM_REG_IOMSTR_INTSET_WTLEN_M 0x00000020
|
||||
#define AM_REG_IOMSTR_INTSET_WTLEN(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// This is the I2C NAK interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_NAK_S 4
|
||||
#define AM_REG_IOMSTR_INTSET_NAK_M 0x00000010
|
||||
#define AM_REG_IOMSTR_INTSET_NAK(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// This is the Read FIFO Overflow interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_FOVFL_S 3
|
||||
#define AM_REG_IOMSTR_INTSET_FOVFL_M 0x00000008
|
||||
#define AM_REG_IOMSTR_INTSET_FOVFL(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// This is the Write FIFO Underflow interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_FUNDFL_S 2
|
||||
#define AM_REG_IOMSTR_INTSET_FUNDFL_M 0x00000004
|
||||
#define AM_REG_IOMSTR_INTSET_FUNDFL(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This is the FIFO Threshold interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_THR_S 1
|
||||
#define AM_REG_IOMSTR_INTSET_THR_M 0x00000002
|
||||
#define AM_REG_IOMSTR_INTSET_THR(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This is the Command Complete interrupt.
|
||||
#define AM_REG_IOMSTR_INTSET_CMDCMP_S 0
|
||||
#define AM_REG_IOMSTR_INTSET_CMDCMP_M 0x00000001
|
||||
#define AM_REG_IOMSTR_INTSET_CMDCMP(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_FIFO - FIFO Access Port
|
||||
//
|
||||
//*****************************************************************************
|
||||
// FIFO access port.
|
||||
#define AM_REG_IOMSTR_FIFO_FIFO_S 0
|
||||
#define AM_REG_IOMSTR_FIFO_FIFO_M 0xFFFFFFFF
|
||||
#define AM_REG_IOMSTR_FIFO_FIFO(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_FIFOPTR - Current FIFO Pointers
|
||||
//
|
||||
//*****************************************************************************
|
||||
// The number of bytes remaining in the FIFO (i.e. 64-FIFOSIZ).
|
||||
#define AM_REG_IOMSTR_FIFOPTR_FIFOREM_S 16
|
||||
#define AM_REG_IOMSTR_FIFOPTR_FIFOREM_M 0x007F0000
|
||||
#define AM_REG_IOMSTR_FIFOPTR_FIFOREM(n) (((uint32_t)(n) << 16) & 0x007F0000)
|
||||
|
||||
// The number of bytes currently in the FIFO.
|
||||
#define AM_REG_IOMSTR_FIFOPTR_FIFOSIZ_S 0
|
||||
#define AM_REG_IOMSTR_FIFOPTR_FIFOSIZ_M 0x0000007F
|
||||
#define AM_REG_IOMSTR_FIFOPTR_FIFOSIZ(n) (((uint32_t)(n) << 0) & 0x0000007F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_TLNGTH - Transfer Length
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Remaining transfer length.
|
||||
#define AM_REG_IOMSTR_TLNGTH_TLNGTH_S 0
|
||||
#define AM_REG_IOMSTR_TLNGTH_TLNGTH_M 0x00000FFF
|
||||
#define AM_REG_IOMSTR_TLNGTH_TLNGTH(n) (((uint32_t)(n) << 0) & 0x00000FFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_FIFOTHR - FIFO Threshold Configuration
|
||||
//
|
||||
//*****************************************************************************
|
||||
// FIFO write threshold.
|
||||
#define AM_REG_IOMSTR_FIFOTHR_FIFOWTHR_S 8
|
||||
#define AM_REG_IOMSTR_FIFOTHR_FIFOWTHR_M 0x00003F00
|
||||
#define AM_REG_IOMSTR_FIFOTHR_FIFOWTHR(n) (((uint32_t)(n) << 8) & 0x00003F00)
|
||||
|
||||
// FIFO read threshold.
|
||||
#define AM_REG_IOMSTR_FIFOTHR_FIFORTHR_S 0
|
||||
#define AM_REG_IOMSTR_FIFOTHR_FIFORTHR_M 0x0000003F
|
||||
#define AM_REG_IOMSTR_FIFOTHR_FIFORTHR(n) (((uint32_t)(n) << 0) & 0x0000003F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_CLKCFG - I/O Clock Configuration
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Clock total count minus 1.
|
||||
#define AM_REG_IOMSTR_CLKCFG_TOTPER_S 24
|
||||
#define AM_REG_IOMSTR_CLKCFG_TOTPER_M 0xFF000000
|
||||
#define AM_REG_IOMSTR_CLKCFG_TOTPER(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Clock low count minus 1.
|
||||
#define AM_REG_IOMSTR_CLKCFG_LOWPER_S 16
|
||||
#define AM_REG_IOMSTR_CLKCFG_LOWPER_M 0x00FF0000
|
||||
#define AM_REG_IOMSTR_CLKCFG_LOWPER(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Enable clock division by TOTPER.
|
||||
#define AM_REG_IOMSTR_CLKCFG_DIVEN_S 12
|
||||
#define AM_REG_IOMSTR_CLKCFG_DIVEN_M 0x00001000
|
||||
#define AM_REG_IOMSTR_CLKCFG_DIVEN(n) (((uint32_t)(n) << 12) & 0x00001000)
|
||||
#define AM_REG_IOMSTR_CLKCFG_DIVEN_DIS 0x00000000
|
||||
#define AM_REG_IOMSTR_CLKCFG_DIVEN_EN 0x00001000
|
||||
|
||||
// Enable divide by 3.
|
||||
#define AM_REG_IOMSTR_CLKCFG_DIV3_S 11
|
||||
#define AM_REG_IOMSTR_CLKCFG_DIV3_M 0x00000800
|
||||
#define AM_REG_IOMSTR_CLKCFG_DIV3(n) (((uint32_t)(n) << 11) & 0x00000800)
|
||||
#define AM_REG_IOMSTR_CLKCFG_DIV3_DIS 0x00000000
|
||||
#define AM_REG_IOMSTR_CLKCFG_DIV3_EN 0x00000800
|
||||
|
||||
// Select the input clock frequency.
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL_S 8
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL_M 0x00000700
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL(n) (((uint32_t)(n) << 8) & 0x00000700)
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL_HFRC_DIV64 0x00000000
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL_HFRC 0x00000100
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL_HFRC_DIV2 0x00000200
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL_HFRC_DIV4 0x00000300
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL_HFRC_DIV8 0x00000400
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL_HFRC_DIV16 0x00000500
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL_HFRC_DIV32 0x00000600
|
||||
#define AM_REG_IOMSTR_CLKCFG_FSEL_RSVD 0x00000700
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_CMD - Command Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This register is the I/O Command.
|
||||
#define AM_REG_IOMSTR_CMD_CMD_S 0
|
||||
#define AM_REG_IOMSTR_CMD_CMD_M 0xFFFFFFFF
|
||||
#define AM_REG_IOMSTR_CMD_CMD(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
#define AM_REG_IOMSTR_CMD_CMD_POS_LENGTH 0x00000000
|
||||
#define AM_REG_IOMSTR_CMD_CMD_POS_OFFSET 0x00000008
|
||||
#define AM_REG_IOMSTR_CMD_CMD_POS_ADDRESS 0x00000010
|
||||
#define AM_REG_IOMSTR_CMD_CMD_POS_CHNL 0x00000010
|
||||
#define AM_REG_IOMSTR_CMD_CMD_POS_UPLNGTH 0x00000017
|
||||
#define AM_REG_IOMSTR_CMD_CMD_POS_10BIT 0x0000001A
|
||||
#define AM_REG_IOMSTR_CMD_CMD_POS_LSB 0x0000001B
|
||||
#define AM_REG_IOMSTR_CMD_CMD_POS_CONT 0x0000001C
|
||||
#define AM_REG_IOMSTR_CMD_CMD_POS_OPER 0x0000001D
|
||||
#define AM_REG_IOMSTR_CMD_CMD_MSK_LENGTH 0x000000FF
|
||||
#define AM_REG_IOMSTR_CMD_CMD_MSK_OFFSET 0x0000FF00
|
||||
#define AM_REG_IOMSTR_CMD_CMD_MSK_ADDRESS 0x00FF0000
|
||||
#define AM_REG_IOMSTR_CMD_CMD_MSK_CHNL 0x00070000
|
||||
#define AM_REG_IOMSTR_CMD_CMD_MSK_UPLNGTH 0x07800000
|
||||
#define AM_REG_IOMSTR_CMD_CMD_MSK_10BIT 0x04000000
|
||||
#define AM_REG_IOMSTR_CMD_CMD_MSK_LSB 0x08000000
|
||||
#define AM_REG_IOMSTR_CMD_CMD_MSK_CONT 0x10000000
|
||||
#define AM_REG_IOMSTR_CMD_CMD_MSK_OPER 0xE0000000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_CMDRPT - Command Repeat Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// These bits hold the Command repeat count.
|
||||
#define AM_REG_IOMSTR_CMDRPT_CMDRPT_S 0
|
||||
#define AM_REG_IOMSTR_CMDRPT_CMDRPT_M 0x0000001F
|
||||
#define AM_REG_IOMSTR_CMDRPT_CMDRPT(n) (((uint32_t)(n) << 0) & 0x0000001F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_STATUS - Status Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit indicates if the I/O state machine is IDLE.
|
||||
#define AM_REG_IOMSTR_STATUS_IDLEST_S 2
|
||||
#define AM_REG_IOMSTR_STATUS_IDLEST_M 0x00000004
|
||||
#define AM_REG_IOMSTR_STATUS_IDLEST(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_IOMSTR_STATUS_IDLEST_IDLE 0x00000004
|
||||
|
||||
// This bit indicates if the I/O Command is active.
|
||||
#define AM_REG_IOMSTR_STATUS_CMDACT_S 1
|
||||
#define AM_REG_IOMSTR_STATUS_CMDACT_M 0x00000002
|
||||
#define AM_REG_IOMSTR_STATUS_CMDACT(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_IOMSTR_STATUS_CMDACT_ACTIVE 0x00000002
|
||||
|
||||
// This bit indicates if an error interrupt has occurred.
|
||||
#define AM_REG_IOMSTR_STATUS_ERR_S 0
|
||||
#define AM_REG_IOMSTR_STATUS_ERR_M 0x00000001
|
||||
#define AM_REG_IOMSTR_STATUS_ERR(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_IOMSTR_STATUS_ERR_ERROR 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOMSTR_CFG - I/O Master Configuration
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit enables the IO Master.
|
||||
#define AM_REG_IOMSTR_CFG_IFCEN_S 31
|
||||
#define AM_REG_IOMSTR_CFG_IFCEN_M 0x80000000
|
||||
#define AM_REG_IOMSTR_CFG_IFCEN(n) (((uint32_t)(n) << 31) & 0x80000000)
|
||||
#define AM_REG_IOMSTR_CFG_IFCEN_DIS 0x00000000
|
||||
#define AM_REG_IOMSTR_CFG_IFCEN_EN 0x80000000
|
||||
|
||||
// This bit selects SPI phase.
|
||||
#define AM_REG_IOMSTR_CFG_SPHA_S 2
|
||||
#define AM_REG_IOMSTR_CFG_SPHA_M 0x00000004
|
||||
#define AM_REG_IOMSTR_CFG_SPHA(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_IOMSTR_CFG_SPHA_SAMPLE_LEADING_EDGE 0x00000000
|
||||
#define AM_REG_IOMSTR_CFG_SPHA_SAMPLE_TRAILING_EDGE 0x00000004
|
||||
|
||||
// This bit selects SPI polarity.
|
||||
#define AM_REG_IOMSTR_CFG_SPOL_S 1
|
||||
#define AM_REG_IOMSTR_CFG_SPOL_M 0x00000002
|
||||
#define AM_REG_IOMSTR_CFG_SPOL(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_IOMSTR_CFG_SPOL_CLK_BASE_0 0x00000000
|
||||
#define AM_REG_IOMSTR_CFG_SPOL_CLK_BASE_1 0x00000002
|
||||
|
||||
// This bit selects the I/O interface.
|
||||
#define AM_REG_IOMSTR_CFG_IFCSEL_S 0
|
||||
#define AM_REG_IOMSTR_CFG_IFCSEL_M 0x00000001
|
||||
#define AM_REG_IOMSTR_CFG_IFCSEL(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_IOMSTR_CFG_IFCSEL_I2C 0x00000000
|
||||
#define AM_REG_IOMSTR_CFG_IFCSEL_SPI 0x00000001
|
||||
|
||||
#endif // AM_REG_IOMSTR_H
|
||||
@@ -0,0 +1,438 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_ioslave.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the IOSLAVE module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_IOSLAVE_H
|
||||
#define AM_REG_IOSLAVE_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_IOSLAVE_NUM_MODULES 1
|
||||
#define AM_REG_IOSLAVEn(n) \
|
||||
(REG_IOSLAVE_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_IOSLAVE_FIFOPTR_O 0x00000100
|
||||
#define AM_REG_IOSLAVE_FIFOCFG_O 0x00000104
|
||||
#define AM_REG_IOSLAVE_FIFOTHR_O 0x00000108
|
||||
#define AM_REG_IOSLAVE_FUPD_O 0x0000010C
|
||||
#define AM_REG_IOSLAVE_FIFOCTR_O 0x00000110
|
||||
#define AM_REG_IOSLAVE_FIFOINC_O 0x00000114
|
||||
#define AM_REG_IOSLAVE_CFG_O 0x00000118
|
||||
#define AM_REG_IOSLAVE_PRENC_O 0x0000011C
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_O 0x00000120
|
||||
#define AM_REG_IOSLAVE_GENADD_O 0x00000124
|
||||
#define AM_REG_IOSLAVE_INTEN_O 0x00000200
|
||||
#define AM_REG_IOSLAVE_INTSTAT_O 0x00000204
|
||||
#define AM_REG_IOSLAVE_INTCLR_O 0x00000208
|
||||
#define AM_REG_IOSLAVE_INTSET_O 0x0000020C
|
||||
#define AM_REG_IOSLAVE_REGACCINTEN_O 0x00000210
|
||||
#define AM_REG_IOSLAVE_REGACCINTSTAT_O 0x00000214
|
||||
#define AM_REG_IOSLAVE_REGACCINTCLR_O 0x00000218
|
||||
#define AM_REG_IOSLAVE_REGACCINTSET_O 0x0000021C
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_INTEN - IO Slave Interrupts: Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// I2C Interrupt Write interrupt.
|
||||
#define AM_REG_IOSLAVE_INTEN_IOINTW_S 5
|
||||
#define AM_REG_IOSLAVE_INTEN_IOINTW_M 0x00000020
|
||||
#define AM_REG_IOSLAVE_INTEN_IOINTW(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// I2C General Address interrupt.
|
||||
#define AM_REG_IOSLAVE_INTEN_GENAD_S 4
|
||||
#define AM_REG_IOSLAVE_INTEN_GENAD_M 0x00000010
|
||||
#define AM_REG_IOSLAVE_INTEN_GENAD(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// FIFO Read Error interrupt.
|
||||
#define AM_REG_IOSLAVE_INTEN_FRDERR_S 3
|
||||
#define AM_REG_IOSLAVE_INTEN_FRDERR_M 0x00000008
|
||||
#define AM_REG_IOSLAVE_INTEN_FRDERR(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// FIFO Underflow interrupt.
|
||||
#define AM_REG_IOSLAVE_INTEN_FUNDFL_S 2
|
||||
#define AM_REG_IOSLAVE_INTEN_FUNDFL_M 0x00000004
|
||||
#define AM_REG_IOSLAVE_INTEN_FUNDFL(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// FIFO Overflow interrupt.
|
||||
#define AM_REG_IOSLAVE_INTEN_FOVFL_S 1
|
||||
#define AM_REG_IOSLAVE_INTEN_FOVFL_M 0x00000002
|
||||
#define AM_REG_IOSLAVE_INTEN_FOVFL(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// FIFO Size interrupt.
|
||||
#define AM_REG_IOSLAVE_INTEN_FSIZE_S 0
|
||||
#define AM_REG_IOSLAVE_INTEN_FSIZE_M 0x00000001
|
||||
#define AM_REG_IOSLAVE_INTEN_FSIZE(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_INTSTAT - IO Slave Interrupts: Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// I2C Interrupt Write interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSTAT_IOINTW_S 5
|
||||
#define AM_REG_IOSLAVE_INTSTAT_IOINTW_M 0x00000020
|
||||
#define AM_REG_IOSLAVE_INTSTAT_IOINTW(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// I2C General Address interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSTAT_GENAD_S 4
|
||||
#define AM_REG_IOSLAVE_INTSTAT_GENAD_M 0x00000010
|
||||
#define AM_REG_IOSLAVE_INTSTAT_GENAD(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// FIFO Read Error interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FRDERR_S 3
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FRDERR_M 0x00000008
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FRDERR(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// FIFO Underflow interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FUNDFL_S 2
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FUNDFL_M 0x00000004
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FUNDFL(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// FIFO Overflow interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FOVFL_S 1
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FOVFL_M 0x00000002
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FOVFL(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// FIFO Size interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FSIZE_S 0
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FSIZE_M 0x00000001
|
||||
#define AM_REG_IOSLAVE_INTSTAT_FSIZE(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_INTCLR - IO Slave Interrupts: Clear
|
||||
//
|
||||
//*****************************************************************************
|
||||
// I2C Interrupt Write interrupt.
|
||||
#define AM_REG_IOSLAVE_INTCLR_IOINTW_S 5
|
||||
#define AM_REG_IOSLAVE_INTCLR_IOINTW_M 0x00000020
|
||||
#define AM_REG_IOSLAVE_INTCLR_IOINTW(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// I2C General Address interrupt.
|
||||
#define AM_REG_IOSLAVE_INTCLR_GENAD_S 4
|
||||
#define AM_REG_IOSLAVE_INTCLR_GENAD_M 0x00000010
|
||||
#define AM_REG_IOSLAVE_INTCLR_GENAD(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// FIFO Read Error interrupt.
|
||||
#define AM_REG_IOSLAVE_INTCLR_FRDERR_S 3
|
||||
#define AM_REG_IOSLAVE_INTCLR_FRDERR_M 0x00000008
|
||||
#define AM_REG_IOSLAVE_INTCLR_FRDERR(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// FIFO Underflow interrupt.
|
||||
#define AM_REG_IOSLAVE_INTCLR_FUNDFL_S 2
|
||||
#define AM_REG_IOSLAVE_INTCLR_FUNDFL_M 0x00000004
|
||||
#define AM_REG_IOSLAVE_INTCLR_FUNDFL(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// FIFO Overflow interrupt.
|
||||
#define AM_REG_IOSLAVE_INTCLR_FOVFL_S 1
|
||||
#define AM_REG_IOSLAVE_INTCLR_FOVFL_M 0x00000002
|
||||
#define AM_REG_IOSLAVE_INTCLR_FOVFL(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// FIFO Size interrupt.
|
||||
#define AM_REG_IOSLAVE_INTCLR_FSIZE_S 0
|
||||
#define AM_REG_IOSLAVE_INTCLR_FSIZE_M 0x00000001
|
||||
#define AM_REG_IOSLAVE_INTCLR_FSIZE(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_INTSET - IO Slave Interrupts: Set
|
||||
//
|
||||
//*****************************************************************************
|
||||
// I2C Interrupt Write interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSET_IOINTW_S 5
|
||||
#define AM_REG_IOSLAVE_INTSET_IOINTW_M 0x00000020
|
||||
#define AM_REG_IOSLAVE_INTSET_IOINTW(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// I2C General Address interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSET_GENAD_S 4
|
||||
#define AM_REG_IOSLAVE_INTSET_GENAD_M 0x00000010
|
||||
#define AM_REG_IOSLAVE_INTSET_GENAD(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// FIFO Read Error interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSET_FRDERR_S 3
|
||||
#define AM_REG_IOSLAVE_INTSET_FRDERR_M 0x00000008
|
||||
#define AM_REG_IOSLAVE_INTSET_FRDERR(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// FIFO Underflow interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSET_FUNDFL_S 2
|
||||
#define AM_REG_IOSLAVE_INTSET_FUNDFL_M 0x00000004
|
||||
#define AM_REG_IOSLAVE_INTSET_FUNDFL(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// FIFO Overflow interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSET_FOVFL_S 1
|
||||
#define AM_REG_IOSLAVE_INTSET_FOVFL_M 0x00000002
|
||||
#define AM_REG_IOSLAVE_INTSET_FOVFL(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// FIFO Size interrupt.
|
||||
#define AM_REG_IOSLAVE_INTSET_FSIZE_S 0
|
||||
#define AM_REG_IOSLAVE_INTSET_FSIZE_M 0x00000001
|
||||
#define AM_REG_IOSLAVE_INTSET_FSIZE(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_REGACCINTEN - Register Access Interrupts: Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Register access interrupts.
|
||||
#define AM_REG_IOSLAVE_REGACCINTEN_REGACC_S 0
|
||||
#define AM_REG_IOSLAVE_REGACCINTEN_REGACC_M 0xFFFFFFFF
|
||||
#define AM_REG_IOSLAVE_REGACCINTEN_REGACC(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_REGACCINTSTAT - Register Access Interrupts: Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Register access interrupts.
|
||||
#define AM_REG_IOSLAVE_REGACCINTSTAT_REGACC_S 0
|
||||
#define AM_REG_IOSLAVE_REGACCINTSTAT_REGACC_M 0xFFFFFFFF
|
||||
#define AM_REG_IOSLAVE_REGACCINTSTAT_REGACC(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_REGACCINTCLR - Register Access Interrupts: Clear
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Register access interrupts.
|
||||
#define AM_REG_IOSLAVE_REGACCINTCLR_REGACC_S 0
|
||||
#define AM_REG_IOSLAVE_REGACCINTCLR_REGACC_M 0xFFFFFFFF
|
||||
#define AM_REG_IOSLAVE_REGACCINTCLR_REGACC(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_REGACCINTSET - Register Access Interrupts: Set
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Register access interrupts.
|
||||
#define AM_REG_IOSLAVE_REGACCINTSET_REGACC_S 0
|
||||
#define AM_REG_IOSLAVE_REGACCINTSET_REGACC_M 0xFFFFFFFF
|
||||
#define AM_REG_IOSLAVE_REGACCINTSET_REGACC(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_FIFOPTR - Current FIFO Pointer
|
||||
//
|
||||
//*****************************************************************************
|
||||
// The number of bytes currently in the hardware FIFO.
|
||||
#define AM_REG_IOSLAVE_FIFOPTR_FIFOSIZ_S 8
|
||||
#define AM_REG_IOSLAVE_FIFOPTR_FIFOSIZ_M 0x0000FF00
|
||||
#define AM_REG_IOSLAVE_FIFOPTR_FIFOSIZ(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Current FIFO pointer.
|
||||
#define AM_REG_IOSLAVE_FIFOPTR_FIFOPTR_S 0
|
||||
#define AM_REG_IOSLAVE_FIFOPTR_FIFOPTR_M 0x000000FF
|
||||
#define AM_REG_IOSLAVE_FIFOPTR_FIFOPTR(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_FIFOCFG - FIFO Configuration
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Defines the read-only area. The IO Slave read-only area is situated in LRAM
|
||||
// at (ROBASE*8) to (FIFOOBASE*8-1)
|
||||
#define AM_REG_IOSLAVE_FIFOCFG_ROBASE_S 24
|
||||
#define AM_REG_IOSLAVE_FIFOCFG_ROBASE_M 0x3F000000
|
||||
#define AM_REG_IOSLAVE_FIFOCFG_ROBASE(n) (((uint32_t)(n) << 24) & 0x3F000000)
|
||||
|
||||
// These bits hold the maximum FIFO address in 8 byte segments. It is also the
|
||||
// beginning of the RAM area of the LRAM. Note that no RAM area is configured
|
||||
// if FIFOMAX is set to 0x1F.
|
||||
#define AM_REG_IOSLAVE_FIFOCFG_FIFOMAX_S 8
|
||||
#define AM_REG_IOSLAVE_FIFOCFG_FIFOMAX_M 0x00003F00
|
||||
#define AM_REG_IOSLAVE_FIFOCFG_FIFOMAX(n) (((uint32_t)(n) << 8) & 0x00003F00)
|
||||
|
||||
// These bits hold the base address of the I/O FIFO in 8 byte segments. The IO
|
||||
// Slave FIFO is situated in LRAM at (FIFOBASE*8) to (FIFOMAX*8-1).
|
||||
#define AM_REG_IOSLAVE_FIFOCFG_FIFOBASE_S 0
|
||||
#define AM_REG_IOSLAVE_FIFOCFG_FIFOBASE_M 0x0000001F
|
||||
#define AM_REG_IOSLAVE_FIFOCFG_FIFOBASE(n) (((uint32_t)(n) << 0) & 0x0000001F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_FIFOTHR - FIFO Threshold Configuration
|
||||
//
|
||||
//*****************************************************************************
|
||||
// FIFO size interrupt threshold.
|
||||
#define AM_REG_IOSLAVE_FIFOTHR_FIFOTHR_S 0
|
||||
#define AM_REG_IOSLAVE_FIFOTHR_FIFOTHR_M 0x000000FF
|
||||
#define AM_REG_IOSLAVE_FIFOTHR_FIFOTHR(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_FUPD - FIFO Update Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bitfield indicates an IO read is active.
|
||||
#define AM_REG_IOSLAVE_FUPD_IOREAD_S 1
|
||||
#define AM_REG_IOSLAVE_FUPD_IOREAD_M 0x00000002
|
||||
#define AM_REG_IOSLAVE_FUPD_IOREAD(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit indicates that a FIFO update is underway.
|
||||
#define AM_REG_IOSLAVE_FUPD_FIFOUPD_S 0
|
||||
#define AM_REG_IOSLAVE_FUPD_FIFOUPD_M 0x00000001
|
||||
#define AM_REG_IOSLAVE_FUPD_FIFOUPD(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_FIFOCTR - Overall FIFO Counter
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Virtual FIFO byte count
|
||||
#define AM_REG_IOSLAVE_FIFOCTR_FIFOCTR_S 0
|
||||
#define AM_REG_IOSLAVE_FIFOCTR_FIFOCTR_M 0x000003FF
|
||||
#define AM_REG_IOSLAVE_FIFOCTR_FIFOCTR(n) (((uint32_t)(n) << 0) & 0x000003FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_FIFOINC - Overall FIFO Counter Increment
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Increment the Overall FIFO Counter by this value on a write
|
||||
#define AM_REG_IOSLAVE_FIFOINC_FIFOINC_S 0
|
||||
#define AM_REG_IOSLAVE_FIFOINC_FIFOINC_M 0x000003FF
|
||||
#define AM_REG_IOSLAVE_FIFOINC_FIFOINC(n) (((uint32_t)(n) << 0) & 0x000003FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_CFG - I/O Slave Configuration
|
||||
//
|
||||
//*****************************************************************************
|
||||
// IOSLAVE interface enable.
|
||||
#define AM_REG_IOSLAVE_CFG_IFCEN_S 31
|
||||
#define AM_REG_IOSLAVE_CFG_IFCEN_M 0x80000000
|
||||
#define AM_REG_IOSLAVE_CFG_IFCEN(n) (((uint32_t)(n) << 31) & 0x80000000)
|
||||
#define AM_REG_IOSLAVE_CFG_IFCEN_DIS 0x00000000
|
||||
#define AM_REG_IOSLAVE_CFG_IFCEN_EN 0x80000000
|
||||
|
||||
// 7-bit or 10-bit I2C device address.
|
||||
#define AM_REG_IOSLAVE_CFG_I2CADDR_S 8
|
||||
#define AM_REG_IOSLAVE_CFG_I2CADDR_M 0x000FFF00
|
||||
#define AM_REG_IOSLAVE_CFG_I2CADDR(n) (((uint32_t)(n) << 8) & 0x000FFF00)
|
||||
|
||||
// This bit holds the cycle to initiate an I/O RAM read.
|
||||
#define AM_REG_IOSLAVE_CFG_STARTRD_S 4
|
||||
#define AM_REG_IOSLAVE_CFG_STARTRD_M 0x00000010
|
||||
#define AM_REG_IOSLAVE_CFG_STARTRD(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
#define AM_REG_IOSLAVE_CFG_STARTRD_LATE 0x00000000
|
||||
#define AM_REG_IOSLAVE_CFG_STARTRD_EARLY 0x00000010
|
||||
|
||||
// This bit selects the transfer bit ordering.
|
||||
#define AM_REG_IOSLAVE_CFG_LSB_S 2
|
||||
#define AM_REG_IOSLAVE_CFG_LSB_M 0x00000004
|
||||
#define AM_REG_IOSLAVE_CFG_LSB(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_IOSLAVE_CFG_LSB_MSB_FIRST 0x00000000
|
||||
#define AM_REG_IOSLAVE_CFG_LSB_LSB_FIRST 0x00000004
|
||||
|
||||
// This bit selects SPI polarity.
|
||||
#define AM_REG_IOSLAVE_CFG_SPOL_S 1
|
||||
#define AM_REG_IOSLAVE_CFG_SPOL_M 0x00000002
|
||||
#define AM_REG_IOSLAVE_CFG_SPOL(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_IOSLAVE_CFG_SPOL_SPI_MODES_0_3 0x00000000
|
||||
#define AM_REG_IOSLAVE_CFG_SPOL_SPI_MODES_1_2 0x00000002
|
||||
|
||||
// This bit selects the I/O interface.
|
||||
#define AM_REG_IOSLAVE_CFG_IFCSEL_S 0
|
||||
#define AM_REG_IOSLAVE_CFG_IFCSEL_M 0x00000001
|
||||
#define AM_REG_IOSLAVE_CFG_IFCSEL(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_IOSLAVE_CFG_IFCSEL_I2C 0x00000000
|
||||
#define AM_REG_IOSLAVE_CFG_IFCSEL_SPI 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_PRENC - I/O Slave Interrupt Priority Encode
|
||||
//
|
||||
//*****************************************************************************
|
||||
// These bits hold the priority encode of the REGACC interrupts.
|
||||
#define AM_REG_IOSLAVE_PRENC_PRENC_S 0
|
||||
#define AM_REG_IOSLAVE_PRENC_PRENC_M 0x0000001F
|
||||
#define AM_REG_IOSLAVE_PRENC_PRENC(n) (((uint32_t)(n) << 0) & 0x0000001F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_IOINTCTL - I/O Interrupt Control
|
||||
//
|
||||
//*****************************************************************************
|
||||
// These bits set the IOINT interrupts when written with a 1.
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINTSET_S 24
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINTSET_M 0xFF000000
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINTSET(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// This bit clears all of the IOINT interrupts when written with a 1.
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINTCLR_S 16
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINTCLR_M 0x00010000
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINTCLR(n) (((uint32_t)(n) << 16) & 0x00010000)
|
||||
|
||||
// These bits read the IOINT interrupts.
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINT_S 8
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINT_M 0x0000FF00
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINT(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// These bits setread the IOINT interrupt enables.
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINTEN_S 0
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINTEN_M 0x000000FF
|
||||
#define AM_REG_IOSLAVE_IOINTCTL_IOINTEN(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// IOSLAVE_GENADD - General Address Data
|
||||
//
|
||||
//*****************************************************************************
|
||||
// The data supplied on the last General Address reference.
|
||||
#define AM_REG_IOSLAVE_GENADD_GADATA_S 0
|
||||
#define AM_REG_IOSLAVE_GENADD_GADATA_M 0x000000FF
|
||||
#define AM_REG_IOSLAVE_GENADD_GADATA(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
#endif // AM_REG_IOSLAVE_H
|
||||
@@ -0,0 +1,662 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_itm.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the ITM module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_ITM_H
|
||||
#define AM_REG_ITM_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_ITM_NUM_MODULES 1
|
||||
#define AM_REG_ITMn(n) \
|
||||
(REG_ITM_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_ITM_STIM0_O 0xE0000000
|
||||
#define AM_REG_ITM_STIM1_O 0xE0000004
|
||||
#define AM_REG_ITM_STIM2_O 0xE0000008
|
||||
#define AM_REG_ITM_STIM3_O 0xE000000C
|
||||
#define AM_REG_ITM_STIM4_O 0xE0000010
|
||||
#define AM_REG_ITM_STIM5_O 0xE0000014
|
||||
#define AM_REG_ITM_STIM6_O 0xE0000018
|
||||
#define AM_REG_ITM_STIM7_O 0xE000001C
|
||||
#define AM_REG_ITM_STIM8_O 0xE0000020
|
||||
#define AM_REG_ITM_STIM9_O 0xE0000024
|
||||
#define AM_REG_ITM_STIM10_O 0xE0000028
|
||||
#define AM_REG_ITM_STIM11_O 0xE000002C
|
||||
#define AM_REG_ITM_STIM12_O 0xE0000030
|
||||
#define AM_REG_ITM_STIM13_O 0xE0000034
|
||||
#define AM_REG_ITM_STIM14_O 0xE0000038
|
||||
#define AM_REG_ITM_STIM15_O 0xE000003C
|
||||
#define AM_REG_ITM_STIM16_O 0xE0000040
|
||||
#define AM_REG_ITM_STIM17_O 0xE0000044
|
||||
#define AM_REG_ITM_STIM18_O 0xE0000048
|
||||
#define AM_REG_ITM_STIM19_O 0xE000004C
|
||||
#define AM_REG_ITM_STIM20_O 0xE0000050
|
||||
#define AM_REG_ITM_STIM21_O 0xE0000054
|
||||
#define AM_REG_ITM_STIM22_O 0xE0000058
|
||||
#define AM_REG_ITM_STIM23_O 0xE000005C
|
||||
#define AM_REG_ITM_STIM24_O 0xE0000060
|
||||
#define AM_REG_ITM_STIM25_O 0xE0000064
|
||||
#define AM_REG_ITM_STIM26_O 0xE0000068
|
||||
#define AM_REG_ITM_STIM27_O 0xE000006C
|
||||
#define AM_REG_ITM_STIM28_O 0xE0000070
|
||||
#define AM_REG_ITM_STIM29_O 0xE0000074
|
||||
#define AM_REG_ITM_STIM30_O 0xE0000078
|
||||
#define AM_REG_ITM_STIM31_O 0xE000007C
|
||||
#define AM_REG_ITM_TER_O 0xE0000E00
|
||||
#define AM_REG_ITM_TPR_O 0xE0000E40
|
||||
#define AM_REG_ITM_TCR_O 0xE0000E80
|
||||
#define AM_REG_ITM_LOCKSREG_O 0xE0000FB4
|
||||
#define AM_REG_ITM_PID4_O 0xE0000FD0
|
||||
#define AM_REG_ITM_PID5_O 0xE0000FD4
|
||||
#define AM_REG_ITM_PID6_O 0xE0000FD8
|
||||
#define AM_REG_ITM_PID7_O 0xE0000FDC
|
||||
#define AM_REG_ITM_PID0_O 0xE0000FE0
|
||||
#define AM_REG_ITM_PID1_O 0xE0000FE4
|
||||
#define AM_REG_ITM_PID2_O 0xE0000FE8
|
||||
#define AM_REG_ITM_PID3_O 0xE0000FEC
|
||||
#define AM_REG_ITM_CID0_O 0xE0000FF0
|
||||
#define AM_REG_ITM_CID1_O 0xE0000FF4
|
||||
#define AM_REG_ITM_CID2_O 0xE0000FF8
|
||||
#define AM_REG_ITM_CID3_O 0xE0000FFC
|
||||
#define AM_REG_ITM_LOCKAREG_O 0xE0000FB0
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Key values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_ITM_LOCKAREG_KEYVAL 0xC5ACCE55
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM0 - Stimulus Port Register 0
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 0.
|
||||
#define AM_REG_ITM_STIM0_STIM0_S 0
|
||||
#define AM_REG_ITM_STIM0_STIM0_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM0_STIM0(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM1 - Stimulus Port Register 1
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 1.
|
||||
#define AM_REG_ITM_STIM1_STIM1_S 0
|
||||
#define AM_REG_ITM_STIM1_STIM1_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM1_STIM1(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM2 - Stimulus Port Register 2
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 2.
|
||||
#define AM_REG_ITM_STIM2_STIM2_S 0
|
||||
#define AM_REG_ITM_STIM2_STIM2_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM2_STIM2(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM3 - Stimulus Port Register 3
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 3.
|
||||
#define AM_REG_ITM_STIM3_STIM3_S 0
|
||||
#define AM_REG_ITM_STIM3_STIM3_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM3_STIM3(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM4 - Stimulus Port Register 4
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 4.
|
||||
#define AM_REG_ITM_STIM4_STIM4_S 0
|
||||
#define AM_REG_ITM_STIM4_STIM4_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM4_STIM4(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM5 - Stimulus Port Register 5
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 5.
|
||||
#define AM_REG_ITM_STIM5_STIM5_S 0
|
||||
#define AM_REG_ITM_STIM5_STIM5_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM5_STIM5(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM6 - Stimulus Port Register 6
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 6.
|
||||
#define AM_REG_ITM_STIM6_STIM6_S 0
|
||||
#define AM_REG_ITM_STIM6_STIM6_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM6_STIM6(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM7 - Stimulus Port Register 7
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 7.
|
||||
#define AM_REG_ITM_STIM7_STIM7_S 0
|
||||
#define AM_REG_ITM_STIM7_STIM7_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM7_STIM7(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM8 - Stimulus Port Register 8
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 8.
|
||||
#define AM_REG_ITM_STIM8_STIM8_S 0
|
||||
#define AM_REG_ITM_STIM8_STIM8_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM8_STIM8(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM9 - Stimulus Port Register 9
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 9.
|
||||
#define AM_REG_ITM_STIM9_STIM9_S 0
|
||||
#define AM_REG_ITM_STIM9_STIM9_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM9_STIM9(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM10 - Stimulus Port Register 10
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 10.
|
||||
#define AM_REG_ITM_STIM10_STIM10_S 0
|
||||
#define AM_REG_ITM_STIM10_STIM10_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM10_STIM10(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM11 - Stimulus Port Register 11
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 11.
|
||||
#define AM_REG_ITM_STIM11_STIM11_S 0
|
||||
#define AM_REG_ITM_STIM11_STIM11_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM11_STIM11(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM12 - Stimulus Port Register 12
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 12.
|
||||
#define AM_REG_ITM_STIM12_STIM12_S 0
|
||||
#define AM_REG_ITM_STIM12_STIM12_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM12_STIM12(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM13 - Stimulus Port Register 13
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 13.
|
||||
#define AM_REG_ITM_STIM13_STIM13_S 0
|
||||
#define AM_REG_ITM_STIM13_STIM13_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM13_STIM13(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM14 - Stimulus Port Register 14
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 14.
|
||||
#define AM_REG_ITM_STIM14_STIM14_S 0
|
||||
#define AM_REG_ITM_STIM14_STIM14_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM14_STIM14(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM15 - Stimulus Port Register 15
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 15.
|
||||
#define AM_REG_ITM_STIM15_STIM15_S 0
|
||||
#define AM_REG_ITM_STIM15_STIM15_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM15_STIM15(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM16 - Stimulus Port Register 16
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 16.
|
||||
#define AM_REG_ITM_STIM16_STIM16_S 0
|
||||
#define AM_REG_ITM_STIM16_STIM16_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM16_STIM16(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM17 - Stimulus Port Register 17
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 17.
|
||||
#define AM_REG_ITM_STIM17_STIM17_S 0
|
||||
#define AM_REG_ITM_STIM17_STIM17_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM17_STIM17(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM18 - Stimulus Port Register 18
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 18.
|
||||
#define AM_REG_ITM_STIM18_STIM18_S 0
|
||||
#define AM_REG_ITM_STIM18_STIM18_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM18_STIM18(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM19 - Stimulus Port Register 19
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 19.
|
||||
#define AM_REG_ITM_STIM19_STIM19_S 0
|
||||
#define AM_REG_ITM_STIM19_STIM19_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM19_STIM19(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM20 - Stimulus Port Register 20
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 20.
|
||||
#define AM_REG_ITM_STIM20_STIM20_S 0
|
||||
#define AM_REG_ITM_STIM20_STIM20_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM20_STIM20(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM21 - Stimulus Port Register 21
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 21.
|
||||
#define AM_REG_ITM_STIM21_STIM21_S 0
|
||||
#define AM_REG_ITM_STIM21_STIM21_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM21_STIM21(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM22 - Stimulus Port Register 22
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 22.
|
||||
#define AM_REG_ITM_STIM22_STIM22_S 0
|
||||
#define AM_REG_ITM_STIM22_STIM22_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM22_STIM22(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM23 - Stimulus Port Register 23
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 23.
|
||||
#define AM_REG_ITM_STIM23_STIM23_S 0
|
||||
#define AM_REG_ITM_STIM23_STIM23_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM23_STIM23(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM24 - Stimulus Port Register 24
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 24.
|
||||
#define AM_REG_ITM_STIM24_STIM24_S 0
|
||||
#define AM_REG_ITM_STIM24_STIM24_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM24_STIM24(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM25 - Stimulus Port Register 25
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 25.
|
||||
#define AM_REG_ITM_STIM25_STIM25_S 0
|
||||
#define AM_REG_ITM_STIM25_STIM25_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM25_STIM25(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM26 - Stimulus Port Register 26
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 26.
|
||||
#define AM_REG_ITM_STIM26_STIM26_S 0
|
||||
#define AM_REG_ITM_STIM26_STIM26_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM26_STIM26(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM27 - Stimulus Port Register 27
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 27.
|
||||
#define AM_REG_ITM_STIM27_STIM27_S 0
|
||||
#define AM_REG_ITM_STIM27_STIM27_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM27_STIM27(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM28 - Stimulus Port Register 28
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 28.
|
||||
#define AM_REG_ITM_STIM28_STIM28_S 0
|
||||
#define AM_REG_ITM_STIM28_STIM28_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM28_STIM28(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM29 - Stimulus Port Register 29
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 29.
|
||||
#define AM_REG_ITM_STIM29_STIM29_S 0
|
||||
#define AM_REG_ITM_STIM29_STIM29_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM29_STIM29(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM30 - Stimulus Port Register 30
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 30.
|
||||
#define AM_REG_ITM_STIM30_STIM30_S 0
|
||||
#define AM_REG_ITM_STIM30_STIM30_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM30_STIM30(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_STIM31 - Stimulus Port Register 31
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Stimulus Port Register 31.
|
||||
#define AM_REG_ITM_STIM31_STIM31_S 0
|
||||
#define AM_REG_ITM_STIM31_STIM31_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_STIM31_STIM31(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_TER - Trace Enable Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Bit mask to enable tracing on ITM stimulus ports. One bit per stimulus port..
|
||||
#define AM_REG_ITM_TER_STIMENA_S 0
|
||||
#define AM_REG_ITM_TER_STIMENA_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_TER_STIMENA(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_TPR - Trace Privilege Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Bit mask to enable tracing on ITM stimulus ports. bit[0] = stimulus
|
||||
// ports[7:0], bit[1] = stimulus ports[15:8], bit[2] = stimulus ports[23:16],
|
||||
// bit[3] = stimulus ports[31:24].
|
||||
#define AM_REG_ITM_TPR_PRIVMASK_S 0
|
||||
#define AM_REG_ITM_TPR_PRIVMASK_M 0x0000000F
|
||||
#define AM_REG_ITM_TPR_PRIVMASK(n) (((uint32_t)(n) << 0) & 0x0000000F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_TCR - Trace Control Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Set when ITM events present and being drained.
|
||||
#define AM_REG_ITM_TCR_BUSY_S 23
|
||||
#define AM_REG_ITM_TCR_BUSY_M 0x00800000
|
||||
#define AM_REG_ITM_TCR_BUSY(n) (((uint32_t)(n) << 23) & 0x00800000)
|
||||
|
||||
// ATB ID for CoreSight system.
|
||||
#define AM_REG_ITM_TCR_ATB_ID_S 16
|
||||
#define AM_REG_ITM_TCR_ATB_ID_M 0x007F0000
|
||||
#define AM_REG_ITM_TCR_ATB_ID(n) (((uint32_t)(n) << 16) & 0x007F0000)
|
||||
|
||||
// Global Timestamp Frequency.
|
||||
#define AM_REG_ITM_TCR_TS_FREQ_S 10
|
||||
#define AM_REG_ITM_TCR_TS_FREQ_M 0x00000C00
|
||||
#define AM_REG_ITM_TCR_TS_FREQ(n) (((uint32_t)(n) << 10) & 0x00000C00)
|
||||
|
||||
// Timestamp prescaler: 0b00 = no prescaling 0b01 = divide by 4 0b10 = divide by
|
||||
// 16 0b11 = divide by 64.
|
||||
#define AM_REG_ITM_TCR_TS_PRESCALE_S 8
|
||||
#define AM_REG_ITM_TCR_TS_PRESCALE_M 0x00000300
|
||||
#define AM_REG_ITM_TCR_TS_PRESCALE(n) (((uint32_t)(n) << 8) & 0x00000300)
|
||||
|
||||
// Enable SWV (Serial Wire Viewer) behavior - count on TPIUEMIT and TPIUBAUD:
|
||||
// Aka SWOENA Enables asynchronous clocking of the timestamp counter.
|
||||
#define AM_REG_ITM_TCR_SWV_ENABLE_S 4
|
||||
#define AM_REG_ITM_TCR_SWV_ENABLE_M 0x00000010
|
||||
#define AM_REG_ITM_TCR_SWV_ENABLE(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// Enables the DWT stimulus.
|
||||
#define AM_REG_ITM_TCR_DWT_ENABLE_S 3
|
||||
#define AM_REG_ITM_TCR_DWT_ENABLE_M 0x00000008
|
||||
#define AM_REG_ITM_TCR_DWT_ENABLE(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// Enables sync packets for TPIU.
|
||||
#define AM_REG_ITM_TCR_SYNC_ENABLE_S 2
|
||||
#define AM_REG_ITM_TCR_SYNC_ENABLE_M 0x00000004
|
||||
#define AM_REG_ITM_TCR_SYNC_ENABLE(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Enables differential timestamps. Differential timestamps are emitted when a
|
||||
// packet is written to the FIFO with a non-zero timestamp counter, and when the
|
||||
// timestamp counter overflows. Timestamps are emitted during idle times after a
|
||||
// fixed number of cycles. This provides a time reference for packets and inter-
|
||||
// packet gaps.
|
||||
#define AM_REG_ITM_TCR_TS_ENABLE_S 1
|
||||
#define AM_REG_ITM_TCR_TS_ENABLE_M 0x00000002
|
||||
#define AM_REG_ITM_TCR_TS_ENABLE(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Enable ITM. This is the master enable, and must be set before ITM Stimulus
|
||||
// and Trace Enable registers can be written.
|
||||
#define AM_REG_ITM_TCR_ITM_ENABLE_S 0
|
||||
#define AM_REG_ITM_TCR_ITM_ENABLE_M 0x00000001
|
||||
#define AM_REG_ITM_TCR_ITM_ENABLE(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_LOCKSREG - Lock Status Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// You cannot implement 8-bit lock accesses.
|
||||
#define AM_REG_ITM_LOCKSREG_BYTEACC_S 2
|
||||
#define AM_REG_ITM_LOCKSREG_BYTEACC_M 0x00000004
|
||||
#define AM_REG_ITM_LOCKSREG_BYTEACC(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Write access to component is blocked. All writes are ignored, reads are
|
||||
// permitted.
|
||||
#define AM_REG_ITM_LOCKSREG_ACCESS_S 1
|
||||
#define AM_REG_ITM_LOCKSREG_ACCESS_M 0x00000002
|
||||
#define AM_REG_ITM_LOCKSREG_ACCESS(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Indicates that a lock mechanism exists for this component.
|
||||
#define AM_REG_ITM_LOCKSREG_PRESENT_S 0
|
||||
#define AM_REG_ITM_LOCKSREG_PRESENT_M 0x00000001
|
||||
#define AM_REG_ITM_LOCKSREG_PRESENT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_PID4 - Peripheral Identification Register 4
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Peripheral Identification 4.
|
||||
#define AM_REG_ITM_PID4_PID4_S 0
|
||||
#define AM_REG_ITM_PID4_PID4_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_PID4_PID4(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_PID5 - Peripheral Identification Register 5
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Peripheral Identification 5.
|
||||
#define AM_REG_ITM_PID5_PID5_S 0
|
||||
#define AM_REG_ITM_PID5_PID5_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_PID5_PID5(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_PID6 - Peripheral Identification Register 6
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Peripheral Identification 6.
|
||||
#define AM_REG_ITM_PID6_PID6_S 0
|
||||
#define AM_REG_ITM_PID6_PID6_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_PID6_PID6(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_PID7 - Peripheral Identification Register 7
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Peripheral Identification 7.
|
||||
#define AM_REG_ITM_PID7_PID7_S 0
|
||||
#define AM_REG_ITM_PID7_PID7_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_PID7_PID7(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_PID0 - Peripheral Identification Register 0
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Peripheral Identification 0.
|
||||
#define AM_REG_ITM_PID0_PID0_S 0
|
||||
#define AM_REG_ITM_PID0_PID0_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_PID0_PID0(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_PID1 - Peripheral Identification Register 1
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Peripheral Identification 1.
|
||||
#define AM_REG_ITM_PID1_PID1_S 0
|
||||
#define AM_REG_ITM_PID1_PID1_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_PID1_PID1(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_PID2 - Peripheral Identification Register 2
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Peripheral Identification 2.
|
||||
#define AM_REG_ITM_PID2_PID2_S 0
|
||||
#define AM_REG_ITM_PID2_PID2_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_PID2_PID2(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_PID3 - Peripheral Identification Register 3
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Peripheral Identification 3.
|
||||
#define AM_REG_ITM_PID3_PID3_S 0
|
||||
#define AM_REG_ITM_PID3_PID3_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_PID3_PID3(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_CID0 - Component Identification Register 1
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Component Identification 1.
|
||||
#define AM_REG_ITM_CID0_CID0_S 0
|
||||
#define AM_REG_ITM_CID0_CID0_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_CID0_CID0(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_CID1 - Component Identification Register 1
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Component Identification 1.
|
||||
#define AM_REG_ITM_CID1_CID1_S 0
|
||||
#define AM_REG_ITM_CID1_CID1_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_CID1_CID1(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_CID2 - Component Identification Register 2
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Component Identification 2.
|
||||
#define AM_REG_ITM_CID2_CID2_S 0
|
||||
#define AM_REG_ITM_CID2_CID2_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_CID2_CID2(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// ITM_CID3 - Component Identification Register 3
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Component Identification 3.
|
||||
#define AM_REG_ITM_CID3_CID3_S 0
|
||||
#define AM_REG_ITM_CID3_CID3_M 0xFFFFFFFF
|
||||
#define AM_REG_ITM_CID3_CID3(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
#endif // AM_REG_ITM_H
|
||||
@@ -0,0 +1,219 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_jedec.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the JEDEC module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_JEDEC_H
|
||||
#define AM_REG_JEDEC_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_JEDEC_NUM_MODULES 1
|
||||
#define AM_REG_JEDECn(n) \
|
||||
(REG_JEDEC_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_JEDEC_PID4_O 0xF0000FD0
|
||||
#define AM_REG_JEDEC_PID5_O 0xF0000FD4
|
||||
#define AM_REG_JEDEC_PID6_O 0xF0000FD8
|
||||
#define AM_REG_JEDEC_PID7_O 0xF0000FDC
|
||||
#define AM_REG_JEDEC_PID0_O 0xF0000FE0
|
||||
#define AM_REG_JEDEC_PID1_O 0xF0000FE4
|
||||
#define AM_REG_JEDEC_PID2_O 0xF0000FE8
|
||||
#define AM_REG_JEDEC_PID3_O 0xF0000FEC
|
||||
#define AM_REG_JEDEC_CID0_O 0xF0000FF0
|
||||
#define AM_REG_JEDEC_CID1_O 0xF0000FF4
|
||||
#define AM_REG_JEDEC_CID2_O 0xF0000FF8
|
||||
#define AM_REG_JEDEC_CID3_O 0xF0000FFC
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_PID4 - JEP Continuation Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Contains the JEP Continuation bits.
|
||||
#define AM_REG_JEDEC_PID4_JEPCONT_S 0
|
||||
#define AM_REG_JEDEC_PID4_JEPCONT_M 0x0000000F
|
||||
#define AM_REG_JEDEC_PID4_JEPCONT(n) (((uint32_t)(n) << 0) & 0x0000000F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_PID5 - JEP reserved Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Contains the value of 0x00000000.
|
||||
#define AM_REG_JEDEC_PID5_VALUE_S 0
|
||||
#define AM_REG_JEDEC_PID5_VALUE_M 0xFFFFFFFF
|
||||
#define AM_REG_JEDEC_PID5_VALUE(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_PID6 - JEP reserved Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Contains the value of 0x00000000.
|
||||
#define AM_REG_JEDEC_PID6_VALUE_S 0
|
||||
#define AM_REG_JEDEC_PID6_VALUE_M 0xFFFFFFFF
|
||||
#define AM_REG_JEDEC_PID6_VALUE(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_PID7 - JEP reserved Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Contains the value of 0x00000000.
|
||||
#define AM_REG_JEDEC_PID7_VALUE_S 0
|
||||
#define AM_REG_JEDEC_PID7_VALUE_M 0xFFFFFFFF
|
||||
#define AM_REG_JEDEC_PID7_VALUE(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_PID0 - Ambiq Partnum low byte
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Contains the low 8 bits of the Ambiq Micro device part number.
|
||||
#define AM_REG_JEDEC_PID0_PNL8_S 0
|
||||
#define AM_REG_JEDEC_PID0_PNL8_M 0x000000FF
|
||||
#define AM_REG_JEDEC_PID0_PNL8(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_PID1 - Ambiq part number high-nibble, JEPID low-nibble.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Contains the low 4 bits of the Ambiq Micro JEDEC JEP-106 ID. The full JEPID
|
||||
// is therefore 0x9B.
|
||||
#define AM_REG_JEDEC_PID1_JEPIDL_S 4
|
||||
#define AM_REG_JEDEC_PID1_JEPIDL_M 0x000000F0
|
||||
#define AM_REG_JEDEC_PID1_JEPIDL(n) (((uint32_t)(n) << 4) & 0x000000F0)
|
||||
|
||||
// Contains the high 4 bits of the Ambiq Micro device part number.
|
||||
#define AM_REG_JEDEC_PID1_PNH4_S 0
|
||||
#define AM_REG_JEDEC_PID1_PNH4_M 0x0000000F
|
||||
#define AM_REG_JEDEC_PID1_PNH4(n) (((uint32_t)(n) << 0) & 0x0000000F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_PID2 - Ambiq chip revision low-nibble, JEPID high-nibble
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Contains the high 4 bits of the Ambiq Micro CHIPREV (see also
|
||||
// MCUCTRL.CHIPREV). Note that this field will change with each revision of the
|
||||
// chip.
|
||||
#define AM_REG_JEDEC_PID2_CHIPREVH4_S 4
|
||||
#define AM_REG_JEDEC_PID2_CHIPREVH4_M 0x000000F0
|
||||
#define AM_REG_JEDEC_PID2_CHIPREVH4(n) (((uint32_t)(n) << 4) & 0x000000F0)
|
||||
|
||||
// Contains the high 3 bits of the Ambiq Micro JEPID. Note that bit3 of this
|
||||
// field is hard-coded to 1. The full JEPID is therefore 0x9B.
|
||||
#define AM_REG_JEDEC_PID2_JEPIDH_S 0
|
||||
#define AM_REG_JEDEC_PID2_JEPIDH_M 0x0000000F
|
||||
#define AM_REG_JEDEC_PID2_JEPIDH(n) (((uint32_t)(n) << 0) & 0x0000000F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_PID3 - Ambiq chip revision high-nibble.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Contains the low 4 bits of the Ambiq Micro CHIPREV (see also
|
||||
// MCUCTRL.CHIPREV). Note that this field will change with each revision of the
|
||||
// chip.
|
||||
#define AM_REG_JEDEC_PID3_CHIPREVL4_S 4
|
||||
#define AM_REG_JEDEC_PID3_CHIPREVL4_M 0x000000F0
|
||||
#define AM_REG_JEDEC_PID3_CHIPREVL4(n) (((uint32_t)(n) << 4) & 0x000000F0)
|
||||
|
||||
// This field is hard-coded to 0x0.
|
||||
#define AM_REG_JEDEC_PID3_ZERO_S 0
|
||||
#define AM_REG_JEDEC_PID3_ZERO_M 0x0000000F
|
||||
#define AM_REG_JEDEC_PID3_ZERO(n) (((uint32_t)(n) << 0) & 0x0000000F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_CID0 - Coresight ROM Table.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Coresight ROM Table, CID0.
|
||||
#define AM_REG_JEDEC_CID0_CID_S 0
|
||||
#define AM_REG_JEDEC_CID0_CID_M 0x000000FF
|
||||
#define AM_REG_JEDEC_CID0_CID(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_CID1 - Coresight ROM Table.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Coresight ROM Table, CID1.
|
||||
#define AM_REG_JEDEC_CID1_CID_S 0
|
||||
#define AM_REG_JEDEC_CID1_CID_M 0x000000FF
|
||||
#define AM_REG_JEDEC_CID1_CID(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_CID2 - Coresight ROM Table.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Coresight ROM Table, CID2.
|
||||
#define AM_REG_JEDEC_CID2_CID_S 0
|
||||
#define AM_REG_JEDEC_CID2_CID_M 0x000000FF
|
||||
#define AM_REG_JEDEC_CID2_CID(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// JEDEC_CID3 - Coresight ROM Table.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Coresight ROM Table, CID3.
|
||||
#define AM_REG_JEDEC_CID3_CID_S 0
|
||||
#define AM_REG_JEDEC_CID3_CID_M 0x000000FF
|
||||
#define AM_REG_JEDEC_CID3_CID(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
#endif // AM_REG_JEDEC_H
|
||||
@@ -0,0 +1,371 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_macros.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Helper macros for using hardware registers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef AM_REG_MACROS_H
|
||||
#define AM_REG_MACROS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Include the inline assembly macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#include "am_reg_macros_asm.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// High-level Helper Macros.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// For direct 32-bit access to a register, use AM_REGVAL:
|
||||
// AM_REGVAL(REG_VCOMP_BASEADDR + AM_VCOMP_VCMPCFG_O) |= 0xDEADBEEF;
|
||||
//
|
||||
// The AM_REG macro can also be used as a shorthand version of AM_REGVAL:
|
||||
// AM_REG(VCOMP, VCMPCFG) |= 0xDEADBEEF;
|
||||
//
|
||||
// The AM_REGn macro is used for accessing registers of peripherals with
|
||||
// multiple instances, such as IOMSTR.
|
||||
// AM_REGn(IOMSTR, 1, CLKCFG) |= 0xDEADBEEF;
|
||||
//
|
||||
// To write to a specific bitfield within a register, use AM_BFW or AM_BFWn:
|
||||
// AM_BFW(CTIMER, 0, CTCTRL0, TMRB0FN, 0x3);
|
||||
//
|
||||
// To read a field, use AM_BFR or AM_BFRn:
|
||||
// ui32Timer0Fn = AM_BFR((CTIMER, 0, CTCTRL0, TMRB0FN);
|
||||
//
|
||||
// Note:
|
||||
//
|
||||
// AM_REGn, AM_BFW and AM_BFR are concatenation-based, which means that
|
||||
// standalone macro definitions should not be used for the 'module', 'reg', and
|
||||
// 'field' arguments.All macro names in the various peripheral header files are
|
||||
// written in one of the following forms:
|
||||
// - AM_REG_##module_reg_O
|
||||
// - AM_REG_##module_reg_field_S
|
||||
// - AM_REG_##module_reg_field_M
|
||||
//
|
||||
// The "module", "reg" and "field" fragments may be used as valid arguments to
|
||||
// the AM_REGn, AM_BFW, and AM_BFR macros, all of which are able to perform the
|
||||
// necessary concatenation operations to reconstruct the full macros and look
|
||||
// up the appropriate base address for the instance number given. For
|
||||
// peripherals with only one instance, use instance number 0.
|
||||
//
|
||||
// The AM_REGVAL macro does not perform any concatenation operations, so the
|
||||
// complete macro name (including any suffix) must be specified.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REGVAL(x) (*((volatile uint32_t *)(x)))
|
||||
#define AM_REGVAL_FLOAT(x) (*((volatile float *)(x)))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register access macros for single-instance modules
|
||||
// AM_REG - Write a register of a module.
|
||||
// AM_BFW - Write a value to a bitfield of a register.
|
||||
// AM_BFWe - Use a defined enum value to write a value to a register bitfield.
|
||||
// AM_BFR - Read a bitfield value from a register.
|
||||
// AM_BFM - Read and mask a bitfield from a register, but leave the value in
|
||||
// its bit position. Useful for comparing with enums.
|
||||
//
|
||||
// AM_BFV - Move a value to a bitfield. This macro is used for creating a
|
||||
// value, it does not modify any register.
|
||||
// AM_BFX - Extract the value of a bitfield from a 32-bit value, such as that
|
||||
// read from a register. Does not read or modify any register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG(module, reg) \
|
||||
/*AM_REGn(m, 0, r) */ \
|
||||
(*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O)))
|
||||
|
||||
#define AM_BFW(module, reg, field, value) \
|
||||
/* AM_BFWn(m,0,r,f,v) */ \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) = \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) & \
|
||||
(~AM_REG_##module##_##reg##_##field##_M)) | \
|
||||
(((uint32_t)(value) << AM_REG_##module##_##reg##_##field##_S) & \
|
||||
AM_REG_##module##_##reg##_##field##_M) )
|
||||
|
||||
#define AM_BFWe(module, reg, field, enumval) \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) = \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) & \
|
||||
(~AM_REG_##module##_##reg##_##field##_M)) | \
|
||||
(AM_REG_##module##_##reg##_##field##_##enumval))
|
||||
|
||||
#define AM_BFR(module, reg, field) \
|
||||
/* AM_BFRn(m,0,r,f) */ \
|
||||
( ( (uint32_t) \
|
||||
(*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) & \
|
||||
AM_REG_##module##_##reg##_##field##_M ) >> \
|
||||
AM_REG_##module##_##reg##_##field##_S )
|
||||
|
||||
#define AM_BFM(module, reg, field) \
|
||||
/* AM_BFMn(m,0,r,f) */ \
|
||||
( (*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) & \
|
||||
AM_REG_##module##_##reg##_##field##_M)
|
||||
|
||||
#define AM_BFV(module, reg, field, value) \
|
||||
(((uint32_t)(value) << AM_REG_##module##_##reg##_##field##_S) & \
|
||||
AM_REG_##module##_##reg##_##field##_M)
|
||||
|
||||
#define AM_BFX(module, reg, field, value) \
|
||||
(((uint32_t)(value) & AM_REG_##module##_##reg##_##field##_M) >> \
|
||||
AM_REG_##module##_##reg##_##field##_S)
|
||||
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register access macros for multi-instance modules
|
||||
// AM_REGADDRn - Calc the register address inside a multiple instance module.
|
||||
// AM_REGn - Write a register of a multiple instance module.
|
||||
// AM_BFWn - Write a value to a bitfield of a register in a multiple instance.
|
||||
// AM_BFWen - Use a defined enum value to write a value to a bitfield of a
|
||||
// register in a multiple instance.
|
||||
// AM_BFRn - Read a bitfield value from a register in a multiple instance.
|
||||
// AM_BFMn - Read and mask a bitfield, but leave the value in its bit position.
|
||||
// (Useful for comparing with enums.)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REGADDRn(module, instance, reg) \
|
||||
(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O)
|
||||
|
||||
|
||||
#define AM_REGn(module, instance, reg) \
|
||||
(*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O)))
|
||||
|
||||
#define AM_BFWn(module, instance, reg, field, value) \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) = \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) & \
|
||||
(~AM_REG_##module##_##reg##_##field##_M)) | \
|
||||
(((uint32_t)(value) << AM_REG_##module##_##reg##_##field##_S) & \
|
||||
AM_REG_##module##_##reg##_##field##_M) )
|
||||
|
||||
#define AM_BFWen(module, instance, reg, field, enumval) \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) = \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) & \
|
||||
(~AM_REG_##module##_##reg##_##field##_M)) | \
|
||||
(AM_REG_##module##_##reg##_##field##_##enumval))
|
||||
|
||||
#define AM_BFRn(module, instance, reg, field) \
|
||||
( ( (uint32_t) \
|
||||
(*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) & \
|
||||
AM_REG_##module##_##reg##_##field##_M ) >> \
|
||||
AM_REG_##module##_##reg##_##field##_S )
|
||||
|
||||
#define AM_BFMn(module, instance, reg, field) \
|
||||
( (*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) & \
|
||||
AM_REG_##module##_##reg##_##field##_M)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// "Atomic" register access macros - use when a read-modify-write is required.
|
||||
//
|
||||
// These macros will be slower than the normal macros, but they will also
|
||||
// guarantee threadsafe hardware access.
|
||||
//
|
||||
// These macros require a nesting-friendly critical section implementation. If
|
||||
// you are using the HAL, you can use the default definitions below. If not,
|
||||
// you will need to supply your own.
|
||||
//
|
||||
// Atomic register access macros usage:
|
||||
// AM_REGa - Write a register of a single instance module. Provide operator
|
||||
// (&,|,etc) to perform that operation on the reg using value, or
|
||||
// no operator to simply write the value atomically.
|
||||
// AM_REGa_SET - Set bits in a single instance module according to the mask.
|
||||
// AM_REGa_CLR - Clear bits in a single instance module according to the mask.
|
||||
// AM_REGan - Multiple module version of AM_REGa.
|
||||
// AM_REGan_SET - Multiple instance version of AM_REGa_SET.
|
||||
// AM_REGan_CLR - Multiple instance version of AM_REGa_CLR.
|
||||
// AM_BFWa - Write a value to a register bitfield.
|
||||
// AM_BFWae - Use a defined enum value to write a value to a bitfield.
|
||||
// AM_BFWan - Write a value to a bitfield of a register in a multiple instance.
|
||||
// AM_BFWaen - Use a defined enum value to write a value to a bitfield of a
|
||||
// register in a multiple instance.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
|
||||
#define AM_REGan(module, instance, reg, operator, value) \
|
||||
AM_CRITICAL_BEGIN \
|
||||
/* AM_REGn(m, i, r) <op>= (value) */ \
|
||||
(*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) operator##= (value); \
|
||||
AM_CRITICAL_END
|
||||
|
||||
#define AM_REGan_SET(module, instance, reg, mask) \
|
||||
AM_CRITICAL_BEGIN \
|
||||
(*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) |= (mask); \
|
||||
AM_CRITICAL_END
|
||||
|
||||
#define AM_REGan_CLR(module, instance, reg, mask) \
|
||||
AM_CRITICAL_BEGIN \
|
||||
(*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) &= (~mask); \
|
||||
AM_CRITICAL_END
|
||||
|
||||
#define AM_REGa(module, reg, operator, value) \
|
||||
/* AM_REGan(m,0,r,op,v) */ \
|
||||
AM_CRITICAL_BEGIN \
|
||||
(*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) operator##= (value); \
|
||||
AM_CRITICAL_END
|
||||
|
||||
#define AM_REGa_CLR(module, reg, mask) \
|
||||
/* AM_REGan_CLR(m, 0, r, m) */ \
|
||||
AM_CRITICAL_BEGIN \
|
||||
(*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) &= (~mask); \
|
||||
AM_CRITICAL_END
|
||||
|
||||
#define AM_REGa_SET(module, reg, mask) \
|
||||
/* AM_REGan_SET(m, 0, r, m) */ \
|
||||
AM_CRITICAL_BEGIN \
|
||||
(*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) |= (mask); \
|
||||
AM_CRITICAL_END
|
||||
|
||||
#define AM_BFWa(module, reg, field, value) \
|
||||
AM_CRITICAL_BEGIN \
|
||||
/* AM_BFW(module, reg, field, value); */ \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) = \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) & \
|
||||
(~AM_REG_##module##_##reg##_##field##_M)) | \
|
||||
(((uint32_t)(value) << AM_REG_##module##_##reg##_##field##_S) & \
|
||||
AM_REG_##module##_##reg##_##field##_M) ); \
|
||||
AM_CRITICAL_END
|
||||
|
||||
#define AM_BFWae(module, reg, field, enumval) \
|
||||
AM_CRITICAL_BEGIN \
|
||||
/* AM_BFWe(module, reg, field, enumval); */ \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) = \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(0) + AM_REG_##module##_##reg##_O))) & \
|
||||
(~AM_REG_##module##_##reg##_##field##_M)) | \
|
||||
(AM_REG_##module##_##reg##_##field##_##enumval)); \
|
||||
AM_CRITICAL_END
|
||||
|
||||
#define AM_BFWan(module, instance, reg, field, value) \
|
||||
AM_CRITICAL_BEGIN \
|
||||
/* AM_BFWn(module, instance, reg, field, enumval); */ \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) = \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) & \
|
||||
(~AM_REG_##module##_##reg##_##field##_M)) | \
|
||||
(((uint32_t)(value) << AM_REG_##module##_##reg##_##field##_S) & \
|
||||
AM_REG_##module##_##reg##_##field##_M) ); \
|
||||
AM_CRITICAL_END
|
||||
|
||||
#define AM_BFWaen(module, instance, reg, field, enumval) \
|
||||
AM_CRITICAL_BEGIN \
|
||||
/* AM_BFWen(module, instance reg, field, enumval); */ \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) = \
|
||||
((*((volatile uint32_t *)(AM_REG_##module##n(instance) + AM_REG_##module##_##reg##_O))) & \
|
||||
(~AM_REG_##module##_##reg##_##field##_M)) | \
|
||||
(AM_REG_##module##_##reg##_##field##_##enumval)); \
|
||||
AM_CRITICAL_END
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Other helper Macros.
|
||||
//
|
||||
// Note: These macros make use of macro concatenation, so the '_S' or '_M'
|
||||
// suffix on a register bitfield macro should not be supplied by the user.
|
||||
// The macro will apply each suffix as needed.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//
|
||||
// AM_ENUMX extracts a register bitfield enumeration to the bit 0 position,
|
||||
// which makes it possible to use enums directly with existing macros such
|
||||
// as AM_BFR() or AM_BFW().
|
||||
// Brief overview: bitfield enumerations are pre-shifted such that the defined
|
||||
// value lines up with the bitfield. This is convenient for many operations,
|
||||
// but not so when using AM_BFR() to read the value of a register bitfield
|
||||
// as AM_BFR() shifts the bitfield value to the bit 0 position.
|
||||
// Note that this type of bitfield extraction is Cortex efficient via the
|
||||
// UBFX (unsigned bit field extract) instruction.
|
||||
//
|
||||
// Alternately, AM_BFM() can also be used. AM_BFM() reads a register and masks
|
||||
// the bitfield value (without shifting), thereby allowing direct comparison
|
||||
// with a defined enum.
|
||||
//
|
||||
// Examples:
|
||||
// if ( AM_BFR(CLKGEN, CCTRL, CORESEL) ==
|
||||
// AM_ENUMX(CLKGEN, CCTRL, CORESEL, HFRC) )
|
||||
//
|
||||
// or alternatively:
|
||||
// if ( AM_BFM(CLKGEN, CCTRL, CORESEL) == AM_REG_CLKGEN_CCTRL_CORESEL_HFRC )
|
||||
//
|
||||
#define AM_ENUMX(module, reg, field, enumname) \
|
||||
((AM_REG_##module##_##reg##_##field##_##enumname) >> \
|
||||
(AM_REG_##module##_##reg##_##field##_S))
|
||||
|
||||
//
|
||||
// AM_WRITE_SM performs a shift/mask operation to prepare the value 'x' to be
|
||||
// written to the register field 'field'.
|
||||
//
|
||||
// For example:
|
||||
// AM_REGVAL(ui32Base + AM_VCOMP_VCMP_CFG_O) |=
|
||||
// AM_WRITE_SM(AM_VCOMP_VCMP_CFG_LVLSEL, ui32Value);
|
||||
//
|
||||
#define AM_WRITE_SM(field, x) (((x) << field##_S) & field##_M)
|
||||
|
||||
//
|
||||
// AM_READ_SM performs a shift/mask operation to make it easier to interpret
|
||||
// the value of a given bitfield. This is essentially the reverse of the
|
||||
// AM_WRITE_SM operation. In most cases, you will want to use the shorter
|
||||
// AM_BFR macro instead of this one.
|
||||
//
|
||||
// For example:
|
||||
// ui32Value = AM_READ_SM(AM_VCOMP_VCMP_CFG_NSEL,
|
||||
// AM_REGVAL(ui32Base + AM_VCOMP_VCMP_CFG_O));
|
||||
//
|
||||
#define AM_READ_SM(field, x) (((x) & field##_M) >> field##_S)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_REG_MACROS_H
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_macros_asm.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Inline assembly macros. Initially for critical section handling in
|
||||
//! protecting hardware registers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef AM_REG_MACROS_ASM_H
|
||||
#define AM_REG_MACROS_ASM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Critical section assembly macros
|
||||
//
|
||||
// These macros implement critical section protection using inline assembly
|
||||
// for various compilers. They are intended to be used in other register
|
||||
// macros or directly in sections of code.
|
||||
//
|
||||
// Important usage note: These macros create a local scope and therefore MUST
|
||||
// be used in pairs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_CRITICAL_BEGIN \
|
||||
if ( 1 ) \
|
||||
{ \
|
||||
volatile uint32_t ui32Primask_04172010; \
|
||||
ui32Primask_04172010 = am_hal_interrupt_master_disable();
|
||||
|
||||
#define AM_CRITICAL_END \
|
||||
am_hal_interrupt_master_set(ui32Primask_04172010); \
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// A collection of some common inline assembly instructions / intrinsics.
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// AM_ASM_BKPT(n)
|
||||
//
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
#define AM_ASM_BKPT(n) __breakpoint(n)
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
#define AM_ASM_BKPT(n) __asm(" bkpt "#n);
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
#define AM_ASM_BKPT(n) __asm(" bkpt "#n);
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#define AM_ASM_BKPT(n) asm(" bkpt "#n);
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
//
|
||||
// AM_ASM_WFI
|
||||
//
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
#define AM_ASM_WFI __wfi();
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
#define AM_ASM_WFI __asm(" wfi");
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
#define AM_ASM_WFI __asm(" wfi");
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#define AM_ASM_WFI asm(" wfi");
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
//
|
||||
// AM_ASM_WFE
|
||||
//
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
#define AM_ASM_WFE __wfe();
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
#define AM_ASM_WFE __asm(" wfe");
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
#define AM_ASM_WFE __asm(" wfe");
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#define AM_ASM_WFE asm(" wfe");
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
//
|
||||
// AM_ASM_SEV
|
||||
//
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
#define AM_ASM_SEV __sev();
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
#define AM_ASM_SEV __asm(" sev");
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
#define AM_ASM_SEV __asm(" sev");
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#define AM_ASM_SEV asm(" sev");
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
//
|
||||
// AM_ASM_NOP
|
||||
//
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
#define AM_ASM_NOP __nop();
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
#define AM_ASM_NOP __asm(" nop");
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
#define AM_ASM_NOP __asm(" nop");
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#define AM_ASM_NOP asm(" nop");
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
//
|
||||
// AM_ASM_DSB
|
||||
// In cmsis_armcc.h, __DSB() is defined as __dsb(0xF).
|
||||
//
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
#define AM_ASM_DSB __dsb(15);
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
#define AM_ASM_DSB __asm(" dsb #15");
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
#define AM_ASM_DSB __asm(" dsb #15");
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#define AM_ASM_DSB asm(" dsb #15");
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
//
|
||||
// AM_ASM_ISB
|
||||
// In cmsis_armcc.h, __ISB() is defined as __isb(0xF).
|
||||
//
|
||||
#if (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION < 6000000)
|
||||
#define AM_ASM_ISB __isb(15);
|
||||
#elif (defined (__ARMCC_VERSION)) && (__ARMCC_VERSION >= 6000000)
|
||||
#define AM_ASM_ISB __asm(" isb #15");
|
||||
#elif defined(__GNUC_STDC_INLINE__)
|
||||
#define AM_ASM_ISB __asm(" isb #15");
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#define AM_ASM_ISB asm(" isb #15");
|
||||
#else
|
||||
#error Compiler is unknown, please contact Ambiq support team
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_REG_MACROS_ASM_H
|
||||
|
||||
@@ -0,0 +1,489 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_mcuctrl.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the MCUCTRL module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_MCUCTRL_H
|
||||
#define AM_REG_MCUCTRL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_MCUCTRL_NUM_MODULES 1
|
||||
#define AM_REG_MCUCTRLn(n) \
|
||||
(REG_MCUCTRL_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_O 0x00000000
|
||||
#define AM_REG_MCUCTRL_CHIPID0_O 0x00000004
|
||||
#define AM_REG_MCUCTRL_CHIPID1_O 0x00000008
|
||||
#define AM_REG_MCUCTRL_CHIPREV_O 0x0000000C
|
||||
#define AM_REG_MCUCTRL_SUPPLYSRC_O 0x00000010
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_O 0x00000014
|
||||
#define AM_REG_MCUCTRL_BANDGAPEN_O 0x000000FC
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_O 0x00000140
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_O 0x00000144
|
||||
#define AM_REG_MCUCTRL_FLASHPWRDIS_O 0x00000148
|
||||
#define AM_REG_MCUCTRL_ICODEFAULTADDR_O 0x000001C0
|
||||
#define AM_REG_MCUCTRL_DCODEFAULTADDR_O 0x000001C4
|
||||
#define AM_REG_MCUCTRL_SYSFAULTADDR_O 0x000001C8
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_O 0x000001CC
|
||||
#define AM_REG_MCUCTRL_FAULTCAPTUREEN_O 0x000001D0
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_O 0x00000250
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_CHIP_INFO - Chip Information Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Device class.
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_CLASS_S 24
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_CLASS_M 0xFF000000
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_CLASS(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_CLASS_APOLLO 0x01000000
|
||||
|
||||
// Device flash size.
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_FLASH_S 20
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_FLASH_M 0x00F00000
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_FLASH(n) (((uint32_t)(n) << 20) & 0x00F00000)
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_FLASH_256K 0x00300000
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_FLASH_512K 0x00400000
|
||||
|
||||
// Device RAM size.
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_RAM_S 16
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_RAM_M 0x000F0000
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_RAM(n) (((uint32_t)(n) << 16) & 0x000F0000)
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_RAM_32K 0x00000000
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_RAM_64K 0x00010000
|
||||
|
||||
// Major device revision number.
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_MAJORREV_S 12
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_MAJORREV_M 0x0000F000
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_MAJORREV(n) (((uint32_t)(n) << 12) & 0x0000F000)
|
||||
|
||||
// Minor device revision number.
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_MINORREV_S 8
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_MINORREV_M 0x00000F00
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_MINORREV(n) (((uint32_t)(n) << 8) & 0x00000F00)
|
||||
|
||||
// Device package type.
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_PKG_S 6
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_PKG_M 0x000000C0
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_PKG(n) (((uint32_t)(n) << 6) & 0x000000C0)
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_PKG_BGA 0x00000080
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_PKG_CSP 0x000000C0
|
||||
|
||||
// Number of pins.
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_PINS_S 3
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_PINS_M 0x00000038
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_PINS(n) (((uint32_t)(n) << 3) & 0x00000038)
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_PINS_41PINS 0x00000008
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_PINS_64PINS 0x00000008
|
||||
|
||||
// Device temperature range.
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_TEMP_S 1
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_TEMP_M 0x00000006
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_TEMP(n) (((uint32_t)(n) << 1) & 0x00000006)
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_TEMP_COMMERCIAL 0x00000000
|
||||
|
||||
// Device qualified.
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_QUAL_S 0
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_QUAL_M 0x00000001
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_QUAL(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_QUAL_PROTOTYPE 0x00000000
|
||||
#define AM_REG_MCUCTRL_CHIP_INFO_QUAL_QUALIFIED 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_CHIPID0 - Unique Chip ID 0
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Unique chip ID 0.
|
||||
#define AM_REG_MCUCTRL_CHIPID0_VALUE_S 0
|
||||
#define AM_REG_MCUCTRL_CHIPID0_VALUE_M 0xFFFFFFFF
|
||||
#define AM_REG_MCUCTRL_CHIPID0_VALUE(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
#define AM_REG_MCUCTRL_CHIPID0_VALUE_APOLLO 0x00000000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_CHIPID1 - Unique Chip ID 1
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Unique chip ID 1.
|
||||
#define AM_REG_MCUCTRL_CHIPID1_VALUE_S 0
|
||||
#define AM_REG_MCUCTRL_CHIPID1_VALUE_M 0xFFFFFFFF
|
||||
#define AM_REG_MCUCTRL_CHIPID1_VALUE(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
#define AM_REG_MCUCTRL_CHIPID1_VALUE_APOLLO 0x00000000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_CHIPREV - Chip Revision
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Chip Revision Number.
|
||||
#define AM_REG_MCUCTRL_CHIPREV_REVISION_S 0
|
||||
#define AM_REG_MCUCTRL_CHIPREV_REVISION_M 0x000000FF
|
||||
#define AM_REG_MCUCTRL_CHIPREV_REVISION(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
#define AM_REG_MCUCTRL_CHIPREV_REVISION_APOLLO 0x00000000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_SUPPLYSRC - Memory and Core Voltage Supply Source Select Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Enables and Selects the Core Buck as the supply for the low-voltage power
|
||||
// domain.
|
||||
#define AM_REG_MCUCTRL_SUPPLYSRC_COREBUCKEN_S 1
|
||||
#define AM_REG_MCUCTRL_SUPPLYSRC_COREBUCKEN_M 0x00000002
|
||||
#define AM_REG_MCUCTRL_SUPPLYSRC_COREBUCKEN(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_MCUCTRL_SUPPLYSRC_COREBUCKEN_EN 0x00000002
|
||||
|
||||
// Enables and select the Memory Buck as the supply for the Flash and SRAM power
|
||||
// domain.
|
||||
#define AM_REG_MCUCTRL_SUPPLYSRC_MEMBUCKEN_S 0
|
||||
#define AM_REG_MCUCTRL_SUPPLYSRC_MEMBUCKEN_M 0x00000001
|
||||
#define AM_REG_MCUCTRL_SUPPLYSRC_MEMBUCKEN(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_MCUCTRL_SUPPLYSRC_MEMBUCKEN_EN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_SUPPLYSTATUS - Memory and Core Voltage Supply Source Status Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Indicates whether the Core low-voltage domain is supplied from the LDO or the
|
||||
// Buck.
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_COREBUCKON_S 1
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_COREBUCKON_M 0x00000002
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_COREBUCKON(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_COREBUCKON_LDO 0x00000000
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_COREBUCKON_BUCK 0x00000002
|
||||
|
||||
// Indicate whether the Memory power domain is supplied from the LDO or the
|
||||
// Buck.
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_MEMBUCKON_S 0
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_MEMBUCKON_M 0x00000001
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_MEMBUCKON(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_MEMBUCKON_LDO 0x00000000
|
||||
#define AM_REG_MCUCTRL_SUPPLYSTATUS_MEMBUCKON_BUCK 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_BANDGAPEN - Band Gap Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Bandgap Enable
|
||||
#define AM_REG_MCUCTRL_BANDGAPEN_BGPEN_S 0
|
||||
#define AM_REG_MCUCTRL_BANDGAPEN_BGPEN_M 0x00000001
|
||||
#define AM_REG_MCUCTRL_BANDGAPEN_BGPEN(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_MCUCTRL_BANDGAPEN_BGPEN_DIS 0x00000000
|
||||
#define AM_REG_MCUCTRL_BANDGAPEN_BGPEN_EN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_SRAMPWDINSLEEP - Powerdown an SRAM Bank in Deep Sleep mode
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Force SRAM Bank 7 to powerdown in deep sleep mode, causing the contents of
|
||||
// the bank to be lost.
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK7_S 7
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK7_M 0x00000080
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK7(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK7_NORMAL 0x00000000
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK7_PWRDN_IN_DEEPSLEEP 0x00000080
|
||||
|
||||
// Force SRAM Bank 6 to powerdown in deep sleep mode, causing the contents of
|
||||
// the bank to be lost.
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK6_S 6
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK6_M 0x00000040
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK6(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK6_NORMAL 0x00000000
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK6_PWRDN_IN_DEEPSLEEP 0x00000040
|
||||
|
||||
// Force SRAM Bank 5 to powerdown in deep sleep mode, causing the contents of
|
||||
// the bank to be lost.
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK5_S 5
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK5_M 0x00000020
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK5(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK5_NORMAL 0x00000000
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK5_PWRDN_IN_DEEPSLEEP 0x00000020
|
||||
|
||||
// Force SRAM Bank 4 to powerdown in deep sleep mode, causing the contents of
|
||||
// the bank to be lost.
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK4_S 4
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK4_M 0x00000010
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK4(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK4_NORMAL 0x00000000
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK4_PWRDN_IN_DEEPSLEEP 0x00000010
|
||||
|
||||
// Force SRAM Bank 3 to powerdown in deep sleep mode, causing the contents of
|
||||
// the bank to be lost.
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK3_S 3
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK3_M 0x00000008
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK3(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK3_NORMAL 0x00000000
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK3_PWRDN_IN_DEEPSLEEP 0x00000008
|
||||
|
||||
// Force SRAM Bank 2 to powerdown in deep sleep mode, causing the contents of
|
||||
// the bank to be lost.
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK2_S 2
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK2_M 0x00000004
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK2(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK2_NORMAL 0x00000000
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK2_PWRDN_IN_DEEPSLEEP 0x00000004
|
||||
|
||||
// Force SRAM Bank 1 to powerdown in deep sleep mode, causing the contents of
|
||||
// the bank to be lost.
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK1_S 1
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK1_M 0x00000002
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK1(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK1_NORMAL 0x00000000
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK1_PWRDN_IN_DEEPSLEEP 0x00000002
|
||||
|
||||
// Force SRAM Bank 0 to powerdown in deep sleep mode, causing the contents of
|
||||
// the bank to be lost.
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK0_S 0
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK0_M 0x00000001
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK0(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK0_NORMAL 0x00000000
|
||||
#define AM_REG_MCUCTRL_SRAMPWDINSLEEP_BANK0_PWRDN_IN_DEEPSLEEP 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_SRAMPWRDIS - Disables individual banks of the SRAM array
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Remove power from SRAM Bank 7 which will cause an access to its address space
|
||||
// to generate a Hard Fault.
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK7_S 7
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK7_M 0x00000080
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK7(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK7_DIS 0x00000080
|
||||
|
||||
// Remove power from SRAM Bank 6 which will cause an access to its address space
|
||||
// to generate a Hard Fault.
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK6_S 6
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK6_M 0x00000040
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK6(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK6_DIS 0x00000040
|
||||
|
||||
// Remove power from SRAM Bank 5 which will cause an access to its address space
|
||||
// to generate a Hard Fault.
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK5_S 5
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK5_M 0x00000020
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK5(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK5_DIS 0x00000020
|
||||
|
||||
// Remove power from SRAM Bank 4 which will cause an access to its address space
|
||||
// to generate a Hard Fault.
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK4_S 4
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK4_M 0x00000010
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK4(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK4_DIS 0x00000010
|
||||
|
||||
// Remove power from SRAM Bank 3 which will cause an access to its address space
|
||||
// to generate a Hard Fault.
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK3_S 3
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK3_M 0x00000008
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK3(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK3_DIS 0x00000008
|
||||
|
||||
// Remove power from SRAM Bank 2 which will cause an access to its address space
|
||||
// to generate a Hard Fault.
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK2_S 2
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK2_M 0x00000004
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK2(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK2_DIS 0x00000004
|
||||
|
||||
// Remove power from SRAM Bank 1 which will cause an access to its address space
|
||||
// to generate a Hard Fault.
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK1_S 1
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK1_M 0x00000002
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK1(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK1_DIS 0x00000002
|
||||
|
||||
// Remove power from SRAM Bank 0 which will cause an access to its address space
|
||||
// to generate a Hard Fault.
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK0_S 0
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK0_M 0x00000001
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK0(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_MCUCTRL_SRAMPWRDIS_BANK0_DIS 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_FLASHPWRDIS - Disables individual banks of the Flash array
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Remove power from Flash Bank 1 which will cause an access to its address
|
||||
// space to generate a Hard Fault.
|
||||
#define AM_REG_MCUCTRL_FLASHPWRDIS_BANK1_S 1
|
||||
#define AM_REG_MCUCTRL_FLASHPWRDIS_BANK1_M 0x00000002
|
||||
#define AM_REG_MCUCTRL_FLASHPWRDIS_BANK1(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_MCUCTRL_FLASHPWRDIS_BANK1_DIS 0x00000002
|
||||
|
||||
// Remove power from Flash Bank 0 which will cause an access to its address
|
||||
// space to generate a Hard Fault.
|
||||
#define AM_REG_MCUCTRL_FLASHPWRDIS_BANK0_S 0
|
||||
#define AM_REG_MCUCTRL_FLASHPWRDIS_BANK0_M 0x00000001
|
||||
#define AM_REG_MCUCTRL_FLASHPWRDIS_BANK0(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_MCUCTRL_FLASHPWRDIS_BANK0_DIS 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_ICODEFAULTADDR - ICODE bus address which was present when a bus fault
|
||||
// occurred.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// The ICODE bus address observed when a Bus Fault occurred. Once an address is
|
||||
// captured in this field, it is held until the corresponding Fault Observed bit
|
||||
// is cleared in the FAULTSTATUS register.
|
||||
#define AM_REG_MCUCTRL_ICODEFAULTADDR_ADDR_S 0
|
||||
#define AM_REG_MCUCTRL_ICODEFAULTADDR_ADDR_M 0xFFFFFFFF
|
||||
#define AM_REG_MCUCTRL_ICODEFAULTADDR_ADDR(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_DCODEFAULTADDR - DCODE bus address which was present when a bus fault
|
||||
// occurred.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// The DCODE bus address observed when a Bus Fault occurred. Once an address is
|
||||
// captured in this field, it is held until the corresponding Fault Observed bit
|
||||
// is cleared in the FAULTSTATUS register.
|
||||
#define AM_REG_MCUCTRL_DCODEFAULTADDR_ADDR_S 0
|
||||
#define AM_REG_MCUCTRL_DCODEFAULTADDR_ADDR_M 0xFFFFFFFF
|
||||
#define AM_REG_MCUCTRL_DCODEFAULTADDR_ADDR(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_SYSFAULTADDR - System bus address which was present when a bus fault
|
||||
// occurred.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// SYS bus address observed when a Bus Fault occurred. Once an address is
|
||||
// captured in this field, it is held until the corresponding Fault Observed bit
|
||||
// is cleared in the FAULTSTATUS register.
|
||||
#define AM_REG_MCUCTRL_SYSFAULTADDR_ADDR_S 0
|
||||
#define AM_REG_MCUCTRL_SYSFAULTADDR_ADDR_M 0xFFFFFFFF
|
||||
#define AM_REG_MCUCTRL_SYSFAULTADDR_ADDR(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_FAULTSTATUS - Reflects the status of the bus decoders' fault
|
||||
// detection. Any write to this register will clear all of the status bits
|
||||
// within the register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// SYS Bus Decoder Fault Detected bit. When set, a fault has been detected, and
|
||||
// the SYSFAULTADDR register will contain the bus address which generated the
|
||||
// fault.
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_SYS_S 2
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_SYS_M 0x00000004
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_SYS(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_SYS_NOFAULT 0x00000000
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_SYS_FAULT 0x00000004
|
||||
|
||||
// DCODE Bus Decoder Fault Detected bit. When set, a fault has been detected,
|
||||
// and the DCODEFAULTADDR register will contain the bus address which generated
|
||||
// the fault.
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_DCODE_S 1
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_DCODE_M 0x00000002
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_DCODE(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_DCODE_NOFAULT 0x00000000
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_DCODE_FAULT 0x00000002
|
||||
|
||||
// The ICODE Bus Decoder Fault Detected bit. When set, a fault has been
|
||||
// detected, and the ICODEFAULTADDR register will contain the bus address which
|
||||
// generated the fault.
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_ICODE_S 0
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_ICODE_M 0x00000001
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_ICODE(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_ICODE_NOFAULT 0x00000000
|
||||
#define AM_REG_MCUCTRL_FAULTSTATUS_ICODE_FAULT 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_FAULTCAPTUREEN - Enable the fault capture registers
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Fault Capture Enable field. When set, the Fault Capture monitors are enabled
|
||||
// and addresses which generate a hard fault are captured into the FAULTADDR
|
||||
// registers.
|
||||
#define AM_REG_MCUCTRL_FAULTCAPTUREEN_ENABLE_S 0
|
||||
#define AM_REG_MCUCTRL_FAULTCAPTUREEN_ENABLE_M 0x00000001
|
||||
#define AM_REG_MCUCTRL_FAULTCAPTUREEN_ENABLE(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_MCUCTRL_FAULTCAPTUREEN_ENABLE_DIS 0x00000000
|
||||
#define AM_REG_MCUCTRL_FAULTCAPTUREEN_ENABLE_EN 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MCUCTRL_TPIUCTRL - TPIU Control Register. Determines the clock enable and
|
||||
// frequency for the M4's TPIU interface.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This field selects the frequency of the ARM M4 TPIU port.
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_S 8
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_M 0x00000300
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_CLKSEL(n) (((uint32_t)(n) << 8) & 0x00000300)
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_LOW_PWR 0x00000000
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_0MHz 0x00000000
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_6MHZ 0x00000100
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_3MHZ 0x00000200
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_1_5MHZ 0x00000300
|
||||
|
||||
// TPIU Enable field. When set, the ARM M4 TPIU is enabled and data can be
|
||||
// streamed out of the MCU's SWO port using the ARM ITM and TPIU modules.
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_ENABLE_S 0
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_ENABLE_M 0x00000001
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_ENABLE(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_ENABLE_DIS 0x00000000
|
||||
#define AM_REG_MCUCTRL_TPIUCTRL_ENABLE_EN 0x00000001
|
||||
|
||||
#endif // AM_REG_MCUCTRL_H
|
||||
@@ -0,0 +1,329 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_nvic.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the NVIC module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_NVIC_H
|
||||
#define AM_REG_NVIC_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_NVIC_NUM_MODULES 1
|
||||
#define AM_REG_NVICn(n) \
|
||||
(REG_NVIC_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_NVIC_ISER0_O 0xE000E100
|
||||
#define AM_REG_NVIC_ICER0_O 0xE000E180
|
||||
#define AM_REG_NVIC_ISPR0_O 0xE000E200
|
||||
#define AM_REG_NVIC_ICPR0_O 0xE000E280
|
||||
#define AM_REG_NVIC_IABR0_O 0xE000E300
|
||||
#define AM_REG_NVIC_IPR0_O 0xE000E400
|
||||
#define AM_REG_NVIC_IPR1_O 0xE000E404
|
||||
#define AM_REG_NVIC_IPR2_O 0xE000E408
|
||||
#define AM_REG_NVIC_IPR3_O 0xE000E40C
|
||||
#define AM_REG_NVIC_IPR4_O 0xE000E410
|
||||
#define AM_REG_NVIC_IPR5_O 0xE000E414
|
||||
#define AM_REG_NVIC_IPR6_O 0xE000E418
|
||||
#define AM_REG_NVIC_IPR7_O 0xE000E41C
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_ISER0 - Interrupt Set-Enable Register 0
|
||||
//
|
||||
//*****************************************************************************
|
||||
// NVIC_ISERn[31:0] are the set-enable bits for interrupts 31 through 0.
|
||||
#define AM_REG_NVIC_ISER0_BITS_S 0
|
||||
#define AM_REG_NVIC_ISER0_BITS_M 0xFFFFFFFF
|
||||
#define AM_REG_NVIC_ISER0_BITS(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_ICER0 - Interrupt Clear-Enable Register 0
|
||||
//
|
||||
//*****************************************************************************
|
||||
// NVIC_ISERn[31:0] are the clear-enable bits for interrupts 31 through 0.
|
||||
#define AM_REG_NVIC_ICER0_BITS_S 0
|
||||
#define AM_REG_NVIC_ICER0_BITS_M 0xFFFFFFFF
|
||||
#define AM_REG_NVIC_ICER0_BITS(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_ISPR0 - Interrupt Set-Pending Register 0
|
||||
//
|
||||
//*****************************************************************************
|
||||
// NVIC_ISERn[31:0] are the set-pending bits for interrupts 31 through 0.
|
||||
#define AM_REG_NVIC_ISPR0_BITS_S 0
|
||||
#define AM_REG_NVIC_ISPR0_BITS_M 0xFFFFFFFF
|
||||
#define AM_REG_NVIC_ISPR0_BITS(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_ICPR0 - Interrupt Clear-Pending Register 0
|
||||
//
|
||||
//*****************************************************************************
|
||||
// NVIC_ISERn[31:0] are the clear-pending bits for interrupts 31 through 0.
|
||||
#define AM_REG_NVIC_ICPR0_BITS_S 0
|
||||
#define AM_REG_NVIC_ICPR0_BITS_M 0xFFFFFFFF
|
||||
#define AM_REG_NVIC_ICPR0_BITS(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_IABR0 - Interrupt Active Bit Register 0
|
||||
//
|
||||
//*****************************************************************************
|
||||
// NVIC_ISERn[31:0] are the interrupt active bits for interrupts 31 through 0.
|
||||
#define AM_REG_NVIC_IABR0_BITS_S 0
|
||||
#define AM_REG_NVIC_IABR0_BITS_M 0xFFFFFFFF
|
||||
#define AM_REG_NVIC_IABR0_BITS(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_IPR0 - Interrupt Priority Register 0
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Priority assignment for interrupt vector 3.
|
||||
#define AM_REG_NVIC_IPR0_PRI_N3_S 24
|
||||
#define AM_REG_NVIC_IPR0_PRI_N3_M 0xFF000000
|
||||
#define AM_REG_NVIC_IPR0_PRI_N3(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Priority assignment for interrupt vector 2.
|
||||
#define AM_REG_NVIC_IPR0_PRI_N2_S 16
|
||||
#define AM_REG_NVIC_IPR0_PRI_N2_M 0x00FF0000
|
||||
#define AM_REG_NVIC_IPR0_PRI_N2(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Priority assignment for interrupt vector 1.
|
||||
#define AM_REG_NVIC_IPR0_PRI_N1_S 8
|
||||
#define AM_REG_NVIC_IPR0_PRI_N1_M 0x0000FF00
|
||||
#define AM_REG_NVIC_IPR0_PRI_N1(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Priority assignment for interrupt vector 0.
|
||||
#define AM_REG_NVIC_IPR0_PRI_N0_S 0
|
||||
#define AM_REG_NVIC_IPR0_PRI_N0_M 0x000000FF
|
||||
#define AM_REG_NVIC_IPR0_PRI_N0(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_IPR1 - Interrupt Priority Register 1
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Priority assignment for interrupt vector 7.
|
||||
#define AM_REG_NVIC_IPR1_PRI_N3_S 24
|
||||
#define AM_REG_NVIC_IPR1_PRI_N3_M 0xFF000000
|
||||
#define AM_REG_NVIC_IPR1_PRI_N3(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Priority assignment for interrupt vector 6.
|
||||
#define AM_REG_NVIC_IPR1_PRI_N2_S 16
|
||||
#define AM_REG_NVIC_IPR1_PRI_N2_M 0x00FF0000
|
||||
#define AM_REG_NVIC_IPR1_PRI_N2(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Priority assignment for interrupt vector 5.
|
||||
#define AM_REG_NVIC_IPR1_PRI_N1_S 8
|
||||
#define AM_REG_NVIC_IPR1_PRI_N1_M 0x0000FF00
|
||||
#define AM_REG_NVIC_IPR1_PRI_N1(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Priority assignment for interrupt vector 4.
|
||||
#define AM_REG_NVIC_IPR1_PRI_N0_S 0
|
||||
#define AM_REG_NVIC_IPR1_PRI_N0_M 0x000000FF
|
||||
#define AM_REG_NVIC_IPR1_PRI_N0(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_IPR2 - Interrupt Priority Register 2
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Priority assignment for interrupt vector 11.
|
||||
#define AM_REG_NVIC_IPR2_PRI_N3_S 24
|
||||
#define AM_REG_NVIC_IPR2_PRI_N3_M 0xFF000000
|
||||
#define AM_REG_NVIC_IPR2_PRI_N3(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Priority assignment for interrupt vector 10.
|
||||
#define AM_REG_NVIC_IPR2_PRI_N2_S 16
|
||||
#define AM_REG_NVIC_IPR2_PRI_N2_M 0x00FF0000
|
||||
#define AM_REG_NVIC_IPR2_PRI_N2(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Priority assignment for interrupt vector 9.
|
||||
#define AM_REG_NVIC_IPR2_PRI_N1_S 8
|
||||
#define AM_REG_NVIC_IPR2_PRI_N1_M 0x0000FF00
|
||||
#define AM_REG_NVIC_IPR2_PRI_N1(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Priority assignment for interrupt vector 8.
|
||||
#define AM_REG_NVIC_IPR2_PRI_N0_S 0
|
||||
#define AM_REG_NVIC_IPR2_PRI_N0_M 0x000000FF
|
||||
#define AM_REG_NVIC_IPR2_PRI_N0(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_IPR3 - Interrupt Priority Register 3
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Priority assignment for interrupt vector 15.
|
||||
#define AM_REG_NVIC_IPR3_PRI_N3_S 24
|
||||
#define AM_REG_NVIC_IPR3_PRI_N3_M 0xFF000000
|
||||
#define AM_REG_NVIC_IPR3_PRI_N3(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Priority assignment for interrupt vector 14.
|
||||
#define AM_REG_NVIC_IPR3_PRI_N2_S 16
|
||||
#define AM_REG_NVIC_IPR3_PRI_N2_M 0x00FF0000
|
||||
#define AM_REG_NVIC_IPR3_PRI_N2(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Priority assignment for interrupt vector 13.
|
||||
#define AM_REG_NVIC_IPR3_PRI_N1_S 8
|
||||
#define AM_REG_NVIC_IPR3_PRI_N1_M 0x0000FF00
|
||||
#define AM_REG_NVIC_IPR3_PRI_N1(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Priority assignment for interrupt vector 12.
|
||||
#define AM_REG_NVIC_IPR3_PRI_N0_S 0
|
||||
#define AM_REG_NVIC_IPR3_PRI_N0_M 0x000000FF
|
||||
#define AM_REG_NVIC_IPR3_PRI_N0(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_IPR4 - Interrupt Priority Register 4
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Priority assignment for interrupt vector 19.
|
||||
#define AM_REG_NVIC_IPR4_PRI_N3_S 24
|
||||
#define AM_REG_NVIC_IPR4_PRI_N3_M 0xFF000000
|
||||
#define AM_REG_NVIC_IPR4_PRI_N3(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Priority assignment for interrupt vector 18.
|
||||
#define AM_REG_NVIC_IPR4_PRI_N2_S 16
|
||||
#define AM_REG_NVIC_IPR4_PRI_N2_M 0x00FF0000
|
||||
#define AM_REG_NVIC_IPR4_PRI_N2(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Priority assignment for interrupt vector 17.
|
||||
#define AM_REG_NVIC_IPR4_PRI_N1_S 8
|
||||
#define AM_REG_NVIC_IPR4_PRI_N1_M 0x0000FF00
|
||||
#define AM_REG_NVIC_IPR4_PRI_N1(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Priority assignment for interrupt vector 16.
|
||||
#define AM_REG_NVIC_IPR4_PRI_N0_S 0
|
||||
#define AM_REG_NVIC_IPR4_PRI_N0_M 0x000000FF
|
||||
#define AM_REG_NVIC_IPR4_PRI_N0(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_IPR5 - Interrupt Priority Register 5
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Priority assignment for interrupt vector 23.
|
||||
#define AM_REG_NVIC_IPR5_PRI_N3_S 24
|
||||
#define AM_REG_NVIC_IPR5_PRI_N3_M 0xFF000000
|
||||
#define AM_REG_NVIC_IPR5_PRI_N3(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Priority assignment for interrupt vector 22.
|
||||
#define AM_REG_NVIC_IPR5_PRI_N2_S 16
|
||||
#define AM_REG_NVIC_IPR5_PRI_N2_M 0x00FF0000
|
||||
#define AM_REG_NVIC_IPR5_PRI_N2(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Priority assignment for interrupt vector 21.
|
||||
#define AM_REG_NVIC_IPR5_PRI_N1_S 8
|
||||
#define AM_REG_NVIC_IPR5_PRI_N1_M 0x0000FF00
|
||||
#define AM_REG_NVIC_IPR5_PRI_N1(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Priority assignment for interrupt vector 20.
|
||||
#define AM_REG_NVIC_IPR5_PRI_N0_S 0
|
||||
#define AM_REG_NVIC_IPR5_PRI_N0_M 0x000000FF
|
||||
#define AM_REG_NVIC_IPR5_PRI_N0(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_IPR6 - Interrupt Priority Register 6
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Priority assignment for interrupt vector 27.
|
||||
#define AM_REG_NVIC_IPR6_PRI_N3_S 24
|
||||
#define AM_REG_NVIC_IPR6_PRI_N3_M 0xFF000000
|
||||
#define AM_REG_NVIC_IPR6_PRI_N3(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Priority assignment for interrupt vector 26.
|
||||
#define AM_REG_NVIC_IPR6_PRI_N2_S 16
|
||||
#define AM_REG_NVIC_IPR6_PRI_N2_M 0x00FF0000
|
||||
#define AM_REG_NVIC_IPR6_PRI_N2(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Priority assignment for interrupt vector 25.
|
||||
#define AM_REG_NVIC_IPR6_PRI_N1_S 8
|
||||
#define AM_REG_NVIC_IPR6_PRI_N1_M 0x0000FF00
|
||||
#define AM_REG_NVIC_IPR6_PRI_N1(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Priority assignment for interrupt vector 24.
|
||||
#define AM_REG_NVIC_IPR6_PRI_N0_S 0
|
||||
#define AM_REG_NVIC_IPR6_PRI_N0_M 0x000000FF
|
||||
#define AM_REG_NVIC_IPR6_PRI_N0(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NVIC_IPR7 - Interrupt Priority Register 7
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Priority assignment for interrupt vector 31.
|
||||
#define AM_REG_NVIC_IPR7_PRI_N3_S 24
|
||||
#define AM_REG_NVIC_IPR7_PRI_N3_M 0xFF000000
|
||||
#define AM_REG_NVIC_IPR7_PRI_N3(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Priority assignment for interrupt vector 30.
|
||||
#define AM_REG_NVIC_IPR7_PRI_N2_S 16
|
||||
#define AM_REG_NVIC_IPR7_PRI_N2_M 0x00FF0000
|
||||
#define AM_REG_NVIC_IPR7_PRI_N2(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Priority assignment for interrupt vector 29.
|
||||
#define AM_REG_NVIC_IPR7_PRI_N1_S 8
|
||||
#define AM_REG_NVIC_IPR7_PRI_N1_M 0x0000FF00
|
||||
#define AM_REG_NVIC_IPR7_PRI_N1(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Priority assignment for interrupt vector 28.
|
||||
#define AM_REG_NVIC_IPR7_PRI_N0_S 0
|
||||
#define AM_REG_NVIC_IPR7_PRI_N0_M 0x000000FF
|
||||
#define AM_REG_NVIC_IPR7_PRI_N0(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
#endif // AM_REG_NVIC_H
|
||||
@@ -0,0 +1,203 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_rstgen.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the RSTGEN module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_RSTGEN_H
|
||||
#define AM_REG_RSTGEN_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RSTGEN
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_RSTGEN_NUM_MODULES 1
|
||||
#define AM_REG_RSTGENn(n) \
|
||||
(REG_RSTGEN_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_RSTGEN_CFG_O 0x00000000
|
||||
#define AM_REG_RSTGEN_SWPOI_O 0x00000004
|
||||
#define AM_REG_RSTGEN_SWPOR_O 0x00000008
|
||||
#define AM_REG_RSTGEN_STAT_O 0x0000000C
|
||||
#define AM_REG_RSTGEN_CLRSTAT_O 0x00000010
|
||||
#define AM_REG_RSTGEN_INTEN_O 0x00000200
|
||||
#define AM_REG_RSTGEN_INTSTAT_O 0x00000204
|
||||
#define AM_REG_RSTGEN_INTCLR_O 0x00000208
|
||||
#define AM_REG_RSTGEN_INTSET_O 0x0000020C
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RSTGEN_INTEN - Reset Interrupt register: Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Enables an interrupt that triggers when VCC is below BODH level.
|
||||
#define AM_REG_RSTGEN_INTEN_BODH_S 0
|
||||
#define AM_REG_RSTGEN_INTEN_BODH_M 0x00000001
|
||||
#define AM_REG_RSTGEN_INTEN_BODH(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RSTGEN_INTSTAT - Reset Interrupt register: Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Enables an interrupt that triggers when VCC is below BODH level.
|
||||
#define AM_REG_RSTGEN_INTSTAT_BODH_S 0
|
||||
#define AM_REG_RSTGEN_INTSTAT_BODH_M 0x00000001
|
||||
#define AM_REG_RSTGEN_INTSTAT_BODH(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RSTGEN_INTCLR - Reset Interrupt register: Clear
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Enables an interrupt that triggers when VCC is below BODH level.
|
||||
#define AM_REG_RSTGEN_INTCLR_BODH_S 0
|
||||
#define AM_REG_RSTGEN_INTCLR_BODH_M 0x00000001
|
||||
#define AM_REG_RSTGEN_INTCLR_BODH(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RSTGEN_INTSET - Reset Interrupt register: Set
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Enables an interrupt that triggers when VCC is below BODH level.
|
||||
#define AM_REG_RSTGEN_INTSET_BODH_S 0
|
||||
#define AM_REG_RSTGEN_INTSET_BODH_M 0x00000001
|
||||
#define AM_REG_RSTGEN_INTSET_BODH(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RSTGEN_CFG - Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Watchdog Timer Reset Enable. NOTE: The WDT module must also be configured
|
||||
// for WDT reset.
|
||||
#define AM_REG_RSTGEN_CFG_WDREN_S 1
|
||||
#define AM_REG_RSTGEN_CFG_WDREN_M 0x00000002
|
||||
#define AM_REG_RSTGEN_CFG_WDREN(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Brown out high (2.1v) reset enable.
|
||||
#define AM_REG_RSTGEN_CFG_BODHREN_S 0
|
||||
#define AM_REG_RSTGEN_CFG_BODHREN_M 0x00000001
|
||||
#define AM_REG_RSTGEN_CFG_BODHREN(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RSTGEN_SWPOI - Software POI Reset
|
||||
//
|
||||
//*****************************************************************************
|
||||
// 0x1B generates a software POI reset.
|
||||
#define AM_REG_RSTGEN_SWPOI_SWPOIKEY_S 0
|
||||
#define AM_REG_RSTGEN_SWPOI_SWPOIKEY_M 0x000000FF
|
||||
#define AM_REG_RSTGEN_SWPOI_SWPOIKEY(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
#define AM_REG_RSTGEN_SWPOI_SWPOIKEY_KEYVALUE 0x0000001B
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RSTGEN_SWPOR - Software POR Reset
|
||||
//
|
||||
//*****************************************************************************
|
||||
// 0xD4 generates a software POR reset.
|
||||
#define AM_REG_RSTGEN_SWPOR_SWPORKEY_S 0
|
||||
#define AM_REG_RSTGEN_SWPOR_SWPORKEY_M 0x000000FF
|
||||
#define AM_REG_RSTGEN_SWPOR_SWPORKEY(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
#define AM_REG_RSTGEN_SWPOR_SWPORKEY_KEYVALUE 0x000000D4
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RSTGEN_STAT - Status Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Reset was initiated by a Watchdog Timer Reset.
|
||||
#define AM_REG_RSTGEN_STAT_WDRSTAT_S 6
|
||||
#define AM_REG_RSTGEN_STAT_WDRSTAT_M 0x00000040
|
||||
#define AM_REG_RSTGEN_STAT_WDRSTAT(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
|
||||
// Reset was a initiated by Debugger Reset.
|
||||
#define AM_REG_RSTGEN_STAT_DBGRSTAT_S 5
|
||||
#define AM_REG_RSTGEN_STAT_DBGRSTAT_M 0x00000020
|
||||
#define AM_REG_RSTGEN_STAT_DBGRSTAT(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// Reset was a initiated by Software POI Reset.
|
||||
#define AM_REG_RSTGEN_STAT_POIRSTAT_S 4
|
||||
#define AM_REG_RSTGEN_STAT_POIRSTAT_M 0x00000010
|
||||
#define AM_REG_RSTGEN_STAT_POIRSTAT(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// Reset was a initiated by SW POR or AIRCR Reset.
|
||||
#define AM_REG_RSTGEN_STAT_SWRSTAT_S 3
|
||||
#define AM_REG_RSTGEN_STAT_SWRSTAT_M 0x00000008
|
||||
#define AM_REG_RSTGEN_STAT_SWRSTAT(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// Reset was initiated by a Brown-Out Reset.
|
||||
#define AM_REG_RSTGEN_STAT_BORSTAT_S 2
|
||||
#define AM_REG_RSTGEN_STAT_BORSTAT_M 0x00000004
|
||||
#define AM_REG_RSTGEN_STAT_BORSTAT(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Reset was initiated by a Power-On Reset.
|
||||
#define AM_REG_RSTGEN_STAT_PORSTAT_S 1
|
||||
#define AM_REG_RSTGEN_STAT_PORSTAT_M 0x00000002
|
||||
#define AM_REG_RSTGEN_STAT_PORSTAT(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Reset was initiated by an External Reset.
|
||||
#define AM_REG_RSTGEN_STAT_EXRSTAT_S 0
|
||||
#define AM_REG_RSTGEN_STAT_EXRSTAT_M 0x00000001
|
||||
#define AM_REG_RSTGEN_STAT_EXRSTAT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RSTGEN_CLRSTAT - Clear the status register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Writing a 1 to this bit clears all bits in the RST_STAT.
|
||||
#define AM_REG_RSTGEN_CLRSTAT_CLRSTAT_S 0
|
||||
#define AM_REG_RSTGEN_CLRSTAT_CLRSTAT_M 0x00000001
|
||||
#define AM_REG_RSTGEN_CLRSTAT_CLRSTAT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
#endif // AM_REG_RSTGEN_H
|
||||
@@ -0,0 +1,330 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_rtc.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the RTC module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_RTC_H
|
||||
#define AM_REG_RTC_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RTC
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_RTC_NUM_MODULES 1
|
||||
#define AM_REG_RTCn(n) \
|
||||
(REG_RTC_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_RTC_CTRLOW_O 0x00000000
|
||||
#define AM_REG_RTC_CTRUP_O 0x00000004
|
||||
#define AM_REG_RTC_ALMLOW_O 0x00000008
|
||||
#define AM_REG_RTC_ALMUP_O 0x0000000C
|
||||
#define AM_REG_RTC_RTCCTL_O 0x00000010
|
||||
#define AM_REG_RTC_INTEN_O 0x000000C0
|
||||
#define AM_REG_RTC_INTSTAT_O 0x000000C4
|
||||
#define AM_REG_RTC_INTCLR_O 0x000000C8
|
||||
#define AM_REG_RTC_INTSET_O 0x000000CC
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RTC_INTEN - CLK_GEN Interrupt Register: Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// RTC Alarm interrupt
|
||||
#define AM_REG_RTC_INTEN_ALM_S 3
|
||||
#define AM_REG_RTC_INTEN_ALM_M 0x00000008
|
||||
#define AM_REG_RTC_INTEN_ALM(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// XT Oscillator Fail interrupt
|
||||
#define AM_REG_RTC_INTEN_OF_S 2
|
||||
#define AM_REG_RTC_INTEN_OF_M 0x00000004
|
||||
#define AM_REG_RTC_INTEN_OF(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Autocalibration Complete interrupt
|
||||
#define AM_REG_RTC_INTEN_ACC_S 1
|
||||
#define AM_REG_RTC_INTEN_ACC_M 0x00000002
|
||||
#define AM_REG_RTC_INTEN_ACC(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Autocalibration Fail interrupt
|
||||
#define AM_REG_RTC_INTEN_ACF_S 0
|
||||
#define AM_REG_RTC_INTEN_ACF_M 0x00000001
|
||||
#define AM_REG_RTC_INTEN_ACF(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RTC_INTSTAT - CLK_GEN Interrupt Register: Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// RTC Alarm interrupt
|
||||
#define AM_REG_RTC_INTSTAT_ALM_S 3
|
||||
#define AM_REG_RTC_INTSTAT_ALM_M 0x00000008
|
||||
#define AM_REG_RTC_INTSTAT_ALM(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// XT Oscillator Fail interrupt
|
||||
#define AM_REG_RTC_INTSTAT_OF_S 2
|
||||
#define AM_REG_RTC_INTSTAT_OF_M 0x00000004
|
||||
#define AM_REG_RTC_INTSTAT_OF(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Autocalibration Complete interrupt
|
||||
#define AM_REG_RTC_INTSTAT_ACC_S 1
|
||||
#define AM_REG_RTC_INTSTAT_ACC_M 0x00000002
|
||||
#define AM_REG_RTC_INTSTAT_ACC(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Autocalibration Fail interrupt
|
||||
#define AM_REG_RTC_INTSTAT_ACF_S 0
|
||||
#define AM_REG_RTC_INTSTAT_ACF_M 0x00000001
|
||||
#define AM_REG_RTC_INTSTAT_ACF(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RTC_INTCLR - CLK_GEN Interrupt Register: Clear
|
||||
//
|
||||
//*****************************************************************************
|
||||
// RTC Alarm interrupt
|
||||
#define AM_REG_RTC_INTCLR_ALM_S 3
|
||||
#define AM_REG_RTC_INTCLR_ALM_M 0x00000008
|
||||
#define AM_REG_RTC_INTCLR_ALM(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// XT Oscillator Fail interrupt
|
||||
#define AM_REG_RTC_INTCLR_OF_S 2
|
||||
#define AM_REG_RTC_INTCLR_OF_M 0x00000004
|
||||
#define AM_REG_RTC_INTCLR_OF(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Autocalibration Complete interrupt
|
||||
#define AM_REG_RTC_INTCLR_ACC_S 1
|
||||
#define AM_REG_RTC_INTCLR_ACC_M 0x00000002
|
||||
#define AM_REG_RTC_INTCLR_ACC(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Autocalibration Fail interrupt
|
||||
#define AM_REG_RTC_INTCLR_ACF_S 0
|
||||
#define AM_REG_RTC_INTCLR_ACF_M 0x00000001
|
||||
#define AM_REG_RTC_INTCLR_ACF(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RTC_INTSET - CLK_GEN Interrupt Register: Set
|
||||
//
|
||||
//*****************************************************************************
|
||||
// RTC Alarm interrupt
|
||||
#define AM_REG_RTC_INTSET_ALM_S 3
|
||||
#define AM_REG_RTC_INTSET_ALM_M 0x00000008
|
||||
#define AM_REG_RTC_INTSET_ALM(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// XT Oscillator Fail interrupt
|
||||
#define AM_REG_RTC_INTSET_OF_S 2
|
||||
#define AM_REG_RTC_INTSET_OF_M 0x00000004
|
||||
#define AM_REG_RTC_INTSET_OF(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Autocalibration Complete interrupt
|
||||
#define AM_REG_RTC_INTSET_ACC_S 1
|
||||
#define AM_REG_RTC_INTSET_ACC_M 0x00000002
|
||||
#define AM_REG_RTC_INTSET_ACC(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Autocalibration Fail interrupt
|
||||
#define AM_REG_RTC_INTSET_ACF_S 0
|
||||
#define AM_REG_RTC_INTSET_ACF_M 0x00000001
|
||||
#define AM_REG_RTC_INTSET_ACF(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RTC_CTRLOW - RTC Counters Lower
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Hours Counter
|
||||
#define AM_REG_RTC_CTRLOW_CTRHR_S 24
|
||||
#define AM_REG_RTC_CTRLOW_CTRHR_M 0x3F000000
|
||||
#define AM_REG_RTC_CTRLOW_CTRHR(n) (((uint32_t)(n) << 24) & 0x3F000000)
|
||||
|
||||
// Minutes Counter
|
||||
#define AM_REG_RTC_CTRLOW_CTRMIN_S 16
|
||||
#define AM_REG_RTC_CTRLOW_CTRMIN_M 0x007F0000
|
||||
#define AM_REG_RTC_CTRLOW_CTRMIN(n) (((uint32_t)(n) << 16) & 0x007F0000)
|
||||
|
||||
// Seconds Counter
|
||||
#define AM_REG_RTC_CTRLOW_CTRSEC_S 8
|
||||
#define AM_REG_RTC_CTRLOW_CTRSEC_M 0x00007F00
|
||||
#define AM_REG_RTC_CTRLOW_CTRSEC(n) (((uint32_t)(n) << 8) & 0x00007F00)
|
||||
|
||||
// 100ths of a second Counter
|
||||
#define AM_REG_RTC_CTRLOW_CTR100_S 0
|
||||
#define AM_REG_RTC_CTRLOW_CTR100_M 0x000000FF
|
||||
#define AM_REG_RTC_CTRLOW_CTR100(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RTC_CTRUP - RTC Counters Upper
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Counter read error status
|
||||
#define AM_REG_RTC_CTRUP_CTERR_S 31
|
||||
#define AM_REG_RTC_CTRUP_CTERR_M 0x80000000
|
||||
#define AM_REG_RTC_CTRUP_CTERR(n) (((uint32_t)(n) << 31) & 0x80000000)
|
||||
#define AM_REG_RTC_CTRUP_CTERR_NOERR 0x00000000
|
||||
#define AM_REG_RTC_CTRUP_CTERR_RDERR 0x80000000
|
||||
|
||||
// Century enable
|
||||
#define AM_REG_RTC_CTRUP_CEB_S 28
|
||||
#define AM_REG_RTC_CTRUP_CEB_M 0x10000000
|
||||
#define AM_REG_RTC_CTRUP_CEB(n) (((uint32_t)(n) << 28) & 0x10000000)
|
||||
#define AM_REG_RTC_CTRUP_CEB_DIS 0x00000000
|
||||
#define AM_REG_RTC_CTRUP_CEB_EN 0x10000000
|
||||
|
||||
// Century
|
||||
#define AM_REG_RTC_CTRUP_CB_S 27
|
||||
#define AM_REG_RTC_CTRUP_CB_M 0x08000000
|
||||
#define AM_REG_RTC_CTRUP_CB(n) (((uint32_t)(n) << 27) & 0x08000000)
|
||||
#define AM_REG_RTC_CTRUP_CB_2000 0x00000000
|
||||
#define AM_REG_RTC_CTRUP_CB_1900_2100 0x08000000
|
||||
|
||||
// Weekdays Counter
|
||||
#define AM_REG_RTC_CTRUP_CTRWKDY_S 24
|
||||
#define AM_REG_RTC_CTRUP_CTRWKDY_M 0x07000000
|
||||
#define AM_REG_RTC_CTRUP_CTRWKDY(n) (((uint32_t)(n) << 24) & 0x07000000)
|
||||
|
||||
// Years Counter
|
||||
#define AM_REG_RTC_CTRUP_CTRYR_S 16
|
||||
#define AM_REG_RTC_CTRUP_CTRYR_M 0x00FF0000
|
||||
#define AM_REG_RTC_CTRUP_CTRYR(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Months Counter
|
||||
#define AM_REG_RTC_CTRUP_CTRMO_S 8
|
||||
#define AM_REG_RTC_CTRUP_CTRMO_M 0x00001F00
|
||||
#define AM_REG_RTC_CTRUP_CTRMO(n) (((uint32_t)(n) << 8) & 0x00001F00)
|
||||
|
||||
// Date Counter
|
||||
#define AM_REG_RTC_CTRUP_CTRDATE_S 0
|
||||
#define AM_REG_RTC_CTRUP_CTRDATE_M 0x0000003F
|
||||
#define AM_REG_RTC_CTRUP_CTRDATE(n) (((uint32_t)(n) << 0) & 0x0000003F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RTC_ALMLOW - RTC Alarms Lower
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Hours Alarm
|
||||
#define AM_REG_RTC_ALMLOW_ALMHR_S 24
|
||||
#define AM_REG_RTC_ALMLOW_ALMHR_M 0x3F000000
|
||||
#define AM_REG_RTC_ALMLOW_ALMHR(n) (((uint32_t)(n) << 24) & 0x3F000000)
|
||||
|
||||
// Minutes Alarm
|
||||
#define AM_REG_RTC_ALMLOW_ALMMIN_S 16
|
||||
#define AM_REG_RTC_ALMLOW_ALMMIN_M 0x007F0000
|
||||
#define AM_REG_RTC_ALMLOW_ALMMIN(n) (((uint32_t)(n) << 16) & 0x007F0000)
|
||||
|
||||
// Seconds Alarm
|
||||
#define AM_REG_RTC_ALMLOW_ALMSEC_S 8
|
||||
#define AM_REG_RTC_ALMLOW_ALMSEC_M 0x00007F00
|
||||
#define AM_REG_RTC_ALMLOW_ALMSEC(n) (((uint32_t)(n) << 8) & 0x00007F00)
|
||||
|
||||
// 100ths of a second Alarm
|
||||
#define AM_REG_RTC_ALMLOW_ALM100_S 0
|
||||
#define AM_REG_RTC_ALMLOW_ALM100_M 0x000000FF
|
||||
#define AM_REG_RTC_ALMLOW_ALM100(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RTC_ALMUP - RTC Alarms Upper
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Weekdays Alarm
|
||||
#define AM_REG_RTC_ALMUP_ALMWKDY_S 16
|
||||
#define AM_REG_RTC_ALMUP_ALMWKDY_M 0x00070000
|
||||
#define AM_REG_RTC_ALMUP_ALMWKDY(n) (((uint32_t)(n) << 16) & 0x00070000)
|
||||
|
||||
// Months Alarm
|
||||
#define AM_REG_RTC_ALMUP_ALMMO_S 8
|
||||
#define AM_REG_RTC_ALMUP_ALMMO_M 0x00001F00
|
||||
#define AM_REG_RTC_ALMUP_ALMMO(n) (((uint32_t)(n) << 8) & 0x00001F00)
|
||||
|
||||
// Date Alarm
|
||||
#define AM_REG_RTC_ALMUP_ALMDATE_S 0
|
||||
#define AM_REG_RTC_ALMUP_ALMDATE_M 0x0000003F
|
||||
#define AM_REG_RTC_ALMUP_ALMDATE(n) (((uint32_t)(n) << 0) & 0x0000003F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// RTC_RTCCTL - RTC Control Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Hours Counter mode
|
||||
#define AM_REG_RTC_RTCCTL_HR1224_S 5
|
||||
#define AM_REG_RTC_RTCCTL_HR1224_M 0x00000020
|
||||
#define AM_REG_RTC_RTCCTL_HR1224(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
#define AM_REG_RTC_RTCCTL_HR1224_24HR 0x00000000
|
||||
#define AM_REG_RTC_RTCCTL_HR1224_12HR 0x00000020
|
||||
|
||||
// RTC input clock control
|
||||
#define AM_REG_RTC_RTCCTL_RSTOP_S 4
|
||||
#define AM_REG_RTC_RTCCTL_RSTOP_M 0x00000010
|
||||
#define AM_REG_RTC_RTCCTL_RSTOP(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
#define AM_REG_RTC_RTCCTL_RSTOP_RUN 0x00000000
|
||||
#define AM_REG_RTC_RTCCTL_RSTOP_STOP 0x00000010
|
||||
|
||||
// Alarm repeat interval
|
||||
#define AM_REG_RTC_RTCCTL_RPT_S 1
|
||||
#define AM_REG_RTC_RTCCTL_RPT_M 0x0000000E
|
||||
#define AM_REG_RTC_RTCCTL_RPT(n) (((uint32_t)(n) << 1) & 0x0000000E)
|
||||
#define AM_REG_RTC_RTCCTL_RPT_DIS 0x00000000
|
||||
#define AM_REG_RTC_RTCCTL_RPT_YEAR 0x00000002
|
||||
#define AM_REG_RTC_RTCCTL_RPT_MONTH 0x00000004
|
||||
#define AM_REG_RTC_RTCCTL_RPT_WEEK 0x00000006
|
||||
#define AM_REG_RTC_RTCCTL_RPT_DAY 0x00000008
|
||||
#define AM_REG_RTC_RTCCTL_RPT_HR 0x0000000A
|
||||
#define AM_REG_RTC_RTCCTL_RPT_MIN 0x0000000C
|
||||
#define AM_REG_RTC_RTCCTL_RPT_SEC 0x0000000E
|
||||
|
||||
// Counter write control
|
||||
#define AM_REG_RTC_RTCCTL_WRTC_S 0
|
||||
#define AM_REG_RTC_RTCCTL_WRTC_M 0x00000001
|
||||
#define AM_REG_RTC_RTCCTL_WRTC(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_RTC_RTCCTL_WRTC_DIS 0x00000000
|
||||
#define AM_REG_RTC_RTCCTL_WRTC_EN 0x00000001
|
||||
|
||||
#endif // AM_REG_RTC_H
|
||||
@@ -0,0 +1,700 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_sysctrl.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the SYSCTRL module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_SYSCTRL_H
|
||||
#define AM_REG_SYSCTRL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_SYSCTRL_NUM_MODULES 1
|
||||
#define AM_REG_SYSCTRLn(n) \
|
||||
(REG_SYSCTRL_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_SYSCTRL_ICTR_O 0xE000E004
|
||||
#define AM_REG_SYSCTRL_ACTLR_O 0xE000E008
|
||||
#define AM_REG_SYSCTRL_ICSR_O 0xE000ED04
|
||||
#define AM_REG_SYSCTRL_VTOR_O 0xE000ED08
|
||||
#define AM_REG_SYSCTRL_AIRCR_O 0xE000ED0C
|
||||
#define AM_REG_SYSCTRL_SCR_O 0xE000ED10
|
||||
#define AM_REG_SYSCTRL_CCR_O 0xE000ED14
|
||||
#define AM_REG_SYSCTRL_SHPR1_O 0xE000ED18
|
||||
#define AM_REG_SYSCTRL_SHPR2_O 0xE000ED1C
|
||||
#define AM_REG_SYSCTRL_SHPR3_O 0xE000ED20
|
||||
#define AM_REG_SYSCTRL_SHCSR_O 0xE000ED24
|
||||
#define AM_REG_SYSCTRL_CFSR_O 0xE000ED28
|
||||
#define AM_REG_SYSCTRL_HFSR_O 0xE000ED2C
|
||||
#define AM_REG_SYSCTRL_MMFAR_O 0xE000ED34
|
||||
#define AM_REG_SYSCTRL_BFAR_O 0xE000ED38
|
||||
#define AM_REG_SYSCTRL_CPACR_O 0xE000ED88
|
||||
#define AM_REG_SYSCTRL_DEMCR_O 0xE000EDFC
|
||||
#define AM_REG_SYSCTRL_STIR_O 0xE000EF00
|
||||
#define AM_REG_SYSCTRL_FPCCR_O 0xE000EF34
|
||||
#define AM_REG_SYSCTRL_FPCAR_O 0xE000EF38
|
||||
#define AM_REG_SYSCTRL_FPDSCR_O 0xE000EF3C
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_ICTR - Interrupt Controller Type Register (NVIC)
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Total number of interrupt lines in groups of 32.
|
||||
#define AM_REG_SYSCTRL_ICTR_INTLINESNUM_S 0
|
||||
#define AM_REG_SYSCTRL_ICTR_INTLINESNUM_M 0x0000000F
|
||||
#define AM_REG_SYSCTRL_ICTR_INTLINESNUM(n) (((uint32_t)(n) << 0) & 0x0000000F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_ACTLR - Auxilliary Control Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Disables lazy stacking of floating point context.
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISFPCA_S 9
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISFPCA_M 0x00000200
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISFPCA(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// Disables floating point instructions completing out of order with respect to
|
||||
// integer instructions.
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISOOFP_S 8
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISOOFP_M 0x00000100
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISOOFP(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// Disables folding of IT instructions.
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISFOLD_S 2
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISFOLD_M 0x00000004
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISFOLD(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Disables write buffer use during default memory map accesses.
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISDEFWBUF_S 1
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISDEFWBUF_M 0x00000002
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISDEFWBUF(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Disables interruption of multi-cycle instructions.
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISMCYCINT_S 0
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISMCYCINT_M 0x00000001
|
||||
#define AM_REG_SYSCTRL_ACTLR_DISMCYCINT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_ICSR - Interrupt Control and State Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Pend an NMI exception.
|
||||
#define AM_REG_SYSCTRL_ICSR_NMIPENDSET_S 31
|
||||
#define AM_REG_SYSCTRL_ICSR_NMIPENDSET_M 0x80000000
|
||||
#define AM_REG_SYSCTRL_ICSR_NMIPENDSET(n) (((uint32_t)(n) << 31) & 0x80000000)
|
||||
|
||||
// Set the PendSV interrupt as pending.
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSVSET_S 28
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSVSET_M 0x10000000
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSVSET(n) (((uint32_t)(n) << 28) & 0x10000000)
|
||||
|
||||
// Remove the pending status of the PendSV exception.
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSVCLR_S 27
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSVCLR_M 0x08000000
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSVCLR(n) (((uint32_t)(n) << 27) & 0x08000000)
|
||||
|
||||
// Set the SysTick exception as pending.
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSTSET_S 26
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSTSET_M 0x04000000
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSTSET(n) (((uint32_t)(n) << 26) & 0x04000000)
|
||||
|
||||
// Remove the pending status of the SysTick exception.
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSTCLR_S 25
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSTCLR_M 0x02000000
|
||||
#define AM_REG_SYSCTRL_ICSR_PENDSTCLR(n) (((uint32_t)(n) << 25) & 0x02000000)
|
||||
|
||||
// Indicates whether a pending exception will be serviced on exit from debug
|
||||
// halt state.
|
||||
#define AM_REG_SYSCTRL_ICSR_ISRPREEMPT_S 23
|
||||
#define AM_REG_SYSCTRL_ICSR_ISRPREEMPT_M 0x00800000
|
||||
#define AM_REG_SYSCTRL_ICSR_ISRPREEMPT(n) (((uint32_t)(n) << 23) & 0x00800000)
|
||||
|
||||
// Indicates whether an external interrupt, generated by the NVIC, is pending.
|
||||
#define AM_REG_SYSCTRL_ICSR_ISRPENDING_S 22
|
||||
#define AM_REG_SYSCTRL_ICSR_ISRPENDING_M 0x00400000
|
||||
#define AM_REG_SYSCTRL_ICSR_ISRPENDING(n) (((uint32_t)(n) << 22) & 0x00400000)
|
||||
|
||||
// The exception number of the highest priority pending exception.
|
||||
#define AM_REG_SYSCTRL_ICSR_VECTPENDING_S 12
|
||||
#define AM_REG_SYSCTRL_ICSR_VECTPENDING_M 0x001FF000
|
||||
#define AM_REG_SYSCTRL_ICSR_VECTPENDING(n) (((uint32_t)(n) << 12) & 0x001FF000)
|
||||
|
||||
// Indicates whether there is an active exception other than the exception shown
|
||||
// by IPSR.
|
||||
#define AM_REG_SYSCTRL_ICSR_RETTOBASE_S 11
|
||||
#define AM_REG_SYSCTRL_ICSR_RETTOBASE_M 0x00000800
|
||||
#define AM_REG_SYSCTRL_ICSR_RETTOBASE(n) (((uint32_t)(n) << 11) & 0x00000800)
|
||||
|
||||
// The exception number of the current executing exception.
|
||||
#define AM_REG_SYSCTRL_ICSR_VECTACTIVE_S 0
|
||||
#define AM_REG_SYSCTRL_ICSR_VECTACTIVE_M 0x000001FF
|
||||
#define AM_REG_SYSCTRL_ICSR_VECTACTIVE(n) (((uint32_t)(n) << 0) & 0x000001FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_VTOR - Vector Table Offset Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Vector table base address.
|
||||
#define AM_REG_SYSCTRL_VTOR_VALUE_S 0
|
||||
#define AM_REG_SYSCTRL_VTOR_VALUE_M 0xFFFFFFFF
|
||||
#define AM_REG_SYSCTRL_VTOR_VALUE(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_AIRCR - Application Interrupt and Reset Control Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Register writes must write 0x5FA to this field, otherwise the write is
|
||||
// ignored.
|
||||
#define AM_REG_SYSCTRL_AIRCR_VECTKEY_S 16
|
||||
#define AM_REG_SYSCTRL_AIRCR_VECTKEY_M 0xFFFF0000
|
||||
#define AM_REG_SYSCTRL_AIRCR_VECTKEY(n) (((uint32_t)(n) << 16) & 0xFFFF0000)
|
||||
|
||||
// Indicates endianness of memory architecture. (Little = 0, Big = 1)
|
||||
#define AM_REG_SYSCTRL_AIRCR_ENDIANNESS_S 15
|
||||
#define AM_REG_SYSCTRL_AIRCR_ENDIANNESS_M 0x00008000
|
||||
#define AM_REG_SYSCTRL_AIRCR_ENDIANNESS(n) (((uint32_t)(n) << 15) & 0x00008000)
|
||||
|
||||
// Priority grouping, indicates the binary point position.
|
||||
#define AM_REG_SYSCTRL_AIRCR_PRIGROUP_S 8
|
||||
#define AM_REG_SYSCTRL_AIRCR_PRIGROUP_M 0x00000700
|
||||
#define AM_REG_SYSCTRL_AIRCR_PRIGROUP(n) (((uint32_t)(n) << 8) & 0x00000700)
|
||||
|
||||
// Writing a 1 to this bit reqests a local reset.
|
||||
#define AM_REG_SYSCTRL_AIRCR_SYSRESETREQ_S 2
|
||||
#define AM_REG_SYSCTRL_AIRCR_SYSRESETREQ_M 0x00000004
|
||||
#define AM_REG_SYSCTRL_AIRCR_SYSRESETREQ(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Writing a 1 to this bit clears all active state information for fixed and
|
||||
// configurable exceptions.
|
||||
#define AM_REG_SYSCTRL_AIRCR_VECTCLRACTIVE_S 1
|
||||
#define AM_REG_SYSCTRL_AIRCR_VECTCLRACTIVE_M 0x00000002
|
||||
#define AM_REG_SYSCTRL_AIRCR_VECTCLRACTIVE(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Writing a 1 to this bit causes a local system reset.
|
||||
#define AM_REG_SYSCTRL_AIRCR_VECTRESET_S 0
|
||||
#define AM_REG_SYSCTRL_AIRCR_VECTRESET_M 0x00000001
|
||||
#define AM_REG_SYSCTRL_AIRCR_VECTRESET(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_SCR - System Control Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Determines whether a pending interrupt is a wakeup event.
|
||||
#define AM_REG_SYSCTRL_SCR_SEVONPEND_S 4
|
||||
#define AM_REG_SYSCTRL_SCR_SEVONPEND_M 0x00000010
|
||||
#define AM_REG_SYSCTRL_SCR_SEVONPEND(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// Determines whether the sleep mode should be regular or deep sleep
|
||||
#define AM_REG_SYSCTRL_SCR_SLEEPDEEP_S 2
|
||||
#define AM_REG_SYSCTRL_SCR_SLEEPDEEP_M 0x00000004
|
||||
#define AM_REG_SYSCTRL_SCR_SLEEPDEEP(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// Determines whether the processor shoudl automatically sleep when an ISR
|
||||
// returns to the base-level.
|
||||
#define AM_REG_SYSCTRL_SCR_SLEEPONEXIT_S 1
|
||||
#define AM_REG_SYSCTRL_SCR_SLEEPONEXIT_M 0x00000002
|
||||
#define AM_REG_SYSCTRL_SCR_SLEEPONEXIT(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_CCR - Configuration and Control Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Set to force 8-byte alignment for the stack pointer.
|
||||
#define AM_REG_SYSCTRL_CCR_STKALIGN_S 9
|
||||
#define AM_REG_SYSCTRL_CCR_STKALIGN_M 0x00000200
|
||||
#define AM_REG_SYSCTRL_CCR_STKALIGN(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// Set to ignore precise data access faults during hard fault handlers.
|
||||
#define AM_REG_SYSCTRL_CCR_BFHFNMIGN_S 8
|
||||
#define AM_REG_SYSCTRL_CCR_BFHFNMIGN_M 0x00000100
|
||||
#define AM_REG_SYSCTRL_CCR_BFHFNMIGN(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// Set to enable trapping on divide-by-zero.
|
||||
#define AM_REG_SYSCTRL_CCR_DIV0TRP_S 4
|
||||
#define AM_REG_SYSCTRL_CCR_DIV0TRP_M 0x00000010
|
||||
#define AM_REG_SYSCTRL_CCR_DIV0TRP(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// Set to enable trapping of unaligned word or halfword accesses.
|
||||
#define AM_REG_SYSCTRL_CCR_UNALIGNTRP_S 3
|
||||
#define AM_REG_SYSCTRL_CCR_UNALIGNTRP_M 0x00000008
|
||||
#define AM_REG_SYSCTRL_CCR_UNALIGNTRP(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// Set to allow unpriveleged software to access the STIR
|
||||
#define AM_REG_SYSCTRL_CCR_USERSETMPEND_S 1
|
||||
#define AM_REG_SYSCTRL_CCR_USERSETMPEND_M 0x00000002
|
||||
#define AM_REG_SYSCTRL_CCR_USERSETMPEND(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Set to enable the processor to enter Thread mode at an execution priority
|
||||
// other than base level.
|
||||
#define AM_REG_SYSCTRL_CCR_NONBASETHRDENA_S 0
|
||||
#define AM_REG_SYSCTRL_CCR_NONBASETHRDENA_M 0x00000001
|
||||
#define AM_REG_SYSCTRL_CCR_NONBASETHRDENA(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_SHPR1 - System Handler Priority Register 1.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Reserved for priority of system handler 7.
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_7_S 24
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_7_M 0xFF000000
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_7(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Priority of system handler 6, UsageFault.
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_6_S 16
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_6_M 0x00FF0000
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_6(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Priority of system handler 5, BusFault.
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_5_S 8
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_5_M 0x0000FF00
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_5(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Priority of system handler 4, MemManage.
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_4_S 0
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_4_M 0x000000FF
|
||||
#define AM_REG_SYSCTRL_SHPR1_PRI_4(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_SHPR2 - System Handler Priority Register 2.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Priority of system handler 11, SVCall.
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_11_S 24
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_11_M 0xFF000000
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_11(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Reserved for priority of system handler 10.
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_10_S 16
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_10_M 0x00FF0000
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_10(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Reserved for priority of system handler 9.
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_9_S 8
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_9_M 0x0000FF00
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_9(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Reserved for priority of system handler 8.
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_8_S 0
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_8_M 0x000000FF
|
||||
#define AM_REG_SYSCTRL_SHPR2_PRI_8(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_SHPR3 - System Handler Priority Register 3.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Priority of system handler 15, SysTick.
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_15_S 24
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_15_M 0xFF000000
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_15(n) (((uint32_t)(n) << 24) & 0xFF000000)
|
||||
|
||||
// Priority of system handler 14, PendSV.
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_14_S 16
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_14_M 0x00FF0000
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_14(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// Reserved for priority of system handler 13.
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_13_S 8
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_13_M 0x0000FF00
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_13(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// Priority of system handler 12, DebugMonitor.
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_12_S 0
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_12_M 0x000000FF
|
||||
#define AM_REG_SYSCTRL_SHPR3_PRI_12(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_SHCSR - System Handler Control and State Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Set to enable UsageFault.
|
||||
#define AM_REG_SYSCTRL_SHCSR_USAGEFAULTENA_S 18
|
||||
#define AM_REG_SYSCTRL_SHCSR_USAGEFAULTENA_M 0x00040000
|
||||
#define AM_REG_SYSCTRL_SHCSR_USAGEFAULTENA(n) (((uint32_t)(n) << 18) & 0x00040000)
|
||||
|
||||
// Set to enable BusFault.
|
||||
#define AM_REG_SYSCTRL_SHCSR_BUSFAULTENA_S 17
|
||||
#define AM_REG_SYSCTRL_SHCSR_BUSFAULTENA_M 0x00020000
|
||||
#define AM_REG_SYSCTRL_SHCSR_BUSFAULTENA(n) (((uint32_t)(n) << 17) & 0x00020000)
|
||||
|
||||
// Set to enable MemManageFault.
|
||||
#define AM_REG_SYSCTRL_SHCSR_MEMFAULTENA_S 16
|
||||
#define AM_REG_SYSCTRL_SHCSR_MEMFAULTENA_M 0x00010000
|
||||
#define AM_REG_SYSCTRL_SHCSR_MEMFAULTENA(n) (((uint32_t)(n) << 16) & 0x00010000)
|
||||
|
||||
// Set to pend the SVCall exception.
|
||||
#define AM_REG_SYSCTRL_SHCSR_SVCALLPENDED_S 15
|
||||
#define AM_REG_SYSCTRL_SHCSR_SVCALLPENDED_M 0x00008000
|
||||
#define AM_REG_SYSCTRL_SHCSR_SVCALLPENDED(n) (((uint32_t)(n) << 15) & 0x00008000)
|
||||
|
||||
// Set to pend the BusFault exception.
|
||||
#define AM_REG_SYSCTRL_SHCSR_BUSFAULTPENDED_S 14
|
||||
#define AM_REG_SYSCTRL_SHCSR_BUSFAULTPENDED_M 0x00004000
|
||||
#define AM_REG_SYSCTRL_SHCSR_BUSFAULTPENDED(n) (((uint32_t)(n) << 14) & 0x00004000)
|
||||
|
||||
// Set to pend the MemManageFault exception.
|
||||
#define AM_REG_SYSCTRL_SHCSR_MEMFAULTPENDED_S 13
|
||||
#define AM_REG_SYSCTRL_SHCSR_MEMFAULTPENDED_M 0x00002000
|
||||
#define AM_REG_SYSCTRL_SHCSR_MEMFAULTPENDED(n) (((uint32_t)(n) << 13) & 0x00002000)
|
||||
|
||||
// Set to pend the UsageFault exception.
|
||||
#define AM_REG_SYSCTRL_SHCSR_USGFAULTPENDED_S 12
|
||||
#define AM_REG_SYSCTRL_SHCSR_USGFAULTPENDED_M 0x00001000
|
||||
#define AM_REG_SYSCTRL_SHCSR_USGFAULTPENDED(n) (((uint32_t)(n) << 12) & 0x00001000)
|
||||
|
||||
// Set when SysTick is active.
|
||||
#define AM_REG_SYSCTRL_SHCSR_SYSTICKACT_S 11
|
||||
#define AM_REG_SYSCTRL_SHCSR_SYSTICKACT_M 0x00000800
|
||||
#define AM_REG_SYSCTRL_SHCSR_SYSTICKACT(n) (((uint32_t)(n) << 11) & 0x00000800)
|
||||
|
||||
// Set when PendSV is active.
|
||||
#define AM_REG_SYSCTRL_SHCSR_PENDSVACT_S 10
|
||||
#define AM_REG_SYSCTRL_SHCSR_PENDSVACT_M 0x00000400
|
||||
#define AM_REG_SYSCTRL_SHCSR_PENDSVACT(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// Set when Monitor is active.
|
||||
#define AM_REG_SYSCTRL_SHCSR_MONITORACT_S 8
|
||||
#define AM_REG_SYSCTRL_SHCSR_MONITORACT_M 0x00000100
|
||||
#define AM_REG_SYSCTRL_SHCSR_MONITORACT(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// Set when SVCall is active.
|
||||
#define AM_REG_SYSCTRL_SHCSR_SVCALLACT_S 7
|
||||
#define AM_REG_SYSCTRL_SHCSR_SVCALLACT_M 0x00000080
|
||||
#define AM_REG_SYSCTRL_SHCSR_SVCALLACT(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// Set when UsageFault is active.
|
||||
#define AM_REG_SYSCTRL_SHCSR_USGFAULTACT_S 3
|
||||
#define AM_REG_SYSCTRL_SHCSR_USGFAULTACT_M 0x00000008
|
||||
#define AM_REG_SYSCTRL_SHCSR_USGFAULTACT(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// Set when BusFault is active.
|
||||
#define AM_REG_SYSCTRL_SHCSR_BUSFAULTACT_S 1
|
||||
#define AM_REG_SYSCTRL_SHCSR_BUSFAULTACT_M 0x00000002
|
||||
#define AM_REG_SYSCTRL_SHCSR_BUSFAULTACT(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Set when MemManageFault is active.
|
||||
#define AM_REG_SYSCTRL_SHCSR_MEMFAULTACT_S 0
|
||||
#define AM_REG_SYSCTRL_SHCSR_MEMFAULTACT_M 0x00000001
|
||||
#define AM_REG_SYSCTRL_SHCSR_MEMFAULTACT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_CFSR - Configurable Fault Status Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Divide by zero error has occurred.
|
||||
#define AM_REG_SYSCTRL_CFSR_DIVBYZERO_S 25
|
||||
#define AM_REG_SYSCTRL_CFSR_DIVBYZERO_M 0x02000000
|
||||
#define AM_REG_SYSCTRL_CFSR_DIVBYZERO(n) (((uint32_t)(n) << 25) & 0x02000000)
|
||||
|
||||
// Unaligned access error has occurred.
|
||||
#define AM_REG_SYSCTRL_CFSR_UNALIGNED_S 24
|
||||
#define AM_REG_SYSCTRL_CFSR_UNALIGNED_M 0x01000000
|
||||
#define AM_REG_SYSCTRL_CFSR_UNALIGNED(n) (((uint32_t)(n) << 24) & 0x01000000)
|
||||
|
||||
// A coprocessor access error has occurred.
|
||||
#define AM_REG_SYSCTRL_CFSR_NOCP_S 19
|
||||
#define AM_REG_SYSCTRL_CFSR_NOCP_M 0x00080000
|
||||
#define AM_REG_SYSCTRL_CFSR_NOCP(n) (((uint32_t)(n) << 19) & 0x00080000)
|
||||
|
||||
// An integrity check error has occurred on EXC_RETURN.
|
||||
#define AM_REG_SYSCTRL_CFSR_INVPC_S 18
|
||||
#define AM_REG_SYSCTRL_CFSR_INVPC_M 0x00040000
|
||||
#define AM_REG_SYSCTRL_CFSR_INVPC(n) (((uint32_t)(n) << 18) & 0x00040000)
|
||||
|
||||
// Instruction executed with invalid EPSR.T or EPSR.IT field.
|
||||
#define AM_REG_SYSCTRL_CFSR_INVSTATE_S 17
|
||||
#define AM_REG_SYSCTRL_CFSR_INVSTATE_M 0x00020000
|
||||
#define AM_REG_SYSCTRL_CFSR_INVSTATE(n) (((uint32_t)(n) << 17) & 0x00020000)
|
||||
|
||||
// Processor attempted to execute an undefined instruction.
|
||||
#define AM_REG_SYSCTRL_CFSR_UNDEFINSTR_S 16
|
||||
#define AM_REG_SYSCTRL_CFSR_UNDEFINSTR_M 0x00010000
|
||||
#define AM_REG_SYSCTRL_CFSR_UNDEFINSTR(n) (((uint32_t)(n) << 16) & 0x00010000)
|
||||
|
||||
// BFAR has valid contents.
|
||||
#define AM_REG_SYSCTRL_CFSR_BFARVALID_S 15
|
||||
#define AM_REG_SYSCTRL_CFSR_BFARVALID_M 0x00008000
|
||||
#define AM_REG_SYSCTRL_CFSR_BFARVALID(n) (((uint32_t)(n) << 15) & 0x00008000)
|
||||
|
||||
// A bus fault occurred during FP lazy state preservation.
|
||||
#define AM_REG_SYSCTRL_CFSR_LSPERR_S 13
|
||||
#define AM_REG_SYSCTRL_CFSR_LSPERR_M 0x00002000
|
||||
#define AM_REG_SYSCTRL_CFSR_LSPERR(n) (((uint32_t)(n) << 13) & 0x00002000)
|
||||
|
||||
// A derived bus fault has occurred on exception entry.
|
||||
#define AM_REG_SYSCTRL_CFSR_STKERR_S 12
|
||||
#define AM_REG_SYSCTRL_CFSR_STKERR_M 0x00001000
|
||||
#define AM_REG_SYSCTRL_CFSR_STKERR(n) (((uint32_t)(n) << 12) & 0x00001000)
|
||||
|
||||
// A derived bus fault has occurred on exception return.
|
||||
#define AM_REG_SYSCTRL_CFSR_UNSTKERR_S 11
|
||||
#define AM_REG_SYSCTRL_CFSR_UNSTKERR_M 0x00000800
|
||||
#define AM_REG_SYSCTRL_CFSR_UNSTKERR(n) (((uint32_t)(n) << 11) & 0x00000800)
|
||||
|
||||
// Imprecise data access error has occurred.
|
||||
#define AM_REG_SYSCTRL_CFSR_IMPRECISERR_S 10
|
||||
#define AM_REG_SYSCTRL_CFSR_IMPRECISERR_M 0x00000400
|
||||
#define AM_REG_SYSCTRL_CFSR_IMPRECISERR(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// A precise data access has occurrred. The faulting address is in BFAR.
|
||||
#define AM_REG_SYSCTRL_CFSR_PRECISERR_S 9
|
||||
#define AM_REG_SYSCTRL_CFSR_PRECISERR_M 0x00000200
|
||||
#define AM_REG_SYSCTRL_CFSR_PRECISERR(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// A bus fault on an instruction prefetch has occurred.
|
||||
#define AM_REG_SYSCTRL_CFSR_IBUSERR_S 8
|
||||
#define AM_REG_SYSCTRL_CFSR_IBUSERR_M 0x00000100
|
||||
#define AM_REG_SYSCTRL_CFSR_IBUSERR(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// MMAR has valid contents.
|
||||
#define AM_REG_SYSCTRL_CFSR_MMARVALID_S 7
|
||||
#define AM_REG_SYSCTRL_CFSR_MMARVALID_M 0x00000080
|
||||
#define AM_REG_SYSCTRL_CFSR_MMARVALID(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// MemManage fault occurred during FP lazy state preservation.
|
||||
#define AM_REG_SYSCTRL_CFSR_MLSPERR_S 5
|
||||
#define AM_REG_SYSCTRL_CFSR_MLSPERR_M 0x00000020
|
||||
#define AM_REG_SYSCTRL_CFSR_MLSPERR(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// Derived MemManage fault occurred on exception entry.
|
||||
#define AM_REG_SYSCTRL_CFSR_MSTKERR_S 4
|
||||
#define AM_REG_SYSCTRL_CFSR_MSTKERR_M 0x00000010
|
||||
#define AM_REG_SYSCTRL_CFSR_MSTKERR(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// Derived MemManage fault occurred on exception return.
|
||||
#define AM_REG_SYSCTRL_CFSR_MUNSTKER_S 3
|
||||
#define AM_REG_SYSCTRL_CFSR_MUNSTKER_M 0x00000008
|
||||
#define AM_REG_SYSCTRL_CFSR_MUNSTKER(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// Data access violation. Address is in MMAR.
|
||||
#define AM_REG_SYSCTRL_CFSR_DACCVIOL_S 1
|
||||
#define AM_REG_SYSCTRL_CFSR_DACCVIOL_M 0x00000002
|
||||
#define AM_REG_SYSCTRL_CFSR_DACCVIOL(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// MPU or Execute Never default memory map access violation.
|
||||
#define AM_REG_SYSCTRL_CFSR_IACCVIOL_S 0
|
||||
#define AM_REG_SYSCTRL_CFSR_IACCVIOL_M 0x00000001
|
||||
#define AM_REG_SYSCTRL_CFSR_IACCVIOL(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_HFSR - Hard Fault Status Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Debug event has occurred.
|
||||
#define AM_REG_SYSCTRL_HFSR_DEBUGEVT_S 31
|
||||
#define AM_REG_SYSCTRL_HFSR_DEBUGEVT_M 0x80000000
|
||||
#define AM_REG_SYSCTRL_HFSR_DEBUGEVT(n) (((uint32_t)(n) << 31) & 0x80000000)
|
||||
|
||||
// Processor has elevated a configurable-priority fault to a HardFault.
|
||||
#define AM_REG_SYSCTRL_HFSR_FORCED_S 30
|
||||
#define AM_REG_SYSCTRL_HFSR_FORCED_M 0x40000000
|
||||
#define AM_REG_SYSCTRL_HFSR_FORCED(n) (((uint32_t)(n) << 30) & 0x40000000)
|
||||
|
||||
// Vector table read fault has occurred.
|
||||
#define AM_REG_SYSCTRL_HFSR_VECTTBL_S 1
|
||||
#define AM_REG_SYSCTRL_HFSR_VECTTBL_M 0x00000002
|
||||
#define AM_REG_SYSCTRL_HFSR_VECTTBL(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_MMFAR - MemManage Fault Address Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Address of the memory location that caused an MMU fault.
|
||||
#define AM_REG_SYSCTRL_MMFAR_ADDRESS_S 0
|
||||
#define AM_REG_SYSCTRL_MMFAR_ADDRESS_M 0xFFFFFFFF
|
||||
#define AM_REG_SYSCTRL_MMFAR_ADDRESS(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_BFAR - Bus Fault Address Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Address of the memory location that caused an Bus fault.
|
||||
#define AM_REG_SYSCTRL_BFAR_ADDRESS_S 0
|
||||
#define AM_REG_SYSCTRL_BFAR_ADDRESS_M 0xFFFFFFFF
|
||||
#define AM_REG_SYSCTRL_BFAR_ADDRESS(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_CPACR - Coprocessor Access Control Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Access priveleges for the Floating point unit. Must always match CP10.
|
||||
#define AM_REG_SYSCTRL_CPACR_CP11_S 22
|
||||
#define AM_REG_SYSCTRL_CPACR_CP11_M 0x00C00000
|
||||
#define AM_REG_SYSCTRL_CPACR_CP11(n) (((uint32_t)(n) << 22) & 0x00C00000)
|
||||
|
||||
// Access priveleges for the Floating point unit. Must always match CP11.
|
||||
#define AM_REG_SYSCTRL_CPACR_CP10_S 20
|
||||
#define AM_REG_SYSCTRL_CPACR_CP10_M 0x00300000
|
||||
#define AM_REG_SYSCTRL_CPACR_CP10(n) (((uint32_t)(n) << 20) & 0x00300000)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_DEMCR - Debug Exception and Monitor Control Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Global enable for all DWT and ITM features.
|
||||
#define AM_REG_SYSCTRL_DEMCR_TRCENA_S 24
|
||||
#define AM_REG_SYSCTRL_DEMCR_TRCENA_M 0x01000000
|
||||
#define AM_REG_SYSCTRL_DEMCR_TRCENA(n) (((uint32_t)(n) << 24) & 0x01000000)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_STIR - Software Triggered Interrupt Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Vector number of the interrupt that should be triggered.
|
||||
#define AM_REG_SYSCTRL_STIR_INTID_S 0
|
||||
#define AM_REG_SYSCTRL_STIR_INTID_M 0xFFFFFFFF
|
||||
#define AM_REG_SYSCTRL_STIR_INTID(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_FPCCR - Floating-Point Context Control Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Set to enable automatic saving of FP registers on exception entry.
|
||||
#define AM_REG_SYSCTRL_FPCCR_ASPEN_S 31
|
||||
#define AM_REG_SYSCTRL_FPCCR_ASPEN_M 0x80000000
|
||||
#define AM_REG_SYSCTRL_FPCCR_ASPEN(n) (((uint32_t)(n) << 31) & 0x80000000)
|
||||
|
||||
// Set to enable lazy context saving of FP registers on exception entry.
|
||||
#define AM_REG_SYSCTRL_FPCCR_LSPEN_S 30
|
||||
#define AM_REG_SYSCTRL_FPCCR_LSPEN_M 0x40000000
|
||||
#define AM_REG_SYSCTRL_FPCCR_LSPEN(n) (((uint32_t)(n) << 30) & 0x40000000)
|
||||
|
||||
// Able to set DebugMonitor exception to pending on last FP stack allocation.
|
||||
#define AM_REG_SYSCTRL_FPCCR_MONRDY_S 8
|
||||
#define AM_REG_SYSCTRL_FPCCR_MONRDY_M 0x00000100
|
||||
#define AM_REG_SYSCTRL_FPCCR_MONRDY(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// Able to set BusFault exception to pending on last FP stack allocation.
|
||||
#define AM_REG_SYSCTRL_FPCCR_BFRDY_S 6
|
||||
#define AM_REG_SYSCTRL_FPCCR_BFRDY_M 0x00000040
|
||||
#define AM_REG_SYSCTRL_FPCCR_BFRDY(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
|
||||
// Able to set MemManage exception to pending on last FP stack allocation.
|
||||
#define AM_REG_SYSCTRL_FPCCR_MMRDY_S 5
|
||||
#define AM_REG_SYSCTRL_FPCCR_MMRDY_M 0x00000020
|
||||
#define AM_REG_SYSCTRL_FPCCR_MMRDY(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// Able to set HardFault exception to pending on last FP stack allocation.
|
||||
#define AM_REG_SYSCTRL_FPCCR_HFRDY_S 4
|
||||
#define AM_REG_SYSCTRL_FPCCR_HFRDY_M 0x00000010
|
||||
#define AM_REG_SYSCTRL_FPCCR_HFRDY(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// Running from Thread mode on last FP stack allocation.
|
||||
#define AM_REG_SYSCTRL_FPCCR_THREAD_S 3
|
||||
#define AM_REG_SYSCTRL_FPCCR_THREAD_M 0x00000008
|
||||
#define AM_REG_SYSCTRL_FPCCR_THREAD(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// Running from unprivileged mode on last FP stack allocation.
|
||||
#define AM_REG_SYSCTRL_FPCCR_USER_S 1
|
||||
#define AM_REG_SYSCTRL_FPCCR_USER_M 0x00000002
|
||||
#define AM_REG_SYSCTRL_FPCCR_USER(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Lazy state preservation is active.
|
||||
#define AM_REG_SYSCTRL_FPCCR_LSPACT_S 0
|
||||
#define AM_REG_SYSCTRL_FPCCR_LSPACT_M 0x00000001
|
||||
#define AM_REG_SYSCTRL_FPCCR_LSPACT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_FPCAR - Floating-Point Context Address Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Address of the unpopulated floating-point register space allocated on the
|
||||
// exception stack frame.
|
||||
#define AM_REG_SYSCTRL_FPCAR_ADDRESS_S 0
|
||||
#define AM_REG_SYSCTRL_FPCAR_ADDRESS_M 0xFFFFFFFF
|
||||
#define AM_REG_SYSCTRL_FPCAR_ADDRESS(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSCTRL_FPDSCR - Floating-Point Default Status Control Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Default value for FPSCR.AHP.
|
||||
#define AM_REG_SYSCTRL_FPDSCR_AHP_S 26
|
||||
#define AM_REG_SYSCTRL_FPDSCR_AHP_M 0x04000000
|
||||
#define AM_REG_SYSCTRL_FPDSCR_AHP(n) (((uint32_t)(n) << 26) & 0x04000000)
|
||||
|
||||
// Default value for FPSCR.DN.
|
||||
#define AM_REG_SYSCTRL_FPDSCR_DN_S 25
|
||||
#define AM_REG_SYSCTRL_FPDSCR_DN_M 0x02000000
|
||||
#define AM_REG_SYSCTRL_FPDSCR_DN(n) (((uint32_t)(n) << 25) & 0x02000000)
|
||||
|
||||
// Default value for FPSCR.FZ.
|
||||
#define AM_REG_SYSCTRL_FPDSCR_FZ_S 24
|
||||
#define AM_REG_SYSCTRL_FPDSCR_FZ_M 0x01000000
|
||||
#define AM_REG_SYSCTRL_FPDSCR_FZ(n) (((uint32_t)(n) << 24) & 0x01000000)
|
||||
|
||||
// Default value for FPSCR.RMode.
|
||||
#define AM_REG_SYSCTRL_FPDSCR_RMODE_S 22
|
||||
#define AM_REG_SYSCTRL_FPDSCR_RMODE_M 0x00C00000
|
||||
#define AM_REG_SYSCTRL_FPDSCR_RMODE(n) (((uint32_t)(n) << 22) & 0x00C00000)
|
||||
|
||||
#endif // AM_REG_SYSCTRL_H
|
||||
@@ -0,0 +1,141 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_systick.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the SYSTICK module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_SYSTICK_H
|
||||
#define AM_REG_SYSTICK_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSTICK
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_SYSTICK_NUM_MODULES 1
|
||||
#define AM_REG_SYSTICKn(n) \
|
||||
(REG_SYSTICK_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_SYSTICK_SYSTCSR_O 0xE000E010
|
||||
#define AM_REG_SYSTICK_SYSTRVR_O 0xE000E014
|
||||
#define AM_REG_SYSTICK_SYSTCVR_O 0xE000E018
|
||||
#define AM_REG_SYSTICK_SYSTCALIB_O 0xE000E01C
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSTICK_SYSTCSR - SysTick Control and Status Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Returns 1 if timer counted to 0 since last time this was read.
|
||||
#define AM_REG_SYSTICK_SYSTCSR_COUNTFLAG_S 16
|
||||
#define AM_REG_SYSTICK_SYSTCSR_COUNTFLAG_M 0x00010000
|
||||
#define AM_REG_SYSTICK_SYSTCSR_COUNTFLAG(n) (((uint32_t)(n) << 16) & 0x00010000)
|
||||
|
||||
// Enables SysTick exception request. Software can use COUNTFLAG to determine if
|
||||
// SysTick has ever counted to zero. 0 = counting down to zero does not assert
|
||||
// the SysTick exception request; 1 = counting down to zero asserts the SysTick
|
||||
// exception request.
|
||||
#define AM_REG_SYSTICK_SYSTCSR_TICKINT_S 1
|
||||
#define AM_REG_SYSTICK_SYSTCSR_TICKINT_M 0x00000002
|
||||
#define AM_REG_SYSTICK_SYSTCSR_TICKINT(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// Enables the counter. 0 = counter disabled; 1 = counter enabled.
|
||||
#define AM_REG_SYSTICK_SYSTCSR_ENABLE_S 0
|
||||
#define AM_REG_SYSTICK_SYSTCSR_ENABLE_M 0x00000001
|
||||
#define AM_REG_SYSTICK_SYSTCSR_ENABLE(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSTICK_SYSTRVR - SysTick Reload Value Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Value to load into the SYSTCVR register when the counter is enabled and when
|
||||
// it reaches 0.
|
||||
#define AM_REG_SYSTICK_SYSTRVR_RELOAD_S 0
|
||||
#define AM_REG_SYSTICK_SYSTRVR_RELOAD_M 0x00FFFFFF
|
||||
#define AM_REG_SYSTICK_SYSTRVR_RELOAD(n) (((uint32_t)(n) << 0) & 0x00FFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSTICK_SYSTCVR - SysTick Current Value Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Reads return the current value of the SysTick counter. A write of any value
|
||||
// clears the field to 0, and also clears the SYSTCSR COUNTFLAG bit to 0.
|
||||
#define AM_REG_SYSTICK_SYSTCVR_CURRENT_S 0
|
||||
#define AM_REG_SYSTICK_SYSTCVR_CURRENT_M 0x00FFFFFF
|
||||
#define AM_REG_SYSTICK_SYSTCVR_CURRENT(n) (((uint32_t)(n) << 0) & 0x00FFFFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SYSTICK_SYSTCALIB - SysTick Calibration Value Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Indicates whether the device provides a reference clock to the processor. 0 =
|
||||
// reference clock provided; 1 = no reference clock provided. If your device
|
||||
// does not provide a reference clock, the SYST_CSR.CLKSOURCE bit reads-as-one
|
||||
// and ignores writes.
|
||||
#define AM_REG_SYSTICK_SYSTCALIB_NOREF_S 31
|
||||
#define AM_REG_SYSTICK_SYSTCALIB_NOREF_M 0x80000000
|
||||
#define AM_REG_SYSTICK_SYSTCALIB_NOREF(n) (((uint32_t)(n) << 31) & 0x80000000)
|
||||
|
||||
// Indicates whether the TENMS value is exact. 0 = TENMS value is exact; 1 =
|
||||
// TENMS value is inexact, or not given. An inexact TENMS value can affect the
|
||||
// suitability of SysTick as a software real time clock.
|
||||
#define AM_REG_SYSTICK_SYSTCALIB_SKEW_S 30
|
||||
#define AM_REG_SYSTICK_SYSTCALIB_SKEW_M 0x40000000
|
||||
#define AM_REG_SYSTICK_SYSTCALIB_SKEW(n) (((uint32_t)(n) << 30) & 0x40000000)
|
||||
|
||||
// Reload value for 10ms (100Hz) timing, subject to system clock skew errors. If
|
||||
// the value reads as zero, the calibration value is not known.
|
||||
#define AM_REG_SYSTICK_SYSTCALIB_TENMS_S 0
|
||||
#define AM_REG_SYSTICK_SYSTCALIB_TENMS_M 0x00FFFFFF
|
||||
#define AM_REG_SYSTICK_SYSTCALIB_TENMS(n) (((uint32_t)(n) << 0) & 0x00FFFFFF)
|
||||
|
||||
#endif // AM_REG_SYSTICK_H
|
||||
@@ -0,0 +1,168 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_tpiu.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the TPIU module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_TPIU_H
|
||||
#define AM_REG_TPIU_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_TPIU_NUM_MODULES 1
|
||||
#define AM_REG_TPIUn(n) \
|
||||
(REG_TPIU_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_TPIU_SSPSR_O 0xE0040000
|
||||
#define AM_REG_TPIU_CSPSR_O 0xE0040004
|
||||
#define AM_REG_TPIU_ACPR_O 0xE0040010
|
||||
#define AM_REG_TPIU_SPPR_O 0xE00400F0
|
||||
#define AM_REG_TPIU_FFCR_O 0xE0040304
|
||||
#define AM_REG_TPIU_ITCTRL_O 0xE0040F00
|
||||
#define AM_REG_TPIU_TYPE_O 0xE0040FC8
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU_SSPSR - Supported Parallel Port Sizes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Parallel Port Width 1 supported
|
||||
#define AM_REG_TPIU_SSPSR_SWIDTH0_S 0
|
||||
#define AM_REG_TPIU_SSPSR_SWIDTH0_M 0x00000001
|
||||
#define AM_REG_TPIU_SSPSR_SWIDTH0(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU_CSPSR - Current Parallel Port Size.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// One-hot representation of the current port width.
|
||||
#define AM_REG_TPIU_CSPSR_CWIDTH_S 0
|
||||
#define AM_REG_TPIU_CSPSR_CWIDTH_M 0xFFFFFFFF
|
||||
#define AM_REG_TPIU_CSPSR_CWIDTH(n) (((uint32_t)(n) << 0) & 0xFFFFFFFF)
|
||||
#define AM_REG_TPIU_CSPSR_CWIDTH_1BIT 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU_ACPR - Asynchronous Clock Prescaler.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Prescaler value for the baudrate of SWO.
|
||||
#define AM_REG_TPIU_ACPR_SWOSCALER_S 0
|
||||
#define AM_REG_TPIU_ACPR_SWOSCALER_M 0x0000FFFF
|
||||
#define AM_REG_TPIU_ACPR_SWOSCALER(n) (((uint32_t)(n) << 0) & 0x0000FFFF)
|
||||
#define AM_REG_TPIU_ACPR_SWOSCALER_115200 0x00000033
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU_SPPR - Selected Pin Protocol.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Selects the protocol used for trace output.
|
||||
#define AM_REG_TPIU_SPPR_TXMODE_S 0
|
||||
#define AM_REG_TPIU_SPPR_TXMODE_M 0x00000003
|
||||
#define AM_REG_TPIU_SPPR_TXMODE(n) (((uint32_t)(n) << 0) & 0x00000003)
|
||||
#define AM_REG_TPIU_SPPR_TXMODE_PARALLEL 0x00000000
|
||||
#define AM_REG_TPIU_SPPR_TXMODE_MANCHESTER 0x00000001
|
||||
#define AM_REG_TPIU_SPPR_TXMODE_NRZ 0x00000002
|
||||
#define AM_REG_TPIU_SPPR_TXMODE_UART 0x00000002
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU_FFCR - Formatter and Flush Control Register.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Enable continuous formatting.
|
||||
#define AM_REG_TPIU_FFCR_ENFCONT_S 1
|
||||
#define AM_REG_TPIU_FFCR_ENFCONT_M 0x00000002
|
||||
#define AM_REG_TPIU_FFCR_ENFCONT(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU_ITCTRL - Specifies normal or integration mode for the TPIU.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Specifies the current mode for the TPIU.
|
||||
#define AM_REG_TPIU_ITCTRL_MODE_S 0
|
||||
#define AM_REG_TPIU_ITCTRL_MODE_M 0x00000003
|
||||
#define AM_REG_TPIU_ITCTRL_MODE(n) (((uint32_t)(n) << 0) & 0x00000003)
|
||||
#define AM_REG_TPIU_ITCTRL_MODE_NORMAL 0x00000000
|
||||
#define AM_REG_TPIU_ITCTRL_MODE_TEST 0x00000001
|
||||
#define AM_REG_TPIU_ITCTRL_MODE_DATA_TEST 0x00000002
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TPIU_TYPE - TPIU Type.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// 1 Indicates UART/NRZ support.
|
||||
#define AM_REG_TPIU_TYPE_NRZVALID_S 11
|
||||
#define AM_REG_TPIU_TYPE_NRZVALID_M 0x00000800
|
||||
#define AM_REG_TPIU_TYPE_NRZVALID(n) (((uint32_t)(n) << 11) & 0x00000800)
|
||||
|
||||
// 1 Indicates Manchester support.
|
||||
#define AM_REG_TPIU_TYPE_MANCVALID_S 10
|
||||
#define AM_REG_TPIU_TYPE_MANCVALID_M 0x00000400
|
||||
#define AM_REG_TPIU_TYPE_MANCVALID(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// 0 Indicates Parallel Trace support.
|
||||
#define AM_REG_TPIU_TYPE_PTINVALID_S 9
|
||||
#define AM_REG_TPIU_TYPE_PTINVALID_M 0x00000200
|
||||
#define AM_REG_TPIU_TYPE_PTINVALID(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// FIFO Size reported as a power of two. For instance, 0x3 indicates a FIFO size
|
||||
// of 8 bytes.
|
||||
#define AM_REG_TPIU_TYPE_FIFOSZ_S 6
|
||||
#define AM_REG_TPIU_TYPE_FIFOSZ_M 0x000001C0
|
||||
#define AM_REG_TPIU_TYPE_FIFOSZ(n) (((uint32_t)(n) << 6) & 0x000001C0)
|
||||
|
||||
#endif // AM_REG_TPIU_H
|
||||
@@ -0,0 +1,616 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_uart.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the UART module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_UART_H
|
||||
#define AM_REG_UART_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_UART_NUM_MODULES 1
|
||||
#define AM_REG_UARTn(n) \
|
||||
(REG_UART_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_UART_DR_O 0x00000000
|
||||
#define AM_REG_UART_RSR_O 0x00000004
|
||||
#define AM_REG_UART_FR_O 0x00000018
|
||||
#define AM_REG_UART_ILPR_O 0x00000020
|
||||
#define AM_REG_UART_IBRD_O 0x00000024
|
||||
#define AM_REG_UART_FBRD_O 0x00000028
|
||||
#define AM_REG_UART_LCRH_O 0x0000002C
|
||||
#define AM_REG_UART_CR_O 0x00000030
|
||||
#define AM_REG_UART_IFLS_O 0x00000034
|
||||
#define AM_REG_UART_IER_O 0x00000038
|
||||
#define AM_REG_UART_IES_O 0x0000003C
|
||||
#define AM_REG_UART_MIS_O 0x00000040
|
||||
#define AM_REG_UART_IEC_O 0x00000044
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_DR - UART Data Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This is the overrun error indicator.
|
||||
#define AM_REG_UART_DR_OEDATA_S 11
|
||||
#define AM_REG_UART_DR_OEDATA_M 0x00000800
|
||||
#define AM_REG_UART_DR_OEDATA(n) (((uint32_t)(n) << 11) & 0x00000800)
|
||||
#define AM_REG_UART_DR_OEDATA_NOERR 0x00000000
|
||||
#define AM_REG_UART_DR_OEDATA_ERR 0x00000800
|
||||
|
||||
// This is the break error indicator.
|
||||
#define AM_REG_UART_DR_BEDATA_S 10
|
||||
#define AM_REG_UART_DR_BEDATA_M 0x00000400
|
||||
#define AM_REG_UART_DR_BEDATA(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
#define AM_REG_UART_DR_BEDATA_NOERR 0x00000000
|
||||
#define AM_REG_UART_DR_BEDATA_ERR 0x00000400
|
||||
|
||||
// This is the parity error indicator.
|
||||
#define AM_REG_UART_DR_PEDATA_S 9
|
||||
#define AM_REG_UART_DR_PEDATA_M 0x00000200
|
||||
#define AM_REG_UART_DR_PEDATA(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
#define AM_REG_UART_DR_PEDATA_NOERR 0x00000000
|
||||
#define AM_REG_UART_DR_PEDATA_ERR 0x00000200
|
||||
|
||||
// This is the framing error indicator.
|
||||
#define AM_REG_UART_DR_FEDATA_S 8
|
||||
#define AM_REG_UART_DR_FEDATA_M 0x00000100
|
||||
#define AM_REG_UART_DR_FEDATA(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
#define AM_REG_UART_DR_FEDATA_NOERR 0x00000000
|
||||
#define AM_REG_UART_DR_FEDATA_ERR 0x00000100
|
||||
|
||||
// This is the UART data port.
|
||||
#define AM_REG_UART_DR_DATA_S 0
|
||||
#define AM_REG_UART_DR_DATA_M 0x000000FF
|
||||
#define AM_REG_UART_DR_DATA(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_RSR - UART Status Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This is the overrun error indicator.
|
||||
#define AM_REG_UART_RSR_OESTAT_S 3
|
||||
#define AM_REG_UART_RSR_OESTAT_M 0x00000008
|
||||
#define AM_REG_UART_RSR_OESTAT(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
#define AM_REG_UART_RSR_OESTAT_NOERR 0x00000000
|
||||
#define AM_REG_UART_RSR_OESTAT_ERR 0x00000008
|
||||
|
||||
// This is the break error indicator.
|
||||
#define AM_REG_UART_RSR_BESTAT_S 2
|
||||
#define AM_REG_UART_RSR_BESTAT_M 0x00000004
|
||||
#define AM_REG_UART_RSR_BESTAT(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_UART_RSR_BESTAT_NOERR 0x00000000
|
||||
#define AM_REG_UART_RSR_BESTAT_ERR 0x00000004
|
||||
|
||||
// This is the parity error indicator.
|
||||
#define AM_REG_UART_RSR_PESTAT_S 1
|
||||
#define AM_REG_UART_RSR_PESTAT_M 0x00000002
|
||||
#define AM_REG_UART_RSR_PESTAT(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_UART_RSR_PESTAT_NOERR 0x00000000
|
||||
#define AM_REG_UART_RSR_PESTAT_ERR 0x00000002
|
||||
|
||||
// This is the framing error indicator.
|
||||
#define AM_REG_UART_RSR_FESTAT_S 0
|
||||
#define AM_REG_UART_RSR_FESTAT_M 0x00000001
|
||||
#define AM_REG_UART_RSR_FESTAT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_UART_RSR_FESTAT_NOERR 0x00000000
|
||||
#define AM_REG_UART_RSR_FESTAT_ERR 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_FR - Flag Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit holds the ring indicator.
|
||||
#define AM_REG_UART_FR_RI_S 8
|
||||
#define AM_REG_UART_FR_RI_M 0x00000100
|
||||
#define AM_REG_UART_FR_RI(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// This bit holds the transmit FIFO empty indicator.
|
||||
#define AM_REG_UART_FR_TXFE_S 7
|
||||
#define AM_REG_UART_FR_TXFE_M 0x00000080
|
||||
#define AM_REG_UART_FR_TXFE(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
#define AM_REG_UART_FR_TXFE_XMTFIFO_EMPTY 0x00000080
|
||||
|
||||
// This bit holds the receive FIFO full indicator.
|
||||
#define AM_REG_UART_FR_RXFF_S 6
|
||||
#define AM_REG_UART_FR_RXFF_M 0x00000040
|
||||
#define AM_REG_UART_FR_RXFF(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
#define AM_REG_UART_FR_RXFF_RCVFIFO_FULL 0x00000040
|
||||
|
||||
// This bit holds the transmit FIFO full indicator.
|
||||
#define AM_REG_UART_FR_TXFF_S 5
|
||||
#define AM_REG_UART_FR_TXFF_M 0x00000020
|
||||
#define AM_REG_UART_FR_TXFF(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
#define AM_REG_UART_FR_TXFF_XMTFIFO_FULL 0x00000020
|
||||
|
||||
// This bit holds the receive FIFO empty indicator.
|
||||
#define AM_REG_UART_FR_RXFE_S 4
|
||||
#define AM_REG_UART_FR_RXFE_M 0x00000010
|
||||
#define AM_REG_UART_FR_RXFE(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
#define AM_REG_UART_FR_RXFE_RCVFIFO_EMPTY 0x00000010
|
||||
|
||||
// This bit holds the busy indicator.
|
||||
#define AM_REG_UART_FR_BUSY_S 3
|
||||
#define AM_REG_UART_FR_BUSY_M 0x00000008
|
||||
#define AM_REG_UART_FR_BUSY(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
#define AM_REG_UART_FR_BUSY_BUSY 0x00000008
|
||||
|
||||
// This bit holds the data carrier detect indicator.
|
||||
#define AM_REG_UART_FR_DCD_S 2
|
||||
#define AM_REG_UART_FR_DCD_M 0x00000004
|
||||
#define AM_REG_UART_FR_DCD(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
#define AM_REG_UART_FR_DCD_DETECTED 0x00000004
|
||||
|
||||
// This bit holds the data set ready indicator.
|
||||
#define AM_REG_UART_FR_DSR_S 1
|
||||
#define AM_REG_UART_FR_DSR_M 0x00000002
|
||||
#define AM_REG_UART_FR_DSR(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_UART_FR_DSR_READY 0x00000002
|
||||
|
||||
// This bit holds the clear to send indicator.
|
||||
#define AM_REG_UART_FR_CTS_S 0
|
||||
#define AM_REG_UART_FR_CTS_M 0x00000001
|
||||
#define AM_REG_UART_FR_CTS(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_UART_FR_CTS_CLEARTOSEND 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_ILPR - IrDA Counter
|
||||
//
|
||||
//*****************************************************************************
|
||||
// These bits hold the IrDA counter divisor.
|
||||
#define AM_REG_UART_ILPR_ILPDVSR_S 0
|
||||
#define AM_REG_UART_ILPR_ILPDVSR_M 0x000000FF
|
||||
#define AM_REG_UART_ILPR_ILPDVSR(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_IBRD - Integer Baud Rate Divisor
|
||||
//
|
||||
//*****************************************************************************
|
||||
// These bits hold the baud integer divisor.
|
||||
#define AM_REG_UART_IBRD_DIVINT_S 0
|
||||
#define AM_REG_UART_IBRD_DIVINT_M 0x0000FFFF
|
||||
#define AM_REG_UART_IBRD_DIVINT(n) (((uint32_t)(n) << 0) & 0x0000FFFF)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_FBRD - Fractional Baud Rate Divisor
|
||||
//
|
||||
//*****************************************************************************
|
||||
// These bits hold the baud fractional divisor.
|
||||
#define AM_REG_UART_FBRD_DIVFRAC_S 0
|
||||
#define AM_REG_UART_FBRD_DIVFRAC_M 0x0000003F
|
||||
#define AM_REG_UART_FBRD_DIVFRAC(n) (((uint32_t)(n) << 0) & 0x0000003F)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_LCRH - Line Control High
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit holds the stick parity select.
|
||||
#define AM_REG_UART_LCRH_SPS_S 7
|
||||
#define AM_REG_UART_LCRH_SPS_M 0x00000080
|
||||
#define AM_REG_UART_LCRH_SPS(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// These bits hold the write length.
|
||||
#define AM_REG_UART_LCRH_WLEN_S 5
|
||||
#define AM_REG_UART_LCRH_WLEN_M 0x00000060
|
||||
#define AM_REG_UART_LCRH_WLEN(n) (((uint32_t)(n) << 5) & 0x00000060)
|
||||
|
||||
// This bit holds the FIFO enable.
|
||||
#define AM_REG_UART_LCRH_FEN_S 4
|
||||
#define AM_REG_UART_LCRH_FEN_M 0x00000010
|
||||
#define AM_REG_UART_LCRH_FEN(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// This bit holds the two stop bits select.
|
||||
#define AM_REG_UART_LCRH_STP2_S 3
|
||||
#define AM_REG_UART_LCRH_STP2_M 0x00000008
|
||||
#define AM_REG_UART_LCRH_STP2(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// This bit holds the even parity select.
|
||||
#define AM_REG_UART_LCRH_EPS_S 2
|
||||
#define AM_REG_UART_LCRH_EPS_M 0x00000004
|
||||
#define AM_REG_UART_LCRH_EPS(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This bit holds the parity enable.
|
||||
#define AM_REG_UART_LCRH_PEN_S 1
|
||||
#define AM_REG_UART_LCRH_PEN_M 0x00000002
|
||||
#define AM_REG_UART_LCRH_PEN(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit holds the break set.
|
||||
#define AM_REG_UART_LCRH_BRK_S 0
|
||||
#define AM_REG_UART_LCRH_BRK_M 0x00000001
|
||||
#define AM_REG_UART_LCRH_BRK(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_CR - Control Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit enables CTS hardware flow control.
|
||||
#define AM_REG_UART_CR_CTSEN_S 15
|
||||
#define AM_REG_UART_CR_CTSEN_M 0x00008000
|
||||
#define AM_REG_UART_CR_CTSEN(n) (((uint32_t)(n) << 15) & 0x00008000)
|
||||
|
||||
// This bit enables RTS hardware flow control.
|
||||
#define AM_REG_UART_CR_RTSEN_S 14
|
||||
#define AM_REG_UART_CR_RTSEN_M 0x00004000
|
||||
#define AM_REG_UART_CR_RTSEN(n) (((uint32_t)(n) << 14) & 0x00004000)
|
||||
|
||||
// This bit holds modem Out2.
|
||||
#define AM_REG_UART_CR_OUT2_S 13
|
||||
#define AM_REG_UART_CR_OUT2_M 0x00002000
|
||||
#define AM_REG_UART_CR_OUT2(n) (((uint32_t)(n) << 13) & 0x00002000)
|
||||
|
||||
// This bit holds modem Out1.
|
||||
#define AM_REG_UART_CR_OUT1_S 12
|
||||
#define AM_REG_UART_CR_OUT1_M 0x00001000
|
||||
#define AM_REG_UART_CR_OUT1(n) (((uint32_t)(n) << 12) & 0x00001000)
|
||||
|
||||
// This bit enables request to send.
|
||||
#define AM_REG_UART_CR_RTS_S 11
|
||||
#define AM_REG_UART_CR_RTS_M 0x00000800
|
||||
#define AM_REG_UART_CR_RTS(n) (((uint32_t)(n) << 11) & 0x00000800)
|
||||
|
||||
// This bit enables data transmit ready.
|
||||
#define AM_REG_UART_CR_DTR_S 10
|
||||
#define AM_REG_UART_CR_DTR_M 0x00000400
|
||||
#define AM_REG_UART_CR_DTR(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// This bit is the receive enable.
|
||||
#define AM_REG_UART_CR_RXE_S 9
|
||||
#define AM_REG_UART_CR_RXE_M 0x00000200
|
||||
#define AM_REG_UART_CR_RXE(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// This bit is the transmit enable.
|
||||
#define AM_REG_UART_CR_TXE_S 8
|
||||
#define AM_REG_UART_CR_TXE_M 0x00000100
|
||||
#define AM_REG_UART_CR_TXE(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// This bit is the loopback enable.
|
||||
#define AM_REG_UART_CR_LBE_S 7
|
||||
#define AM_REG_UART_CR_LBE_M 0x00000080
|
||||
#define AM_REG_UART_CR_LBE(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// This bitfield is the UART clock select.
|
||||
#define AM_REG_UART_CR_CLKSEL_S 4
|
||||
#define AM_REG_UART_CR_CLKSEL_M 0x00000070
|
||||
#define AM_REG_UART_CR_CLKSEL(n) (((uint32_t)(n) << 4) & 0x00000070)
|
||||
#define AM_REG_UART_CR_CLKSEL_NOCLK 0x00000000
|
||||
#define AM_REG_UART_CR_CLKSEL_24MHZ 0x00000010
|
||||
#define AM_REG_UART_CR_CLKSEL_12MHZ 0x00000020
|
||||
#define AM_REG_UART_CR_CLKSEL_6MHZ 0x00000030
|
||||
#define AM_REG_UART_CR_CLKSEL_3MHZ 0x00000040
|
||||
#define AM_REG_UART_CR_CLKSEL_RSVD5 0x00000050
|
||||
#define AM_REG_UART_CR_CLKSEL_RSVD6 0x00000060
|
||||
#define AM_REG_UART_CR_CLKSEL_RSVD7 0x00000070
|
||||
|
||||
// This bit is the UART clock enable.
|
||||
#define AM_REG_UART_CR_CLKEN_S 3
|
||||
#define AM_REG_UART_CR_CLKEN_M 0x00000008
|
||||
#define AM_REG_UART_CR_CLKEN(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// This bit is the SIR low power select.
|
||||
#define AM_REG_UART_CR_SIRLP_S 2
|
||||
#define AM_REG_UART_CR_SIRLP_M 0x00000004
|
||||
#define AM_REG_UART_CR_SIRLP(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This bit is the SIR ENDEC enable.
|
||||
#define AM_REG_UART_CR_SIREN_S 1
|
||||
#define AM_REG_UART_CR_SIREN_M 0x00000002
|
||||
#define AM_REG_UART_CR_SIREN(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit is the UART enable.
|
||||
#define AM_REG_UART_CR_UARTEN_S 0
|
||||
#define AM_REG_UART_CR_UARTEN_M 0x00000001
|
||||
#define AM_REG_UART_CR_UARTEN(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_IFLS - FIFO Interrupt Level Select
|
||||
//
|
||||
//*****************************************************************************
|
||||
// These bits hold the receive FIFO interrupt level.
|
||||
#define AM_REG_UART_IFLS_RXIFLSEL_S 3
|
||||
#define AM_REG_UART_IFLS_RXIFLSEL_M 0x00000038
|
||||
#define AM_REG_UART_IFLS_RXIFLSEL(n) (((uint32_t)(n) << 3) & 0x00000038)
|
||||
|
||||
// These bits hold the transmit FIFO interrupt level.
|
||||
#define AM_REG_UART_IFLS_TXIFLSEL_S 0
|
||||
#define AM_REG_UART_IFLS_TXIFLSEL_M 0x00000007
|
||||
#define AM_REG_UART_IFLS_TXIFLSEL(n) (((uint32_t)(n) << 0) & 0x00000007)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_IER - Interrupt Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit holds the overflow interrupt enable.
|
||||
#define AM_REG_UART_IER_OEIM_S 10
|
||||
#define AM_REG_UART_IER_OEIM_M 0x00000400
|
||||
#define AM_REG_UART_IER_OEIM(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// This bit holds the break error interrupt enable.
|
||||
#define AM_REG_UART_IER_BEIM_S 9
|
||||
#define AM_REG_UART_IER_BEIM_M 0x00000200
|
||||
#define AM_REG_UART_IER_BEIM(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// This bit holds the parity error interrupt enable.
|
||||
#define AM_REG_UART_IER_PEIM_S 8
|
||||
#define AM_REG_UART_IER_PEIM_M 0x00000100
|
||||
#define AM_REG_UART_IER_PEIM(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// This bit holds the framing error interrupt enable.
|
||||
#define AM_REG_UART_IER_FEIM_S 7
|
||||
#define AM_REG_UART_IER_FEIM_M 0x00000080
|
||||
#define AM_REG_UART_IER_FEIM(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// This bit holds the receive timeout interrupt enable.
|
||||
#define AM_REG_UART_IER_RTIM_S 6
|
||||
#define AM_REG_UART_IER_RTIM_M 0x00000040
|
||||
#define AM_REG_UART_IER_RTIM(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
|
||||
// This bit holds the transmit interrupt enable.
|
||||
#define AM_REG_UART_IER_TXIM_S 5
|
||||
#define AM_REG_UART_IER_TXIM_M 0x00000020
|
||||
#define AM_REG_UART_IER_TXIM(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// This bit holds the receive interrupt enable.
|
||||
#define AM_REG_UART_IER_RXIM_S 4
|
||||
#define AM_REG_UART_IER_RXIM_M 0x00000010
|
||||
#define AM_REG_UART_IER_RXIM(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// This bit holds the modem DSR interrupt enable.
|
||||
#define AM_REG_UART_IER_DSRMIM_S 3
|
||||
#define AM_REG_UART_IER_DSRMIM_M 0x00000008
|
||||
#define AM_REG_UART_IER_DSRMIM(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// This bit holds the modem DCD interrupt enable.
|
||||
#define AM_REG_UART_IER_DCDMIM_S 2
|
||||
#define AM_REG_UART_IER_DCDMIM_M 0x00000004
|
||||
#define AM_REG_UART_IER_DCDMIM(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This bit holds the modem CTS interrupt enable.
|
||||
#define AM_REG_UART_IER_CTSMIM_S 1
|
||||
#define AM_REG_UART_IER_CTSMIM_M 0x00000002
|
||||
#define AM_REG_UART_IER_CTSMIM(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit holds the modem RI interrupt enable.
|
||||
#define AM_REG_UART_IER_RIMIM_S 0
|
||||
#define AM_REG_UART_IER_RIMIM_M 0x00000001
|
||||
#define AM_REG_UART_IER_RIMIM(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_IES - Interrupt Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit holds the overflow interrupt status.
|
||||
#define AM_REG_UART_IES_OERIS_S 10
|
||||
#define AM_REG_UART_IES_OERIS_M 0x00000400
|
||||
#define AM_REG_UART_IES_OERIS(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// This bit holds the break error interrupt status.
|
||||
#define AM_REG_UART_IES_BERIS_S 9
|
||||
#define AM_REG_UART_IES_BERIS_M 0x00000200
|
||||
#define AM_REG_UART_IES_BERIS(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// This bit holds the parity error interrupt status.
|
||||
#define AM_REG_UART_IES_PERIS_S 8
|
||||
#define AM_REG_UART_IES_PERIS_M 0x00000100
|
||||
#define AM_REG_UART_IES_PERIS(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// This bit holds the framing error interrupt status.
|
||||
#define AM_REG_UART_IES_FERIS_S 7
|
||||
#define AM_REG_UART_IES_FERIS_M 0x00000080
|
||||
#define AM_REG_UART_IES_FERIS(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// This bit holds the receive timeout interrupt status.
|
||||
#define AM_REG_UART_IES_RTRIS_S 6
|
||||
#define AM_REG_UART_IES_RTRIS_M 0x00000040
|
||||
#define AM_REG_UART_IES_RTRIS(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
|
||||
// This bit holds the transmit interrupt status.
|
||||
#define AM_REG_UART_IES_TXRIS_S 5
|
||||
#define AM_REG_UART_IES_TXRIS_M 0x00000020
|
||||
#define AM_REG_UART_IES_TXRIS(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// This bit holds the receive interrupt status.
|
||||
#define AM_REG_UART_IES_RXRIS_S 4
|
||||
#define AM_REG_UART_IES_RXRIS_M 0x00000010
|
||||
#define AM_REG_UART_IES_RXRIS(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// This bit holds the modem DSR interrupt status.
|
||||
#define AM_REG_UART_IES_DSRMRIS_S 3
|
||||
#define AM_REG_UART_IES_DSRMRIS_M 0x00000008
|
||||
#define AM_REG_UART_IES_DSRMRIS(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// This bit holds the modem DCD interrupt status.
|
||||
#define AM_REG_UART_IES_DCDMRIS_S 2
|
||||
#define AM_REG_UART_IES_DCDMRIS_M 0x00000004
|
||||
#define AM_REG_UART_IES_DCDMRIS(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This bit holds the modem CTS interrupt status.
|
||||
#define AM_REG_UART_IES_CTSMRIS_S 1
|
||||
#define AM_REG_UART_IES_CTSMRIS_M 0x00000002
|
||||
#define AM_REG_UART_IES_CTSMRIS(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit holds the modem RI interrupt status.
|
||||
#define AM_REG_UART_IES_RIMRIS_S 0
|
||||
#define AM_REG_UART_IES_RIMRIS_M 0x00000001
|
||||
#define AM_REG_UART_IES_RIMRIS(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_MIS - Masked Interrupt Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit holds the overflow interrupt status masked.
|
||||
#define AM_REG_UART_MIS_OEMIS_S 10
|
||||
#define AM_REG_UART_MIS_OEMIS_M 0x00000400
|
||||
#define AM_REG_UART_MIS_OEMIS(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// This bit holds the break error interrupt status masked.
|
||||
#define AM_REG_UART_MIS_BEMIS_S 9
|
||||
#define AM_REG_UART_MIS_BEMIS_M 0x00000200
|
||||
#define AM_REG_UART_MIS_BEMIS(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// This bit holds the parity error interrupt status masked.
|
||||
#define AM_REG_UART_MIS_PEMIS_S 8
|
||||
#define AM_REG_UART_MIS_PEMIS_M 0x00000100
|
||||
#define AM_REG_UART_MIS_PEMIS(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// This bit holds the framing error interrupt status masked.
|
||||
#define AM_REG_UART_MIS_FEMIS_S 7
|
||||
#define AM_REG_UART_MIS_FEMIS_M 0x00000080
|
||||
#define AM_REG_UART_MIS_FEMIS(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// This bit holds the receive timeout interrupt status masked.
|
||||
#define AM_REG_UART_MIS_RTMIS_S 6
|
||||
#define AM_REG_UART_MIS_RTMIS_M 0x00000040
|
||||
#define AM_REG_UART_MIS_RTMIS(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
|
||||
// This bit holds the transmit interrupt status masked.
|
||||
#define AM_REG_UART_MIS_TXMIS_S 5
|
||||
#define AM_REG_UART_MIS_TXMIS_M 0x00000020
|
||||
#define AM_REG_UART_MIS_TXMIS(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// This bit holds the receive interrupt status masked.
|
||||
#define AM_REG_UART_MIS_RXMIS_S 4
|
||||
#define AM_REG_UART_MIS_RXMIS_M 0x00000010
|
||||
#define AM_REG_UART_MIS_RXMIS(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// This bit holds the modem DSR interrupt status masked.
|
||||
#define AM_REG_UART_MIS_DSRMMIS_S 3
|
||||
#define AM_REG_UART_MIS_DSRMMIS_M 0x00000008
|
||||
#define AM_REG_UART_MIS_DSRMMIS(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// This bit holds the modem DCD interrupt status masked.
|
||||
#define AM_REG_UART_MIS_DCDMMIS_S 2
|
||||
#define AM_REG_UART_MIS_DCDMMIS_M 0x00000004
|
||||
#define AM_REG_UART_MIS_DCDMMIS(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This bit holds the modem CTS interrupt status masked.
|
||||
#define AM_REG_UART_MIS_CTSMMIS_S 1
|
||||
#define AM_REG_UART_MIS_CTSMMIS_M 0x00000002
|
||||
#define AM_REG_UART_MIS_CTSMMIS(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit holds the modem RI interrupt status masked.
|
||||
#define AM_REG_UART_MIS_RIMMIS_S 0
|
||||
#define AM_REG_UART_MIS_RIMMIS_M 0x00000001
|
||||
#define AM_REG_UART_MIS_RIMMIS(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UART_IEC - Interrupt Clear
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit holds the overflow interrupt clear.
|
||||
#define AM_REG_UART_IEC_OEIC_S 10
|
||||
#define AM_REG_UART_IEC_OEIC_M 0x00000400
|
||||
#define AM_REG_UART_IEC_OEIC(n) (((uint32_t)(n) << 10) & 0x00000400)
|
||||
|
||||
// This bit holds the break error interrupt clear.
|
||||
#define AM_REG_UART_IEC_BEIC_S 9
|
||||
#define AM_REG_UART_IEC_BEIC_M 0x00000200
|
||||
#define AM_REG_UART_IEC_BEIC(n) (((uint32_t)(n) << 9) & 0x00000200)
|
||||
|
||||
// This bit holds the parity error interrupt clear.
|
||||
#define AM_REG_UART_IEC_PEIC_S 8
|
||||
#define AM_REG_UART_IEC_PEIC_M 0x00000100
|
||||
#define AM_REG_UART_IEC_PEIC(n) (((uint32_t)(n) << 8) & 0x00000100)
|
||||
|
||||
// This bit holds the framing error interrupt clear.
|
||||
#define AM_REG_UART_IEC_FEIC_S 7
|
||||
#define AM_REG_UART_IEC_FEIC_M 0x00000080
|
||||
#define AM_REG_UART_IEC_FEIC(n) (((uint32_t)(n) << 7) & 0x00000080)
|
||||
|
||||
// This bit holds the receive timeout interrupt clear.
|
||||
#define AM_REG_UART_IEC_RTIC_S 6
|
||||
#define AM_REG_UART_IEC_RTIC_M 0x00000040
|
||||
#define AM_REG_UART_IEC_RTIC(n) (((uint32_t)(n) << 6) & 0x00000040)
|
||||
|
||||
// This bit holds the transmit interrupt clear.
|
||||
#define AM_REG_UART_IEC_TXIC_S 5
|
||||
#define AM_REG_UART_IEC_TXIC_M 0x00000020
|
||||
#define AM_REG_UART_IEC_TXIC(n) (((uint32_t)(n) << 5) & 0x00000020)
|
||||
|
||||
// This bit holds the receive interrupt clear.
|
||||
#define AM_REG_UART_IEC_RXIC_S 4
|
||||
#define AM_REG_UART_IEC_RXIC_M 0x00000010
|
||||
#define AM_REG_UART_IEC_RXIC(n) (((uint32_t)(n) << 4) & 0x00000010)
|
||||
|
||||
// This bit holds the modem DSR interrupt clear.
|
||||
#define AM_REG_UART_IEC_DSRMIC_S 3
|
||||
#define AM_REG_UART_IEC_DSRMIC_M 0x00000008
|
||||
#define AM_REG_UART_IEC_DSRMIC(n) (((uint32_t)(n) << 3) & 0x00000008)
|
||||
|
||||
// This bit holds the modem DCD interrupt clear.
|
||||
#define AM_REG_UART_IEC_DCDMIC_S 2
|
||||
#define AM_REG_UART_IEC_DCDMIC_M 0x00000004
|
||||
#define AM_REG_UART_IEC_DCDMIC(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This bit holds the modem CTS interrupt clear.
|
||||
#define AM_REG_UART_IEC_CTSMIC_S 1
|
||||
#define AM_REG_UART_IEC_CTSMIC_M 0x00000002
|
||||
#define AM_REG_UART_IEC_CTSMIC(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit holds the modem RI interrupt clear.
|
||||
#define AM_REG_UART_IEC_RIMIC_S 0
|
||||
#define AM_REG_UART_IEC_RIMIC_M 0x00000001
|
||||
#define AM_REG_UART_IEC_RIMIC(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
#endif // AM_REG_UART_H
|
||||
@@ -0,0 +1,204 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_vcomp.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the VCOMP module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_VCOMP_H
|
||||
#define AM_REG_VCOMP_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// VCOMP
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_VCOMP_NUM_MODULES 1
|
||||
#define AM_REG_VCOMPn(n) \
|
||||
(REG_VCOMP_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_VCOMP_CFG_O 0x00000000
|
||||
#define AM_REG_VCOMP_STAT_O 0x00000004
|
||||
#define AM_REG_VCOMP_PWDKEY_O 0x00000008
|
||||
#define AM_REG_VCOMP_INTEN_O 0x00000200
|
||||
#define AM_REG_VCOMP_INTSTAT_O 0x00000204
|
||||
#define AM_REG_VCOMP_INTCLR_O 0x00000208
|
||||
#define AM_REG_VCOMP_INTSET_O 0x0000020C
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Key values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_VCOMP_PWDKEY_KEYVAL 0x00000037
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// VCOMP_INTEN - Voltage Comparator Interrupt registers: Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit is the vcompout high interrupt.
|
||||
#define AM_REG_VCOMP_INTEN_OUTHI_S 1
|
||||
#define AM_REG_VCOMP_INTEN_OUTHI_M 0x00000002
|
||||
#define AM_REG_VCOMP_INTEN_OUTHI(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit is the vcompout low interrupt.
|
||||
#define AM_REG_VCOMP_INTEN_OUTLOW_S 0
|
||||
#define AM_REG_VCOMP_INTEN_OUTLOW_M 0x00000001
|
||||
#define AM_REG_VCOMP_INTEN_OUTLOW(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// VCOMP_INTSTAT - Voltage Comparator Interrupt registers: Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit is the vcompout high interrupt.
|
||||
#define AM_REG_VCOMP_INTSTAT_OUTHI_S 1
|
||||
#define AM_REG_VCOMP_INTSTAT_OUTHI_M 0x00000002
|
||||
#define AM_REG_VCOMP_INTSTAT_OUTHI(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit is the vcompout low interrupt.
|
||||
#define AM_REG_VCOMP_INTSTAT_OUTLOW_S 0
|
||||
#define AM_REG_VCOMP_INTSTAT_OUTLOW_M 0x00000001
|
||||
#define AM_REG_VCOMP_INTSTAT_OUTLOW(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// VCOMP_INTCLR - Voltage Comparator Interrupt registers: Clear
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit is the vcompout high interrupt.
|
||||
#define AM_REG_VCOMP_INTCLR_OUTHI_S 1
|
||||
#define AM_REG_VCOMP_INTCLR_OUTHI_M 0x00000002
|
||||
#define AM_REG_VCOMP_INTCLR_OUTHI(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit is the vcompout low interrupt.
|
||||
#define AM_REG_VCOMP_INTCLR_OUTLOW_S 0
|
||||
#define AM_REG_VCOMP_INTCLR_OUTLOW_M 0x00000001
|
||||
#define AM_REG_VCOMP_INTCLR_OUTLOW(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// VCOMP_INTSET - Voltage Comparator Interrupt registers: Set
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit is the vcompout high interrupt.
|
||||
#define AM_REG_VCOMP_INTSET_OUTHI_S 1
|
||||
#define AM_REG_VCOMP_INTSET_OUTHI_M 0x00000002
|
||||
#define AM_REG_VCOMP_INTSET_OUTHI(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bit is the vcompout low interrupt.
|
||||
#define AM_REG_VCOMP_INTSET_OUTLOW_S 0
|
||||
#define AM_REG_VCOMP_INTSET_OUTLOW_M 0x00000001
|
||||
#define AM_REG_VCOMP_INTSET_OUTLOW(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// VCOMP_CFG - Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// When the reference input NSEL is set to NSEL_DAC, this bitfield selects the
|
||||
// voltage level for the negative input to the comparator.
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_S 16
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_M 0x000F0000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL(n) (((uint32_t)(n) << 16) & 0x000F0000)
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_0P58V 0x00000000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_0P77V 0x00010000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_0P97V 0x00020000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_1P16V 0x00030000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_1P35V 0x00040000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_1P55V 0x00050000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_1P74V 0x00060000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_1P93V 0x00070000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_2P13V 0x00080000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_2P32V 0x00090000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_2P51V 0x000A0000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_2P71V 0x000B0000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_2P90V 0x000C0000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_3P09V 0x000D0000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_3P29V 0x000E0000
|
||||
#define AM_REG_VCOMP_CFG_LVLSEL_3P48V 0x000F0000
|
||||
|
||||
// This bitfield selects the negative input to the comparator.
|
||||
#define AM_REG_VCOMP_CFG_NSEL_S 8
|
||||
#define AM_REG_VCOMP_CFG_NSEL_M 0x00000300
|
||||
#define AM_REG_VCOMP_CFG_NSEL(n) (((uint32_t)(n) << 8) & 0x00000300)
|
||||
#define AM_REG_VCOMP_CFG_NSEL_VREFEXT1 0x00000000
|
||||
#define AM_REG_VCOMP_CFG_NSEL_VREFEXT2 0x00000100
|
||||
#define AM_REG_VCOMP_CFG_NSEL_VREFEXT3 0x00000300
|
||||
#define AM_REG_VCOMP_CFG_NSEL_DAC 0x00000300
|
||||
|
||||
// This bitfield selects the positive input to the comparator.
|
||||
#define AM_REG_VCOMP_CFG_PSEL_S 0
|
||||
#define AM_REG_VCOMP_CFG_PSEL_M 0x00000003
|
||||
#define AM_REG_VCOMP_CFG_PSEL(n) (((uint32_t)(n) << 0) & 0x00000003)
|
||||
#define AM_REG_VCOMP_CFG_PSEL_VDDADJ 0x00000000
|
||||
#define AM_REG_VCOMP_CFG_PSEL_VTEMP 0x00000001
|
||||
#define AM_REG_VCOMP_CFG_PSEL_VEXT1 0x00000002
|
||||
#define AM_REG_VCOMP_CFG_PSEL_VEXT2 0x00000003
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// VCOMP_STAT - Status Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bit indicates the power down state of the voltage comparator.
|
||||
#define AM_REG_VCOMP_STAT_PWDSTAT_S 1
|
||||
#define AM_REG_VCOMP_STAT_PWDSTAT_M 0x00000002
|
||||
#define AM_REG_VCOMP_STAT_PWDSTAT(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
#define AM_REG_VCOMP_STAT_PWDSTAT_POWERED_DOWN 0x00000002
|
||||
|
||||
// This bit is 1 if the positive input of the comparator is greater than the
|
||||
// negative input.
|
||||
#define AM_REG_VCOMP_STAT_CMPOUT_S 0
|
||||
#define AM_REG_VCOMP_STAT_CMPOUT_M 0x00000001
|
||||
#define AM_REG_VCOMP_STAT_CMPOUT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
#define AM_REG_VCOMP_STAT_CMPOUT_VOUT_LOW 0x00000000
|
||||
#define AM_REG_VCOMP_STAT_CMPOUT_VOUT_HIGH 0x00000001
|
||||
|
||||
#endif // AM_REG_VCOMP_H
|
||||
@@ -0,0 +1,171 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_reg_wdt.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Register macros for the WDT module
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_REG_WDT_H
|
||||
#define AM_REG_WDT_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WDT
|
||||
// Instance finder. (1 instance(s) available)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_WDT_NUM_MODULES 1
|
||||
#define AM_REG_WDTn(n) \
|
||||
(REG_WDT_BASEADDR + 0x00000000 * n)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Register offsets.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_WDT_CFG_O 0x00000000
|
||||
#define AM_REG_WDT_RSTRT_O 0x00000004
|
||||
#define AM_REG_WDT_LOCK_O 0x00000008
|
||||
#define AM_REG_WDT_INTEN_O 0x00000200
|
||||
#define AM_REG_WDT_INTSTAT_O 0x00000204
|
||||
#define AM_REG_WDT_INTCLR_O 0x00000208
|
||||
#define AM_REG_WDT_INTSET_O 0x0000020C
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WDT_INTEN - WDT Interrupt register: Enable
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Watchdog Timer Interrupt.
|
||||
#define AM_REG_WDT_INTEN_WDTINT_S 0
|
||||
#define AM_REG_WDT_INTEN_WDTINT_M 0x00000001
|
||||
#define AM_REG_WDT_INTEN_WDTINT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WDT_INTSTAT - WDT Interrupt register: Status
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Watchdog Timer Interrupt.
|
||||
#define AM_REG_WDT_INTSTAT_WDTINT_S 0
|
||||
#define AM_REG_WDT_INTSTAT_WDTINT_M 0x00000001
|
||||
#define AM_REG_WDT_INTSTAT_WDTINT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WDT_INTCLR - WDT Interrupt register: Clear
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Watchdog Timer Interrupt.
|
||||
#define AM_REG_WDT_INTCLR_WDTINT_S 0
|
||||
#define AM_REG_WDT_INTCLR_WDTINT_M 0x00000001
|
||||
#define AM_REG_WDT_INTCLR_WDTINT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WDT_INTSET - WDT Interrupt register: Set
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Watchdog Timer Interrupt.
|
||||
#define AM_REG_WDT_INTSET_WDTINT_S 0
|
||||
#define AM_REG_WDT_INTSET_WDTINT_M 0x00000001
|
||||
#define AM_REG_WDT_INTSET_WDTINT(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WDT_CFG - Configuration Register
|
||||
//
|
||||
//*****************************************************************************
|
||||
// This bitfield is the compare value for counter bits 7:0 to generate a
|
||||
// watchdog interrupt.
|
||||
#define AM_REG_WDT_CFG_INTVAL_S 16
|
||||
#define AM_REG_WDT_CFG_INTVAL_M 0x00FF0000
|
||||
#define AM_REG_WDT_CFG_INTVAL(n) (((uint32_t)(n) << 16) & 0x00FF0000)
|
||||
|
||||
// This bitfield is the compare value for counter bits 7:0 to generate a
|
||||
// watchdog reset.
|
||||
#define AM_REG_WDT_CFG_RESVAL_S 8
|
||||
#define AM_REG_WDT_CFG_RESVAL_M 0x0000FF00
|
||||
#define AM_REG_WDT_CFG_RESVAL(n) (((uint32_t)(n) << 8) & 0x0000FF00)
|
||||
|
||||
// This bitfield enables the WDT reset.
|
||||
#define AM_REG_WDT_CFG_RESEN_S 2
|
||||
#define AM_REG_WDT_CFG_RESEN_M 0x00000004
|
||||
#define AM_REG_WDT_CFG_RESEN(n) (((uint32_t)(n) << 2) & 0x00000004)
|
||||
|
||||
// This bitfield enables the WDT interrupt. Note : This bit must be set before
|
||||
// the interrupt status bit will reflect a watchdog timer expiration. The IER
|
||||
// interrupt register must also be enabled for a WDT interrupt to be sent to the
|
||||
// NVIC.
|
||||
#define AM_REG_WDT_CFG_INTEN_S 1
|
||||
#define AM_REG_WDT_CFG_INTEN_M 0x00000002
|
||||
#define AM_REG_WDT_CFG_INTEN(n) (((uint32_t)(n) << 1) & 0x00000002)
|
||||
|
||||
// This bitfield enables the WDT.
|
||||
#define AM_REG_WDT_CFG_WDTEN_S 0
|
||||
#define AM_REG_WDT_CFG_WDTEN_M 0x00000001
|
||||
#define AM_REG_WDT_CFG_WDTEN(n) (((uint32_t)(n) << 0) & 0x00000001)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WDT_RSTRT - Restart the watchdog timer
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Writing 0xB2 to WDTRSTRT restarts the watchdog timer.
|
||||
#define AM_REG_WDT_RSTRT_RSTRT_S 0
|
||||
#define AM_REG_WDT_RSTRT_RSTRT_M 0x000000FF
|
||||
#define AM_REG_WDT_RSTRT_RSTRT(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
#define AM_REG_WDT_RSTRT_RSTRT_KEYVALUE 0x000000B2
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// WDT_LOCK - Locks the WDT
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Writing 0x3A locks the watchdog timer. Once locked, the WDTCFG reg cannot be
|
||||
// written and WDTEN is set.
|
||||
#define AM_REG_WDT_LOCK_LOCK_S 0
|
||||
#define AM_REG_WDT_LOCK_LOCK_M 0x000000FF
|
||||
#define AM_REG_WDT_LOCK_LOCK(n) (((uint32_t)(n) << 0) & 0x000000FF)
|
||||
#define AM_REG_WDT_LOCK_LOCK_KEYVALUE 0x0000003A
|
||||
|
||||
#endif // AM_REG_WDT_H
|
||||
@@ -0,0 +1,57 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# Makefile - Rules for building the libraries, examples and docs.
|
||||
#
|
||||
# Copyright (c) 2020, Ambiq Micro
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# Third party software included in this distribution is subject to the
|
||||
# additional license terms as defined in the /docs/licenses directory.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
SUBDIRS=${wildcard */}
|
||||
|
||||
all:
|
||||
@for i in ${SUBDIRS}; \
|
||||
do \
|
||||
if [ -f $${i}/Makefile ]; then \
|
||||
$(MAKE) -C $${i} || exit $$?; fi; \
|
||||
done
|
||||
|
||||
clean:
|
||||
@for i in ${SUBDIRS}; \
|
||||
do \
|
||||
if [ -f $${i}/Makefile ]; then \
|
||||
$(MAKE) -C $${i} clean; fi; \
|
||||
done
|
||||
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_mcu_apollo.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Top Include for Apollo2 class devices.
|
||||
//!
|
||||
//! This file provides all the includes necessary for an apollo device.
|
||||
//!
|
||||
//! @addtogroup hal Hardware Abstraction Layer (HAL)
|
||||
//
|
||||
//! @defgroup apollo2hal HAL for Apollo2
|
||||
//! @ingroup hal
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_MCU_APOLLO_H
|
||||
#define AM_MCU_APOLLO_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Define AM_CMSIS_REGS to indicate that AM_REGS registers are supported.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_CMSIS_REGS 0 // 0 = Use AM_REGS
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// C99
|
||||
//
|
||||
//*****************************************************************************
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
#include "intrinsics.h" // __CLZ() and other intrinsics
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Registers
|
||||
//
|
||||
//*****************************************************************************
|
||||
#include "regs/am_reg_base_addresses.h"
|
||||
|
||||
#include "regs/am_reg_macros.h"
|
||||
|
||||
#include "regs/am_reg_adc.h"
|
||||
#include "regs/am_reg_cachectrl.h"
|
||||
#include "regs/am_reg_clkgen.h"
|
||||
#include "regs/am_reg_ctimer.h"
|
||||
#include "regs/am_reg_gpio.h"
|
||||
#include "regs/am_reg_iomstr.h"
|
||||
#include "regs/am_reg_ioslave.h"
|
||||
#include "regs/am_reg_itm.h"
|
||||
#include "regs/am_reg_jedec.h"
|
||||
#include "regs/am_reg_mcuctrl.h"
|
||||
#include "regs/am_reg_nvic.h"
|
||||
#include "regs/am_reg_pdm.h"
|
||||
#include "regs/am_reg_pwrctrl.h"
|
||||
#include "regs/am_reg_rstgen.h"
|
||||
#include "regs/am_reg_rtc.h"
|
||||
#include "regs/am_reg_sysctrl.h"
|
||||
#include "regs/am_reg_systick.h"
|
||||
#include "regs/am_reg_tpiu.h"
|
||||
#include "regs/am_reg_uart.h"
|
||||
#include "regs/am_reg_vcomp.h"
|
||||
#include "regs/am_reg_wdt.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// HAL
|
||||
//
|
||||
//*****************************************************************************
|
||||
#include "hal/am_hal_adc.h"
|
||||
#include "hal/am_hal_cachectrl.h"
|
||||
#include "hal/am_hal_clkgen.h"
|
||||
#include "hal/am_hal_ctimer.h"
|
||||
#include "hal/am_hal_debug.h"
|
||||
#include "hal/am_hal_flash.h"
|
||||
#include "hal/am_hal_global.h"
|
||||
#include "hal/am_hal_gpio.h"
|
||||
#include "hal/am_hal_i2c_bit_bang.h"
|
||||
#include "hal/am_hal_interrupt.h"
|
||||
#include "hal/am_hal_iom.h"
|
||||
#include "hal/am_hal_ios.h"
|
||||
#include "hal/am_hal_itm.h"
|
||||
#include "hal/am_hal_mcuctrl.h"
|
||||
#include "hal/am_hal_otp.h"
|
||||
#include "hal/am_hal_pdm.h"
|
||||
#include "hal/am_hal_pin.h"
|
||||
#include "hal/am_hal_pwrctrl.h"
|
||||
#include "hal/am_hal_queue.h"
|
||||
#include "hal/am_hal_reset.h"
|
||||
#include "hal/am_hal_rtc.h"
|
||||
#include "hal/am_hal_stimer.h"
|
||||
#include "hal/am_hal_sysctrl.h"
|
||||
#include "hal/am_hal_systick.h"
|
||||
#include "hal/am_hal_tpiu.h"
|
||||
#include "hal/am_hal_uart.h"
|
||||
#include "hal/am_hal_vcomp.h"
|
||||
#include "hal/am_hal_wdt.h"
|
||||
|
||||
#endif // AM_MCU_APOLLO_H
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# Makefile - Rules for compiling
|
||||
#
|
||||
# Copyright (c) 2020, Ambiq Micro
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# Third party software included in this distribution is subject to the
|
||||
# additional license terms as defined in the /docs/licenses directory.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
# All makefiles use this to find the top level directory.
|
||||
SWROOT?=../../..
|
||||
|
||||
# Include rules for building the HAL.
|
||||
include $(SWROOT)/makedefs/am_hal.mk
|
||||
|
||||
# Generate pin definitions for apollo3.
|
||||
CHIP_GENERATION = 2
|
||||
@@ -0,0 +1,559 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_adc.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the Analog to Digital Converter.
|
||||
//!
|
||||
//! @addtogroup adc2 Analog-to-Digital Converter (ADC)
|
||||
//! @ingroup apollo2hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Private SRAM view of temperature trims.
|
||||
//!
|
||||
//! This static SRAM union is private to the ADC HAL functions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static union
|
||||
{
|
||||
//! These trim values are loaded as uint32_t values.
|
||||
struct
|
||||
{
|
||||
//! Temperature of the package test head (in degrees Kelvin)
|
||||
uint32_t ui32CalibrationTemperature;
|
||||
|
||||
//! Voltage corresponding to temperature measured on test head.
|
||||
uint32_t ui32CalibrationVoltage;
|
||||
|
||||
//! ADC offset voltage measured on the package test head.
|
||||
uint32_t ui32CalibrationOffset;
|
||||
|
||||
//! Flag if default (guess) or measured.
|
||||
bool bMeasured;
|
||||
} ui32;
|
||||
//! These trim values are accessed as floats when used in temp calculations.
|
||||
struct
|
||||
{
|
||||
//! Temperature of the package test head in degrees Kelvin
|
||||
float fCalibrationTemperature;
|
||||
|
||||
//! Voltage corresponding to temperature measured on test head.
|
||||
float fCalibrationVoltage;
|
||||
|
||||
//! ADC offset voltage measured on the package test head.
|
||||
float fCalibrationOffset;
|
||||
|
||||
//! Flag if default (guess) or measured.
|
||||
float fMeasuredFlag;
|
||||
} flt;
|
||||
} priv_temp_trims;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configure the ADC.
|
||||
//!
|
||||
//! @param psConfig - pointer to the configuration structure for the ADC.
|
||||
//!
|
||||
//! This function may be used to perform the initial setup of the ADC based on
|
||||
//! setting found in a configuration structure.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_config(am_hal_adc_config_t *psConfig)
|
||||
{
|
||||
//
|
||||
// Set general ADC configuration parameters.
|
||||
//
|
||||
AM_REG(ADC, CFG) = (psConfig->ui32Clock |
|
||||
psConfig->ui32TriggerConfig |
|
||||
psConfig->ui32Reference |
|
||||
psConfig->ui32ClockMode |
|
||||
psConfig->ui32PowerMode |
|
||||
psConfig->ui32Repeat |
|
||||
AM_REG_ADC_CFG_ADCEN(1));
|
||||
|
||||
//
|
||||
// Grab the temperature trims.
|
||||
//
|
||||
priv_temp_trims.ui32.ui32CalibrationTemperature =
|
||||
am_hal_flash_load_ui32(AM_HAL_ADC_CALIB_TEMP_ADDR);
|
||||
priv_temp_trims.ui32.ui32CalibrationVoltage =
|
||||
am_hal_flash_load_ui32(AM_HAL_ADC_CALIB_AMBIENT_ADDR);
|
||||
priv_temp_trims.ui32.ui32CalibrationOffset =
|
||||
am_hal_flash_load_ui32(AM_HAL_ADC_CALIB_ADC_OFFSET_ADDR);
|
||||
|
||||
if ( (priv_temp_trims.ui32.ui32CalibrationTemperature == 0xffffffff) ||
|
||||
(priv_temp_trims.ui32.ui32CalibrationVoltage == 0xffffffff) ||
|
||||
(priv_temp_trims.ui32.ui32CalibrationOffset == 0xffffffff) )
|
||||
{
|
||||
//
|
||||
// Since the device has not been calibrated on the tester, we'll load
|
||||
// default calibration values. These default values should result
|
||||
// in worst-case temperature measurements of +-6 degress C.
|
||||
//
|
||||
priv_temp_trims.flt.fCalibrationTemperature = AM_HAL_ADC_CALIB_TEMP_DEFAULT;
|
||||
priv_temp_trims.flt.fCalibrationVoltage = AM_HAL_ADC_CALIB_AMBIENT_DEFAULT;
|
||||
priv_temp_trims.flt.fCalibrationOffset = AM_HAL_ADC_CALIB_ADC_OFFSET_DEFAULT;
|
||||
priv_temp_trims.ui32.bMeasured = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
priv_temp_trims.ui32.bMeasured = true;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the temperature trim parameters after configuring the ADC.
|
||||
//!
|
||||
//! @param pfTemp - pointer to a location to store the calibration temperature.
|
||||
//! @param pfVoltage - pointer to a location to store the calibration voltage.
|
||||
//! @param pfOffsetV - pointer to a location to store the calibration offset.
|
||||
//!
|
||||
//! This function may be used to access the actual temperature sensor trim
|
||||
//! values from the private structure.
|
||||
//!
|
||||
//! WARNING: only call this after the ADC has been configured with
|
||||
//! am_hal_adc_config.
|
||||
//!
|
||||
//! @return True if the returned values are actual calibrated values.
|
||||
//! False if the returned values are default (non-measureed) values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
am_hal_adc_temp_trims_get(float * pfTemp, float * pfVoltage, float * pfOffsetV)
|
||||
{
|
||||
//
|
||||
// Return trim temperature as a float, if you can.
|
||||
//
|
||||
if ( pfTemp != NULL )
|
||||
{
|
||||
*pfTemp = priv_temp_trims.flt.fCalibrationTemperature;
|
||||
}
|
||||
|
||||
//
|
||||
// Return trim voltage as a float, if you can.
|
||||
//
|
||||
if ( pfVoltage != NULL )
|
||||
{
|
||||
*pfVoltage = priv_temp_trims.flt.fCalibrationVoltage;
|
||||
}
|
||||
|
||||
//
|
||||
// Return trim ADC offset voltage as a float, if you can.
|
||||
//
|
||||
if ( pfOffsetV != NULL )
|
||||
{
|
||||
*pfOffsetV = priv_temp_trims.flt.fCalibrationOffset;
|
||||
}
|
||||
|
||||
return priv_temp_trims.ui32.bMeasured;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set the ADC window parameters.
|
||||
//!
|
||||
//! @param ui32Upper - the upper limit for the ADC window.
|
||||
//! @param ui32Upper - the lower limit for the ADC window.
|
||||
//!
|
||||
//! This function may be used to change the ADC window parameters. Please note
|
||||
//! that the upper and lower limits are only 16-bits wide in the ADC hardware.
|
||||
//! This function will ignore the upper 16 bits of these arguments.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_window_set(uint32_t ui32Upper, uint32_t ui32Lower)
|
||||
{
|
||||
//
|
||||
// Set the window limits for the ADC.
|
||||
//
|
||||
AM_BFW(ADC, WULIM, ULIM, ui32Upper);
|
||||
AM_BFW(ADC, WLLIM, LLIM, ui32Lower);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configure a single ADC slot.
|
||||
//!
|
||||
//! @param ui32SlotNumber - the number of the ADC slot to be configured.
|
||||
//! @param ui32SlotConfig - contains slot-specific options.
|
||||
//!
|
||||
//! This function may be used to configure the settings for an individual ADC
|
||||
//! slot. The parameter \b ui32SlotConfig should be the logical 'OR' of a slot
|
||||
//! average macro, a slot hold-time macro, a slot channel macro, and
|
||||
//! optionally, the slot window enable macro.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_slot_config(uint32_t ui32SlotNumber, uint32_t ui32SlotConfig)
|
||||
{
|
||||
uint32_t ui32RegOffset;
|
||||
|
||||
//
|
||||
// Make sure we're accessing a real slot.
|
||||
//
|
||||
am_hal_debug_assert_msg((ui32SlotNumber & 0xFFFFFFFF0) == 0,
|
||||
"Trying to configure an ADC slot that doesn't exist.");
|
||||
|
||||
//
|
||||
// Locate the correct register for this ADC slot.
|
||||
//
|
||||
ui32RegOffset = (AM_REG_ADCn(0) + AM_REG_ADC_SL0CFG_O + (4 * ui32SlotNumber));
|
||||
|
||||
//
|
||||
// Write the register with the caller's configuration value.
|
||||
//
|
||||
AM_REGVAL(ui32RegOffset) = ui32SlotConfig;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Peek at the next fifo entry.
|
||||
//!
|
||||
//! This function reads the oldest value in the ADC sample fifo but doesn't
|
||||
//! actually advance the fifo to the next entry. This function is useful when
|
||||
//! you need information from the fifo but you don't want to also empty the
|
||||
//! fifo. This could be helpful if you want to check the FIFO depth without
|
||||
//! pulling any data out.
|
||||
//!
|
||||
//! The value returned by this function is the raw 32-bit value provided by the
|
||||
//! ADC hardware. In order to interpret this value, you will need to use one of
|
||||
//! the following macros.
|
||||
//!
|
||||
//! @return 32-bit FIFO entry.
|
||||
//!
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_adc_fifo_peek(void)
|
||||
{
|
||||
uint32_t ui32FIFOValue;
|
||||
|
||||
//
|
||||
// Grab a value from the ADC FIFO.
|
||||
//
|
||||
ui32FIFOValue = AM_REG(ADC, FIFO);
|
||||
|
||||
//
|
||||
// Return FIFO entry.
|
||||
//
|
||||
return ui32FIFOValue;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief
|
||||
//!
|
||||
//! This function reads the oldest value in the ADC fifo and then pops the
|
||||
//! fifo. Use this function when you actually want to pull data out of the
|
||||
//! fifo.
|
||||
//!
|
||||
//! @return 32-bit FIFO entry.
|
||||
//!
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_adc_fifo_pop(void)
|
||||
{
|
||||
uint32_t ui32FIFOValue;
|
||||
|
||||
//
|
||||
// Grab a value from the ADC FIFO.
|
||||
//
|
||||
ui32FIFOValue = AM_REG(ADC, FIFO);
|
||||
|
||||
//
|
||||
// Pop the FIFO.
|
||||
//
|
||||
AM_REG(ADC, FIFO) = 0;
|
||||
|
||||
//
|
||||
// Return FIFO valid bits.
|
||||
//
|
||||
return ui32FIFOValue;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Issue Software Trigger to the ADC.
|
||||
//!
|
||||
//! This function issues the software trigger to the ADC.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_trigger(void)
|
||||
{
|
||||
//
|
||||
// Write to the Software trigger register in the ADC.
|
||||
//
|
||||
AM_REG(ADC, SWT) = 0x37;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the ADC.
|
||||
//!
|
||||
//! Use this function to enable the ADC.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_enable(void)
|
||||
{
|
||||
//
|
||||
// Enable the ADC.
|
||||
//
|
||||
AM_BFW(ADC, CFG, ADCEN, 0x1);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the ADC.
|
||||
//!
|
||||
//! Use this function to disable the ADC.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the ADC.
|
||||
//
|
||||
AM_BFW(ADC, CFG, ADCEN, 0x0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable selected ADC Interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_adc.h.
|
||||
//!
|
||||
//! Use this function to enable the ADC interrupts.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_int_enable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Enable the interrupts.
|
||||
//
|
||||
AM_REG(ADC, INTEN) |= ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return enabled ADC Interrupts.
|
||||
//!
|
||||
//! Use this function to get all enabled ADC interrupts.
|
||||
//!
|
||||
//! @return enabled ADC Interrupts.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_adc_int_enable_get(void)
|
||||
{
|
||||
//
|
||||
// Return enabled interrupts.
|
||||
//
|
||||
return AM_REG(ADC, INTEN);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable selected ADC Interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_adc.h.
|
||||
//!
|
||||
//! Use this function to disable the ADC interrupts.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_int_disable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Disable the interrupts.
|
||||
//
|
||||
AM_REG(ADC, INTEN) &= ~ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clear selected ADC Interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_adc.h.
|
||||
//!
|
||||
//! Use this function to clear the ADC interrupts.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_int_clear(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Clear the interrupts.
|
||||
//
|
||||
AM_REG(ADC, INTCLR) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set selected ADC Interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_adc.h.
|
||||
//!
|
||||
//! Use this function to set the ADC interrupts.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_adc_int_set(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Set the interrupts.
|
||||
//
|
||||
AM_REG(ADC, INTSET) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return either enabled or raw selected ADC interrupt status.
|
||||
//!
|
||||
//! @param bEnabledOnly - return the status of only the enabled interrupts.
|
||||
//!
|
||||
//! Use this function to get the ADC interrupt status.
|
||||
//!
|
||||
//! @return enabled or raw ADC interrupt status.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_adc_int_status_get(bool bEnabledOnly)
|
||||
{
|
||||
//
|
||||
// Return the status.
|
||||
//
|
||||
if (bEnabledOnly)
|
||||
{
|
||||
uint32_t u32RetVal = AM_REG(ADC, INTEN);
|
||||
u32RetVal &= AM_REG(ADC, INTSTAT);
|
||||
return u32RetVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AM_REG(ADC, INTSTAT);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return temperature in degrees C of supplied voltage.
|
||||
//!
|
||||
//! @param fVoltage - return the temperature corresponding to this voltage.
|
||||
//!
|
||||
//! Use this function to convert volts from the temperature sensor into degrees
|
||||
//! C. Caller converts ADC binary code to volts based on reference used.
|
||||
//! This routine looks up the trim parameters and returns corrected temperature.
|
||||
//!
|
||||
//! The computation is based on a line running through 0 degrees K.
|
||||
//! We find the slope from the trimmed temperature calibration point.
|
||||
//!
|
||||
//!
|
||||
//! @return the temperature in degrees C.
|
||||
//
|
||||
//*****************************************************************************
|
||||
float
|
||||
am_hal_adc_volts_to_celsius(float fVoltage)
|
||||
{
|
||||
float fTemp;
|
||||
|
||||
//
|
||||
// Get calibration temperature from trimmed values & convert to degrees K.
|
||||
//
|
||||
float fCalibration_temp = priv_temp_trims.flt.fCalibrationTemperature;
|
||||
|
||||
//
|
||||
// Get remaining trimmed values.
|
||||
//
|
||||
float fCalibration_voltage = priv_temp_trims.flt.fCalibrationVoltage;
|
||||
float fCalibration_offset = priv_temp_trims.flt.fCalibrationOffset;
|
||||
|
||||
//
|
||||
// Compute the temperature.
|
||||
//
|
||||
fTemp = fCalibration_temp;
|
||||
fTemp /= (fCalibration_voltage - fCalibration_offset);
|
||||
fTemp *= (fVoltage - fCalibration_offset);
|
||||
|
||||
//
|
||||
// Give it back to the caller in Celsius.
|
||||
//
|
||||
return fTemp - 273.15f;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,351 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_adc.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the Analog to Digital Converter
|
||||
//!
|
||||
//! @addtogroup adc2 Analog-to-Digital Converter (ADC)
|
||||
//! @ingroup apollo2hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_ADC_H
|
||||
#define AM_HAL_ADC_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Clock Selection
|
||||
//! @brief These macros may be used to set the ADC module's clock source.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_CLOCK_OFF AM_REG_ADC_CFG_CLKSEL_OFF
|
||||
#define AM_HAL_ADC_CLOCK_HFRC AM_REG_ADC_CFG_CLKSEL_HFRC
|
||||
#define AM_HAL_ADC_CLOCK_DIV2 AM_REG_ADC_CFG_CLKSEL_HFRC_DIV2
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Trigger Settings
|
||||
//! @brief ADC trigger setting macros.
|
||||
//!
|
||||
//! These macros alter the ADC's trigger source and trigger polarity. Note that
|
||||
//! the external trigger setting needs to be ORed with a POS or NEG option to
|
||||
//! define the desired trigger polarity.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_TRIGGER_SOFT AM_REG_ADC_CFG_TRIGSEL_SWT
|
||||
#define AM_HAL_ADC_TRIGGER_VCOMP AM_REG_ADC_CFG_TRIGSEL_VCOMP
|
||||
#define AM_HAL_ADC_TRIGGER_EXT0 AM_REG_ADC_CFG_TRIGSEL_EXT0
|
||||
#define AM_HAL_ADC_TRIGGER_EXT1 AM_REG_ADC_CFG_TRIGSEL_EXT1
|
||||
#define AM_HAL_ADC_TRIGGER_EXT2 AM_REG_ADC_CFG_TRIGSEL_EXT2
|
||||
#define AM_HAL_ADC_TRIGGER_EXT3 AM_REG_ADC_CFG_TRIGSEL_EXT3
|
||||
#define AM_HAL_ADC_TRIGGER_FALL AM_REG_ADC_CFG_TRIGPOL_FALLING_EDGE
|
||||
#define AM_HAL_ADC_TRIGGER_RISE AM_REG_ADC_CFG_TRIGPOL_RISING_EDGE
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Reference Settings
|
||||
//! @brief ADC reference voltage setting macros.
|
||||
//!
|
||||
//! These macros control the ADC reference voltage source.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_REF_EXT_2P0 AM_REG_ADC_CFG_REFSEL_EXT2P0
|
||||
#define AM_HAL_ADC_REF_EXT_1P5 AM_REG_ADC_CFG_REFSEL_EXT1P5
|
||||
#define AM_HAL_ADC_REF_INT_2P0 AM_REG_ADC_CFG_REFSEL_INT2P0
|
||||
#define AM_HAL_ADC_REF_INT_1P5 AM_REG_ADC_CFG_REFSEL_INT1P5
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Clock Mode
|
||||
//! @brief ADC clock mode settings
|
||||
//!
|
||||
//! These macros determine whether the ADC shuts down its clock between
|
||||
//! samples. Shutting down the clock will reduce power consumption, but
|
||||
//! increase latency. This setting is only valid for LPMODE 0. For other modes,
|
||||
//! it will be ignored.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_CK_LOW_POWER AM_REG_ADC_CFG_CKMODE_LPCKMODE
|
||||
#define AM_HAL_ADC_CK_LOW_LATENCY AM_REG_ADC_CFG_CKMODE_LLCKMODE
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Low Power Mode
|
||||
//! @brief ADC power conservation settings.
|
||||
//!
|
||||
//! These macros select the power state to enter between active scans. Each low
|
||||
//! power mode has its own set of timing constraints. Please see the datasheet
|
||||
//! for additional timing information on each power mode.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_LPMODE_0 AM_REG_ADC_CFG_LPMODE_MODE0
|
||||
#define AM_HAL_ADC_LPMODE_1 AM_REG_ADC_CFG_LPMODE_MODE1
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Repeat Mode
|
||||
//! @brief Enable repeating scan mode.
|
||||
//!
|
||||
//! Use this macro to enable repeating scans using timer 3.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_REPEAT AM_REG_ADC_CFG_RPTEN(1)
|
||||
#define AM_HAL_ADC_NO_REPEAT AM_REG_ADC_CFG_RPTEN(0)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Slot configuration
|
||||
//! @brief Slot configuration macros
|
||||
//!
|
||||
//! These macros may be used to configure an individual ADC slot.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
// Set number of samples to average.
|
||||
#define AM_HAL_ADC_SLOT_AVG_1 AM_REG_ADC_SL0CFG_ADSEL0(0)
|
||||
#define AM_HAL_ADC_SLOT_AVG_2 AM_REG_ADC_SL0CFG_ADSEL0(1)
|
||||
#define AM_HAL_ADC_SLOT_AVG_4 AM_REG_ADC_SL0CFG_ADSEL0(2)
|
||||
#define AM_HAL_ADC_SLOT_AVG_8 AM_REG_ADC_SL0CFG_ADSEL0(3)
|
||||
#define AM_HAL_ADC_SLOT_AVG_16 AM_REG_ADC_SL0CFG_ADSEL0(4)
|
||||
#define AM_HAL_ADC_SLOT_AVG_32 AM_REG_ADC_SL0CFG_ADSEL0(5)
|
||||
#define AM_HAL_ADC_SLOT_AVG_64 AM_REG_ADC_SL0CFG_ADSEL0(6)
|
||||
#define AM_HAL_ADC_SLOT_AVG_128 AM_REG_ADC_SL0CFG_ADSEL0(7)
|
||||
|
||||
// Set slot precision mode.
|
||||
#define AM_HAL_ADC_SLOT_14BIT AM_REG_ADC_SL0CFG_PRMODE0_P14B
|
||||
#define AM_HAL_ADC_SLOT_12BIT AM_REG_ADC_SL0CFG_PRMODE0_P12B
|
||||
#define AM_HAL_ADC_SLOT_10BIT AM_REG_ADC_SL0CFG_PRMODE0_P10B
|
||||
#define AM_HAL_ADC_SLOT_8BIT AM_REG_ADC_SL0CFG_PRMODE0_P8B
|
||||
|
||||
// Select a channel by number.
|
||||
#define AM_HAL_ADC_SLOT_CHANNEL(n) AM_REG_ADC_SL0CFG_CHSEL0(n)
|
||||
|
||||
// Single-ended channels
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_SE0 AM_REG_ADC_SL0CFG_CHSEL0_SE0
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_SE1 AM_REG_ADC_SL0CFG_CHSEL0_SE1
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_SE2 AM_REG_ADC_SL0CFG_CHSEL0_SE2
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_SE3 AM_REG_ADC_SL0CFG_CHSEL0_SE3
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_SE4 AM_REG_ADC_SL0CFG_CHSEL0_SE4
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_SE5 AM_REG_ADC_SL0CFG_CHSEL0_SE5
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_SE6 AM_REG_ADC_SL0CFG_CHSEL0_SE6
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_SE7 AM_REG_ADC_SL0CFG_CHSEL0_SE7
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_SE8 AM_REG_ADC_SL0CFG_CHSEL0_SE8
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_SE9 AM_REG_ADC_SL0CFG_CHSEL0_SE9
|
||||
|
||||
// Differential channels.
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_DF0 AM_REG_ADC_SL0CFG_CHSEL0_DF0
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_DF1 AM_REG_ADC_SL0CFG_CHSEL0_DF1
|
||||
|
||||
// Miscellaneous other signals.
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_TEMP AM_REG_ADC_SL0CFG_CHSEL0_TEMP
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_VSS AM_REG_ADC_SL0CFG_CHSEL0_VSS
|
||||
#define AM_HAL_ADC_SLOT_CHSEL_VBATT AM_REG_ADC_SL0CFG_CHSEL0_BATT
|
||||
|
||||
// Window enable.
|
||||
#define AM_HAL_ADC_SLOT_WINDOW_EN AM_REG_ADC_SL0CFG_WCEN0(1)
|
||||
|
||||
// Enable the slot.
|
||||
#define AM_HAL_ADC_SLOT_ENABLE AM_REG_ADC_SL0CFG_SLEN0(1)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Interrupt Status Bits
|
||||
//! @brief Interrupt Status Bits for enable/disble use
|
||||
//!
|
||||
//! These macros may be used to enable an individual ADC interrupt cause.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_INT_WCINC AM_REG_ADC_INTEN_WCINC(1)
|
||||
#define AM_HAL_ADC_INT_WCEXC AM_REG_ADC_INTEN_WCEXC(1)
|
||||
#define AM_HAL_ADC_INT_FIFOOVR2 AM_REG_ADC_INTEN_FIFOOVR2(1)
|
||||
#define AM_HAL_ADC_INT_FIFOOVR1 AM_REG_ADC_INTEN_FIFOOVR1(1)
|
||||
#define AM_HAL_ADC_INT_SCNCMP AM_REG_ADC_INTEN_SCNCMP(1)
|
||||
#define AM_HAL_ADC_INT_CNVCMP AM_REG_ADC_INTEN_CNVCMP(1)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Temperature Trim Value Locations
|
||||
//! @brief Temperature calibration cofficients are stored in readable space.
|
||||
//!
|
||||
//! These macros are used to access the temperature trim values in readable
|
||||
//! space.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_CALIB_TEMP_ADDR (0x50023010)
|
||||
#define AM_HAL_ADC_CALIB_AMBIENT_ADDR (0x50023014)
|
||||
#define AM_HAL_ADC_CALIB_ADC_OFFSET_ADDR (0x50023018)
|
||||
|
||||
//
|
||||
// Default coefficients (used when trims not provided):
|
||||
// TEMP_DEFAULT = Temperature in deg K (e.g. 299.5 - 273.15 = 26.35)
|
||||
// AMBIENT_DEFAULT = Voltage measurement at default temperature.
|
||||
// OFFSET_DEFAULT = Default ADC offset at 1v.
|
||||
//
|
||||
#define AM_HAL_ADC_CALIB_TEMP_DEFAULT (299.5F)
|
||||
#define AM_HAL_ADC_CALIB_AMBIENT_DEFAULT (1.02809F)
|
||||
#define AM_HAL_ADC_CALIB_ADC_OFFSET_DEFAULT (-0.004281F)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configuration structure for the ADC.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//! Select the ADC Clock source using one of the clock source macros.
|
||||
uint32_t ui32Clock;
|
||||
|
||||
//! Select the ADC trigger source using a trigger source macro.
|
||||
uint32_t ui32TriggerConfig;
|
||||
|
||||
//! Use a macro to select the ADC reference voltage.
|
||||
uint32_t ui32Reference;
|
||||
|
||||
//! Use a macro to decide whether to disable clocks between samples.
|
||||
uint32_t ui32ClockMode;
|
||||
|
||||
//! Use a macro to select the ADC power mode.
|
||||
uint32_t ui32PowerMode;
|
||||
|
||||
//! Select whether the ADC will re-trigger based on a signal from timer 3.
|
||||
uint32_t ui32Repeat;
|
||||
}
|
||||
am_hal_adc_config_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief ADC Fifo Read macros
|
||||
//!
|
||||
//! These are helper macros for interpreting FIFO data. Each ADC FIFO entry
|
||||
//! contains information about the slot number and the FIFO depth alongside the
|
||||
//! current sample. These macros perform the correct masking and shifting to
|
||||
//! read those values.
|
||||
//!
|
||||
//! The SAMPLE and FULL_SAMPLE options refer to the fractional part of averaged
|
||||
//! samples. If you are not using hardware averaging or don't need the
|
||||
//! fractional part of the ADC sample, you should just use
|
||||
//! AM_HAL_ADC_FIFO_SAMPLE.
|
||||
//!
|
||||
//! If you do need the fractional part, use AM_HAL_ADC_FIFO_FULL_SAMPLE. This
|
||||
//! macro will keep six bits of precision past the decimal point. Depending on
|
||||
//! the number of averaged samples, anywhere between 1 and 6 of these bits will
|
||||
//! be valid. Please consult the datasheet to find out how many bits of data
|
||||
//! are valid for your chosen averaging settings.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_ADC_FIFO_SAMPLE(value) \
|
||||
((((value) & AM_REG_ADC_FIFO_DATA_M) >> AM_REG_ADC_FIFO_DATA_S) >> 6)
|
||||
|
||||
#define AM_HAL_ADC_FIFO_FULL_SAMPLE(value) \
|
||||
(((value) & AM_REG_ADC_FIFO_DATA_M) >> AM_REG_ADC_FIFO_DATA_S )
|
||||
|
||||
#define AM_HAL_ADC_FIFO_SLOT(value) \
|
||||
(((value) & AM_REG_ADC_FIFO_SLOTNUM_M) >> AM_REG_ADC_FIFO_SLOTNUM_S)
|
||||
|
||||
#define AM_HAL_ADC_FIFO_COUNT(value) \
|
||||
(((value) & AM_REG_ADC_FIFO_COUNT_M) >> AM_REG_ADC_FIFO_COUNT_S)
|
||||
//! @}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_adc_config(am_hal_adc_config_t *psConfig);
|
||||
extern void am_hal_adc_window_set(uint32_t ui32Upper, uint32_t ui32Lower);
|
||||
extern void am_hal_adc_slot_config(uint32_t ui32SlotNumber,
|
||||
uint32_t ui32SlotConfig);
|
||||
|
||||
extern uint32_t am_hal_adc_fifo_peek(void);
|
||||
extern uint32_t am_hal_adc_fifo_pop(void);
|
||||
|
||||
extern void am_hal_adc_trigger(void);
|
||||
extern void am_hal_adc_enable(void);
|
||||
extern void am_hal_adc_disable(void);
|
||||
extern void am_hal_adc_int_enable(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_adc_int_enable_get(void);
|
||||
extern void am_hal_adc_int_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_adc_int_clear(uint32_t ui32Interrupt);
|
||||
extern void am_hal_adc_int_set(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_adc_int_status_get(bool bEnabledOnly);
|
||||
extern float am_hal_adc_volts_to_celsius(float fVoltage);
|
||||
extern bool am_hal_adc_temp_trims_get(float * pfTemp, float * pfVoltage, float * pfOffsetV);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_ADC_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,579 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_cachectrl.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the CACHE controller.
|
||||
//!
|
||||
//! @addtogroup clkgen2 Clock Generator (CACHE)
|
||||
//! @ingroup apollo2hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Default settings for the cache.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const am_hal_cachectrl_config_t am_hal_cachectrl_defaults =
|
||||
{
|
||||
.ui32EnableCache = 1,
|
||||
.ui32LRU = 0,
|
||||
.ui32EnableNCregions = 0,
|
||||
.ui32Config = AM_HAL_CACHECTRL_CACHECFG_CONFIG_2WAY_512,
|
||||
.ui32SerialCacheMode = 0,
|
||||
.ui32FlashCachingEnables = 3,
|
||||
.ui32EnableCacheClockGating = 1,
|
||||
.ui32EnableLightSleep = 0,
|
||||
.ui32Dly = 1,
|
||||
.ui32SMDly = 1,
|
||||
.ui32EnableDataClockGating = 1,
|
||||
.ui32EnableCacheMonitoring = 0,
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the cache using the supplied settings
|
||||
//!
|
||||
//! @param psConfig - pointer to a config structure containing cache settings.
|
||||
//!
|
||||
//! This function takes in a structure of cache settings, and uses them to
|
||||
//! enable the cache. This function will take care of the necessary register
|
||||
//! writes both in this module and in the power control module, so a separate
|
||||
//! powerctrl call is not necessary.
|
||||
//!
|
||||
//! For most applications, the default cache settings will be the most
|
||||
//! efficient choice. To use the default cache settings with this function, use
|
||||
//! the address of the global am_hal_cachectrl_defaults structure as the
|
||||
//! psConfig argument.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_cachectrl_enable(const am_hal_cachectrl_config_t *psConfig)
|
||||
{
|
||||
uint32_t ui32ConfigValue;
|
||||
uint32_t ui32Timeout;
|
||||
|
||||
//
|
||||
// Pull the configuration data from the structure, and prepare to write the
|
||||
// cache configuration register.
|
||||
//
|
||||
// NOTE: ICACHE and DCACHE settings were left out from this step. This is a
|
||||
// workaround for a timing issue with early versions of Apollo2 that caused
|
||||
// the cache to incorrectly mark itself valid during the startup sequence.
|
||||
// The workaround calls for us to start the cache, manually invalidate it,
|
||||
// and then enable ICACHE and DCACHE operation.
|
||||
//
|
||||
ui32ConfigValue = (AM_REG_CACHECTRL_CACHECFG_ENABLE( 1 ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_LRU( psConfig->ui32LRU ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_NC0( (psConfig->ui32EnableNCregions & 0x1) >> 0 ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_NC1( (psConfig->ui32EnableNCregions & 0x2) >> 1 ) |
|
||||
psConfig->ui32Config |
|
||||
AM_REG_CACHECTRL_CACHECFG_SERIAL(psConfig->ui32SerialCacheMode) |
|
||||
AM_REG_CACHECTRL_CACHECFG_CACHE_CLKGATE( psConfig->ui32EnableCacheClockGating ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_CACHE_LS(psConfig->ui32EnableLightSleep ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_DLY( psConfig->ui32Dly ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_SMDLY( psConfig->ui32SMDly ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_DATA_CLKGATE(psConfig->ui32EnableDataClockGating) |
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_MONITOR(psConfig->ui32EnableCacheMonitoring) );
|
||||
|
||||
//
|
||||
// Make sure the cache is enabled in the power control block.
|
||||
//
|
||||
am_hal_pwrctrl_memory_enable(AM_HAL_PWRCTRL_MEMEN_CACHE);
|
||||
|
||||
//
|
||||
// Set the initial cache settings.
|
||||
//
|
||||
AM_REG(CACHECTRL, CACHECFG) = ui32ConfigValue;
|
||||
|
||||
//
|
||||
// Wait for the cache ready signal.
|
||||
//
|
||||
for (ui32Timeout = 0; ui32Timeout < 50; ui32Timeout++)
|
||||
{
|
||||
if (AM_BFM(CACHECTRL, CTRL, CACHE_READY))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Manually invalidate the cache (workaround for the issue described above.)
|
||||
//
|
||||
AM_BFW(CACHECTRL, CTRL, INVALIDATE, 1);
|
||||
|
||||
//
|
||||
// Wait for the cache ready signal again.
|
||||
//
|
||||
for (ui32Timeout = 0; ui32Timeout < 50; ui32Timeout++)
|
||||
{
|
||||
if (AM_BFM(CACHECTRL, CTRL, CACHE_READY))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Now that the cache is running, and correctly marked invalid, we can OR in
|
||||
// the ICACHE and DCACHE settings.
|
||||
//
|
||||
ui32ConfigValue |= (AM_REG_CACHECTRL_CACHECFG_ICACHE_ENABLE( (psConfig->ui32FlashCachingEnables & 0x1) >> 0 ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_DCACHE_ENABLE( (psConfig->ui32FlashCachingEnables & 0x2) >> 1 ) );
|
||||
|
||||
//
|
||||
// Write the final configuration settings to the CACHECTRL register.
|
||||
//
|
||||
AM_REG(CACHECTRL, CACHECFG) = ui32ConfigValue;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable the cache.
|
||||
//!
|
||||
//! Call this function to completely shut down cache features.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_cachectrl_disable(void)
|
||||
{
|
||||
uint32_t ui32CacheCfg;
|
||||
|
||||
//
|
||||
// Save the cache settings.
|
||||
//
|
||||
ui32CacheCfg = AM_REG(CACHECTRL, CACHECFG);
|
||||
|
||||
//
|
||||
// Remove the ICACHE and DCACHE settings.
|
||||
//
|
||||
ui32CacheCfg &= (AM_REG_CACHECTRL_CACHECFG_DCACHE_ENABLE(0) |
|
||||
AM_REG_CACHECTRL_CACHECFG_ICACHE_ENABLE(0));
|
||||
|
||||
//
|
||||
// Write the resulting value back to the register.
|
||||
//
|
||||
AM_REG(CACHECTRL, CACHECFG) = ui32CacheCfg;
|
||||
|
||||
//
|
||||
// Read the CACHECTRL register a few times
|
||||
//
|
||||
AM_REG(CACHECTRL, CTRL);
|
||||
AM_REG(CACHECTRL, CTRL);
|
||||
AM_REG(CACHECTRL, CTRL);
|
||||
|
||||
//
|
||||
// Disable the cache completely.
|
||||
//
|
||||
AM_BFW(CACHECTRL, CACHECFG, ENABLE, 0);
|
||||
|
||||
//
|
||||
// Power the cache down in the powerctrl block.
|
||||
//
|
||||
am_hal_pwrctrl_memory_enable(AM_HAL_PWRCTRL_MEMEN_CACHE_DIS);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Set a default cache configuration.
|
||||
//!
|
||||
//! This function is used to set a default cache configuration.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_cachectrl_config_default(void)
|
||||
{
|
||||
//
|
||||
// Set PWRCTRL
|
||||
//
|
||||
am_hal_pwrctrl_memory_enable(AM_HAL_PWRCTRL_MEMEN_CACHE);
|
||||
|
||||
//
|
||||
// Write a default configuration to the CACHECFG register.
|
||||
//
|
||||
AM_REG(CACHECTRL, CACHECFG) = \
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE( 1 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_LRU( 0 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_NC0( 0 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_NC1( 0 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_CONFIG_W2_128B_512E | \
|
||||
AM_REG_CACHECTRL_CACHECFG_SERIAL( 0 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_ICACHE_ENABLE( 1 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_DCACHE_ENABLE( 1 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_CACHE_CLKGATE( 1 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_CACHE_LS( 0 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_DLY( 1 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_SMDLY( 1 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_DATA_CLKGATE( 1 ) | \
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_MONITOR( 0 );
|
||||
|
||||
//
|
||||
// Write a default configuration to the FLASHCFG register.
|
||||
//
|
||||
AM_REG(CACHECTRL, FLASHCFG) = AM_REG_CACHECTRL_FLASHCFG_RD_WAIT(1);
|
||||
|
||||
//
|
||||
// Write a default configuration to the CACHECTRL register.
|
||||
//
|
||||
AM_REG(CACHECTRL, CTRL) = \
|
||||
AM_REG_CACHECTRL_CTRL_FLASH1_SLM_ENABLE(1) | \
|
||||
AM_REG_CACHECTRL_CTRL_FLASH1_SLM_DISABLE(0) | \
|
||||
AM_REG_CACHECTRL_CTRL_FLASH0_SLM_ENABLE(1) | \
|
||||
AM_REG_CACHECTRL_CTRL_FLASH0_SLM_DISABLE(0) | \
|
||||
AM_REG_CACHECTRL_CTRL_RESET_STAT(0) | \
|
||||
AM_REG_CACHECTRL_CTRL_INVALIDATE(0);
|
||||
|
||||
//
|
||||
// Write a default configuration to the NCR0START and NCR0END registers.
|
||||
//
|
||||
AM_REG(CACHECTRL, NCR0START) = \
|
||||
AM_REG_CACHECTRL_NCR0START_ADDR(0);
|
||||
AM_REG(CACHECTRL, NCR0END) = \
|
||||
AM_REG_CACHECTRL_NCR0END_ADDR(0);
|
||||
|
||||
//
|
||||
// Write a default configuration to the NCR1START and NCR1END registers.
|
||||
//
|
||||
AM_REG(CACHECTRL, NCR1START) = \
|
||||
AM_REG_CACHECTRL_NCR1START_ADDR(0);
|
||||
AM_REG(CACHECTRL, NCR1END) = \
|
||||
AM_REG_CACHECTRL_NCR1END_ADDR(0);
|
||||
|
||||
//
|
||||
// Write a default configuration to the DMONn and IMONn registers.
|
||||
//
|
||||
AM_REG(CACHECTRL, DMON0) = \
|
||||
AM_REG_CACHECTRL_DMON0_DACCESS_COUNT(0);
|
||||
AM_REG(CACHECTRL, DMON1) = \
|
||||
AM_REG_CACHECTRL_DMON1_DLOOKUP_COUNT(0);
|
||||
AM_REG(CACHECTRL, DMON2) = \
|
||||
AM_REG_CACHECTRL_DMON2_DHIT_COUNT(0);
|
||||
AM_REG(CACHECTRL, DMON3) = \
|
||||
AM_REG_CACHECTRL_DMON3_DLINE_COUNT(0);
|
||||
AM_REG(CACHECTRL, IMON0) = \
|
||||
AM_REG_CACHECTRL_IMON0_IACCESS_COUNT(0);
|
||||
AM_REG(CACHECTRL, IMON1) = \
|
||||
AM_REG_CACHECTRL_IMON1_ILOOKUP_COUNT(0);
|
||||
AM_REG(CACHECTRL, IMON2) = \
|
||||
AM_REG_CACHECTRL_IMON2_IHIT_COUNT(0);
|
||||
AM_REG(CACHECTRL, IMON3) = \
|
||||
AM_REG_CACHECTRL_IMON3_ILINE_COUNT(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable the flash cache controller via a configuration structure.
|
||||
//!
|
||||
//! @param psConfig - Pointer to a data structure containing all of the data
|
||||
// necessary to configure the CACHECFG register.
|
||||
//!
|
||||
//! This function is used to configure all fields of the CACHECFG.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_cachectrl_config(am_hal_cachectrl_config_t *psConfig)
|
||||
{
|
||||
uint32_t u32ConfigValue;
|
||||
|
||||
//
|
||||
// Arrange all of the members of the data structure into a single u32 that
|
||||
// can be written to the register.
|
||||
//
|
||||
u32ConfigValue =
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE( psConfig->ui32EnableCache ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_LRU( psConfig->ui32LRU ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_NC0(
|
||||
(psConfig->ui32EnableNCregions & 0x1) >> 0 ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_NC1(
|
||||
(psConfig->ui32EnableNCregions & 0x2) >> 1 ) |
|
||||
psConfig->ui32Config |
|
||||
AM_REG_CACHECTRL_CACHECFG_SERIAL(psConfig->ui32SerialCacheMode) |
|
||||
AM_REG_CACHECTRL_CACHECFG_ICACHE_ENABLE(
|
||||
(psConfig->ui32FlashCachingEnables & 0x1) >> 0 ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_DCACHE_ENABLE(
|
||||
(psConfig->ui32FlashCachingEnables & 0x2) >> 1 ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_CACHE_CLKGATE(
|
||||
psConfig->ui32EnableCacheClockGating ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_CACHE_LS(
|
||||
psConfig->ui32EnableLightSleep ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_DLY( psConfig->ui32Dly ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_SMDLY( psConfig->ui32SMDly ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_DATA_CLKGATE(
|
||||
psConfig->ui32EnableDataClockGating ) |
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_MONITOR(
|
||||
psConfig->ui32EnableCacheMonitoring );
|
||||
|
||||
//
|
||||
// Write the configuration value to the CACHECFG register.
|
||||
//
|
||||
AM_REG(CACHECTRL, CACHECFG) = u32ConfigValue;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Configure the various flash cache controller enables.
|
||||
//!
|
||||
//! @param u32EnableMask - Mask of features to be enabled.
|
||||
//! @param u32DisableMask - Mask of features to be disabled.
|
||||
//!
|
||||
//! This function is used to enable or disable the various flash cache
|
||||
//! controller configuration enables which consist of the following:
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_ENABLE Flash cache controller
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_LRU_ENABLE LRU (disabled = LRR)
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_NC0_ENABLE Non-cacheable region 0
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_NC1_ENABLE Non-cacheable region 1
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_SERIAL_ENABLE Serial cache mode
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_ICACHE_ENABLE Instruction caching
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_DCACHE_ENABLE Data caching.
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_CACHE_CLKGATE_ENABLE Cache clock gating
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_LS_ENABLE Light sleep cache RAMs
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_DATA_CLKGATE_ENABLE Data clock gating
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_MONITOR_ENABLE Cache Monitoring Stats
|
||||
//!
|
||||
//! Note that if both an enable and disable are provided in their respective
|
||||
//! masks, the enable will take precendence.
|
||||
//!
|
||||
//! @return The previous status of the flash cache controller enables.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define CACHECTRL_VALID_ENABLES ( \
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_M | \
|
||||
AM_REG_CACHECTRL_CACHECFG_LRU_M | \
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_NC0_M | \
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_NC1_M | \
|
||||
AM_REG_CACHECTRL_CACHECFG_SERIAL_M | \
|
||||
AM_REG_CACHECTRL_CACHECFG_ICACHE_ENABLE_M | \
|
||||
AM_REG_CACHECTRL_CACHECFG_DCACHE_ENABLE_M | \
|
||||
AM_REG_CACHECTRL_CACHECFG_CACHE_CLKGATE_M | \
|
||||
AM_REG_CACHECTRL_CACHECFG_CACHE_LS_M | \
|
||||
AM_REG_CACHECTRL_CACHECFG_DATA_CLKGATE_M | \
|
||||
AM_REG_CACHECTRL_CACHECFG_ENABLE_MONITOR_M )
|
||||
|
||||
uint32_t
|
||||
am_hal_cachectrl_cache_enables(uint32_t u32EnableMask, uint32_t u32DisableMask)
|
||||
{
|
||||
uint32_t ui32RetVal = AM_BFR(CACHECTRL, CACHECFG, ENABLE) &
|
||||
CACHECTRL_VALID_ENABLES;
|
||||
|
||||
//
|
||||
// Make sure the enable masks include only valid bits.
|
||||
//
|
||||
u32EnableMask &= CACHECTRL_VALID_ENABLES;
|
||||
u32DisableMask &= CACHECTRL_VALID_ENABLES;
|
||||
|
||||
//
|
||||
// First, do the disables.
|
||||
//
|
||||
AM_REG(CACHECTRL, CACHECFG) &= ~u32DisableMask;
|
||||
|
||||
//
|
||||
// Now set the enables.
|
||||
//
|
||||
AM_REG(CACHECTRL, CACHECFG) |= u32EnableMask;
|
||||
|
||||
return ui32RetVal;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Select the cache configuration type.
|
||||
//!
|
||||
//! This functions only sets the CACHECFG CONFIG field.
|
||||
//!
|
||||
//! @param ui32CacheConfig - The cache configuration value.
|
||||
//!
|
||||
//! This function can be used to select the type of cache.frequency of the main
|
||||
//! system clock. The ui32CacheConfig parameter should be set to one of the
|
||||
//! following values:
|
||||
//!
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_CONFIG_DIRECT_256 : Direct mapped,
|
||||
//! 128-bit linesize, 256 entries (2 SRAMs active).
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_CONFIG_2WAY_256 : Two-way set associative,
|
||||
//! 128-bit linesize, 256 entries (4 SRAMs active).
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_CONFIG_2WAY_512 : Two-way set associative,
|
||||
//! 128-bit linesize, 512 entries (8 SRAMs active).
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_cachectrl_cache_config(uint32_t ui32CacheConfig)
|
||||
{
|
||||
//
|
||||
// Clear the bitfield
|
||||
//
|
||||
AM_REG(CACHECTRL, CACHECFG) &= ~AM_REG_CACHECTRL_CACHECFG_CONFIG_M;
|
||||
|
||||
//
|
||||
// Write the new value to the bitfield.
|
||||
//
|
||||
AM_REG(CACHECTRL, CACHECFG) |= ui32CacheConfig &
|
||||
AM_REG_CACHECTRL_CACHECFG_CONFIG_M;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Invalidate the flash cache.
|
||||
//!
|
||||
//! This function is used to invalidate the flash cache.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_cachectrl_invalidate_flash_cache(void)
|
||||
{
|
||||
//
|
||||
// Write the bit to invalidate the flash cache.
|
||||
// Note - this bit is not sticky, no need to write it back to 0.
|
||||
//
|
||||
AM_REG(CACHECTRL, CTRL) |= AM_REG_CACHECTRL_CTRL_INVALIDATE_GO;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Reset cache statistics.
|
||||
//!
|
||||
//! This function is used to reset cache statistics.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_cachectrl_reset_statistics(void)
|
||||
{
|
||||
//
|
||||
// Write the bit to reset flash statistics.
|
||||
// Note - this bit is not sticky, no need to write it back to 0.
|
||||
//
|
||||
AM_REG(CACHECTRL, CTRL) |= AM_REG_CACHECTRL_CTRL_RESET_STAT_CLEAR;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get flash cache sleep mode status.
|
||||
//!
|
||||
//! This function returns flash cache sleep mode statuses.
|
||||
//!
|
||||
//! @return
|
||||
//! bit0 indicates that flash0 flash sleep mode is enabled.
|
||||
//! bit1 indicates that flash1 flash sleep mode is enabled.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_cachectrl_sleep_mode_status(void)
|
||||
{
|
||||
uint32_t ui32Status, ui32Ret;
|
||||
|
||||
//
|
||||
// Get the current sleep mode status bits.
|
||||
//
|
||||
ui32Status = AM_REG(CACHECTRL, CTRL);
|
||||
ui32Ret = (ui32Status & \
|
||||
AM_REG_CACHECTRL_CTRL_FLASH0_SLM_STATUS_M) >> \
|
||||
(AM_REG_CACHECTRL_CTRL_FLASH0_SLM_STATUS_S - 0);
|
||||
ui32Ret |= (ui32Status & \
|
||||
AM_REG_CACHECTRL_CTRL_FLASH1_SLM_STATUS_M) >> \
|
||||
(AM_REG_CACHECTRL_CTRL_FLASH1_SLM_STATUS_S - 1);
|
||||
|
||||
return ui32Ret;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable or disable flash cache sleep mode.
|
||||
//!
|
||||
//! This function enables or disables flash cache sleep mode.
|
||||
//! @param ui32EnableMask - bit0 for flash0, bit1 for flash1.
|
||||
//! @param ui32DisableMask - bit0 for flash0, bit1 for flash1.
|
||||
//!
|
||||
//! Note that if both an enable and disable are provided in their respective
|
||||
//! masks, the enable will take precedence.
|
||||
//!
|
||||
//! @return Previous status.
|
||||
//! bit0 indicates that flash0 flash sleep mode was previously enabled.
|
||||
//! bit1 indicates that flash1 flash sleep mode was previously enabled.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_cachectrl_sleep_mode_enable(uint32_t ui32EnableMask,
|
||||
uint32_t ui32DisableMask)
|
||||
{
|
||||
uint32_t ui32Ret = am_hal_cachectrl_sleep_mode_status();
|
||||
|
||||
if ( ui32DisableMask & 0x1 )
|
||||
{
|
||||
AM_REG(CACHECTRL, CTRL) |= AM_REG_CACHECTRL_CTRL_FLASH0_SLM_DISABLE_M;
|
||||
}
|
||||
|
||||
if ( ui32DisableMask & 0x2 )
|
||||
{
|
||||
AM_REG(CACHECTRL, CTRL) |= AM_REG_CACHECTRL_CTRL_FLASH1_SLM_DISABLE_M;
|
||||
}
|
||||
|
||||
if ( ui32EnableMask & 0x1 )
|
||||
{
|
||||
AM_REG(CACHECTRL, CTRL) |= AM_REG_CACHECTRL_CTRL_FLASH0_SLM_ENABLE_M;
|
||||
}
|
||||
|
||||
if ( ui32EnableMask & 0x2 )
|
||||
{
|
||||
AM_REG(CACHECTRL, CTRL) |= AM_REG_CACHECTRL_CTRL_FLASH1_SLM_ENABLE_M;
|
||||
}
|
||||
|
||||
return ui32Ret;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,214 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_cachectrl.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the CACHE controller.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_CACHECTRL_H
|
||||
#define AM_HAL_CACHECTRL_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Cache configuration structure
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! Set to 1 to enable the cache.
|
||||
//
|
||||
uint8_t ui32EnableCache;
|
||||
|
||||
//
|
||||
//! Set to 1 to enable the LRU cache replacement policy.
|
||||
//! Set to 0 to enable the LRR (least recently used) replacement policy.
|
||||
//! LEE minimizes writes to the TAG SRAM.
|
||||
//
|
||||
uint8_t ui32LRU;
|
||||
|
||||
//
|
||||
//! Set to 3 to enable non-cachable region 1 and non-cachable region 0.
|
||||
//! Set to 2 to enable non-cachable region 1.
|
||||
//! Set to 1 to enable non-cachable region 0.
|
||||
//! Set to 0 to make all regions cacheable.
|
||||
//
|
||||
uint8_t ui32EnableNCregions;
|
||||
|
||||
//
|
||||
//! Set to:
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_CONFIG_DIRECT_256 for direct-mapped,
|
||||
//! 128-bit linesize, 256 entries (2 SRAMs active)
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_CONFIG_2WAY_256 for two-way set associative,
|
||||
//! 128-bit linesize, 256 entries (4 SRAMs active)
|
||||
//! AM_HAL_CACHECTRL_CACHECFG_CONFIG_2WAY_512 for two-way set associative,
|
||||
//! 128-bit linesize, 512 entries (8 SRAMs active)
|
||||
//
|
||||
uint8_t ui32Config;
|
||||
|
||||
//
|
||||
//! Set to 1 to enable serial cache mode.
|
||||
//
|
||||
uint8_t ui32SerialCacheMode;
|
||||
|
||||
//
|
||||
//! Set to 3 to enable flash data caching and flash instruction caching.
|
||||
//! Set to 2 to enable flash data caching.
|
||||
//! Set to 1 to enable flash instruction caching.
|
||||
//! Set to 0 to disable flash data caching and flash instruction caching.
|
||||
//
|
||||
uint8_t ui32FlashCachingEnables;
|
||||
|
||||
//
|
||||
//! Set to 1 to enable clock gating of cache RAMs.
|
||||
//
|
||||
uint8_t ui32EnableCacheClockGating;
|
||||
|
||||
//
|
||||
//! Set to 1 to enable light sleep of cache RAMs.
|
||||
//
|
||||
uint8_t ui32EnableLightSleep;
|
||||
|
||||
//
|
||||
//! Set Data RAM delay value (0x0 - 0xF).
|
||||
//
|
||||
uint8_t ui32Dly;
|
||||
|
||||
//
|
||||
//! Set SM Data RAM delay value (0x0 - 0xF).
|
||||
//
|
||||
uint8_t ui32SMDly;
|
||||
|
||||
//
|
||||
//! Set to 1 to enable clock gating of the entire data array.
|
||||
//
|
||||
uint8_t ui32EnableDataClockGating;
|
||||
|
||||
//
|
||||
//! Set to 1 to enable cache monitor statistics.
|
||||
//
|
||||
uint8_t ui32EnableCacheMonitoring;
|
||||
}
|
||||
am_hal_cachectrl_config_t;
|
||||
|
||||
extern const am_hal_cachectrl_config_t am_hal_cachectrl_defaults;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Cache enables
|
||||
//! @brief Configuration selection for the various cache enables.
|
||||
//!
|
||||
//! These macros may be used in conjunction with the
|
||||
//! am_hal_cachectrl_cache_enable() function to enable various cache features.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_ENABLE AM_REG_CACHECTRL_CACHECFG_ENABLE_M
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_LRU_ENABLE AM_REG_CACHECTRL_CACHECFG_LRU_M
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_NC0_ENABLE AM_REG_CACHECTRL_CACHECFG_ENABLE_NC0_M
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_NC1_ENABLE AM_REG_CACHECTRL_CACHECFG_ENABLE_NC1_M
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_SERIAL_ENABLE AM_REG_CACHECTRL_CACHECFG_SERIAL_M
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_ICACHE_ENABLE AM_REG_CACHECTRL_CACHECFG_ICACHE_ENABLE_M
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_DCACHE_ENABLE AM_REG_CACHECTRL_CACHECFG_DCACHE_ENABLE_M
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_CACHE_CLKGATE_ENABLE AM_REG_CACHECTRL_CACHECFG_CACHE_CLKGATE_M
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_LS_ENABLE AM_REG_CACHECTRL_CACHECFG_CACHE_LS_M
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_DATA_CLKGATE_ENABLE AM_REG_CACHECTRL_CACHECFG_DATA_CLKGATE_M
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_MONITOR_ENABLE AM_REG_CACHECTRL_CACHECFG_ENABLE_MONITOR_M
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Cache Config
|
||||
//! @brief Configuration selection for the cache.
|
||||
//!
|
||||
//! These macros may be used in conjunction with the
|
||||
//! am_hal_cachectrl_cache_config() function to select the cache type.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_CONFIG_DIRECT_256 AM_REG_CACHECTRL_CACHECFG_CONFIG_W1_128B_256E
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_CONFIG_2WAY_256 AM_REG_CACHECTRL_CACHECFG_CONFIG_W2_128B_256E
|
||||
#define AM_HAL_CACHECTRL_CACHECFG_CONFIG_2WAY_512 AM_REG_CACHECTRL_CACHECFG_CONFIG_W2_128B_512E
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Default cache settings
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CACHECTRL_DEFAULTS \
|
||||
(AM_HAL_CACHECTRL_CACHECFG_ICACHE_ENABLE | \
|
||||
AM_HAL_CACHECTRL_CACHECFG_DCACHE_ENABLE | \
|
||||
AM_HAL_CACHECTRL_CACHECFG_CACHE_CLKGATE_ENABLE | \
|
||||
AM_HAL_CACHECTRL_CACHECFG_DATA_CLKGATE_ENABLE | \
|
||||
AM_HAL_CACHECTRL_CACHECFG_CONFIG_2WAY_512)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_cachectrl_enable(const am_hal_cachectrl_config_t *psConfig);
|
||||
extern void am_hal_cachectrl_disable(void);
|
||||
extern void am_hal_cachectrl_config_default(void);
|
||||
extern void am_hal_cachectrl_config(am_hal_cachectrl_config_t *psConfig);
|
||||
extern uint32_t am_hal_cachectrl_cache_enables(uint32_t u32EnableMask,
|
||||
uint32_t u32DisableMask);
|
||||
extern void am_hal_cachectrl_cache_config(uint32_t ui32CacheConfig);
|
||||
extern void am_hal_cachectrl_invalidate_flash_cache(void);
|
||||
extern void am_hal_cachectrl_reset_statistics(void);
|
||||
extern uint32_t am_hal_cachectrl_sleep_mode_status(void);
|
||||
extern uint32_t am_hal_cachectrl_sleep_mode_enable(uint32_t ui32EnableMask,
|
||||
uint32_t ui32DisableMask);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_CACHECTRL_H
|
||||
@@ -0,0 +1,506 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_clkgen.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for interfacing with the CLKGEN.
|
||||
//!
|
||||
//! @addtogroup clkgen2 Clock Generator (CLKGEN)
|
||||
//! @ingroup apollo2hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CLKGEN HFADJ register
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_REG_CLKGEN_HFADJ_HFXTADJ_DEFAULT 0x5B8
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Select the clock divisor for the main system clock.
|
||||
//!
|
||||
//! @param ui32ClockSetting - The divisor value for the system clock.
|
||||
//!
|
||||
//! This function can be used to select the frequency of the main system clock.
|
||||
//! The \e ui32ClockSetting parameter should be set to one of the following
|
||||
//! values:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_SYSCLK_MAX
|
||||
//! AM_HAL_CLKGEN_SYSCLK_48MHZ
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_sysclk_select(uint32_t ui32ClockSetting)
|
||||
{
|
||||
am_hal_debug_assert_msg(ui32ClockSetting == AM_HAL_CLKGEN_SYSCLK_48MHZ,
|
||||
"am_hal_clkgen_sysclk_select(): invalid clock setting.");
|
||||
|
||||
//
|
||||
// Unlock the clock control register.
|
||||
//
|
||||
AM_REG(CLKGEN, CLKKEY) = AM_REG_CLKGEN_CLKKEY_KEYVAL;
|
||||
|
||||
//
|
||||
// Set the HFRC divisor to the required operating value.
|
||||
//
|
||||
AM_REG(CLKGEN, CCTRL) = ui32ClockSetting;
|
||||
|
||||
//
|
||||
// Lock the clock configuration registers.
|
||||
//
|
||||
AM_REG(CLKGEN, CLKKEY) = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Get the current system clock frequency.
|
||||
//!
|
||||
//! This function can be used to determine the frequency of the main system
|
||||
//! clock. The return value is the system clock frequency measured in hertz.
|
||||
//!
|
||||
//! @return System clock frequency in Hz
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_clkgen_sysclk_get(void)
|
||||
{
|
||||
uint32_t ui32ClockSetting;
|
||||
uint32_t ui32ClockFreq;
|
||||
|
||||
//
|
||||
// Read the value of the clock divider.
|
||||
//
|
||||
ui32ClockSetting = AM_REG(CLKGEN, CCTRL) & AM_REG_CLKGEN_CCTRL_CORESEL_M;
|
||||
|
||||
switch ( ui32ClockSetting )
|
||||
{
|
||||
case AM_REG_CLKGEN_CCTRL_CORESEL_HFRC:
|
||||
ui32ClockFreq = 48000000;
|
||||
break;
|
||||
|
||||
case AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV2:
|
||||
ui32ClockFreq = 24000000;
|
||||
break;
|
||||
}
|
||||
|
||||
return ui32ClockFreq;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable selected CLKGEN Interrupts.
|
||||
//!
|
||||
//! Use this function to enable the interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_clkgen.h
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_int_enable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Enable the interrupts.
|
||||
//
|
||||
AM_REG(CLKGEN, INTEN) |= ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Return enabled CLKGEN Interrupts.
|
||||
//!
|
||||
//! Use this function to get all enabled CLKGEN interrupts.
|
||||
//!
|
||||
//! @return enabled CLKGEN interrupts.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_clkgen_int_enable_get(void)
|
||||
{
|
||||
//
|
||||
// Return the enabled interrupts.
|
||||
//
|
||||
return AM_REG(CLKGEN, INTEN);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disable selected CLKGEN Interrupts.
|
||||
//!
|
||||
//! Use this function to disable the CLKGEN interrupts.
|
||||
//!
|
||||
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_clkgen.h
|
||||
//!
|
||||
//! @return None
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_int_disable(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Disable the interrupts.
|
||||
//
|
||||
AM_REG(CLKGEN, INTEN) &= ~ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Sets the interrupt status.
|
||||
//!
|
||||
//! @param ui32IntFlags interrupts to be enabled.
|
||||
//!
|
||||
//! This function sets the interrupts.
|
||||
//!
|
||||
//! Valid values for ui32IntFlags are:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_INT_RTC_ALARM
|
||||
//! AM_HAL_CLKGEN_INT_XT_FAIL
|
||||
//! AM_HAL_CLKGEN_INT_AUTOCAL_COMPLETE
|
||||
//! AM_HAL_CLKGEN_INT AUTOCAL_FAIL
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_int_set(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Set the interrupt status.
|
||||
//
|
||||
AM_REG(CLKGEN, INTSET) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Gets the interrupt configuration.
|
||||
//!
|
||||
//! @param bEnabledOnly - return the status of only the enabled interrupts.
|
||||
//!
|
||||
//! This function gets the currently configured interrupts.
|
||||
//!
|
||||
//! @return the configured interrupts.
|
||||
//!
|
||||
//! Possible values for the return are:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_INT_RTC_ALARM
|
||||
//! AM_HAL_CLKGEN_INT_XT_FAIL
|
||||
//! AM_HAL_CLKGEN_INT_AUTOCAL_COMPLETE
|
||||
//! AM_HAL_CLKGEN_INT AUTOCAL_FAIL
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
am_hal_clkgen_int_status_get(bool bEnabledOnly)
|
||||
{
|
||||
//
|
||||
// Return the status.
|
||||
//
|
||||
if ( bEnabledOnly )
|
||||
{
|
||||
uint32_t u32RetVal = AM_REG(CLKGEN, INTSTAT);
|
||||
u32RetVal &= AM_REG(CLKGEN, INTEN);
|
||||
return u32RetVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AM_REG(CLKGEN, INTSTAT);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Clears the interrupts.
|
||||
//!
|
||||
//! @param ui32IntFlags interrupts to be cleared.
|
||||
//!
|
||||
//! This function clears the interrupts.
|
||||
//!
|
||||
//! Valid values for ui32IntFlags are:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_INT_RTC_ALARM
|
||||
//! AM_HAL_CLKGEN_INT_XT_FAIL
|
||||
//! AM_HAL_CLKGEN_INT_AUTOCAL_COMPLETE
|
||||
//! AM_HAL_CLKGEN_INT AUTOCAL_FAIL
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_int_clear(uint32_t ui32Interrupt)
|
||||
{
|
||||
//
|
||||
// Clear the interrupts.
|
||||
//
|
||||
AM_REG(CLKGEN, INTCLR) = ui32Interrupt;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Starts the desired oscillator(s) (OSC).
|
||||
//!
|
||||
//! @param ui32OscFlags oscillator(s) to start.
|
||||
//!
|
||||
//! This function starts the desired oscillator(s) (OSC).
|
||||
//!
|
||||
//! Valid values for ui32OscFlags are:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_OSC_LFRC
|
||||
//! AM_HAL_CLKGEN_OSC_XT
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_osc_start(uint32_t ui32OscFlags)
|
||||
{
|
||||
if ( ui32OscFlags & (AM_HAL_CLKGEN_OSC_LFRC | AM_HAL_CLKGEN_OSC_XT) )
|
||||
{
|
||||
//
|
||||
// Start the oscillator(s).
|
||||
// Note that these bits are cleared in order to enable the oscillator.
|
||||
//
|
||||
AM_REG(CLKGEN, OCTRL) &= ~ui32OscFlags;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Stops the desired oscillator(s) (OSC).
|
||||
//!
|
||||
//! @param ui32OscFlags oscillator(s) to stop.
|
||||
//!
|
||||
//! This function stops the desired oscillator(s) (OSC).
|
||||
//!
|
||||
//! Valid values for ui32OscFlags are:
|
||||
//!
|
||||
//! AM_HAL_CLKGEN_OSC_LFRC
|
||||
//! AM_HAL_CLKGEN_OSC_XT
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_osc_stop(uint32_t ui32OscFlags)
|
||||
{
|
||||
if ( ui32OscFlags & (AM_HAL_CLKGEN_OSC_LFRC | AM_HAL_CLKGEN_OSC_XT) )
|
||||
{
|
||||
//
|
||||
// Stop the oscillator(s).
|
||||
// Note that these bits are set in order to stop the oscillator.
|
||||
//
|
||||
AM_REG(CLKGEN, OCTRL) |= ui32OscFlags;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enables the clock out signal.
|
||||
//!
|
||||
//! @param ui32Signal desired location for the clock out signal.
|
||||
//!
|
||||
//! This function enables the clock out signal. See am_hal_clkgen.h for
|
||||
//! available signals.
|
||||
//!
|
||||
//! e.g. AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC
|
||||
//! AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV4
|
||||
//! AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_clkout_enable(uint32_t ui32Signal)
|
||||
{
|
||||
//
|
||||
// Enable the clock out on desired signal.
|
||||
//
|
||||
AM_REG(CLKGEN, CLKOUT) = AM_REG_CLKGEN_CLKOUT_CKEN_M | ui32Signal;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disables the clock out signal.
|
||||
//!
|
||||
//! This function disables the clock out signal.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_clkout_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the clock out.
|
||||
//
|
||||
AM_REG(CLKGEN, CLKOUT) = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enable UART system clock.
|
||||
//!
|
||||
//! This function enables or disables the UART system clock.
|
||||
//!
|
||||
//! @param ui32Module is 0 or 1 for Apollo2.
|
||||
//! @param ui32UartEn is one of the following.
|
||||
//! AM_HAL_CLKGEN_UARTEN_DIS
|
||||
//! AM_HAL_CLKGEN_UARTEN_EN
|
||||
//! AM_HAL_CLKGEN_UARTEN_REDUCE_FREQ
|
||||
//! AM_HAL_CLKGEN_UARTEN_EN_POWER_SAV
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_uarten_set(uint32_t ui32Module, uint32_t ui32UartEn)
|
||||
{
|
||||
uint32_t ui32Mask;
|
||||
|
||||
if ( (ui32Module >= AM_REG_UART_NUM_MODULES) ||
|
||||
(ui32UartEn > AM_HAL_CLKGEN_UARTEN_EN_POWER_SAV) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ui32UartEn <<= (ui32Module * AM_HAL_CLKGEN_UARTEN_UARTENn_S(ui32Module));
|
||||
ui32Mask = ~(AM_HAL_CLKGEN_UARTEN_UARTENn_M(ui32Module));
|
||||
|
||||
//
|
||||
// Begin critical section.
|
||||
//
|
||||
AM_CRITICAL_BEGIN
|
||||
|
||||
//
|
||||
// Set the UART clock
|
||||
//
|
||||
AM_REG(CLKGEN, UARTEN) &= ui32Mask;
|
||||
AM_REG(CLKGEN, UARTEN) |= ui32UartEn;
|
||||
|
||||
//
|
||||
// Begin critical section.
|
||||
//
|
||||
AM_CRITICAL_END
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Enables HFRC auto-adjustment at the specified interval.
|
||||
//!
|
||||
//! @param ui32Warmup - How long to give the HFRC to stabilize during each
|
||||
//! calibration attempt.
|
||||
//! @param ui32Frequency - How often the auto-adjustment should happen.
|
||||
//!
|
||||
//! This function enables HFRC auto-adjustment from an external crystal
|
||||
//! oscillator even when the crystal is not normally being used.
|
||||
//!
|
||||
//! ui32Warmup should be one of the following values:
|
||||
//!
|
||||
//! AM_REG_CLKGEN_HFADJ_HFWARMUP_1SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFWARMUP_2SEC
|
||||
//!
|
||||
//! ui32Frequency should be one of the following values:
|
||||
//!
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_4SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_16SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_32SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_64SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_128SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_256SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_512SEC
|
||||
//! AM_REG_CLKGEN_HFADJ_HFADJCK_1024SEC
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_hfrc_adjust_enable(uint32_t ui32Warmup, uint32_t ui32Frequency)
|
||||
{
|
||||
//
|
||||
// Set the HFRC Auto-adjust register for the user's chosen settings. Assume
|
||||
// that the HFRC should be calibrated to 48 MHz and that the crystal is
|
||||
// running at 32.768 kHz.
|
||||
//
|
||||
AM_REG(CLKGEN, HFADJ) =
|
||||
AM_REG_CLKGEN_HFADJ_HFADJ_GAIN_Gain_of_1_in_2 |
|
||||
ui32Warmup |
|
||||
AM_REG_CLKGEN_HFADJ_HFXTADJ(AM_REG_CLKGEN_HFADJ_HFXTADJ_DEFAULT) |
|
||||
ui32Frequency |
|
||||
AM_REG_CLKGEN_HFADJ_HFADJEN_EN;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Disables HFRC auto-adjustment.
|
||||
//!
|
||||
//! This function disables HFRC auto-adjustment.
|
||||
//!
|
||||
//! @return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
am_hal_clkgen_hfrc_adjust_disable(void)
|
||||
{
|
||||
//
|
||||
// Disable the clock out.
|
||||
//
|
||||
AM_REG(CLKGEN, HFADJ) =
|
||||
AM_REG_CLKGEN_HFADJ_HFADJ_GAIN_Gain_of_1_in_2 |
|
||||
AM_REG_CLKGEN_HFADJ_HFWARMUP_1SEC |
|
||||
AM_REG_CLKGEN_HFADJ_HFXTADJ(AM_REG_CLKGEN_HFADJ_HFXTADJ_DEFAULT) |
|
||||
AM_REG_CLKGEN_HFADJ_HFADJCK_4SEC |
|
||||
AM_REG_CLKGEN_HFADJ_HFADJEN_DIS;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,211 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_clkgen.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the CLKGEN.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_CLKGEN_H
|
||||
#define AM_HAL_CLKGEN_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name System Clock max frequency
|
||||
//! @brief Defines the maximum clock frequency for this device.
|
||||
//!
|
||||
//! These macros provide a definition of the maximum clock frequency.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_FREQ_MAX_HZ 48000000
|
||||
#define AM_HAL_CLKGEN_FREQ_MAX_KHZ (AM_HAL_CLKGEN_FREQ_MAX_HZ / 1000)
|
||||
#define AM_HAL_CLKGEN_FREQ_MAX_MHZ (AM_HAL_CLKGEN_FREQ_MAX_HZ / 1000000)
|
||||
#define AM_HAL_CLKGEN_CORESEL_MAXDIV AM_REG_CLKGEN_CCTRL_CORESEL_HFRC_DIV2
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name System Clock Selection
|
||||
//! @brief Divisor selection for the main system clock.
|
||||
//!
|
||||
//! These macros may be used along with the am_hal_clkgen_sysctl_select()
|
||||
//! function to select the frequency of the main system clock.
|
||||
//!
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_SYSCLK_MAX AM_REG_CLKGEN_CCTRL_CORESEL_HFRC
|
||||
#define AM_HAL_CLKGEN_SYSCLK_48MHZ AM_REG_CLKGEN_CCTRL_CORESEL_HFRC
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Interrupt Status Bits
|
||||
//! @brief Interrupt Status Bits for enable/disble use
|
||||
//!
|
||||
//! These macros may be used to set and clear interrupt bits.
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_INT_ALM AM_REG_CLKGEN_INTEN_ALM_M
|
||||
#define AM_HAL_CLKGEN_INT_OF AM_REG_CLKGEN_INTEN_OF_M
|
||||
#define AM_HAL_CLKGEN_INT_ACC AM_REG_CLKGEN_INTEN_ACC_M
|
||||
#define AM_HAL_CLKGEN_INT_ACF AM_REG_CLKGEN_INTEN_ACF_M
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name OSC Start and Stop
|
||||
//! @brief OSC Start and Stop defines.
|
||||
//!
|
||||
//! OSC Start and Stop defines to be used with \e am_hal_clkgen_osc_x().
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_OSC_LFRC AM_REG_CLKGEN_OCTRL_STOPRC_M
|
||||
#define AM_HAL_CLKGEN_OSC_XT AM_REG_CLKGEN_OCTRL_STOPXT_M
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// OSC Start, Stop, Select defines
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV2 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV2
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV4 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV4
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV8 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV8
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV16 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV16
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV32 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV32
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_RTC_100Hz AM_REG_CLKGEN_CLKOUT_CKSEL_RTC_100Hz
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV2M AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV2M
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT AM_REG_CLKGEN_CLKOUT_CKSEL_XT
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_CG_100Hz AM_REG_CLKGEN_CLKOUT_CKSEL_CG_100Hz
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV4 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV4
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV8 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV8
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV32 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV32
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV64 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV64
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV128 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV128
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV256 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV256
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_CORE_CLK AM_REG_CLKGEN_CLKOUT_CKSEL_CORE_CLK
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_FLASH_CLK AM_REG_CLKGEN_CLKOUT_CKSEL_FLASH_CLK
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC_DIV2 AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV2
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC_DIV32 AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV32
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC_DIV512 AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV512
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC_DIV32K AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV32K
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV256 AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV256
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV8K AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV8K
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XT_DIV64K AM_REG_CLKGEN_CLKOUT_CKSEL_XT_DIV64K
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV16 AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV16
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV128 AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV128
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_ULFRC_1Hz AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_1Hz
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV4K AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV4K
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV1M AM_REG_CLKGEN_CLKOUT_CKSEL_ULFRC_DIV1M
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV64K AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV64K
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRC_DIV16M AM_REG_CLKGEN_CLKOUT_CKSEL_HFRC_DIV16M
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRC_DIV2M AM_REG_CLKGEN_CLKOUT_CKSEL_LFRC_DIV2M
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRCNE AM_REG_CLKGEN_CLKOUT_CKSEL_HFRCNE
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_HFRCNE_DIV8 AM_REG_CLKGEN_CLKOUT_CKSEL_HFRCNE_DIV8
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_CORE_CLKNE AM_REG_CLKGEN_CLKOUT_CKSEL_CORE_CLKNE
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XTNE AM_REG_CLKGEN_CLKOUT_CKSEL_XTNE
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_XTNE_DIV16 AM_REG_CLKGEN_CLKOUT_CKSEL_XTNE_DIV16
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRCNE_DIV32 AM_REG_CLKGEN_CLKOUT_CKSEL_LFRCNE_DIV32
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_FCLKNE AM_REG_CLKGEN_CLKOUT_CKSEL_FCLKNE
|
||||
#define AM_HAL_CLKGEN_CLKOUT_CKSEL_LFRCNE AM_REG_CLKGEN_CLKOUT_CKSEL_LFRCNE
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// UARTEN
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CLKGEN_UARTEN_DIS AM_REG_CLKGEN_UARTEN_UART0EN_DIS
|
||||
#define AM_HAL_CLKGEN_UARTEN_EN AM_REG_CLKGEN_UARTEN_UART0EN_EN
|
||||
#define AM_HAL_CLKGEN_UARTEN_REDUCE_FREQ AM_REG_CLKGEN_UARTEN_UART0EN_REDUCE_FREQ
|
||||
#define AM_HAL_CLKGEN_UARTEN_EN_POWER_SAV AM_REG_CLKGEN_UARTEN_UART0EN_EN_POWER_SAV
|
||||
|
||||
#define AM_HAL_CLKGEN_UARTEN_UARTENn_S(module) \
|
||||
((module) * \
|
||||
(AM_REG_CLKGEN_UARTEN_UART1EN_S - AM_REG_CLKGEN_UARTEN_UART0EN_S))
|
||||
|
||||
#define AM_HAL_CLKGEN_UARTEN_UARTENn_M(module) \
|
||||
(AM_REG_CLKGEN_UARTEN_UART0EN_M << AM_HAL_CLKGEN_UARTEN_UARTENn_S(module))
|
||||
|
||||
//
|
||||
// UARTEN: entype is one of DIS, EN, REDUCE_FREQ, EN_POWER_SAV.
|
||||
//
|
||||
#define AM_HAL_CLKGEN_UARTEN_UARTENn(module, entype) \
|
||||
(AM_REG_CLKGEN_UARTEN_UART0EN_##entype << \
|
||||
AM_HAL_CLKGEN_UARTEN_UARTENn_S(module))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_clkgen_sysclk_select(uint32_t ui32ClockSetting);
|
||||
extern uint32_t am_hal_clkgen_sysclk_get(void);
|
||||
extern void am_hal_clkgen_osc_start(uint32_t ui32OscFlags);
|
||||
extern void am_hal_clkgen_osc_stop(uint32_t ui32OscFlags);
|
||||
extern void am_hal_clkgen_clkout_enable(uint32_t ui32Signal);
|
||||
extern void am_hal_clkgen_clkout_disable(void);
|
||||
extern void am_hal_clkgen_uarten_set(uint32_t ui32Module, uint32_t ui32UartEn);
|
||||
extern void am_hal_clkgen_int_enable(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_clkgen_int_enable_get(void);
|
||||
extern void am_hal_clkgen_int_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_clkgen_int_clear(uint32_t ui32Interrupt);
|
||||
extern void am_hal_clkgen_int_set(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_clkgen_int_status_get(bool bEnabledOnly);
|
||||
extern void am_hal_clkgen_hfrc_adjust_enable(uint32_t ui32Warmup, uint32_t ui32Frequency);
|
||||
extern void am_hal_clkgen_hfrc_adjust_disable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_CLKGEN_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,281 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_ctimer.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for accessing and configuring the CTIMER.
|
||||
//!
|
||||
//! @addtogroup ctimer2 Counter/Timer (CTIMER)
|
||||
//! @ingroup apollo2hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_CTIMER_H
|
||||
#define AM_HAL_CTIMER_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Number of timers
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_TIMERS_NUM 4
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Timer offset value
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_TIMER_OFFSET (AM_REG_CTIMER_TMR1_O - AM_REG_CTIMER_TMR0_O)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Interrupt Status Bits
|
||||
//! @brief Interrupt Status Bits for enable/disble use
|
||||
//!
|
||||
//! These macros may be used to set and clear interrupt bits
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_INT_TIMERA0C0 AM_REG_CTIMER_INTEN_CTMRA0C0INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERA0C1 AM_REG_CTIMER_INTEN_CTMRA0C1INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERA1C0 AM_REG_CTIMER_INTEN_CTMRA1C0INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERA1C1 AM_REG_CTIMER_INTEN_CTMRA1C1INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERA2C0 AM_REG_CTIMER_INTEN_CTMRA2C0INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERA2C1 AM_REG_CTIMER_INTEN_CTMRA2C1INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERA3C0 AM_REG_CTIMER_INTEN_CTMRA3C0INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERA3C1 AM_REG_CTIMER_INTEN_CTMRA3C1INT_M
|
||||
|
||||
#define AM_HAL_CTIMER_INT_TIMERB0C0 AM_REG_CTIMER_INTEN_CTMRB0C0INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB0C1 AM_REG_CTIMER_INTEN_CTMRB0C1INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB1C0 AM_REG_CTIMER_INTEN_CTMRB1C0INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB1C1 AM_REG_CTIMER_INTEN_CTMRB1C1INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB2C0 AM_REG_CTIMER_INTEN_CTMRB2C0INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB2C1 AM_REG_CTIMER_INTEN_CTMRB2C1INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB3C0 AM_REG_CTIMER_INTEN_CTMRB3C0INT_M
|
||||
#define AM_HAL_CTIMER_INT_TIMERB3C1 AM_REG_CTIMER_INTEN_CTMRB3C1INT_M
|
||||
|
||||
//
|
||||
// Deprecated, use the newer macros above.
|
||||
//
|
||||
#define AM_HAL_CTIMER_INT_TIMERA0 AM_HAL_CTIMER_INT_TIMERA0C0
|
||||
#define AM_HAL_CTIMER_INT_TIMERB0 AM_HAL_CTIMER_INT_TIMERB0C0
|
||||
#define AM_HAL_CTIMER_INT_TIMERA1 AM_HAL_CTIMER_INT_TIMERA1C0
|
||||
#define AM_HAL_CTIMER_INT_TIMERB1 AM_HAL_CTIMER_INT_TIMERB1C0
|
||||
#define AM_HAL_CTIMER_INT_TIMERA2 AM_HAL_CTIMER_INT_TIMERA2C0
|
||||
#define AM_HAL_CTIMER_INT_TIMERB2 AM_HAL_CTIMER_INT_TIMERB2C0
|
||||
#define AM_HAL_CTIMER_INT_TIMERA3 AM_HAL_CTIMER_INT_TIMERA3C0
|
||||
#define AM_HAL_CTIMER_INT_TIMERB3 AM_HAL_CTIMER_INT_TIMERB3C0
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @name Configuration options
|
||||
//! @brief Configuration options for \e am_hal_ctimer_config_t
|
||||
//!
|
||||
//! These options are to be used with the \e am_hal_ctimer_config_t structure
|
||||
//! used by \e am_hal_ctimer_config
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_CLK_PIN AM_REG_CTIMER_CTRL0_TMRA0CLK(0x0)
|
||||
#define AM_HAL_CTIMER_HFRC_12MHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x1)
|
||||
#define AM_HAL_CTIMER_HFRC_3MHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x2)
|
||||
#define AM_HAL_CTIMER_HFRC_187_5KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x3)
|
||||
#define AM_HAL_CTIMER_HFRC_47KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x4)
|
||||
#define AM_HAL_CTIMER_HFRC_12KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x5)
|
||||
#define AM_HAL_CTIMER_XT_32_768KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x6)
|
||||
#define AM_HAL_CTIMER_XT_16_384KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x7)
|
||||
#define AM_HAL_CTIMER_XT_2_048KHZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x8)
|
||||
#define AM_HAL_CTIMER_XT_256HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0x9)
|
||||
#define AM_HAL_CTIMER_LFRC_512HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0xA)
|
||||
#define AM_HAL_CTIMER_LFRC_32HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0xB)
|
||||
#define AM_HAL_CTIMER_LFRC_1HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0xC)
|
||||
#define AM_HAL_CTIMER_LFRC_1_16HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0xD)
|
||||
#define AM_HAL_CTIMER_RTC_100HZ AM_REG_CTIMER_CTRL0_TMRA0CLK(0xE)
|
||||
#define AM_HAL_CTIMER_HCLK AM_REG_CTIMER_CTRL0_TMRA0CLK(0xF)
|
||||
#define AM_HAL_CTIMER_BUCK AM_REG_CTIMER_CTRL0_TMRA0CLK(0x10)
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Timer function macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_FN_ONCE AM_REG_CTIMER_CTRL0_TMRA0FN(0)
|
||||
#define AM_HAL_CTIMER_FN_REPEAT AM_REG_CTIMER_CTRL0_TMRA0FN(1)
|
||||
#define AM_HAL_CTIMER_FN_PWM_ONCE AM_REG_CTIMER_CTRL0_TMRA0FN(2)
|
||||
#define AM_HAL_CTIMER_FN_PWM_REPEAT AM_REG_CTIMER_CTRL0_TMRA0FN(3)
|
||||
#define AM_HAL_CTIMER_FN_CONTINUOUS AM_REG_CTIMER_CTRL0_TMRA0FN(4)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Half-timer options.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_INT_ENABLE AM_REG_CTIMER_CTRL0_TMRA0IE0_M
|
||||
#define AM_HAL_CTIMER_PIN_ENABLE AM_REG_CTIMER_CTRL0_TMRA0PE_M
|
||||
#define AM_HAL_CTIMER_PIN_INVERT AM_REG_CTIMER_CTRL0_TMRA0POL_M
|
||||
#define AM_HAL_CTIMER_CLEAR AM_REG_CTIMER_CTRL0_TMRA0CLR_M
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Additional timer options.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_LINK AM_REG_CTIMER_CTRL0_CTLINK0_M
|
||||
#define AM_HAL_CTIMER_ADC_TRIG AM_REG_CTIMER_CTRL3_ADCEN_M
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Timer selection macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_CTIMER_TIMERA 0x0000FFFF
|
||||
#define AM_HAL_CTIMER_TIMERB 0xFFFF0000
|
||||
#define AM_HAL_CTIMER_BOTH 0xFFFFFFFF
|
||||
//! @}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Timer configuration structure
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! Set to 1 to operate this timer as a 32-bit timer instead of two 16-bit
|
||||
//! timers.
|
||||
//
|
||||
uint32_t ui32Link;
|
||||
|
||||
//
|
||||
//! Configuration options for TIMERA
|
||||
//
|
||||
uint32_t ui32TimerAConfig;
|
||||
|
||||
//
|
||||
//! Configuration options for TIMERB
|
||||
//
|
||||
uint32_t ui32TimerBConfig;
|
||||
|
||||
}
|
||||
am_hal_ctimer_config_t;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Function pointer type for CTimer interrupt handlers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (*am_hal_ctimer_handler_t)(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_ctimer_config(uint32_t ui32TimerNumber,
|
||||
am_hal_ctimer_config_t *psConfig);
|
||||
|
||||
extern void am_hal_ctimer_config_single(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment,
|
||||
uint32_t ui32ConfigVal);
|
||||
|
||||
extern void am_hal_ctimer_start(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern void am_hal_ctimer_stop(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern void am_hal_ctimer_clear(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern uint32_t am_hal_ctimer_read(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern void am_hal_ctimer_pin_enable(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern void am_hal_ctimer_pin_disable(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment);
|
||||
|
||||
extern void am_hal_ctimer_pin_invert(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment,
|
||||
bool bInvertOutput);
|
||||
|
||||
extern void am_hal_ctimer_compare_set(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment,
|
||||
uint32_t ui32CompareReg,
|
||||
uint32_t ui32Value);
|
||||
|
||||
extern void am_hal_ctimer_period_set(uint32_t ui32TimerNumber,
|
||||
uint32_t ui32TimerSegment,
|
||||
uint32_t ui32Period,
|
||||
uint32_t ui32OnTime);
|
||||
|
||||
extern void am_hal_ctimer_adc_trigger_enable(void);
|
||||
extern void am_hal_ctimer_adc_trigger_disable(void);
|
||||
extern void am_hal_ctimer_int_enable(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_ctimer_int_enable_get(void);
|
||||
extern void am_hal_ctimer_int_disable(uint32_t ui32Interrupt);
|
||||
extern void am_hal_ctimer_int_set(uint32_t ui32Interrupt);
|
||||
extern void am_hal_ctimer_int_clear(uint32_t ui32Interrupt);
|
||||
extern uint32_t am_hal_ctimer_int_status_get(bool bEnabledOnly);
|
||||
extern void am_hal_ctimer_int_register(uint32_t ui32Interrupt,
|
||||
am_hal_ctimer_handler_t pfnHandler);
|
||||
extern void am_hal_ctimer_int_service(uint32_t ui32Status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_CTIMER_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,84 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_debug.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Useful functions for debugging.
|
||||
//!
|
||||
//! These functions and macros were created to assist with debugging. They are
|
||||
//! intended to be as unintrusive as possible and designed to be removed from
|
||||
//! the compilation of a project when they are no longer needed.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @brief Default implementation of a failed ASSERT statement.
|
||||
//!
|
||||
//! @param pcFile is the name of the source file where the error occurred.
|
||||
//! @param ui32Line is the line number where the error occurred.
|
||||
//! @param pcMessage is an optional message describing the failure.
|
||||
//!
|
||||
//! This function is called by am_hal_debug_assert() macro when the supplied
|
||||
//! condition is not true. The implementation here simply halts the application
|
||||
//! for further analysis. Individual applications may define their own
|
||||
//! implementations of am_hal_debug_error() to provide more detailed feedback
|
||||
//! about the failed am_hal_debug_assert() statement.
|
||||
//!
|
||||
//! @return
|
||||
//
|
||||
//*****************************************************************************
|
||||
#if defined (__IAR_SYSTEMS_ICC__)
|
||||
__weak void
|
||||
#else
|
||||
void __attribute__((weak))
|
||||
#endif
|
||||
am_hal_debug_error(const char *pcFile, uint32_t ui32Line, const char *pcMessage)
|
||||
{
|
||||
//
|
||||
// Halt for analysis.
|
||||
//
|
||||
while(1);
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_debug.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Useful macros for debugging.
|
||||
//!
|
||||
//! These functions and macros were created to assist with debugging. They are
|
||||
//! intended to be as unintrusive as possible and designed to be removed from
|
||||
//! the compilation of a project when they are no longer needed.
|
||||
//!
|
||||
//! @addtogroup haldebug3 HAL Debug/Assert Utilities
|
||||
//! @ingroup apollo2hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_DEBUG_H
|
||||
#define AM_HAL_DEBUG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Determine DBG_FILENAME
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// By spec and convention, the standard __FILE__ compiler macro includes a full
|
||||
// path (absolute or relative) to the file being compiled. This makes recreating
|
||||
// binaries virtually impossible unless rebuilt on the same or identically
|
||||
// configured system.
|
||||
//
|
||||
// To be able to build consistent binaries on different systems, we want to make
|
||||
// sure the full pathname is not included in the binary. Only IAR EWARM provides
|
||||
// an easy mechanism to provide only the filename without the path. For other
|
||||
// platforms, we will simply use a generic pathname.
|
||||
//
|
||||
#if defined (__IAR_SYSTEMS_ICC__)
|
||||
//
|
||||
// With EWARM the --no_path_in_file_macros option reduces __FILE__ to only the
|
||||
// module name. Therefore this define assumes the option is being used.
|
||||
//
|
||||
#define DBG_FILENAME __FILE__
|
||||
#elif defined(__KEIL__)
|
||||
//
|
||||
// Keil provides __MODULE__ which is simply the module name portion of __FILE__.
|
||||
//
|
||||
#define DBG_FILENAME __MODULE__
|
||||
#elif defined(__ARMCC_VERSION)
|
||||
#define DBG_FILENAME __MODULE__
|
||||
#else
|
||||
//
|
||||
// With GCC, we're out of luck.
|
||||
//
|
||||
#define DBG_FILENAME "debug_filename.ext"
|
||||
//#define DBG_FILENAME __FILE__
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Debug assert macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_DEBUG_NO_ASSERT
|
||||
|
||||
#define am_hal_debug_assert_msg(bCondition, pcMessage) \
|
||||
if ( !(bCondition)) am_hal_debug_error(DBG_FILENAME, __LINE__, pcMessage)
|
||||
|
||||
#define am_hal_debug_assert(bCondition) \
|
||||
if ( !(bCondition)) am_hal_debug_error(DBG_FILENAME, __LINE__, 0)
|
||||
|
||||
#else
|
||||
|
||||
#define am_hal_debug_assert_msg(bCondition, pcMessage)
|
||||
#define am_hal_debug_assert(bCondition)
|
||||
|
||||
#endif // AM_DEBUG_ASSERT
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// External function prototypes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void am_hal_debug_error(const char *pcFile, uint32_t ui32Line,
|
||||
const char *pcMessage);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_DEBUG_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,315 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_flash.h
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Functions for performing Flash operations.
|
||||
//!
|
||||
//! @addtogroup flash2 Flash
|
||||
//! @ingroup apollo2hal
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef AM_HAL_FLASH_H
|
||||
#define AM_HAL_FLASH_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Flash Program keys.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_FLASH_PROGRAM_KEY 0x12344321
|
||||
#define AM_HAL_FLASH_RECOVERY_KEY 0xA35C9B6D
|
||||
#define AM_HAL_FLASH_INFO_KEY 0x12344321
|
||||
#define AM_HAL_FLASH_OTP_KEY (AM_HAL_FLASH_INFO_KEY)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Some helpful flash values and macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_FLASH_ADDR 0x00000000
|
||||
#define AM_HAL_FLASH_PAGE_SIZE ( 8 * 1024 )
|
||||
#define AM_HAL_FLASH_INFO_SIZE AM_HAL_FLASH_PAGE_SIZE
|
||||
#define AM_HAL_FLASH_INSTANCE_SIZE ( 512 * 1024 )
|
||||
#define AM_HAL_FLASH_INSTANCE_PAGES ( AM_HAL_FLASH_INSTANCE_SIZE / AM_HAL_FLASH_PAGE_SIZE )
|
||||
#define AM_HAL_FLASH_TOTAL_SIZE ( AM_HAL_FLASH_INSTANCE_SIZE * 2 )
|
||||
#define AM_HAL_FLASH_LARGEST_VALID_ADDR ( AM_HAL_FLASH_ADDR + AM_HAL_FLASH_TOTAL_SIZE - 1 )
|
||||
|
||||
//
|
||||
// Macros to describe the flash ROW layout.
|
||||
//
|
||||
#define AM_HAL_FLASH_ROW_WIDTH_BYTES (512)
|
||||
|
||||
//
|
||||
// Convert an absolute flash address to a instance
|
||||
//
|
||||
#define AM_HAL_FLASH_ADDR2INST(addr) ( ( addr >> 19 ) & 1 )
|
||||
|
||||
//
|
||||
// Convert an absolute flash address to a page number relative to the instance
|
||||
//
|
||||
#define AM_HAL_FLASH_ADDR2PAGE(addr) ( ( addr >> 13 ) & 0x3F )
|
||||
|
||||
//
|
||||
// Convert an absolute flash address to an absolute page number
|
||||
//
|
||||
#define AM_HAL_FLASH_ADDR2ABSPAGE(addr) ( addr >> 13 )
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Given an integer number of microseconds, convert to a value representing the
|
||||
// number of am_hal_flash_delay() cycles that will provide that amount of delay.
|
||||
// This macro is designed to take into account some of the call overhead.
|
||||
//
|
||||
// e.g. To provide a 2us delay:
|
||||
// am_hal_flash_delay( FLASH_CYCLES_US(2) );
|
||||
//
|
||||
// IMPORTANT - Apollo2 is spec'ed for only 48MHz operation, so this macro
|
||||
// assumes that.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define FLASH_CYCLES_US(n) ((n * (AM_HAL_CLKGEN_FREQ_MAX_MHZ / 3)) - 4)
|
||||
|
||||
//
|
||||
// Backward compatibility
|
||||
//
|
||||
#define am_hal_flash_program_otp am_hal_flash_program_info
|
||||
#define am_hal_flash_program_otp_sram am_hal_flash_program_info_sram
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Structure of function pointers to helper functions for invoking various
|
||||
// flash operations. The functions we are pointing to here are in the Apollo 2
|
||||
// integrated BOOTROM.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct am_hal_flash_helper_struct
|
||||
{
|
||||
//
|
||||
// The basics.
|
||||
//
|
||||
int (*flash_mass_erase)(uint32_t, uint32_t);
|
||||
int (*flash_page_erase)(uint32_t, uint32_t, uint32_t);
|
||||
int (*flash_program_main)(uint32_t, uint32_t *,
|
||||
uint32_t*, uint32_t);
|
||||
int (*flash_program_info)(uint32_t, uint32_t,
|
||||
uint32_t*, uint32_t, uint32_t);
|
||||
|
||||
//
|
||||
// Non-blocking variants, but be careful these are not interrupt safe so
|
||||
// mask interrupts while these very long operations proceed.
|
||||
//
|
||||
int (*flash_mass_erase_nb)(uint32_t, uint32_t);
|
||||
int (*flash_page_erase_nb)(uint32_t, uint32_t, uint32_t);
|
||||
bool (*flash_nb_operation_complete)(void);
|
||||
|
||||
//
|
||||
// Essentially these are recovery options.
|
||||
//
|
||||
int (*flash_erase_info)(uint32_t, uint32_t);
|
||||
int (*flash_erase_main_plus_info)(uint32_t, uint32_t);
|
||||
int (*flash_erase_main_plus_info_both_instances)(uint32_t);
|
||||
void (*flash_recovery)(uint32_t);
|
||||
|
||||
//
|
||||
// Useful utilities.
|
||||
//
|
||||
uint32_t (*flash_util_read_word)(uint32_t*);
|
||||
void (*flash_util_write_word)(uint32_t*, uint32_t);
|
||||
void (*delay_cycles)(uint32_t);
|
||||
|
||||
//
|
||||
// The following functions pointers will generally never be called from
|
||||
// user programs. They are here primarily to document these entry points
|
||||
// which are usable from a debugger or debugger script.
|
||||
//
|
||||
void (*flash_program_main_sram)(void);
|
||||
void (*flash_program_info_sram)(void);
|
||||
void (*flash_erase_main_pages_sram)(void);
|
||||
void (*flash_mass_erase_sram)(void);
|
||||
void (*flash_erase_info_sram)(void);
|
||||
void (*flash_erase_main_plus_info_sram)(void);
|
||||
} g_am_hal_flash_t;
|
||||
extern const g_am_hal_flash_t g_am_hal_flash;
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Define some FLASH INFO SPACE values and macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AM_HAL_FLASH_INFO_ADDR 0x50020000
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_O 0x10
|
||||
#define AM_HAL_FLASH_INFO_WRITPROT_O 0x20
|
||||
#define AM_HAL_FLASH_INFO_COPYPROT_O 0x30
|
||||
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_ADDR (AM_HAL_FLASH_INFO_ADDR + AM_HAL_FLASH_INFO_SECURITY_O)
|
||||
#define AM_HAL_FLASH_INFO_WRITPROT_ADDR (AM_HAL_FLASH_INFO_ADDR + AM_HAL_FLASH_INFO_WRITPROT_O)
|
||||
#define AM_HAL_FLASH_INFO_COPYPROT_ADDR (AM_HAL_FLASH_INFO_ADDR + AM_HAL_FLASH_INFO_COPYPROT_O)
|
||||
|
||||
//
|
||||
// Define the customer info signature data (at AM_HAL_FLASH_INFO_ADDR).
|
||||
// These bits must exist in the customer info space in order for many of the
|
||||
// security and protection functions to work.
|
||||
//
|
||||
#define AM_HAL_FLASH_INFO_SIGNATURE0 0x48EAAD88
|
||||
#define AM_HAL_FLASH_INFO_SIGNATURE1 0xC9705737
|
||||
#define AM_HAL_FLASH_INFO_SIGNATURE2 0x0A6B8458
|
||||
#define AM_HAL_FLASH_INFO_SIGNATURE3 0xE41A9D74
|
||||
|
||||
//
|
||||
// Define the customer security bits (at AM_HAL_FLASH_INFO_SECURITY_ADDR)
|
||||
//
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_DEBUGGERPROT_S 0
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_SWOCTRL_S 1
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_SRAMWIPE_S 2
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_FLASHWIPE_S 3
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_ENINFOPRGM_S 4
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_ENINFOERASE_S 8
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_BOOTLOADERSPIN_S 9
|
||||
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_DEBUGGERPROT_M ((uint32_t)(0x1 << AM_HAL_FLASH_INFO_SECURITY_DEBUGGERPROT_S))
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_SWOCTRL_M ((uint32_t)(0x1 << AM_HAL_FLASH_INFO_SECURITY_SWOCTRL_S))
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_SRAMWIPE_M ((uint32_t)(0x1 << AM_HAL_FLASH_INFO_SECURITY_SRAMWIPE_S))
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_FLASHWIPE_M ((uint32_t)(0x1 << AM_HAL_FLASH_INFO_SECURITY_FLASHWIPE_S))
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_ENINFOPRGM_M ((uint32_t)(0xF << AM_HAL_FLASH_INFO_SECURITY_ENINFOPRGM_S))
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_ENINFOERASE_M ((uint32_t)(0x1 << AM_HAL_FLASH_INFO_SECURITY_ENINFOERASE_S))
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_BOOTLOADERSPIN_M ((uint32_t)(0x1 << AM_HAL_FLASH_INFO_SECURITY_BOOTLOADERSPIN_S))
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_DEEPSLEEP_M ((uint32_t)(0x1 << AM_HAL_FLASH_INFO_SECURITY_BOOTLOADERSPIN_S))
|
||||
#define AM_HAL_FLASH_INFO_SECURITY_DEEPSLEEP ((uint32_t)(0x0 << AM_HAL_FLASH_INFO_SECURITY_BOOTLOADERSPIN_S))
|
||||
|
||||
//
|
||||
// Protection chunk macros
|
||||
// AM_HAL_FLASH_INFO_CHUNK2ADDR: Convert a chunk number to an address
|
||||
// AM_HAL_FLASH_INFO_CHUNK2INST: Convert a chunk number to an instance number
|
||||
// AM_HAL_FLASH_INFO_ADDR2CHUNK: Convert an address to a chunk number
|
||||
//
|
||||
#define AM_HAL_FLASH_INFO_CHUNKSIZE (16*1024)
|
||||
|
||||
#define AM_HAL_FLASH_INFO_CHUNK2ADDR(n) (AM_HAL_FLASH_ADDR + (n << 14))
|
||||
#define AM_HAL_FLASH_INFO_CHUNK2INST(n) ((n >> 5) & 1
|
||||
#define AM_HAL_FLASH_INFO_ADDR2CHUNK(n) ((n) >> 14)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Function prototypes for the helper functions
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern int am_hal_flash_mass_erase(uint32_t ui32Value, uint32_t ui32FlashInst);
|
||||
extern int am_hal_flash_page_erase(uint32_t ui32Value, uint32_t ui32FlashInst,
|
||||
uint32_t ui32PageNum);
|
||||
extern int am_hal_flash_program_main(uint32_t value, uint32_t *pSrc,
|
||||
uint32_t *pDst, uint32_t NumberOfWords);
|
||||
extern int am_hal_flash_program_info(uint32_t ui32Value, uint32_t ui32InfoInst,
|
||||
uint32_t *pui32Src, uint32_t ui32Offset,
|
||||
uint32_t ui32NumWords);
|
||||
|
||||
//
|
||||
// Recovery type functions for Customer INFO space.
|
||||
//
|
||||
extern int am_hal_flash_erase_info(uint32_t ui32ProgramKey,
|
||||
uint32_t ui32Instance);
|
||||
extern int am_hal_flash_erase_main_plus_info(uint32_t ui32ProgramKey,
|
||||
uint32_t ui32Instance);
|
||||
extern int am_hal_flash_erase_main_plus_info_both_instances(
|
||||
uint32_t ui32ProgramKey);
|
||||
extern void am_hal_flash_recovery(uint32_t ui32RecoveryKey);
|
||||
|
||||
//
|
||||
// BOOTROM resident reader, writer and delay utility functions.
|
||||
//
|
||||
extern uint32_t am_hal_flash_load_ui32(uint32_t ui32Address);
|
||||
extern void am_hal_flash_store_ui32(uint32_t ui32Address, uint32_t ui32Data);
|
||||
extern void am_hal_flash_delay(uint32_t ui32Iterations);
|
||||
extern uint32_t am_hal_flash_delay_status_change(uint32_t ui32Iterations,
|
||||
uint32_t ui32Address,
|
||||
uint32_t ui32Mask,
|
||||
uint32_t ui32Value);
|
||||
|
||||
//
|
||||
// These functions update security/protection bits in the customer INFO blOCK.
|
||||
//
|
||||
extern bool am_hal_flash_customer_info_signature_check(void);
|
||||
extern bool am_hal_flash_info_signature_set(void);
|
||||
extern int32_t am_hal_flash_info_erase_disable(void);
|
||||
extern bool am_hal_flash_info_erase_disable_check(void);
|
||||
extern int32_t am_hal_flash_info_program_disable(uint32_t ui32Mask);
|
||||
extern uint32_t am_hal_flash_info_program_disable_get(void);
|
||||
extern int32_t am_hal_flash_wipe_flash_enable(void);
|
||||
extern bool am_hal_flash_wipe_flash_enable_check(void);
|
||||
extern int32_t am_hal_flash_wipe_sram_enable(void);
|
||||
extern bool am_hal_flash_wipe_sram_enable_check(void);
|
||||
extern int32_t am_hal_flash_swo_disable(void);
|
||||
extern bool am_hal_flash_swo_disable_check(void);
|
||||
extern int32_t am_hal_flash_debugger_disable(void);
|
||||
extern bool am_hal_flash_debugger_disable_check(void);
|
||||
|
||||
extern int32_t am_hal_flash_copy_protect_set(uint32_t *pui32StartAddress,
|
||||
uint32_t *pui32StopAddress);
|
||||
extern bool am_hal_flash_copy_protect_check(uint32_t *pui32StartAddress,
|
||||
uint32_t *pui32StopAddress);
|
||||
extern int32_t am_hal_flash_write_protect_set(uint32_t *pui32StartAddress,
|
||||
uint32_t *pui32StopAddress);
|
||||
extern bool am_hal_flash_write_protect_check(uint32_t *pui32StartAddress,
|
||||
uint32_t *pui32StopAddress);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AM_HAL_FLASH_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// End Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
@@ -0,0 +1,62 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// am_hal_global.c
|
||||
//! @file
|
||||
//!
|
||||
//! @brief Locate global variables here.
|
||||
//!
|
||||
//! This module contains global variables that are used throughout the HAL.
|
||||
//!
|
||||
//! One use in particular is that it uses a global HAL flags variable that
|
||||
//! contains flags used in various parts of the HAL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (c) 2020, Ambiq Micro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// Third party software included in this distribution is subject to the
|
||||
// additional license terms as defined in the /docs/licenses directory.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// 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 2.4.2 of the AmbiqSuite Development Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "am_mcu_apollo.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t volatile g_ui32HALflags = 0x00000000;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user