/******************************************************************************* * Function Name: ChargeDelay_WritePeriod ******************************************************************************** * * Summary: * This function is used to change the period of the counter. The new period * will be loaded the next time terminal count is detected. * * Parameters: * period: Period value. May be between 1 and (2^Resolution)-1. A value of 0 * will result in the counter remaining at zero. * * Return: * None * *******************************************************************************/ void ChargeDelay_WritePeriod(uint8 period) { #if(ChargeDelay_UsingFixedFunction) CY_SET_REG16(ChargeDelay_PERIOD_LSB_PTR, (uint16)period); #else CY_SET_REG8(ChargeDelay_PERIOD_LSB_PTR, period); #endif /* (ChargeDelay_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: ChargeDelay_WriteCompare ******************************************************************************** * * Summary: * This funtion is used to change the compare1 value when the PWM is in Dither * mode. The compare output will reflect the new value on the next UDB clock. * The compare output will be driven high when the present counter value is * compared to the compare value based on the compare mode defined in * Dither Mode. * * Parameters: * compare: New compare value. * * Return: * None * * Side Effects: * This function is only available if the PWM mode parameter is set to * Dither Mode, Center Aligned Mode or One Output Mode * *******************************************************************************/ void ChargeDelay_WriteCompare(uint8 compare) \ { #if(ChargeDelay_UsingFixedFunction) CY_SET_REG16(ChargeDelay_COMPARE1_LSB_PTR, (uint16)compare); #else CY_SET_REG8(ChargeDelay_COMPARE1_LSB_PTR, compare); #endif /* (ChargeDelay_UsingFixedFunction) */ #if (ChargeDelay_PWMMode == ChargeDelay__B_PWM__DITHER) #if(ChargeDelay_UsingFixedFunction) CY_SET_REG16(ChargeDelay_COMPARE2_LSB_PTR, (uint16)(compare + 1u)); #else CY_SET_REG8(ChargeDelay_COMPARE2_LSB_PTR, (compare + 1u)); #endif /* (ChargeDelay_UsingFixedFunction) */ #endif /* (ChargeDelay_PWMMode == ChargeDelay__B_PWM__DITHER) */ }
/******************************************************************************* * Function Name: QuadDecoder_Cnt8_WritePeriod ******************************************************************************** * Summary: * Changes the period of the counter. The new period * will be loaded the next time terminal count is detected. * * Parameters: * period: (uint8) A value of 0 will result in * the counter remaining at zero. * * Return: * void * *******************************************************************************/ void QuadDecoder_Cnt8_WritePeriod(uint8 period) { #if(QuadDecoder_Cnt8_UsingFixedFunction) CY_SET_REG16(QuadDecoder_Cnt8_PERIOD_LSB_PTR,(uint16)period); #else CY_SET_REG8(QuadDecoder_Cnt8_PERIOD_LSB_PTR, period); #endif /* (QuadDecoder_Cnt8_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: PWM_B_WriteCompare ******************************************************************************** * * Summary: * This funtion is used to change the compare1 value when the PWM is in Dither * mode. The compare output will reflect the new value on the next UDB clock. * The compare output will be driven high when the present counter value is * compared to the compare value based on the compare mode defined in * Dither Mode. * * Parameters: * compare: New compare value. * * Return: * None * * Side Effects: * This function is only available if the PWM mode parameter is set to * Dither Mode, Center Aligned Mode or One Output Mode * *******************************************************************************/ void PWM_B_WriteCompare(uint8 compare) \ { #if(PWM_B_UsingFixedFunction) CY_SET_REG16(PWM_B_COMPARE1_LSB_PTR, (uint16)compare); #else CY_SET_REG8(PWM_B_COMPARE1_LSB_PTR, compare); #endif /* (PWM_B_UsingFixedFunction) */ #if (PWM_B_PWMMode == PWM_B__B_PWM__DITHER) #if(PWM_B_UsingFixedFunction) CY_SET_REG16(PWM_B_COMPARE2_LSB_PTR, (uint16)(compare + 1u)); #else CY_SET_REG8(PWM_B_COMPARE2_LSB_PTR, (compare + 1u)); #endif /* (PWM_B_UsingFixedFunction) */ #endif /* (PWM_B_PWMMode == PWM_B__B_PWM__DITHER) */ }
/******************************************************************************* * Function Name: PWM_WritePeriod ******************************************************************************** * * Summary: * This function is used to change the period of the counter. The new period * will be loaded the next time terminal count is detected. * * Parameters: * period: Period value. May be between 1 and (2^Resolution)-1. A value of 0 * will result in the counter remaining at zero. * * Return: * None * *******************************************************************************/ void PWM_WritePeriod(uint8 period) { #if(PWM_UsingFixedFunction) CY_SET_REG16(PWM_PERIOD_LSB_PTR, (uint16)period); #else CY_SET_REG8(PWM_PERIOD_LSB_PTR, period); #endif /* (PWM_UsingFixedFunction) */ }
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable) { if (!enable) CY_SET_REG8(obj->inttypeReg, 0x0); else if (event == IRQ_RISE) CY_SET_REG8(obj->inttypeReg, 0x01); else if (event == IRQ_FALL) CY_SET_REG8(obj->inttypeReg, 0x02); else if (event == (IRQ_FALL | IRQ_RISE)) CY_SET_REG8(obj->inttypeReg, 0x03); else debug("Did not set any interrupt handler type!\r\n"); obj->intTypeValue = CY_GET_REG8(obj->inttypeReg); CyIntSetVector(obj->irqLine, handle_interrupt_in); CyIntEnable(obj->irqLine); }
/******************************************************************************* * Function Name: QuadDecoder_Cnt8_WriteCompare ******************************************************************************** * Summary: * Changes the compare value. The compare output will * reflect the new value on the next UDB clock. The compare output will be * driven high when the present counter value compares true based on the * configured compare mode setting. * * Parameters: * Compare: New compare value. * * Return: * void * *******************************************************************************/ void QuadDecoder_Cnt8_WriteCompare(uint8 compare) \ { #if(QuadDecoder_Cnt8_UsingFixedFunction) CY_SET_REG16(QuadDecoder_Cnt8_COMPARE_LSB_PTR, (uint16)compare); #else CY_SET_REG8(QuadDecoder_Cnt8_COMPARE_LSB_PTR, compare); #endif /* (QuadDecoder_Cnt8_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: ChargeDelay_WriteCompare2 ******************************************************************************** * * Summary: * This funtion is used to change the compare value, for compare1 output. * The compare output will reflect the new value on the next UDB clock. * The compare output will be driven high when the present counter value is * less than or less than or equal to the compare register, depending on the * mode. * * Parameters: * compare: New compare value. * * Return: * None * *******************************************************************************/ void ChargeDelay_WriteCompare2(uint8 compare) \ { #if(ChargeDelay_UsingFixedFunction) CY_SET_REG16(ChargeDelay_COMPARE2_LSB_PTR, compare); #else CY_SET_REG8(ChargeDelay_COMPARE2_LSB_PTR, compare); #endif /* (ChargeDelay_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: USBFS_1_CheckActivity ******************************************************************************** * * Summary: * Returns the activity status of the bus. Clears the status hardware to * provide fresh activity status on the next call of this routine. * * Parameters: * None. * * Return: * 1 - If bus activity was detected since the last call to this function * 0 - If bus activity not was detected since the last call to this function * *******************************************************************************/ uint8 USBFS_1_CheckActivity(void) { uint8 r; r = CY_GET_REG8(USBFS_1_CR1_PTR); CY_SET_REG8(USBFS_1_CR1_PTR, (r & ((uint8)(~USBFS_1_CR1_BUS_ACTIVITY)))); return((r & USBFS_1_CR1_BUS_ACTIVITY) >> USBFS_1_CR1_BUS_ACTIVITY_SHIFT); }
/******************************************************************************* * Function Name: LED_SEG_PWM_WriteCompare1 ******************************************************************************** * * Summary: * This funtion is used to change the compare1 value. The compare output will * reflect the new value on the next UDB clock. The compare output will be * driven high when the present counter value is less than or less than or * equal to the compare register, depending on the mode. * * Parameters: * compare: New compare value. * * Return: * None * *******************************************************************************/ void LED_SEG_PWM_WriteCompare1(uint8 compare) \ { #if(LED_SEG_PWM_UsingFixedFunction) CY_SET_REG16(LED_SEG_PWM_COMPARE1_LSB_PTR, (uint16)compare); #else CY_SET_REG8(LED_SEG_PWM_COMPARE1_LSB_PTR, compare); #endif /* (LED_SEG_PWM_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: MotorPWM_WriteCompare2 ******************************************************************************** * * Summary: * This funtion is used to change the compare value, for compare1 output. * The compare output will reflect the new value on the next UDB clock. * The compare output will be driven high when the present counter value is * less than or less than or equal to the compare register, depending on the * mode. * * Parameters: * compare: New compare value. * * Return: * None * *******************************************************************************/ void MotorPWM_WriteCompare2(uint8 compare) \ { #if(MotorPWM_UsingFixedFunction) CY_SET_REG16(MotorPWM_COMPARE2_LSB_PTR, compare); #else CY_SET_REG8(MotorPWM_COMPARE2_LSB_PTR, compare); #endif /* (MotorPWM_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: TIMER_ThreadTimer_WritePeriod ******************************************************************************** * * Summary: * This function is used to change the period of the counter. The new period * will be loaded the next time terminal count is detected. * * Parameters: * period: This value may be between 1 and (2^Resolution)-1. A value of 0 will * result in the counter remaining at zero. * * Return: * void * *******************************************************************************/ void TIMER_ThreadTimer_WritePeriod(uint8 period) { #if(TIMER_ThreadTimer_UsingFixedFunction) uint16 period_temp = (uint16)period; CY_SET_REG16(TIMER_ThreadTimer_PERIOD_LSB_PTR, period_temp); #else CY_SET_REG8(TIMER_ThreadTimer_PERIOD_LSB_PTR, period); #endif /*Write Period value with appropriate resolution suffix depending on UDB or fixed function implementation */ }
/******************************************************************************* * Function Name: Counter_reset_gen_WriteCompare ******************************************************************************** * Summary: * Changes the compare value. The compare output will * reflect the new value on the next UDB clock. The compare output will be * driven high when the present counter value compares true based on the * configured compare mode setting. * * Parameters: * Compare: New compare value. * * Return: * void * *******************************************************************************/ void Counter_reset_gen_WriteCompare(uint8 compare) \ { #if(Counter_reset_gen_UsingFixedFunction) CY_SET_REG16(Counter_reset_gen_COMPARE_LSB_PTR, (uint16)compare); #else CY_SET_REG8(Counter_reset_gen_COMPARE_LSB_PTR, compare); #endif /* (Counter_reset_gen_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: PWM_3_WriteCompare2 ******************************************************************************** * * Summary: * This funtion is used to change the compare value, for compare1 output. * The compare output will reflect the new value on the next UDB clock. * The compare output will be driven high when the present counter value is * less than or less than or equal to the compare register, depending on the * mode. * * Parameters: * compare: New compare value. * * Return: * None * *******************************************************************************/ void PWM_3_WriteCompare2(uint8 compare) \ { #if(PWM_3_UsingFixedFunction) CY_SET_REG16(PWM_3_COMPARE2_LSB_PTR, compare); #else CY_SET_REG8(PWM_3_COMPARE2_LSB_PTR, compare); #endif /* (PWM_3_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: PWM_BC_WriteCompare1 ******************************************************************************** * * Summary: * This funtion is used to change the compare1 value. The compare output will * reflect the new value on the next UDB clock. The compare output will be * driven high when the present counter value is less than or less than or * equal to the compare register, depending on the mode. * * Parameters: * compare: New compare value. * * Return: * None * *******************************************************************************/ void PWM_BC_WriteCompare1(uint8 compare) \ { #if(PWM_BC_UsingFixedFunction) CY_SET_REG16(PWM_BC_COMPARE1_LSB_PTR, (uint16)compare); #else CY_SET_REG8(PWM_BC_COMPARE1_LSB_PTR, compare); #endif /* (PWM_BC_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: hallTickCounter_WriteCompare ******************************************************************************** * Summary: * Changes the compare value. The compare output will * reflect the new value on the next UDB clock. The compare output will be * driven high when the present counter value compares true based on the * configured compare mode setting. * * Parameters: * Compare: New compare value. * * Return: * void * *******************************************************************************/ void hallTickCounter_WriteCompare(uint8 compare) \ { #if(hallTickCounter_UsingFixedFunction) CY_SET_REG16(hallTickCounter_COMPARE_LSB_PTR, (uint16)compare); #else CY_SET_REG8(hallTickCounter_COMPARE_LSB_PTR, compare); #endif /* (hallTickCounter_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: pwm_WriteCompare2 ******************************************************************************** * * Summary: * This funtion is used to change the compare value, for compare1 output. * The compare output will reflect the new value on the next UDB clock. * The compare output will be driven high when the present counter value is * less than or less than or equal to the compare register, depending on the * mode. * * Parameters: * compare: New compare value. * * Return: * None * *******************************************************************************/ void pwm_WriteCompare2(uint8 compare) \ { #if(pwm_UsingFixedFunction) CY_SET_REG16(pwm_COMPARE2_LSB_PTR, compare); #else CY_SET_REG8(pwm_COMPARE2_LSB_PTR, compare); #endif /* (pwm_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: Timer_2_WriteCounter ******************************************************************************** * * Summary: * This funtion is used to set the counter to a specific value * * Parameters: * counter: New counter value. * * Return: * void * *******************************************************************************/ void Timer_2_WriteCounter(uint8 counter) { #if(Timer_2_UsingFixedFunction) /* This functionality is removed until a FixedFunction HW update to * allow this register to be written */ CY_SET_REG16(Timer_2_COUNTER_LSB_PTR, (uint16)counter); #else CY_SET_REG8(Timer_2_COUNTER_LSB_PTR, counter); #endif /* Set Write Counter only for the UDB implementation (Write Counter not available in fixed function Timer */ }
/******************************************************************************* * Function Name: pwm_right_WriteDeadTime ******************************************************************************** * * Summary: * This function writes the dead-band counts to the corresponding register * * Parameters: * deadtime: Number of counts for dead time * * Return: * void * * Reentrant: * Yes * *******************************************************************************/ void pwm_right_WriteDeadTime(uint8 deadtime) { /* If using the Dead Band 1-255 mode then just write the register */ #if(!pwm_right_DeadBand2_4) CY_SET_REG8(pwm_right_DEADBAND_COUNT_PTR, deadtime); #else /* Otherwise the data has to be masked and offset */ /* Clear existing data */ pwm_right_DEADBAND_COUNT &= ~pwm_right_DEADBAND_COUNT_MASK; /* Set new dead time */ pwm_right_DEADBAND_COUNT |= (deadtime << pwm_right_DEADBAND_COUNT_SHIFT) & pwm_right_DEADBAND_COUNT_MASK; #endif }
/******************************************************************************* * Function Name: Counter_reset_gen_WriteCounter ******************************************************************************** * Summary: * This funtion is used to set the counter to a specific value * * Parameters: * counter: New counter value. * * Return: * void * *******************************************************************************/ void Counter_reset_gen_WriteCounter(uint8 counter) \ { #if(Counter_reset_gen_UsingFixedFunction) /* assert if block is already enabled */ CYASSERT (0u == (Counter_reset_gen_GLOBAL_ENABLE & Counter_reset_gen_BLOCK_EN_MASK)); /* If block is disabled, enable it and then write the counter */ Counter_reset_gen_GLOBAL_ENABLE |= Counter_reset_gen_BLOCK_EN_MASK; CY_SET_REG16(Counter_reset_gen_COUNTER_LSB_PTR, (uint16)counter); Counter_reset_gen_GLOBAL_ENABLE &= ((uint8)(~Counter_reset_gen_BLOCK_EN_MASK)); #else CY_SET_REG8(Counter_reset_gen_COUNTER_LSB_PTR, counter); #endif /* (Counter_reset_gen_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: hallTickCounter_WriteCounter ******************************************************************************** * Summary: * This funtion is used to set the counter to a specific value * * Parameters: * counter: New counter value. * * Return: * void * *******************************************************************************/ void hallTickCounter_WriteCounter(uint8 counter) \ { #if(hallTickCounter_UsingFixedFunction) /* assert if block is already enabled */ CYASSERT (0u == (hallTickCounter_GLOBAL_ENABLE & hallTickCounter_BLOCK_EN_MASK)); /* If block is disabled, enable it and then write the counter */ hallTickCounter_GLOBAL_ENABLE |= hallTickCounter_BLOCK_EN_MASK; CY_SET_REG16(hallTickCounter_COUNTER_LSB_PTR, (uint16)counter); hallTickCounter_GLOBAL_ENABLE &= ((uint8)(~hallTickCounter_BLOCK_EN_MASK)); #else CY_SET_REG8(hallTickCounter_COUNTER_LSB_PTR, counter); #endif /* (hallTickCounter_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: QuadDecoder_Cnt8_WriteCounter ******************************************************************************** * Summary: * This funtion is used to set the counter to a specific value * * Parameters: * counter: New counter value. * * Return: * void * *******************************************************************************/ void QuadDecoder_Cnt8_WriteCounter(uint8 counter) \ { #if(QuadDecoder_Cnt8_UsingFixedFunction) /* assert if block is already enabled */ CYASSERT (0u == (QuadDecoder_Cnt8_GLOBAL_ENABLE & QuadDecoder_Cnt8_BLOCK_EN_MASK)); /* If block is disabled, enable it and then write the counter */ QuadDecoder_Cnt8_GLOBAL_ENABLE |= QuadDecoder_Cnt8_BLOCK_EN_MASK; CY_SET_REG16(QuadDecoder_Cnt8_COUNTER_LSB_PTR, (uint16)counter); QuadDecoder_Cnt8_GLOBAL_ENABLE &= ((uint8)(~QuadDecoder_Cnt8_BLOCK_EN_MASK)); #else CY_SET_REG8(QuadDecoder_Cnt8_COUNTER_LSB_PTR, counter); #endif /* (QuadDecoder_Cnt8_UsingFixedFunction) */ }
void scsiPhyInit() { scsiPhyInitDMA(); SCSI_RST_ISR_StartEx(scsiResetISR); SCSI_SEL_ISR_StartEx(scsiSelectionISR); // Disable the glitch filter for ACK to improve performance. if (scsiDev.boardCfg.flags & CONFIG_DISABLE_GLITCH) { SCSI_Glitch_Ctl_Write(1); CY_SET_REG8(scsiTarget_datapath__D0_REG, 0); } }
/******************************************************************************* * Function Name: USB_Bootloader_NoDataControlStatusStage ******************************************************************************** * Summary: * Handle the Status Stage of a no data control transfer. * * SET_ADDRESS is special, since we need to receive the status stage with * the old address. * * Parameters: * None. * * Return: * None. * * Global variables: * USB_Bootloader_transferState - set to TRANS_STATE_IDLE. * USB_Bootloader_ep0Mode - set to MODE_STALL_IN_OUT. * USB_Bootloader_ep0Toggle - set to EP0_CNT_DATA_TOGGLE * USB_Bootloader_deviceAddress - used to set new address and cleared * * Reentrant: * No. * *******************************************************************************/ void USB_Bootloader_NoDataControlStatusStage(void) { /* Change the USB address register if we got a SET_ADDRESS. */ if (USB_Bootloader_deviceAddress != 0u) { CY_SET_REG8(USB_Bootloader_CR0_PTR, USB_Bootloader_deviceAddress | USB_Bootloader_CR0_ENABLE); USB_Bootloader_deviceAddress = 0u; } /* Go Idle */ USB_Bootloader_transferState = USB_Bootloader_TRANS_STATE_IDLE; /* Update the completion block */ USB_Bootloader_UpdateStatusBlock(USB_Bootloader_XFER_STATUS_ACK); /* We expect no more data, so stall INs and OUTs */ USB_Bootloader_ep0Mode = USB_Bootloader_MODE_STALL_IN_OUT; }
int uart1_putc(char c) { if (c == '\n') uart1_putc('\r'); while (CY_GET_REG8(CYDEV_ITM_BASE) == 0); CY_SET_REG8(CYDEV_ITM_BASE,c); #ifndef MINIMALISTIC // Copy to buffer if there's at least one byte available // (write ptr is >= readptr or write ptr is < readptr-1) if((log_ring_write>=log_ring_read) || ((log_ring_write<(log_ring_read-1)) && (log_ring_read!=0))) { log_ring[log_ring_write]=c; log_ring_write++; if(log_ring_write==LOGRINGSIZE) log_ring_write=0; } #endif return 0; }
/******************************************************************************* * Function Name: PWM_3_WriteDeadTime ******************************************************************************** * * Summary: * This function writes the dead-band counts to the corresponding register * * Parameters: * deadtime: Number of counts for dead time * * Return: * None * *******************************************************************************/ void PWM_3_WriteDeadTime(uint8 deadtime) { /* If using the Dead Band 1-255 mode then just write the register */ #if(!PWM_3_DeadBand2_4) CY_SET_REG8(PWM_3_DEADBAND_COUNT_PTR, deadtime); #else /* Otherwise the data has to be masked and offset */ /* Clear existing data */ PWM_3_DEADBAND_COUNT &= ((uint8)(~PWM_3_DEADBAND_COUNT_MASK)); /* Set new dead time */ #if(PWM_3_DEADBAND_COUNT_SHIFT) PWM_3_DEADBAND_COUNT |= ((uint8)((uint8)deadtime << PWM_3_DEADBAND_COUNT_SHIFT)) & PWM_3_DEADBAND_COUNT_MASK; #else PWM_3_DEADBAND_COUNT |= deadtime & PWM_3_DEADBAND_COUNT_MASK; #endif /* (PWM_3_DEADBAND_COUNT_SHIFT) */ #endif /* (!PWM_3_DeadBand2_4) */ }
/******************************************************************************* * Function Name: USB_Bootloader_HandleSetup ******************************************************************************** * * Summary: * This Routine dispatches requests for the four USB request types * * Parameters: * None. * * Return: * None. * * Reentrant: * No. * *******************************************************************************/ void USB_Bootloader_HandleSetup(void) { uint8 requestHandled; requestHandled = CY_GET_REG8(USB_Bootloader_EP0_CR_PTR); /* unlock registers */ CY_SET_REG8(USB_Bootloader_EP0_CR_PTR, requestHandled); /* clear setup bit */ requestHandled = CY_GET_REG8(USB_Bootloader_EP0_CR_PTR); /* reread register */ if((requestHandled & USB_Bootloader_MODE_SETUP_RCVD) != 0u) { USB_Bootloader_ep0Mode = requestHandled; /* if SETUP bit set -> exit without modifying the mode */ } else { /* In case the previous transfer did not complete, close it out */ USB_Bootloader_UpdateStatusBlock(USB_Bootloader_XFER_PREMATURE); switch (CY_GET_REG8(USB_Bootloader_bmRequestType) & USB_Bootloader_RQST_TYPE_MASK) { case USB_Bootloader_RQST_TYPE_STD: requestHandled = USB_Bootloader_HandleStandardRqst(); break; case USB_Bootloader_RQST_TYPE_CLS: requestHandled = USB_Bootloader_DispatchClassRqst(); break; case USB_Bootloader_RQST_TYPE_VND: requestHandled = USB_Bootloader_HandleVendorRqst(); break; default: requestHandled = USB_Bootloader_FALSE; break; } if (requestHandled == USB_Bootloader_FALSE) { USB_Bootloader_ep0Mode = USB_Bootloader_MODE_STALL_IN_OUT; } } }
/******************************************************************************* * Function Name: USB_Bootloader_LoadEP0 ******************************************************************************** * * Summary: * This routine loads the EP0 data registers for OUT transfers. It uses the * currentTD (previously initialized by the _InitControlWrite function and * updated for each OUT transfer, and the bLastPacketSize) to determine how * many uint8s to transfer on the current OUT. * * If the number of uint8s remaining is zero and the last transfer was full, * we need to send a zero length packet. Otherwise we send the minimum * of the control endpoint size (8) or remaining number of uint8s for the * transaction. * * Parameters: * None. * * Return: * None. * * Global variables: * USB_Bootloader_transferByteCount - Update the transfer byte count from the * last transaction. * USB_Bootloader_ep0Count - counts the data loaded to the SIE memory in * current packet. * USB_Bootloader_lastPacketSize - remembers the USBFS_ep0Count value for the * next packet. * USB_Bootloader_transferByteCount - sum of the previous bytes transferred * on previous packets(sum of USBFS_lastPacketSize) * USB_Bootloader_ep0Toggle - inverted * USB_Bootloader_ep0Mode - prepare for mode register content. * USB_Bootloader_transferState - set to TRANS_STATE_CONTROL_READ * * Reentrant: * No. * *******************************************************************************/ void USB_Bootloader_LoadEP0(void) { uint8 ep0Count = 0u; /* Update the transfer byte count from the last transaction */ USB_Bootloader_transferByteCount += USB_Bootloader_lastPacketSize; /* Now load the next transaction */ while ((USB_Bootloader_currentTD.count > 0u) && (ep0Count < 8u)) { CY_SET_REG8((reg8 *)(USB_Bootloader_EP0_DR0_IND + ep0Count), *USB_Bootloader_currentTD.pData); USB_Bootloader_currentTD.pData = &USB_Bootloader_currentTD.pData[1u]; ep0Count++; USB_Bootloader_currentTD.count--; } /* Support zero-length packet*/ if( (USB_Bootloader_lastPacketSize == 8u) || (ep0Count > 0u) ) { /* Update the data toggle */ USB_Bootloader_ep0Toggle ^= USB_Bootloader_EP0_CNT_DATA_TOGGLE; /* Set the Mode Register */ USB_Bootloader_ep0Mode = USB_Bootloader_MODE_ACK_IN_STATUS_OUT; /* Update the state (or stay the same) */ USB_Bootloader_transferState = USB_Bootloader_TRANS_STATE_CONTROL_READ; } else { /* Expect Status Stage Out */ USB_Bootloader_ep0Mode = USB_Bootloader_MODE_STATUS_OUT_ONLY; /* Update the state (or stay the same) */ USB_Bootloader_transferState = USB_Bootloader_TRANS_STATE_CONTROL_READ; } /* Save the packet size for next time */ USB_Bootloader_lastPacketSize = ep0Count; USB_Bootloader_ep0Count = ep0Count; }
/******************************************************************************* * Function Name: PWM_3_WriteKillTime ******************************************************************************** * * Summary: * Writes the kill time value used by the hardware when the Kill Mode * is set to Minimum Time. * * Parameters: * uint8: Minimum Time kill counts * * Return: * None * *******************************************************************************/ void PWM_3_WriteKillTime(uint8 killtime) { CY_SET_REG8(PWM_3_KILLMODEMINTIME_PTR, killtime); }
/******************************************************************************* * Function Name: PWM_3_WriteControlRegister ******************************************************************************** * * Summary: * Sets the bit field of the control register. This API is available only if * the control register is not removed. * * Parameters: * uint8 control: Control register bit field, The status register bits are: * [7] : PWM Enable * [6] : Reset * [5:3] : Compare Mode2 * [2:0] : Compare Mode2 * * Return: * None * *******************************************************************************/ void PWM_3_WriteControlRegister(uint8 control) { CY_SET_REG8(PWM_3_CONTROL_PTR, control); }