Rewritten to match HW operations. And now it works.
Fixed incorrect indata reference.