/Designs/HOPEwireless/SW_RX_RFM01/RX_RFM01.c
0,0 → 1,135
/* mija 2008
demo for RFM01 - RX 868MHz
 
PIC 16F876A
xtal = 4MHz
*/
#include "RX_RFM01.h"
 
//************************************************************************
 
#define SDI PIN_B0
#define SCK PIN_B1
#define SDO PIN_B2 // input for PIC
#define nIRQ PIN_B3
#define nSEL PIN_B4
#define LED PIN_B5
 
//************************************************************************
unsigned char RF_RXBUF[22];
int1 led_trg;
 
//************************************************************************
 
void RF_INIT(void)
{
output_high(nSEL);
output_high(SDI);
output_low(SCK);
input(SDO);
}
 
void RF_WRITE_CMD(unsigned int16 cmd)
{
unsigned int8 i;
 
output_low(SCK);
output_low(nSEL);
for (i=0;i<16;i++)
{
output_low(SCK);
if (cmd & 0x8000) output_high(SDI);
else output_low(SDI);
output_high(SCK);
cmd <<= 1;
}
output_low(SCK);
output_high(nSEL);
}
 
int8 RF_RDFIFO(void)
{
unsigned int8 i,Result;
 
output_low(SCK);
output_low(nSEL);
output_low(SDI);
for (i=0;i<16;i++) // skip satus bits
{
output_high(SCK);
output_high(SCK);
output_low(SCK);
output_low(SCK);
}
Result = 0;
for (i=0;i<8;i++)
{
Result <<= 1;
if (input(SDO)) Result |= 1;
output_high(SCK);
output_high(SCK);
output_low(SCK);
output_low(SCK);
}
output_high(nSEL);
return Result;
}
 
void main()
{
unsigned int8 i,j,ChkSum;
 
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
 
output_high(LED);
delay_ms(1000);
output_low(LED);
 
RF_INIT();
 
RF_WRITE_CMD(0x0000);
RF_WRITE_CMD(0x918A); // 868BAND,134kHz
RF_WRITE_CMD(0xA640); // 876Mhz
RF_WRITE_CMD(0xC847); // 4.8kbps
RF_WRITE_CMD(0xC69B); // AFC setting
RF_WRITE_CMD(0xC42A); // Clock recovery manualcontrol,Dig. filter, DQD=4
RF_WRITE_CMD(0xC240); // output 1.66Mhz
RF_WRITE_CMD(0xC080);
RF_WRITE_CMD(0xCE88); // use FIFO 8bit
RF_WRITE_CMD(0xCE8B);
RF_WRITE_CMD(0xC081); // open RX
 
led_trg = 0;
i = 0;
while (1)
{
while (!input(nIRQ))
{
RF_RXBUF[i++] = RF_RDFIFO();
putc(RF_RXBUF[i-1]);
if (i == 18)
{
i = 0;
RF_WRITE_CMD(0xCE88);
RF_WRITE_CMD(0xCE8B);
ChkSum = 0;
for (j=0;j<16;j++) ChkSum += RF_RXBUF[j];
if (ChkSum == RF_RXBUF[16])
{
led_trg = ~led_trg;
output_bit(LED,led_trg);
}
}
}
}
}
 
 
 
/Designs/HOPEwireless/SW_RX_RFM01/RX_RFM01.h
0,0 → 1,9
#include <16F876A.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT,NOLVP,NOBROWNOUT
 
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
 
/Designs/HOPEwireless/SW_RX_RFM01/RX_RFM01.hex
0,0 → 1,52
:1000000000308A00AD2800003C308400000803194D
:1000100018280130F800F701F70B0C28F80B0B2813
:100020004A30F700F70B122800000000800B092867
:100030008A110A12FE2883160612831206168316E8
:1000400006108312061483168610831286108316F8
:10005000061583128A110A12052983168610831247
:1000600086108316061283120612BD013D080F3C4E
:10007000031C592883168610831286100039F70056
:100080003C088039FA0077087A0403194C28831653
:1000900006108312061450288316061083120610C9
:1000A00083168610831286140310BB0DBC0DBD0A87
:1000B0003628831686108312861083160612831242
:1000C00006160034831686108312861083160612D5
:1000D000831206128316061083120610BD013D0816
:1000E0000F3C031C85288316861083128614831602
:1000F0008610831286148316861083128610831648
:10010000861083128610BD0A6F28BE01BD013D080E
:10011000073C031CA4280310BE0D8316061583128A
:1001200006193E14831686108312861483168610D1
:100130008312861483168610831286108316861007
:1001400083128610BD0A87288316061283120616AC
:100150003E08F8008A110A12462984011F308305DF
:100160001930831699002630980090308312980039
:1001700083161F149F141F159F1107309C00FF301A
:100180008312B70083161F149F141F159F1183122B
:100190001F109412B7123708831687008312371680
:1001A0003708831687008312B71137088316870034
:1001B0002030831294000030831694000108C73960
:1001C00008388100831290010030F800920000305E
:1001D0008316920007309C0005080330F700F70BE8
:1001E000EF281C0883120D1383169D0186128312BB
:1001F00086160430BB00FA30BC000428BB0BFB2879
:1002000083168612831286121B28BC01BB012D2087
:100210009130BC008A30BB002D20A630BC0040309D
:10022000BB002D20C830BC004730BB002D20C6309D
:10023000BC009B30BB002D20C430BC002A30BB006A
:100240002D20C230BC004030BB002D20C030BC008F
:100250008030BB002D20CE30BC008830BB002D206C
:10026000CE30BC008B30BB002D20C030BC008130B4
:10027000BB002D203610B80183168615831286190F
:100280007F293808B80A203EBC0062283C08840058
:100290007808800001303802203E84000008BC004D
:1002A0003C080C1E512999003808123C031D7E2978
:1002B000B801CE30BC008830BB002D20CE30BC0051
:1002C0008B30BB002D20BA01B90139080F3C031C4B
:1002D00070292030390784000008BA07B90A652957
:1002E00030083A02031D7E290130B60636187A29F5
:1002F00086127B2986168316861283123C293C2996
:02030000630098
:02400E00393F38
:00000001FF
;PIC16F876A
/Designs/HOPEwireless/SW_TX_RFM02/TX_RFM02.c
0,0 → 1,109
/* mija 2008
demo for RFM01 - TX 868MHz
 
PIC 16F84
xtal = 4MHz
*/
 
#include "TX_RFM02.h"
 
//************************************************************************
 
#define SDI PIN_B0
#define SCK PIN_B1
#define FSK PIN_B2
#define nIRQ PIN_B3 // input for PIC
#define nSEL PIN_B4
 
//************************************************************************
 
//unsigned int8 test[16]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x03b,0x3c,0x3d,0x3e,0x3f};
unsigned int8 test[16]="\n\r\r\rtest\n\r\r\r ";
 
//************************************************************************
 
void RF_INIT(void)
{
output_high(nSEL);
output_high(SDI);
output_low(SCK);
input(nIRQ);
}
 
void RF_WRITE_CMD(unsigned int16 cmd)
{
unsigned int8 i;
 
output_low(SCK);
output_low(nSEL);
for (i=0;i<16;i++)
{
output_low(SCK);
if (cmd & 0x8000) output_high(SDI);
else output_low(SDI);
output_high(SCK);
cmd <<= 1;
}
output_low(SCK);
output_high(nSEL);
}
 
void RF_WRITE_DATA(unsigned int8 data)
{
unsigned int8 i;
 
for (i=0;i<8;i++)
{
while (input(nIRQ));
while (!input(nIRQ));
if (data & 0x80) output_high(FSK);
else output_low(FSK);
data <<= 1;
}
}
 
void main()
{
unsigned int8 i,j,ChkSum;
 
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
 
output_high(LED);
delay_ms(1000);
output_low(LED);
RF_INIT();
 
RF_WRITE_CMD(0xCC00);
RF_WRITE_CMD(0x9361); // 868BAND,+/-90kHz
RF_WRITE_CMD(0xA640); // 868Mhz
RF_WRITE_CMD(0xD040); // rate/2
RF_WRITE_CMD(0xC823); // 4.8kbps
RF_WRITE_CMD(0xC220); // enable bit sync
RF_WRITE_CMD(0xC001); // close all
 
j= ' ';
while (1)
{
RF_WRITE_CMD(0xC039); // start tx
ChkSum = 0;
RF_WRITE_DATA(0xAA);
RF_WRITE_DATA(0xAA);
RF_WRITE_DATA(0xAA);
RF_WRITE_DATA(0x2D);
RF_WRITE_DATA(0xD4);
if (j++ > '~') j = '!';
test[15]=j;
for (i=0;i<16;i++)
{
RF_WRITE_DATA(test[i]);
ChkSum += test[i];
}
RF_WRITE_DATA(ChkSum);
RF_WRITE_DATA(0xAA);
RF_WRITE_CMD(0xC001);
delay_ms(1000);
}
}
 
 
 
/Designs/HOPEwireless/SW_TX_RFM02/TX_RFM02.h
0,0 → 1,7
#include <16F84.h>
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT
#use delay(clock=4000000)
//#use rs232(baud=9600,parity=N,xmit=PIN_A3,rcv=PIN_A2,bits=8)
 
/Designs/HOPEwireless/SW_TX_RFM02/TX_RFM02.hex
0,0 → 1,38
:1000000000308A007D280000253084000008031994
:10001000182801308D008C018C0B0C288D0B0B28BF
:100020004A308C008C0B122800000000800B09283D
:1000300000348316061283120616831606108312E6
:100040000614831686108312861083168615831273
:10005000AD2883168610831286108316061283122B
:100060000612A60126080F3C031C5528831686108D
:100070008312861000398C00250880398F000C0807
:100080000F040319482883160610831206144C28FF
:1000900083160610831206108316861083128614A8
:1000A0000310A40DA50DA60A32288316861083120C
:1000B000861083160612831206160034A60126083F
:1000C000073C031C7C288316861583128619632837
:1000D000831686158312861D6828A51F742883162B
:1000E000061183120615782883160611831206114D
:1000F0000310A50DA60A5F28003484011F30830574
:100100000A3091000D3092009300940074309500F5
:100110006530960073309700743098000A3099006B
:100120000D309A009B009C0020309D009E009F0097
:10013000A00183160108C73908388100861283128E
:1001400086160430A400FA30A5000420A40BA328CE
:1001500083168612831286121928CC30A500A401BA
:1001600029209330A5006130A4002920A630A500E5
:100170004030A4002920D030A5004030A400292020
:10018000C830A5002330A4002920C230A5002030AB
:10019000A4002920C030A5000130A400292020306F
:1001A000A200C030A5003930A4002920A301AA3044
:1001B000A5005E20AA30A5005E20AA30A5005E2022
:1001C0002D30A5005E20D430A5005E202208A20AB2
:1001D0007E3C0318ED282130A2002208A000A101D6
:1001E00021080F3C031C022911302107840000085C
:1001F000A400A5005E201130210784000008A30799
:10020000A10AF0282308A5005E20AA30A5005E20E0
:10021000C030A5000130A40029200430A400FA3029
:0C022000A5000420A40B0F29D1286300C6
:02400E00F93F78
:00000001FF
;PIC16F84