/*
 *  for MB9BF618T on FRK-FM3
 * 
 *   Copyright (C) by Y.Ishioka.
 */
#include <tk/tkernel.h>

#include <tk/sysdef.h>


/***********************************************************/
/*
 * LED port initialize
 */
void  led_init( void )
{
    out_w( GPIO_PFRF, in_w(GPIO_PFRF) & ~0x0008 ) ;  /* set GPIO to bit3 */
    out_w( GPIO_PCRF, in_w(GPIO_PCRF) & ~0x0008 ) ;  /* off pull-up to bit3 */
    out_w( GPIO_DDRF, in_w(GPIO_DDRF) |  0x0008 ) ;  /* set output mode to bit3 */

    out_w( GPIO_PDORF, in_w(GPIO_PDORF) | 0x0008 ) ; /* LED off */
}


/*
 * bit0 : 0 : LED OFF
 *        1 : LED ON
 */
void  led_set( unsigned int led )
{
    if( led & 0x00000001 ) {
        /* LED ON */
        out_w( GPIO_PDORF, (in_w(GPIO_PDORF)& ~0x00000008) ) ;
    } else {
        /* LED OFF */
        out_w( GPIO_PDORF, in_w(GPIO_PDORF) | 0x00000008 ) ;
    }
}

