?? led.c
字號(hào):
/*******************************************************************************
Ledc
********************************************************************************
Written by: Bennie de Wet
nSoft Developement.
********************************************************************************
Version
0.00aA 12 Aug 04 BDW Cleaning up
0.00aB 14 Aug 04 BDW Patching in data handeling
0.00aD 15 Sep 04 BDW Making build compatible with new Protocessors
0.00aG 08 Oct 04 BDW Preping for first release to Douglas
*******************************************************************************/
#include <fst.h>
#if defined ( P18F6720 )
#include <p18f6720.h>
#elif defined (P18F6520)
#include <p18f6520.h>
#else
#error must defined P18F6X20 compiler option
#endif
//LED Ports on the Protocessor(18f6x20)
#define DDR_LEDS DDRA
#define LEDS PORTA
#define WORKING PORTAbits.RA0
#define PANIC PORTAbits.RA2 // Not connected at this time
#define LED_ON 0
#define LED_OFF 1
//=============================================================================
VOID tk_panic ( INT error )
{
static INT tst = 0 ;
tst++;
}
//=============================================================================
static BYTE led_state = 0x07 ; // Leds off by default
VOID led_init()
{
DDR_LEDS = 0 ; // LED port all outputs
LEDS = led_state ;
}
//=============================================================================
VOID led_on ( INT nr )
{
BYTE mask = ~( 1 << nr ) & 0x07; // Only want first 3 bits
led_state &= mask ;
LEDS = led_state ;
}
//=============================================================================
VOID led_off ( INT nr )
{
BYTE mask = ( 1 << nr ) & 0x07; // Only want first 3 bits
led_state |= mask ;
LEDS = led_state ;
}
//=============================================================================
VOID led_toggle ( INT nr )
{
if ( (led_state>>nr) & 0x1 )
{
led_on(nr);
}
else
{
led_off(nr);
}
}
//=============================================================================
VOID led_run ( )
{
static UINT32 start_time = 0 ;
if ( !start_time )
{
start_time = get_milliseconds();
}
if ( get_milliseconds () - start_time > (UINT32)200 )
{
led_toggle(0);
start_time = get_milliseconds();
}
}
//=============================================================================
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -