 
     // turn around time
     SWDReadBit();         // trn
-    
+
+    bool parity = calcParity32(data);
     for(uint8_t i=0; i<32; i++)
     { 
-      if (data >= 0x80000000)
+      if ((data & 1) != 0)
         SWDWriteBit(true);
       else
         SWDWriteBit(false);
-      data <<= 1;
+      data >>= 1;
     }
 
-    // TODO: generate correct parity
-    SWDWriteBit(false);
-
-    SWDIdle();    
+    SWDWriteBit(parity);
+
+    // turn-around    
+    SWDReadBit();    
   }
   else
   {

    SWDWriteBit(false);
  }
}

uint32_t SWDTransaction(bool APnDP, bool RnW, uint8_t A23, uint32_t data)
{

    result = 0;
    for(uint8_t i=0; i<32; i++)
    {
      result >>= 1;
      if (SWDReadBit())
        result |= 0x80000000;
    }

    bool parity = SWDReadBit();

    // turn-around    
    SWDReadBit();
    
    //TODO: get SWD code
    //      and check parity.. 
