Add generic, upper-half PWM driver

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4191 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2011-12-16 16:17:34 +00:00
parent 3a2318e7f6
commit cabf8f45e9
8 changed files with 578 additions and 103 deletions
+38 -10
View File
@@ -159,18 +159,55 @@ struct adc_dev_s
extern "C" {
#endif
/************************************************************************************
* "Upper-Half" ADC Driver Interfaces
************************************************************************************/
/************************************************************************************
* Name: adc_register
*
* Description:
* Register a adc driver.
* Register a ADC driver. This function binds an instance of a "lower half" ADC
* driver with the "upper half" ADC device and registers that device so that can
* be used by application code.
*
* Input parameters:
* path - The full path to the driver to be registers in the NuttX pseudo-
* filesystem. The recommended convention is to name all PWM drivers
* as "/dev/adc", "/dev/adc1", etc. where the driver path differs only
* in the "minor" number at the end of the device name.
* dev - A pointer to an instance of lower half ADC driver. This instance
* is bound to the upper half ADC driver and must persists as long as the
* upper half driver driver persists.
*
* Returned Value:
* Zero on success; a negated errno value on failure.
*
************************************************************************************/
int adc_register(FAR const char *path, FAR struct adc_dev_s *dev);
/************************************************************************************
* Name: adc_receive
*
* Description:
* This function is called from the lower half, platform-specific ADC logic when
* new ADC sample data is available.
*
* Input Parameters:
* dev - The ADC device structure that was previously registered by adc_register()
* ch - And ID for the ADC channel number that generated the data
* data - The actualy converted data from the channel.
*
* Returned Value:
* Zero on success; a negated errno value on failure.
*
************************************************************************************/
int adc_receive(FAR struct adc_dev_s *dev, uint8_t ch, int32_t data);
/************************************************************************************
* Platform-Independent "Lower Half" ADC Driver Interfaces
************************************************************************************/
/************************************************************************************
* Name: up_ads1255initialize
*
@@ -181,15 +218,6 @@ int adc_receive(FAR struct adc_dev_s *dev, uint8_t ch, int32_t data);
FAR struct adc_dev_s *up_ads1255initialize(FAR struct spi_dev_s *spi, unsigned int devno);
/************************************************************************************
* Name: up_adcinitialize
*
* Description:
* Initialize the MCU internal adc driver
*
************************************************************************************/
FAR struct adc_dev_s *up_adcinitialize();
#if defined(__cplusplus)
}
#endif
+8 -1
View File
@@ -61,7 +61,9 @@
#define _ARPIOCBASE (0x0800) /* ARP ioctl commands */
#define _TSIOCBASE (0x0900) /* Touchscreen ioctl commands */
#define _SNIOCBASE (0x0a00) /* Sensor ioctl commands */
#define _CAIOCBASE (0x0b00) /* CDC/ACM ioctl commands */
#define _ANIOCBASE (0x0b00) /* Analog (DAC/ADC) ioctl commands */
#define _PWMIOCBASE (0x0c00) /* PWM ioctl commands */
#define _CAIOCBASE (0x0d00) /* CDC/ACM ioctl commands */
/* Macros used to manage ioctl commands */
@@ -173,6 +175,11 @@
#define _SNIOCVALID(c) (_IOC_TYPE(c)==_SNIOCBASE)
#define _SNIOC(nr) _IOC(_SNIOCBASE,nr)
/* NuttX PWM ioctl definitions (see nuttx/pwm.h) ***************************/
#define _PWMIOCVALID(c) (_IOC_TYPE(c)==_PWMIOCBASE)
#define _PWMIOC(nr) _IOC(_PWMIOCBASE,nr)
/* NuttX USB CDC/ACM serial driver ioctl definitions ************************/
/* (see nuttx/usb/cdc_serial.h) */