mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/shell: added commands for iot-lab_M3 sensors
This commit is contained in:
parent
4ef5a97e9a
commit
7e043bb27f
@ -55,5 +55,10 @@ ifneq (,$(filter native,$(BOARD)))
|
||||
USEMODULE += config
|
||||
USEMODULE += random
|
||||
endif
|
||||
ifneq (,$(filter iot-lab_M3,$(BOARD)))
|
||||
USEMODULE += isl29020
|
||||
USEMODULE += lps331ap
|
||||
USEMODULE += l3g4200d
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -43,5 +43,14 @@ endif
|
||||
ifeq ($(CPU),x86)
|
||||
SRC += sc_x86_lspci.c
|
||||
endif
|
||||
ifneq (,$(filter isl29020,$(USEMODULE)))
|
||||
SRC += sc_isl29020.c
|
||||
endif
|
||||
ifneq (,$(filter lps331ap,$(USEMODULE)))
|
||||
SRC += sc_lps331ap.c
|
||||
endif
|
||||
ifneq (,$(filter l3g4200d,$(USEMODULE)))
|
||||
SRC += sc_l3g4200d.c
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
71
sys/shell/commands/sc_isl29020.c
Normal file
71
sys/shell/commands/sc_isl29020.c
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup shell_commands
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Provides shell commands to poll the ISL29020 sensor
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "isl29020.h"
|
||||
|
||||
#ifdef MODULE_ISL29020
|
||||
|
||||
#define MODE ISL29020_MODE_AMBIENT
|
||||
#define RANGE ISL29020_RANGE_16K
|
||||
|
||||
static isl29020_t isl29020_dev;
|
||||
|
||||
void _get_isl29020_init_handler(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
int res;
|
||||
|
||||
res = isl29020_init(&isl29020_dev, ISL29020_I2C, ISL29020_ADDR, RANGE, MODE);
|
||||
|
||||
if (res) {
|
||||
puts("Error initializing ISL29020 sensor.");
|
||||
}
|
||||
else {
|
||||
puts("Initialized ISL29020 sensor with default values");
|
||||
}
|
||||
}
|
||||
|
||||
void _get_isl29020_read_handler(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
int val;
|
||||
|
||||
if (!isl29020_dev.address) {
|
||||
puts("Error: please call `isl29020_init` first!");
|
||||
}
|
||||
|
||||
val = isl29020_read(&isl29020_dev);
|
||||
if (val < 0) {
|
||||
puts("Error reading brightness value from ISL29020.");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
printf("ISL29020: brightness %i LUX\n", val);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MODULE_ISL29020 */
|
73
sys/shell/commands/sc_l3g4200d.c
Normal file
73
sys/shell/commands/sc_l3g4200d.c
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup shell_commands
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Provides shell commands to poll the L3G4200D sensor
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "l3g4200d.h"
|
||||
|
||||
#ifdef MODULE_L3G4200D
|
||||
|
||||
#define MODE L3G4200D_MODE_100_25
|
||||
#define SCALE L3G4200D_SCALE_500DPS
|
||||
|
||||
static l3g4200d_t l3g4200d_dev;
|
||||
|
||||
void _get_l3g4200d_init_handler(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
int res;
|
||||
|
||||
res = l3g4200d_init(&l3g4200d_dev, L3G4200D_I2C, L3G4200D_ADDR,
|
||||
L3G4200D_INT, L3G4200D_DRDY,
|
||||
MODE, SCALE);
|
||||
|
||||
if (res) {
|
||||
puts("Error initializing L3G4200D sensor.");
|
||||
}
|
||||
else {
|
||||
puts("Initialized L3G4200D sensor with default values");
|
||||
}
|
||||
}
|
||||
|
||||
void _get_l3g4200d_read_handler(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
int res;
|
||||
l3g4200d_data_t data;
|
||||
|
||||
if (!l3g4200d_dev.addr) {
|
||||
puts("Error: please call `l3g4200d_init` first!");
|
||||
}
|
||||
|
||||
res = l3g4200d_read(&l3g4200d_dev, &data);
|
||||
if (res < 0) {
|
||||
puts("Error reading gyro values from L3G4200D.");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
printf("L3G4200D: gyro values: roll(x): %6i pitch(y): %6i yaw(z): %6i\n",
|
||||
data.acc_x, data.acc_y, data.acc_z);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MODULE_L3G4200D */
|
81
sys/shell/commands/sc_lps331ap.c
Normal file
81
sys/shell/commands/sc_lps331ap.c
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup shell_commands
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Provides shell commands to poll the LPS331AP sensor
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "lps331ap.h"
|
||||
|
||||
#ifdef MODULE_LPS331AP
|
||||
|
||||
#define RATE LPS331AP_RATE_7HZ
|
||||
|
||||
static lps331ap_t lps331ap_dev;
|
||||
|
||||
void _get_lps331ap_init_handler(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
int res;
|
||||
|
||||
res = lps331ap_init(&lps331ap_dev, LPS331AP_I2C, LPS331AP_ADDR, RATE);
|
||||
|
||||
if (res) {
|
||||
puts("Error initializing LPS331AP sensor.");
|
||||
}
|
||||
else {
|
||||
puts("Initialized LPS331AP sensor with default values");
|
||||
}
|
||||
}
|
||||
|
||||
void _get_lps331ap_read_handler(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
int temp;
|
||||
int pres;
|
||||
|
||||
if (!lps331ap_dev.address) {
|
||||
puts("Error: please call `lps331ap_init` first!");
|
||||
}
|
||||
|
||||
temp = lps331ap_read_temp(&lps331ap_dev);
|
||||
pres = lps331ap_read_pres(&lps331ap_dev);
|
||||
|
||||
if (temp < 0) {
|
||||
puts("Error reading temperature value from LPS331AP.");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
int temp_abs = temp / 1000;
|
||||
temp -= (temp_abs * 1000);
|
||||
printf("LPS331AP: temperature: %i.%03i °C\n", temp_abs, temp);
|
||||
}
|
||||
|
||||
if (pres < 0) {
|
||||
puts("Error reading pressure value from LPS331AP.");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
printf("LPS331AP: pressure: %i mBar\n", pres);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MODULE_LPS331AP */
|
@ -49,6 +49,21 @@ extern void _get_weather_handler(int argc, char **argv);
|
||||
extern void _set_offset_handler(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_ISL29020
|
||||
extern void _get_isl29020_init_handler(int argc, char **argv);
|
||||
extern void _get_isl29020_read_handler(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_LPS331AP
|
||||
extern void _get_lps331ap_init_handler(int argc, char **argv);
|
||||
extern void _get_lps331ap_read_handler(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_L3G4200D
|
||||
extern void _get_l3g4200d_init_handler(int argc, char **argv);
|
||||
extern void _get_l3g4200d_read_handler(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_LTC4150
|
||||
extern void _get_current_handler(int argc, char **argv);
|
||||
extern void _reset_current_handler(int argc, char **argv);
|
||||
@ -145,6 +160,18 @@ const shell_command_t _shell_command_list[] = {
|
||||
{"weather", "Prints measured humidity and temperature.", _get_weather_handler},
|
||||
{"offset", "Set temperature offset.", _set_offset_handler},
|
||||
#endif
|
||||
#ifdef MODULE_ISL29020
|
||||
{"isl29020_init", "Initializes the isl29020 sensor driver.", _get_isl29020_init_handler},
|
||||
{"isl29020_read", "Prints data from the isl29020 sensor.", _get_isl29020_read_handler},
|
||||
#endif
|
||||
#ifdef MODULE_LPS331AP
|
||||
{"lps331ap_init", "Initializes the lps331ap sensor driver.", _get_lps331ap_init_handler},
|
||||
{"lps331ap_read", "Prints data from the lps331ap sensor.", _get_lps331ap_read_handler},
|
||||
#endif
|
||||
#ifdef MODULE_L3G4200D
|
||||
{"l3g4200d_init", "Initializes the l3g4200d sensor driver.", _get_l3g4200d_init_handler},
|
||||
{"l3g4200d_read", "Prints data from the l3g4200d sensor.", _get_l3g4200d_read_handler},
|
||||
#endif
|
||||
#ifdef MODULE_LTC4150
|
||||
{"cur", "Prints current and average power consumption.", _get_current_handler},
|
||||
{"rstcur", "Resets coulomb counter.", _reset_current_handler},
|
||||
|
Loading…
Reference in New Issue
Block a user