drv_adc.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * File : drv_adc.h
  3. * This file is part of GK710X BSP for RT-Thread distribution.
  4. *
  5. * Copyright (c) 2017 GOKE Microelectronics Co., Ltd.
  6. * All rights reserved
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. *
  22. * Visit http://www.goke.com to get contact with Goke.
  23. *
  24. * Change Logs:
  25. * Date Author Notes
  26. */
  27. #ifndef ADC_H_
  28. #define ADC_H_
  29. #include <rtdef.h>
  30. #ifdef RT_USING_ADC
  31. /****************************************************************************
  32. * #define section
  33. * add constant #define here if any
  34. ***************************************************************************/
  35. #define MAX_CHANNEL_NO (2)
  36. #define ADC_INIT_ALREADY (0x33)
  37. #define ADC_CMD_READ_RAW_DATA (0x22)
  38. #define ADC_CMD_DISABLE (0x44)
  39. /****************************************************************************
  40. * ADT section
  41. * add Abstract Data Type definition here
  42. ***************************************************************************/
  43. struct wrap_adc_obj
  44. {
  45. rt_uint32_t id;
  46. rt_uint32_t init_flag;
  47. rt_uint32_t active_channel_no;
  48. rt_uint32_t handle;
  49. rt_uint16_t channel_data[MAX_CHANNEL_NO];
  50. // bind to the rtdev..
  51. rt_device_t rt_dev;
  52. };
  53. typedef struct
  54. {
  55. rt_uint32_t channel;
  56. rt_uint32_t adc_data;
  57. } ADC_INFO;
  58. /****************************************************************************
  59. * extern variable declaration section
  60. ***************************************************************************/
  61. /****************************************************************************
  62. * section
  63. * add function prototype here if any
  64. ***************************************************************************/
  65. void rt_hw_adc_init(void);
  66. #endif
  67. #endif /* ADC_H_ */