November 24, 2011
Author: Cao Zhongming, China Qingyuan see embedded training center instructor.
ADC is commonly used in embedded devices, it is not difficult to drive, but if there are more of these devices, then you have to consider the ADC interrupt sharing problem, but this change is driven was more complex, and difficult to control. In the 2.6.29 kernel in arch / arm / plat-samsung directory added adc.c this code, which is a generic adc driver code. This code is used to initialize the adc equipment and build a list of customer requests, customer requests to accept the conversion data.
The following structure is used to describe a customer:
struct s3c_adc_client {
structplatform_device * pdev;
structlist_headpend ; / / used to build customer request list
wait_queue_head_t * wait; / / wait queue head, used to sleep
unsignedintnr_samples;
int result ;
unsigned char is_ts; / / if the touch screen
unsigned charchannel; / / channel
void (* select_cb) (struct s3c_adc_client * c , unsigned selected);
void (* convert_cb) (struct s3c_adc_client * c,
unsigned val1, unsigned val2,
unsigned * samples_left) ; / / convert callback function
};
we need in our drive to build this structure, and the generic driver to register the adc structure. Registration function:
struct s3c_adc_client * s3c_adc_register (structplatform_device * pdev,
void (* select) (struct s3c_adc_client * client, unsignedint selected),
void (* conv) (struct s3c_adc_client * client, unsigned d0, unsigned d1, unsigned * samples_left),
unsignedintis_ts)
Then we can read the corresponding channel of the data:
int s3c_adc_read (struct s3c_adc_client * client, unsigned intch);
Now we begin to write our driver:
1, structure to build our equipment in arch/arm/mach-s3c2410/mach-smdk2410.c
add the following
structplatform_device s3c_device_adc_conversion = {
. name = “adc_conversion”,
. id = -1,
. dev.parent =
December 26, 2011
samsung ADC Universal Driver
Comments Off
No Comments
No comments yet.
RSS feed for comments on this post.
Sorry, the comment form is closed at this time.