There's a couple of registers which need to be set: https://wiki.osdev.org/ATA_PIO_Mode and you can then just read/write the data from the parallel lines.
Here's a similar project using an ATmega32: https://github.com/zwostein/idetrol (i used this code, ported to ARM to check my hardware before I wrote the kerneldriver)