📄 idetest.c
字号:
#include "..\header\armperipherals.h"
#include "..\header\FPGA_peripherals.h"
#include <stdio.h>
#include "omap30.h"
#include "omap30_arminth.h"
#include "omap1510_inth2.h"
#include "swi.h"
extern unsigned short *fpga_intmask;
//int SetupGPIOHandler(unsigned int BitNum, unsigned int RouteToARM, unsigned int IsInput, enum GPIO_interrupt_type interrupt_type) {
int SetupGPIO(unsigned int BitNum, unsigned int RouteToARM, unsigned int IsInput, enum GPIO_interrupt_type interrupt_type) {
struct GPIO_struct *pGPIO = (struct GPIO_struct*)GPIO_BASE_ADDRESS;
struct MPU_CLK_reset_power_CTL_struct * pMPU_CRPC \
= (struct MPU_CLK_reset_power_CTL_struct*)0xfffece00;
unsigned short temp;
if(BitNum > 15)
return -1;
pMPU_CRPC->arm_idlect2 |= (1<<EN_GPIOCK);
temp = pGPIO->pin_control_reg;
temp &= ~(1<<BitNum);
if(RouteToARM)
temp |= (GPIO_PIN4ARM<<BitNum);
else
temp |= (GPIO_PIN4DSP<<BitNum);
pGPIO->pin_control_reg = temp;
temp = pGPIO->direction_control_reg;
temp &= ~(1<<BitNum);
if(IsInput)
temp |= (GPIO_DIRECTION_INPUT<<BitNum);
else
temp |= (GPIO_DIRECTION_OUTPUT<<BitNum);
pGPIO->direction_control_reg = temp;
temp = pGPIO->interrupt_mask_reg;
temp &= ~(1<<BitNum);
if(interrupt_type == NON_INTERRUPT) {
temp |= (GPIO_INTERRUPT_DISABLE<<BitNum);
pGPIO->interrupt_mask_reg = temp;
}
else {
temp |= (GPIO_INTERRUPT_ENABLE<<BitNum);
pGPIO->interrupt_mask_reg = temp;
temp = pGPIO->interrupt_control_reg;
temp &= ~(1<<BitNum);
if(interrupt_type == LOW2HIGH_INTERRUPT)
temp |= (GPIO_INTERRUPT_LOW2HIGH<<BitNum);
else
temp |= (GPIO_INTERRUPT_HIGH2LOW<<BitNum);
pGPIO->interrupt_control_reg = temp;
}
return 0;
}
extern int idetest_flag;
int idetest(void) {
int retval = 0;
/* Interrupt from i2c mapped on irq of the interrupt handler 2 */
INTH2_InitLevel(GPIO_INT,INTH_IRQ,INTH_HIGHEST_PRIORITY,INTH_LOW_LEVEL_SENSITIVE);
INTH2_EnableOneIT(GPIO_INT,INTH_IRQ);
/* Set up GPIO 13 */
if (SetupGPIO(13, 1, 1, LOW2HIGH_INTERRUPT))
return -1;
// Enable touch screen interrupt in FPGA interrupt handler
// *fpga_intmask = 0x0008;
printf("\nIDE test ...\n");
if((retval = CF_test(0)) < 0)
printf("IDE test failed \n");
printf("\nCF Disk test ...\n");
if((retval = CF_test(1)) < 0)
printf("CF Disk test failed \n");
idetest_flag = 1;
INTH2_DisableOneIT(14);
//printf("GPIO = 14 Interrupt handler masked \n ");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -