📄 bsp.c
字号:
/*
*********************************************************************************************************
* OKI L67Q4051
* AME-51-AS Board Support Package
*
* (c) Copyright 2004, Micrium, Weston, FL
* All Rights Reserved
*
*
* File : BSP.C
* By : Eric Shufro
*********************************************************************************************************
*/
#include <includes.h>
/*
*********************************************************************************************************
* DEFINITIONS
*********************************************************************************************************
*/
#define PIOD_PATTERN 0x0018
#define PIOF_PATTERN 0x003F
#define PIOD_MASK_PATTERN 0x00E7
#define PIOF_MASK_PATTERN 0x00C0
#define INPUT_PIOD_PATTERN 0x00C0
/*
*********************************************************************************************************
* PROTOTYPES
*********************************************************************************************************
*/
static void SevenSegment_Init(void);
static void IntCtl_Init(void);
static void Tmr_TickInit(void);
static void Normal_ISR_Dummy(void); /* Dummy IRQ ISR Handler */
static void FAST_ISR_Dummy(void); /* Dummy FIQ ISR Handler */
/*
*********************************************************************************************************
* VARIABLES
*********************************************************************************************************
*/
BSP_FNCT_PTR BSP_IRQ[64]; /* Look up table for normal ISRs */
BSP_FNCT_PTR BSP_FIQ[64]; /* Look up table for normal ISRs */
/*
*********************************************************************************************************
* 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)
{
IntCtl_Init(); /* Initialize the Interrupt Controller */
LED_Init(); /* Initialize the I/Os for the LED routines */
SevenSegment_Init(); /* Initilize the I/Os for the 7 segment display */
Tmr_TickInit(); /* Initialize the uC/OS-II tick interrupt */
}
/*
*********************************************************************************************************
* IntCtl_Init()
*
* Description : This function initialized the interrupt controller on the OKI L67Q4051
*********************************************************************************************************
*/
void IntCtl_Init(void)
{
INT8U i;
/* Initialize the interrupt controller registers */
put_wvalue(ILC0, 0); /* Mask interrupt sources 0-7 */
put_wvalue(ILC1, 0); /* Mask interrupt sources 8-15 */
put_wvalue(EXILCA, 0); /* Mask extended interrupt sources 16-30 */
put_wvalue(EXILCB, 0); /* Mask extended interrupt sources 32-46 */
put_wvalue(EXILCC, 0); /* Mask extended interrupt sources 48-62 */
put_wvalue(IRQS, 0); /* Clear any pending software interrupt requests */
put_wvalue(CIL, 0xFE); /* Unmask all global interrupt levels */
/* Initialize IRQ / FIQ handler table */
for (i = 0; i < 64; i++) {
BSP_IRQ[i] = Normal_ISR_Dummy; /* No interrupt handler is defined yet */
BSP_FIQ[i] = FAST_ISR_Dummy; /* No interrupt handler is defined yet */
}
}
/*
*********************************************************************************************************
* 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 LED_Init (void)
{
INT8U gppo_data;
INT8U set_data;
/* Set DDR Port E pins 0-2 as outputs */
gppo_data = get_value(PM4);
set_data = (gppo_data | 0x07);
put_value(PM4, set_data);
LED_Off(0);
LED_Off(1);
LED_Off(2);
}
/*
*********************************************************************************************************
* 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 turns ON LED0 on the board
* 1 turns ON LED1 on the board
* 2 turns ON LED2 on the board
*********************************************************************************************************
*/
void LED_On (INT8U led)
{
INT8U gppo_data;
INT8U set_data;
gppo_data = get_value(PO4);
switch (led) {
case 0:
set_data = gppo_data | (1 << 0);
put_value(PO4, set_data);
break;
case 1:
set_data = gppo_data | (1 << 1);
put_value(PO4, set_data);
break;
case 2:
set_data = gppo_data | (1 << 2);
put_value(PO4, set_data);
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 turns OFF LED0 on the board
* 1 turns OFF LED1 on the board
* 2 turns OFF LED2 on the board
*********************************************************************************************************
*/
void LED_Off (INT8U led)
{
INT8U gppo_data;
INT8U set_data;
gppo_data = get_value(PO4);
switch (led) {
case 0:
set_data = gppo_data & ~(1 << 0);
put_value(PO4, set_data);
break;
case 1:
set_data = gppo_data & ~(1 << 1);
put_value(PO4, set_data);
break;
case 2:
set_data = gppo_data & ~(1 << 2);
put_value(PO4, set_data);
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 toggles LED0 on the board
* 1 toggles LED1 on the board
* 2 toggles LED2 on the board
*********************************************************************************************************
*/
void LED_Toggle (INT8U led)
{
INT8U gppo_data;
INT8U set_data;
gppo_data = get_value(PO4);
switch (led) {
case 0:
set_data = gppo_data ^ (1 << 0);
put_value(PO4, set_data);
break;
case 1:
set_data = gppo_data ^ (1 << 1);
put_value(PO4, set_data);
break;
case 2:
set_data = gppo_data ^ (1 << 2);
put_value(PO4, set_data);
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -