1 Introduction
In embedded systems, embedded processors based on ARM micro-core have become the mainstream of the market. With the widespread application of ARM technology, building an embedded operating system for ARM architecture has become a hot issue in the measurement industry. When adding a new external device in the LINUX operating system, you only need to add the corresponding driver for it. Introducing another way to write a driver, that is, using MISC class devices. In essence, it is also a character device. It can combine various types of user drive devices into one type, share a major device number, and distinguish them by different minor device numbers and device node names. It is convenient to manage these driver modules. Character-type driver device modules must allocate major device numbers, minor device numbers, and create device node names when mounting. When uninstalling the driver device, the device node name must also be deleted at the same time. By using MISC class devices, when mounting the device driver, there is no need to use the mknod command to allocate major device numbers, minor device numbers, and create device node names. After mounting with insmodl, only mdev-s can automatically assemble the device files in the /dev directory.
2 AD7859L Pin Function Description and Registers
The pin function description of AD7859L is shown in Table 1.
AD7859L contains a control register, A/D conversion output register, status register, test register and 10-bit calibration register. The control register can only be written, the A/D conversion output register and status register can only be read, and the test register and calibration register are readable and writable.
When writing data to the AD7859L, the data width must be 16 bits. When 16-bit data is written to the AD7859L, it can be written as a 16-bit word or as two 8-bit bytes, depending on the logic level on pin W/B. When W/B is connected to a high level, 16-bit data is transferred from DB0 to DB15, with DB0 being the lowest bit and DB15 being the highest bit. When W/B is connected to a low level, pin DB8/HBEN is enabled as the high byte, and two 8-bit bytes of data are transferred from DB0 to DB7, with DB0 being the lowest bit and DB7 being the highest bit. When writing data as two 8-bit bytes, the low byte must be written first, followed by the high byte. The highest two bits of the 16-bit data, ADDR1 and ADDR0, are encoded to determine which register to access, and the following 14 bits of data are written to that register. Table 2 shows the encoding distribution.
When reading registers, you must first set the DB6 and DB7 bits of the control register, namely RDSLTO and RDSLTl. These two bits determine which register to access through encoding. At power-on, the initial value of these two bits is 00, so the register accessed by the read operation is the A/D converter output register. As with writing registers, either word mode or byte mode is possible. When reading the calibration register in byte mode, the low byte must be read first.
3 AD7859L Driver
The operating system generally provides device drivers to control specific hardware in order to establish an abstract interface between the application and the device, rather than the application directly operating the hardware. The device driver is actually the software that operates the hardware. It is a low-level hardware processing routine with the highest privilege level in the kernel, resident in memory, and shareable.
Use MISC class devices to add AD7859L driver. The structure definition statement of AD7859L is as follows:
The concept of platform was introduced in the 2.6 version of the kernel. When developing the underlying driver, the device address and interrupt vector number must be confirmed first. Add the address, interrupt number, and device node name of AD7859L in the kernel. When loading, the device driver first needs to call the entry function module_init(), which completes the initialization of the device driver, such as register setting, structure assignment, etc. The most important task is to register the device with the kernel. Open the device file in the application, and then use the ioctl() function to pass various control commands to the driver. After each A /D conversion is completed, an interrupt will be generated, and the interrupt response function will be called to write the converted data to the buffer. When the user needs to read the A/D converted data, the buffer data is read by calling the read() function. The driver structure is shown in Figure 1.
3.1 Platform Resources
In the 2.6 kernel, the resources of each device are described by the structure platform_dev IC e, which is defined in /include/linux/platform_device.h. The platform resources of the AD7859L driver are as follows. Add the following structure to the file /arch/arm/roach-s3c2410/devs.c.
This macro is defined in the map.h file. The second group describes the interrupt vector number of the AD7859L device. Flags describes the resource type, and the device driver will obtain the corresponding resource information based on flags. Add the above s3c_device_ad7859ADC platform resource in the structure stat IC struct platform_device* SMD k2410_devices[]__initdata. This structure is defined in the /arch/arm/mach—s3c2410/mach—smdk2410.C file.
3.2 MISC equipment
Create a miscdevice type device driver structure pointer in the AD7859L structure and add a misc type device. This structure is defined in /include/miscdevice.h.
Call misc_register(stmctmiscdev IC e*misc) function in AD7859L driver's probe function to register misc type device. This function will register a misc type device for the kernel. If minor is set to MISCDYNAMIC_MINOR, the system will dynamically assign a minor device number to the device to distinguish other devices. The device registration and deregistration functions called by different types of devices are different. The deregistration function of misc type device is misc_deregister(struct miscdevice}misc). It returns zero if successful, otherwise it returns an error code.
3.3 Application
The application program under test is relatively simple. It uses the open function to open the device file and uses the ioctl function to set the sampling parameters of AD7859L, including which channels to select for sampling, the sampling time interval, the sampling method, etc. The read function is used to read the buffer data, and the close function is called to close the device file when the program exits.
4 Conclusion
AD7859L is a high-speed, low-power analog-to-digital converter with broad application prospects in the measurement industry. With the recognition of Linux, embedded Linux will be accepted by more and more people. By introducing the development of AD7859L device driver in MISC class device mode under Linux, everyone can understand the operation method of MISC type device more clearly.
Previous article:Visual safety reversing system based on embedded Linux operating system
Next article:Design of communication interface of measurement and control system based on ARM9S3C2440 processor
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Driving WS2812 with only 2 wires
- How to completely shut down Pmos
- Problems with the Linux development board
- Proteus simulation implementation of simple single-chip calculator
- 【GD32L233C-START Review】 Second Development Board Function Review
- Technologies such as RFID enhance the security of smart IoT
- I2C Pressure Sensor
- Differences between CPU and CLA in C28x+FPU architecture and error handling techniques
- Prize-winning quiz | TE "New Energy Application Solutions White Paper"
- Why are XH connector manufacturers so stupid?