当前位置: 首页 > news >正文

深圳做门户网站的网络公司网站建设背景介绍

深圳做门户网站的网络公司,网站建设背景介绍,平台制作公司,网络网页制作这篇文章是讲解的pwm控制三色灯的部分#xff0c;这部分也是后续全彩智能灯的基础。 硬件原理如下 IO管脚定义在hi-12f_v1.1.2-规格书-20211202.pdf文档中 GPIO API API名称 说明 unsigned int IoTGpioInit(unsigned int id); GPIO模块初始化 hi_u32 hi_io_set_func(hi_i…这篇文章是讲解的pwm控制三色灯的部分这部分也是后续全彩智能灯的基础。 硬件原理如下 IO管脚定义在hi-12f_v1.1.2-规格书-20211202.pdf文档中 GPIO API API名称 说明 unsigned int IoTGpioInit(unsigned int id); GPIO模块初始化 hi_u32 hi_io_set_func(hi_io_name id, hi_u8 val); 配置某个IO的复用功能 unsigned int IoTPwmInit(unsigned int port); 初始化一个PWM设备 unsigned int IoTPwmStart(unsigned int port, unsigned short duty, unsigned int freq); 根据给定的输出频率和占空比从指定端口启动PWM信号输出。 unsigned int IoTPwmStop(unsigned int port); 停止来自指定端口的PWM信号输出。 在官方给的代码中IoTPwmStart占空比参数范围为1-99也就是不能达到全灭和全亮的程度。所以对源码进行修改。 修改D:\DevEcoProjects\test\src\device\hisilicon\hispark_pegasus\hi3861_adapter\hals\iot_hardware\wifiiot_lite\hal_iot_pwm.c unsigned int IoTPwmStart(unsigned int port, unsigned short duty, unsigned int freq) {unsigned short hiDuty;unsigned short hiFreq;if ((freq 0) || (duty DUTY_MAX)) {return IOT_FAILURE;}if ((CLK_160M / freq) SHORT_MAX) {return IOT_FAILURE;}hiFreq (unsigned short)(CLK_160M / freq);hiDuty (duty * hiFreq) / DUTY_MAX;return hi_pwm_start((hi_pwm_port)port, hiDuty, hiFreq); } 使其支持0和100. 修改D:\DevEcoProjects\test\src\device\hisilicon\hispark_pegasus\sdk_liteos\platform\drivers\pwm\hi_pwm.c hi_u32 hi_pwm_start(hi_pwm_port port, hi_u16 duty, hi_u16 freq) {hi_u32 ret;if ((pwm_check_port(port) ! HI_ERR_SUCCESS) || (freq 0)|| (duty freq)) {return HI_ERR_PWM_INVALID_PARAMETER;}if (pwm_is_init(port) HI_FALSE) {return HI_ERR_PWM_NO_INIT;}ret pwm_lock(port);if (ret ! HI_ERR_SUCCESS) {return ret;}pwm_set_enable(port, HI_TRUE);pwm_set_freq(port, freq);pwm_set_duty(port, duty);pwm_take_effect(port);return pwm_unlock(port); } 同样是使其支持0和100. 以上就是对源码的修改。下面是测试代码部分。 修改D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\BUILD.gn文件 # Copyright (c) 2023 Beijing HuaQing YuanJian Education Technology Co., Ltd # Licensed under the Apache License, Version 2.0 (the License); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an AS IS BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import(//build/lite/config/component/lite_component.gni)lite_component(demo) {features [#base_00_helloworld:base_helloworld_example,#base_01_led:base_led_example,#base_02_loopkey:base_loopkey_example,#base_03_irqkey:base_irqkey_example,#base_04_adc:base_adc_example,base_05_pwm:base_pwm_example,] } 创建D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\base_05_pwm文件夹 文件夹中创建D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\base_05_pwm\base_pwm_example.c文件D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\base_05_pwm\BUILD.gn文件 # Copyright (c) 2023 Beijing HuaQing YuanJian Education Technology Co., Ltd # Licensed under the Apache License, Version 2.0 (the License); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an AS IS BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. static_library(base_pwm_example) {sources [base_pwm_example.c,]include_dirs [//utils/native/lite/include,//kernel/liteos_m/kal/cmsis,//base/iot_hardware/peripheral/interfaces/kits,//vendor/hqyj/fs_hi3861/common/bsp/include] } /** Copyright (C) 2023 HiHope Open Source Organization .* Licensed under the Apache License, Version 2.0 (the License);* you may not use this file except in compliance with the License.* You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/#include stdio.h #include unistd.h#include cmsis_os2.h #include hi_io.h #include iot_errno.h #include iot_gpio.h #include iot_pwm.h #include ohos_init.h#define RED_LED_PIN_NAME HI_IO_NAME_GPIO_10 #define RED_LED_PIN_FUNCTION WIFI_IOT_IO_FUNC_GPIO_10_GPIO #define GREEN_LED_PIN_NAME HI_IO_NAME_GPIO_2 #define GREEN_LED_PIN_FUNCTION WIFI_IOT_IO_FUNC_GPIO_2_GPIO #define BLUE_LED_PIN_NAME HI_IO_NAME_GPIO_7 #define BLUE_LED_PIN_FUNCTION WIFI_IOT_IO_FUNC_GPIO_7_GPIO#define PWM_FREQ_DIVITION 64000 #define DELAY_US 30000 #define STACK_SIZE (4096) #define PWM0_PORT_NUM (0) #define PWM1_PORT_NUM (1) #define PWM2_PORT_NUM (2)static void PWMLedDemoTask(void) {// pwm占空比记录变量unsigned short duty0 0, duty1 40, duty2 80;// 记录占空比是增加还是减少hi_bool duty0_increase HI_TRUE;hi_bool duty1_increase HI_TRUE;hi_bool duty2_increase HI_TRUE;// 炫彩灯板的红灯hi_io_set_func(RED_LED_PIN_NAME, HI_IO_FUNC_GPIO_10_PWM1_OUT);hi_io_set_func(GREEN_LED_PIN_NAME, HI_IO_FUNC_GPIO_2_PWM2_OUT);hi_io_set_func(BLUE_LED_PIN_NAME, HI_IO_FUNC_GPIO_7_PWM0_OUT);IoTPwmInit(PWM0_PORT_NUM);IoTPwmInit(PWM1_PORT_NUM);IoTPwmInit(PWM2_PORT_NUM);while (1) {// use PWM control RED LED brightness// 蓝灯呼吸代码IoTPwmStart(PWM0_PORT_NUM, duty0, PWM_FREQ_DIVITION);if (duty0_increase) {duty0;if (duty0 100) {// 自增超过100后需要进行自减duty0_increase HI_FALSE;duty0 99;}} else {duty0--;if (duty0 0) {// 自减到0后需要进行自增duty0_increase HI_TRUE;}}// 红灯呼吸代码IoTPwmStart(PWM1_PORT_NUM, duty1, PWM_FREQ_DIVITION);if (duty1_increase) {duty1;if (duty1 100) {duty1_increase HI_FALSE;duty1 99;}} else {duty1--;if (duty1 0) {duty1_increase HI_TRUE;}}// 绿灯呼吸代码IoTPwmStart(PWM2_PORT_NUM, duty2, PWM_FREQ_DIVITION);if (duty2_increase) {duty2;if (duty2 100) {duty2_increase HI_FALSE;duty2 99;}} else {duty2--;if (duty2 0) {duty2_increase HI_TRUE;}}usleep(DELAY_US);} }static void PWMLedDemo(void) {osThreadAttr_t attr;// set Red LED pin to GPIO functionIoTGpioInit(RED_LED_PIN_NAME);attr.name PWMLedDemoTask;attr.attr_bits 0U;attr.cb_mem NULL;attr.cb_size 0U;attr.stack_mem NULL;attr.stack_size STACK_SIZE;attr.priority osPriorityNormal;if (osThreadNew(PWMLedDemoTask, NULL, attr) NULL) {printf([ColorfulLightDemo] Falied to create PWMLedDemoTask!\n);} } APP_FEATURE_INIT(PWMLedDemo);目录结构 │ config.json │ ├─common │ └─bsp │ ├─include │ └─src ├─demo │ │ BUILD.gn │ │ │ ├─base_00_helloworld │ │ base_helloworld_example.c │ │ BUILD.gn │ │ │ ├─base_01_led │ │ base_led_example.c │ │ BUILD.gn │ │ │ ├─base_02_loopkey │ │ base_loopkey_example.c │ │ BUILD.gn │ │ │ ├─base_03_irqkey │ │ base_irqkey_example.c │ │ BUILD.gn │ │ │ ├─base_04_adc │ │ base_adc_example.c │ │ BUILD.gn │ │ │ └─base_05_pwm │ base_pwm_example.c │ BUILD.gn │ └─doc│ HarmonyOS开发板实验指导书 v2.1.pdf│ 华清远见 FS_Hi3861开发指导.md│ 华清远见 FS_Hi3861新手入门手册.md│├─board│ FS-Hi3861-V4.2.pdf│ FS-Hi3861QDB-V3.2.pdf│ hi-12f_kit_v1.1.0规格书-20211025.pdf│ hi-12f_v1.1.2-规格书-20211202.pdf│ nodemcu-hi-07s_12f-kit_v1.1-20210913.pdf│ RTplay2.01_2024-06-14.pdf│└─figures 使用build编译成功后使用upload进行烧录。 运行效果如下三色灯颜色会变化。
http://www.dnsts.com.cn/news/28283.html

相关文章:

  • 宁夏住房和城乡建设部网站汕头网站设计有限公司
  • 建设通网站有法律特色美食网站建设
  • 中国建设银行保函查询网站什么软件可以看网站
  • 提交网站地图wordpress链接伪静态
  • 公司网站建设申请报告域通联达网站
  • 福州网站建设免费咨询ug.wordpress.org
  • 做网站开源框架长沙产品网站建设
  • 网站伪静态如何配置Wordpress多站点为什么注册不了
  • 东莞公司网站建设静态网页设计实训报告摘要
  • 移动端网站开发与网页开发区别免费做简易网站
  • pc端网站生成wap版wordpress搬家跳回首页
  • 网站建设费用的账务处理那个网站攻略做的好
  • 模板网站建设市场调研报告模板范文
  • 企业网站pv是什么网站建设征求意见
  • 东莞寮步镇网站做企业网站建设
  • 加热器网站怎么做的好单库如何做网站
  • 购物网站怎么经营xmlrpc wordpress
  • 以域名做网站关键词最超值的郑州网站建设
  • 动易网站安装南京seo优化公司
  • 辽宁网站建设公司苏州网站建设找苏州聚尚网络推荐
  • 跨境建站服务公司网站后台目录如何保护
  • 男女直接做视频网站建网站怎么赚流量
  • 淘宝客网站里面catid=16网站开发工资一般多少钱
  • 虹口建设机械网站制作怎么进入外网
  • 免费网站模板 php郑州低价网站制作
  • 网站权重是怎么提升的wordpress幻灯片
  • 免费网站商城模板wordpress嵌入网页
  • 网站建设百度云织梦网站广告
  • 第一次做网站选多大空间青海中小企业网站建设
  • 可信网站收费吗万网建站教程