コード例 #1
0
ファイル: fsa9480_i2c.c プロジェクト: Smackbox/linux-2.6-sgt
static int fsa9480_codec_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	struct fsa9480_state *state;
	struct device *dev = &client->dev;
	u8 pData;

	DEBUG_FSA9480("[FSA9480] %s\n", __func__);

	s3c_gpio_cfgpin(GPIO_USB_SW_SCL, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_USB_SW_SCL, S3C_GPIO_PULL_NONE);

	s3c_gpio_cfgpin(GPIO_USB_SW_SDA, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_USB_SW_SDA, S3C_GPIO_PULL_NONE);

	 s3c_gpio_cfgpin(GPIO_UART_SEL, S3C_GPIO_OUTPUT );
	 s3c_gpio_setpull(GPIO_UART_SEL, S3C_GPIO_PULL_NONE);

	user_switch_init();

	 init_waitqueue_head(&usb_detect_waitq); 
	 INIT_WORK(&fsa9480_work, FSA9480_ReadIntRegister);
	 fsa9480_workqueue = create_singlethread_workqueue("fsa9480_workqueue");

	 state = kzalloc(sizeof(struct fsa9480_state), GFP_KERNEL);
	 if(!state) {
		 dev_err(dev, "%s: failed to create fsa9480_state\n", __func__);
		 return -ENOMEM;
	 }

	state->client = client;
	fsa9480_i2c_client = client;

	i2c_set_clientdata(client, state);
	if(!fsa9480_i2c_client)
	{
		dev_err(dev, "%s: failed to create fsa9480_i2c_client\n", __func__);
		return -ENODEV;
	}

	 /*clear interrupt mask register*/
	fsa9480_read( REGISTER_CONTROL, &pData);
	fsa9480_write( REGISTER_CONTROL, pData & ~INT_MASK);

	 fsa9480_interrupt_init();

	 fsa9480_chip_init();

	 return 0;
}
コード例 #2
0
int main (void)
{

    SystemInit();                         /* initialize clocks */
    debug_frmwrk_init();
    do{
      user_switch_init();
      }while(int_flag != 1);

  	print_menu();

    i2c_lpc_init(I2C_SPEED_100);
    test_i2c_at24c256_flash();
    while(1);
}
コード例 #3
0
ファイル: user_main.c プロジェクト: hehao3344/mkit
void user_init(void)
{
    uart_init(BIT_RATE_115200, BIT_RATE_115200);
    os_printf("SDK version:%s\n", system_get_sdk_version());
    
    // rsa_api_unit_test();
    
    os_printf("================= \n");
    
    packet_test();
    
    //json_test();
    
    //aes_api_unit_test();    
    //os_printf("================= \n");
    //crypto_api_unit_test();
    
    return;

    struct station_config station_conf;
    wifi_station_get_config(&station_conf);
    os_printf(MACSTR ",%s,%s \n", MAC2STR(station_conf.bssid), station_conf.password, station_conf.ssid);


    //struct station_config {
    //    uint8 ssid[32];
    //    uint8 password[64];
    //    uint8 bssid_set;    // Note: If bssid_set is 1, station will just connect to the router
    //                        // with both ssid[] and bssid[] matched. Please check about this.
    //    uint8 bssid[6];
    //};

    // 0c:4b:54:84:9e:2d t77y2qs4
    //station_conf.bssid[0] = 0x0c;
    //station_conf.bssid[1] = 0x4b;
    //station_conf.bssid[2] = 0x54;
    //station_conf.bssid[3] = 0x84;
    //station_conf.bssid[4] = 0x9e;
    //station_conf.bssid[5] = 0x2d;
    station_conf.bssid_set = 0;
    //os_strcpy(station_conf.ssid,     "hehao");
    //os_strcpy(station_conf.password, "ziqiangbuxi");
    wifi_station_set_config(&station_conf);

    wifi_station_get_config(&station_conf);
    os_printf(MACSTR ", %s, %s %d\n", MAC2STR(station_conf.bssid), station_conf.password, station_conf.ssid, station_conf.bssid_set);

    int8 id_buf[16] = {0};
    flash_param_get_id(id_buf);
    os_printf("get id = %s \n", id_buf);

    if (0 == os_strcmp(id_buf, CONFIG_RESET_ID))
    {
        os_printf("airkiss start ... \n");
        smart_config_start();
        user_switch_init();

        os_timer_disarm(&status_timer);
        os_timer_setfn(&status_timer, (os_timer_func_t *)led_status_center, NULL);
        os_timer_arm(&status_timer, 2000, 0);

        single_key[0] = key_init_single(PLUG_KEY_0_IO_NUM,
                                        PLUG_KEY_0_IO_MUX,
                                        PLUG_KEY_0_IO_FUNC,
                                        key_long_press,
                                        key_short_press);
        keys.key_num    = PLUG_KEY_NUM;
        keys.single_key = single_key;
        key_init(&keys);

        os_timer_disarm(&sys_timer);
        os_timer_setfn(&sys_timer, (os_timer_func_t *)system_secs_center, NULL);
        os_timer_arm(&sys_timer, 1000, 1); // 0 at once, 1 restart auto.

        switch_level = 0x01;
        user_switch_output(1);
    }
    else
    {
        schedule_create(0);
    }
}