Bruno Allaire-Lemay
/
APP1test
df
Fork of APP1 by
Diff: HomemadeMbed.cpp
- Revision:
- 14:2f89279586cb
- Parent:
- 13:bb9669053eb3
- Child:
- 15:b38d9d210e32
diff -r bb9669053eb3 -r 2f89279586cb HomemadeMbed.cpp --- a/HomemadeMbed.cpp Mon Jan 16 00:06:45 2017 +0000 +++ b/HomemadeMbed.cpp Mon Jan 16 02:28:40 2017 +0000 @@ -1,9 +1,10 @@ #include "HomemadeMbed.hpp" #include "Utility.hpp" +#include <cstdio> namespace homemade_mbed { - unsigned int read_bits(int* address_4_bytes, const int start_bit, const int stop_bit) + 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); @@ -11,8 +12,10 @@ return right_shifted; } - void write_bits(int* address_4_bytes, const int start_bit, const int stop_bit, const unsigned int new_value) + 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;