diff --git a/applications/applications.mk b/applications/applications.mk index 911cccc8..bb237f3b 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -87,8 +87,8 @@ endif APP_CC1101 ?= 0 ifeq ($(APP_CC1101), 1) CFLAGS += -DAPP_CC1101 -CPP_SOURCES += $(APP_DIR)/cc1101-workaround/cc1101-workaround.cpp -CPP_SOURCES += $(APP_DIR)/cc1101-workaround/cc1101.cpp +C_SOURCES += $(wildcard $(APP_DIR)/cc1101-workaround/*.c) +CPP_SOURCES += $(wildcard $(APP_DIR)/cc1101-workaround/*.cpp) APP_INPUT = 1 APP_DISPLAY = 1 endif diff --git a/applications/cc1101-workaround/cc1101-workaround.cpp b/applications/cc1101-workaround/cc1101-workaround.cpp index 1e8158cc..f0334731 100644 --- a/applications/cc1101-workaround/cc1101-workaround.cpp +++ b/applications/cc1101-workaround/cc1101-workaround.cpp @@ -200,12 +200,12 @@ extern "C" void cc1101_workaround(void* p) { widget_draw_callback_set(widget, render_callback, NULL); // Open GUI and register widget - GuiApi* gui = furi_open("gui"); + GuiApi* gui = (GuiApi*)furi_open("gui"); if(gui == NULL) { printf("gui is not available\n"); furiac_exit(NULL); } - gui->add_widget(gui, state.widget, WidgetLayerFullscreen); + gui->add_widget(gui, widget, WidgetLayerFullscreen); printf("[cc1101] creating device\n"); @@ -253,7 +253,7 @@ extern "C" void cc1101_workaround(void* p) { highRSSI[activeBand] ); - /* + * if(jamm_on) { jamming(&cc1101, activeBand, activeChannel, 500); } else { diff --git a/applications/cc1101-workaround/cc1101.cpp b/applications/cc1101-workaround/cc1101.cpp new file mode 100644 index 00000000..9baef3f7 --- /dev/null +++ b/applications/cc1101-workaround/cc1101.cpp @@ -0,0 +1,396 @@ +#include "flipper_v2.h" +#include "cc1101-workaround/cc1101.h" + +// ****************************************************************************** +#define WRITE_BURST 0x40 +#define READ_SINGLE 0x80 +#define READ_BURST 0xC0 +#define BYTES_IN_FIFO 0x7F //used to detect FIFO underflow or overflow + +/*********************ss_pin as global variable****************************** */ +/* cc1101 */ +/******************************************************************************/ +GpioPin ss_pin; + +CC1101::CC1101(GpioPin ss_pin) { + /* + pinMode(gdo0_pin, OUTPUT); //GDO0 as asynchronous serial mode input + pinMode(gdo2_pin, INPUT); //GDO2 as asynchronous serial mode output + */ + pinMode(ss_pin, OUTPUT); + this->ss_pin = ss_pin; +} +//****************************************************************************** +//SpiInit +/******************************************************************************/ +void CC1101::SpiInit(void) { + //initialize spi pins + + //Enable spi master, MSB, SPI mode 0, FOSC/4 + SpiMode(0); +} + +void CC1101::SpiEnd(void) { + /* + SPCR = ((0<