📄 bsp.c
字号:
/*
*********************************************************************************************************
* BOARD SUPPORT PACKAGE
*
* (c) Copyright 2003-2006; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
* Knowledge of the source code may NOT be used to develop a similar product.
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* BOARD SUPPORT
*
* Luminary Micro LM3S811
* with the
* LM3S811 Evaluation Kit
*
* Filename : bsp.c
* Version : V1.00
* Programmer(s) : Brian Nagel
*********************************************************************************************************
*/
#define BSP_GLOBALS
#include <includes.h>
/*
*********************************************************************************************************
* CONSTANTS
*********************************************************************************************************
*/
#define PB_USER (1 << 4)
#define LED_USER (1 << 5)
/*
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
*/
typedef void (*PFNCT)(void);
/*
*********************************************************************************************************
* VARIABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* PROTOTYPES
*********************************************************************************************************
*/
static void Tmr_TickInit (void);
static void LED_Init (void);
static void PB_Init (void);
static void ADC_Init (void);
/*
******************************************************************************************************************************
******************************************************************************************************************************
** Global Functions
******************************************************************************************************************************
******************************************************************************************************************************
*/
/*
*********************************************************************************************************
* BSP INITIALIZATION
*
* Description : This function should be called by your application code before you make use of any of the
* functions found in this module.
*
* Arguments : none
*********************************************************************************************************
*/
void BSP_Init (void)
{
/* Set the clock using a divider of 5 */
SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC); /* Enable ADC peripheral */
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); /* Enable GPIOC peripheral */
OSRAMInit(DEF_TRUE); /* Initialize the OSRAM OLED display */
LED_Init(); /* Initialize the I/Os for the LED controls */
PB_Init(); /* Initialize the I/Os for the PB controls */
ADC_Init(); /* Initialize the I/Os for the ADC control */
Tmr_TickInit(); /* Initialize the uC/OS-II tick interrupt */
}
/*
*********************************************************************************************************
* DISABLE ALL INTERRUPTS
*
* Description : This function disables all interrupts from the interrupt controller.
*
* Arguments : none
*********************************************************************************************************
*/
void BSP_IntDisAll (void)
{
CPU_DI();
}
/*
******************************************************************************************************************************
******************************************************************************************************************************
** PB, LED, and ADC Functions
******************************************************************************************************************************
******************************************************************************************************************************
*/
/*
*********************************************************************************************************
* LED INITIALIZATION
*
* Description : This function initializes the board's LEDs
*
* Arguments : none
*********************************************************************************************************
*/
static void LED_Init (void)
{
GPIODirModeSet(GPIO_PORTC_BASE, LED_USER, GPIO_DIR_MODE_OUT);
LED_Off(0); /* Turn OFF all the LEDs */
}
/*
*********************************************************************************************************
* LED ON
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments : led is the number of the LED to control
* 0 indicates that you want ALL the LEDs to be ON
* 1 turns ON LED1 on the board
*********************************************************************************************************
*/
void LED_On (CPU_INT08U led)
{
switch (led) {
case 0:
GPIOPinWrite(GPIO_PORTC_BASE, LED_USER, 0);
case 1:
GPIOPinWrite(GPIO_PORTC_BASE, LED_USER, 0);
break;
default:
break;
}
}
/*
*********************************************************************************************************
* LED OFF
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments : led is the number of the LED to turn OFF
* 0 indicates that you want ALL the LEDs to be OFF
* 1 turns OFF LED1 on the board
* .
* .
* 16 turns OFF LED16 on the board
*********************************************************************************************************
*/
void LED_Off (CPU_INT08U led)
{
switch (led) {
case 0:
GPIOPinWrite(GPIO_PORTC_BASE, LED_USER, 1);
break;
case 1:
GPIOPinWrite(GPIO_PORTC_BASE, LED_USER, 1);
break;
default:
break;
}
}
/*
*********************************************************************************************************
* LED TOGGLE
*
* Description : This function is used to toggle any or all the LEDs on the board.
*
* Arguments : led is the number of the LED to control
* 0 indicates that you want to toggle ALL the LEDs
* 1 toggles LED1 on the board
* .
* .
* 16 toggles LED16 on the board
*********************************************************************************************************
*/
void LED_Toggle (CPU_INT08U led)
{
CPU_INT32U pins;
switch (led) {
case 0:
pins = GPIOPinRead(GPIO_PORTC_BASE, LED_USER);
if ((pins & LED_USER) == 0) {
GPIOPinWrite(GPIO_PORTC_BASE, LED_USER, 1);
} else {
GPIOPinWrite(GPIO_PORTC_BASE, LED_USER, 0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -