diff --git a/Makefile.dep b/Makefile.dep index e23725d442..8a32b0900c 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -33,5 +33,11 @@ ifneq (,$(findstring cc110x_ng,$(USEMODULE))) USEMODULE += hwtimer endif endif + ifneq (,$(findstring native,$(BOARD))) + USEMODULE += cc110x_spi + ifeq (,$(findstring hwtimer,$(USEMODULE))) + USEMODULE += hwtimer + endif + endif endif diff --git a/cpu/native/Makefile b/cpu/native/Makefile index bc80511fb5..b804fc8755 100644 --- a/cpu/native/Makefile +++ b/cpu/native/Makefile @@ -5,6 +5,9 @@ DIRS = ifneq (,$(findstring rtc,$(USEMODULE))) DIRS += rtc endif +ifneq (,$(findstring cc110x_ng,$(USEMODULE))) + DIRS += cc110x_ng +endif all: $(BINDIR)$(MODULE).a @for i in $(DIRS) ; do $(MAKE) -C $$i ; done ; diff --git a/cpu/native/cc110x_ng/Makefile b/cpu/native/cc110x_ng/Makefile new file mode 100644 index 0000000000..db427dad5a --- /dev/null +++ b/cpu/native/cc110x_ng/Makefile @@ -0,0 +1,7 @@ +INCLUDES = -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/core/include +INCLUDES += -I$(RIOTBASE)/drivers/cc110x_ng/include/ -I$(RIOTBASE)/sys/include + +MODULE =cc110x_ng + +include $(MAKEBASE)/Makefile.base + diff --git a/cpu/native/cc110x_ng/cc110x_ng_cpu.c b/cpu/native/cc110x_ng/cc110x_ng_cpu.c new file mode 100644 index 0000000000..bb04e2a29c --- /dev/null +++ b/cpu/native/cc110x_ng/cc110x_ng_cpu.c @@ -0,0 +1,151 @@ +#include +#include + +#include + +#include +#include +#include +#include /* CC1100_READ_BURST etc. */ + +static int native_cc110x_enabled; + +static int native_cc110x_gd0; +static int native_cc110x_gd1; +static int native_cc110x_gd2; + +static int native_cc110x_gd0_enabled; +static int native_cc110x_gd2_enabled; + +static uint8_t native_cc110x_ssp0dr; + +/* arch */ + +/** + * writes to SSP0 data register and reads from it once it is ready + */ +uint8_t cc110x_txrx(uint8_t c) +{ + native_cc110x_ssp0dr = c; + switch (c) { + case CC1100_READ_BURST: + case CC1100_WRITE_BURST: + case CC1100_READ_SINGLE: + case CC1100_NOBYTE: + default: + warnx("cc110x_txrx (%i): not implemented", c); + } + DEBUG("cc110x_txrx\n"); + return native_cc110x_ssp0dr; +} + +/** + * disables GDO0 interrupt + */ +void cc110x_gdo0_enable(void) +{ + /* this would be for rising/high edge if this was proper hardware */ + native_cc110x_gd0_enabled = 1; + DEBUG("cc110x_gdo0_enable\n"); + return; +} + + +/** + * enables GDO0 interrupt + */ +void cc110x_gdo0_disable(void) +{ + native_cc110x_gd0_enabled = 0; + DEBUG("cc110x_gdo0_disable\n"); + return; +} + +/** + * enables GDO2 interrupt + */ +void cc110x_gdo2_enable(void) +{ + /* this would be for falling/low edge if this was proper hardware */ + native_cc110x_gd2_enabled = 1; + DEBUG("cc110x_gdo2_enable\n"); + return; +} + +/** + * disables GDO2 interrupt + */ +void cc110x_gdo2_disable(void) +{ + native_cc110x_gd2_enabled = 0; + DEBUG("cc110x_gdo2_disable\n"); + return; +} + +/** + * enable interrupts for GDO0 and GDO2 + */ +void cc110x_init_interrupts(void) +{ + /* this would be for low edge in both cases if this was proper hardware */ + cc110x_gdo2_enable(); + cc110x_gdo0_enable(); + DEBUG("cc110x_init_interrupts\n"); + return; +} + +void cc110x_before_send(void) +{ + cc110x_gdo2_disable(); + DEBUG("cc110x_before_send\n"); + return; +} +void cc110x_after_send(void) +{ + cc110x_gdo2_enable(); + DEBUG("cc110x_after_send\n"); + return; +} + +/* spi */ + +int cc110x_get_gdo0(void) +{ + DEBUG("cc110x_get_gdo0\n"); + return native_cc110x_gd0; +} +int cc110x_get_gdo1(void) +{ + DEBUG("cc110x_get_gdo1\n"); + return native_cc110x_gd1; +} +int cc110x_get_gdo2(void) +{ + DEBUG("cc110x_get_gdo2\n"); + return native_cc110x_gd2; +} + +void cc110x_spi_init(void) +{ + native_cc110x_enabled = 1; /* power on */ + DEBUG("cc110x_spi_init\n"); + return; +} + +void cc110x_spi_cs(void) +{ + DEBUG("cc110x_spi_cs\n"); + return; +} +void cc110x_spi_select(void) +{ + DEBUG("cc110x_spi_select\n"); + return; +} +void cc110x_spi_unselect(void) +{ + DEBUG("cc110x_spi_unselect\n"); + return; +} + +/* ng */ diff --git a/cpu/native/include/cpu-conf.h b/cpu/native/include/cpu-conf.h index eebbe2e30b..5964de56af 100644 --- a/cpu/native/include/cpu-conf.h +++ b/cpu/native/include/cpu-conf.h @@ -21,7 +21,7 @@ #define KERNEL_CONF_STACKSIZE_DEFAULT 8192 #endif -#define KERNEL_CONF_STACKSIZE_IDLE 2048 +#define KERNEL_CONF_STACKSIZE_IDLE 4096 #define NATIVE_ISR_STACKSIZE 8192 #define _SIG_UNDEF SIGRTMIN + 0 @@ -30,4 +30,8 @@ /* TODO: check for overflow (SIGRTMAX) */ +/* for cc110x_ng */ +#define RX_BUF_SIZE (10) +#define TRANSCEIVER_BUFFER_SIZE (3) + #endif /* CPUCONF_H_ */ diff --git a/drivers/cc110x_ng/Makefile b/drivers/cc110x_ng/Makefile index 6fadf78ad4..f5f3820efc 100644 --- a/drivers/cc110x_ng/Makefile +++ b/drivers/cc110x_ng/Makefile @@ -8,6 +8,9 @@ endif ifneq (,$(findstring msba2,$(BOARD))) DIRS += spi endif +ifneq (,$(findstring native,$(BOARD))) + DIRS += spi +endif all: $(BINDIR)$(MODULE).a @for i in $(DIRS) ; do $(MAKE) -C $$i ; done ;