refactored for state flags
Merge branch 'master' of github.com:krase/chibios_posix