/* * Copyright (C) 2017 XRADIO TECHNOLOGY CO., LTD. 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 XRADIO TECHNOLOGY CO., LTD. nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * 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 * OWNER 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. */ #include #include #include #include "common/framework/platform_init.h" #include "driver/chip/hal_gpio.h" #include "xrlink/xrlink.h" #include "driver/component/axp/axp.h" #include "driver/component/axp/pmu_mg/pmu_manager.h" #include "kernel/os/os_timer.h" #include "common/cmd/cmd_defs.h" #include "debug/heap_trace.h" #include "kernel/os/os_time.h" int i = 0; void xradio_link_recv_cb(uint8_t *data, uint32_t len) { printf("index:%d len:%d \n", i++, len); } #if defined(CONFIG_MALLOC_TRACE) extern void sram_heap_trace_info_get(heap_info_t *info); extern void heap_get_space(uint8_t **start, uint8_t **end, uint8_t **current); static void xradio_monitor_heap_display(void *arg) { uint8_t *start, *end, *current; heap_info_t sram_info; heap_get_space(&start, &end, ¤t); sram_heap_trace_info_get(&sram_info); printf("sram total %u (%u KB), " "use %u (%u KB), free %u (%u KB), " "max use %u (%u KB), min free %u (%u KB)\n", end - start, (end - start) / 1024, sram_info.sum, sram_info.sum / 1024, end - start - sram_info.sum, (end - start - sram_info.sum) / 1024, sram_info.sum_max, sram_info.sum_max / 1024, end - start - sram_info.sum_max, (end - start - sram_info.sum_max) / 1024); } void xradio_monitor_heap_space(void) { OS_Timer_t timer; OS_TimerSetInvalid(&timer); if (OS_TimerCreate(&timer, OS_TIMER_PERIODIC, xradio_monitor_heap_display, NULL, 5 * 1000) != OS_OK) { printf("monitor heap timer create failed\n"); return; } OS_TimerStart(&timer); /* start OS timer to feed watchdog */ } #endif int main(void) { platform_init(); xrlink_pmu_mamger_init(); xradio_link_init(); xradio_link_reg_recv_cb(xradio_link_recv_cb); #if defined(CONFIG_MALLOC_TRACE) xradio_monitor_heap_space(); #endif return 0; }