⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bsp.c

📁 ucos2.86在STM32L152DISCOVERY上的移植
💻 C
字号:
#include "includes.h"




void BSP_LED_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);

  ////配置PB6 PB7为输出状态

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
}

void led_on(uint32_t n)
{
	switch (n)
	{
		case LED1:	GPIO_ResetBits(GPIOB,GPIO_Pin_6);
				    break;

		case LED2:	GPIO_ResetBits(GPIOB,GPIO_Pin_7);
					break;
		default:    break;
	
	}
}

void led_off(uint32_t n)
{
	switch (n)
	{
		case LED1:	GPIO_SetBits(GPIOB,GPIO_Pin_6);
				    break;

		case LED2:	GPIO_SetBits(GPIOB,GPIO_Pin_7);
					break;
		default:    break;
	
	}
}

void BSP_Init(void)
{
	SystemInit();
	BSP_LED_Init();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -