标签:
一个包含各种驱动的工程,main函数中用驱动函数实现功能
C:\Users\LiTao\Desktop\儿童智能硬件资料\my_workspace\pwm
改造实现了PWM两路输出
1 #include <stdbool.h> 2 #include <stdint.h> 3 #include "nrf_delay.h" 4 #include "nrf_gpio.h" 5 #include "boards.h" 6 #include "nrf_pwm.h" 7 8 /** 9 * @brief Function for application main entry. 10 */ 11 int main(void) 12 { 13 uint8_t t; 14 15 nrf_pwm_config_t pwm_config = PWM_DEFAULT_CONFIG;// 16 17 pwm_config.mode = PWM_MODE_LED_255; // 8-bit resolution, 122Hz PWM frequency, 32kHz timer frequency (prescaler 9) 18 pwm_config.num_channels = 2; 19 pwm_config.gpio_num[0] = LED_0; //该设置为使用哪个IO口作为PWM输出 20 pwm_config.gpio_num[1] = LED_1; //该设置为使用哪个IO口作为PWM输出 21 22 nrf_pwm_init(&pwm_config); //pwm初始化 23 24 // Configure LED-pins as outputs 25 nrf_gpio_cfg_output(LED_0); 26 nrf_gpio_cfg_output(LED_1); 27 28 29 30 // LED 0 and LED 1 blink alternately. 31 t=1; 32 while(true) 33 { 34 t=t+1; 35 nrf_pwm_set_value(0, t); 36 nrf_delay_ms(50); 37 38 39 if(t>200)t=0; 40 // nrf_pwm_set_value(1, 200); 41 } 42 }
nrf_pwm_config_t pwm_config = PWM_DEFAULT_CONFIG;[M1]
标签:
原文地址:http://www.cnblogs.com/happyhappy/p/4719685.html