Commit df39cdd3 authored by Robert Hartung's avatar Robert Hartung
Browse files

adds temperature sensor tmp102 to software

parent c1a8ccee
......@@ -33,6 +33,7 @@
#include "net/gnrc.h"
#include "net/gnrc/netreg.h"
#include "net/gnrc/netif/ieee802154.h"
#include "periph/i2c.h"
#define SEND_INTERVAL (1)
#define RCV_QUEUE_SIZE (8)
......@@ -107,6 +108,7 @@ int shell_payload(int argc, char** argv) {
} else {
strcpy((char*)eval_message.payload, argv[1]);
eval_message.payload_length = strlen(argv[1]);
//eval_message.payload_length = strncpy( (char*)eval_message.payload, argv[1], MAX_PAYLOAD_LENGTH);
}
return 0;
}
......@@ -119,9 +121,9 @@ int shell_memdump(int argc, char** argv) {
const uint8_t *addr = (const uint8_t*)0x1800;
while(addr < (const uint8_t*)0x2600) {
uint8_t i = 0;
printf("%04X: ",addr);
printf("%04X: ",(unsigned int)addr);
while(i<0xF) {
printf("%02X ", *(addr+i));
printf("%02X ", (unsigned int)(*(addr+i)));
i++;
}
i = 0;
......@@ -137,10 +139,34 @@ int shell_memdump(int argc, char** argv) {
return 0;
}
#ifdef BOARD_INGA_BLUE
int shell_temp(int argc, char** argv) {
(void) argc;
(void) argv;
// uint8_t result;
uint8_t result[2];
i2c_acquire(0);
//i2c_read_reg(0, 0x48, 0x00, &result);
i2c_read_regs(0, 0x48, 0x00, result, 2);
i2c_release(0);
//uint16_t temp = (result[0] << 8) | (result[1] >> 4);
//printf("temperature is %d %d\n", result[0], result[1]);
//printf("temperature=%u\n", temp);
printf("temperature=%u.%d\n", result[0], (result[1]>>4) );
return 0;
}
#endif
shell_command_t eval_shell_commands[] = {
{"tx", "Sends packets", shell_tx},
{"payload", "Sets or prints the payload", shell_payload},
{"memdump", "Prints the memory", shell_memdump},
#ifdef BOARD_INGA_BLUE
{"temp", "Read temperatur", shell_temp},
#endif
{NULL, NULL, NULL}
};
......@@ -485,6 +511,9 @@ int main(void)
{
/// +1 -> INGA working, but TelosB/Sky not
thread_create(dump_thread_stack, sizeof(dump_thread_stack), THREAD_PRIORITY_MAIN + 1, THREAD_CREATE_STACKTEST, dump_thread, NULL, "dump_thread");
int res = i2c_init_master(I2C_DEV(0), 2);
printf("i2c init: %s\n", res == 0 ? "OK\n" : "FAILED\n");
gnrc_netif_t *netif = NULL;
if((netif = gnrc_netif_iter(netif))) {
......@@ -507,4 +536,4 @@ int main(void)
shell_run(eval_shell_commands, line_buf, SHELL_BUFFER_SIZE);
return 0;
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment