If you haven’t guessed by now, there are always a bunch of ways to do the same thing it’s just a matter of finding the method that suits you best. This post is about accessing the GPIO pins on the Raspberry Pi using the sysfs interface through standard c. The sysfs interface is the simplest method of accessing GPIO on almost any embedded linux board.
Sysfs is a filesystem, so you treat it like one. You open these special files and you read and write to them. In this case you open a branch in the gpio subsection, write the pin you want to export to the ‘export’ file. A new file appears. Open that file, write the direction and the state and presto.
Read the post here. Source code included, it doesn’t do anything fancy but blinking an led but you should be able to bit-bang almost any protocol from there.