|
|
|
Component
USB
USB device bean
Methods:
(Methods are user-callable functions/subroutines intended for
the component functions control. Please see the Embedded Components page for more information.)
-
Enable
- This method enables the USB device. Device must be enabled to be detected by the host. This method is not used with MC68HC908LD64 (device is enabled by the host request only).
ANSIC prototype: byte Enable(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode.
-
Disable
- This method disables the USB device (disconnect D- pin internal pull-up). This method is not used with MC68HC908LD64 (device is disabled by the host request only).
ANSIC prototype: byte Disable(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode.
-
EnableEvent
- This method enables events OnTransmit and OnReceive.
ANSIC prototype: byte EnableEvent(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode.
-
DisableEvent
- This method disables events OnTransmit and OnReceive.
ANSIC prototype: byte DisableEvent(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode.
-
ForceRemoteWakeUp
- This method wakes-up the USB bus. The method wakes-up the USB bus only if wake-up feature is enabled by the host. This method is enabled only if device supports remote wake-up feature in some of its configurations.
ANSIC prototype: byte ForceRemoteWakeUp(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode. ERR_DISABLED - Device is disabled. ERR_HOST_DISABLED - Method is just now disabled by the host. ERR_NOTSUSPENDED - Device is not in SUSPEND state. ERR_NOT_CONFIGURED - Device is not configured.
-
EPHaltFeature
- Force or abort STALL handshake on selected endpoint (this method is not supported for the control endpoint zero).
ANSIC prototype: byte EPHaltFeature(byte EndpointAddress, bool ForceStall)
- EndpointAddress:byte - Addres of the endpoint.
- ForceStall:bool - true - Causes endpoint to return a STALL handshake when polled by either IN or OUT token by the USB host controller.
false - Cancels a STALL handshake.
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode. ERR_DISABLED - Device is disabled. ERR_SUSPENDED - Device is in SUSPEND state. ERR_NOT_CONFIGURED - Device is not configured. ERR_RANGE - Endpoint address out of range.
-
SendChar
- This method puts character into the output buffer. Character is sent to the host on the next IN token. This method is available only if at least one pipe has "Direction" property set to "IN".
ANSIC prototype: byte SendChar(byte EndpointAddress, byte Char)
- EndpointAddress:byte - Number of endpoint to send character.
- Char:byte - Character to send.
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode. ERR_DISABLED - Device is disabled. ERR_SUSPENDED - Device is in SUSPEND state. ERR_NOT_CONFIGURED - Device is not configured. ERR_TXFULL - Buffer is full. ERR_BUSY - Method SendBlock() is running. ERR_RANGE - Endpoint address out of range.
-
SendBlock
- This method transfers a block of bytes to the host. When a transfer involves more data than can fit in one data payload of the currently established maximum size, all data payloads are maximum-sized except for the last data payload, which will contain the remaining data. You can use this method to send zero length packet. Output buffer must be empty to start transfer (method returns ERR_BUSY if there are characters in output buffer). This method is available only if at least one pipe has "Direction" property set to "IN".
ANSIC prototype: byte SendBlock(byte *Ptr, word Size, byte EndpointAddress, bool Wait)
- Ptr: Pointer to byte - Pointer to the block of data to send.
- Size:word - Size of the block.
- EndpointAddress:byte - Number of endpoint to send block.
- Wait:bool - true - return after all data has been sent.
false- return immediately after start of the transfer. (Don't wait for result.)
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode. ERR_DISABLED - Device is disabled ERR_SUSPENDED - Device is in SUSPEND state. ERR_NOT_CONFIGURED - Device is not configured. ERR_RANGE - Endpoint address out of range. ERR_BUSY - Method is already running or characters sent by SendChar() method has not been sent yet.
- Methods for HC908JB8, HC908JB12, HC908JB16, MC68HC908JG16 and HC908JR32 derivatives.
-
RecvChar
- This method reads one character from internal buffer. This method is available only if at least one pipe has "Direction" property set to "OUT".
ANSIC prototype: byte RecvChar(byte EndpointAddress, byte *pChar)
- EndpointAddress:byte - Number of endpoint to receive character.
- pChar: Pointer to byte - Pointer to buffer for received character.
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode. ERR_DISABLED - Device is disabled. ERR_SUSPENDED - Device is in SUSPEND state. ERR_NOT_CONFIGURED - Device is not configured. ERR_RXEMPTY - Buffer is empty. ERR_RANGE - Endpoint address out of range.
-
RecvBlock
- This method reads the block of data. The method returns after required number of bytes has been read. This method is available only if at least one pipe has "Direction" property set to "OUT".
ANSIC prototype: byte RecvBlock(byte *Ptr, word Size, word *BytesReceived, byte EndpointAddress, byte Wait)
- Ptr: Pointer to byte - Pointer to the block to receive data to.
- Size:word - Size of the block.
- BytesReceived: Pointer to word - Pointer to variable to return the number of received bytes.
- EndpointAddress:byte - Number of endpoint to receive data.
- Wait:byte - true - return after required amount of data has been read.
false- return immediately after start of reading. (Don't wait for result.)
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode. ERR_DISABLED - Device is disabled ERR_SUSPENDED - Device is in SUSPEND state. ERR_NOT_CONFIGURED - Device is not configured. ERR_RANGE - Endpoint address out of range.
- Methods for HC908JB8, HC908JB12, HC908JB16, HC908JG16, HC908BD48 and HC908JR32 derivatives.
-
ChangePowerSource
- This method allows to inform the host about power source change.
ANSIC prototype: byte ChangePowerSource(bool BusPowered, byte MaxBusCurrentConsumption)
- BusPowered:bool - This parameter should be false (new power source is external power source) or true (device si powered from the USB).
- MaxBusCurrentConsumption:byte - Maximal power consumption (2 mA units) from the bus after power source has changed. (If this value is greater then value in cfg. descriptor ERR_POWER is returned.)
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode. ERR_DISABLED - Device is disabled ERR_POWER - Device requires more power from the bus then reported in this cfg. descriptor.
- Methods for HC908JB8, HC908JB12 HC908JB16 and HC908JG16 derivatives.
-
ForceUSBport
- This method forces the output level of the D+ pin and D- pin.
ANSIC prototype: byte ForceUSBport(bool output, bool dplus, bool dminus)
- output:bool - Enable/disable the USB output buffers. If the output buffers are disabled (false value of the output) other parameters are ignored.
- dplus:bool - Output level of the D+ pin.
- dminus:bool - Output level of the D- pin.
- Return value:byte - Error code, possible codes:
ERR_OK - OK. ERR_SPEED - Device does not work in the active speed mode. ERR_DISABLED - Device is disabled
Note: Some methods can be implemented as macros.
|