示例#1
0
/**
 * @brief   RDA_bt_SerialCommTxByte蓝牙I2C设置。
 * @author  LHD
 * @date    2012-02-16
 * @param   Data 要发送的数据
 * @return  uint8
 */
uint8 RDA_bt_SerialCommTxByte(uint8 data) /* return 0 --> ack */
{
    T_S32 i;
    uint8 temp_value = 0;
    for(i=7; (i>=0)&&(i<=7); i--){
       gpio_set_pin_level(GPIO_I2C_SCLK,0); /* low */
       DELAY(DURATION_LOW);
       if(i==7)gpio_set_pin_dir(GPIO_I2C_SDA,1);
       DELAY(DURATION_LOW/2);
       gpio_set_pin_level(GPIO_I2C_SDA,((data>>i)&0x01));
       DELAY(DURATION_LOW/2);
       gpio_set_pin_level(GPIO_I2C_SCLK,1); /* high */
       DELAY(DURATION_HIGH);
    }
    gpio_set_pin_level(GPIO_I2C_SCLK,0);/* low */  
    DELAY(DURATION_LOW);
    gpio_set_pin_dir(GPIO_I2C_SDA,0);
    DELAY(DURATION_LOW/2);
    gpio_set_pin_level(GPIO_I2C_SCLK,1);
    DELAY(DURATION_HIGH);    
    temp_value = gpio_get_pin_level(GPIO_I2C_SDA);
    gpio_set_pin_level(GPIO_I2C_SCLK,0);
    DELAY(DURATION_LOW);
    return temp_value;
}
示例#2
0
void SerialCommInit(void)
{
    gpio_set_pin_dir(GPIO_I2C_SCLK,1);  
    gpio_set_pin_dir(GPIO_I2C_SDA,1);     
    gpio_set_pin_level(GPIO_I2C_SCLK,1);
    gpio_set_pin_level(GPIO_I2C_SDA,1);
}
示例#3
0
void SerialCommRxByte(uint8 *data, uint8 ack)
{
   T_S32 i;
   uint32 dataCache;

   dataCache = 0;
   for(i=7; (i>=0)&&(i<=7); i--){
      gpio_set_pin_level(GPIO_I2C_SCLK,0);
      DELAY(DURATION_LOW);
       if(i==7)gpio_set_pin_dir(GPIO_I2C_SDA,0);
      DELAY(DURATION_LOW/2);
      gpio_set_pin_level(GPIO_I2C_SCLK,1);
      DELAY(DURATION_HIGH);
      dataCache |= (gpio_get_pin_level(GPIO_I2C_SDA)<<i);
      DELAY(DURATION_LOW/2);
   }
   
   gpio_set_pin_level(GPIO_I2C_SCLK,0);
   DELAY(DURATION_LOW);
   gpio_set_pin_dir(GPIO_I2C_SDA,1);
   DELAY(DURATION_LOW/2);
   gpio_set_pin_level(GPIO_I2C_SDA,ack);   
   DELAY(DURATION_LOW/2);   
   gpio_set_pin_level(GPIO_I2C_SCLK,1);
   DELAY(DURATION_HIGH);
   *data = (uint8)dataCache;
   gpio_set_pin_level(GPIO_I2C_SCLK,0);
}
示例#4
0
static T_BOOL cam_ov3640_close(T_VOID)
{    
    gpio_set_pin_level(GPIO_CAMERA_CHIP_ENABLE, !CAM_EN_LEVEL);
    gpio_set_pin_dir(GPIO_CAMERA_RESET, GPIO_DIR_INPUT);

	//IICÐèÒªÓûغê
	gpio_set_pin_dir(28, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(28, GPIO_LEVEL_LOW);
    gpio_set_pin_dir(0, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(0, GPIO_LEVEL_LOW);
    
    return AK_TRUE;
}
示例#5
0
/*******************************************************************************
 * @brief   set LoudSpeaker connect
 * @author  
 * @date    
 * @param   [in]bIsConnect: connect or not
 * @return  T_VOID
*******************************************************************************/
T_VOID Fwl_SpkConnectSet(T_BOOL bIsConnect)
{
    if (bIsConnect)
    {
        gpio_set_pin_dir(GPIO_SPEAKER_CONTROL, GPIO_DIR_OUTPUT);
        gpio_set_pin_level(GPIO_SPEAKER_CONTROL, LEVEL_HIGH);
    }
    else
    {
        gpio_set_pin_dir(GPIO_SPEAKER_CONTROL, GPIO_DIR_OUTPUT);
        gpio_set_pin_level(GPIO_SPEAKER_CONTROL, LEVEL_LOW);
    }
}
示例#6
0
void SerialCommStart(void) /* start or re-start */
{
   gpio_set_pin_dir(GPIO_I2C_SCLK,1);
   gpio_set_pin_dir(GPIO_I2C_SDA,1);
   gpio_set_pin_level(GPIO_I2C_SDA,1);
   DELAY(DURATION_START_1);
   gpio_set_pin_level(GPIO_I2C_SCLK,1);
   DELAY(DURATION_START_1);   
   gpio_set_pin_level(GPIO_I2C_SDA,0);
   DELAY(DURATION_START_2);
   gpio_set_pin_level(GPIO_I2C_SCLK,0);/* start condition */
   DELAY(DURATION_START_3);   
}
示例#7
0
static T_VOID cam_ov3640_open(T_VOID)
{
	gpio_set_pin_as_gpio(GPIO_CAMERA_CHIP_ENABLE);
    gpio_set_pin_dir(GPIO_CAMERA_CHIP_ENABLE, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(GPIO_CAMERA_CHIP_ENABLE, CAM_EN_LEVEL);
    delay_ms(10);
	gpio_set_pin_as_gpio(GPIO_CAMERA_RESET);
    gpio_set_pin_dir(GPIO_CAMERA_RESET, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(GPIO_CAMERA_RESET, CAM_RESET_LEVEL);
    delay_ms(10);
    gpio_set_pin_level(GPIO_CAMERA_RESET, !CAM_RESET_LEVEL);

    delay_ms(20);
}
示例#8
0
/**
 * @brief       select/deselect a nandflash target
 * @author      Yang Yiming
 * @date        2012-12-25
 * @param       [in]nTarget target nandflash
 * @param       [in]bSelect AK_TRUE to select, AK_FALSE to deselect
 * @return      T_BOOL
 */
T_BOOL nfc_select(T_U8 nTarget, T_BOOL bSelect)
{
    //only when additional #ce is needed, this block is essential
    if (s_nPhyPos[nTarget] < INVALID_GPIO)
    {
        gpio_set_pin_dir(s_nPhyPos[nTarget], GPIO_DIR_OUTPUT);
        gpio_set_pin_level(s_nPhyPos[nTarget], bSelect ? GPIO_LEVEL_LOW : GPIO_LEVEL_HIGH);
    }

    if (bSelect)
    {
        g_clk_map |= CLK_NFC_EN;
        store_int(INT_EN_L2);
        sys_module_enable(eVME_NANDFLASH_CLK, AK_TRUE);
        sys_share_pin_lock(ePIN_AS_NANDFLASH);
        s_nActChip = nTarget;
    }
    else
    {
        s_nActChip = 0xFF;
        sys_module_enable(eVME_NANDFLASH_CLK, AK_FALSE);
        sys_share_pin_unlock(ePIN_AS_NANDFLASH);
        restore_int();
        g_clk_map &= ~CLK_NFC_EN;
    }
    
    return AK_TRUE;
}
示例#9
0
/** @brief Handler for IPMI_OEM_CMD_GPIO IPMI command
 *
 * Access and configure the controller's GPIO
 *
 * Req data:
 * [0] - Mode - (0) = Read port status (direction and value)
 *              (1) = Set pin as input
 *              (2) = Set pin as output (pin value is on byte 3)
 * [1] - GPIO Port number
 * [2] - GPIO Pin number
 * [3] - Output pin value (optional)
 *
 * @param req[in]
 * @param rsp[out]
 *
 * @return
 */
IPMI_HANDLER(ipmi_oem_cmd_gpio_pin, NETFN_CUSTOM_OEM, IPMI_OEM_CMD_GPIO_PIN, ipmi_msg *req, ipmi_msg* rsp)
{
    uint8_t mode = req->data[0];
    uint8_t port = req->data[1];
    uint8_t pin = req->data[2];
    uint8_t pin_state;

    uint8_t len = 0;

    rsp->completion_code = IPMI_CC_OK;

    switch (mode) {
    case 0:
        /* Port read, returns port direction and read value*/
        rsp->data[len++] = ( gpio_get_port_dir( port ) >> 24 ) & 0xFF;
        rsp->data[len++] = ( gpio_get_port_dir( port ) >> 16 ) & 0xFF;
        rsp->data[len++] = ( gpio_get_port_dir( port ) >>  8 ) & 0xFF;
        rsp->data[len++] = ( gpio_get_port_dir( port ) >>  0 ) & 0xFF;
        rsp->data[len++] = ( gpio_read_port( port ) >> 24 ) & 0xFF;
        rsp->data[len++] = ( gpio_read_port( port ) >> 16 ) & 0xFF;
        rsp->data[len++] = ( gpio_read_port( port ) >>  8 ) & 0xFF;
        rsp->data[len++] = ( gpio_read_port( port ) >>  0 ) & 0xFF;
        break;

    case 1:
        /* Set pin as input */
        gpio_set_pin_dir( port, pin, GPIO_DIR_INPUT );
        break;

    case 2:
        /* Set pin as output */
        gpio_set_pin_dir( port, pin, GPIO_DIR_OUTPUT );

        /* If given, set the pin output value */
        if (req->data_len > 3) {
            pin_state = req->data[3];
            gpio_set_pin_state( port, pin, pin_state );
        }
        break;

    default:
        rsp->completion_code = IPMI_CC_INV_DATA_FIELD_IN_REQ;
        break;
    }

    rsp->data_len = len;
}
示例#10
0
static T_VOID cam_ov2643_open(T_VOID)
{  
    gpio_set_pin_dir(GPIO_CAMERA_AVDD, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(GPIO_CAMERA_AVDD, gpio_pin_get_ActiveLevel(GPIO_CAMERA_AVDD));   

    gpio_set_pin_as_gpio(GPIO_CAMERA_CHIP_ENABLE);
    gpio_set_pin_dir(GPIO_CAMERA_CHIP_ENABLE, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(GPIO_CAMERA_CHIP_ENABLE, CAM_EN_LEVEL);    
    mini_delay(10);

    gpio_set_pin_as_gpio(GPIO_CAMERA_RESET);
    gpio_set_pin_dir(GPIO_CAMERA_RESET, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(GPIO_CAMERA_RESET, CAM_RESET_LEVEL);
    mini_delay(10);
    gpio_set_pin_level(GPIO_CAMERA_RESET, !CAM_RESET_LEVEL);

    mini_delay(20);
}
示例#11
0
static T_BOOL cam_gc0308_close(T_VOID)
{
    //sccb software standby mode
	T_U8 Reg0x1a = 0x2b;
	T_U8 Reg0x25 = 0x00;
    sccb_write_data(CAMERA_SCCB_ADDR, 0x1a, &Reg0x1a, 1);
	sccb_write_data(CAMERA_SCCB_ADDR, 0x25, &Reg0x25, 1);

	gpio_set_pin_level(GPIO_CAMERA_CHIP_ENABLE, !CAM_EN_LEVEL);
    gpio_set_pin_level(GPIO_CAMERA_AVDD, !gpio_pin_get_ActiveLevel(GPIO_CAMERA_AVDD));    
    gpio_set_pin_dir(GPIO_CAMERA_RESET, GPIO_DIR_INPUT);

    gpio_set_pin_dir(GPIO_I2C_SCL, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(GPIO_I2C_SCL, GPIO_LEVEL_LOW);
    gpio_set_pin_dir(GPIO_I2C_SDA, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(GPIO_I2C_SDA, GPIO_LEVEL_LOW);
    
    return AK_TRUE;
}
示例#12
0
void LED_init(void)
{
    /* Init LED Pin */
    gpio_init();

    /* Set pins as output */
    gpio_set_pin_dir( LEDBLUE_PORT, LEDBLUE_PIN, OUTPUT);
    gpio_set_pin_dir( LEDGREEN_PORT, LEDGREEN_PIN, OUTPUT);
    gpio_set_pin_dir( LEDRED_PORT, LEDRED_PIN, OUTPUT);

    LED_state_rec_t* pLED;
    for (int i = 0; i<LED_CNT; i++){
        pLED = &LEDstate[i];
        pLED->queue = xQueueCreate( 2, sizeof(LED_activity_desc_t));
        xQueueSend( pLED->queue, pLED->local_ptr, 0 );
    }

    xTaskCreate( LEDTask, (const char *) "LED Task", 120, (void * ) NULL, tskLED_PRIORITY, ( TaskHandle_t * ) NULL);
    /*! @todo Handle task creation error */
}
示例#13
0
static T_BOOL cam_hm1375_close(T_VOID)
{
    //sccb software standby mode
//    T_U8 Reg0x3d = 0x48;
//    T_U8 Reg0xc3 = 0x00;
    
//    sccb_write_short(CAMERA_SCCB_ADDR, 0x3d, &Reg0x3d, 1);
//    sccb_write_short(CAMERA_SCCB_ADDR, 0xc3, &Reg0xc3, 1);

    gpio_set_pin_level(GPIO_CAMERA_CHIP_ENABLE, !CAM_EN_LEVEL);
    gpio_set_pin_level(GPIO_CAMERA_AVDD, !gpio_pin_get_ActiveLevel(GPIO_CAMERA_AVDD));    
    gpio_set_pin_dir(GPIO_CAMERA_RESET, GPIO_DIR_INPUT);

    gpio_set_pin_dir(GPIO_I2C_SCL, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(GPIO_I2C_SCL, GPIO_LEVEL_LOW);
    gpio_set_pin_dir(GPIO_I2C_SDA, GPIO_DIR_OUTPUT);
    gpio_set_pin_level(GPIO_I2C_SDA, GPIO_LEVEL_LOW);
    
    return AK_TRUE;
}
示例#14
0
void SerialCommStop(void)
{
    gpio_set_pin_level(GPIO_I2C_SCLK,0);
    DELAY(DURATION_LOW);
    gpio_set_pin_dir(GPIO_I2C_SDA,1);
    gpio_set_pin_level(GPIO_I2C_SDA,0);
    DELAY(DURATION_STOP_1);
    gpio_set_pin_level(GPIO_I2C_SCLK,1);
    DELAY(DURATION_STOP_2);    
    gpio_set_pin_level(GPIO_I2C_SDA,1);/* stop condition */
    DELAY(DURATION_STOP_3);      
}
示例#15
0
void ssp_init( uint8_t id, uint32_t bitrate, uint8_t frame_sz, bool master_mode, bool poll )
{
    ssp_cfg[id].polling = poll;
    ssp_cfg[id].frame_size = frame_sz;
    ssp_cfg[id].master_mode = master_mode;
    ssp_cfg[id].bitrate = bitrate;

    /* Set up clock and muxing for SSP0/1 interface */
    /* Slave Select (SSEL/FCS_B) is left as GPIO so we can send more than one byte without this pin going high (default operation of SSP interface) */

    Chip_IOCON_Init(LPC_IOCON);

    Chip_IOCON_PinMux(LPC_IOCON, ssp_pins[id].port, ssp_pins[id].sck_pin, IOCON_MODE_PULLDOWN, ssp_pins[id].sck_func);
    Chip_IOCON_PinMux(LPC_IOCON, ssp_pins[id].port, ssp_pins[id].ssel_pin, IOCON_MODE_PULLUP, ssp_pins[id].ssel_func);
    Chip_IOCON_PinMux(LPC_IOCON, ssp_pins[id].port, ssp_pins[id].mosi_pin, IOCON_MODE_INACT, ssp_pins[id].mosi_func);
    Chip_IOCON_PinMux(LPC_IOCON, ssp_pins[id].port, ssp_pins[id].miso_pin, IOCON_MODE_INACT, ssp_pins[id].miso_func);

    if (ssp_pins[id].ssel_func == 0) {
        gpio_set_pin_dir( ssp_pins[id].port, ssp_pins[id].ssel_pin, OUTPUT);
        gpio_set_pin_state( ssp_pins[id].port, ssp_pins[id].ssel_pin, HIGH);
    }

    Chip_SSP_Init(ssp_cfg[id].lpc_id);
    Chip_SSP_SetBitRate(ssp_cfg[id].lpc_id, bitrate);
    Chip_SSP_SetMaster(ssp_cfg[id].lpc_id, master_mode);
    Chip_SSP_SetFormat(ssp_cfg[id].lpc_id, (frame_sz-1), SSP_FRAMEFORMAT_SPI, SSP_CLOCK_CPHA0_CPOL0);
    Chip_SSP_Enable(ssp_cfg[id].lpc_id);

    if (!poll) {
        /* Configure interruption priority and enable it */
        NVIC_SetPriority( ssp_cfg[id].irq, configMAX_SYSCALL_INTERRUPT_PRIORITY );
        NVIC_EnableIRQ( ssp_cfg[id].irq );
    }

    if (ssp_cfg[id].lpc_id == LPC_SSP0) {
        active_SSP0 = id;
    }
}
示例#16
0
T_VOID SerialCommDeInit(T_VOID)
{
    gpio_set_pin_dir(GPIO_I2C_SCLK,0);  
    gpio_set_pin_dir(GPIO_I2C_SDA,0);    
}