20
20
21
21
#include <device.h>
22
22
#include <misc/byteorder.h>
23
- #define SYS_LOG_NO_NEWLINE
24
- #include <misc/sys_log.h>
25
23
#include <adc.h>
26
24
25
+ #if defined(CONFIG_STDOUT_CONSOLE )
26
+ #include <stdio.h>
27
+ #define DBG printf
28
+ #else
29
+ #include <misc/printk.h>
30
+ #define DBG printk
31
+ #endif
32
+
27
33
#define SLEEPTIME 2
28
34
#define SLEEPTICKS (SLEEPTIME * sys_clock_ticks_per_sec)
29
35
@@ -57,11 +63,11 @@ static struct adc_seq_table table = {
57
63
58
64
static void _print_sample_in_hex (uint8_t * buf , uint32_t length )
59
65
{
60
- SYS_LOG_DBG ("Buffer content:\n" );
66
+ DBG ("Buffer content:\n" );
61
67
for (; length > 0 ; length -= 4 , buf += 4 ) {
62
- SYS_LOG_DBG ("0x%x " , * ((uint32_t * )buf ));
68
+ DBG ("0x%x " , * ((uint32_t * )buf ));
63
69
}
64
- SYS_LOG_DBG ("\n" );
70
+ DBG ("\n" );
65
71
}
66
72
67
73
void main (void )
@@ -70,21 +76,21 @@ void main(void)
70
76
struct nano_timer timer ;
71
77
uint32_t data [2 ] = {0 , 0 };
72
78
73
- SYS_LOG_DBG ("ADC sample started on %s\n" , ADC_DEVICE_NAME );
79
+ DBG ("ADC sample started on %s\n" , ADC_DEVICE_NAME );
74
80
75
81
adc = device_get_binding (ADC_DEVICE_NAME );
76
82
if (!adc ) {
77
- SYS_LOG_DBG ("Cannot get adc controller\n" );
83
+ DBG ("Cannot get adc controller\n" );
78
84
return ;
79
85
}
80
86
81
87
nano_timer_init (& timer , data );
82
88
adc_enable (adc );
83
89
while (1 ) {
84
90
if (adc_read (adc , & table ) != 0 ) {
85
- SYS_LOG_DBG ("Sampling could not proceed, an error occurred\n" );
91
+ DBG ("Sampling could not proceed, an error occurred\n" );
86
92
} else {
87
- SYS_LOG_DBG ("Sampling is done\n" );
93
+ DBG ("Sampling is done\n" );
88
94
_print_sample_in_hex (seq_buffer , BUFFER_SIZE );
89
95
}
90
96
nano_timer_start (& timer , SLEEPTICKS );
0 commit comments