main.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <stdarg.h>
  2. #include <stdint.h>
  3. #include "ycdef.h"
  4. #include "yc11xx.h"
  5. #include "yc11xx_gpio.h"
  6. #include "yc11xx_pwm.h"
  7. #include "yc11xx_uart.h"
  8. #include "system.h"
  9. void PWM_Config(GPIO_NUM gpio, PWM_ChxTypeDef pwm_channel, uint16_t pcnt,uint16_t ncnt, PWM_ClkdivDef clk_div,START_TypeDef LEVEL, PWM_SwitchDef SWITCH);
  10. void PWM_Test();
  11. void PWM_Config(GPIO_NUM gpio, PWM_ChxTypeDef pwm_channel, uint16_t pcnt,uint16_t ncnt, PWM_ClkdivDef clk_div,START_TypeDef LEVEL, PWM_SwitchDef SWITCH)
  12. {
  13. PWM_InitTypeDef PWM_InitStruct;
  14. PWM_InitStruct.pwm_gpio = gpio;
  15. PWM_InitStruct.PWM_Channel = pwm_channel;
  16. PWM_InitStruct.HighLevelPeriod = pcnt;
  17. PWM_InitStruct.LowLevelPeriod = ncnt;
  18. PWM_InitStruct.pwm_ctrl.clk_div = clk_div;
  19. PWM_InitStruct.pwm_ctrl.StartLevel = LEVEL;
  20. PWM_InitStruct.pwm_ctrl.pwm_switch = SWITCH;
  21. PWM_Init(&PWM_InitStruct);
  22. }
  23. int hcnt=0x3000;
  24. int lcnt = 0x3000;
  25. void PWM_Test()
  26. {
  27. MyPrintf("\r\n*********************this is 11XX PWM TEST DEMO***********************\r\n ");
  28. PWM_Config(GPIO_19,PWM_CHANNEL_0,hcnt,lcnt,PWM_CLK_DIVISION_0,OutputLow,PWM_ENABLE);
  29. }
  30. //void _assert_handler(const char* file, int line,const char* func)
  31. //{
  32. // while(1);
  33. //}
  34. int main(void)
  35. {
  36. printport_init();
  37. PWM_Test();
  38. while(1);
  39. }