Lock counter

These should probably go in src/peripherals/random.c, if there isn't already an implementation in the libopencm3 source.