Exemplo n.º 1
0
/*
** ===================================================================
**     Method      :  LedB_SetDir (component BitIO)
**
**     Description :
**         This method sets direction of the bean.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Dir        - Direction to set (FALSE or TRUE)
**                      FALSE = Input, TRUE = Output
**     Returns     : Nothing
** ===================================================================
*/
void LedB_SetDir(bool Dir)
{
  if (Dir) {
    setReg8(PTBD, (getReg8(PTBD) & (~0x08)) | (Shadow_PTB & 0x08)); /* PTBD3=Shadow_PTB[bit 3] */
    setReg8Bits(PTBDD, 0x08);          /* PTBDD3=0x01 */
  } else { /* !Dir */
    clrReg8Bits(PTBDD, 0x08);          /* PTBDD3=0x00 */
  } /* !Dir */
}
Exemplo n.º 2
0
/*
** ===================================================================
**     Method      :  statusLED_SetDir (component BitIO)
**     Description :
**         This method sets direction of the component.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Dir        - Direction to set (FALSE or TRUE)
**                      FALSE = Input, TRUE = Output
**     Returns     : Nothing
** ===================================================================
*/
void statusLED_SetDir(bool Dir)
{
  if (Dir) {
    setReg8(PTGD, (getReg8(PTGD) & (byte)(~(byte)0x01U)) | (Shadow_PTG & 0x01U)); /* PTGD0=Shadow_PTG[bit 0] */
    setReg8Bits(PTGDD, 0x01U);         /* PTGDD0=0x01U */
  } else { /* !Dir */
    clrReg8Bits(PTGDD, 0x01U);         /* PTGDD0=0x00U */
  } /* !Dir */
}
Exemplo n.º 3
0
/*
** ===================================================================
**     Method      :  M_1_Enable (component PWM)
**     Description :
**         This method enables the component - it starts the signal
**         generation. Events may be generated (<DisableEvent>
**         /<EnableEvent>).
**     Parameters  : None
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
byte M_1_Enable(void)
{
  (void)getReg8(TPM1SC);               /* Dummy read of the TPM1SC register to reset flag */
  /* TPM1SC: TOF=0,TOIE=1 */
  clrSetReg8Bits(TPM1SC, 0x80U, 0x40U); /* Clear Overflow interrupt flag and enable Overflow interrupt */ 
  /* TPM1C1SC: CH1F=0,CH1IE=0,MS1B=1,MS1A=1,ELS1B=1,ELS1A=1,??=0,??=0 */
  setReg8(TPM1C1SC, 0x3CU);            /* Set up PWM mode with output signal level low */ 
  return ERR_OK;                       /* OK */
}
Exemplo n.º 4
0
/*
** ===================================================================
**     Method      :  powerLED_SetDir (component BitIO)
**     Description :
**         This method sets direction of the component.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Dir        - Direction to set (FALSE or TRUE)
**                      FALSE = Input, TRUE = Output
**     Returns     : Nothing
** ===================================================================
*/
void powerLED_SetDir(bool Dir)
{
  if (Dir) {
    setReg8(PTGD, (getReg8(PTGD) & (byte)(~(byte)0x02U)) | (Shadow_PTG & 0x02U)); /* PTGD1=Shadow_PTG[bit 1] */
    setReg8Bits(PTGDD, 0x02U);         /* PTGDD1=0x01U */
  } else { /* !Dir */
    clrReg8Bits(PTGDD, 0x02U);         /* PTGDD1=0x00U */
  } /* !Dir */
}
Exemplo n.º 5
0
/** Set the value in a 8bit register using a mask */
int setReg8Mask(CAMERA_DEVICE *dev,unsigned char reg_id, unsigned char value, unsigned char mask)
{
	int				ret;
	unsigned char	current, final;

	ret = getReg8(dev, reg_id, &current);

	if (ret < 0) return -1;

	current	&= (~mask);
	value	&= mask;
	final	 = current | value;
Exemplo n.º 6
0
/*
** ===================================================================
**     Method      :  M_1_Init (component PWM)
**
**     Description :
**         Initializes the associated peripheral(s) and the components 
**         internal variables. The method is called automatically as a 
**         part of the application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void M_1_Init(void)
{
  /* TPM1SC: TOF=0,TOIE=0,CPWMS=0,CLKSB=0,CLKSA=0,PS2=0,PS1=0,PS0=0 */
  setReg8(TPM1SC, 0x00U);              /* Disable device */ 
  /* TPM1C1SC: CH1F=0,CH1IE=0,MS1B=1,MS1A=1,ELS1B=1,ELS1A=1,??=0,??=0 */
  setReg8(TPM1C1SC, 0x3CU);            /* Set up PWM mode with output signal level low */ 
  ActualRatio.Value = 0xFFFFU;         /* Store initial value of the ratio */
  /* TPM1MOD: BIT15=1,BIT14=1,BIT13=1,BIT12=1,BIT11=0,BIT10=1,BIT9=0,BIT8=1,BIT7=1,BIT6=1,BIT5=0,BIT4=0,BIT3=0,BIT2=0,BIT1=1,BIT0=0 */
  setReg16(TPM1MOD, 0xF5C2U);          /* Set modulo register */ 
  SetRatio();                          /* Calculate and set up new values of the compare according to the selected speed CPU mode */
  (void)getReg8(TPM1SC);               /* Dummy read of the TPM1SC register to reset flag */
  /* TPM1SC: TOF=0,TOIE=1 */
  clrSetReg8Bits(TPM1SC, 0x80U, 0x40U); /* Clear Overflow interrupt flag and enable Overflow interrupt */ 
}
Exemplo n.º 7
0
Arquivo: E.c Projeto: ducis/HCS
/*
** ===================================================================
**     Method      :  E_GetBit (bean ByteIO)
**
**     Description :
**         This method returns the specified bit of the input value.
**           a) direction = Input  : reads the input value from pins
**                                   and returns the specified bit
**           b) direction = Output : returns the specified bit
**                                   of the last written value
**         Note: This bean is set to work in Input direction only.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to read (0 to 7)
**     Returns     :
**         ---        - Value of the specified bit (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
** ===================================================================
*/
bool E_GetBit(byte Bit)
{
  byte const Mask = E_GetMsk(Bit);     /* Temporary variable - bit mask to test */
  return (bool)((getReg8(PORTE) & Mask) == Mask); /* Test if specified bit of port data register is set */
}
Exemplo n.º 8
0
/*
** ===================================================================
**     Method      :  hwLed_GetVal (bean BitsIO)
**
**     Description :
**         This method returns an input value.
**           a) direction = Input  : reads the input value from the
**                                   pins and returns it
**           b) direction = Output : returns the last written value
**         Note: This bean is set to work in Output direction only.
**     Parameters  : None
**     Returns     :
**         ---        - Input value (0 to 7)
** ===================================================================
*/
byte hwLed_GetVal(void)
{
  return (byte)((getReg8(PTED) & 0xE0) >> 5); /* Return port data */
}
Exemplo n.º 9
0
/*
** ===================================================================
**     Method      :  hwLed_PutVal (bean BitsIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val        - Output value (0 to 7)
**     Returns     : Nothing
** ===================================================================
*/
void hwLed_PutVal(byte Val)
{
  Val = (byte)((Val & 0x07) << 5);     /* Mask and shift output value */
  setReg8(PTED, (getReg8(PTED) & (~0xE0)) | Val); /* Put masked value on port */
}
Exemplo n.º 10
0
/*
** ===================================================================
**     Method      :  Fingers_GetVal (component BitsIO)
**
**     Description :
**         This method returns an input value.
**           a) direction = Input  : reads the input value from the
**                                   pins and returns it
**           b) direction = Output : returns the last written value
**         Note: This component is set to work in Input direction only.
**     Parameters  : None
**     Returns     :
**         ---        - Input value (0 to 7)
** ===================================================================
*/
byte Fingers_GetVal(void)
{
  return (byte)(getReg8(PTBD) & 0x07U); /* Return port data */
}
Exemplo n.º 11
0
/*
** ===================================================================
**     Method      :  Fingers_GetBit (component BitsIO)
**
**     Description :
**         This method returns the specified bit of the input value.
**           a) direction = Input  : reads the input value from pins
**                                   and returns the specified bit
**           b) direction = Output : returns the specified bit
**                                   of the last written value
**         Note: This component is set to work in Input direction only.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to read (0 to 2)
**     Returns     :
**         ---        - Value of the specified bit (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
** ===================================================================
*/
bool Fingers_GetBit(byte Bit)
{
  byte const Mask = Fingers_GetMsk(Bit); /* Temporary variable - bit mask to test */
  return (bool)(((getReg8(PTBD) & Mask) == Mask)? 1U: 0U); /* Test if specified bit of port register is set */
}
Exemplo n.º 12
0
/*
** ===================================================================
**     Method      :  LED_RUN_GetVal (component BitIO)
**     Description :
**         This method returns an input value.
**           a) direction = Input  : reads the input value from the
**                                   pin and returns it
**           b) direction = Output : returns the last written value
**         Note: This component is set to work in Output direction only.
**     Parameters  : None
**     Returns     :
**         ---             - Input value. Possible values:
**                           FALSE - logical "0" (Low level)
**                           TRUE - logical "1" (High level)

** ===================================================================
*/
bool LED_RUN_GetVal(void)
{
  return (bool)((getReg8(PORT_PTAD) & 0x01U)); /* Return port data */
}