1 /**************************************************************************/
4 @author K. Townsend (microBuilder.eu)
6 @brief Code to execute for cmd_sysinfo in the 'core/cmd'
7 command-line interpretter.
11 Software License Agreement (BSD License)
13 Copyright (c) 2010, microBuilder SARL
16 Redistribution and use in source and binary forms, with or without
17 modification, are permitted provided that the following conditions are met:
18 1. Redistributions of source code must retain the above copyright
19 notice, this list of conditions and the following disclaimer.
20 2. Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in the
22 documentation and/or other materials provided with the distribution.
23 3. Neither the name of the copyright holders nor the
24 names of its contributors may be used to endorse or promote products
25 derived from this software without specific prior written permission.
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
28 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
31 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 /**************************************************************************/
41 #include "projectconfig.h"
42 #include "core/cmd/cmd.h"
43 #include "core/systick/systick.h"
44 #include "core/iap/iap.h"
45 #include "project/commands.h" // Generic helper functions
48 #include "drivers/rf/chibi/chb.h"
49 #include "drivers/rf/chibi/chb_drvr.h"
52 #ifdef CFG_PRINTF_UART
53 #include "core/uart/uart.h"
57 #include "drivers/sensors/lm75b/lm75b.h"
61 #include "drivers/displays/tft/lcd.h"
65 #include "core/gpio/gpio.h"
68 /**************************************************************************/
70 'sysinfo' command handler
72 /**************************************************************************/
73 void cmd_sysinfo(uint8_t argc
, char **argv
)
75 IAP_return_t iap_return
;
77 printf("%-25s : %d.%d MHz %s", "System Clock", CFG_CPU_CCLK
/ 1000000, CFG_CPU_CCLK
% 1000000, CFG_PRINTF_NEWLINE
);
78 printf("%-25s : v%d.%d.%d %s", "Firmware", CFG_FIRMWARE_VERSION_MAJOR
, CFG_FIRMWARE_VERSION_MINOR
, CFG_FIRMWARE_VERSION_REVISION
, CFG_PRINTF_NEWLINE
);
80 // 128-bit MCU Serial Number
81 iap_return
= iapReadSerialNumber();
82 if(iap_return
.ReturnCode
== 0)
84 printf("%-25s : %08X %08X %08X %08X %s", "Serial Number", iap_return
.Result
[0],iap_return
.Result
[1],iap_return
.Result
[2],iap_return
.Result
[3], CFG_PRINTF_NEWLINE
);
87 // CLI and buffer Settings
89 printf("%-25s : %d bytes %s", "Max CLI Command", CFG_INTERFACE_MAXMSGSIZE
, CFG_PRINTF_NEWLINE
);
92 #ifdef CFG_PRINTF_UART
93 uart_pcb_t
*pcb
= uartGetPCB();
94 printf("%-25s : %u %s", "UART Baud Rate", (unsigned int)(pcb
->baudrate
), CFG_PRINTF_NEWLINE
);
97 // TFT LCD Settings (if CFG_TFTLCD enabled)
99 printf("%-25s : %d %s", "LCD Width", (int)lcdGetWidth(), CFG_PRINTF_NEWLINE
);
100 printf("%-25s : %d %s", "LCD Height", (int)lcdGetHeight(), CFG_PRINTF_NEWLINE
);
103 // Wireless Settings (if CFG_CHIBI enabled)
105 chb_pcb_t
*pcb
= chb_get_pcb();
106 printf("%-25s : %s %s", "Wireless", "AT86RF212", CFG_PRINTF_NEWLINE
);
107 printf("%-25s : 0x%04X %s", "802.15.4 PAN ID", CFG_CHIBI_PANID
, CFG_PRINTF_NEWLINE
);
108 printf("%-25s : 0x%04X %s", "802.15.4 Node Address", pcb
->src_addr
, CFG_PRINTF_NEWLINE
);
109 printf("%-25s : %d %s", "802.15.4 Channel", CFG_CHIBI_CHANNEL
, CFG_PRINTF_NEWLINE
);
112 // System Uptime (based on systick timer)
113 printf("%-25s : %u s %s", "System Uptime", (unsigned int)systickGetSecondsActive(), CFG_PRINTF_NEWLINE
);
115 // System Temperature (if LM75B Present)
118 lm75bGetTemperature(&temp
);
120 printf("%-25s : %d.%d C %s", "Temperature", temp
/ 1000, temp
% 1000, CFG_PRINTF_NEWLINE
);
124 printf("%-25s : %s %s", "SD Card Present", gpioGetValue(CFG_SDCARD_CDPORT
, CFG_SDCARD_CDPIN
) ? "True" : "False", CFG_PRINTF_NEWLINE
);