fn read_touchdata(data: &mut TouchEventInfo) -> MynewtResult<()> {
        read_register_range(TOUCH_CONTROLLER_ADDRESS, 0, POINT_READ_BUF as u8,
                            unsafe {
                                &mut BUF
                            }).expect("read touchdata fail");
        *data =
            unsafe {
                ::core::mem::transmute::<[u8; ::core::mem::size_of::<TouchEventInfo>()],
                                         TouchEventInfo>([0;
                                                             ::core::mem::size_of::<TouchEventInfo>()])
            };
        data.point_num = unsafe { BUF[FT_TOUCH_POINT_NUM] & 0x0F };
        data.count = 0;
        for i in 0..CFG_MAX_TOUCH_POINTS {
            let pointid =
                unsafe { BUF[HYN_TOUCH_ID_POS + HYN_TOUCH_STEP * i] } >> 4;
            if pointid >= HYN_MAX_ID { break ; }
            data.count += 1;
            let x_high =
                unsafe { BUF[HYN_TOUCH_X_H_POS + HYN_TOUCH_STEP * i] & 0x0F }
                    as u16;
            let x_low =
                unsafe { BUF[HYN_TOUCH_X_L_POS + HYN_TOUCH_STEP * i] } as u16;
            data.touches[i].x = (x_high << 8) | x_low;
            let y_high =
                unsafe { BUF[HYN_TOUCH_Y_H_POS + HYN_TOUCH_STEP * i] & 0x0F }
                    as u16;
            let y_low =
                unsafe { BUF[HYN_TOUCH_Y_L_POS + HYN_TOUCH_STEP * i] } as u16;
            data.touches[i].y = (y_high << 8) | y_low;
            data.touches[i].action =
                unsafe { BUF[HYN_TOUCH_EVENT_POS + HYN_TOUCH_STEP * i] } >> 6;
            data.touches[i].finger =
                unsafe { BUF[HYN_TOUCH_ID_POS + HYN_TOUCH_STEP * i] } >> 4;
            data.touches[i].pressure =
                unsafe { BUF[HYN_TOUCH_XY_POS + HYN_TOUCH_STEP * i] };
            data.touches[i].area =
                unsafe { BUF[HYN_TOUCH_MISC + HYN_TOUCH_STEP * i] } >> 4;
            if (data.touches[i].action == 0 || data.touches[i].action == 2) &&
                   (data.point_num == 0) {
                break ;
            }
        }
        Ok(())
    }
/// Read touch controller data. This only works when the screen has been tapped and the touch controller wakes up.
/// Ported from https://github.com/lupyuen/hynitron_i2c_cst0xxse/blob/master/cst0xx_core.c#L407-L466
Read touch controller data. This only works when the screen has been tapped and the touch controller wakes up.
Read touch controller data . This only works when the screen has been tapped and the touch controller wakes up .
fn read_touchdata(data: &mut TouchEventInfo) -> MynewtResult<()> {
        read_register_range(TOUCH_CONTROLLER_ADDRESS, 0, POINT_READ_BUF as u8,
                            unsafe {
                                &mut BUF
                            }).expect("read touchdata fail");
        *data =
            unsafe {
                ::core::mem::transmute::<[u8; ::core::mem::size_of::<TouchEventInfo>()],
                                         TouchEventInfo>([0;
                                                             ::core::mem::size_of::<TouchEventInfo>()])
            };
        data.point_num = unsafe { BUF[FT_TOUCH_POINT_NUM] & 0x0F };
        data.count = 0;
        for i in 0..CFG_MAX_TOUCH_POINTS {
            let pointid =
                unsafe { BUF[HYN_TOUCH_ID_POS + HYN_TOUCH_STEP * i] } >> 4;
            if pointid >= HYN_MAX_ID { break ; }
            data.count += 1;
            let x_high =
                unsafe { BUF[HYN_TOUCH_X_H_POS + HYN_TOUCH_STEP * i] & 0x0F }
                    as u16;
            let x_low =
                unsafe { BUF[HYN_TOUCH_X_L_POS + HYN_TOUCH_STEP * i] } as u16;
            data.touches[i].x = (x_high << 8) | x_low;
            let y_high =
                unsafe { BUF[HYN_TOUCH_Y_H_POS + HYN_TOUCH_STEP * i] & 0x0F }
                    as u16;
            let y_low =
                unsafe { BUF[HYN_TOUCH_Y_L_POS + HYN_TOUCH_STEP * i] } as u16;
            data.touches[i].y = (y_high << 8) | y_low;
            data.touches[i].action =
                unsafe { BUF[HYN_TOUCH_EVENT_POS + HYN_TOUCH_STEP * i] } >> 6;
            data.touches[i].finger =
                unsafe { BUF[HYN_TOUCH_ID_POS + HYN_TOUCH_STEP * i] } >> 4;
            data.touches[i].pressure =
                unsafe { BUF[HYN_TOUCH_XY_POS + HYN_TOUCH_STEP * i] };
            data.touches[i].area =
                unsafe { BUF[HYN_TOUCH_MISC + HYN_TOUCH_STEP * i] } >> 4;
            if (data.touches[i].action == 0 || data.touches[i].action == 2) &&
                   (data.point_num == 0) {
                break ;
            }
        }
        Ok(())
    }
fn read_touchdata ( data : & mut TouchEventInfo ) -> MynewtResult < ( ) > { read_register_range ( TOUCH_CONTROLLER_ADDRESS , 0 , POINT_READ_BUF as u8 , unsafe { & mut BUF } ) . expect ( " " ) ; * data = unsafe { :: core :: mem :: transmute :: < [ u8 ; :: core :: mem :: size_of :: < TouchEventInfo > ( ) ] , TouchEventInfo > ( [ 0 ; :: core :: mem :: size_of :: < TouchEventInfo > ( ) ] ) } ; data . point_num = unsafe { BUF [ FT_TOUCH_POINT_NUM ] & 0x0F } ; data . count = 0 ; for i in 0 .. CFG_MAX_TOUCH_POINTS { let pointid = unsafe { BUF [ HYN_TOUCH_ID_POS + HYN_TOUCH_STEP * i ] } >> 4 ; if pointid >= HYN_MAX_ID { break ; } data . count += 1 ; let x_high = unsafe { BUF [ HYN_TOUCH_X_H_POS + HYN_TOUCH_STEP * i ] & 0x0F } as u16 ; let x_low = unsafe { BUF [ HYN_TOUCH_X_L_POS + HYN_TOUCH_STEP * i ] } as u16 ; data . touches [ i ] . x = ( x_high << 8 ) | x_low ; let y_high = unsafe { BUF [ HYN_TOUCH_Y_H_POS + HYN_TOUCH_STEP * i ] & 0x0F } as u16 ; let y_low = unsafe { BUF [ HYN_TOUCH_Y_L_POS + HYN_TOUCH_STEP * i ] } as u16 ; data . touches [ i ] . y = ( y_high << 8 ) | y_low ; data . touches [ i ] . action = unsafe { BUF [ HYN_TOUCH_EVENT_POS + HYN_TOUCH_STEP * i ] } >> 6 ; data . touches [ i ] . finger = unsafe { BUF [ HYN_TOUCH_ID_POS + HYN_TOUCH_STEP * i ] } >> 4 ; data . touches [ i ] . pressure = unsafe { BUF [ HYN_TOUCH_XY_POS + HYN_TOUCH_STEP * i ] } ; data . touches [ i ] . area = unsafe { BUF [ HYN_TOUCH_MISC + HYN_TOUCH_STEP * i ] } >> 4 ; if ( data . touches [ i ] . action == 0 || data . touches [ i ] . action == 2 ) && ( data . point_num == 0 ) { break ; } } Ok ( ( ) ) }
Read touch controller data.
Read touch controller data .
data
&mut TouchEventInfo
data
&mut TouchEventInfo