154 lines
4.7 KiB
C
154 lines
4.7 KiB
C
//*****************************************************************************
|
|
//
|
|
//! @file ble_freertos_ancs.c
|
|
//!
|
|
//! @brief ARM Cordio BLE - Apple Notification Center Service (ANCS) Example.
|
|
//!
|
|
//! Purpose: This example implements a BLE Apple Notification Center Service
|
|
//! profile.
|
|
//!
|
|
//! Printing takes place over the ITM at 1M Baud.
|
|
//
|
|
//*****************************************************************************
|
|
|
|
//*****************************************************************************
|
|
//
|
|
// Copyright (c) 2021, Ambiq Micro, Inc.
|
|
// 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 release_sdk_4_0_0-60f150b187 of the AmbiqSuite Development Package.
|
|
//
|
|
//*****************************************************************************
|
|
|
|
//*****************************************************************************
|
|
//
|
|
// This application has a large number of common include files. For
|
|
// convenience, we'll collect them all together in a single header and include
|
|
// that everywhere.
|
|
//
|
|
//*****************************************************************************
|
|
|
|
#include "config_hw.h"
|
|
#include "config_sw.h"
|
|
|
|
#include "user_debug.h"
|
|
#include "user_task_manage.h"
|
|
|
|
#include "ble_freertos_ancs.h"
|
|
|
|
|
|
//*****************************************************************************
|
|
//
|
|
// Main Function
|
|
//
|
|
//*****************************************************************************
|
|
int main(void)
|
|
{
|
|
#if !defined(AM_PART_APOLLO4)
|
|
//
|
|
// Set the clock frequency
|
|
//
|
|
am_hal_clkgen_control(AM_HAL_CLKGEN_CONTROL_SYSCLK_MAX, 0);
|
|
|
|
//
|
|
// Set the default cache configuration
|
|
//
|
|
am_hal_cachectrl_config(&am_hal_cachectrl_defaults);
|
|
am_hal_cachectrl_enable();
|
|
#endif
|
|
|
|
//
|
|
// Enable the floating point module, and configure the core for lazy
|
|
// stacking.
|
|
//
|
|
#ifndef NOFPU
|
|
am_hal_sysctrl_fpu_enable();
|
|
am_hal_sysctrl_fpu_stacking_enable(true);
|
|
#else
|
|
am_hal_sysctrl_fpu_disable();
|
|
#endif
|
|
|
|
//
|
|
// Configure the board for low power.
|
|
//
|
|
am_bsp_low_power_init();
|
|
|
|
#if !defined(AM_PART_APOLLO4)
|
|
//
|
|
// Turn off unused Flash & SRAM
|
|
//
|
|
#if 0 //defined(AM_PART_APOLLO3P)
|
|
am_hal_pwrctrl_memory_enable(AM_HAL_PWRCTRL_MEM_FLASH_2M);
|
|
am_hal_pwrctrl_memory_enable(AM_HAL_PWRCTRL_MEM_SRAM_768K);
|
|
#endif
|
|
|
|
//
|
|
// Enable fault detection. about MSPI ?
|
|
//
|
|
#if AM_APOLLO3_MCUCTRL
|
|
am_hal_mcuctrl_control(AM_HAL_MCUCTRL_CONTROL_FAULT_CAPTURE_ENABLE, 0);
|
|
#else
|
|
am_hal_mcuctrl_fault_capture_enable();
|
|
#endif
|
|
#endif
|
|
|
|
//
|
|
// Enable printing to the console.
|
|
//
|
|
#ifdef AM_DEBUG_PRINTF
|
|
am_bsp_debug_printf_enable();
|
|
#endif
|
|
|
|
//
|
|
// Initialize plotting interface.
|
|
//
|
|
// am_util_debug_printf("FreeRTOS ANCS Example\n");
|
|
am_util_stdio_printf("\r\n ------ ZY017 [%s %s] ------ \r\n", __DATE__, __TIME__);
|
|
|
|
//
|
|
// Run the application.
|
|
//
|
|
// run_tasks();
|
|
|
|
// user task run
|
|
user_run();
|
|
|
|
//
|
|
// We shouldn't ever get here.
|
|
//
|
|
while (1)
|
|
{
|
|
;
|
|
}
|
|
}
|
|
|