Forked repo of Platform Drivers- Analog Devices
ain.h@20:26b1a4570f4b, 2021-11-22 (annotated)
- Committer:
- Janani Sunil
- Date:
- Mon Nov 22 22:26:51 2021 +0530
- Revision:
- 20:26b1a4570f4b
- Parent:
- 19:3c61197500c4
The following changes were made:
1.) Modified udelay() function for generating more accurate smaller usec delays
2.) Implemented the irq_enable and irq_disable functions
3.) Removed the confusion b/w application created peripheral object and interrupt specific object
4.) Created PWM extra init structure and added PWM pin as it's member for multiplatform project compatibility
5.) Added a module for timer and its related header file
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kjansen |
19:3c61197500c4 | 1 | /***************************************************************************//** |
Kjansen |
19:3c61197500c4 | 2 | * @file ain.h |
Kjansen |
19:3c61197500c4 | 3 | * @author PMallick (Pratyush.Mallick@analog.com) |
Kjansen |
19:3c61197500c4 | 4 | ******************************************************************************** |
Kjansen |
19:3c61197500c4 | 5 | * Copyright (c) 2021 Analog Devices, Inc. |
Kjansen |
19:3c61197500c4 | 6 | * All rights reserved. |
Kjansen |
19:3c61197500c4 | 7 | * |
Kjansen |
19:3c61197500c4 | 8 | * This software is proprietary to Analog Devices, Inc. and its licensors. |
Kjansen |
19:3c61197500c4 | 9 | * By using this software you agree to the terms of the associated |
Kjansen |
19:3c61197500c4 | 10 | * Analog Devices Software License Agreement. |
Kjansen |
19:3c61197500c4 | 11 | *******************************************************************************/ |
Kjansen |
19:3c61197500c4 | 12 | |
Kjansen |
19:3c61197500c4 | 13 | #ifndef AIN_H |
Kjansen |
19:3c61197500c4 | 14 | #define AIN_H |
Kjansen |
19:3c61197500c4 | 15 | |
Kjansen |
19:3c61197500c4 | 16 | /******************************************************************************/ |
Kjansen |
19:3c61197500c4 | 17 | /***************************** Include Files **********************************/ |
Kjansen |
19:3c61197500c4 | 18 | /******************************************************************************/ |
Kjansen |
19:3c61197500c4 | 19 | |
Kjansen |
19:3c61197500c4 | 20 | #include <stdint.h> |
Kjansen |
19:3c61197500c4 | 21 | |
Kjansen |
19:3c61197500c4 | 22 | /******************************************************************************/ |
Kjansen |
19:3c61197500c4 | 23 | /********************** Macros and Constants Definitions **********************/ |
Kjansen |
19:3c61197500c4 | 24 | /******************************************************************************/ |
Kjansen |
19:3c61197500c4 | 25 | |
Kjansen |
19:3c61197500c4 | 26 | /******************************************************************************/ |
Kjansen |
19:3c61197500c4 | 27 | /*************************** Types Declarations *******************************/ |
Kjansen |
19:3c61197500c4 | 28 | /******************************************************************************/ |
Kjansen |
19:3c61197500c4 | 29 | /** |
Kjansen |
19:3c61197500c4 | 30 | * @struct ain_init_param |
Kjansen |
19:3c61197500c4 | 31 | * @brief Structure holding parameters for analog input initialization |
Kjansen |
19:3c61197500c4 | 32 | */ |
Kjansen |
19:3c61197500c4 | 33 | struct ain_init_param { |
Kjansen |
19:3c61197500c4 | 34 | /* Analog input pin number */ |
Kjansen |
19:3c61197500c4 | 35 | int32_t number; |
Kjansen |
19:3c61197500c4 | 36 | /* Analog input reference voltage */ |
Kjansen |
19:3c61197500c4 | 37 | float vref; |
Kjansen |
19:3c61197500c4 | 38 | /* Analog input platform specific functions */ |
Kjansen |
19:3c61197500c4 | 39 | const struct ain_platform_ops *platform_ops; |
Kjansen |
19:3c61197500c4 | 40 | }; |
Kjansen |
19:3c61197500c4 | 41 | |
Kjansen |
19:3c61197500c4 | 42 | /** |
Kjansen |
19:3c61197500c4 | 43 | * @struct ain_desc |
Kjansen |
19:3c61197500c4 | 44 | * @brief Structure holding analog input descriptor |
Kjansen |
19:3c61197500c4 | 45 | */ |
Kjansen |
19:3c61197500c4 | 46 | struct ain_desc { |
Kjansen |
19:3c61197500c4 | 47 | /* Analog input pin number */ |
Kjansen |
19:3c61197500c4 | 48 | int32_t number; |
Kjansen |
19:3c61197500c4 | 49 | /* Analog input reference voltage */ |
Kjansen |
19:3c61197500c4 | 50 | float vref; |
Kjansen |
19:3c61197500c4 | 51 | /* Analog input platform specific functions */ |
Kjansen |
19:3c61197500c4 | 52 | const struct ain_platform_ops *platform_ops; |
Kjansen |
19:3c61197500c4 | 53 | /* Analog extra parameters (device specific) */ |
Kjansen |
19:3c61197500c4 | 54 | void *extra; |
Kjansen |
19:3c61197500c4 | 55 | }; |
Kjansen |
19:3c61197500c4 | 56 | |
Kjansen |
19:3c61197500c4 | 57 | /** |
Kjansen |
19:3c61197500c4 | 58 | * @struct ain_platform_ops |
Kjansen |
19:3c61197500c4 | 59 | * @brief Structure holding analog input function pointers that |
Kjansen |
19:3c61197500c4 | 60 | * point to the platform specific function |
Kjansen |
19:3c61197500c4 | 61 | */ |
Kjansen |
19:3c61197500c4 | 62 | struct ain_platform_ops { |
Kjansen |
19:3c61197500c4 | 63 | /** Analog input initialization function pointer */ |
Kjansen |
19:3c61197500c4 | 64 | int32_t(*init)(struct ain_desc **, const struct ain_init_param *); |
Kjansen |
19:3c61197500c4 | 65 | /** Analog input read function pointer */ |
Kjansen |
19:3c61197500c4 | 66 | int32_t(*read)(struct ain_desc *, float *); |
Kjansen |
19:3c61197500c4 | 67 | /** Analog input remove function pointer */ |
Kjansen |
19:3c61197500c4 | 68 | int32_t(*remove)(struct ain_desc *); |
Kjansen |
19:3c61197500c4 | 69 | }; |
Kjansen |
19:3c61197500c4 | 70 | |
Kjansen |
19:3c61197500c4 | 71 | /******************************************************************************/ |
Kjansen |
19:3c61197500c4 | 72 | /************************ Functions Declarations ******************************/ |
Kjansen |
19:3c61197500c4 | 73 | /******************************************************************************/ |
Kjansen |
19:3c61197500c4 | 74 | /* Read analog input voltage */ |
Kjansen |
19:3c61197500c4 | 75 | int32_t ain_get_voltage(struct ain_desc *desc, float *value); |
Kjansen |
19:3c61197500c4 | 76 | |
Kjansen |
19:3c61197500c4 | 77 | /* Initialize the analog input pin */ |
Kjansen |
19:3c61197500c4 | 78 | int32_t ain_init(struct ain_desc **desc, |
Kjansen |
19:3c61197500c4 | 79 | const struct ain_init_param *param); |
Kjansen |
19:3c61197500c4 | 80 | |
Kjansen |
19:3c61197500c4 | 81 | /* Free the resources allocated by ain_init() */ |
Kjansen |
19:3c61197500c4 | 82 | int32_t ain_remove(struct ain_desc *desc); |
Kjansen |
19:3c61197500c4 | 83 | |
Kjansen |
19:3c61197500c4 | 84 | #endif |