program recepteur_RC5;

{$NOSHADOW}
{ $W+ Warnings}            {Warnings off}

Device = mega8, VCC = 5;

Import {SysTick,} RC5Rxport; //, LCDport;

From System Import;

Define
  ProcClock      = 8000000;        {Hertz}

  StackSize      = $0064, iData;
  FrameSize      = $0064, iData;

  RC5RxPort      = PinB, 2, negative;
  RC5mode        = rc_7bit; //rc_6bit = default

Implementation

{$IDATA}

{--------------------------------------------------------------}
{ Type Declarations }

type


{--------------------------------------------------------------}
{ Const Declarations }


{--------------------------------------------------------------}
{ Var Declarations }
{$IDATA}
var
  rxAdr          : byte;
  rxCmd          : byte;
  adr1           : integer;
  cmd1           : integer;
{--------------------------------------------------------------}
{procedures et functions }
procedure InitPorts;
begin
  DDRB:= %00000011;
  PortB:= $00;
  DDRC:= %00111111;
  PortC:= $00;
  DDRD:= %11111111;
  PortD:= $00;
end;

{--------------------------------------------------------------}
{ processes and tasks }


{--------------------------------------------------------------}
{ Main Program }
{$IDATA}

begin
  InitPorts;
  EnableInts;

  loop

    if RecvRC5(rxAdr, rxCmd) then
      adr1:= integer(rxAdr);
      cmd1:= 127 and integer(rxCmd);
    endif;

    case cmd1 of
      0  : PortD:= PortD or 1;
         |
      1  : PortD:= PortD or 2;
         |
      2  : PortD:= PortD or 4;
         |
      3  : PortD:= PortD or 8;
         |
      4  : PortD:= PortD or 16;
         |
      5  : PortD:= PortD or 32;
         |
      6  : PortD:= PortD or 64;
         |
      7  : PortD:= PortD or 128;
         |
      8  : PortC:= PortC or 1;
         |
      9  : PortC:= PortC or 2;
         |
      10 : PortC:= PortC or 4;       //10=touche 10+
         |
      12 : PortC:= PortC or 8;       //12=touche POWER    (13=toucheMUTE)
         |
      16 : PortC:= PortC or 16;      //volume+
         |
      17 : PortC:= PortC or 32;      //volume-
         |
      32 : PortB:= PortC or 1;       //PROGRAM+
         |
      33 : PortB:= PortC or 2;       //PROGRAM-
         |

  else PortD:= $00; PortC:= %00; PortB:= PortB and %00; endcase;

//    if cmd1<>255 then PortD:=byte(cmd1); endif;   //pour lire les codes directement

    mdelay(5);
    cmd1:= 255;

  endloop;
end recepteur_RC5.

