Prototype - Boids Demo Mac OS

There is no developer bigger than Adobe when it comes to designing. Adobe XD, the UI prototype designer is another example of that only. This is a vector-based tool, which is quite useful for putting up a prototype, tools for interactions, transitions, and other dynamic functions, etc. As it is a vector-based tool, it is easy to resize the.

Mac OS X Developer Preview (retroactively referred to as Developer Preview 1 or DP1) was the first of four developer releases of Mac OS X. 1 Interface 2 Included applications 3 External links Mac OS X DP's interface did not yet adopt the Aqua interface used today. Instead, the Platinum interface from Mac OS 8 (and earlier on, from Copland) was still used. The system font remained primarily. Boids is an artificial life simulation originally developed by Craig Reynolds. The aim of the simulation was to replicate the behavior of flocks of birds. Instead of controlling the interactions of an entire flock, however, the Boids simulation only specifies the behavior of each individual bird.

The original Macintosh was a relatively simple machine, now of interest for its simplicity and for the fact that it was the first computer produced by Apple under the name Macintosh. The Macintosh used standard off-the-shelf components to the greatest extent possible, achieving a moderate price point by mixing complex LSI chips, readily customizable programmable array logic, and off-the-shelf components.

Overall architecture[edit]

The Macintosh used the Motorola 68000. The 68000's bus was wired directly to the other programmable components of the computer: the IWM floppy controller, the Zilog 8530 SCC, and the MOS Technology 6522.

The bus also connected the 68000 to the 128 or 512 KiB of main memory (DRAM), which was shared between the processor and the multimedia circuits in a direct memory access (DMA) arrangement. Either the processor or the video/sound engine could access the memory, but not both, resulting in up to a 10% loss in performance; the DMA circuit also performed necessary maintenance on the RAM which would otherwise add overhead, a trick previously used in the Apple II.

Precise timing information was relayed to the 68000 by interrupts. The 68000 provides three interrupt inputs, which in the Macintosh 128K/512K were connected to the 6522, the 8530, and a human input designed for programmers, in order of increasing priority. Thus typing on the keyboard (attached to the 6522) did not reduce serial data (8530) performance, yet the program controlling the serial bus could be debugged by the programmer.

To further reduce the cost of manufacture, as compared with its predecessor the Lisa, Apple did not include an MMU. As a result the Macintosh did not support protected memory, and this feature remained absent from the OS until 2001 with the Mac OS X operating system.

According to Andy Hertzfeld the Macintosh used for the introduction demo on January 24, 1984 was a prototype with 512k RAM, even though the first model offered for sale implemented just 128k of non-expandable memory. This prototype was used to provide adequate RAM to run the memory-intensive demo, which showcased speech synthesis software intended to impress the crowd.[1]

Components[edit]

This is a comprehensive list of the integrated circuits in the original Macintosh:

  • a MotorolaMC68000microprocessor at clock speed 7.8336 MHz
  • 64 or 128 KB of ROM in two chips containing parts of the operating system
  • 128 KB of RAM in 16 chips
  • eight TTL chips implementing a video and sound DMA controller, plus
    • two TTL chips providing a 16-bit video buffer (74166 type)
    • one PAL chip generating video timing signals (LAG)
    • two TTL chips providing an 8-bit Pulse-width modulation sound driver (74LS161 type)
    • two analog chips providing sound amplification (MC14016 switch, LF353 op-amp)
  • a Zilog 8530 chip controlling two RS-422 buses through two driver chips
  • an Integrated Woz Machine 400 KB floppy disk controller plus support PAL (ASG)
  • a 6522 VIA bridge chip connecting to the keyboard and clock
    • an Apple real-time clock chip plus a 32.768 kHzquartz oscillator
    • an Intel 8021 microcontroller in the keyboard
  • bus control and extra logic including
    • two PAL chips to activate the other chips (BMU0/1)
    • two PAL chips to convert the 16 MHz clock to other timing signals (TSM, TSG)
    • two TTL chips buffering the RAM to the 68000 (74LS244 type)
    • some inverters (74LS04 type)

This personal computer was implemented in four special-purpose LSI chips, six MSI PALs, 19 chips of standard SSI/MSI logic and analog circuits, plus memory. Most of the simpler chips would be consolidated into a few custom chips in the next generation, much reducing cost.

Features[edit]

The above components implemented the Macintosh GUI and networking as described below.

Mouse[edit]

The centerpiece of the new interface was mouse-driven control. The mouse contained only electromechanical components: a button, and two optical encoders. The button was connected to the 6522. The encoders' four outputs were connected two to the 8530 and two to the 6522.

The optical encoders detected movement by quadrature. Each encoder had a wheel with radial stripes which would interrupt the light passing between an LED and a light-detecting photodiode, producing electrical pulses with mouse movement. Both the X and the Y encoders were turned by frictional contact with the mouse ball. Two pairs of emitters and detectors were used on each encoder. Portage mac os. A first set of pulses is enough to detect the rate of rotation without indicating the direction of rotation, and a second set of synchronized but 90° out of phase pulses provides the direction of rotation. Therefore, two emitter-detector pairs were used for X and Y each.

The motion detection signals connected to the 8530 chip using two non-essential pins used for obsolete modems. Originally these signaled modem connection or disconnection. When the mouse moved by a certain amount, the model connect/disconnect signal would change state and the 8530 would interrupt the processor. The operating system would then read the direction signals from the 6522 to differentiate left from right, and up from down, and move the mouse cursor.

Cursor and video[edit]

The mouse cursor was drawn on the screen by software, as were all other on-screen objects. To support real-time animation the screen timing PAL circuit would send a pulse to the 6522 once per vertical retrace. This was the basis for an operating system service called the VBL (vertical blanking) Manager. When the screen was to be redrawn, the cursor would be moved and games had an opportunity to update the display.

It could sometimes be difficult to avoid a race condition between a game and the raster display. Flicker could result from the processor writing to the image while it was being sent to the CRT. Therefore, the Macintosh provided a choice of two images in memory, so one could be read while the other was written. The 'page' was selected by a general-purpose I/O output connected from the 6522 to the video DMA. As two images added up to 42.75 KiB of precious RAM, however, this feature was unpopular.

The DMA graphics controller operated independently and autonomously. One-bit pixels were fetched sixteen at a time over a 16-bit data bus and output at just less 16 MHz, necessitating almost one million fetches per second. Each fetch took one memory access cycle out of every two available during active parts of the display, implying a memory bandwidth for the CPU of about 2.56MB per second.[2]

Keyboard[edit]

The 6522 provided a general-purpose serial bus. The keyboard contained an Intel 8021 microprocessor which transmitted user input to the 6522 over standard phone patch cable. A new keystroke resulted in a processor interrupt.

Sound[edit]

The sampled sound engine piggybacked on the video circuit. As the raster scan returned from the right side of the screen to the left, one byte of data was placed into a PWM generator instead of the screen. This provided 8-bit sampled monaural sound sampled at the 22.25 kHz horizontal blanking rate. General purpose 6522 outputs could mute the sampled sound, or set its volume to one of 8 levels of attenuation.

A square wave generator was included on the 6522. One of its two timer circuits could be set to toggle the mute output periodically. This could produce frequencies higher than 11 kHz.

This system was not compatible with the Lisa / Mac XL hardware, which in other respects could run Mac software with commonly available software/firmware modifications. Running programs on Lisas which made use of the Mac sound features would cause severe video problems and system crashes.

Communication[edit]

The Zilog 8530 SCC was clocked at around 3.7 MHz. At this speed each serial channel was half as fast as the main memory. The RS-422 protocol was implemented except for the connection-established line, which was used to support the mouse. Apple later changed to an 8-pin connector which dropped it entirely.

Storage[edit]

The Macintosh's persistent storage medium was Sony's floppy diskette drive. This drive replaced the Apple ]['s Shugart drive and the 871K FileWare/'Twiggy' floppy drive used in the original Lisa as the storage medium chosen for the original Macintosh. The single-sided 3.5 inch floppy stored 400 KB by spinning the disk slower when the outer edge was used. A separate microcontroller, the IWM (Integrated Woz Machine), was dedicated to disk control. The floppy operated by polled I/O so access was not seamless: loading and saving files were operations that stopped the entire machine.

Twenty bytes of memory were included in the real-time clock counter chip. This data was retained using a 4.5 Volt alkaline battery and was used to store user preferences.

Timekeeping[edit]

The Macintosh featured a real-time clock counting seconds, and a countdown timer with near-microsecond resolution. The former was connected to the 6522 by a serial bus on three general-purpose I/O lines. It functioned much as a quartz watch when the machine was powered off. The latter was built into the 6522 itself. Either could generate interrupts.

  • RAM begins at $000000 and ends at $01FFFF (128K)/$07FFFF (512K) and is divided up into a series of different functional areas:
    • System globals ($000000 - $000AFF)
    • System heap ($000B00). SysZone points to start, ApplZone points to end + 1
    • Application heap (ApplZone; grows upwards. HeapEnd points to its end; ApplLimit sets maximum)
    • Stack. Grows downwards from CurStackBase; SP = A7 points to top of stack.
    • QuickDraw globals. (206 bytes) A5 points to boundary between QD globals and App globals (the 'A5 world').
    • Application globals
    • Application parameters (32 bytes)
    • Jump table
    • Alternate screen buffer, 21,888 bytes (BufPtr)
    • 9344 bytes of undocumented space
    • 740 bytes alternate sound buffer
    • 796 bytes undocumented
    • Screen buffer, 21,888 bytes (ScrnBase = $01A700 (128K)/$07A700 (512K))
    • System Error handler, 128 bytes
    • Main sound buffer, 740 bytes
    • 28 bytes undocumented, MemTop points to the end of RAM, +1
  • ROM ($400000 - $41FFFF)
  • sccRBase - SCC read operations - $9FFFF8
  • sccWBase - SCC write operations - $BFFFF9
  • IWM (dBase) $DFE1FF
  • VIA (vBase) $EFE1FE
    • aVBufB - register B base - $EFE1FE
    • aVBufA - register A base - $EFFFFE
    • aVIFR - interrupt flag register - $EFFBFE
    • aVIER - interrupt enable register - $EFFDFE

The RAM map is organised so that the system globals, system and application heaps grow upwards from low memory, everything else grows downwards from MemTop, from high memory towards low memory. On the 512K Macintosh, the 'extra' RAM thus appears as a wider gap between the application heap and the stack, where it is available for application use.

References[edit]

  1. ^Andy Hertzfeld [1] 'It Sure Is Great To Get Out Of That Bag!'
  2. ^Guide to the Macintosh® Family Hardware, Second Edition. Addison Wesley. 1990. p. 194. ISBN0-201-52405-8.

External links[edit]

  • Macintosh Serial Ports: Serial Ports as Slots MacTech Volume 1, Issue 8 (July 1985)
  • Macintosh 128K/Macintosh 512K Apple Computer Historical Information - Macintosh Hardware Description
Retrieved from 'https://en.wikipedia.org/w/index.php?title=Macintosh_128K/512K_technical_details&oldid=1006010306'
Demo-->

Device Class registration

Each device class follows the same principle for registration. A structure containing specific class parameters is passed to the class initialize function.

Each class can register, optionally, a callback function when a instance of the class gets activated. The callback is then called by the device stack to inform the application that an instance was created.

The application would have in its body the 2 functions for activation and deactivation, as shown in the following example.

It is not recommended to do anything within these functions but to memorize the instance of the class and synchronize with the rest of the application.

USB Device Storage Class

The USB device storage class allows for a storage device embedded in the system to be made visible to a USB host.

The USB device storage class does not by itself provide a storage solution. It merely accepts and interprets SCSI requests coming from the host. When one of these requests is a read or a write command, it will invoke a pre-defined call back to a real storage device handler, such as an ATA device driver or a Flash device driver.

When initializing the device storage class, a pointer structure is given to the class that contains all the information necessary. An example is given below.

In this example, the driver storage strings are customized by assigning string pointers to corresponding parameter. If any one of the string pointer is left to UX_NULL, the default Azure RTOS string is used.

In this example, the drive's last block address or LBA is given as well as the logical sector size. The LBA is the number of sectors available in the media –1. The block length is set to 512 in regular storage media. It can be set to 2048 for optical drives.

The application needs to pass three callback function pointers to allow the storage class to read, write and obtain status for the media.

The prototypes for the read and write functions are shown in the example below.

Where:

  • storage is the instance of the storage class.
  • lun is the LUN the command is directed to.
  • data_pointer is the address of the buffer to be used for reading or writing.
  • number_blocks is the number of sectors to read/write.
  • lba is the sector address to read.
  • media_status should be filled out exactly like the media status callback return value.

The return value can have either the value UX_SUCCESS or UX_ERROR indicating a successful or unsuccessful operation. These operations do not need to return any other error codes. If there is an error in any operation, the storage class will invoke the status call back function.

This function has the following prototype.

The calling parameter media_id is not currently used and should always be 0. In the future it may be used to distinguish multiple storage devices or storage devices with multiple SCSI LUNs. This version of the storage class does not support multiple instances of the storage class or storage devices with multiple SCSI LUNs.

The return value is a SCSI error code that can have the following format.

  • Bits 0-7 Sense_key
  • Bits 8-15 Additional Sense Code
  • Bits 16-23 Additional Sense Code Qualifier

The following table provides the possible Sense/ASC/ASCQ combinations.

Sense KeyASCASCQDescription
000000NO SENSE
011701RECOVERED DATA WITH RETRIES
011800RECOVERED DATA WITH ECC
020401LOGICAL DRIVE NOT READY - BECOMING READY
020402LOGICAL DRIVE NOT READY - INITIALIZATION REQUIRED
020404LOGICAL UNIT NOT READY - FORMAT IN PROGRESS
0204FFLOGICAL DRIVE NOT READY - DEVICE IS BUSY
020600NO REFERENCE POSITION FOUND
020800LOGICAL UNIT COMMUNICATION FAILURE
020801LOGICAL UNIT COMMUNICATION TIME-OUT
020880LOGICAL UNIT COMMUNICATION OVERRUN
023A00MEDIUM NOT PRESENT
025400USB TO HOST SYSTEM INTERFACE FAILURE
028000INSUFFICIENT RESOURCES
02FFFFUNKNOWN ERROR
030200NO SEEK COMPLETE
030300WRITE FAULT
031000ID CRC ERROR
031100UNRECOVERED READ ERROR
031200ADDRESS MARK NOT FOUND FOR ID FIELD
031300ADDRESS MARK NOT FOUND FOR DATA FIELD
031400RECORDED ENTITY NOT FOUND
033001CANNOT READ MEDIUM - UNKNOWN FORMAT
033101FORMAT COMMAND FAILED
0440NNDIAGNOSTIC FAILURE ON COMPONENT NN (80H-FFH)
051A00PARAMETER LIST LENGTH ERROR
052000INVALID COMMAND OPERATION CODE
052100LOGICAL BLOCK ADDRESS OUT OF RANGE
052400INVALID FIELD IN COMMAND PACKET
052500LOGICAL UNIT NOT SUPPORTED
052600INVALID FIELD IN PARAMETER LIST
052601PARAMETER NOT SUPPORTED
052602PARAMETER VALUE INVALID
053900SAVING PARAMETERS NOT SUPPORT
062800NOT READY TO READY TRANSITION – MEDIA CHANGED
062900POWER ON RESET OR BUS DEVICE RESET OCCURRED
062F00COMMANDS CLEARED BY ANOTHER INITIATOR
072700WRITE PROTECTED MEDIA
0B4E00OVERLAPPED COMMAND ATTEMPTED

There are two additional, optional callbacks the application may implement; one is for responding to a GET_STATUS_NOTIFICATION command and the other is for responding to the SYNCHRONIZE_CACHE command.

If the application would like to handle the GET_STATUS_NOTIFICATION command from the host, it should implement a callback with the following prototype.

Where: Planet of cubes survival craft mac os.

  • storage is the instance of the storage class.
  • media_id is not currently used. notification_class specifies the class of notification.
  • media_notification should be set by the application to the buffer containing the response for the notification.
  • media_notification_length should be set by the application to contain the length of the response buffer.

The return value indicates whether or not the command succeeded – should be either UX_SUCCESS or UX_ERROR.

If the application does not implement this callback, then upon receiving the GET_STATUS_NOTIFICATION command, USBX will notify the host that the command is not implemented.

The SYNCHRONIZE_CACHE command should be handled if the application is utilizing a cache for writes from the host. A host may send this command if it knows the storage device is about to be disconnected, for example, in Windows, if you right click a flash drive icon in the toolbar and select 'Eject [storage device name]', Windows will issue the SYNCHRONIZE_CACHE command to that device.

If the application would like to handle the GET_STATUS_NOTIFICATION command from the host, it should implement a callback with the following prototype.

Where:

  • storage is the instance of the storage class.
  • lun parameter specifies which LUN the command is directed to.
  • number_blocks specifies the number of blocks to synchronize.
  • lba is the sector address of the first block to synchronize.
  • media_status should be filled out exactly like the media status callback return value.

The return value indicates whether or not the command succeeded – should be either UX_SUCCESS or UX_ERROR.

Multiple SCSI LUN

The USBX device storage class supports multiple LUNs. It is therefore possible to create a storage device that acts as a CD-ROM and a Flash disk at the same time. In such a case, the initialization would be slightly different. Here is an example for a Flash Disk and CD-ROM:

USB Device CDC-ACM Class

The USB device CDC-ACM class allows for a USB host system to communicate with the device as a serial device. This class is based on the USB standard and is a subset of the CDC standard.

A CDC-ACM compliant device framework needs to be declared by the device stack. An example is found here below.

The CDC-ACM class uses a composite device framework to group interfaces (control and data). As a result care should be taken when defining the device descriptor. USBX relies on the IAD descriptor to know internally how to bind interfaces. The IAD descriptor should be declared before the interfaces and contain the first interface of the CDC-ACM class and how many interfaces are attached.

The CDC-ACM class also uses a union functional descriptor which performs the same function as the newer IAD descriptor. Although a Union Functional descriptor must be declared for historical reasons and compatibility with the host side, it is not used by USBX.

The initialization of the CDC-ACM class expects the following parameters.

The 2 parameters defined are callback pointers into the user applications that will be called when the stack activates or deactivate this class.

The third parameter defined is a callback pointer to the user application that will be called when there is line coding or line states parameter change. E.g., when there is request from host to change DTR state to TRUE, the callback is invoked, in it user application can check line states through IOCTL function to kow host is ready for communication.

The CDC-ACM is based on a USB-IF standard and is automatically recognized by MACOs and Linux operating systems. On Windows platforms, this class requires a .inf file for Windows version prior to 10. Windows 10 does not require any .inf files. We supply a template for the CDC-ACM class and it can be found in the usbx_windows_host_files directory. For more recent version of Windows the file CDC_ACM_Template_Win7_64bit.inf should be used (except Win10). This file needs to be modified to reflect the PID/VID used by the device. The PID/VID will be specific to the final customer when the company and the product are registered with the USB-IF. In the inf file, the fields to modify are located here.

In the device framework of the CDC-ACM device, the PID/VID are stored in the device descriptor (see the device descriptor declared above).

When a USB host systems discovers the USB CDC-ACM device, it will mount a serial class and the device can be used with any serial terminal program. See the host Operating System for reference.

The CDC-ACM class API functions are defined below.

ux_device_class_cdc_acm_ioctl

Perform IOCTL on the CDC-ACM interface

Prototype

Description

This function is called when an application needs to perform various ioctl calls to the cdc acm interface

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • ioctl_function: Ioctl function to be performed.
  • parameter: Pointer to a parameter specific to the ioctl call.

Return Value

  • UX_SUCCESS (0x00) This operation was successful.
  • UX_ERROR (0xFF) Error from function

Example

Ioctl functions:

FunctionValue
UX_SLAVE_CLASS_CDC_ACM_IOCTL_SET_LINE_CODING1
UX_SLAVE_CLASS_CDC_ACM_IOCTL_GET_LINE_CODING2
UX_SLAVE_CLASS_CDC_ACM_IOCTL_GET_LINE_STATE3
UX_SLAVE_CLASS_CDC_ACM_IOCTL_ABORT_PIPE4
UX_SLAVE_CLASS_CDC_ACM_IOCTL_SET_LINE_STATE5
UX_SLAVE_CLASS_CDC_ACM_IOCTL_TRANSMISSION_START6
UX_SLAVE_CLASS_CDC_ACM_IOCTL_TRANSMISSION_STOP7

ux_device_class_cdc_acm_ioctl: UX_SLAVE_CLASS_CDC_ACM_IOCTL_SET_LINE_CODING

https://truebfil148.weebly.com/rados-mac-os.html. Perform IOCTL Set Line Coding on the CDC-ACM interface

Prototype

Description

This function is called when an application needs to Set the Line Coding parameters.

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • ioctl_function: ux_SLAVE_CLASS_CDC_ACM_IOCTL_SET_LINE_CODING
  • parameter: Pointer to a line parameter structure:

Return Value

UX_SUCCESS (0x00) This operation was successful.

Example

ux_device_class_cdc_acm_ioctl: UX_SLAVE_CLASS_CDC_ACM_IOCTL_GET_LINE_CODING

Perform IOCTL Get Line Coding on the CDC-ACM interface

Prototype

Description

This function is called when an application needs to Get the Line Coding parameters.

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • ioctl_function: ux_SLAVE_CLASS_CDC_ACM_IOCTL_GET_ LINE_CODING
  • parameter: Pointer to a line parameter structure:

Return Value

  • UX_SUCCESS (0x00) This operation was successful.

Example

ux_device_class_cdc_acm_ioctl: UX_SLAVE_CLASS_CDC_ACM_IOCTL_GET_LINE_STATE

Perform IOCTL Get Line State on the CDC-ACM interface

Prototype

Description

This function is called when an application needs to Get the Line State parameters.

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • ioctl_function: ux_SLAVE_CLASS_CDC_ACM_IOCTL_GET_LINE_STATE
  • parameter: Pointer to a line parameter structure:

Return Value

  • UX_SUCCESS (0x00) This operation was successful.

Example

ux_device_class_cdc_acm_ioctl: UX_SLAVE_CLASS_CDC_ACM_IOCTL_SET_LINE_STATE

Perform IOCTL Set Line State on the CDC-ACM interface

Prototype

Description

This function is called when an application needs to Get the Line State parameters

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • ioctl_function: ux_SLAVE_CLASS_CDC_ACM_IOCTL_SET_LINE_STATE
  • parameter: Pointer to a line parameter structure:

Return Value

  • UX_SUCCESS (0x00) This operation was successful.

Example

ux_device_class_cdc_acm_ioctl: UX_SLAVE_CLASS_CDC_ACM_IOCTL_ABORT_PIPE

Perform IOCTL ABORT PIPE on the CDC-ACM interface

Prototype

Description

This function is called when an application needs to abort a pipe. For example, to abort an ongoing write, UX_SLAVE_CLASS_CDC_ACM_ENDPOINT_XMIT should be passed as the parameter.

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • ioctl_function: ux_SLAVE_CLASS_CDC_ACM_IOCTL_ABORT_PIPE
  • parameter: The pipe direction:

Return Value

  • UX_SUCCESS (0x00) This operation was successful.
  • UX_ENDPOINT_HANDLE_UNKNOWN (0x53) Invalid pipe direction.

Example

ux_device_class_cdc_acm_ioctl: UX_SLAVE_CLASS_CDC_ACM_IOCTL_TRANSMISSION_START

Prototype

Perform IOCTL Transmission Start on the CDC-ACM interface

Prototype

Description

This function is called when an application wants to use transmission with callback.

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • ioctl_function: ux_SLAVE_CLASS_CDC_ACM_IOCTL_TRANSMISSION_START
  • parameter: Pointer to the Start Transmission parameter structure:

Return Value

  • UX_SUCCESS (0x00) This operation was successful.
  • UX_ERROR (0xFF) Transmission already started.
  • UX_MEMORY_INSUFFICIENT (0x12) A memory allocation failed.

Example

ux_device_class_cdc_acm_ioctl: UX_SLAVE_CLASS_CDC_ACM_IOCTL_TRANSMISSION_STOP

Perform IOCTL Transmission Stop on the CDC-ACM interface

Prototype

Description

This function is called when an application wants to stop using transmission with callback.

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • ioctl_function: ux_SLAVE_CLASS_CDC_ACM_IOCTL_TRANSMISSI ON_STOP
  • parameter: Not used

Return Value

  • UX_SUCCESS (0x00) This operation was successful.
  • UX_ERROR (0xFF) No ongoing transmission.

Example

ux_device_class_cdc_acm_read

Read from CDC-ACM pipe

Prototype

Description

This function is called when an application needs to read from the OUT data pipe (OUT from the host, IN from the device). It is blocking.

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • buffer: Buffer address where data will be stored.
  • requested_length: The maximum length we expect.
  • actual_length: The length returned into the buffer.

Return Value

  • UX_SUCCESS (0x00) This operation was successful.
  • UX_CONFIGURATION_HANDLE_UNKNOWN (0x51) Device is no longer in the configured state.
  • UX_TRANSFER_NO_ANSWER (0x22) No answer from device. The device was probably disconnected while the transfer was pending.

Example

ux_device_class_cdc_acm_write

Write to a CDC-ACM pipe

Prototype

Description

This function is called when an application needs to write to the IN data pipe (IN from the host, OUT from the device). It is blocking.

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • buffer: Buffer address where data is stored.
  • requested_length: The length of the buffer to write.
  • actual_length: The length returned into the buffer after write is performed.

Return Value

  • UX_SUCCESS (0x00) This operation was successful.
  • UX_CONFIGURATION_HANDLE_UNKNOWN (0x51) Device is no longer in the configured state.
  • UX_TRANSFER_NO_ANSWER (0x22) No answer from device. The device was probably disconnected while the transfer was pending.

Example

ux_device_class_cdc_acm_write_with_callback

Writing to a CDC-ACM pipe with callback

Prototype

Description

This function is called when an application needs to write to the IN data pipe (IN from the host, OUT from the device). This function is non-blocking and the completion will be done through a callback set in UX_SLAVE_CLASS_CDC_ACM_IOCTL_TRANSMISSION_START.

Parameters

  • cdc_acm: Pointer to the cdc class instance.
  • buffer: Buffer address where data is stored.
  • requested_length: The length of the buffer to write.
  • actual_length: The length returned into the buffer after write is performed

Return Value

  • UX_SUCCESS (0x00) This operation was successful.
  • UX_CONFIGURATION_HANDLE_UNKNOWN (0x51) Device is no longer in the configured state.
  • UX_TRANSFER_NO_ANSWER (0x22) No answer from device. The device was probably disconnected while the transfer was pending.

Example

USB Device CDC-ECM Class

The USB device CDC-ECM class allows for a USB host system to communicate with the device as a ethernet device. This class is based on the USB standard and is a subset of the CDC standard.

A CDC-ACM compliant device framework needs to be declared by the device stack. An example is found here below.

The CDC-ECM class uses a very similar device descriptor approach to the CDC-ACM and also requires an IAD descriptor. See the CDC-ACM class for definition.

In addition to the regular device framework, the CDC-ECM requires special string descriptors. An example is given below.

The MAC address string descriptor is used by the CDC-ECM class to reply to the host queries as to what MAC address the device is answering to at the TCP/IP protocol. It can be set to the device choice but must be defined here.

The initialization of the CDC-ECM class is as follows.

The initialization of this class expects the same function callback for activation and deactivation, although here as an exercise they are set to NULL so that no callback is performed.

Prototype - Boids Demo Mac Os Catalina

The next parameters are for the definition of the node IDs. 2 Nodes are necessary for the CDC-ECM, a local node and a remote node. The local node specifies the MAC address of the device, while the remote node specifies the MAC address of the host. The remote node must be the same one as the one declared in the device framework string descriptor.

The CDC-ECM class has built-in APIs for transferring data both ways but they are hidden to the application as the user application will communicate with the USB Ethernet device through NetX.

The USBX CDC-ECM class is closely tied to Azure RTOS NetX Network stack. An application using both NetX and USBX CDC-ECM class will activate the NetX network stack in its usual way but in addition needs to activate the USB network stack as follows.

The USB network stack needs to be activated only once and is not specific to CDCECM but is required by any USB class that requires NetX services. Apk official site.

The CDC-ECM class will be recognized by MAC OS and Linux hosts. But there is no driver supplied by Microsoft Windows to recognize CDC-ECM natively. Some commercial products do exist for Windows platforms and they supply their own .inf file. This file will need to be modified the same way as the CDC-ACM inf template to match the PID/VID of the USB network device.

USB Device HID Class

The USB device HID class allows for a USB host system to connect to a HID device with specific HID client capabilities.

USBX HID device class is relatively simple compared to the host side. It is closely tied to the behavior of the device and its HID descriptor.

Any HID client requires first to define a HID device framework as the example below.

The HID framework contains an interface descriptor that describes the HID class and the HID device subclass. The HID interface can be a standalone class or part of a composite device.

Currently, the USBX HID class does not support multiple report IDs, as most applications only require one ID (ID zero). If multiple report IDs is a feature you are interested in, please contact us.

The initialization of the HID class is as follow, using a USB keyboard as an example.

The application needs to pass to the HID class a HID report descriptor and its length. The report descriptor is a collection of items that describe the device. For more information on the HID grammar refer to the HID USB class specification.

In addition to the report descriptor, the application passes a call back when a HID event happens.

The USBX HID class supports the following standard HID commands from the host.

Command nameValueDescription
UX_DEVICE_CLASS_HID_COMMAND_GET_REPORT0x01Get a report from the device
UX_DEVICE_CLASS_HID_COMMAND_GET_IDLE0x02Get the idle frequency of the interrupt endpoint
UX_DEVICE_CLASS_HID_COMMAND_GET_PROTOCOL0x03Get the protocol running on the device
UX_DEVICE_CLASS_HID_COMMAND_SET_REPORT0x09Set a report to the device
UX_DEVICE_CLASS_HID_COMMAND_SET_IDLE0x0aSet the idle frequency of the interrupt endpoint
UX_DEVICE_CLASS_HID_COMMAND_SET_PROTOCOL0x0bGet the protocol running on the device

The Get and Set report are the most commonly used commands by HID to transfer data back and forth between the host and the device. Most commonly the host sends data on the control endpoint but can receive data either on the interrupt endpoint or by issuing a GET_REPORT command to fetch the data on the control endpoint.

The HID class can send data back to the host on the interrupt endpoint by using the ux_device_class_hid_event_set function.

ux_device_class_hid_event_set

Setting an event to the HID class

Prototype

Description

This function is called when an application needs to send a HID event back to the host. The function is not blocking, it merely puts the report into a circular queue and returns to the application.

Prototype - Boids Demo Mac Os 8

Parameters

Prototype - Boids Demo Mac Os 11

  • hid: Pointer to the hid class instance.
  • hid_event: Pointer to structure of the hid event.

Return Value

  • UX_SUCCESS (0x00) This operation was successful.
  • UX_ERROR (0xFF) Error no space available in circular queue.

Example

The callback defined at the initialization of the HID class performs the opposite of sending an event. It gets as input the event sent by the host. The prototype of the callback is as follows.

hid_callback

Prototype - Boids Demo Mac Os Catalina

Getting an event from the HID class

Prototype

Description

Prototype - Boids Demo Mac Os Download

This function is called when the host sends a HID report to the application.

Parameters

  • hid: Pointer to the hid class instance.
  • hid_event: Pointer to structure of the hid event.

Example

The following example shows how to interpret an event for a HID keyboard: