Exemplo n.º 1
0
/*******************************************************************************
* Function Name: HeartbeatCounter_ReadPeriod
********************************************************************************
* Summary:
* Reads the current period value without affecting counter operation.
*
* Parameters:  
*  void:  
*
* Return: 
*  (uint32) Present period value.
*
*******************************************************************************/
uint32 HeartbeatCounter_ReadPeriod(void) 
{
    #if(HeartbeatCounter_UsingFixedFunction)
        return ((uint32)CY_GET_REG16(HeartbeatCounter_PERIOD_LSB_PTR));
    #else
        return (CY_GET_REG32(HeartbeatCounter_PERIOD_LSB_PTR));
    #endif /* (HeartbeatCounter_UsingFixedFunction) */
}
/*******************************************************************************
* Function Name: hallTickTimer_ReadPeriod
********************************************************************************
*
* Summary:
*  This function returns the current value of the Period.
*
* Parameters:
*  void
*
* Return:
*  The present value of the counter.
*
*******************************************************************************/
uint32 hallTickTimer_ReadPeriod(void) 
{
   #if(hallTickTimer_UsingFixedFunction)
       return ((uint32)CY_GET_REG16(hallTickTimer_PERIOD_LSB_PTR));
   #else
       return (CY_GET_REG32(hallTickTimer_PERIOD_LSB_PTR));
   #endif /* (hallTickTimer_UsingFixedFunction) */
}
Exemplo n.º 3
0
/*******************************************************************************
* Function Name: Timer_Look_ahead_mode_ReadCapture
********************************************************************************
*
* Summary:
*  This function returns the last value captured.
*
* Parameters:
*  void
*
* Return:
*  Present Capture value.
*
*******************************************************************************/
uint32 Timer_Look_ahead_mode_ReadCapture(void) 
{
   #if(Timer_Look_ahead_mode_UsingFixedFunction)
       return ((uint32)CY_GET_REG16(Timer_Look_ahead_mode_CAPTURE_LSB_PTR));
   #else
       return (CY_GET_REG24(Timer_Look_ahead_mode_CAPTURE_LSB_PTR));
   #endif /* (Timer_Look_ahead_mode_UsingFixedFunction) */
}
Exemplo n.º 4
0
/*******************************************************************************
* Function Name: HeartbeatCounter_ReadCapture
********************************************************************************
* Summary:
*   This function returns the last value captured.
*
* Parameters:  
*  void
*
* Return: 
*  (uint32) Present Capture value.
*
*******************************************************************************/
uint32 HeartbeatCounter_ReadCapture(void) 
{
    #if(HeartbeatCounter_UsingFixedFunction)
        return ((uint32)CY_GET_REG16(HeartbeatCounter_STATICCOUNT_LSB_PTR));
    #else
        return (CY_GET_REG32(HeartbeatCounter_STATICCOUNT_LSB_PTR));
    #endif /* (HeartbeatCounter_UsingFixedFunction) */
}
Exemplo n.º 5
0
/*******************************************************************************
* Function Name: ChargeDelay_ReadPeriod
********************************************************************************
*
* Summary:
*  Reads the period value used by the PWM hardware.
*
* Parameters:
*  None
*
* Return:
*  uint8/16: Period value
*
*******************************************************************************/
uint8 ChargeDelay_ReadPeriod(void) 
{
    #if(ChargeDelay_UsingFixedFunction)
        return ((uint8)CY_GET_REG16(ChargeDelay_PERIOD_LSB_PTR));
    #else
        return (CY_GET_REG8(ChargeDelay_PERIOD_LSB_PTR));
    #endif /* (ChargeDelay_UsingFixedFunction) */
}
Exemplo n.º 6
0
/*******************************************************************************
* Function Name: Timer_Look_ahead_mode_ReadPeriod
********************************************************************************
*
* Summary:
*  This function returns the current value of the Period.
*
* Parameters:
*  void
*
* Return:
*  The present value of the counter.
*
*******************************************************************************/
uint32 Timer_Look_ahead_mode_ReadPeriod(void) 
{
   #if(Timer_Look_ahead_mode_UsingFixedFunction)
       return ((uint32)CY_GET_REG16(Timer_Look_ahead_mode_PERIOD_LSB_PTR));
   #else
       return (CY_GET_REG24(Timer_Look_ahead_mode_PERIOD_LSB_PTR));
   #endif /* (Timer_Look_ahead_mode_UsingFixedFunction) */
}
Exemplo n.º 7
0
/*******************************************************************************
* Function Name: QuadDecoder_Cnt8_ReadPeriod
********************************************************************************
* Summary:
* Reads the current period value without affecting counter operation.
*
* Parameters:  
*  void:  
*
* Return: 
*  (uint8) Present period value.
*
*******************************************************************************/
uint8 QuadDecoder_Cnt8_ReadPeriod(void) 
{
    #if(QuadDecoder_Cnt8_UsingFixedFunction)
        return ((uint8)CY_GET_REG16(QuadDecoder_Cnt8_PERIOD_LSB_PTR));
    #else
        return (CY_GET_REG8(QuadDecoder_Cnt8_PERIOD_LSB_PTR));
    #endif /* (QuadDecoder_Cnt8_UsingFixedFunction) */
}
Exemplo n.º 8
0
 /*******************************************************************************
 * Function Name: ChargeDelay_ReadCompare
 ********************************************************************************
 *
 * Summary:
 *  Reads the compare value for the compare output when the PWM Mode parameter is
 *  set to Dither mode, Center Aligned mode, or One Output mode.
 *
 * Parameters:
 *  None
 *
 * Return:
 *  uint8/uint16: Current compare value
 *
 *******************************************************************************/
 uint8 ChargeDelay_ReadCompare(void) 
 {
     #if(ChargeDelay_UsingFixedFunction)
         return ((uint8)CY_GET_REG16(ChargeDelay_COMPARE1_LSB_PTR));
     #else
         return (CY_GET_REG8(ChargeDelay_COMPARE1_LSB_PTR));
     #endif /* (ChargeDelay_UsingFixedFunction) */
 }
Exemplo n.º 9
0
/*******************************************************************************
* Function Name: TimerC_ReadCapture
********************************************************************************
*
* Summary:
*  This function returns the last value captured.
*
* Parameters:
*  void
*
* Return:
*  Present Capture value.
*
*******************************************************************************/
uint8 TimerC_ReadCapture(void) 
{
   #if(TimerC_UsingFixedFunction)
       return ((uint8)CY_GET_REG16(TimerC_CAPTURE_LSB_PTR));
   #else
       return (CY_GET_REG8(TimerC_CAPTURE_LSB_PTR));
   #endif /* (TimerC_UsingFixedFunction) */
}
Exemplo n.º 10
0
/*******************************************************************************
* Function Name: QuadDecoder_Cnt8_ReadCapture
********************************************************************************
* Summary:
*   This function returns the last value captured.
*
* Parameters:  
*  void
*
* Return: 
*  (uint8) Present Capture value.
*
*******************************************************************************/
uint8 QuadDecoder_Cnt8_ReadCapture(void) 
{
    #if(QuadDecoder_Cnt8_UsingFixedFunction)
        return ((uint8)CY_GET_REG16(QuadDecoder_Cnt8_STATICCOUNT_LSB_PTR));
    #else
        return (CY_GET_REG8(QuadDecoder_Cnt8_STATICCOUNT_LSB_PTR));
    #endif /* (QuadDecoder_Cnt8_UsingFixedFunction) */
}
Exemplo n.º 11
0
/*******************************************************************************
* Function Name: OSC1_Freq_Timer_3_ReadCapture
********************************************************************************
*
* Summary:
*  This function returns the last value captured.
*
* Parameters:
*  void
*
* Return:
*  Present Capture value.
*
*******************************************************************************/
uint32 OSC1_Freq_Timer_3_ReadCapture(void) 
{
   #if(OSC1_Freq_Timer_3_UsingFixedFunction)
       return ((uint32)CY_GET_REG16(OSC1_Freq_Timer_3_CAPTURE_LSB_PTR));
   #else
       return (CY_GET_REG24(OSC1_Freq_Timer_3_CAPTURE_LSB_PTR));
   #endif /* (OSC1_Freq_Timer_3_UsingFixedFunction) */
}
Exemplo n.º 12
0
/*******************************************************************************
* Function Name: OSC1_Freq_Timer_3_ReadPeriod
********************************************************************************
*
* Summary:
*  This function returns the current value of the Period.
*
* Parameters:
*  void
*
* Return:
*  The present value of the counter.
*
*******************************************************************************/
uint32 OSC1_Freq_Timer_3_ReadPeriod(void) 
{
   #if(OSC1_Freq_Timer_3_UsingFixedFunction)
       return ((uint32)CY_GET_REG16(OSC1_Freq_Timer_3_PERIOD_LSB_PTR));
   #else
       return (CY_GET_REG24(OSC1_Freq_Timer_3_PERIOD_LSB_PTR));
   #endif /* (OSC1_Freq_Timer_3_UsingFixedFunction) */
}
Exemplo n.º 13
0
/*******************************************************************************
* Function Name: MotorPWM_ReadPeriod
********************************************************************************
*
* Summary:
*  Reads the period value used by the PWM hardware.
*
* Parameters:
*  None
*
* Return:
*  uint8/16: Period value
*
*******************************************************************************/
uint8 MotorPWM_ReadPeriod(void) 
{
    #if(MotorPWM_UsingFixedFunction)
        return ((uint8)CY_GET_REG16(MotorPWM_PERIOD_LSB_PTR));
    #else
        return (CY_GET_REG8(MotorPWM_PERIOD_LSB_PTR));
    #endif /* (MotorPWM_UsingFixedFunction) */
}
Exemplo n.º 14
0
 /*******************************************************************************
 * Function Name: MotorPWM_ReadCompare
 ********************************************************************************
 *
 * Summary:
 *  Reads the compare value for the compare output when the PWM Mode parameter is
 *  set to Dither mode, Center Aligned mode, or One Output mode.
 *
 * Parameters:
 *  None
 *
 * Return:
 *  uint8/uint16: Current compare value
 *
 *******************************************************************************/
 uint8 MotorPWM_ReadCompare(void) 
 {
     #if(MotorPWM_UsingFixedFunction)
         return ((uint8)CY_GET_REG16(MotorPWM_COMPARE1_LSB_PTR));
     #else
         return (CY_GET_REG8(MotorPWM_COMPARE1_LSB_PTR));
     #endif /* (MotorPWM_UsingFixedFunction) */
 }
/*******************************************************************************
* Function Name: hallTickTimer_ReadCapture
********************************************************************************
*
* Summary:
*  This function returns the last value captured.
*
* Parameters:
*  void
*
* Return:
*  Present Capture value.
*
*******************************************************************************/
uint32 hallTickTimer_ReadCapture(void) 
{
   #if(hallTickTimer_UsingFixedFunction)
       return ((uint32)CY_GET_REG16(hallTickTimer_CAPTURE_LSB_PTR));
   #else
       return (CY_GET_REG32(hallTickTimer_CAPTURE_LSB_PTR));
   #endif /* (hallTickTimer_UsingFixedFunction) */
}
Exemplo n.º 16
0
/*******************************************************************************
* Function Name: LED_SEG_PWM_ReadPeriod
********************************************************************************
*
* Summary:
*  Reads the period value used by the PWM hardware.
*
* Parameters:
*  None
*
* Return:
*  uint8/16: Period value
*
*******************************************************************************/
uint8 LED_SEG_PWM_ReadPeriod(void)
{
#if(LED_SEG_PWM_UsingFixedFunction)
    return ((uint8)CY_GET_REG16(LED_SEG_PWM_PERIOD_LSB_PTR));
#else
    return (CY_GET_REG8(LED_SEG_PWM_PERIOD_LSB_PTR));
#endif /* (LED_SEG_PWM_UsingFixedFunction) */
}
Exemplo n.º 17
0
/*******************************************************************************
* Function Name: PWM_BC_ReadPeriod
********************************************************************************
* 
* Summary:
*  Reads the period value used by the PWM hardware.
*
* Parameters:  
*  None
*
* Return: 
*  uint8/16: Period value
*
*******************************************************************************/ 
uint8 PWM_BC_ReadPeriod(void) 
{
	#if(PWM_BC_UsingFixedFunction)
        return ((uint8)CY_GET_REG16(PWM_BC_PERIOD_LSB_PTR));
    #else
        return (CY_GET_REG8(PWM_BC_PERIOD_LSB_PTR));
    #endif /* (PWM_BC_UsingFixedFunction) */
}
/*******************************************************************************
* Function Name: Left_Phase_Counter_ReadCapture
********************************************************************************
* Summary:
*   This function returns the last value captured.
*
* Parameters:  
*  void
*
* Return: 
*  (uint32) Present Capture value.
*
*******************************************************************************/
uint32 Left_Phase_Counter_ReadCapture(void) 
{
    #if(Left_Phase_Counter_UsingFixedFunction)
        return ((uint32)CY_GET_REG16(Left_Phase_Counter_STATICCOUNT_LSB_PTR));
    #else
        return (CY_GET_REG32(Left_Phase_Counter_STATICCOUNT_LSB_PTR));
    #endif /* (Left_Phase_Counter_UsingFixedFunction) */
}
Exemplo n.º 19
0
/*******************************************************************************
* Function Name: Counter_1_ReadPeriod
********************************************************************************
* Summary:
* Reads the current period value without affecting counter operation.
*
* Parameters:
*  void:
*
* Return:
*  (uint8) Present period value.
*
*******************************************************************************/
uint8 Counter_1_ReadPeriod(void)
{
#if(Counter_1_UsingFixedFunction)
    return ((uint8)CY_GET_REG16(Counter_1_PERIOD_LSB_PTR));
#else
    return (CY_GET_REG8(Counter_1_PERIOD_LSB_PTR));
#endif /* (Counter_1_UsingFixedFunction) */
}
Exemplo n.º 20
0
    /*******************************************************************************
    * Function Name: PWM_BC_ReadCompare
    ********************************************************************************
    * 
    * Summary:
    *  Reads the compare value for the compare output when the PWM Mode parameter is 
    *  set to Dither mode, Center Aligned mode, or One Output mode.
    *
    * Parameters:  
    *  None
    *
    * Return: 
    *  uint8/uint16: Current compare value
    *
    *******************************************************************************/  
    uint8 PWM_BC_ReadCompare(void)  
    {
		#if(PWM_BC_UsingFixedFunction)
            return ((uint8)CY_GET_REG16(PWM_BC_COMPARE1_LSB_PTR));
        #else
            return (CY_GET_REG8(PWM_BC_COMPARE1_LSB_PTR));
        #endif /* (PWM_BC_UsingFixedFunction) */
    }
Exemplo n.º 21
0
/*******************************************************************************
* Function Name: Counter_1_ReadCapture
********************************************************************************
* Summary:
*   This function returns the last value captured.
*
* Parameters:
*  void
*
* Return:
*  (uint8) Present Capture value.
*
*******************************************************************************/
uint8 Counter_1_ReadCapture(void)
{
#if(Counter_1_UsingFixedFunction)
    return ((uint8)CY_GET_REG16(Counter_1_STATICCOUNT_LSB_PTR));
#else
    return (CY_GET_REG8(Counter_1_STATICCOUNT_LSB_PTR));
#endif /* (Counter_1_UsingFixedFunction) */
}
Exemplo n.º 22
0
Arquivo: ADC.c Projeto: GSejas/Control
/*******************************************************************************
* Function Name: ADC_GetResult16
********************************************************************************
*
* Summary:
*  Returns a 16-bit result for a conversion with a result that has a resolution
*  of 8 to 12 bits.
*  ADC_IsEndConversion() should be called to verify that the data
*   sample is ready
*
* Parameters:
*  None.
*
* Return:
*  The 16-bit result of the last ADC conversion
*
* Global Variables:
*  ADC_shift - used to convert the ADC counts to the 2s
*  compliment form.
*
* Side Effects:
*  Converts the ADC counts to the 2s complement form.
*
*******************************************************************************/
int16 ADC_GetResult16( void )
{
    uint16 res;

    res = CY_GET_REG16(ADC_SAR_WRK_PTR);

    return( (int16)res - ADC_shift );
}
/*******************************************************************************
* Function Name: hallTickCounter_ReadPeriod
********************************************************************************
* Summary:
* Reads the current period value without affecting counter operation.
*
* Parameters:  
*  void:  
*
* Return: 
*  (uint8) Present period value.
*
*******************************************************************************/
uint8 hallTickCounter_ReadPeriod(void) 
{
    #if(hallTickCounter_UsingFixedFunction)
        return ((uint8)CY_GET_REG16(hallTickCounter_PERIOD_LSB_PTR));
    #else
        return (CY_GET_REG8(hallTickCounter_PERIOD_LSB_PTR));
    #endif /* (hallTickCounter_UsingFixedFunction) */
}
/*******************************************************************************
* Function Name: hallTickCounter_ReadCapture
********************************************************************************
* Summary:
*   This function returns the last value captured.
*
* Parameters:  
*  void
*
* Return: 
*  (uint8) Present Capture value.
*
*******************************************************************************/
uint8 hallTickCounter_ReadCapture(void) 
{
    #if(hallTickCounter_UsingFixedFunction)
        return ((uint8)CY_GET_REG16(hallTickCounter_STATICCOUNT_LSB_PTR));
    #else
        return (CY_GET_REG8(hallTickCounter_STATICCOUNT_LSB_PTR));
    #endif /* (hallTickCounter_UsingFixedFunction) */
}
Exemplo n.º 25
0
/*******************************************************************************
* Function Name: Wave_Timer_ReadCounter
********************************************************************************
*
* Summary:
*  This function returns the current counter value.
*
* Parameters:
*  void
*
* Return:
*  Present compare value.
*
*******************************************************************************/
uint16 Wave_Timer_ReadCounter(void) 
{
    /* Force capture by reading Accumulator */
    /* Must first do a software capture to be able to read the counter */
    /* It is up to the user code to make sure there isn't already captured data in the FIFO */
    #if(Wave_Timer_UsingFixedFunction)
        (void)CY_GET_REG16(Wave_Timer_COUNTER_LSB_PTR);
    #else
        (void)CY_GET_REG8(Wave_Timer_COUNTER_LSB_PTR_8BIT);
    #endif/* (Wave_Timer_UsingFixedFunction) */

    /* Read the data from the FIFO (or capture register for Fixed Function)*/
    #if(Wave_Timer_UsingFixedFunction)
        return ((uint16)CY_GET_REG16(Wave_Timer_CAPTURE_LSB_PTR));
    #else
        return (CY_GET_REG16(Wave_Timer_CAPTURE_LSB_PTR));
    #endif /* (Wave_Timer_UsingFixedFunction) */
}
Exemplo n.º 26
0
/*******************************************************************************
* Function Name: Wave_Timer_SoftwareCapture
********************************************************************************
*
* Summary:
*  This function forces a capture independent of the capture signal.
*
* Parameters:
*  void
*
* Return:
*  void
*
* Side Effects:
*  An existing hardware capture could be overwritten.
*
*******************************************************************************/
void Wave_Timer_SoftwareCapture(void) 
{
    /* Generate a software capture by reading the counter register */
    #if(Wave_Timer_UsingFixedFunction)
        (void)CY_GET_REG16(Wave_Timer_COUNTER_LSB_PTR);
    #else
        (void)CY_GET_REG8(Wave_Timer_COUNTER_LSB_PTR_8BIT);
    #endif/* (Wave_Timer_UsingFixedFunction) */
    /* Capture Data is now in the FIFO */
}
Exemplo n.º 27
0
/*******************************************************************************
* Function Name: Counter_ReadCounter
********************************************************************************
* Summary:
* Returns the current value of the counter.  It doesn't matter
* if the counter is enabled or running.
*
* Parameters:
*  void:
*
* Return:
*  (uint16) The present value of the counter.
*
* Reentrant
*  Yes
*
*******************************************************************************/
uint16 Counter_ReadCounter(void)
{
    /* Force capture by reading Accumulator */
    /* Must first do a software capture to be able to read the counter */
    /* It is up to the user code to make sure there isn't already captured data in the FIFO */
    CY_GET_REG8(Counter_COUNTER_LSB_PTR);

    /* Read the data from the FIFO (or capture register for Fixed Function)*/
    return (CY_GET_REG16(Counter_STATICCOUNT_LSB_PTR));
}
Exemplo n.º 28
0
 /*******************************************************************************
 * Function Name: PWM_LED_B_ReadCounter
 ********************************************************************************
 * 
 * Summary:
 *  This function returns the current value of the counter.  It doesn't matter
 *  if the counter is enabled or running.
 *
 * Parameters:  
 *  None  
 *
 * Return: 
 *  The current value of the counter.
 *
 *******************************************************************************/
 uint16 PWM_LED_B_ReadCounter(void) 
 {
     /* Force capture by reading Accumulator */
     /* Must first do a software capture to be able to read the counter */
     /* It is up to the user code to make sure there isn't already captured data in the FIFO */
     (void)PWM_LED_B_COUNTERCAP_LSB;
     
     /* Read the data from the FIFO (or capture register for Fixed Function)*/
     return (CY_GET_REG16(PWM_LED_B_CAPTURE_LSB_PTR));
 }
Exemplo n.º 29
0
/*******************************************************************************
* Function Name: PWM_ReadCounter
********************************************************************************
*
* Summary:
*  This function returns the current value of the counter.  It doesn't matter
*  if the counter is enabled or running.
*
* Parameters:
*  None
*
* Return:
*  The current value of the counter.
*
*******************************************************************************/
uint16 PWM_ReadCounter(void)
{
    /* Force capture by reading Accumulator */
    /* Must first do a software capture to be able to read the counter */
    /* It is up to the user code to make sure there isn't already captured data in the FIFO */
    (void)CY_GET_REG8(PWM_COUNTERCAP_LSB_PTR_8BIT);

    /* Read the data from the FIFO */
    return (CY_GET_REG16(PWM_CAPTURE_LSB_PTR));
}
Exemplo n.º 30
0
/*******************************************************************************
* Function Name: LED_SaveConfig
********************************************************************************
*
* Summary:
*  Saves the current user configuration.
*  
* Parameters:  
*  None.
*
* Return: 
*  None.
*
* Global Variables:
*  LED_backup - modified when non-retention registers are saved.
*
* Reentrant:
*  No.
*
*******************************************************************************/
void LED_SaveConfig(void) 
{
    #if (CY_UDB_V0)
        #if(!LED_PULSE_TYPE_HARDCODED)
            LED_backup.cr = LED_CONTROL_REG;
        #endif /* End LED_PULSE_TYPE_HARDCODED */
        LED_backup.seed = LED_ReadSeed();
        LED_backup.seed_copy = CY_GET_REG16(LED_SEED_COPY_PTR);
        LED_backup.polynom = LED_ReadPolynomial();
        LED_backup.density0 = LED_ReadPulse0();
        LED_backup.density1 = LED_ReadPulse1();
    #else /* CY_UDB_V1 */
        #if(!LED_PULSE_TYPE_HARDCODED)
            LED_backup.cr = LED_CONTROL_REG;
        #endif /* End LED_PULSE_TYPE_HARDCODED */
        LED_backup.seed = LED_ReadSeed();
        LED_backup.seed_copy = CY_GET_REG16(LED_SEED_COPY_PTR);
        LED_backup.polynom = LED_ReadPolynomial();
    #endif  /* CY_UDB_V0 */
}