moving perihperals code into individual libs. starting to implement algorithms described in previous commit