Bruno Allaire-Lemay
/
APP1test
df
Fork of APP1 by
TestHomemadeMbed.cpp@15:b38d9d210e32, 2017-01-17 (annotated)
- Committer:
- dupm2216
- Date:
- Tue Jan 17 00:06:38 2017 +0000
- Revision:
- 15:b38d9d210e32
- Parent:
- 14:2f89279586cb
- Child:
- 21:a111be2582be
Fini?
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GaiSensei | 13:bb9669053eb3 | 1 | #include "TestHomemadeMbed.hpp" |
GaiSensei | 13:bb9669053eb3 | 2 | #include "Utility.hpp" |
GaiSensei | 13:bb9669053eb3 | 3 | #include "HomemadeMbed.hpp" |
GaiSensei | 13:bb9669053eb3 | 4 | |
GaiSensei | 13:bb9669053eb3 | 5 | #include <cassert> |
GaiSensei | 13:bb9669053eb3 | 6 | #include <cstdio> |
GaiSensei | 13:bb9669053eb3 | 7 | |
GaiSensei | 13:bb9669053eb3 | 8 | namespace homemade_mbed |
GaiSensei | 13:bb9669053eb3 | 9 | { |
GaiSensei | 13:bb9669053eb3 | 10 | void run_all_tests() |
GaiSensei | 13:bb9669053eb3 | 11 | { |
GaiSensei | 13:bb9669053eb3 | 12 | test_read_bits(); |
GaiSensei | 13:bb9669053eb3 | 13 | test_write_bits(); |
dupm2216 | 15:b38d9d210e32 | 14 | test_get_reserved_bits_mask(); |
GaiSensei | 13:bb9669053eb3 | 15 | } |
GaiSensei | 13:bb9669053eb3 | 16 | |
GaiSensei | 13:bb9669053eb3 | 17 | void test_read_bits() |
GaiSensei | 13:bb9669053eb3 | 18 | { |
GaiSensei | 13:bb9669053eb3 | 19 | //CLKOUTCFG - 0x400F C1C8 |
GaiSensei | 13:bb9669053eb3 | 20 | //Bits 0-9 all have a reset value of 0 |
GaiSensei | 14:2f89279586cb | 21 | assert(0x00 == read_bits(reinterpret_cast<unsigned int*>(0x400FC1C8), 0, 9)); |
GaiSensei | 13:bb9669053eb3 | 22 | |
GaiSensei | 13:bb9669053eb3 | 23 | //PCONP - address 0x400F C0C4 |
GaiSensei | 13:bb9669053eb3 | 24 | //Bits 1,2,3,4 all have a reset value of 1 |
GaiSensei | 14:2f89279586cb | 25 | assert(0x0F == read_bits(reinterpret_cast<unsigned int*>(0x400FC0C4), 1, 4)); |
GaiSensei | 13:bb9669053eb3 | 26 | } |
GaiSensei | 13:bb9669053eb3 | 27 | |
GaiSensei | 13:bb9669053eb3 | 28 | void test_write_bits() |
GaiSensei | 13:bb9669053eb3 | 29 | { |
GaiSensei | 13:bb9669053eb3 | 30 | //CLKOUTCFG - 0x400F C1C8 |
GaiSensei | 13:bb9669053eb3 | 31 | //Bits 0-9 all have a reset value of 0 |
GaiSensei | 14:2f89279586cb | 32 | assert(0x00 == read_bits(reinterpret_cast<unsigned int*>(0x400FC1C8), 0, 9)); |
GaiSensei | 13:bb9669053eb3 | 33 | |
GaiSensei | 14:2f89279586cb | 34 | write_bits(reinterpret_cast<unsigned int*>(0x400FC1C8), 4, 7, 0x0F); |
GaiSensei | 13:bb9669053eb3 | 35 | |
GaiSensei | 14:2f89279586cb | 36 | assert(0x0F == read_bits(reinterpret_cast<unsigned int*>(0x400FC1C8), 4, 7)); |
GaiSensei | 14:2f89279586cb | 37 | write_bits(reinterpret_cast<unsigned int*>(0x400FC1C8), 4, 7, 0x00); |
GaiSensei | 13:bb9669053eb3 | 38 | } |
dupm2216 | 15:b38d9d210e32 | 39 | |
dupm2216 | 15:b38d9d210e32 | 40 | void test_get_reserved_bits_mask() |
dupm2216 | 15:b38d9d210e32 | 41 | { |
dupm2216 | 15:b38d9d210e32 | 42 | assert(0x000003FF == get_reserved_bits_mask(reinterpret_cast<unsigned int*>(0x400FC1C8))); |
dupm2216 | 15:b38d9d210e32 | 43 | } |
GaiSensei | 13:bb9669053eb3 | 44 | } |