|
|
|
Component
USB
USB device bean
Events:
(Events are call-back functions called when an important event occurrs.
Please see the Embedded Components page for more information.)
-
EventModule
- Name of the user module (without extension), where the events from this component are placed.
-
BeforeNewSpeed
- This event is called when the CPU speed mode is being changed (using CPU methods) - before the change. The event is enabled only if speed modes are supported in the target CPU component (more than one speed mode).
ANSIC prototype: void BeforeNewSpeed(void)
-
AfterNewSpeed
- This event is called when the CPU speed mode is being changed (using CPU methods) - after the change. The event is enabled only if speed modes are supported in the target CPU component (more than one speed mode).
ANSIC prototype: void AfterNewSpeed(void)
-
OnTransmitt
- This event is generally invoked after the data stored in endpoint transmit buffers have been sent and an ACK handshake packet received from the host. When method SendBlock() is called, this event is invoked after all data have been sent and a last ACK handshake packet received from the host.
ANSIC prototype: void OnTransmitt(byte endpoint)
- endpoint:byte - Number of endpoint that generates this event.
-
OnConfigurationChange
- This event is invoked after the device has received SET_CONFIGURATION request and before ACK handshake is returned to the host. Data transfers are not possible until device is configured.
ANSIC prototype: void OnConfigurationChange(byte NewConfigurationNumber)
- NewConfigurationNumber:byte - Number of new confuguration.
-
OnIntfAltSetChange
- This event is invoked after the host has sent SET_INTERFACE request and before ACK handshake is returned to the host.
ANSIC prototype: void OnIntfAltSetChange(byte Interface, byte AlternateSetting)
- Interface:byte - Number of interface to set new alternate setting.
- AlternateSetting:byte - Number of new alternate setting.
-
OnReset
- This event is invoked after the reset signaling is removed. Devices must be able to accept a SetAddress() request (refer to Section 11.16.2 and Section 9.4 respectively of the USB Specification Rev. 1.1) after the reset recovery time 10ms (TRSTRCY) after the reset is removed. This event should be finished as quick as possible.
ANSIC prototype: void OnReset(void)
-
OnSuspend
- This event is invoked when device sees constant IDLE state on their upstream bus lines between 5 - 6 ms. The device must actually be suspended, drawing only suspend current from the bus after no more than 10 ms of bus inactivity on all its ports (refer to Section 7.1.7.4 of the USB Specification Rev. 1.1) You have up to 4 ms to decrease current consumption. This component needs no HW resources after this event is invoked.
ANSIC prototype: void OnSuspend(void)
-
OnResume
- This event is invoked on end of resume signaling.
ANSIC prototype: void OnResume(void)
- Events for HC908JB8, HC908JB12, HC908JB16, MC68HC908JG16 and HC908JR32 derivatives.
-
OnReceive
- This event is generally invoked after the USB module has received a data packet and responded with an ACK handshake packet. When method RecvBlock() is called, this event is invoked after all required data have been read and a last ACK handshake packet has been sent to the host of after a packet with a payload size less than wMaxPacketSize or a zero-length packet has been received and a ACK handshake packet sent to the host.
ANSIC prototype: void OnReceive(byte endpoint)
- endpoint:byte - Number of endpoint that generates this event.
-
OnNonStandardSetupPacket
- This event is invoked after the end of setup stage of the nonstandard device request. Setup data can be accessed through the global "SetupBuffer" variable.
If the request is not supported or to stall the pipe set return value to FALSE (*pRetVal=FALSE;) - STALL handshake will be return in the next stage of the control transfer. For nonstandard requests without data stage set size of the block to zero(*pBufferSize=0) and set return value to TRUE (*pRetVal=TRUE) - Zero-length data packet will be return to the host in the status stage of the control transfer. For nonstandard requests with device to host data stage (control read) specify address of the data block (*pDataToSend=address of_data), size of the block (*pBufferSize=Sizeof(data)) and set return value to TRUE (*pRetVal=TRUE). You can use event "OnNonStandardControlReadEnd()" to be informed about successful reception of the data by the host. BE SURE that buffer is accessible after return from this event - don't allocate buffer on the stack of this event. For nonstandard requests with host to device data stage (control write) specify address of the buffer (*pDataToSend=address_of_buffer), size of the buffer (*pBufferSize=Sizeof(buffer)) and set return value to TRUE (*pRetVal=TRUE). Event OnNonStandardControlWriteEnd(...) will be invoked after reception of required number of bytes.
ANSIC prototype: void OnNonStandardSetupPacket(byte **pDataToSend, word *pBufferSize, bool *pRetVal)
- pDataToSend:void* - Pointer to pointer on the data to be sent to the host.
- pBufferSize:word - Pointer to variable that specfies size of data to be sent to the host.
- pRetVal:bool - Pointer to variable that specfies result of command processing.
-
OnNonStandardControlWriteEnd
- This event is invoked after successful data stage of control write transaction.
ANSIC prototype: void OnNonStandardControlWriteEnd(bool Overflow, bool *Result)
- Overflow:bool - This parametr is set to true if the host send more data then is the size of buffer provided by the user.
- Result:bool - Pointer to variable to specify the result of command processing. If set to false(*Result=false) control endpoint will be stalled. If set to true, zero-length data packet will be send to the host in the status stage of this transfer.
-
OnNonStandardControlReadEnd
- This event is invoked after successful status stage of control read transfer. You can use this method for example to free memory allocated in OnNonStandardSetupPacket() event for control read transfer.
ANSIC prototype: void OnNonStandardControlReadEnd(void)
For each generated event it is possible to set:
- Procedure Name - name of procedure (written by user) that handles the event.
|