📄 armio.c
字号:
/* * ARMIO.C * * * Control diagnostic bits * * Reference : GCS207 * */#include "l1sw.cfg"#include "swconfig.cfg"#if (OP_L1_STANDALONE == 0) #ifdef BLUETOOTH_INCLUDED #include "btemobile.cfg" #endif#endif#if (OP_L1_STANDALONE == 1) #include "l1_macro.h" #include "l1_confg.h"#endif#include "board.cfg"#include "chipset.cfg"#include "sys_types.h"#include "memif/mem.h"#include "inth/iq.h"#include "armio/armio.h"#include "abb/abb.h" // for AI_Power function : to be removed, use ABB_Power_Off in abb.c file instead !!!#include "general.h"#include "board.cfg"#if (CHIPSET != 12)/* * AI_EnableBit * * Enable ARMIO input/output bit (see CLKM module specification) */void AI_EnableBit(int bit){ *((volatile SYS_UWORD16 *) CLKM_IO_CNTL) |= (1<<bit); }/* * AI_DisableBit * * Disable ARMIO input/output bit (see CLKM module specification) */void AI_DisableBit(int bit){ *((volatile SYS_UWORD16 *) CLKM_IO_CNTL) &= ~(1<<bit); }#endif /* CHIPSET != 12 *//* * AI_SetBit * * Switch-on one bit */void AI_SetBit(int bit){ *((volatile SYS_UWORD16 *) ARMIO_OUT) |= (1<<bit); }/* * AI_ResetBit * * Switch-off one bit */void AI_ResetBit(int bit){ *((volatile SYS_UWORD16 *) ARMIO_OUT) &= ~(1<<bit); }/* * AI_ConfigBitAsOutput * * Set this bit as an output */void AI_ConfigBitAsOutput(int bit){ *((volatile SYS_UWORD16 *) ARMIO_IO_CNTL) &= ~(1<<bit); }/* * AI_ConfigBitAsInput * * Set this bit as an input */void AI_ConfigBitAsInput(int bit){ *((volatile SYS_UWORD16 *) ARMIO_IO_CNTL) |= (1<<bit); }/* * AI_ReadBit * * Read value in register */SYS_BOOL AI_ReadBit(int bit){ if ((*((volatile SYS_UWORD16 *) ARMIO_IN)) & (1<<bit)) return (1); else return (0);}/* * AI_Power * * Switch-on or off the board * * Parameters : SYS_UWORD8 power: 1 to power-on (maintain power) * 0 to power-off * */#if (OP_L1_STANDALONE == 0)void AI_Power(SYS_UWORD8 power){ SYS_UWORD16 status_value; if (power == 0) { // Check whether charger is present or not? #if ((ANLG_FAM == 1) || (ANLG_FAM == 2)) status_value = ABB_Read_Status(); #elif (ANLG_FAM == 3) status_value = ABB_Read_Register_on_page(PAGE1, VRPCCFG); #endif // if (!(status_value & CHGPRES)) { // Charger not present => Turn-Off the Board ABB_Power_Off(); } /*else { // Charging is still on-going }*/ }}#endif/* * AI_ResetIoConfig * * Reset all default IO configurations * */void AI_ResetIoConfig(void){ *((volatile SYS_UWORD16 *) ARMIO_IO_CNTL) = 0xFFFF; // all bits are inputs#if (CHIPSET != 12) *((volatile SYS_UWORD16 *) CLKM_IO_CNTL) = 0; // default config #endif /* CHIPSET != 12 */}/* * AI_ClockEnable * * Enable ARMIO clock module * */void AI_ClockEnable(void){ *((volatile SYS_UWORD16 *) ARMIO_CNTL_REG) |= ARMIO_CLOCKEN; // set to 1 bit 5}#if (BOARD == 7)/* * AI_InitIOConfig * * Configure all GPIOs at initialization in order to optimize the power consumption * of the B-Sample : * - select IOs 8,9,10,11,12 and 13 on the pins instead of MCSI and MCUEN signals. * - configure these IOs in output high. * - configure the IOs 0 and 1 in output low. */void AI_InitIOConfig(void){ // reset the IOs config AI_ResetIoConfig(); // CLKM_IO_CNTL register configuration : // select IOs 8,9,10,11,12 and 13 on the pins instead of MCSI and MCUEN signals. #if (CHIPSET != 12) AI_EnableBit(4); #endif /* Bits 5,6,7,8 are used to output I/O 9,10,11,12 or MCSI pins */ /* If Bluetooth, IO should be disabled, outputting MCSI used for Bluetooth voice */#ifdef BTEMOBILE #if (CHIPSET != 12) AI_DisableBit(5); AI_DisableBit(6); AI_DisableBit(7); AI_DisableBit(8); #endif#else #if (CHIPSET != 12) AI_EnableBit(5); AI_EnableBit(6); AI_EnableBit(7); AI_EnableBit(8);#endif#endif #if (CHIPSET != 12) AI_EnableBit(9); #endif // ARMIO_OUT register configuration : // reset the general output latchs. *((volatile SYS_UWORD16 *) ARMIO_OUT) = 0x3F00; // ARMIO_CNTL_REG register configuration : // set IOs 0,1,8,9,10,11,12 and 13 as ouputs. AI_ConfigBitAsOutput(0); // vibrator AI_ConfigBitAsOutput(1); // LCD_A0 AI_ConfigBitAsOutput(8); AI_ConfigBitAsOutput(9); AI_ConfigBitAsOutput(10); AI_ConfigBitAsOutput(11); AI_ConfigBitAsOutput(12); AI_ConfigBitAsOutput(13);}#elif ((BOARD == 8) || (BOARD == 9) || (BOARD == 40) || (BOARD == 41) || (BOARD == 42) || (BOARD == 43) || (BOARD == 45))/* * AI_InitIOConfig * * Configure all GPIOs at initialization in order to optimize the power consumption * of the C-Sample : * - select IOs 8,9,10,11,12 and 13 on the pins instead of MCSI and MCUEN signals. * - configure these IOs in output high. * - configure the IOs 0 (Vibrator LED) and 1 (LCD_A0) in output low. */void AI_InitIOConfig(void){ // reset the IOs config AI_ResetIoConfig(); // CLKM_IO_CNTL register configuration : // select IOs 6,8,9,10,11,12 and 13 on the pins instead of MCSI and MCUEN signals. #if (CHIPSET != 12) AI_EnableBit(2); AI_EnableBit(4); #endif /* Bits 5,6,7,8 are used to output I/O 9,10,11,12 or MCSI pins */ /* If Bluetooth, IO should be disabled, outputting MCSI used for Bluetooth voice */#ifdef BTEMOBILE #if (CHIPSET != 12) AI_DisableBit(5); AI_DisableBit(6); AI_DisableBit(7); AI_DisableBit(8); #endif#else #if (CHIPSET != 12) AI_EnableBit(5); AI_EnableBit(6); AI_EnableBit(7); AI_EnableBit(8);#endif#endif #if (CHIPSET != 12) AI_EnableBit(9); #endif // ARMIO_OUT register configuration : // set IOs 8,9,10,11,12 and 13 as high // set IOs 0 to 7 as low #if ((BOARD == 8) || (BOARD == 9)) *((volatile SYS_UWORD16 *) ARMIO_OUT) = 0x3F00; // ARMIO_CNTL_REG register configuration : // set IOs 0,1,6,8,9,10,11,12 and 13 as ouputs. AI_ConfigBitAsOutput(0); AI_ConfigBitAsOutput(1); AI_ConfigBitAsOutput(6); AI_ConfigBitAsOutput(8); AI_ConfigBitAsOutput(9); AI_ConfigBitAsOutput(10); AI_ConfigBitAsOutput(11); AI_ConfigBitAsOutput(12); AI_ConfigBitAsOutput(13); #elif ((BOARD == 40) || (BOARD == 41) || (BOARD == 42) || (BOARD == 43) || (BOARD == 45)) // set IOs 1 and 8 to 13 as high // set IOs 0 and 2 to 7 as low // On D-Sample GPIO 1 must be set to high to enable the audio amplifier. #if (OP_L1_STANDALONE == 0) *((volatile SYS_UWORD16 *) ARMIO_OUT) = 0x3F02; #else *((volatile SYS_UWORD16 *) ARMIO_OUT) = 0x3F01; #endif // ARMIO_CNTL_REG register configuration : // set IOs 1,2,5,7,9,14 and 15 as ouputs. AI_ConfigBitAsOutput(1); AI_ConfigBitAsOutput(2); AI_ConfigBitAsOutput(5); AI_ConfigBitAsOutput(7); AI_ConfigBitAsOutput(9); AI_ConfigBitAsOutput(14); AI_ConfigBitAsOutput(15); #endif}//配置c1500主板iovoid AI_InitIOConfig_c1500(void){ // reset the IOs config AI_ResetIoConfig(); AI_ConfigBitAsOutput(0);//handfree enable AI_ConfigBitAsInput(1);//not use AI_ConfigBitAsInput(2);//earphone key check AI_ConfigBitAsOutput(3);//keypad light AI_ConfigBitAsInput(4);//camera hv AI_ConfigBitAsInput(5);//not use AI_ConfigBitAsOutput(6);//Motor enable AI_ConfigBitAsOutput(7);//usb charge enable AI_ConfigBitAsOutput(8);//camera reset AI_ConfigBitAsOutput(9);//camera standby AI_ConfigBitAsInput(10);//usb charge status 1 AI_ConfigBitAsOutput(11);//midi pa enable AI_ConfigBitAsOutput(12);//midi reset AI_ConfigBitAsInput(13);//usb charge status 2 AI_ResetBit(0); AI_ResetBit(3); AI_ResetBit(6); AI_ResetBit(7); AI_ResetBit(11); AI_ResetBit(12);#if (CCDH_SENSOR == 1) ov7660_powerOff();#else AI_ResetBit(8); AI_ResetBit(9);#endif}void AI_Keypad_Light(SYS_UWORD8 open){ AI_ConfigBitAsOutput(3); if(open) AI_SetBit(3); else AI_ResetBit(3);}/* * AI_SelectIOForIT * * Select which IO will be used to generate an interrupt. * 'Edge' specifies if interrup must be detected on falling or rising edge. * * Warning: parameters are not checked. */ void AI_SelectIOForIT (SYS_UWORD16 Pin, SYS_UWORD16 Edge){ #if (CHIPSET == 12) /* * Update INTERRUPT_LEVEL_REG with Edge configuration on Pin selection */ GPIO_INTERRUPT_LEVEL_REG = (Edge & 0x0001) << Pin; /* * Update INTERRUPT_MASK_REG to enable interrupt generation on Pin selection */ GPIO_INTERRUPT_MASK_REG = 1 << Pin; #else /* * Bit SET_GPIO_EVENT_MODE (bit 0) is set to enable the GPIO event mode. */ *((volatile SYS_UWORD16 *) ARMIO_GPIO_EVENT_MODE) = (Pin << 1) + (Edge << 5) + 1; #endif}#if (CHIPSET != 12)/* * AI_CheckITSource * * Check if the interrupt specified by 'Source' is active or not. * * Output: 0: IT is not active * 1: IT is active * * Warning: parameters are not checked. * * Warning: If the keypad and GPIO interrupts may occur the GPIO interrupt * must be checked first because the GPIO status bit is reset when * the register is read. */ int AI_CheckITSource (SYS_UWORD16 Source){ return (*((volatile SYS_UWORD16 *) ARMIO_KBD_GPIO_INT) & Source ? 1 : 0);}/* * AI_UnmaskIT * * Unmask the IT specified by 'Source' (keyboard or GPIO). * * Warning: parameters are not checked. */ void AI_UnmaskIT (SYS_UWORD16 Source){ *((volatile SYS_UWORD16 *) ARMIO_KBD_GPIO_MASKIT) &= ~Source;}/* * AI_MaskIT * * Mask the IT specified by 'Source' (keyboard or GPIO). * * Warning: parameters are not checked. */ void AI_MaskIT (SYS_UWORD16 Source){ *((volatile SYS_UWORD16 *) ARMIO_KBD_GPIO_MASKIT) |= Source;}#endif /* CHIPSET != 12 */#if (CHIPSET == 12) void AI_MaskIT(SYS_UWORD16 d_io_number) { GPIO_INTERRUPT_MASK_REG |= (1 << d_io_number); } /* f_gpio_mask_it() */ void AI_UnmaskIT(SYS_UWORD16 d_io_number) { GPIO_INTERRUPT_MASK_REG &= ~(1 << d_io_number); } /* f_gpio_unmask_it() */#if (CCDH_SENSOR == 1)#define ov7660_standby_pin 9#define ov7660_reset_pin 8#define ov7660_vsync 4#define ov7660_href_high_max 20#define ov7660_href_low_max 10extern UINT8 camd_clock_flag;static void ov7660_nop_delay(SYS_UWORD32 ms){ unsigned short a; while (ms-- > 0) for (a=0;a<1000;a++) asm(" nop");}void ov7660_standby(SYS_UWORD8 open){ AI_ConfigBitAsOutput(ov7660_standby_pin); if(open == 1) { AI_SetBit(ov7660_standby_pin); }else{ AI_ResetBit(ov7660_standby_pin); }}void ov7660_reset(SYS_UWORD8 reset){ AI_ConfigBitAsOutput(ov7660_reset_pin); if(reset == 1) { AI_SetBit(ov7660_reset_pin); }else{ AI_ResetBit(ov7660_reset_pin); }}void ov7660_powerOff(void){ ov7660_standby(1); ov7660_reset(0); }void ov7660_powerOn(void){ ov7660_standby(0); //ov7660_nop_delay(100); ov7660_reset(0); //ov7660_nop_delay(100); }void ov7660_vsyncSetup(void){ AI_ConfigBitAsInput(ov7660_vsync);}void ov7660_chipInit(void){ ov7660_powerOn(); ov7660_vsyncSetup(); }void ov7660_ChipReset(void){ ov7660_reset(1); ov7660_nop_delay(100); ov7660_reset(0); ov7660_nop_delay(100); }void camera_wait_href(void){register int count=0; AI_ConfigBitAsInput(ov7660_vsync); do{ if(AI_ReadBit(ov7660_vsync)) { count++; }else{ count = 0; } if(camd_clock_flag == FALSE) return; }while(count < ov7660_href_high_max); count = 0; do{ if(!AI_ReadBit(ov7660_vsync)) { count++; }else{ count = 0; } if(camd_clock_flag == FALSE) return; }while(count < ov7660_href_low_max);}#endif#endif#elif ((BOARD == 35) || (BOARD == 46))/* * AI_InitIOConfig * * Configure GPIOs */void AI_InitIOConfig(void){ AI_ResetIoConfig(); AI_ConfigBitAsOutput(4); // Set bit 4 to indicate when external memories are not needed AI_ConfigBitAsInput (5); // bit 5 is set by ARM9 ULPD to indicate availability of ext. mem}#endif /* BOARD 8, 9, 35, 40, 41, 42, 43 or 45*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -