luat_mcu.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef LUAT_MCU_H
  2. #define LUAT_MCU_H
  3. #include "luat_base.h"
  4. enum
  5. {
  6. LUAT_MCU_PERIPHERAL_UART,
  7. LUAT_MCU_PERIPHERAL_I2C,
  8. LUAT_MCU_PERIPHERAL_SPI,
  9. LUAT_MCU_PERIPHERAL_PWM,
  10. LUAT_MCU_PERIPHERAL_GPIO,
  11. LUAT_MCU_PERIPHERAL_I2S,
  12. LUAT_MCU_PERIPHERAL_LCD,
  13. LUAT_MCU_PERIPHERAL_CAM,
  14. };
  15. int luat_mcu_set_clk(size_t mhz);
  16. int luat_mcu_get_clk(void);
  17. const char* luat_mcu_unique_id(size_t* t);
  18. long luat_mcu_ticks(void);
  19. uint32_t luat_mcu_hz(void);
  20. uint64_t luat_mcu_tick64(void);
  21. int luat_mcu_us_period(void);
  22. uint64_t luat_mcu_tick64_ms(void);
  23. void luat_mcu_set_clk_source(uint8_t source_main, uint8_t source_32k, uint32_t delay);
  24. /**
  25. * @brief 用户是否设置了外设的IOMUX
  26. * @param type 外设类型 LUAT_MCU_PERIPHERAL_XXX
  27. * @param sn 外设序号,0~7
  28. * @return 0 用户配置了 1用户没配置
  29. */
  30. uint8_t luat_mcu_iomux_is_default(uint8_t type, uint8_t sn);
  31. /**
  32. * @brief 用户控制外设的IOMUX,如果不配置或者取消,则外设初始化时使用默认配置
  33. * @param type 外设类型 LUAT_MCU_PERIPHERAL_XXX
  34. * @param sn 外设序号,0~7
  35. * @param pad_index pad序号,具体看芯片,可能是GPIO序号,可能是PAD序号。如果是-1,则表示取消配置
  36. * @param alt 复用功能序号,具体看芯片
  37. * @param is_input,是否是单纯输入功能
  38. * @return 无
  39. */
  40. void luat_mcu_iomux_ctrl(uint8_t type, uint8_t sn, int pad_index, uint8_t alt, uint8_t is_input);
  41. void luat_mcu_set_hardfault_mode(int mode);
  42. /**
  43. * @brief 外部晶振参考信号输出
  44. * @param main_enable 主晶振参考信号输出使能,0关闭,其他开启
  45. * @param slow_32k_enable 慢速(一般是32K)晶振参考信号输出使能,0关闭,其他开启
  46. * @return 无
  47. */
  48. void luat_mcu_xtal_ref_output(uint8_t main_enable, uint8_t slow_32k_enable);
  49. #endif