![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
df
Fork of APP1 by
HomemadeMbed.cpp
- Committer:
- GaiSensei
- Date:
- 2017-01-16
- Revision:
- 14:2f89279586cb
- Parent:
- 13:bb9669053eb3
- Child:
- 15:b38d9d210e32
File content as of revision 14:2f89279586cb:
#include "HomemadeMbed.hpp" #include "Utility.hpp" #include <cstdio> namespace homemade_mbed { unsigned int read_bits(unsigned int* address_4_bytes, const int start_bit, const int stop_bit) { const unsigned int all_4_bytes = *address_4_bytes; const unsigned int left_shifted = all_4_bytes << (31 - stop_bit); const unsigned int right_shifted = left_shifted >> (31 - stop_bit + start_bit); return right_shifted; } void write_bits(unsigned int* address_4_bytes, const int start_bit, const int stop_bit, const unsigned int new_value) { //std::printf("write_bits()\r\n"); const unsigned int all_4_bytes = *address_4_bytes; const unsigned int new_bits = utility::update_bits(all_4_bytes, start_bit, stop_bit, new_value); *address_4_bytes = new_bits; } }