hpm_ov5640.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * Copyright (c) 2021 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_OV5640_H
  8. #define HPM_OV5640_H
  9. #include "hpm_common.h"
  10. #include "hpm_camera_config.h"
  11. #define OV5640_ACTIVE_IMAGE_WIDTH (2592U)
  12. #define OV5640_ACTIVE_IMAGE_HEIGHT (1944U)
  13. #define OV5640_I2C_ADDR (0x3CU)
  14. #define OV5640_CHIP_ID_HIGH_BYTE_ADDR (0x300A)
  15. #define OV5640_CHIP_ID_HIGH_BYTE_VALUE (0x56)
  16. #define OV5640_CHIP_ID_LOW_BYTE_ADDR (0x300B)
  17. #define OV5640_CHIP_ID_LOW_BYTE_VALUE (0x40)
  18. #define OV5640_RST_ACTIVE 0
  19. #define OV5640_RST_INACTIVE 1
  20. #define OV5640_PWDN_ACTIVE 1
  21. #define OV5640_PWDN_INACTIVE 0
  22. /* Camera clock configuration elements. */
  23. typedef struct {
  24. uint32_t resolution;
  25. uint8_t fps;
  26. uint8_t pllctrl1;
  27. uint8_t pllctrl2;
  28. uint8_t vfifoctrl0c;
  29. uint8_t pclkdiv;
  30. uint8_t pclkperiod;
  31. } ov5640_clock_config_t;
  32. typedef struct {
  33. uint8_t lightmode;
  34. uint8_t awbctrl;
  35. uint8_t awbr_h;
  36. uint8_t awbr_l;
  37. uint8_t awbg_h;
  38. uint8_t awbg_l;
  39. uint8_t awbb_h;
  40. uint8_t awbb_l;
  41. } ov5640_light_mode_config_t;
  42. typedef struct {
  43. uint8_t effect;
  44. uint8_t sdectrl0;
  45. uint8_t sdectrl3;
  46. uint8_t sdectrl4;
  47. } ov5640_special_effect_config_t;
  48. typedef struct {
  49. uint16_t regaddr;
  50. uint8_t regval;
  51. } ov5640_reg_val_t;
  52. typedef struct {
  53. uint32_t resolution; /*!< Resolution. */
  54. ov5640_reg_val_t param[]; /*!< register value from 0x3800 to 0x3813. */
  55. } ov5640_resolution_param_t;
  56. #ifdef __cplusplus
  57. extern "C" {
  58. #endif
  59. /*
  60. * ov5640 initialization
  61. */
  62. hpm_stat_t ov5640_init(camera_context_t *context, camera_config_t *ov_config);
  63. /*
  64. * ov5640 read register
  65. */
  66. hpm_stat_t ov5640_read_register(camera_context_t *context, uint16_t reg, uint8_t *buf);
  67. /*
  68. * ov5640 write register
  69. */
  70. hpm_stat_t ov5640_write_register(camera_context_t *context, uint16_t reg, uint8_t val);
  71. /*
  72. * ov5640 write multi register
  73. */
  74. hpm_stat_t ov5640_write_multi_registers(camera_context_t *context, const ov5640_reg_val_t regval[], uint32_t len);
  75. /*
  76. * ov5640 softreset
  77. */
  78. hpm_stat_t ov5640_software_reset(camera_context_t *context);
  79. /*
  80. * ov5640 set pixel format
  81. */
  82. hpm_stat_t ov5640_set_pixel_format(camera_context_t *context, display_pixel_format_t pixel_format);
  83. /*
  84. * ov5640 check chip id
  85. */
  86. hpm_stat_t ov5640_check_chip_id(camera_context_t *context);
  87. /*
  88. * ov5640 set image size
  89. */
  90. hpm_stat_t ov5640_set_image_size(camera_context_t *context, camera_config_t *ov_config);
  91. /*
  92. * ov5640 set clock config
  93. */
  94. hpm_stat_t ov5640_set_clock_config(camera_context_t *context, camera_config_t *ov_config);
  95. /*
  96. * ov5640 set interface
  97. */
  98. hpm_stat_t ov5640_set_interface(camera_context_t *context, camera_config_t *ov_config);
  99. /**
  100. * @brief set ov5640 flip
  101. *
  102. * @param context @ref camera_context_t
  103. * @return hpm_stat_t
  104. */
  105. hpm_stat_t ov5640_flip(camera_context_t *context);
  106. /*
  107. * ov5640 start
  108. */
  109. hpm_stat_t ov5640_start(camera_context_t *context);
  110. /*
  111. * ov5640 stop
  112. */
  113. hpm_stat_t ov5640_stop(camera_context_t *context);
  114. /*
  115. * ov5640 set brightness
  116. */
  117. hpm_stat_t ov5640_set_brightness(camera_context_t *context, int32_t brightness);
  118. /*
  119. * ov5640 set contrast
  120. */
  121. hpm_stat_t ov5640_set_contrast(camera_context_t *context, int32_t contrast);
  122. /*
  123. * ov5640 set saturation
  124. */
  125. hpm_stat_t ov5640_set_saturation(camera_context_t *context, int32_t saturation);
  126. /*
  127. * ov5640 set environment light mode
  128. */
  129. hpm_stat_t ov5640_set_light_mode(camera_context_t *context, int32_t lightmode);
  130. /*
  131. * ov5640 set special effect
  132. */
  133. hpm_stat_t ov5640_set_special_effect(camera_context_t *context, int32_t effect);
  134. /**
  135. * @brief ov5640 power up
  136. *
  137. * @param [in] context camera_context_t
  138. */
  139. void ov5640_power_up(camera_context_t *context);
  140. #ifdef __cplusplus
  141. }
  142. #endif
  143. #endif /* HPM_OV5640_H */