* introduced flashrom driver for msb430
* restructured some files concerning flashrom access * added some ifdefs to shell commands
This commit is contained in:
parent
fb1cb91c75
commit
1eec8e170e
@ -34,4 +34,5 @@ FLASHFLAGS ?= -d $(FLASH_PORT) -j uif ;
|
|||||||
|
|
||||||
RESET ?= $(FLASHER) $(FLASHFLAGS) reset ;
|
RESET ?= $(FLASHER) $(FLASHFLAGS) reset ;
|
||||||
|
|
||||||
|
HDRS += [ FPath $(TOP) board msb-430-common include ] ;
|
||||||
HDRS += [ FPath $(TOP) board msb-430-common drivers include ] ;
|
HDRS += [ FPath $(TOP) board msb-430-common drivers include ] ;
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <board-conf.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <flashrom.h>
|
||||||
|
|
||||||
uint8_t config_save(void) {
|
uint8_t config_save(void) {
|
||||||
return 1;
|
configmem_t mem = { CONFIG_KEY, sysconfig };
|
||||||
|
return (flashrom_erase((uint8_t*) INFOMEM) && flashrom_write((uint8_t*) INFOMEM, (char*) &mem, sizeof(mem)));
|
||||||
}
|
}
|
||||||
|
|||||||
6
board/msb-430-common/include/board-conf.h
Normal file
6
board/msb-430-common/include/board-conf.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef BOARD_CONF_H
|
||||||
|
#define BOARD_CONF_H
|
||||||
|
|
||||||
|
#define INFOMEM (0x1000)
|
||||||
|
|
||||||
|
#endif /* BOARD-CONF_H */
|
||||||
@ -4,5 +4,5 @@
|
|||||||
|
|
||||||
uint8_t config_save(void) {
|
uint8_t config_save(void) {
|
||||||
configmem_t mem = { CONFIG_KEY, sysconfig };
|
configmem_t mem = { CONFIG_KEY, sysconfig };
|
||||||
return (flashrom_erase((uint32_t) configmem) && flashrom_write((uint32_t) configmem, (char*) &mem, sizeof(mem)));
|
return (flashrom_erase((uint8_t*) &configmem) && flashrom_write((uint8_t*) &configmem, (char*) &mem, sizeof(mem)));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <flashrom.h>
|
#include <flashrom.h>
|
||||||
|
#include <iap.h>
|
||||||
#include <lpc2387.h>
|
#include <lpc2387.h>
|
||||||
|
|
||||||
//#define ENABLE_DEBUG
|
//#define ENABLE_DEBUG
|
||||||
@ -31,7 +32,7 @@ static uint32_t iap(uint32_t code, uint32_t p1, uint32_t p2, uint32_t p3, uint32
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* P U B L I C F U N C T I O N S
|
* P U B L I C F U N C T I O N S
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
uint8_t flashrom_write(uint32_t dst, char *src, uint32_t size) {
|
uint8_t flashrom_write(uint8_t *dst, char *src, size_t size) {
|
||||||
char err;
|
char err;
|
||||||
unsigned intstate;
|
unsigned intstate;
|
||||||
uint8_t sec;
|
uint8_t sec;
|
||||||
@ -39,7 +40,7 @@ uint8_t flashrom_write(uint32_t dst, char *src, uint32_t size) {
|
|||||||
//buffer_vic = VICIntEnable; // save interrupt enable
|
//buffer_vic = VICIntEnable; // save interrupt enable
|
||||||
//VICIntEnClr = 0xFFFFFFFF; // clear vic
|
//VICIntEnClr = 0xFFFFFFFF; // clear vic
|
||||||
|
|
||||||
sec = flashrom_get_sector(dst);
|
sec = iap_get_sector((uint32_t) dst);
|
||||||
if (sec == INVALID_ADDRESS) {
|
if (sec == INVALID_ADDRESS) {
|
||||||
DEBUG("Invalid address\n");
|
DEBUG("Invalid address\n");
|
||||||
return 0;
|
return 0;
|
||||||
@ -61,7 +62,7 @@ uint8_t flashrom_write(uint32_t dst, char *src, uint32_t size) {
|
|||||||
/* write flash */
|
/* write flash */
|
||||||
else {
|
else {
|
||||||
intstate = disableIRQ();
|
intstate = disableIRQ();
|
||||||
err = copy_ram_to_flash(dst, (uint32_t) src, 256);
|
err = copy_ram_to_flash((uint32_t) dst, (uint32_t) src, 256);
|
||||||
restoreIRQ(intstate);
|
restoreIRQ(intstate);
|
||||||
if(err) {
|
if(err) {
|
||||||
DEBUG("ERROR: COPY_RAM_TO_FLASH: %u\n", err);
|
DEBUG("ERROR: COPY_RAM_TO_FLASH: %u\n", err);
|
||||||
@ -72,7 +73,7 @@ uint8_t flashrom_write(uint32_t dst, char *src, uint32_t size) {
|
|||||||
}
|
}
|
||||||
/* check result */
|
/* check result */
|
||||||
else {
|
else {
|
||||||
err = compare(dst, (uint32_t) src, 256);
|
err = compare((uint32_t) dst, (uint32_t) src, 256);
|
||||||
if (err) {
|
if (err) {
|
||||||
DEBUG("ERROR: COMPARE: %i (at position %u)\n", err, iap_result[1]);
|
DEBUG("ERROR: COMPARE: %i (at position %u)\n", err, iap_result[1]);
|
||||||
/* set interrupts back and return */
|
/* set interrupts back and return */
|
||||||
@ -91,8 +92,8 @@ uint8_t flashrom_write(uint32_t dst, char *src, uint32_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t flashrom_erase(uint32_t addr) {
|
uint8_t flashrom_erase(uint8_t *addr) {
|
||||||
uint8_t sec = flashrom_get_sector(addr);
|
uint8_t sec = iap_get_sector((uint32_t) addr);
|
||||||
unsigned intstate;
|
unsigned intstate;
|
||||||
|
|
||||||
if (sec == INVALID_ADDRESS) {
|
if (sec == INVALID_ADDRESS) {
|
||||||
|
|||||||
@ -37,25 +37,6 @@
|
|||||||
#define PLLCON_PLLC (0x03) ///< PLL Connect
|
#define PLLCON_PLLC (0x03) ///< PLL Connect
|
||||||
#define PLLSTAT_PLOCK (0x0400) //</ PLL Lock Status
|
#define PLLSTAT_PLOCK (0x0400) //</ PLL Lock Status
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Erase sector
|
|
||||||
*
|
|
||||||
* @param addr Address within a flash sector to erase
|
|
||||||
*
|
|
||||||
* @return 1 on success, 0 otherwise
|
|
||||||
*/
|
|
||||||
uint8_t flashrom_erase(uint32_t addr);
|
|
||||||
|
|
||||||
/* @brief Write buffer from ram to flash
|
|
||||||
*
|
|
||||||
* @param dst Address within a flash sector to write, must be a 256 byte boundary
|
|
||||||
* @param src Address within ram, must be a word boundary
|
|
||||||
* @param size Bytes to write
|
|
||||||
*
|
|
||||||
* @return 1 on success, 0 otherwise
|
|
||||||
*/
|
|
||||||
uint8_t flashrom_write(uint32_t dst, char *src, uint32_t size);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief: Converts 'addr' to sector number
|
* @brief: Converts 'addr' to sector number
|
||||||
* @note: Sector table (Users Manual P. 610)
|
* @note: Sector table (Users Manual P. 610)
|
||||||
@ -64,6 +45,6 @@ uint8_t flashrom_write(uint32_t dst, char *src, uint32_t size);
|
|||||||
*
|
*
|
||||||
* @return Sector number. 0xFF on error
|
* @return Sector number. 0xFF on error
|
||||||
*/
|
*/
|
||||||
uint8_t flashrom_get_sector(uint32_t addr);
|
uint8_t iap_get_sector(uint32_t addr);
|
||||||
|
|
||||||
#endif /*IAP_H_*/
|
#endif /*IAP_H_*/
|
||||||
@ -1,7 +1,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <flashrom.h>
|
#include <flashrom.h>
|
||||||
|
#include <iap.h>
|
||||||
|
|
||||||
uint8_t flashrom_get_sector(uint32_t addr) {
|
uint8_t iap_get_sector(uint32_t addr) {
|
||||||
if ((addr >=0x00000000) && (addr <= 0x00000FFF)) {
|
if ((addr >=0x00000000) && (addr <= 0x00000FFF)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
SubDir TOP cpu msp430 ;
|
SubDir TOP cpu msp430 ;
|
||||||
|
|
||||||
Module cpu : msp430-main.c cpu.c atomic.c irq.c ;
|
Module cpu : msp430-main.c cpu.c atomic.c irq.c flashrom.c ;
|
||||||
Module hwtimer_cpu : hwtimer_cpu.c ;
|
Module hwtimer_cpu : hwtimer_cpu.c ;
|
||||||
|
|
||||||
UseModule cpu ;
|
UseModule cpu ;
|
||||||
|
|||||||
80
cpu/msp430/flashrom.c
Normal file
80
cpu/msp430/flashrom.c
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#include <stddef.h>
|
||||||
|
#include <msp430x16x.h>
|
||||||
|
#include <msp430/flash.h>
|
||||||
|
#include <irq.h>
|
||||||
|
|
||||||
|
uint8_t ie1, ie2;
|
||||||
|
|
||||||
|
static uint8_t prepare(void);
|
||||||
|
static void finish(uint8_t istate);
|
||||||
|
static inline void busy_wait(void);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
uint8_t flashrom_erase(uint8_t *addr) {
|
||||||
|
uint8_t istate = prepare();
|
||||||
|
|
||||||
|
FCTL3 = FWKEY; /* Lock = 0 */
|
||||||
|
busy_wait();
|
||||||
|
FCTL1 = FWKEY | ERASE;
|
||||||
|
*addr = 0; /* erase Flash segment */
|
||||||
|
busy_wait();
|
||||||
|
FCTL1 = FWKEY; /* ERASE = 0 */
|
||||||
|
FCTL3 = FWKEY | LOCK;
|
||||||
|
finish(istate);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void flashrom_write(uint8_t *dst, uint8_t *src, size_t size) {
|
||||||
|
unsigned int i;
|
||||||
|
FCTL3 = FWKEY; /* Lock = 0 */
|
||||||
|
busy_wait();
|
||||||
|
for (i = size; i > 0; i--) {
|
||||||
|
FCTL1 = FWKEY | WRT;
|
||||||
|
*dst = *src; /* program Flash word */
|
||||||
|
while (!(FCTL3 & WAIT)) {
|
||||||
|
nop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
busy_wait();
|
||||||
|
FCTL1 = FWKEY; /* WRT = 0 */
|
||||||
|
FCTL3 = FWKEY | LOCK; /* Lock = 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static uint8_t prepare(void) {
|
||||||
|
uint8_t istate;
|
||||||
|
|
||||||
|
/* Disable all interrupts. */
|
||||||
|
|
||||||
|
/* Clear interrupt flag1. */
|
||||||
|
IFG1 = 0;
|
||||||
|
|
||||||
|
/* DCO(SMCLK) is 2,4576MHz, /6 = 409600 Hz
|
||||||
|
select SMCLK for flash timing, divider 4+1 */
|
||||||
|
FCTL2 = FWKEY | FSSEL_3 | FN2 | FN0;
|
||||||
|
|
||||||
|
/* disable all interrupts to protect CPU
|
||||||
|
during programming from system crash */
|
||||||
|
istate = disableIRQ();
|
||||||
|
|
||||||
|
/* disable all NMI-Interrupt sources */
|
||||||
|
ie1 = IE1;
|
||||||
|
ie2 = IE2;
|
||||||
|
IE1 = 0x00;
|
||||||
|
IE2 = 0x00;
|
||||||
|
return istate;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void finish(uint8_t istate) {
|
||||||
|
/* Enable interrupts. */
|
||||||
|
IE1 = ie1;
|
||||||
|
IE2 = ie2;
|
||||||
|
restoreIRQ(istate);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void busy_wait(void) {
|
||||||
|
/* Wait for BUSY = 0, not needed unless run from RAM */
|
||||||
|
while(FCTL3 & 0x0001) {
|
||||||
|
nop();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
drivers/include/flashrom.h
Normal file
27
drivers/include/flashrom.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef FLASHROM_H
|
||||||
|
#define FLASHROM_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Erase sector
|
||||||
|
*
|
||||||
|
* @param addr Address within a flash sector to erase
|
||||||
|
*
|
||||||
|
* @return 1 on success, 0 otherwise
|
||||||
|
*/
|
||||||
|
uint8_t flashrom_erase(uint8_t *addr);
|
||||||
|
|
||||||
|
/* @brief Write buffer from ram to flash
|
||||||
|
*
|
||||||
|
* @param dst Address within a flash sector to write, must be a 256 byte boundary
|
||||||
|
* @param src Address within ram, must be a word boundary
|
||||||
|
* @param size Bytes to write
|
||||||
|
*
|
||||||
|
* @return 1 on success, 0 otherwise
|
||||||
|
*/
|
||||||
|
uint8_t flashrom_write(uint8_t *dst, char *src, size_t size);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FLASHROM_H */
|
||||||
@ -1,5 +1,5 @@
|
|||||||
SubDir TOP projects msb430_cc110x_ng ;
|
SubDir TOP projects msb430_cc110x_ng ;
|
||||||
|
|
||||||
Module msb430_cc110x_ng : main.c : cc110x_ng transceiver ps posix_io uart0 auto_init ;
|
Module msb430_cc110x_ng : main.c : cc110x_ng transceiver shell shell_commands ps posix_io uart0 auto_init ;
|
||||||
|
|
||||||
UseModule msb430_cc110x_ng ;
|
UseModule msb430_cc110x_ng ;
|
||||||
|
|||||||
@ -12,13 +12,15 @@
|
|||||||
#include <transceiver.h>
|
#include <transceiver.h>
|
||||||
#include <cc1100_ng.h>
|
#include <cc1100_ng.h>
|
||||||
|
|
||||||
#define RADIO_STACK_SIZE (1024)
|
#define SHELL_STACK_SIZE (512)
|
||||||
|
#define RADIO_STACK_SIZE (512)
|
||||||
|
|
||||||
#define SND_BUFFER_SIZE (3)
|
#define SND_BUFFER_SIZE (3)
|
||||||
#define RCV_BUFFER_SIZE (4)
|
#define RCV_BUFFER_SIZE (4)
|
||||||
|
|
||||||
#define SENDING_DELAY (5 * 1000)
|
#define SENDING_DELAY (5 * 1000)
|
||||||
|
|
||||||
|
char shell_stack_buffer[SHELL_STACK_SIZE];
|
||||||
char radio_stack_buffer[RADIO_STACK_SIZE];
|
char radio_stack_buffer[RADIO_STACK_SIZE];
|
||||||
|
|
||||||
uint8_t snd_buffer[SND_BUFFER_SIZE][CC1100_MAX_DATA_LENGTH];
|
uint8_t snd_buffer[SND_BUFFER_SIZE][CC1100_MAX_DATA_LENGTH];
|
||||||
@ -32,6 +34,20 @@ static radio_packet_t p;
|
|||||||
void sender(char *count);
|
void sender(char *count);
|
||||||
void print_buffer(char *unused);
|
void print_buffer(char *unused);
|
||||||
|
|
||||||
|
shell_t shell;
|
||||||
|
const shell_command_t sc[] = {
|
||||||
|
{"snd", "", sender},
|
||||||
|
{"buffer", "", print_buffer},
|
||||||
|
{NULL, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
void shell_runner(void) {
|
||||||
|
shell_init(&shell, sc, uart0_readc, uart0_putc);
|
||||||
|
posix_open(uart0_handler_pid, 0);
|
||||||
|
shell_run(&shell);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void sender(char *count) {
|
void sender(char *count) {
|
||||||
unsigned int c = 3;
|
unsigned int c = 3;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -104,12 +120,18 @@ int main(void) {
|
|||||||
for (i = 0; i < SND_BUFFER_SIZE; i++) {
|
for (i = 0; i < SND_BUFFER_SIZE; i++) {
|
||||||
memset(snd_buffer[i], i, CC1100_MAX_DATA_LENGTH);
|
memset(snd_buffer[i], i, CC1100_MAX_DATA_LENGTH);
|
||||||
}
|
}
|
||||||
|
thread_create(shell_stack_buffer, SHELL_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, shell_runner, "shell");
|
||||||
radio_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, radio, "radio");
|
radio_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, radio, "radio");
|
||||||
transceiver_init(TRANSCEIVER_CC1100);
|
transceiver_init(TRANSCEIVER_CC1100);
|
||||||
transceiver_start();
|
transceiver_start();
|
||||||
transceiver_register(TRANSCEIVER_CC1100, radio_pid);
|
transceiver_register(TRANSCEIVER_CC1100, radio_pid);
|
||||||
sender(NULL);
|
sender(NULL);
|
||||||
|
|
||||||
|
printf("Config:\n");
|
||||||
|
printf("\tid: %u\n", sysconfig.id);
|
||||||
|
printf("\taddr: %u\n", sysconfig.radio_address);
|
||||||
|
printf("\tchannel: %u\n", sysconfig.radio_channel);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
extern void thread_print_all(void);
|
extern void thread_print_all(void);
|
||||||
thread_print_all();
|
thread_print_all();
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <cc1100-interface.h>
|
#include <cc1100-interface.h>
|
||||||
|
|
||||||
|
#ifdef MODULE_CC110X
|
||||||
|
|
||||||
void _cc1100_get_address_handler(char *str) {
|
void _cc1100_get_address_handler(char *str) {
|
||||||
radio_address_t addr = cc1100_get_address();
|
radio_address_t addr = cc1100_get_address();
|
||||||
printf("cc1100 address: %i\n", addr);
|
printf("cc1100 address: %i\n", addr);
|
||||||
@ -22,3 +24,4 @@ void _cc1100_set_address_handler(char *str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <transceiver.h>
|
#include <transceiver.h>
|
||||||
#include <cc1100_ng.h>
|
#include <cc1100_ng.h>
|
||||||
@ -16,7 +17,8 @@ void _cc1100_ng_get_set_address_handler(char *addr) {
|
|||||||
tcmd.transceivers = TRANSCEIVER_CC1100;
|
tcmd.transceivers = TRANSCEIVER_CC1100;
|
||||||
tcmd.data = &a;
|
tcmd.data = &a;
|
||||||
mesg.content.ptr = (char*) &tcmd;
|
mesg.content.ptr = (char*) &tcmd;
|
||||||
if (sscanf(addr, "addr %hi", &a) > 0) {
|
a = atoi(addr+5);
|
||||||
|
if (strlen(addr) > 5) {
|
||||||
printf("[cc1100] Trying to set address %i\n", a);
|
printf("[cc1100] Trying to set address %i\n", a);
|
||||||
mesg.type = SET_ADDRESS;
|
mesg.type = SET_ADDRESS;
|
||||||
}
|
}
|
||||||
@ -33,7 +35,8 @@ void _cc1100_ng_get_set_channel_handler(char *chan) {
|
|||||||
tcmd.transceivers = TRANSCEIVER_CC1100;
|
tcmd.transceivers = TRANSCEIVER_CC1100;
|
||||||
tcmd.data = &c;
|
tcmd.data = &c;
|
||||||
mesg.content.ptr = (char*) &tcmd;
|
mesg.content.ptr = (char*) &tcmd;
|
||||||
if (sscanf(chan, "chan %hi", &c) > 0) {
|
c = atoi(chan+5);
|
||||||
|
if (strlen(chan) > 5) {
|
||||||
printf("[cc1100] Trying to set channel %i\n", c);
|
printf("[cc1100] Trying to set channel %i\n", c);
|
||||||
mesg.type = SET_CHANNEL;
|
mesg.type = SET_CHANNEL;
|
||||||
}
|
}
|
||||||
@ -51,7 +54,10 @@ void _cc1100_ng_send_handler(char *pkt) {
|
|||||||
tcmd.data = &p;
|
tcmd.data = &p;
|
||||||
uint16_t addr;
|
uint16_t addr;
|
||||||
|
|
||||||
if (sscanf(pkt, "txtsnd %hu %s", &(addr), text_msg) == 2) {
|
addr = atoi(pkt+7);
|
||||||
|
memcpy(text_msg, "Text", 5);
|
||||||
|
/* if (sscanf(pkt, "txtsnd %hu %s", &(addr), text_msg) == 2) {*/
|
||||||
|
if (1 == 1) {
|
||||||
p.data = (uint8_t*) text_msg;
|
p.data = (uint8_t*) text_msg;
|
||||||
p.length = strlen(text_msg);
|
p.length = strlen(text_msg);
|
||||||
p.dst = addr;
|
p.dst = addr;
|
||||||
@ -73,7 +79,8 @@ void _cc1100_ng_monitor_handler(char *mode) {
|
|||||||
tcmd.transceivers = TRANSCEIVER_CC1100;
|
tcmd.transceivers = TRANSCEIVER_CC1100;
|
||||||
tcmd.data = &m;
|
tcmd.data = &m;
|
||||||
mesg.content.ptr = (char*) &tcmd;
|
mesg.content.ptr = (char*) &tcmd;
|
||||||
if (sscanf(mode, "monitor %u", &m) == 1) {
|
m = atoi(mode+8);
|
||||||
|
if (strlen(mode) > 8) {
|
||||||
printf("Setting monitor mode: %u\n", m);
|
printf("Setting monitor mode: %u\n", m);
|
||||||
mesg.type = SET_MONITOR;
|
mesg.type = SET_MONITOR;
|
||||||
msg_send(&mesg, transceiver_pid, 1);
|
msg_send(&mesg, transceiver_pid, 1);
|
||||||
|
|||||||
@ -1,17 +1,20 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
void _id_handler(char *id) {
|
void _id_handler(char *id) {
|
||||||
uint16_t newid;
|
long newid;
|
||||||
|
|
||||||
if (sscanf(id, "id %hu", &newid) == 1) {
|
newid = atoi(id+3);
|
||||||
printf("Setting new id %u\n", newid);
|
if (strlen(id) < 3) {
|
||||||
|
printf("Current id: %u\n", sysconfig.id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("Setting new id %lu\n", newid);
|
||||||
sysconfig.id = newid;
|
sysconfig.id = newid;
|
||||||
if (!config_save()) {
|
if (!config_save()) {
|
||||||
puts("ERROR setting new id");
|
puts("ERROR setting new id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
printf("Current id: %u\n", sysconfig.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef MODULE_RTC
|
||||||
#include <lpc2387-rtc.h>
|
#include <lpc2387-rtc.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void _gettime_handler(void) {
|
void _gettime_handler(void) {
|
||||||
struct tm now;
|
struct tm now;
|
||||||
@ -46,3 +48,5 @@ void _date_handler(char* c) {
|
|||||||
_settime_handler(c);
|
_settime_handler(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -41,13 +41,13 @@ and the mailinglist (subscription via web site)
|
|||||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/unistd.h>
|
//#include <sys/unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <shell.h>
|
#include <shell.h>
|
||||||
#include <shell_commands.h>
|
#include <shell_commands.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void(*find_handler(const shell_command_t *command_list, char *command))(char*) {
|
static void(*find_handler(const shell_command_t *command_list, char *command))(char*) {
|
||||||
const shell_command_t* entry = command_list;
|
const shell_command_t* entry = command_list;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include <shell.h>
|
#include <shell_commands.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
extern void _id_handler(char* id);
|
extern void _id_handler(char* id);
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
#include <sht11.h>
|
#include <sht11.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef MODULE_SHT11
|
||||||
|
|
||||||
extern float sht11_temperature_offset;
|
extern float sht11_temperature_offset;
|
||||||
|
|
||||||
void _get_humidity_handler(char* unused) {
|
void _get_humidity_handler(char* unused) {
|
||||||
@ -51,3 +53,5 @@ void _set_offset_handler(char* offset) {
|
|||||||
printf("Temperature offset set to %f\n", sht11_temperature_offset);
|
printf("Temperature offset set to %f\n", sht11_temperature_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user