This is modified program from original CC1101_Transceiver. CC1101 Test succeeded STM32-F407 platform. Feature are improved little bit.
Dependencies: mbed
TI CC1101 chip is embedded along with STM32-F407 MCU.
Revision 2:54c832c68208, committed 2015-03-31
- Comitter:
- hillkim7
- Date:
- Tue Mar 31 08:48:00 2015 +0000
- Parent:
- 1:e96096a7b90b
- Commit message:
- Fix misspelled word.
Changed in this revision
--- a/CC1101.cpp Tue Mar 31 07:48:52 2015 +0000 +++ b/CC1101.cpp Tue Mar 31 08:48:00 2015 +0000 @@ -4,8 +4,8 @@ #define RF_0db //#define RF_10db /////////////////////////////////////////////////////////////////////////////////////// -CC1101::CC1101(PinName mosi, PinName miso, PinName clk, PinName csn, PinName RDmiso, PinName gdo0, PinName gdo1): - _spi(mosi, miso, clk), _csn(csn), _RDmiso(RDmiso), _gdo0(gdo0), _gdo1(gdo1) +CC1101::CC1101(PinName mosi, PinName miso, PinName clk, PinName csn, PinName RDmiso, PinName gdo0, PinName gdo2): + _spi(mosi, miso, clk), _csn(csn), _RDmiso(RDmiso), _gdo0(gdo0), _gdo2(gdo2) { _csn = 1; @@ -484,15 +484,15 @@ const unsigned safe_check_count = 1000000; t = 0; - // Wait for GDO0 to be set -> sync transmitted - while (!_gdo1 && t++ < safe_check_count); + // Wait for GDO2 to be set -> sync transmitted + while (!_gdo2 && t++ < safe_check_count); if (t == safe_check_count) { printf("check timeout 1\r\n"); } - // Wait for GDO0 to be cleared -> end of packet + // Wait for GDO2 to be cleared -> end of packet t = 0; - while (_gdo1 && t++ < safe_check_count); + while (_gdo2 && t++ < safe_check_count); if (t == safe_check_count) { printf("check timeout 2\r\n"); @@ -551,9 +551,9 @@ return _gdo0; } /////////////////////////////////////////////////////////////////////////////////////// -int CC1101::GetGDO1(void) +int CC1101::GetGDO2(void) { - return _gdo1; + return _gdo2; } ///////////////////////////////////////////////////////////////////////////////////////
--- a/CC1101.h Tue Mar 31 07:48:52 2015 +0000 +++ b/CC1101.h Tue Mar 31 08:48:00 2015 +0000 @@ -218,8 +218,10 @@ * @param clk mbed pin to use for SCK line of SPI interface. * @param csn mbed pin to use for not chip select line of SPI interface. * @param RDmiso mbed pin connected to SPI MISO pin for CC1101 RDY read. + * @param gdo0 mbed pin connected to GDO0 pin for RX checking. + * @param gdo2 mbed pin connected to GDO2 pin for TX checking. */ - CC1101(PinName mosi, PinName miso, PinName clk, PinName csn, PinName RDmiso, PinName gdo0, PinName gdo1); + CC1101(PinName mosi, PinName miso, PinName clk, PinName csn, PinName RDmiso, PinName gdo0, PinName gdo2); /** * Initialize CC1101 parameters. @@ -344,9 +346,9 @@ int GetGDO0(void); /** - * This function return GDO1 input pin status. + * This function return GDO2 input pin status. */ - int GetGDO1(void); + int GetGDO2(void); unsigned char ReadStatus(unsigned char addr); @@ -362,7 +364,7 @@ unsigned char rssi; unsigned char lqi; DigitalIn _gdo0; - DigitalIn _gdo1; + DigitalIn _gdo2; }; /////////////////////////////////////////////////////////////////////////////////////// #endif
--- a/main.cpp Tue Mar 31 07:48:52 2015 +0000 +++ b/main.cpp Tue Mar 31 08:48:00 2015 +0000 @@ -3,9 +3,9 @@ * Test result: TX, RX work well with 433MHz on STM32-F407 platform. * Two features are improved from the original source code. * - Synchronous implementation of CC1101::SendPacket() - * For subsequent packet transmission, now this function returns after packet transmission. + * For subsequent packet transmission, now this function returns after packet transmission. * - FIFO checking routine changed. - * Original code uses timer to check FIFO, it may cause resource corruption by timer interrupt. + * Original code uses timer to check FIFO, it may cause resource corruption by timer interrupt. */ #include "mbed.h" #include "CC1101.h" @@ -32,16 +32,22 @@ const PinName gdo0 = PE_0; // pin for checking that sent a packet -// It related with CC1101 IOCFG01register. -const PinName gdo1 = PE_1; +// It related with CC1101 IOCFG02register. +const PinName gdo2 = PE_1; + +CC1101 cc1101(mosi, miso, clk, csn, RDmiso, gdo0, gdo2); -CC1101 cc1101(mosi, miso, clk, csn, RDmiso, gdo0, gdo1); - +#if 1 +Serial pc(PD_8, PD_9); // tx, rx +DigitalOut led1(PD_12); // FIFO led +DigitalOut led2(PD_13); // RX led +DigitalOut led3(PD_14); // TX led +#else Serial pc(USBTX, USBRX); DigitalOut led1(LED1); // FIFO led DigitalOut led2(LED2); // RX led DigitalOut led3(LED3); // TX led - +#endif RingBuffer pcRX(512); // ring buffer for the pc RX data RingBuffer pcTX(512); // ring buffer for the pc TX data Timeout pcRXtimeout;