mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-27 02:40:00 +08:00
删除driver中的led相应文件改成直接使用pin操作
This commit is contained in:
1 parent
0c25d7c82b
commit
7d8cfef866
6 files changed
+302
-423
No files matched your search
@@ -11,34 +11,19 @@
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include "board.h"
|
||||
#include <drivers/pin.h>
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : assert_failed
|
||||
* Description : Reports the name of the source file and the source line number
|
||||
* where the assert error has occurred.
|
||||
* Input : - file: pointer to the source file name
|
||||
* - line: assert error line source number
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
|
||||
void assert_failed(uint8_t *file, uint32_t line)
|
||||
{
|
||||
rt_kprintf("\n\r Wrong parameter value detected on\r\n");
|
||||
rt_kprintf(" file %s\r\n", file);
|
||||
rt_kprintf(" line %d\r\n", line);
|
||||
|
||||
while (1) ;
|
||||
}
|
||||
#define LED_PIN_NUM 1 /* PA1 */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
rt_hw_led_init();
|
||||
rt_pin_mode(LED_PIN_NUM, PIN_MODE_OUTPUT);
|
||||
|
||||
while(1)
|
||||
{
|
||||
rt_hw_led_on(0);
|
||||
rt_pin_write(LED_PIN_NUM, PIN_LOW);
|
||||
rt_thread_delay(RT_TICK_PER_SECOND/2);
|
||||
rt_hw_led_off(0);
|
||||
rt_pin_write(LED_PIN_NUM, PIN_HIGH);
|
||||
rt_thread_delay(RT_TICK_PER_SECOND/2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#include <rtconfig.h>
|
||||
#include "ACM32Fxx_HAL.h"
|
||||
#include "led.h"
|
||||
|
||||
/*-------------------------- UART CONFIG BEGIN --------------------------*/
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-08-23 AisinoChip first implementation
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "board.h"
|
||||
|
||||
#define led1_gpio GPIOA
|
||||
#define led1_pin (GPIO_PIN_1)
|
||||
|
||||
void rt_hw_led_init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_Handle;
|
||||
|
||||
GPIO_Handle.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_Handle.Pull = GPIO_PULLUP;
|
||||
GPIO_Handle.Alternate = GPIO_FUNCTION_0;
|
||||
|
||||
GPIO_Handle.Pin = led1_pin;
|
||||
HAL_GPIO_Init(led1_gpio, &GPIO_Handle);
|
||||
}
|
||||
|
||||
void rt_hw_led_on(rt_uint32_t n)
|
||||
{
|
||||
switch (n)
|
||||
{
|
||||
case 0:
|
||||
HAL_GPIO_WritePin(led1_gpio, led1_pin, GPIO_PIN_SET);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rt_hw_led_off(rt_uint32_t n)
|
||||
{
|
||||
switch (n)
|
||||
{
|
||||
case 0:
|
||||
HAL_GPIO_WritePin(led1_gpio, led1_pin, GPIO_PIN_CLEAR);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rt_hw_led_toggle(rt_uint32_t n)
|
||||
{
|
||||
static rt_bool_t stat = RT_TRUE;
|
||||
|
||||
if (stat == RT_TRUE)
|
||||
{
|
||||
rt_hw_led_on(n);
|
||||
stat = RT_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_hw_led_off(n);
|
||||
stat = RT_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-08-25 AisinoChip the first version
|
||||
*/
|
||||
|
||||
#ifndef __LED_H__
|
||||
#define __LED_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
void rt_hw_led_init(void);
|
||||
void rt_hw_led_on(rt_uint32_t led);
|
||||
void rt_hw_led_off(rt_uint32_t led);
|
||||
void rt_hw_led_toggle(rt_uint32_t led);
|
||||
|
||||
#endif
|
||||
+202
-214
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user