Sometimes the user need to get the complete usb information (PID/VID etc) within software under Windows system just like the lsusb command under linux system.
In fact, Windows also have provided some function interface to get the device information as illustrated in the Device Manager.
SetupDiGetClassDevs function
The SetupDiGetClassDevs function returns a handle to a device information set that contains requested device information elements for a local computer.
Please reference the link as below for the detailed Syntax/Parameters/Return Value/Remarks information of this interface.
And please also reference the attached example code, it listed all of the usb devices in the PC, and also extracted the PID/VID/Interface information for further implementation.
For example, Run USBInfo.exe directly with CP2108 plug-in for checking, the detailed information of CP2108 interface as below,
The I2C module include transmit and receive FIFOs to help increase throughput in faster applications, and the I2CSLAVE0 FIFO sizes are 2 bytes for TX, 2 bytes for RX.
An I2CSLAVE0 interrupt will be generated when the WR is set in the I2C0STAT register. And the WR interrupt will be set by hardware on the 9th SCL falling edge when one of the following conditions are met: - The I2C0 Slave responds with an ACK, and the RX FIFO is full. - The I2C0 Slave responds with a NACK, and the RX FIFO is full. - The current byte transaction has a matching I2C0 Slave address, the 8th bit was a WRITE bit (0), and FACS is set to 1. This bit will set the I2C0INT bit and generate an interrupt, if enabled. Software must clear this bit.
Because the FIFO length of I2C Rx is 2, so the WR bit will only be set for every three byte receiving, but not be set for every one byte receiving.
So need to monitor the “RXE” flag of I2C0FCN1 for every one byte receiving with the setting of RFRQE(Read Request Interrupt Enable) is true, and RXTH(RX FIFO Threshold) is 0.
Detailed example code as below,
while((I2C0FCN1 & I2C0FCN1_RXE__BMASK) == I2C0FCN1_RXE__NOT_EMPTY) { // Read data out I2C_DATA = I2C0DIN; // This example only supports host write 1 byte to slave // If want slave to accept more than 1 byte, use a buffer to save the data from FIFO DATA_READY = 1; }
There are 2 main functions in Type-c. One is power negotiation, 2nd is alternate mode.
The USB Billboard Device Class definition describes the methods used to communicate the Alternate Modes supported by a Device Container to a host system. This includes string descriptors that can be used to provide support details in a human-readable format.
If a device fails to successfully enter an Alternate Mode within tAMETimeout then the device shall minimally expose a USB 2.0 interface (USB Billboard Device Class) that is powered by VBUS for popping-up message window to the user.
For the USB Type-C solution, two pins on the connector, CC1 and CC2, are used to establish and manage the Source-to-Sink connection.
Functionally, the configuration channel is used to serve the following purposes. • Detect attach of USB ports, e.g. a Source to a Sink • Resolve cable orientation and twist connections to establish USB data bus routing • Establish data roles between two attached ports • Discover and configure VBUS: USB Type-C Current modes or USB Power Delivery • Configure VCONN • Discover and configure optional Alternate and Accessory modes
1. Detect attach of USB ports, e.g. a Source to a Sink
The general concept for setting up a valid connection between a Source and Sink is based on being able to detect terminations residing in the product being attached. To aid in defining the functional behavior of CC, a pull-up (Rp) and pull-down (Rd) termination model is used – actual implementation in hosts and devices may vary.
Initially, a Source exposes independent Rp terminations on its CC1 and CC2 pins, and a Sink exposes independent Rd terminations on its CC1 and CC2 pins, the Source-to-Sink combination of this circuit configuration represents a valid connection.
To detect this, the Source monitors CC1 and CC2 for a voltage lower than its unterminated voltage. This indicates that either a Sink, a powered cable, or a Sink connected via a powered cable has been attached.
2. Resolve cable orientation and twist connections to establish USB data bus routing
Only one CC pin is connected through the cable to establish signal orientation and the other CC pin is repurposed as VCONN for powering electronics in the USB Type-C plug.
To establish the proper routing of the active USB data bus from host to device, the standard USB Type-C cable is wired such that a single CC wire is position aligned with the first USB SuperSpeed signal pairs (SSTXp1/SSTXn1 and SSRXp1/SSRXn1) – in this way, the CC wire and USB SuperSpeed data bus wires that are used for signaling within the cable track with regard to the orientation and twist of the cable.
3. Establish data roles between two attached ports
By being able to detect which of the CC pins (CC1 or CC2) at the receptacle is terminated by the device, the host is able to determine which SuperSpeed USB signals are to be used for the connection and the host can use this to control the functional switch for routing the SuperSpeed USB signal pairs.
Similarly in the device, detecting which of the CC pins at the receptacle is terminated by the host allows the device to control the functional switch that routes its SuperSpeed USB signal pairs.
4. Configure VCONN
The electronically marked cables provides a method to determine the characteristics of the cable, e.g. its current carrying capability, its performance, vendor identification, etc. And the powered cable should expose Ra on its VCONN pin(the other CC pin), the source will source VCONN when Ra is detected.
5. Discover and configure VBUS
The Source will adjusts Rp (or current source) to advertise which current levels (default/1.5A/3A) it supports. The value of Rp establishes a voltage (vRd) on CC that is used by the Sink to determine the maximum current it may draw.
If the Sink wants to consume more than the default USB current, it shall track vRd to determine the maximum current it may draw.
6. Discover and configure optional Alternate and Accessory modes
If the Sink supports advanced functions (USB Power Delivery and/or Alternate Modes), USB PD communication through CC is required.
Entry and exit into and from an Alternate Mode is controlled by the USB PD Structured VDMs Enter Mode and Exit Mode commands through CC.
How do I use the Comparator0 (CMP0) as a wake-up source for the C8051F96x family of MCUs? In addition, I would like to route the Comparator output to a pin - is that possible in the low power modes SLEEP and SUSPEND?
Answer
To use the Comparator0 as a wake-up source from the low power modes of the C8051F96x devices, the following steps are required:
1) Firmware must configure the desired wake-up sources (Comparator0 in this case) and clear the wakeup flags in the PMU0CF and PMU0FL registers.
2) Enter the desired low power mode by writing a '1' to the SLEEP or SUSPEND bits in the PMU0CF register.
Attached to this article is an example project for the C8051F960-TB that demonstrates using the Comparator0 as a wakeup source for the device (F96x_SleepMode_ComparatorWake.zip). This code can be modified to put the device into SLEEP or SUSPEND mode.
To import this project into Simplicity Studio, follow these steps:
1) Do not unzip the file.
2) In the Simplicity Studio IDE, click [File] > [Import...]
3) Select [Existing Projects into Workspace] > [Next...]
4) Click [Select archive file] > [Browse...] and navigate to the location of the .zip file.
5) Select the .zip file and click [Open]
6) The project "F96x_SleepMode_ComparatorWake" and click [Finish]
As for routing the Comparator0 output to a port pin, it is possible to route either the latched/synchronous comparator output value (CP0) or the asynchronous output value (CP0A) to a port pin via the crossbar on the C8051F960. The code necessary to do this is posted below, however neither signal will be available on the port pin when the device is in SLEEP mode, as the output value of the port pins are latched in SLEEP mode. You can, however, produce the CP0A signal on a port pin while the device is in SUSPEND mode, as the port pins values are not latched. Level changes on the comparator output that result in the wake event for the device do not appear on the pin when the device is in SLEEP mode, but after the device wakes, it is possible to see the comparator output on the pin. Conversely, when the device is in SUSPEND, it is possible to see the CP0A (asynchronous only) signal on that pin before and after the device has woken from SUSPEND. It is not possible to output the synchronous comparator output on a pin in either SLEEP or SUSPEND mode, as the clock that latches the synchronous output value to the output buffer is not active in these low power modes.
To enable the Comparator0 output on a port pin, the following steps are required:
1) In the XBR0 register, enable comparator synchronous/CP0 output (XBR0 |= 0x10 or asynchronous/CP0A output (XBR0 |= 0x20.
2) Ensure that port pin you wish to use is configured as a digital output.
3) Skip any pins necessary to assign CPT0 output to your desired pin. For instance, if you wish to use P0.4, and assuming that you are not using any higher priority digital peripherals on the crossbar (UART0, SPI1, SPI0, or SMBus), then you would need to skip pins P0.0 - P0.3 (P0SKIP |= 0x0F.
Thus, to enable the asynchronous CP0A output to pin P0.4, the following code should be added to the COMPARATOR0_Init() routine:
XBR0 |= 0x20; // enable CPT0A asynchronous output to pin
P0MDOUT |= 0x10; // set P0.4 to push-pull
P0SKIP |= 0x0F; // skip P.0.0-P0.3 on crossbar - this should put CP0A on P0.4
The typical single conversion times for the CS0 module on the C8052F97x, C8052F97x, and the EFM8SB1, as listed in the datasheet for 12-bit, 13-bit, 14-bit, and 16-bit modes are 25, 27, 29, and 33 us, respectively. How do these typical conversion times change depending on the clock source and frequency of SYSCLK (i.e. LPOSC0, HFOSC0, EXTCLK, RTCOSC, LFOSC0)?
Answer
The CS0 module present on the C8051F97x, C8051F99x, and EFM8SB1 devices has its own dedicated oscillator which is active whenever the module is enabled. Thus, the choice of oscillator source for SYSCLK will not affect the conversion times specified in the datasheet (which are for the default configuration).
Other factors that might affect the conversion time (or the time between conversion complete interrupts) are the accumulator setting (CS0ACU in CS0CF) and the conversion rate (CS0CR in CS0MD2 - though this is covered in the default electrical specifications).
I want to convert all of my Silicon Labs 8-bit IDE projects from using absolute include paths to relative paths so that these projects can be pulled down from a repository by different users to wherever they want on their drive and still have the project compile correctly. How can I do this?
Answer
It is possible to include the necessary file paths in the build commands for projects in which all header files are located in directories that are relative to the directory containing the project ".wsp" file (and where this relative structure will be maintained no matter where a user pulls down the repository). This will be the case when the ".wsp" file is located in the project root directory and all necessary header files are located in this root directory or sub-directories of the root.
In the example case I am using to illustrate this technique, the project ".wsp" file is located in a particular directory, and the needed .h files are located in a sub-directory that is two levels down from the ".wsp" file. In the IDE, if you click Project -> Tool Chain Integration -> Compiler Tab, you must add the command line directive:
INCDIR(<relative path from .wsp file to .h include directory>)
In this case, all the header files needed to be included are in the ".\extra_layer_to_test_relative paths\inc" directory. In the case that there were also header files in the root directory (".\") and in the ".\extra_layer_to_test_relative paths" directory, the needed compiler directive would be:
On occasion, users have reported an unusual situation in which some combinations of header files that themselves include other header files in a different part of the directory structure fail to compile, with the compiler warning that the file in the lower level of the directory path could not be opened. For instance, in this example say that a header file located in the ".\extra_layer_to_test_relative paths\inc" directory includes a file located in the ".\" directory. If the subsequent file could not be found by the compiler, it may be necessary to add the relative path "..\.." to the path list:
When using the Keil compiler, one of the build outputs is the memory usage of the program. Check the Console window of the Simplicity Studio IDE, and the 4th to last line of the build will show the "Program Size." It will show the Data memory usage, xdata usage, const size, and code size. Here's a sample Program Size line that shows data usage of 10.1 bytes and code size of 340 bytes:
Program Size: data=10.1 xdata=0 const=0 code=340
Note that the size will not be output if the build is not successful.
"Note: On device reset or upon waking up from Sleep mode, address 0x0000 of external memory (XRAM) may be overwritten by an indeterminate value. The indeterminate value is 0x00 in most situations. A dummy variable should be placed at address 0x0000 in external memory to ensure that the application firmware does not store any data that needs to be retained through reset or Sleep at this memory location."
What is the difference between EFM8BBx -G and -I devices?
Answer
The only difference is the temperature grade. The I grade devices are production tested for operation at an extended temperature range compared to the G grade devices.
Temperature range is -40 to +85 °C for EFM8BB1/2/3 -G grade devices and -40 to +125 °C for -I grade devices.
8-bit Knowledge Base
How to get the information of usb devices under windows
How to get an IIC interrupt every one byte receiving
What's the role of billboard device in Type-c solution
What's the role of CC pin in Type-C solution
Using Comparator0 as a Wake-up Source for the C8051F960
CS0 Conversion Time on the C8051F99x/C8051F97x/EFM8SB1
Using Relative Include Paths with Keil 8051 tools and Silicon Labs 8-bit IDE
Memory Usage
定义"SI_LOCATED_VARIABLE_NO_INIT (reserved, uint8_t, SI_SEG_XDATA, 0x0000);" 的理由
What is the difference between EFM8BBx -G and -I devices?