Exemple #1
0
static int32_t config_gpio_event(uint8_t cmd_type, iotlab_packet_t* packet)
{
     /*
     * Expected packet format is (length:2B:
     *      * Start / Stop mode         [1B]
     *      * GPIOs (PPS|GPIO1|GPIO2)    [1B]
     */

    packet_t* pkt = (packet_t*) packet;
    if (pkt->length != 2)
        return 1;

    uint8_t mode  = pkt->data[0];
    uint8_t gpios = pkt->data[1];
    (void)gpios;

    if (mode == STOP) {
        gpio_disable_irq(&gpio_config[3]);
        return 0;
    } else {
        gpio_enable_irq(&gpio_config[3], IRQ_RISING, pps_handler_irq, NULL);
        return 0;
    }

}
Exemple #2
0
static int cmd_test_pps_start(char *command)
{
    if (strcmp(command, "test_pps_start"))
        return 1;
    // third gpio line
    seconds = 0;
    gpio_enable_irq(&gpio_config[3], IRQ_RISING, pps_handler_irq, NULL);
    printf("ACK test_pps_start\n");
    return 0;
}
Exemple #3
0
static void pixcir_read_work(struct work_struct *work)
{    
	u8 *p;
	u8 touch, button;
	u8 rdbuf[27]={0};
	int ret, i;
    int x=0,y=0,px,py,track_id,brn;
    struct pixcir_data *pixcir=container_of(work, struct pixcir_data, read_work.work);

    if(gpio_get_value(pixcir->igp_idx, pixcir->igp_bit) || pixcir->earlysus){
        dbg("INT High Level.\n");
        goto exit_penup;
    }

	ret = pixcir_read(pixcir, rdbuf, sizeof(rdbuf));
	if (ret <= 0) {
		dbg_err("pixcir_read failed, ret=%d\n",ret);
        goto exit_penup;
	}

	touch = rdbuf[0]&0x07;
	button = rdbuf[1];
	p=&rdbuf[2];
    dbg("%02x,%02x\n",touch,button);
    if (touch) {
		for(i=0; i<touch; i++) {
            brn = (*(p+4))>>3;//broken line
            track_id = (*(p+4))&0x7;
            px = (*(p+1)<<8)+(*(p));	
            py = (*(p+3)<<8)+(*(p+2));	
            p+=5;

            x = px;
            y = py;
            
            if(pixcir->swap) {
                x = py;
                y = px;
            }

            if (pixcir->xch) x = pixcir->xresl - px;
            if (pixcir->ych) y = pixcir->yresl - py;

            pixcir->penup = PEN_DOWN;
            input_report_abs(pixcir->input_dev, ABS_MT_TRACKING_ID, track_id+1);
			input_report_abs(pixcir->input_dev, ABS_MT_POSITION_X, x);
			input_report_abs(pixcir->input_dev, ABS_MT_POSITION_Y, y);
			input_mt_sync(pixcir->input_dev);
            
			if(pixcir->dbg) printk("F%d: brn=%-2d Tid=%1d px=%-5d py=%-5d x=%-5d y=%-5d\n",i,brn,track_id,px,py,x,y);   
		}
        input_sync(pixcir->input_dev);
	} 

#ifdef TOUCH_KEY        
    if(button){
        if(!pixcir->tkey_pressed ){
            pixcir->tkey_pressed = 1;
            switch(button){
                case 1:
                    pixcir->tkey_idx = SEARCH_IDX;
                    input_report_key(pixcir->input_dev, keycodes[SEARCH_IDX], 1);
                    break;
                case 2:
                    pixcir->tkey_idx = BACK_IDX;
                    input_report_key(pixcir->input_dev, keycodes[BACK_IDX], 1);
                    break;
                case 4:
                    pixcir->tkey_idx = HOME_IDX;
                    input_report_key(pixcir->input_dev, keycodes[HOME_IDX], 1);
                    break;
                case 8:
                    pixcir->tkey_idx = MENU_IDX;
                    input_report_key(pixcir->input_dev, keycodes[MENU_IDX], 1);
                    break;
                default:
                    pixcir->tkey_idx = NUM_KEYS;
                    break;    
            }
        }
    }
    else{
        if(pixcir->tkey_pressed){
            if(pixcir->tkey_idx < NUM_KEYS ) {
                dbg("Report virtual key.\n");
                input_report_key(pixcir->input_dev, keycodes[pixcir->tkey_idx], 0);
                input_sync(pixcir->input_dev);             
            }
            pixcir->tkey_pressed = 0;
        }
    }        
#endif

    queue_delayed_work(pixcir->workqueue, &pixcir->read_work,16*HZ/1000);
    return;

exit_penup:
    if(pixcir->penup == PEN_DOWN){
        dbg("Report pen up.\n");
        input_mt_sync(pixcir->input_dev);
		input_sync(pixcir->input_dev);
        pixcir->penup = PEN_UP;
    }
#ifdef TOUCH_KEY     
    if(pixcir->tkey_idx < NUM_KEYS && pixcir->tkey_pressed ) {
        dbg("Report virtual key.\n");
        input_report_key(pixcir->input_dev, keycodes[pixcir->tkey_idx], 0);
        input_sync(pixcir->input_dev);
        pixcir->tkey_pressed = 0;
    }
#endif    
    gpio_enable_irq(pixcir->igp_idx, pixcir->igp_bit);
    return;
		
}