Platform: Ti
GPIO is the simplest and most commonly used resource in embedded systems, such as lighting up LEDs, controlling buzzers, outputting high and low levels, detecting buttons, etc.
Due to hardware resource reasons, DM6441 is not a pure GPIO pin. GPIO pins and some other standard interfaces reuse the same pins, such as SPI and GPIO reuse, I2C and GPIO reuse, etc. Whether to use GPIO or other interfaces, you need
to set the two registers
PINMUX0 and PINMUX1 during initialization (see DM6441 chip p72), and the software settings are in
the directory of Montavista linux-2.6.18_pro500/arch/arm/mach-davinci in mux_cfg.c and the corresponding include/asm/arch-davinci/mux.h. From the data sheet, we know that gpio5, 6, 7 are gpio functions by default.
Analysis of mux_cfg.c
The first parameter explanation of MUX_CFG()
#include
#include
#include
#include
#include
#ifdef CONFIG_DAVINCI_MUX
struct pin_config __initdata_or_module davinci_dm644x_pins[] = {
MUX_CFG("HDIREN",
MUX_CFG("ATAEN",
MUX_CFG("MSTK",
MUX_CFG("I2C",
MUX_CFG("MCBSP",
MUX_CFG("PWM0",
MUX_CFG("PWM1",
MUX_CFG("PWM2",
MUX_CFG("VLINQEN",
MUX_CFG("VLINQWD",
MUX_CFG("EMACEN",
MUX_CFG("GPIO3V",
MUX_CFG("GPIO0",
MUX_CFG("GPIO3",
MUX_CFG("GPIO43_44",
MUX_CFG( "GPIO46_47",
MUX_CFG("RGB666",
MUX_CFG("LOEEN",
MUX_CFG("LFLDEN",
};
The interface provided in the kernel is in gpio.c in the linux-2.6.18_pro500/arch/arm/mach-davinci directory. This is a register-level driver. For related operations on this file,
see http://blog.csdn.net/langxing0508/archive/2008/12/25/3604043.aspx
Well said, thanks here.
Below is my gpio driver
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
#define DEVICE_NAME "dm644x_gpios"
#define GPIO_MAJOR 199
#define ZX_GPIO5
#define ZX_GPIO6
#define ZX_GPIO7
static int davinci_dm644x_gpio_open(struct inode *inode, struct file *file)
{
//
//
//
//
}
static int gpio_release(struct inode *inode,struct file *filp)
{
}
[page]
static int davinci_dm644x_gpio_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
}
static const struct file_operations davinci_dm644x_gpio_fileops = {
};
static int __init davinci_dm644x_gpio_init(void)
{
}
static void __exit davinci_dm644x_gpio_exit(void)
{
}
module_init(davinci_dm644x_gpio_init);
module_exit(davinci_dm644x_gpio_exit);
MODULE_AUTHOR("xxx <>") ;
MODULE_DESCRIPTION("Davinci DM644x gpio driver");
MODULE_LICENSE("GPL");
Below is the application
#include
#include
#include
#include
#define
#define
int main(void)
{
}
Below is the Makefile.
#
# Makefile for the skeleton device drivers.
#
KDIR=/root/work/linux-2.6.18_pro500
PWD := $(shell pwd)
ifeq ($(KERNELRELEASE), )
modules:
modules_install:
clean:
.PHONY: modules modules_install clean
else
endif
Just make it directly.
HyperTerminal operation:
insmod
mknod
./gpio_test
Previous article:S3C2440 RTC bare metal program
Next article:ARM builds FTP server
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Here is the camera information on the national competition list
- RF Components Test Technology Seminar for 5G - You are invited to attend!
- Has anyone designed this power supply?
- Network Control of ROS Melodic
- Let’s take a look at how this overvoltage protection circuit can be optimized?
- Inverter and Motor Control
- 【ST NUCLEO-H743ZI Review】(2) First experience with Ethernet testing
- Disassembling a common fire emergency light
- [NXP Rapid IoT Review] Mobile APP connection finally succeeded
- Buy an oscilloscope and get the essential analysis software 5-PWR for power engineers