Running stm32f407 on RT-Thread and enbale the LED

Created at 2020-12-11 11:01:35

Forwarded from RT-Thread Community Developer luzixing

Hardware:

  • At least 1 GPIO, which can be used to pick up LED lights
  • 1 string of serial port, used to make the msh shell terminal

Software:

  • Serial Port Driver
  • PIN Driver

Preparation:

  • Configure the PIN number of the development board LED light connection.

The implementation code:

#include <rtthread.h>
#include <rtdevice.h>

#define LED_PIN1     21
#define LED_PIN2     22

void led_link(void *parameter)
{
        rt_uint8_t count = 0;
        rt_pin_mode(LED_PIN1, PIN_MODE_OUTPUT);
        rt_pin_mode(LED_PIN2, PIN_MODE_OUTPUT);

        while (1)
        {
                /* led1 on */
                rt_kprintf("led on, count : %d <br>", count);
                count++;
                rt_pin_write(LED_PIN1, 0);
                rt_pin_write(LED_PIN2, 0);
                rt_thread_delay(RT_TICK_PER_SECOND / 2); /* ?? 500 ?? */
                
                /* led1 off */
                rt_kprintf("led off <br>");
                rt_pin_write(LED_PIN1, 1);
                rt_pin_write(LED_PIN2, 1);
                rt_thread_delay(RT_TICK_PER_SECOND / 2);
        }
}

MSH_CMD_EXPORT(led_link, led blink sample);

Process:

Experimental steps:

  • Start by configuring the pins
  • Set the pin to the output pin and turn on/ off the light by lighting its level.

Results:

1535599052(1).jpg微信图片_20180830111808.jpg

更多

Follower
0
Views
602
0 Answer
There is no answer, come and add the answer

Write Your Answer

Log in to publish your answer,Click here to log in.

Create
Post

Share