www.pudn.com > writemac.rar > dm643_led.c


/* 
 *  Copyright 2003 by Spectrum Digital Incorporated. 
 *  All rights reserved. Property of Spectrum Digital Incorporated. 
 */ 
  
/* 
 *  ======== dm643_led.c ======== 
 *  LED module for the DM643 
 */ 
  
#include  
//#include  
//#include  
 
#include "dm643.h" 
#include "dm643_led.h" 
 
 
 
void DM643_LED_init() 
{ 
    *(Uint32 *)MAPEN |= 0x4a000080; 
    *(Uint32 *)MAPDIR |= 0x4a000080; 
    /* Turn all LEDs off */ 
    *(Uint32 *)MAPDOUT |= 0x4a000000; 
} 
 
void DM643_LED_off(Uint32 ledNum) 
{ 
   switch(ledNum) 
    { 
       case 0: *(Uint32 *)MAPDOUT |= 0x4a000000; break; 
       case 1: *(Uint32 *)MAPDOUT |= 0x40000000; break; 
       case 2: *(Uint32 *)MAPDOUT |= 0x2000000; break; 
       case 3: *(Uint32 *)MAPDOUT |= 0x8000000; break;        
       default: return; 
     } 
}	 
 
void DM643_LED_on(Uint32 ledNum) 
{ 
	switch(ledNum) 
    { 
       case 0: *(Uint32 *)MAPDOUT &= 0xb5ffffff; break; 
       case 1: *(Uint32 *)MAPDOUT &= 0xbfffffff; break; 
       case 2: *(Uint32 *)MAPDOUT &= 0xfdffffff; break; 
       case 3: *(Uint32 *)MAPDOUT &= 0xf7ffffff; break;        
       default: return; 
     }   
} 
 
void DM643_LED_toggle(Uint32 ledNum) 
{ 
	Int32 ledstate; 
	switch(ledNum) 
    { 
       case 0: ledstate=*(Uint32 *)MAPDIN & 0x4a000000; break;  
       case 1: ledstate=*(Uint32 *)MAPDIN & 0x40000000; break;        
       case 2: ledstate=*(Uint32 *)MAPDIN & 0x2000000; break;  
       case 3: ledstate=*(Uint32 *)MAPDIN & 0x8000000; break;        
       default: return; 
     }   
      
     if (ledstate > 0) 
		DM643_LED_on(ledNum); 
	 else 
		DM643_LED_off(ledNum); 
}