#define PIN_MODE_INPUT_PULLDOWN 0x03 //下拉输入 #define PIN_MODE_OUTPUT_OD 0x04 //开漏输出#define PIN_LOW 0x00//设置为低电平 #define PIN_HIGH 0x01//设置为高电平 3.操作引脚 rt_pin_read(LED_PIN);//读取引脚状态,int类型 rt_pin_write(LED_PIN, PIN_LOW);//设置引脚状态,下同 rt_pin...
#define LED_PIN GET_PIN(I, 8) /*define function*/ static int LED_init(void); /** * @brief mian * @param None * @retval None */ int main(void) { rt_uint32_t count = 1; LED_init(); while(count++) { rt_thread_mdelay(500); rt_pin_write(LED_PIN, PIN_HIGH); rt_thread_...
{ rt_pin_write(LED_PIN, PIN_HIGH); rt_thread_mdelay(500); rt_pin_write(LED_PIN, PIN_LOW); rt_thread_mdelay(500); } } 烧写运行demo,P001接板子电源口,运行结果如下,电压还是算合理的 分类: 开发日志 标签: rt-thread , ra6m3 , renesas 好文要顶 关注我 收藏该文 微信分享 hywing ...
int main(void) { int count = 1; /* Initialize all configured peripherals */ //MX_GPIO_Init(); rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT); while (count++) { rt_pin_write(LED_PIN, PIN_LOW); LOG_D("Hello RT-Thread!"); rt_thread_mdelay(1000); rt_pin_write(LED_PIN, PIN_HIGH);...
我们在代码里面直接调用rt_pin_mode(rt_base_t pin, rt_base_t mode)函数即可 /* defined the LED0 pin: PF9 */#defineLED0_PIN89intmain(void){/* set LED0 pin mode to output */rt_pin_mode(LED0_PIN,PIN_MODE_OUTPUT);} 如果不想去找IO口的序号,还有另外一种写法 ...
void Led_Entry(void*parameter) { rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT); while(1) { rt_pin_write(LED_PIN, PIN_HIGH); rt_kprintf("Led On\n"); rt_thread_mdelay(1000); rt_pin_write(LED_PIN, PIN_LOW); rt_kprintf("Led Off\n"); ...
rt_pin_write(pin, PIN_HIGH); ///这里向PE1写入低电平,红色的熄灭。 rt_thread_mdelay(500); } } 所以,通过上面代码分析,RT-Thread Studio默认创建的AB32VG1工程,实现RGB的红色LED闪烁的功能。那我们就可以仿照这个程序,对主程序做如下修改,即可实现RGB三色的变换闪烁。代码如下: ...
;voidhal_entry(void){rt_kprintf("\nHello RT-Thread!\n");while(1){rt_pin_write(LED_PIN,PIN_HIGH);rt_thread_mdelay(500);rt_pin_write(LED_PIN,PIN_LOW);rt_thread_mdelay(500);}} 烧写运行demo,P001接板子电源口,运行结果如下,电压还是算合理的...
\n"); rt_pin_write(BEEP_PIN_NUM, PIN_HIGH); } static void pin_beep_sample(void) { /* 按键0引 脚为输入模式 */ rt_pin_mode(KEY0_PIN_NUM, PIN_MODE_INPUT_PULLUP); /* 绑定中断, 下降沿模式, 回调函数名为beep_on */ rt_pin_attach_irq(KEY0_PIN_NUM, PIN_IRQ_MODE_FALLING, ...
假设LED 高电平灭,调用 API 输出低电平,使 LED 熄灭。 intled_off(void){/* 调用 API 输出高电平 */rt_pin_write(LED_PIN,PIN_HIGH);return0;} LED 状态翻转 intled_toggle(void);//LED 灯亮灭状态翻转 要使LED 状态翻转应先利用APIrt_pin_read读出当前电平,然后输出相反电平 ...