Through the study of the eighth chapter, I summed up some of my own thought important, need to master the knowledge points.
1. Control the buzzer sound by writing a specific value to the register.
2, in the encounter can not uninstall the Linux driver by directly modifying the Linux drive corresponding memory address to remove the Linux drive to avoid restarting the machine trouble.
3, through different source code files to store different function codes to facilitate the classification and management of code.
4, MAIN.C is the main program of Linux driver.
5. Initialize Linux drivers
Static int _init main _init (void)
6. Uninstalling Linux Drivers
Static void _exit main _exit (void)
7, register the function of initializing Linux driver
Module_init (Main_init);
8, register the function of uninstalling Linux driver
Module_exit (Main_exit);
9, code reuse is divided into static and dynamic two kinds,
10, forcibly uninstall the Linux driver occurs:
Initialization function crashes, unload functions are blocked,
11, through the corresponding register to control the buzzer open and close.
12, buzzer driving principle: Buzzer is also called PWM (pulse width modulation), the basic principle is to control the buzzer by pulse to open and close.
13. Open and close pwm via I/o command.
14. The close function of the PWM device file
Static int s3c64xx_pwm_close (struct inode *inode,struct file *file)
15. Releasing the semaphore
Up (&lock);
16. Open PWM
Pwm_start ();
17. Stop PWM
Pwm_stop ();
18. Initialize the semaphore
Init_motex (&lock);
19. Registration of equipment files
/dev/pwm_den
20. Removal of device files
Misc_deregister (&MISC);
21. I/o command, open PWM
#define PWM_IOCTL_START 1
22. I/o command; Stop PWM
#define PWM_IOCTL_STOP 0
23. Open PWM function
Extern void Pwm_start (void);
24, Stop the PWM function
Extern void pwm_stop (void);
25, the high two bits of the Gpfcon register are zeroed, the other bits are reserved
TMP &=~ (0x3u << 30);
26. Set the high two bit of the Gpfcon register to 10
TMP |= (0x2u << 30);
27, write the new value will Gpfcon register, PWM started screaming
IOWRITE32 (TMP, S3c64xx_gpfcon);
28, write the new value will Gpfcon register, PWM stop screaming
IOWRITE32 (TMP, S3c64xx_gpfcon);
29. Open PWM
#./ioctl/dev/pwm_dev 1 0
30. Stop PWM
#./ioctl/dev/pwm_dev 0 0
The eighth chapter makes the Development Board sound: Buzzer driver