Skip to content

Commit 8bd3dfb

Browse files
committed
doxygen: convert 5.device
Signed-off-by: Chen Wang <[email protected]>
1 parent d2393ae commit 8bd3dfb

File tree

14 files changed

+186
-174
lines changed

14 files changed

+186
-174
lines changed

documentation/5.device/INDEX.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
11
@page device Device
2+
3+
- @subpage device_framework
4+
- @subpage device_pin
5+
- @subpage device_uart
6+
- @subpage device_adc
7+
- @subpage device_i2c
8+
- @subpage device_spi
9+
- @subpage device_pwm
10+
- @subpage device_rtc
11+
- @subpage device_hwtimer
12+
- @subpage device_watchdog
13+
- @subpage device_wlan
14+
- @subpage device_sensor

documentation/INDEX.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@
2020
- @ref env
2121
- @ref scons
2222

23-
**Device**
24-
25-
- [I/O Device Framework](device/device.md)
26-
- [PIN Device](device/pin/pin.md)
27-
- [UART Device](device/uart/uart.md)
28-
- [ADC Device](device/adc/adc.md)
29-
- [I2C Bus Device](device/i2c/i2c.md)
30-
- [SPI Device](device/spi/spi.md)
31-
- [PWM Device](device/pwm/pwm.md)
32-
- [RTC Device](device/rtc/rtc.md)
33-
- [HWTIMER Device](device/hwtimer/hwtimer.md)
34-
- [WATCHDOG Device](device/watchdog/watchdog.md)
35-
- [WLAN Device](device/wlan/wlan.md)
36-
- [Sensor Device](device/sensor/sensor.md)
23+
@subpage device
24+
25+
- @ref device_framework
26+
- @ref device_pin
27+
- @ref device_uart
28+
- @ref device_adc
29+
- @ref device_i2c
30+
- @ref device_spi
31+
- @ref device_pwm
32+
- @ref device_rtc
33+
- @ref device_hwtimer
34+
- @ref device_watchdog
35+
- @ref device_wlan
36+
- @ref device_sensor
3737

3838
**Components**
3939

documentation/device/adc/adc.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# ADC Device
1+
@page device_adc ADC Device
22

3-
## An Introduction to ADC
3+
# An Introduction to ADC
44

55
An ADC (analog-to-digital converter) is a hardware device that converts continuously changing analog signals to discrete digital signals. Usually, these analog signals include temperature, pressure, sound, video and many other types of signals. Converting them is important, as digital signals are easier to store, process, and transmit. This conversion can be achieved by using an ADC device which is commonly integrated in various platforms. Historically, ADCs were first used to convert received wireless signals to digital signals, for example, television signals, or signals from long-short broadcast stations.
66

7-
### Conversion Process
7+
## Conversion Process
88

99
As shown in the figure below, the analog-to-digital conversion generally involves steps of sampling, holding, quantifying, and encoding. In actual circuits, some processes are combined, such as sampling and holding, while quantization and encoding are implemented simultaneously in the conversion process.
1010

@@ -14,19 +14,19 @@ Sampling is the conversion of analog signals that changes continuously over time
1414

1515
The process of converting a numerically continuous analog quantity into a digital quantity is called quantization. Digital signals are discrete numerically. The output voltage of the sample-and-hold circuit also needs to be naturalized to a corresponding discrete level in a similar way, and any digital quantity can only be an integer multiple of a certain minimum quantity unit. The quantized value also requires the encoding process, which is the digital output of the A/D converter.
1616

17-
### Resolution
17+
## Resolution
1818

1919
Resolution is represented as binary (or decimal) numbers. Generally, it comes in 8 bits, 10 bits, 12 bits, 16 bits, etc. A larger resolution, in bits, means more accuracy in the conversion of analog to digital signals.
2020

21-
### Precision
21+
## Precision
2222

2323
Precision is the maximum error value between analog signals and real ADC device numerical points’ values.An ADC with a high resolution might have a low precision, meaning that factors like noise can affect the numerical ADC reading more than small changes in the input signal.
2424

25-
### Conversion Rate
25+
## Conversion Rate
2626

2727
The conversion rate is the reciprocal of time taken for an ADC device to complete conversion from an analog to a digital signal. For example, an ADC device with a conversion rate of 1MHz means that the ADC conversion time is 1 microsecond.
2828

29-
## Access ADC Device
29+
# Access ADC Device
3030

3131
The application accesses the ADC hardware through the ADC device management interface provided by RT-Thread. The relevant interfaces are as follows:
3232

@@ -37,7 +37,7 @@ The application accesses the ADC hardware through the ADC device management inte
3737
| rt_adc_read() | Read ADC device data |
3838
| rt_adc_disable() | Close the ADC device |
3939

40-
### Find ADC Devices
40+
## Find ADC Devices
4141

4242
The application gets the device handler based on the ADC device name to operate the ADC device. Following is the interface function to find the devices:
4343

@@ -62,7 +62,7 @@ rt_adc_device_t adc_dev; /* ADC device handle */
6262
adc_dev = (rt_adc_device_t)rt_device_find(ADC_DEV_NAME);
6363
```
6464

65-
### Enable ADC Channel
65+
## Enable ADC Channel
6666

6767
It is required to enable the ADC device with the following interface function before reading and operating the ADC device.
6868

@@ -91,7 +91,7 @@ adc_dev = (rt_adc_device_t)rt_device_find(ADC_DEV_NAME);
9191
rt_adc_enable(adc_dev, ADC_DEV_CHANNEL);
9292
```
9393

94-
### Read ADC Channel Sample Values
94+
## Read ADC Channel Sample Values
9595

9696
Reading the ADC channel sample values can be done by the following function:
9797

@@ -129,7 +129,7 @@ rt_kprintf("the voltage is :%d.%02d \n", vol / 100, vol % 100);
129129

130130
The calculation formula of the actual voltage value is: `sampling value * reference voltage/(1 << resolution digit)`. In the above example, variable *vol* was enlarged 100 times, so finally the integer part of voltage is obtained through *vol / 100*, and the decimal part of voltage is obtained through *vol % 100*.
131131

132-
### Disabling the ADC Channel
132+
## Disabling the ADC Channel
133133

134134
An ADC channel can be disabled through the following function:
135135

@@ -166,7 +166,7 @@ rt_kprintf("the voltage is :%d.%02d \n", vol / 100, vol % 100);
166166
rt_adc_disable(adc_dev, ADC_DEV_CHANNEL);
167167
```
168168

169-
### FinSH Command
169+
## FinSH Command
170170

171171
To find out the registered device, you can use the command adc probe followed by the registered ADC device name as following,
172172

@@ -198,7 +198,7 @@ adc1 channel 5 disable success
198198
msh >
199199
```
200200

201-
## ADC Device Usage Example
201+
# ADC Device Usage Example
202202

203203
The specific usage of the ADC device can refer to the following sample code. The main steps of the sample code are as follows:
204204

documentation/device/device.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# I/O Device Framework
1+
@page device_framework I/O Device Framework
22

33
Most embedded systems include some I/O (Input/Output) devices, data displays on instruments, serial communication on industrial devices, Flash or SD cards for saving data on data acquisition devices,as well as Ethernet interfaces for network devices, are examples of I/O devices that are commonly seen in embedded systems.
44

55
This chapter describes how RT-Thread manages different I/O devices.
66

7-
## I/O Device Introduction
7+
# I/O Device Introduction
88

9-
### I/O Device Framework
9+
## I/O Device Framework
1010

1111
RT-Thread provides a set of I/O device framework, as shown in the following figure. It is located between the hardware and the application. It is divided into three layers. From top to bottom, they are I/O device management layer, device driver framework layer, and device driver layer.
1212

@@ -35,7 +35,7 @@ Usage of Watchdog device:
3535

3636
![Watchdog Device Use Sequence Diagram](figures/wtd-uml.png)
3737

38-
### I/O Device Model
38+
## I/O Device Model
3939

4040
The device model of RT-Thread is based on the kernel object model, which is considered a kind of objects and is included in the scope of the object manager. Each device object is derived from the base object. Each concrete device can inherit the properties of its parent class object and derive its own properties. The following figure is a schematic diagram of the inheritance and derivation relationship of device object.
4141

@@ -66,7 +66,7 @@ typedef struct rt_device *rt_device_t;
6666

6767
```
6868

69-
### I/O Device Type
69+
## I/O Device Type
7070

7171
RT-Thread supports multiple I/O device types, the main device types are as follows:
7272

@@ -95,7 +95,7 @@ A block device transfers one data block at a time, for example 512 bytes data at
9595

9696
When the system serves a write operation with a large amount of data, the device driver must first divide the data into multiple packets, each with the data size specified by the device. In the actual process, the last part of the data size may be smaller than the normal device block size. Each block in the above figure is written to the device using a separate write request, and the first three are directly written. However, the last data block size is smaller than the device block size, and the device driver must process the last data block differently than the first 3 blocks. Normally, the device driver needs to first perform a read operation of the corresponding device block, then overwrite the write data onto the read data, and then write the "composited" data block back to the device as a whole block. . For example, for block 4 in the above figure, the driver needs to read out the device block corresponding to block 4, and then overwrite the data to be written to the data read from the device block, and merge them into a new block. Finally write back to the block device.
9797

98-
## Create and Register I/O Device
98+
# Create and Register I/O Device
9999

100100
The driver layer is responsible for creating device instances and registering them in the I/O Device Manager. You can create device instances in a statically declared manner or dynamically create them with the following interfaces:
101101

@@ -245,13 +245,13 @@ rt_err_t rt_hw_watchdog_register(struct rt_watchdog_device *wtd,
245245
246246
```
247247

248-
## Access I/O Devices
248+
# Access I/O Devices
249249

250250
The application accesses the hardware device through the I/O device management interface, which is accessible to the application when the device driver is implemented. The mapping relationship between the I/O device management interface and the operations on the I/O device is as follows:
251251

252252
![Mapping between the I/O Device Management Interface and the Operations on the I/O Device](figures/io-fun-call.png)
253253

254-
### Find Device
254+
## Find Device
255255

256256
The application obtains the device handle based on the device name, which in turn allows the device to operate. To find device, use function below:
257257

@@ -266,7 +266,7 @@ rt_device_t rt_device_find(const char* name);
266266
| device handle | finding the corresponding device will return the corresponding device handle |
267267
| RT_NULL | no corresponding device object found |
268268
269-
### Initialize Device
269+
## Initialize Device
270270
271271
Once the device handle is obtained, the application can initialize the device using the following functions:
272272
@@ -283,7 +283,7 @@ rt_err_t rt_device_init(rt_device_t dev);
283283

284284
>When a device has been successfully initialized, calling this interface will not repeat initialization.
285285
286-
### Open and Close Device
286+
## Open and Close Device
287287

288288
Through the device handle, the application can open and close the device. When the device is opened, it will detect whether the device has been initialized. If it is not initialized, it will call the initialization interface to initialize the device by default. Open the device with the following function:
289289

@@ -333,7 +333,7 @@ rt_err_t rt_device_close(rt_device_t dev);
333333
334334
>Device interfaces `rt_device_open()` and `rt_device_close()` need to used in pairs. Open a device requires close the device, so that the device will be completely closed, otherwise the device will remain on.
335335
336-
### Control Device
336+
## Control Device
337337
338338
By commanding the control word, the application can also control the device with the following function:
339339
@@ -362,7 +362,7 @@ The generic device command for the parameter `cmd` can be defined as follows:
362362
#define RT_DEVICE_CTRL_GET_INT 0x12 /* obtain interrupt status */
363363
```
364364

365-
### Read and Write Device
365+
## Read and Write Device
366366

367367
Application can read data from the device by the following function:
368368

@@ -400,7 +400,7 @@ rt_size_t rt_device_write(rt_device_t dev, rt_off_t pos,const void* buffer, rt_s
400400

401401
Calling this function will write the data in the buffer to the *dev* device . The maximum length of the written data is *size*, and *pos* has different meanings depending on the device class.
402402

403-
### Data Transceiving and Call-back
403+
## Data Transceiving and Call-back
404404

405405
When the hardware device receives the data, the following function can be used to call back another function to set the data receiving indication to notify the upper application thread that the data arrives:
406406

@@ -432,7 +432,7 @@ rt_err_t rt_device_set_tx_complete(rt_device_t dev, rt_err_t (*tx_done)(rt_devic
432432

433433
When this function is called, the callback function is provided by the user. When the hardware device sends the data, the driver calls back the function and passes the sent data block address buffer as a parameter to the upper application. When the upper layer application (thread) receives the indication, it will release the buffer memory block or use it as the buffer for the next write data according to the condition of sending the buffer.
434434

435-
### Access Device Sample
435+
## Access Device Sample
436436

437437
The following code is an example of accessing a device. First, find the watchdog device through the `rt_device_find()` port, obtain the device handle, then initialize the device through the `rt_device_init()` port, and set the watchdog device timeout through the `rt_device_control()`port.
438438

documentation/device/hwtimer/hwtimer.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# HWTIMER Device
1+
@page device_hwtimer HWTIMER Device
22

3-
4-
## Introduction to the Timer
3+
# Introduction to the Timer
54

65
Hardware timers generally have two modes of operation, timer mode and counter mode. No matter which mode is operated, it works by counting the pulse signal counted by the internal counter module. Here are some important concepts of timers.
76

@@ -11,7 +10,7 @@ Hardware timers generally have two modes of operation, timer mode and counter mo
1110

1211
**Counting frequency**:Since the input frequency is usually fixed, the time it takes for the counter to reach its desired count number can be calculated from just the given frequency - `time = count value / count frequency`. For example, if the counting frequency is 1 MHz, the counter counts once every 1 / 1000000 seconds. That is, every 1 microsecond, the counter is incremented by one (or subtracted by one), at this time, the maximum timing capability of the 16-bit counter is 65535 microseconds, or 65.535 milliseconds.
1312

14-
## Access Hardware Timer Device
13+
# Access Hardware Timer Device
1514

1615
The application accesses the hardware timer device through the I/O device management interface provided by RT-Thread. The related interfaces are as follows:
1716

@@ -25,7 +24,7 @@ The application accesses the hardware timer device through the I/O device manage
2524
| rt_device_read() | to get the current value of the timer |
2625
| rt_device_close() | to turn off the timer device. |
2726

28-
### Find Timer Device
27+
## Find Timer Device
2928

3029
The application obtains the device handle based on the hardware timer device name, and thus can operate the hardware timer device. The device function is as follows:
3130

@@ -49,7 +48,7 @@ rt_device_t hw_dev; /* timer device handle */
4948
hw_dev = rt_device_find(HWTIMER_DEV_NAME);
5049
```
5150

52-
### Open Timer Device
51+
## Open Timer Device
5352

5453
With the device handle, the application can open the device. When the device is open, it will detect whether the device has been initialized. If it is not initialized, it will call the initialization interface to initialize the device by default. Open the device with the following function:
5554

@@ -76,7 +75,7 @@ hw_dev = rt_device_find(HWTIMER_DEV_NAME);
7675
rt_device_open(hw_dev, RT_DEVICE_OFLAG_RDWR);
7776
```
7877

79-
### Set the Timeout Callback Function
78+
## Set the Timeout Callback Function
8079

8180
Set the timer timeout callback function with the following function - this is the function that will be called when the timer reaches its set count value:
8281

@@ -117,7 +116,7 @@ static int hwtimer_sample(int argc, char *argv[])
117116
}
118117
```
119118

120-
### Control the Timer Device
119+
## Control the Timer Device
121120

122121
By sending control words, the application can configure the hardware timer device with the following function:
123122

@@ -189,7 +188,7 @@ static int hwtimer_sample(int argc, char *argv[])
189188
}
190189
```
191190
192-
### Set the Timer Timeout Value
191+
## Set the Timer Timeout Value
193192
194193
The timer timeout value can be set by the following function:
195194
@@ -253,7 +252,7 @@ static int hwtimer_sample(int argc, char *argv[])
253252
}
254253
```
255254
256-
### Obtain the Current Value of the Timer
255+
## Obtain the Current Value of the Timer
257256
258257
The current value of the timer can be obtained by the following function:
259258
@@ -279,7 +278,7 @@ rt_hwtimerval_t timeout_s; /* Used to save the time the timer has elapsed *
279278
rt_device_read(hw_dev, 0, &timeout_s, sizeof(timeout_s));
280279
```
281280
282-
### Close the Timer Device
281+
## Close the Timer Device
283282
284283
The timer device can be closed with the following function:
285284
@@ -310,7 +309,7 @@ rt_device_close(hw_dev);
310309
311310
>Timing errors may occur. Assume that the counter has a maximum value of 0xFFFF, a counting frequency of 1Mhz, and a timing time of 1 second and 1 microsecond. Since the timer can only count up to 65535us at a time, the timing requirement for 1000001us can be completed 20 times at 50000us, and the calculation error will be 1us.
312311
313-
## Hardware Timer Device Usage Example
312+
# Hardware Timer Device Usage Example
314313
315314
The specific use of the hardware timer device can refer to the following sample code. The main steps of the sample code are as follows:
316315

documentation/device/i2c/i2c.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# I2C Bus Device
1+
@page device_i2c I2C Bus Device
22

3-
## Introduction of I2C
3+
# Introduction of I2C
44

55
The I2C (Inter Integrated Circuit) bus is a half-duplex, bidirectional two-wire synchronous serial bus developed by Philips. The I2C bus has only two signal lines, one is the bidirectional data line SDA (serial data), and the other is the bidirectional clock line SCL (serial clock). Compared to the SPI bus, which has two lines for receiving data and transmitting data between the master and slave devices, the I2C bus uses only one line for data transmission and reception.
66

@@ -28,7 +28,7 @@ When the bus is idle, both SDA and SCL are in a high state. When the host wants
2828

2929
* **Stop Condition:** When SDA is low, the master pulls SCL high and stays high, then pulls SDA high to indicate the end of the transfer.
3030

31-
## Access to I2C Bus Devices
31+
# Access to I2C Bus Devices
3232

3333
In general, the MCU's I2C device communicates as a master and slave. In the RT-Thread, the I2C master is virtualized as an I2C bus device. The I2C slave communicates with the I2C bus through the I2C device interface. The related interfaces are as follows:
3434

@@ -37,7 +37,7 @@ In general, the MCU's I2C device communicates as a master and slave. In the RT-T
3737
| rt_device_find() | Find device handles based on I2C bus device name |
3838
| rt_i2c_transfer() | transfer data |
3939

40-
### Finding I2C Bus Device
40+
## Finding I2C Bus Device
4141

4242
Before using the I2C bus device, you need to obtain the device handle according to the I2C bus device name, so that you can operate the I2C bus device. The device function is as follows.
4343

@@ -62,7 +62,7 @@ struct rt_i2c_bus_device *i2c_bus; /* I2C bus device handle */
6262
i2c_bus = (struct rt_i2c_bus_device *)rt_device_find(name);
6363
```
6464

65-
### Data Transmission
65+
## Data Transmission
6666

6767
You can use `rt_i2c_transfer()` for data transfer by getting the I2C bus device handle. The function prototype is as follows:
6868

@@ -144,7 +144,7 @@ static rt_err_t read_regs(struct rt_i2c_bus_device *bus, rt_uint8_t len, rt_uint
144144
}
145145
```
146146
147-
## I2C Bus Device Usage Example
147+
# I2C Bus Device Usage Example
148148
149149
The specific usage of the I2C device can be referred to the following sample code. The main steps of the sample code are as follows:
150150

0 commit comments

Comments
 (0)