nkjnm
Dependencies: MAX44000 nexpaq_mdk
Fork of LED_Demo by
main.cpp
00001 /* 00002 * Copyright (c) 2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #include <string.h> 00017 #include <stdio.h> 00018 #include <stdarg.h> 00019 00020 //stack 00021 #include "eventOS_event.h" 00022 #include "eventOS_scheduler.h" 00023 00024 //mbed-client-libservice 00025 #include "randLIB.h" 00026 #include "nsdynmemLIB.h" 00027 #include "mbed-trace/mbed_trace.h" 00028 #include "ns_cmdline.h" 00029 00030 00031 //application 00032 #include "cmd_commands.h" 00033 00034 #define APP_DEV_HEAP_SIZE 30000 00035 00036 void eventOS_scheduler_idle(void) 00037 { 00038 eventOS_scheduler_wait(); 00039 } 00040 00041 /*Global variables*/ 00042 00043 uint8_t app_defined_stack_heap[APP_DEV_HEAP_SIZE]; 00044 00045 void app_heap_error_handler(heap_fail_t event) 00046 { 00047 switch (event) 00048 { 00049 case NS_DYN_MEM_NULL_FREE: 00050 tracef(TRACE_LEVEL_ERROR, "mem", "Dyn mem error:NULL_FREE"); 00051 break; 00052 case NS_DYN_MEM_DOUBLE_FREE: 00053 tracef(TRACE_LEVEL_ERROR, "mem", "Dyn mem error:DOUBLE_FREE"); 00054 break; 00055 00056 case NS_DYN_MEM_ALLOCATE_SIZE_NOT_VALID: 00057 tracef(TRACE_LEVEL_ERROR, "mem", "Dyn mem error:SIZE_NOT_VALID"); 00058 break; 00059 case NS_DYN_MEM_POINTER_NOT_VALID: 00060 tracef(TRACE_LEVEL_ERROR, "mem", "Dyn mem error:POINTER_NOT_VALID"); 00061 break; 00062 00063 case NS_DYN_MEM_HEAP_SECTOR_CORRUPTED: 00064 tracef(TRACE_LEVEL_ERROR, "mem", "Dyn mem error:SECTOR_CORRUPTED"); 00065 break; 00066 00067 case NS_DYN_MEM_HEAP_SECTOR_UNITIALIZED: 00068 tracef(TRACE_LEVEL_ERROR, "mem", "Dyn mem error:SECTOR_UNITIALIZED"); 00069 break; 00070 default: 00071 tracef(TRACE_LEVEL_ERROR, "mem", "Dyn mem error:UNKNOWN!"); 00072 break; 00073 } 00074 while(1); 00075 } 00076 00077 int app_time_i=0; 00078 char* time_now(size_t size) 00079 { 00080 static char str[10] = {0}; 00081 sprintf(str, "[%04d]", app_time_i++); 00082 return str; 00083 } 00084 00085 void trace_printer(const char* str) 00086 { 00087 printf("%s\r\n", str); 00088 cmd_output(); 00089 fflush(stdout); 00090 } 00091 void cmd_printer(const char *str) 00092 { 00093 cmd_printf("%s", str); 00094 fflush(stdout); 00095 } 00096 00097 void custom_cmd_response_out(const char* fmt, va_list ap) 00098 { 00099 vprintf(fmt, ap); 00100 fflush(stdout); 00101 } 00102 00103 mem_stat_t memory_heap_stat; 00104 /** 00105 * \brief Application infinite loop. 00106 */ 00107 int main(void) 00108 { 00109 ns_dyn_mem_init(app_defined_stack_heap, APP_DEV_HEAP_SIZE, app_heap_error_handler, &memory_heap_stat); 00110 eventOS_scheduler_init(); 00111 mbed_trace_init(); 00112 mbed_trace_print_function_set( trace_printer ); 00113 mbed_trace_cmdprint_function_set( cmd_printer ); 00114 mbed_trace_prefix_function_set( time_now ); 00115 mbed_trace_config_set(TRACE_MODE_COLOR|TRACE_ACTIVE_LEVEL_DEBUG|TRACE_CARRIAGE_RETURN); 00116 cmd_init( &custom_cmd_response_out ); 00117 00118 initialize_app_commands(0); 00119 00120 eventOS_scheduler_run(); 00121 return 0; 00122 }
Generated on Tue Jul 12 2022 17:03:46 by
1.7.2
