Textdateiankuckdingviech.
[hackover2013-badge-firmware.git] / project / commands / cmd_sysinfo.c
1 /**************************************************************************/
2 /*!
3 @file cmd_sysinfo.c
4 @author K. Townsend (microBuilder.eu)
5
6 @brief Code to execute for cmd_sysinfo in the 'core/cmd'
7 command-line interpretter.
8
9 @section LICENSE
10
11 Software License Agreement (BSD License)
12
13 Copyright (c) 2010, microBuilder SARL
14 All rights reserved.
15
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.
26
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.
37 */
38 /**************************************************************************/
39 #include <stdio.h>
40
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
46
47 #ifdef CFG_CHIBI
48 #include "drivers/rf/chibi/chb.h"
49 #include "drivers/rf/chibi/chb_drvr.h"
50 #endif
51
52 #ifdef CFG_PRINTF_UART
53 #include "core/uart/uart.h"
54 #endif
55
56 #ifdef CFG_LM75B
57 #include "drivers/sensors/lm75b/lm75b.h"
58 #endif
59
60 #ifdef CFG_TFTLCD
61 #include "drivers/displays/tft/lcd.h"
62 #include "drivers/storage/eeprom/eeprom.h"
63 #endif
64
65 #ifdef CFG_SDCARD
66 #include "core/gpio/gpio.h"
67 #endif
68
69 /**************************************************************************/
70 /*!
71 'sysinfo' command handler
72 */
73 /**************************************************************************/
74 void cmd_sysinfo(uint8_t argc, char **argv)
75 {
76 IAP_return_t iap_return;
77
78 /* Note: Certain values are only reported if CFG_INTERFACE_LONGSYSINFO
79 is set to 1 in projectconfig.h. These extra values are more useful
80 for debugging than real-world use, so there's no point wasiting
81 flash space storing the code for them */
82
83 printf("%-25s : %d.%d.%d %s", "Firmware", CFG_FIRMWARE_VERSION_MAJOR, CFG_FIRMWARE_VERSION_MINOR, CFG_FIRMWARE_VERSION_REVISION, CFG_PRINTF_NEWLINE);
84 printf("%-25s : %d.%d MHz %s", "System Clock", CFG_CPU_CCLK / 1000000, CFG_CPU_CCLK % 1000000, CFG_PRINTF_NEWLINE);
85
86 // System Uptime (based on systick timer)
87 printf("%-25s : %u s %s", "System Uptime", (unsigned int)systickGetSecondsActive(), CFG_PRINTF_NEWLINE);
88
89 // 128-bit MCU Serial Number
90 iap_return = iapReadSerialNumber();
91 if(iap_return.ReturnCode == 0)
92 {
93 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);
94 }
95
96 #if CFG_INTERFACE_LONGSYSINFO
97 #ifdef CFG_USBCDC
98 printf("%-25s : %d ms %s", "USB Init Timeout", CFG_USBCDC_INITTIMEOUT, CFG_PRINTF_NEWLINE);
99 #endif
100 #endif
101
102 // CLI and buffer Settings
103 #if CFG_INTERFACE_LONGSYSINFO
104 printf("%-25s : %d bytes %s", "CLI Max Command Size", CFG_INTERFACE_MAXMSGSIZE, CFG_PRINTF_NEWLINE);
105 printf("%-25s : %s %s", "CLI IRQ Enabled", CFG_INTERFACE_ENABLEIRQ ? "True" : "False", CFG_PRINTF_NEWLINE);
106 #if CFG_INTERFACE_ENABLEIRQ
107 printf("%-25s : %d.%d %s", "CLI IRQ Location", CFG_INTERFACE_IRQPORT, CFG_INTERFACE_IRQPIN, CFG_PRINTF_NEWLINE);
108 #endif
109 #endif
110
111 #if CFG_INTERFACE_LONGSYSINFO
112 #ifdef CFG_I2CEEPROM
113 printf("%-25s : %d bytes %s", "EEPROM Size", CFG_I2CEEPROM_SIZE, CFG_PRINTF_NEWLINE);
114 #endif
115 #endif
116
117 #ifdef CFG_SDCARD
118 printf("%-25s : %s %s", "SD Card Present", gpioGetValue(CFG_SDCARD_CDPORT, CFG_SDCARD_CDPIN) ? "True" : "False", CFG_PRINTF_NEWLINE);
119 #if CFG_INTERFACE_LONGSYSINFO
120 printf("%-25s : %s %s", "FAT File System", CFG_SDCARD_READONLY ? "Read Only" : "Read/Write", CFG_PRINTF_NEWLINE);
121 #endif
122 #endif
123
124 #ifdef CFG_PRINTF_UART
125 uart_pcb_t *pcb = uartGetPCB();
126 printf("%-25s : %u %s", "UART Baud Rate", (unsigned int)(pcb->baudrate), CFG_PRINTF_NEWLINE);
127 #endif
128
129 // TFT LCD Settings (if CFG_TFTLCD enabled)
130 #ifdef CFG_TFTLCD
131 printf("%-25s : %d %s", "LCD Width", (int)lcdGetWidth(), CFG_PRINTF_NEWLINE);
132 printf("%-25s : %d %s", "LCD Height", (int)lcdGetHeight(), CFG_PRINTF_NEWLINE);
133 #if CFG_INTERFACE_LONGSYSINFO
134 printf("%-25s : %04X %s", "LCD Controller ID", (unsigned short)lcdGetControllerID(), CFG_PRINTF_NEWLINE);
135 printf("%-25s : %s %s", "LCD Small Fonts", CFG_TFTLCD_INCLUDESMALLFONTS == 1 ? "True" : "False", CFG_PRINTF_NEWLINE);
136 printf("%-25s : %s %s", "LCD AA Fonts", CFG_TFTLCD_USEAAFONTS == 1 ? "True" : "False", CFG_PRINTF_NEWLINE);
137 lcdProperties_t lcdprops = lcdGetProperties();
138 printf("%-25s : %s %s", "Touch Screen", lcdprops.touchscreen ? "True" : "False", CFG_PRINTF_NEWLINE);
139 if (lcdprops.touchscreen)
140 {
141 printf("%-25s : %s %s", "Touch Screen Calibrated", eepromReadU8(CFG_EEPROM_TOUCHSCREEN_CALIBRATED) == 1 ? "True" : "False", CFG_PRINTF_NEWLINE);
142 printf("%-25s : %d %s", "Touch Screen Threshold", CFG_TFTLCD_TS_DEFAULTTHRESHOLD, CFG_PRINTF_NEWLINE);
143 }
144 #endif
145 #endif
146
147 // Wireless Settings (if CFG_CHIBI enabled)
148 #ifdef CFG_CHIBI
149 chb_pcb_t *pcb = chb_get_pcb();
150 printf("%-25s : %s %s", "Wireless", "AT86RF212", CFG_PRINTF_NEWLINE);
151 printf("%-25s : 0x%04X %s", "802.15.4 PAN ID", CFG_CHIBI_PANID, CFG_PRINTF_NEWLINE);
152 printf("%-25s : 0x%04X %s", "802.15.4 Node Address", pcb->src_addr, CFG_PRINTF_NEWLINE);
153 printf("%-25s : %d %s", "802.15.4 Channel", CFG_CHIBI_CHANNEL, CFG_PRINTF_NEWLINE);
154 #endif
155
156 // System Temperature (if LM75B Present)
157 #ifdef CFG_LM75B
158 int32_t temp = 0;
159 lm75bGetTemperature(&temp);
160 temp *= 125;
161 printf("%-25s : %d.%d C %s", "Temperature", temp / 1000, temp % 1000, CFG_PRINTF_NEWLINE);
162 #endif
163
164 // ADC Averaging
165 #if CFG_INTERFACE_LONGSYSINFO
166 printf("%-25s : %s %s", "ADC Averaging", ADC_AVERAGING_ENABLE ? "True" : "False", CFG_PRINTF_NEWLINE);
167 #if ADC_AVERAGING_ENABLE
168 printf("%-25s : %d %s", "ADC Averaging Samples", ADC_AVERAGING_SAMPLES, CFG_PRINTF_NEWLINE);
169 #endif
170 #endif
171
172 // Debug LED
173 #if CFG_INTERFACE_LONGSYSINFO
174 printf("%-25s : %d.%d %s", "LED Location", CFG_LED_PORT, CFG_LED_PIN, CFG_PRINTF_NEWLINE);
175 #endif
176 }
This page took 0.070525 seconds and 5 git commands to generate.