dev_config.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @file
  3. *
  4. * @brief Public devices config for drivers.
  5. */
  6. #ifndef ZEPHYR_INCLUDE_DEV_CONFIG_H_
  7. #define ZEPHYR_INCLUDE_DEV_CONFIG_H_
  8. #include <board_cfg.h>
  9. #if defined(CONFIG_SOC_SERIES_LARK)
  10. #include <drivers/cfg_drv/pinctrl_lark.h>
  11. #include <drivers/cfg_drv/dev_lark.h>
  12. #elif defined(CONFIG_SOC_SERIES_LEOPARD)
  13. #include <drivers/cfg_drv/pinctrl_leopard.h>
  14. #include <drivers/cfg_drv/dev_leopard.h>
  15. #else
  16. #errro "not soc series"
  17. #endif
  18. struct dma_cfg {
  19. const char *dma_dev_name;
  20. uint8_t dma_id;
  21. uint8_t dma_chan; // 0xff vchan, 0-3 pchan
  22. uint8_t use_dma; // 0 not use
  23. };
  24. struct gpio_cfg {
  25. const char *gpio_dev_name;
  26. uint8_t gpion; // 0-31
  27. uint8_t flag; //GPIO_ACTIVE_HIGH or GPIO_ACTIVE_LOW
  28. uint8_t use_gpio; // 0 not use
  29. };
  30. struct pwm_cfg {
  31. const char *dev_name;
  32. uint16_t period; // period (max duty) in pwm clock cycles
  33. uint8_t chan; // 0-31
  34. uint8_t flag; // 1: active high; 0: active low
  35. };
  36. #define DMA_CFG_MAKE(dev_name, id, chan, use) {\
  37. .dma_dev_name = dev_name, \
  38. .dma_id = id,\
  39. .dma_chan = chan,\
  40. .use_dma = use, \
  41. }
  42. #define DMA_CFG_SET(dev_name, id, chan, use) (\
  43. .dma_dev_name = dev_name, \
  44. .dma_id = id,\
  45. .dma_chan = chan,\
  46. .use_dma = use, \
  47. )
  48. #define COND_DMA_CODE(_flag, id, chan) COND_CODE_1(_flag,DMA_CFG_SET(CONFIG_DMA_0_NAME, id, chan, 1), DMA_CFG_SET(NULL, 0, 0, 0))
  49. #define GPIO_CFG_MAKE(dev_name, gpio, gflag, use) {\
  50. .gpio_dev_name = dev_name, \
  51. .gpion = gpio,\
  52. .flag = gflag,\
  53. .use_gpio = use,\
  54. }
  55. #define GPIO_CFG_SET(dev_name, gpio, gflag, use) (\
  56. .gpio_dev_name = dev_name, \
  57. .gpion = gpio,\
  58. .flag = gflag,\
  59. .use_gpio = use,\
  60. )
  61. #define COND_GPIO_CODE(_flag, gpio_dev, gpio, gflag) COND_CODE_1(_flag,GPIO_CFG_SET(gpio_dev, gpio, gflag, 1), GPIO_CFG_SET(NULL, 0, 0, 0))
  62. #define PWM_CFG_MAKE(_dev_name, _chan, _period, _flag) {\
  63. .dev_name = _dev_name, \
  64. .chan = _chan,\
  65. .period = _period,\
  66. .flag = _flag, \
  67. }
  68. #endif //ZEPHYR_INCLUDE_DEV_CONFIG_H_