hallo miparo,
es funktioniert leider nur zum teil. als 'data' scheint es problemlos zu laufen. sobald ich aber umschalte auf 'bcast' bekomme ich am Slave nichts mehr. hier habe ich kein problem im programm finden können. bis jetzt ist das nicht so zufriedenstellend, wenn hir eine funktion vorhanden ist, bei der was nicht geht, und ich nicht weis warum.
Code
program WLAN01_M;
{$NOSHADOW}
{ $WG} {global Warnings off}
Device = mega32, VCC=5;
Define_Fuses
Override_Fuses;
COMport = USB;
FuseBits0 = [];
FuseBits1 = [SPIEN];
FuseBits2 = [];
ProgMode = SPI;
Import SysTick;
Import MIRF24port;
From System Import LongWord, LongInt, Float;
Define
ProcClock = 16000000; {Hertz}
SysTick = 10; {msec}
StackSize = $0064, iData;
FrameSize = $0064, iData;
// SCK, MOSI, MISO, SS, CE, IRQ
MIRF24port = SPI_Soft, PortC, 2, 3, 4, 1, 0, 5;
uses uMIRF24;
Implementation
{$IDATA}
{--------------------------------------------------------------}
{ Type Declarations }
{--------------------------------------------------------------}
{ Const Declarations }
{--------------------------------------------------------------}
{ Var Declarations }
Var
Poll [@PortB,0] :Bit;
txBuff : array[0..31] of byte;
txString[@txBuff] : string[30];
rxBuff : array[0..31] of byte;
rxString[@rxBuff] : string[30];
rxCnt : byte;
X : byte;
{--------------------------------------------------------------}
{ functions }
Procedure PollLED(mS:Word);
Begin
Poll:=False;
mDelay(mS);
Poll:=True;
mDelay(25);
End;
Procedure InitSystem;
Begin
DDRB := DDRB Or %00000001; // Output=1 Input=0
Poll:=True;
EnableInts;
mrfSetChan(mrfChan4, false);
mrfSetPower(mrfdBm0);
mrfSetLocalAddr(1);
mrfSetRetryMax(10);
mrfSetRetryTimeOut(3); // 5x 250usec -> 1.25msec
mrfSetRFspeed(mrfRF2000);
End;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}
begin
InitSystem;
EnableInts;
Loop
if mrfInit then
PollLED(25);
loop
txString:= '12345';
Repeat
Until mrfTxPacket(20, @txBuff,5, false);
PollLED(25);
mDelay(500);
endloop;
endif;
mDelay(500);
EndLoop;
end.
Code
program WLAN01_S;
{$NOSHADOW}
{ $WG} {global Warnings off}
Device = mega32, VCC=5;
Define_Fuses
Override_Fuses;
COMport = USB;
FuseBits0 = [];
FuseBits1 = [SPIEN];
FuseBits2 = [];
ProgMode = SPI;
Import SysTick;
Import MIRF24port;
From System Import LongWord, LongInt, Float;
Define
ProcClock = 16000000; {Hertz}
SysTick = 10; {msec}
StackSize = $0064, iData;
FrameSize = $0064, iData;
// SCK, MOSI, MISO, SS, CE, IRQ
MIRF24port = SPI_Soft, PortC, 2, 3, 4, 1, 0, 5;
uses uMIRF24;
Implementation
{$IDATA}
{--------------------------------------------------------------}
{ Type Declarations }
{--------------------------------------------------------------}
{ Const Declarations }
{--------------------------------------------------------------}
{ Var Declarations }
Var
Poll [@PortB,0] :Bit;
txBuff : array[0..31] of byte;
txString[@txBuff] : string[30];
rxBuff : array[0..31] of byte;
rxString[@rxBuff] : string[30];
rxCnt : byte;
X : byte;
{--------------------------------------------------------------}
{ functions }
Procedure PollLED(mS:Word);
Begin
Poll:=False;
mDelay(mS);
Poll:=True;
mDelay(25);
End;
Procedure InitSystem;
Begin
DDRB := DDRB Or %00000001; // Output=1 Input=0
Poll:=True;
EnableInts;
mrfSetChan(mrfChan4, false);
mrfSetPower(mrfdBm0);
mrfSetLocalAddr(20);
mrfSetRetryMax(10);
mrfSetRetryTimeOut(3); // 5x 250usec -> 1.25msec
mrfSetRFspeed(mrfRF2000);
End;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}
begin
EnableInts;
InitSystem;
loop
PollLED(25);
if mrfInit then
loop
repeat
until (mrfGetRxType <> mrfPKTnone) Or (x<=0);
case mrfRxPacket(@rxBuff, 100, rxCnt) of
mrfPKTbcast : PollLED(25);PollLED(25);|
mrfPKTdata : If rxCnt=5 Then
If rxBuff[2]=Ord('2') Then
PollLED(15);
EndIf;
EndIf; |
EndCase;
endloop;
endif;
endloop;
end.