📄 edb7xxx_misc.c
字号:
COEOI, // CYGNUM_HAL_INTERRUPT_CSINT 5 0, // CYGNUM_HAL_INTERRUPT_EINT1 6 0, // CYGNUM_HAL_INTERRUPT_EINT2 7 0, // CYGNUM_HAL_INTERRUPT_EINT3 8 TC1EOI, // CYGNUM_HAL_INTERRUPT_TC1OI 9 TC2EOI, // CYGNUM_HAL_INTERRUPT_TC2OI 10 RTCEOI, // CYGNUM_HAL_INTERRUPT_RTCMI 11 TEOI, // CYGNUM_HAL_INTERRUPT_TINT 12 0, // CYGNUM_HAL_INTERRUPT_UTXINT1 13 0, // CYGNUM_HAL_INTERRUPT_URXINT1 14 UMSEOI, // CYGNUM_HAL_INTERRUPT_UMSINT 15 0, // CYGNUM_HAL_INTERRUPT_SSEOTI 16 KBDEOI, // CYGNUM_HAL_INTERRUPT_KBDINT 17 0, // CYGNUM_HAL_INTERRUPT_SS2RX 18 0, // CYGNUM_HAL_INTERRUPT_SS2TX 19 0, // CYGNUM_HAL_INTERRUPT_UTXINT2 20 0, // CYGNUM_HAL_INTERRUPT_URXINT2 21#if defined(__EDB7211) 0, // CYGNUM_HAL_INTERRUPT_MCPINT 22#endif#if defined(__EDB7209) 0, // CYGNUM_HAL_INTERRUPT_I2SINT 22#endif};static struct regmap { int first_int, last_int; cyg_uint32 stat_reg, mask_reg;} hal_interrupt_status_regmap[] = { { CYGNUM_HAL_INTERRUPT_EXTFIQ, CYGNUM_HAL_INTERRUPT_SSEOTI, INTSR1, INTMR1}, { CYGNUM_HAL_INTERRUPT_KBDINT, CYGNUM_HAL_INTERRUPT_URXINT2, INTSR2, INTMR2},#if defined(__EDB7211) { CYGNUM_HAL_INTERRUPT_MCPINT, CYGNUM_HAL_INTERRUPT_MCPINT, INTSR3, INTMR3},#endif#if defined(__EDB7209) { CYGNUM_HAL_INTERRUPT_I2SINT, CYGNUM_HAL_INTERRUPT_I2SINT, INTSR3, INTMR3},#endif { 0, 0, 0}};#ifdef CYGHWR_HAL_ARM_EDB7XXX_BATLOW// This ISR is called when the battery low interrupt occursint cyg_hal_batlow_isr(cyg_vector_t vector, cyg_addrword_t data, HAL_SavedRegisters *regs){ diag_printf("Battery low\n"); cyg_drv_interrupt_mask(CYGNUM_HAL_INTERRUPT_BLINT); // Presumably, one would leave this masked until the battery changed cyg_drv_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_BLINT); return 0; // No need to run DSR}#endif//// Early stage hardware initialization// Some initialization has already been done before we get here. For now// just set up the interrupt environment.void hal_hardware_init(void){ volatile cyg_uint32 *icr; int vector; // Clear and initialize instruction cache HAL_ICACHE_INVALIDATE_ALL(); HAL_ICACHE_ENABLE(); // Any hardware/platform initialization that needs to be done. *(volatile cyg_uint32 *)INTMR1 = 0; *(volatile cyg_uint32 *)INTMR2 = 0;#if !defined(__CL7111) *(volatile cyg_uint32 *)INTMR3 = 0; *(volatile cyg_uint8 *)SYSCON3 = SYSCON3_CLKCTL(CPU_CLOCK);#endif#if 0 diag_printf("IMR1: %04x, IMR2: %04x\n", *(volatile cyg_uint32 *)INTMR1, *(volatile cyg_uint32 *)INTMR2); diag_printf("Memcfg1: %08x, Memcfg2: %08x, DRAM refresh: %08x\n", *(volatile cyg_uint32 *)MEMCFG1, *(volatile cyg_uint32 *)MEMCFG2, *(volatile cyg_uint8 *)DRFPR);#endif#define MEMCFG_BUS_WIDTH(n) (n<<0)#define MEMCFG_BUS_WIDTH_32 (0<<0)#define MEMCFG_BUS_WIDTH_16 (1<<0)#define MEMCFG_BUS_WIDTH_8 (2<<0)#define MEMCFG_WAIT_STATES(n) (n<<2) // 0 is max, 15 min#define MEMCFG_SQAEN (1<<6)#define MEMCFG_CLKENB (1<<7)// These need to be checked/improved#define CS0_CONFIG MEMCFG_BUS_WIDTH_32 | MEMCFG_WAIT_STATES(3) | MEMCFG_SQAEN#define CS1_CONFIG MEMCFG_BUS_WIDTH_32 | MEMCFG_WAIT_STATES(4)#define CS2_CONFIG MEMCFG_BUS_WIDTH_32 | MEMCFG_WAIT_STATES(0)#define CS3_CONFIG MEMCFG_BUS_WIDTH_32 | MEMCFG_WAIT_STATES(0)#define CS4_CONFIG MEMCFG_BUS_WIDTH_32 | MEMCFG_WAIT_STATES(0)#define CS5_CONFIG MEMCFG_BUS_WIDTH_32 | MEMCFG_WAIT_STATES(0)#define CS6_CONFIG MEMCFG_BUS_WIDTH_32 | MEMCFG_WAIT_STATES(0)#define CS7_CONFIG MEMCFG_BUS_WIDTH_32 | MEMCFG_WAIT_STATES(0)#if defined(__EDB7209) *(volatile cyg_uint32 *)MEMCFG1 = (CS0_CONFIG << 0) | // FLASH rom (CS1_CONFIG << 8) | // NAND flash (CS2_CONFIG << 16) | // Ethernet (CS3_CONFIG << 24); // Parallel printer, keyboard, touch panel *(volatile cyg_uint32 *)MEMCFG2 = (CS4_CONFIG << 0) | // USB (CS5_CONFIG << 8) | // Expansion (CS6_CONFIG << 16) | // Local SRAM (CS7_CONFIG << 24); // Boot ROM // This value came from Cirrus, but doesn't match the recommendations above? *(volatile cyg_uint32 *)MEMCFG1 = 0x3C001814; // Set up GPIO lines *(volatile cyg_uint8 *)PADDR = 0x00; // Keyboard data 0-7 input *(volatile cyg_uint8 *)PBDDR = 0xFA; // 0 - I/O on J22 // 1 - RTS on UART1 // 2 - Ring on UART1 // 3 - SSI header, Pin 13 // 4 - NAND Command Latch Enable // 5 - NAND Address Latch Enable // 6 - On-board NAND Select (active low) // 7 - SmartMedia Card Enable (active low) *(volatile cyg_uint8 *)PBDR = 0xC0; // Everything off *(volatile cyg_uint8 *)PDDDR = 0x40; // 0 - Diagnostic LED control // 1 - Enable DC-DC converter for LCD // 2 - Enable LCD // 3 - ENable LCD Backlight // 4 - CS4342 I2C Data // 5 - CS4342 I2C Clock // 6 - SmartMedia Presence indicator // 7 - I/O on J22 *(volatile cyg_uint8 *)PDDR = 0x00; // Everything off *(volatile cyg_uint8 *)PEDDR = 0x05; // 0 - Codec or ADC/DAC // 1 - I/O on JP38 (0 when inserted) // 2 - Enable touch panel *(volatile cyg_uint8 *)PEDR = 0x01; // Enable audio (not CODEC) // Initialize system control *(volatile cyg_uint32 *)SYSCON2 = SYSCON2_KBWEN;#endif // Reset all interrupt masks (disable all interrupt sources) for (vector = CYGNUM_HAL_ISR_MIN; vector < CYGNUM_HAL_ISR_COUNT; vector++) { icr = (volatile cyg_uint32 *)hal_interrupt_clear_map[vector]; if (icr) *icr = 0; // Just a write clears the latch } // Turn on the DIAG LED to let the world know the board is alive *(volatile unsigned char *)LEDFLSH = LEDFLSH_ENABLE|LEDFLSH_DUTY(16)|LEDFLSH_PERIOD(1);#ifdef CYGHWR_HAL_ARM_EDB7XXX_BATLOW cyg_drv_interrupt_create(CYGNUM_HAL_INTERRUPT_BLINT, 99, // Priority - what goes here? 0, // Data item passed to interrupt handler cyg_hal_batlow_isr, 0, &batlow_interrupt_handle, &batlow_interrupt); cyg_drv_interrupt_attach(batlow_interrupt_handle); cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_BLINT);#endif}//// This routine is called to respond to a hardware interrupt (IRQ). It// should interrogate the hardware and return the IRQ vector number.// This code is a little convoluted to keep it general while still avoiding// reading the hardware a lot, since the interrupt status is split across// three separate registers.int hal_spurious_ints;int hal_IRQ_handler(void){ struct regmap *map = hal_interrupt_status_regmap; cyg_uint32 stat; int vector; while (map->first_int) { stat = *(volatile cyg_uint32 *)map->stat_reg & *(volatile cyg_uint32 *)map->mask_reg; for (vector = map->first_int; vector <= map->last_int; vector++) { if (stat & hal_interrupt_bitmap[vector]) return vector; } map++; // Next interrupt status register } hal_spurious_ints++; return CYGNUM_HAL_INTERRUPT_unused; // This shouldn't happen!}//// Interrupt control//void hal_interrupt_mask(int vector){ volatile cyg_uint32 *imr; imr = (volatile cyg_uint32 *)hal_interrupt_mask_regmap[vector]; *imr &= ~hal_interrupt_bitmap[vector];}void hal_interrupt_unmask(int vector){ volatile cyg_uint32 *imr; imr = (volatile cyg_uint32 *)hal_interrupt_mask_regmap[vector]; *imr |= hal_interrupt_bitmap[vector];}void hal_interrupt_acknowledge(int vector){ // Some interrupt sources have a register for this. volatile cyg_uint8 *icr; icr = (volatile cyg_uint8 *)hal_interrupt_clear_map[vector]; if (icr) { *icr = 0; // Any data clears interrupt }}void hal_interrupt_configure(int vector, int level, int up){ // No interrupts are configurable on this hardware}void hal_interrupt_set_level(int vector, int level){ // No interrupts are configurable on this hardware}/*------------------------------------------------------------------------*/// EOF hal_misc.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -