1 /* 2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 #include <stdarg.h> 7 #include <stdio.h> 8 9 #include "pico.h" 10 #include "hardware/timer.h" 11 PICO_WEAK_FUNCTION_DEF(tight_loop_contents)12PICO_WEAK_FUNCTION_DEF(tight_loop_contents) 13 void PICO_WEAK_FUNCTION_IMPL_NAME(tight_loop_contents)() { 14 15 } 16 17 PICO_WEAK_FUNCTION_DEF(get_core_num)18PICO_WEAK_FUNCTION_DEF(get_core_num) 19 uint PICO_WEAK_FUNCTION_IMPL_NAME(get_core_num)() { 20 return 0; 21 } 22 panic_unsupported()23void __noreturn panic_unsupported() { 24 panic("not supported"); 25 } 26 panic(const char * fmt,...)27void panic(const char *fmt, ...) { 28 va_list args; 29 30 puts("*** PANIC ***\n"); 31 if (fmt) { 32 va_start(args, fmt); 33 vprintf(fmt, args); 34 va_end(args); 35 } 36 37 puts("\n"); 38 39 __breakpoint(); 40 } 41 __breakpoint()42void __breakpoint() { 43 #ifdef _MSC_VER 44 __debugbreak(); 45 #else 46 __builtin_trap(); 47 #endif 48 } 49 PICO_WEAK_FUNCTION_DEF(busy_wait_at_least_cycles)50PICO_WEAK_FUNCTION_DEF(busy_wait_at_least_cycles) 51 void PICO_WEAK_FUNCTION_IMPL_NAME(busy_wait_at_least_cycles)(uint32_t cycles) { 52 // fairly arbitrary; we'll use 125Mhz as a reference 53 busy_wait_us((cycles + 124)/125); 54 } 55