📄 bsp.c
字号:
pfnct = BSP_ISR_Table[idx]; /* Read the interrupt vector from the table */
if (pfnct != (BSP_PFNCT)0) { /* Make sure we don't have a NULL pointer */
(*pfnct)(); /* Execute the ISR for the interrupting device */
}
}
/*
*********************************************************************************************************
* FIQ ISR HANDLER
*
* Description : This function is called by OS_CPU_FIQ_ISR() to determine the source of the interrupt
* and process it accordingly.
*
* Arguments : none
*********************************************************************************************************
*/
void OS_CPU_FIQ_ISR_Handler (void)
{
}
/*
*********************************************************************************************************
* INITIALIZE I/Os
*
* Description : This function initializes the GPIO pins. All the I/O pins are initialized in this
* function so you don't have to look at multiple places for I/O initialization. All the
* pins are initialized as outputs, except for the UART0 pins, the EMI pins, and the pins
* connected to the board's push buttons.
*
* Arguments : none
*********************************************************************************************************
*/
static void BSP_IO_Init (void)
{
GPIO0->PC0 = 0xFFFF; /* Pins 8 and 9 in Port 0 correspond to UART 0 */
GPIO0->PC1 = 0x0300;
GPIO0->PC2 = 0xFFFF;
GPIO1->PC0 = 0xFFFF; /* Pins 8 and 9 in Port 1 correspond to the buttons */
GPIO1->PC1 = 0x0000;
GPIO1->PC2 = 0xFCFF;
GPIO2->PC0 = 0xFFFF; /* Pins 0-7 are used by the EMI; pins 0-3 are set up */
GPIO2->PC1 = 0x00FF; /* as outputs because the EMI will be used with the */
GPIO2->PC2 = 0xFFFF; /* LCD */
}
/*
********************************************************************************************************
* SPEAKER ON
*
* Description : Turn on the STR710-EVAL board's speaker.
*
* Arguments : None
********************************************************************************************************
*/
void Speaker_On (void)
{
CPU_INT16U speaker_state;
speaker_state = GPIO1->PD;
speaker_state &= (~0x0080);
GPIO1->PD = speaker_state;
}
/*
*********************************************************************************************************
* SPEAKER OFF
*
* Description: Turn off the STR710-EVAL board's speaker.
*
* Arguments : None
*********************************************************************************************************
*/
void Speaker_Off (void)
{
CPU_INT16U speaker_state;
speaker_state = GPIO1->PD;
speaker_state |= 0x0080;
GPIO1->PD = speaker_state;
}
/*
*********************************************************************************************************
* SPEAKER TOGGLE
*
* Description: Toggle the state of the STR710-EVAL board's speaker.
*
* Arguments : None
*********************************************************************************************************
*/
void Speaker_Toggle (void)
{
CPU_INT16U speaker_state;
speaker_state = GPIO1->PD;
speaker_state ^= 0x0080;
GPIO1->PD = speaker_state;
}
/*
*********************************************************************************************************
* GET 'PUSH BUTTON' STATUS
*
* Description : This function is used to get the status of any push button on the board.
*
* Arguments : push_button is the number of the push button to probe
* 1 probe the "select" push button
* 2 probe the "next" push button
*********************************************************************************************************
*/
BOOLEAN PB_GetStatus (CPU_INT08U push_button_id)
{
BOOLEAN status;
status = FALSE;
switch (push_button_id) {
case 1:
if (((GPIO1->PD) & (1 << 8)) == 0) {
return (TRUE);
}
break;
case 2:
if (((GPIO1->PD) & (1 << 9)) == 0) {
return (TRUE);
}
break;
default:
break;
}
return (status);
}
/*
*********************************************************************************************************
* LED INITIALIZATION
*
* Description : This function initializes the board's LEDs.
*
* Arguments : none
*********************************************************************************************************
*/
void LED_Init (void)
{
LED_Off(0);
}
/*
*********************************************************************************************************
* 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 to turn on all of the board's LEDs
* 1 turn on LD 16 (located on the upper-left corner of the board)
* 2 turn on LD 12 (located next to LD 16)
* .
* 16 turn on LD 6 (the last of the 16 LEDs located at the top of the board)
*********************************************************************************************************
*/
void LED_On (CPU_INT08U led)
{
switch (led) {
case 0:
GPIO0->PD |= 0x100F;
GPIO1->PD |= 0x8070;
GPIO2->PD |= 0xFE00;
break;
case 1:
GPIO2->PD |= 0x8000;
break;
case 2:
GPIO2->PD |= 0x0800;
break;
case 3:
GPIO1->PD |= 0x0040;
break;
case 4:
GPIO2->PD |= 0x1000;
break;
case 5:
GPIO1->PD |= 0x0020;
break;
case 6:
GPIO2->PD |= 0x2000;
break;
case 7:
GPIO1->PD |= 0x0010;
break;
case 8:
GPIO2->PD |= 0x4000;
break;
case 9:
GPIO0->PD |= 0x1000;
break;
case 10:
GPIO0->PD |= 0x0008;
break;
case 11:
GPIO1->PD |= 0x8000;
break;
case 12:
GPIO0->PD |= 0x0004;
break;
case 13:
GPIO2->PD |= 0x0200;
break;
case 14:
GPIO0->PD |= 0x0002;
break;
case 15:
GPIO2->PD |= 0x0400;
break;
case 16:
GPIO0->PD |= 0x0001;
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 to turn off all of the board's LEDs
* 1 turn off LD 16 (located on the upper-left corner of the board)
* 2 turn off LD 12 (located next to LD 16)
* .
* 16 turn off LD 6 (the last of the 16 LEDs located at the top of the board)
*********************************************************************************************************
*/
void LED_Off (CPU_INT08U led)
{
switch (led) {
case 0:
GPIO0->PD &= (~0x100F);
GPIO1->PD &= (~0x8070);
GPIO2->PD &= (~0xFE00);
break;
case 1:
GPIO2->PD &= (~0x8000);
break;
case 2:
GPIO2->PD &= (~0x0800);
break;
case 3:
GPIO1->PD &= (~0x0040);
break;
case 4:
GPIO2->PD &= (~0x1000);
break;
case 5:
GPIO1->PD &= (~0x0020);
break;
case 6:
GPIO2->PD &= (~0x2000);
break;
case 7:
GPIO1->PD &= (~0x0010);
break;
case 8:
GPIO2->PD &= (~0x4000);
break;
case 9:
GPIO0->PD &= (~0x1000);
break;
case 10:
GPIO0->PD &= (~0x0008);
break;
case 11:
GPIO1->PD &= (~0x8000);
break;
case 12:
GPIO0->PD &= (~0x0004);
break;
case 13:
GPIO2->PD &= (~0x0200);
break;
case 14:
GPIO0->PD &= (~0x0002);
break;
case 15:
GPIO2->PD &= (~0x0400);
break;
case 16:
GPIO0->PD &= (~0x0001);
break;
}
}
/*
*********************************************************************************************************
* LED TOGGLE
*
* Description : This function is used to alternate the state of an LED
*
* Arguments : led is the number of the LED to control
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -