Added initial statemachine and hardware near code.

This is mainly copied from the course "datastyring".