Exemplo n.º 1
0
pwm_driver2_t* pwm_driver2_open(pwm_driver2_descriptor_ptr driver) {
  if (!pwm_driver2_prepare_device(driver)) {
    printf("Cannot prepare driver %d\n", driver->id);
    return NULL;
  }
  pwm_driver2_t* pwm_driver2 = malloc(sizeof(pwm_driver2_t));
  pwm_driver2->pwm = pwm_open(driver->pwm, 50000);
  if (!pwm_driver2->pwm) {
    free(pwm_driver2);
    return NULL;
  }
  pwm_driver2->direction = gpio_open(driver->direction, GPIO_OUT);
  if (!pwm_driver2->direction) {
    pwm_close(pwm_driver2->pwm);
    free(pwm_driver2);
    return NULL;
  }
  pwm_driver2->enable = driver->enable;
  if (!gpio_write_direction_file(pwm_driver2->enable, GPIO_OUT)) {
    pwm_close(pwm_driver2->pwm);
    gpio_close(pwm_driver2->direction);
    free(pwm_driver2);
    return NULL;
  }
  pwm_driver2->pwm->zero = 0;
  pwm_set_duty(pwm_driver2->pwm, pwm_driver2->pwm->zero);
  gpio_write_value_file(pwm_driver2->enable, 0);
  return pwm_driver2;
}
Exemplo n.º 2
0
void KeyScan_PlayTone(UINT8 bType)
{
        PWM_struct PWMInfo;
        UINT32 uiKeyToneTimerID;
        UINT32 uiKeyPlayTime = 100; //ms


        if((ubIsPlaying)||(!bKeyToneEn))
            return;

        PWMInfo.uiDiv       = 180;
        PWMInfo.uiPrd       = 20;
        PWMInfo.uiOnCycle   = 0;
        PWMInfo.uiInv       = 0;
        PWMInfo.uiRise      = 0;
        PWMInfo.uiFall      = 10;
        pwm_open(PWMID_0);
        pwm_set(PWMID_0, &PWMInfo);

        if(timer_openAutoClose((UINT *)&uiKeyToneTimerID, (FP)KeyScan_PlayToneStop) == E_OK)
        {
            pwm_en(PWMID_0);
            timer_set(uiKeyToneTimerID, uiKeyPlayTime, _TIMER_CTRL_ONE_SHOT|_TIMER_CTRL_INT_ENABLE, _TIMER_PLAY);

        }
        ubIsPlaying = TRUE;
}
Exemplo n.º 3
0
/**
  Turn on LED

  Turn on LED.

  @param UINT32 uiLED: Which LED, could be the following
    GPIOMAP_LED_GREEN
    GPIOMAP_LED_RED
    GPIOMAP_LED_FCS //FOCUS
  @return void
*/
void LED_TurnOnLED(UINT32 uiLED)
{

    DBG_IND("LED_TurnOnLED %d\r\n",uiLED);
    switch (uiLED)
    {
    case GPIOMAP_LED_GREEN:
    #if (LED_GREEN_CTRL == LED_GREEN_BY_GPIO)
        gpio_setPin(GPIO_GREEN_LED);
    #endif
    break;

    case GPIOMAP_LED_RED:
    #if (LED_RED_CTRL == LED_RED_BY_GPIO)
        gpio_setPin(GPIO_RED_LED);
    #endif
    break;

    case GPIOMAP_LED_FCS:
    #if (LED_FOCUS_CTRL == LED_FOCUS_BY_GPIO)
        gpio_setPin(GPIO_FOCUS_LED);
    #endif
    #if (LED_FOCUS_CTRL == LED_FOCUS_BY_PWM)
    {
        //set FOCUS LED brightness level
        PWM_CFG PWMInfo;
        if(pwm_open(PWMID_FOCUS_LED)!=E_OK)
        {
            pwm_stop(PWMID_FOCUS_LED);
            pwm_close(PWMID_FOCUS_LED, TRUE);
            pwm_open(PWMID_FOCUS_LED);
        }
        PWMInfo.uiDiv=220;
        PWMInfo.uiPrd=22;
        PWMInfo.uiFall=FcsLedPrdVal[FcsLedLvl];
        PWMInfo.uiOnCycle=0;
        PWMInfo.uiInv=0;
        PWMInfo.uiRise=0;
        pwm_set(PWMID_FOCUS_LED, &PWMInfo);
        pwm_reload(PWMID_FOCUS_LED);
    }
    #endif

    default:
    break;
    }
}
Exemplo n.º 4
0
/**
  Turn on LCD backlight

  Turn on LCD backlight.

  @param void
  @return void
*/
void GPIOMap_TurnOnLCDBacklight(void)
{
    DBG_IND("GPIOMap_TurnOnLCDBacklight: Adjust value %d\r\n", g_LCDBacklightLvl);

    if (g_LCDBacklightEn == FALSE)
    {
#if (LCD_BACKLIGHT_CTRL == LCD_BACKLIGHT_BY_PWM)
        g_LCDBacklightPWMInfo.uiRise = g_LCDBacklightLvlPWMDuty[g_LCDBacklightLvl];
        DBG_IND("PWM: rise=%d\r\n", g_LCDBacklightPWMInfo.uiRise);
        pwm_open(PWMID_BLG_PCTL);
        pwm_pwmConfig(PWMID_BLG_PCTL, &g_LCDBacklightPWMInfo);
        pwm_pwmEnable(PWMID_BLG_PCTL);
#elif (LCD_BACKLIGHT_CTRL == LCD_BACKLIGHT_BY_GPIO)
        gpio_setPin(GPIO_LCD_BLG_PCTL);
#endif
        g_LCDBacklightEn = TRUE;
    }
}
Exemplo n.º 5
0
/***********************************************************************
 *
 * Function: c_entry
 *
 * Purpose: Application entry point from the startup code
 *
 * Processing:
 *     See function.
 *
 * Parameters: None
 *
 * Outputs: None
 *
 * Returns: Nothing
 *
 * Notes: None
 *
 **********************************************************************/
void c_entry(void)
{
  static PWM_CHANNEL_SETUP_T pwm_channel_setup[2][7];
  static PWM_SYSTEM_SETUP_T pwm_system_setup[2];
  static PWM_UPDATE_CONTROL_T pwm_update_control[2];

  /* Disable interrupts in ARM core */
  disable_irq();

  /* Setup miscellaneous board functions */
  phy3250_board_init();

  /* Set virtual address of MMU table */
  cp15_set_vmmu_addr((void *)
                     (IRAM_BASE + (256 * 1024) - (16 * 1024)));

  /* Initialize interrupt system */
  int_initialize(0xFFFFFFFF);

  /* Install standard IRQ dispatcher at ARM IRQ vector */
  int_install_arm_vec_handler(IRQ_VEC, (PFV) lpc32xx_irq_handler);

  /* Enable IRQ interrupts in the ARM core */
  enable_irq();

  /* Enable PWM3/4 clocks */
  clkpwr_clk_en_dis(CLKPWR_PWM3_CLK, 1);
  clkpwr_clk_en_dis(CLKPWR_PWM4_CLK, 1);

  /* Install PWM3 and PWM4 interrupt handlers as a IRQ interrupts */
  int_install_ext_irq_handler(IRQ_PWM3,
                              (PFV) pwm3_user_interrupt, ACTIVE_LOW, 1);
  int_install_ext_irq_handler(IRQ_PWM4,
                              (PFV) pwm4_user_interrupt, ACTIVE_LOW, 1);

  /* Disable SD/MMC output and select PWM3.x on the SD/MMC pins */
  CLKPWR->clkpwr_ms_ctrl = CLKPWR_MSCARD_MSDIO_PIN_DIS;
  GPIO->p_mux_set = P_MAT21 | P_MAT20 |
                    P_MAT03 | P_MAT02 |
                    P_MAT01 | P_MAT00;

  /* Select PWM3.x on the LCD pins */
  GPIO->p3_mux_set = P3_GPO10_MC2B | P3_GPO12_MC2A |
                     P3_GPO13_MC1B | P3_GPO15_MC1A |
                     P3_GPO16_MC0B | P3_GPO18_MC0A;

  /* Select PWM4.x on the LCD pins */
  GPIO->p3_mux_set = P3_GPO6 | P3_GPO8 |
                     P3_GPO9;

  /* Loop forever and let the demo syscle thru different steps */
  while (1)
  {

    /* PWM3/4 clock is the Peripheral clock (13 MHz)           */
    /* PWM3 and PWM4 are not synchronized                      */
    /*                                                         */
    /* Seven single edge independently controlled outputs      */
    /*                                                         */
    /* PWM3 prescaler: 2, period: 10000 ticks => fout = 650 Hz */
    /* channel 1: single edge, duty cycle 14%                  */
    /* channel 2: single edge, duty cycle 28%                  */
    /* channel 3: single edge, duty cycle 42%                  */
    /* channel 4: single edge, duty cycle 56%                  */
    /* channel 5: single edge, duty cycle 70%                  */
    /* channel 6: single edge, duty cycle 84%                  */
    /*                                                         */
    /* PWM4 prescaler: 2, period: 5000 ticks => fout = 1300 Hz */
    /* channel 1: single edge, toggle @ 2000                   */
    /* channel 2: single edge, toggle @ 3000                   */
    /* channel 3: single edge, toggle @ 4000                   */


    /* open PWM3 */
    pwmdev1 = pwm_open(PWM3, 0);

    pwm_ioctl(pwmdev1, PWM_SYSTEM_CONTROL, PWM_TIMER_RESET);

    pwm_system_setup[0].clock = PWM_CLOCK_PERIPHERAL;
    pwm_system_setup[0].prescale = 2;
    pwm_system_setup[0].period = 10000;
    pwm_system_setup[0].update = PWM_NO_UPDATE;
    pwm_ioctl(pwmdev1, PWM_SYSTEM_SETUP,
              (INT_32) &pwm_system_setup[0]);

    pwm_channel_setup[0][1].channel     = 1;
    pwm_channel_setup[0][1].mode        = PWM_SINGLE_EDGE;
    pwm_channel_setup[0][1].duty_option = PWM_WAV_DUTY_PER;
    pwm_channel_setup[0][1].duty        = 14;
    pwm_ioctl(pwmdev1, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[0][1]);
    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_ENABLE, 1);

    pwm_channel_setup[0][2].channel     = 2;
    pwm_channel_setup[0][2].mode        = PWM_SINGLE_EDGE;
    pwm_channel_setup[0][2].duty_option = PWM_WAV_DUTY_PER;
    pwm_channel_setup[0][2].duty        = 28;
    pwm_ioctl(pwmdev1, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[0][2]);
    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_ENABLE, 2);

    pwm_channel_setup[0][3].channel     = 3;
    pwm_channel_setup[0][3].mode        = PWM_SINGLE_EDGE;
    pwm_channel_setup[0][3].duty_option = PWM_WAV_DUTY_PER;
    pwm_channel_setup[0][3].duty        = 42;
    pwm_ioctl(pwmdev1, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[0][3]);
    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_ENABLE, 3);

    pwm_channel_setup[0][4].channel     = 4;
    pwm_channel_setup[0][4].mode        = PWM_SINGLE_EDGE;
    pwm_channel_setup[0][4].duty_option = PWM_WAV_DUTY_PER;
    pwm_channel_setup[0][4].duty        = 56;
    pwm_ioctl(pwmdev1, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[0][4]);
    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_ENABLE, 4);

    pwm_channel_setup[0][5].channel     = 5;
    pwm_channel_setup[0][5].mode        = PWM_SINGLE_EDGE;
    pwm_channel_setup[0][5].duty_option = PWM_WAV_DUTY_PER;
    pwm_channel_setup[0][5].duty        = 70;
    pwm_ioctl(pwmdev1, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[0][5]);
    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_ENABLE, 5);

    pwm_channel_setup[0][6].channel     = 6;
    pwm_channel_setup[0][6].mode        = PWM_SINGLE_EDGE;
    pwm_channel_setup[0][6].duty_option = PWM_WAV_DUTY_PER;
    pwm_channel_setup[0][6].duty        = 84;
    pwm_ioctl(pwmdev1, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[0][6]);
    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_ENABLE, 6);

    pwm_update_control[0].update    = PWM_UPDATE;
    pwm_update_control[0].channels  = 0x7E;
    pwm_ioctl(pwmdev1, PWM_UPDATE_CONTROL,
              (INT_32) &pwm_update_control[0]);
    pwm_ioctl(pwmdev1, PWM_SYSTEM_CONTROL, PWM_TIMER_RESTART);

    /* open PWM4 */
    pwmdev2 = pwm_open(PWM4, 0);

    pwm_system_setup[1].clock = PWM_CLOCK_PERIPHERAL;
    pwm_system_setup[1].prescale = 2;
    pwm_system_setup[1].period = 5000;
    pwm_system_setup[1].update = PWM_NO_UPDATE;
    pwm_ioctl(pwmdev2, PWM_SYSTEM_SETUP, (INT_32) &pwm_system_setup[1]);

    pwm_channel_setup[1][1].channel     = 1;
    pwm_channel_setup[1][1].mode        = PWM_SINGLE_EDGE;
    pwm_channel_setup[1][1].duty_option = PWM_WAV_DUTY_ABS;
    pwm_channel_setup[1][1].duty        = 2000;
    pwm_ioctl(pwmdev2, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[1][1]);
    pwm_ioctl(pwmdev2, PWM_CHANNEL_OUT_ENABLE, 1);

    pwm_channel_setup[1][2].channel     = 2;
    pwm_channel_setup[1][2].mode        = PWM_SINGLE_EDGE;
    pwm_channel_setup[1][2].duty_option = PWM_WAV_DUTY_ABS;
    pwm_channel_setup[1][2].duty        = 3000;
    pwm_ioctl(pwmdev2, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[1][2]);
    pwm_ioctl(pwmdev2, PWM_CHANNEL_OUT_ENABLE, 2);

    pwm_channel_setup[1][3].channel     = 3;
    pwm_channel_setup[1][3].mode        = PWM_SINGLE_EDGE;
    pwm_channel_setup[1][3].duty_option = PWM_WAV_DUTY_ABS;
    pwm_channel_setup[1][3].duty        = 4000;
    pwm_ioctl(pwmdev2, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[1][3]);
    pwm_ioctl(pwmdev2, PWM_CHANNEL_OUT_ENABLE, 3);

    pwm_update_control[1].update    = PWM_UPDATE;
    pwm_update_control[1].channels  = 0x0E;
    pwm_ioctl(pwmdev2, PWM_UPDATE_CONTROL,
              (INT_32) &pwm_update_control[1]);
    pwm_ioctl(pwmdev2, PWM_SYSTEM_CONTROL, PWM_TIMER_RESTART);

    delay(2500000);

    /* close PWM3 & PWM4 */
    pwm_close(pwmdev1);
    pwm_close(pwmdev2);
    delay(2500000);


    /* PWM3/4 clock is the Peripheral clock (13 MHz)                */
    /* PWM3 and PWM4 are synchronized                               */
    /*                                                              */
    /* Four dual edge controlled outputs PWM3.2/4/6 and PWM4.2      */
    /* (as in a stepper motor control application) and a single     */
    /* edge independently controlled output PWM4.3                  */
    /* PWM3.1/3/5 are disabled                                      */
    /*                                                              */
    /* PWM3 prescaler: 5, period: 10000 ticks => fout = 260 Hz      */
    /* channel 1: disabled                                          */
    /* channel 2: dual edge, duty cycle 80%, offset 5%              */
    /* channel 3: disabled                                          */
    /* channel 4: dual edge, duty cycle 80%  offset 30%             */
    /* channel 5: disabled                                          */
    /* channel 6: dual edge, duty cycle 80%  offset 55%             */
    /*                                                              */
    /* PWM4 prescaler: 5, period: 10000 ticks => fout = 260 Hz      */
    /* channel 1: disabled                                          */
    /* channel 2: dual edge, duty cycle 80%  offset 80%             */
    /* channel 3: single edge, toggle @ 500                         */

    /* open PWM3 */
    pwmdev1 = pwm_open(PWM3, 0);

    pwm_ioctl(pwmdev1, PWM_SYSTEM_CONTROL, PWM_TIMER_RESET);

    pwm_system_setup[0].clock = PWM_CLOCK_PERIPHERAL;
    pwm_system_setup[0].prescale = 5;
    pwm_system_setup[0].period = 10000;
    pwm_system_setup[0].update = PWM_NO_UPDATE;
    pwm_ioctl(pwmdev1, PWM_SYSTEM_SETUP, (INT_32) &pwm_system_setup[0]);

    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_DISABLE, 1);

    pwm_channel_setup[0][2].channel     	= 2;
    pwm_channel_setup[0][2].mode        	= PWM_DUAL_EDGE;
    pwm_channel_setup[0][2].duty_option 	= PWM_WAV_DUTY_PER;
    pwm_channel_setup[0][2].duty        	= 80;
    pwm_channel_setup[0][2].offset_option	= PWM_WAV_OFFSET_PER;
    pwm_channel_setup[0][2].offset        	= 5;
    pwm_channel_setup[0][2].ini_state      	= 1;
    pwm_ioctl(pwmdev1, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[0][2]);
    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_ENABLE, 2);

    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_DISABLE, 3);

    pwm_channel_setup[0][4].channel     	= 4;
    pwm_channel_setup[0][4].mode        	= PWM_DUAL_EDGE;
    pwm_channel_setup[0][4].duty_option 	= PWM_WAV_DUTY_PER;
    pwm_channel_setup[0][4].duty        	= 80;
    pwm_channel_setup[0][4].offset_option	= PWM_WAV_OFFSET_PER;
    pwm_channel_setup[0][4].offset        	= 30;
    pwm_channel_setup[0][4].ini_state      	= 1;
    pwm_ioctl(pwmdev1, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[0][4]);
    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_ENABLE, 4);

    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_DISABLE, 5);

    pwm_channel_setup[0][6].channel     	= 6;
    pwm_channel_setup[0][6].mode        	= PWM_DUAL_EDGE;
    pwm_channel_setup[0][6].duty_option 	= PWM_WAV_DUTY_PER;
    pwm_channel_setup[0][6].duty        	= 80;
    pwm_channel_setup[0][6].offset_option	= PWM_WAV_OFFSET_PER;
    pwm_channel_setup[0][6].offset        	= 55;
    pwm_channel_setup[0][6].ini_state      	= 1;
    pwm_ioctl(pwmdev1, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[0][6]);
    pwm_ioctl(pwmdev1, PWM_CHANNEL_OUT_ENABLE, 6);

    pwm_update_control[0].update    = PWM_UPDATE;
    pwm_update_control[0].channels  = 0x7E;
    pwm_ioctl(pwmdev1, PWM_UPDATE_CONTROL,
              (INT_32) &pwm_update_control[0]);

    /* open PWM4 */
    pwmdev2 = pwm_open(PWM4, 0);

    pwm_system_setup[1].clock = PWM_CLOCK_PERIPHERAL;
    pwm_system_setup[1].prescale = 5;
    pwm_system_setup[1].period = 10000;
    pwm_system_setup[1].update = PWM_NO_UPDATE;
    pwm_ioctl(pwmdev2, PWM_SYSTEM_SETUP, (INT_32) &pwm_system_setup[1]);

    pwm_channel_setup[1][2].channel     	= 2;
    pwm_channel_setup[1][2].mode        	= PWM_DUAL_EDGE;
    pwm_channel_setup[1][2].duty_option 	= PWM_WAV_DUTY_PER;
    pwm_channel_setup[1][2].duty        	= 80;
    pwm_channel_setup[1][2].offset_option	= PWM_WAV_OFFSET_PER;
    pwm_channel_setup[1][2].offset        	= 80;
    pwm_channel_setup[1][2].ini_state      	= 1;
    pwm_ioctl(pwmdev2, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[1][2]);
    pwm_ioctl(pwmdev2, PWM_CHANNEL_OUT_ENABLE, 2);

    pwm_channel_setup[1][3].channel     = 3;
    pwm_channel_setup[1][3].mode        = PWM_SINGLE_EDGE;
    pwm_channel_setup[1][3].duty_option = PWM_WAV_DUTY_ABS;
    pwm_channel_setup[1][3].duty        = 500;
    pwm_ioctl(pwmdev2, PWM_CHANNEL_SETUP,
              (INT_32) &pwm_channel_setup[1][3]);
    pwm_ioctl(pwmdev2, PWM_CHANNEL_OUT_ENABLE, 3);

    pwm_update_control[1].update    = PWM_UPDATE;
    pwm_update_control[1].channels  = 0x0E;
    pwm_ioctl(pwmdev2, PWM_UPDATE_CONTROL,
              (INT_32) &pwm_update_control[1]);

    pwm_ioctl(pwmdev1, PWM_SYSTEM_CONTROL, PWM_TIMER_SYNC);
    pwm_ioctl(pwmdev2, PWM_SYSTEM_CONTROL, PWM_TIMER_RESTART);
    pwm_ioctl(pwmdev1, PWM_SYSTEM_CONTROL, PWM_TIMER_GO);

    delay(2500000);

    /* close PWM3 & PWM4 */
    pwm_close(pwmdev1);
    pwm_close(pwmdev2);
    delay(2500000);
  }
}
Exemplo n.º 6
0
/**
  Do GPIO initialization

  Initialize input/output pins, and pin status

  @param void
  @return void
*/
void GPIOMap_Init(void)
{
    // Open GPIO driver
    gpio_open();

    // Shutter key
    gpio_setIntTypePol(GPIOINT_KEY_SHUTTER1, GPIO_INTTYPE_LEVEL, GPIO_INTPOL_POSHIGH);
    dma_setKeyScanEN(DRAM_KEY_SHUTTER1, TRUE);

    gpio_setIntTypePol(GPIOINT_KEY_SHUTTER2, GPIO_INTTYPE_LEVEL, GPIO_INTPOL_POSHIGH);
    dma_setKeyScanEN(DRAM_KEY_SHUTTER2, TRUE);

    // Storage Card detect
    gpio_setIntTypePol(GPIOINT_CARD_DETECT, GPIO_INTTYPE_LEVEL, GPIO_INTPOL_POSHIGH);
    dma_setKeyScanEN(DRAM_KEY_CARD_DETECT, TRUE);

    // Storage Card write protect
    dma_setKeyScanEN(DRAM_KEY_CARD_WP, TRUE);

    // LCD
    gpio_setDir(GPIO_LCD_BL_CTRL, GPIO_DIR_OUTPUT);
    gpio_clearPin(GPIO_LCD_BL_CTRL);

    //gpio_setDir(GPIO_LCD_BL_PWR, GPIO_DIR_OUTPUT);
    //gpio_setPin(GPIO_LCD_BL_PWR);

     //Video Light  //michael
    gpio_setDir(VIDEO_FLOOD_LIGHT, GPIO_DIR_OUTPUT);
    gpio_clearPin(VIDEO_FLOOD_LIGHT);

    // TV detect
    gpio_setIntTypePol(GPIOINT_TV_DETECT, GPIO_INTTYPE_LEVEL, GPIO_INTPOL_POSHIGH);
    dma_setKeyScanEN(DRAM_KEY_TV_DETECT, TRUE);

    // LCD ROTATE detect
    gpio_setIntTypePol(GPIOINT_LCD_ROTATE, GPIO_INTTYPE_LEVEL, GPIO_INTPOL_POSHIGH);
    dma_setKeyScanEN(DRAM_LCD_ROTATE, TRUE);

    //Power Det
    gpio_setIntTypePol(GPIOINT_POWER_DET, GPIO_INTTYPE_LEVEL, GPIO_INTPOL_POSHIGH);
    dma_setKeyScanEN(DRAM_POWER_DET, TRUE);

    // LED
//    gpio_setDir(GPIO_LED_R, GPIO_DIR_OUTPUT);
//    gpio_setPin(GPIO_LED_R);


    // Sensor
    //pinmux_switch_dgpio(PINMUX_DGPIO1, PINMUX_DGPIO1_GPIO);

    gpio_setDir(GPIO_SENSOR_RESET, GPIO_DIR_OUTPUT);
    gpio_clearPin(GPIO_SENSOR_RESET);

    #if (_SUDPLAY_USE_ == _SUDPLAY_USE_PWM_IOSIM_)
    gpio_setDir(GPIO_BEEP_PWMIOSIM, GPIO_DIR_OUTPUT);
    gpio_clearPin(GPIO_BEEP_PWMIOSIM);
    #endif

    // PWM Init
    //pwm_open(PWM_FLASH_CHARGE);

    #if (_SUDPLAY_USE_ == _SUDPLAY_USE_PWM_)
    pwm_open(PWM_BEEP_SOUND);
    #endif
}
Exemplo n.º 7
0
/**
  Do GPIO initialization

  Initialize input/output pins, and pin status

  @param void
  @return void
*/
void GPIOMap_Init(void)
{
    // Open GPIO driver
    gpio_open();

    #if 0
    gpio_setDir(GPIO_KEY_LEFT, GPIO_DIR_INPUT);
    pad_setPullUpDown(PAD_KEY_LEFT, PAD_PULLUP);

    gpio_setDir(GPIO_KEY_RIGHT, GPIO_DIR_INPUT);
    pad_setPullUpDown(PAD_KEY_RIGHT, PAD_PULLUP);

    gpio_setDir(GPIO_KEY_UP, GPIO_DIR_INPUT);
    pad_setPullUpDown(PAD_KEY_UP, PAD_PULLUP);

    gpio_setDir(GPIO_KEY_DOWN, GPIO_DIR_INPUT);
    pad_setPullUpDown(PAD_KEY_DOWN, PAD_PULLUP);

    gpio_setDir(GPIO_KEY_ZOOMOUT, GPIO_DIR_INPUT);
    pad_setPullUpDown(PAD_KEY_ZOOMOUT, PAD_PULLUP);

    gpio_setDir(GPIO_KEY_ZOOMIN, GPIO_DIR_INPUT);
    pad_setPullUpDown(PAD_KEY_ZOOMIN, PAD_PULLUP);

    gpio_setDir(GPIO_KEY_MENU, GPIO_DIR_INPUT);
    pad_setPullUpDown(PAD_KEY_MENU, PAD_PULLUP);

    gpio_setDir(GPIO_KEY_SHUTTER, GPIO_DIR_INPUT);
    pad_setPullUpDown(PAD_KEY_SHUTTER, PAD_PULLUP);

    gpio_setDir(DGPIO_KEY_SHUTTER2, GPIO_DIR_INPUT);
    pad_setPullUpDown(PAD_KEY_SHUTTER2, PAD_PULLUP);
    #endif

    // Storage Card detect
    //gpio_setDir(GPIO_CARD_DETECT, GPIO_DIR_INPUT);
    //pad_setPullUpDown(PAD_CARD_DETECT, PAD_PULLUP);
    gpio_setIntTypePol(GPIOINT_CARD_DETECT, GPIO_INTTYPE_LEVEL, GPIO_INTPOL_POSHIGH);
    dma_setKeyScanEN(DRAM_KEY_CARD_DETECT, TRUE);

    // Storage Card write protect
    gpio_setDir(GPIO_CARD_WP, GPIO_DIR_INPUT);
    pad_setPullUpDown(PAD_CARD_WP, PAD_PULLUP);

    //LCD
    gpio_setDir(GPIO_LCD_BL_CTRL, GPIO_DIR_OUTPUT);
    gpio_clearPin(GPIO_LCD_BL_CTRL);

    gpio_setDir(GPIO_LCD_BL_PWR, GPIO_DIR_OUTPUT);
    gpio_clearPin(GPIO_LCD_BL_PWR);

    // Sensor
    gpio_setDir(GPIO_SENSOR_RESET, GPIO_DIR_OUTPUT);
    gpio_clearPin(GPIO_SENSOR_RESET);

    #if (_SUDPLAY_USE_ == _SUDPLAY_USE_PWM_IOSIM_)
    gpio_setDir(GPIO_BEEP_PWMIOSIM, GPIO_DIR_OUTPUT);
    gpio_clearPin(GPIO_BEEP_PWMIOSIM);
    #endif

    // PWM Init
    //pwm_open(PWM_FLASH_CHARGE);

    #if (_SUDPLAY_USE_ == _SUDPLAY_USE_PWM_)
    pwm_open(PWM_BEEP_SOUND);
    #endif
}