284/317
9 - A Carrier-current System for domestIc Remote Control
InitPorts () ;
InitTimerA() ;
InitTimerB() ;
MISCR = 0x0 ;
/* Normal mode (clock/2). */
EnableInterrupts ;
LastDirection = STOP_OPEN ; /* to properly start manual cycle */
StopMotor () ;
/* To guarantee motor off at power on */
while (1)
{
if ( HOUSE_CODE == Codes[HouseCode] )
{
switch ( Codes[KeyCode] )
{
/* If code acceptable, energize one of the coils. */
/* They will be de-energized by timer interrupt. */
case CLOSE_COMMAND :
SwitchMotor ( START_CLOSE ) ;
break ;
case OPEN_COMMAND :
SwitchMotor ( START_OPEN ) ;
break ;
}
KeyCode = NO_COMMAND ;
/* Erase order. */
HouseCode = NO_COMMAND ;
/* Erase order. */
}
if ( ButtonPressed () )
/* Take into account the push button. It overrides the remote
control. */
switch ( LastDirection )
{
case START_OPEN :
SwitchMotor ( STOP_OPEN ) ;
break ;
case STOP_OPEN :
SwitchMotor ( START_CLOSE ) ;
break ;
case START_CLOSE :
SwitchMotor ( STOP_CLOSE ) ;
break ;
case STOP_CLOSE :
SwitchMotor ( START_OPEN ) ;
break ;
}
/* Update state when end-of travel automatic stop. */
switch ( LastDirection )
{
case START_OPEN :
if ( ReadADC ( MOTOR_ADC_CHANNEL ) < RUNNING_VOLTAGE )
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...