您当前的位置: 首页 >  ar

txwtech

暂无认证

  • 2浏览

    0关注

    813博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

鸿蒙开发板Hi3861_通过GPIO12 PWM呼吸灯实验-——基于code-2.0-CANARY

txwtech 发布时间:2021-08-23 22:29:35 ,浏览量:2

//通过PWM呼吸灯实验-A12连接一个LED, A12接长脚,短脚接GND

//,by txwtech

编译报错参考:

https://blog.csdn.net/txwtech/article/details/119853772

//通过PWM呼吸灯实验-A12连接一个LED, A12接长脚,短脚接GND
//,by txwtech
#include  
#include "ohos_init.h"
#include "cmsis_os2.h"
#include "iot_gpio.h"
#include "hi_io.h"
#include "iot_pwm.h"
#include "hi_pwm.h"
#include "hi_time.h"


static void GpioTask(void *arg)
{
    (void) arg;
   hi_gpio_init();
   hi_io_set_func(HI_IO_NAME_GPIO_12,HI_IO_FUNC_GPIO_12_PWM3_OUT);  
  // 
   hi_pwm_init(HI_PWM_PORT_PWM3);   
   hi_pwm_set_clock(PWM_CLK_160M);  
   while(1)
   {
    
       IotGpioValue val=IOT_GPIO_VALUE0;
       IoTGpioGetOutputVal(HI_IO_NAME_GPIO_12,&val);
       

       printf("execute pwm,value: %d\n",val);
       for(int i=10;i10;i--)
       {
          hi_pwm_start(HI_PWM_PORT_PWM3,i,200);
          osDelay(1);
       }
       
       
       
   }
}
static void GpioEntry(void)
{
    osThreadAttr_t attr={0};
    attr.name="GpioTask";
    attr.stack_size=4096;
    attr.priority=osPriorityNormal;
    if(osThreadNew(GpioTask,NULL,&attr)==NULL)
    {
        printf("[GpioEntry] create GpioTask failed!\n");
    }
}
SYS_RUN(GpioTask);
//SYS_RUN(GpioEntry);

 https://blog.csdn.net/YangHxuan/article/details/118911199 其他资料参考

关注
打赏
1665060526
查看更多评论
立即登录/注册

微信扫码登录

0.0545s