From a22d9c106276bb1819e583012d7ea41b6529b318 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Wed, 16 May 2018 08:14:05 +0800
Subject: [PATCH] add new LED key systick sample code
---
src/bare_test/2.Key/user/stm32v5_led.c | 109 ++++++++++++++++++++++++++++++------------------------
1 files changed, 60 insertions(+), 49 deletions(-)
diff --git a/src/bare_test/stm32_key/board/stm32v5_led.c b/src/bare_test/2.Key/user/stm32v5_led.c
similarity index 70%
copy from src/bare_test/stm32_key/board/stm32v5_led.c
copy to src/bare_test/2.Key/user/stm32v5_led.c
index ae15262..269c539 100644
--- a/src/bare_test/stm32_key/board/stm32v5_led.c
+++ b/src/bare_test/2.Key/user/stm32v5_led.c
@@ -1,49 +1,60 @@
-/****************************************************************************
-* Copyright: (C)2014 �人����Ƕ��ʽʵ���� www.emblinux.com
-* Author: GuoWenxue<guowenxue@gmail.com> QQ: 281143292
-* Description: �ܶ�STM32v5������contiki����ϵͳLED�豸���������ӿ�
-*
-* ChangeLog:
-* �汾�� ���� ���� ˵��
-* V1.0.0 2014.08.25 GuoWenxue �����ð汾
-****************************************************************************/
-
-#include "stm32v5_led.h"
-
-static led_gpio_t leds_gpio[MAX_LED] =
-{
- {LED1, GPIOB, GPIO_Pin_5}, /* LED1 �õ�GPB5 */
- {LED2, GPIOD, GPIO_Pin_6}, /* LED2 �õ�GPD6 */
- {LED3, GPIOD, GPIO_Pin_3}, /* LED3 �õ�GPD3 */
-};
-
-
-void init_led_gpio(void)
-{
- int i;
- GPIO_InitTypeDef GPIO_InitStructure;
-
- /* ʹ��PB��PD�� GPIO��ʱ�� */
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD , ENABLE);
-
- /*���� PB5(LED1), PD6(LED2), PD3(LED3)Ϊ GPIO �������ģʽ�����߷�ת�ٶ�Ϊ50MHz */
- for(i=0; i<MAX_LED; i++)
- {
- /*���� PB5(LED1)Ϊ GPIO �������ģʽ�����߷�ת�ٶ�Ϊ50MHz */
- GPIO_InitStructure.GPIO_Pin = leds_gpio[i].pin;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(leds_gpio[i].group, &GPIO_InitStructure);
- }
-}
-
-void turn_led(int which, int cmd)
-{
- if(which<0 || which> MAX_LED )
- return;
-
- if(OFF == cmd)
- GPIO_ResetBits(leds_gpio[which].group, leds_gpio[which].pin);
- else
- GPIO_SetBits(leds_gpio[which].group, leds_gpio[which].pin);
-}
+/****************************************************************************
+* Copyright: (C)2018 �人���������ǿ�ʵ���� www.iot-yun.com
+* Author: GuoWenxue<guowenxue@gmail.com> QQ: 281143292
+* Description: �ܶ�STM32v5������ LED�豸���������ӿ�
+*
+* ChangeLog:
+* �汾�� ���� ���� ˵��
+* V1.0.0 2018.05.10 GuoWenxue �����ð汾
+****************************************************************************/
+
+#include "stm32f10x.h"
+#include "stm32v5_led.h"
+
+/* STM32v5 ����LED�ֱ����� GPIO�ڵ� PB5(LED1)��PD6(LED2)��PD3(LED3) */
+led_gpio_t leds_gpio[MAX_LED] =
+{
+ {LED1, GPIOB, GPIO_Pin_5}, /* LED1 �õ�GPB5 */
+ {LED2, GPIOD, GPIO_Pin_6}, /* LED2 �õ�GPD6 */
+ {LED3, GPIOD, GPIO_Pin_3}, /* LED3 �õ�GPD3 */
+};
+
+/* ����˵��: ���� LED GPIO�ں�ʱ�ӣ�
+ * ����˵��: ��
+ * ����ֵ: ��
+ */
+void init_led_gpio(void)
+{
+ int i;
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ /* ʹ��PB��PD�� GPIO��ʱ�� */
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD , ENABLE);
+
+ /*���� PB5(LED1), PD6(LED2), PD3(LED3)Ϊ GPIO �������ģʽ�����߷�ת�ٶ�Ϊ50MHz */
+ for(i=0; i<MAX_LED; i++)
+ {
+ /*���� PB5(LED1)Ϊ GPIO �������ģʽ�����߷�ת�ٶ�Ϊ50MHz */
+ GPIO_InitStructure.GPIO_Pin = leds_gpio[i].pin;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_Init(leds_gpio[i].group, &GPIO_InitStructure);
+ }
+}
+
+
+/* ����˵��: �����������ӦLED
+ * ����˵��: which: Ҫ�����ĸ�LED,��ֵӦ��Ϊ LED1��LED2 �� LED3�
+ * cmd: Ҫ��������, ��ֵ��ӦΪ ON �� OFF
+ * ����ֵ: ��
+ */
+void turn_led(int which, int cmd)
+{
+ if(which<0 || which> MAX_LED )
+ return;
+
+ if(OFF == cmd)
+ GPIO_ResetBits(leds_gpio[which].group, leds_gpio[which].pin);
+ else
+ GPIO_SetBits(leds_gpio[which].group, leds_gpio[which].pin);
+}
--
Gitblit v1.9.1