| 
 | 1 | +/*  | 
 | 2 | + * Copyright (c) 2012-2014 Wind River Systems, Inc.  | 
 | 3 | + * Copyright (c) 2021 Intel Corporation  | 
 | 4 | + *  | 
 | 5 | + * SPDX-License-Identifier: Apache-2.0  | 
 | 6 | + */  | 
 | 7 | + | 
 | 8 | +#include <inttypes.h>  | 
 | 9 | +#include <zephyr.h>  | 
 | 10 | +#include <string.h>  | 
 | 11 | +#include <sys/printk.h>  | 
 | 12 | +#include <logging/log.h>  | 
 | 13 | + | 
 | 14 | +LOG_MODULE_REGISTER(hello_world, 4);  | 
 | 15 | + | 
 | 16 | +static const char *hexdump_msg = "HEXDUMP! HEXDUMP@ HEXDUMP#";  | 
 | 17 | + | 
 | 18 | +void main(void)  | 
 | 19 | +{  | 
 | 20 | +	int8_t i8 = 1;  | 
 | 21 | +	uint8_t u8 = 2;  | 
 | 22 | +	int16_t i16 = 16;  | 
 | 23 | +	uint16_t u16 = 17;  | 
 | 24 | +	int32_t i32 = 32;  | 
 | 25 | +	uint32_t u32 = 33;  | 
 | 26 | +	int64_t i64 = 64;  | 
 | 27 | +	uint64_t u64 = 65;  | 
 | 28 | +	char c = '!';  | 
 | 29 | +	char *s = "static str";  | 
 | 30 | +	char vs0[32];  | 
 | 31 | +	char vs1[32];  | 
 | 32 | +	void *p = s;  | 
 | 33 | + | 
 | 34 | +#ifdef CONFIG_FPU  | 
 | 35 | +	float f = 66.67;  | 
 | 36 | +	double d = 68.69;  | 
 | 37 | + | 
 | 38 | +	long double ld = 70.71;  | 
 | 39 | +#endif  | 
 | 40 | + | 
 | 41 | +	printk("Hello World! %s\n", CONFIG_BOARD);  | 
 | 42 | + | 
 | 43 | +	LOG_ERR("error string");  | 
 | 44 | +	LOG_DBG("debug string");  | 
 | 45 | +	LOG_INF("info string");  | 
 | 46 | + | 
 | 47 | +	LOG_DBG("int8_t %" PRId8 ", uint8_t %" PRIu8, i8, u8);  | 
 | 48 | +	LOG_DBG("int16_t %" PRId16 ", uint16_t %" PRIu16, i16, u16);  | 
 | 49 | +	LOG_DBG("int32_t %" PRId32 ", uint32_t %" PRIu32, i32, u32);  | 
 | 50 | +	LOG_DBG("int64_t %" PRId64 ", uint64_t %" PRIu64, i64, u64);  | 
 | 51 | + | 
 | 52 | +	memset(vs0, 0, sizeof(vs0));  | 
 | 53 | +	snprintk(&vs0[0], sizeof(vs0), "%s", "dynamic str");  | 
 | 54 | + | 
 | 55 | +	memset(vs1, 0, sizeof(vs1));  | 
 | 56 | +	snprintk(&vs1[0], sizeof(vs1), "%s", "another dynamic str");  | 
 | 57 | + | 
 | 58 | +	LOG_DBG("char %c", c);  | 
 | 59 | +	LOG_DBG("s str %s", s);  | 
 | 60 | +	LOG_DBG("d str %s", vs0);  | 
 | 61 | +	LOG_DBG("mixed str %s %s %s %s %s %s %s", vs0, "---", vs0, "---", vs1, "---", vs1);  | 
 | 62 | +	LOG_DBG("mixed c/s %c %s %s %s %c", c, s, vs0, s, c);  | 
 | 63 | + | 
 | 64 | +	LOG_DBG("pointer %p", p);  | 
 | 65 | + | 
 | 66 | +	LOG_HEXDUMP_DBG(hexdump_msg, strlen(hexdump_msg), "For HeXdUmP!");  | 
 | 67 | + | 
 | 68 | +#ifdef CONFIG_FPU  | 
 | 69 | +	LOG_DBG("float %f, double %f, long double %Lf", f, d, ld);  | 
 | 70 | +#endif  | 
 | 71 | +}  | 
0 commit comments