Bruno Allaire-Lemay
/
APP1test
df
Fork of APP1 by
TestHomemadeMbed.cpp@13:bb9669053eb3, 2017-01-16 (annotated)
- Committer:
- GaiSensei
- Date:
- Mon Jan 16 00:06:45 2017 +0000
- Revision:
- 13:bb9669053eb3
- Child:
- 14:2f89279586cb
Create homemade_mbed functions; ; - Read bits; - Write bits; ; Sorry messy commit
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(); |
GaiSensei | 13:bb9669053eb3 | 14 | } |
GaiSensei | 13:bb9669053eb3 | 15 | |
GaiSensei | 13:bb9669053eb3 | 16 | void test_read_bits() |
GaiSensei | 13:bb9669053eb3 | 17 | { |
GaiSensei | 13:bb9669053eb3 | 18 | //CLKOUTCFG - 0x400F C1C8 |
GaiSensei | 13:bb9669053eb3 | 19 | //Bits 0-9 all have a reset value of 0 |
GaiSensei | 13:bb9669053eb3 | 20 | assert(0x00 == read_bits(reinterpret_cast<int*>(0x400FC1C8), 0, 9)); |
GaiSensei | 13:bb9669053eb3 | 21 | |
GaiSensei | 13:bb9669053eb3 | 22 | //PCONP - address 0x400F C0C4 |
GaiSensei | 13:bb9669053eb3 | 23 | //Bits 1,2,3,4 all have a reset value of 1 |
GaiSensei | 13:bb9669053eb3 | 24 | assert(0x0F == read_bits(reinterpret_cast<int*>(0x400FC0C4), 1, 4)); |
GaiSensei | 13:bb9669053eb3 | 25 | } |
GaiSensei | 13:bb9669053eb3 | 26 | |
GaiSensei | 13:bb9669053eb3 | 27 | void test_write_bits() |
GaiSensei | 13:bb9669053eb3 | 28 | { |
GaiSensei | 13:bb9669053eb3 | 29 | //CLKOUTCFG - 0x400F C1C8 |
GaiSensei | 13:bb9669053eb3 | 30 | //Bits 0-9 all have a reset value of 0 |
GaiSensei | 13:bb9669053eb3 | 31 | assert(0x00 == read_bits(reinterpret_cast<int*>(0x400FC1C8), 0, 9)); |
GaiSensei | 13:bb9669053eb3 | 32 | |
GaiSensei | 13:bb9669053eb3 | 33 | write_bits(reinterpret_cast<int*>(0x400FC1C8), 4, 7, 0x0F); |
GaiSensei | 13:bb9669053eb3 | 34 | |
GaiSensei | 13:bb9669053eb3 | 35 | assert(0x0F == read_bits(reinterpret_cast<int*>(0x400FC1C8), 4, 7)); |
GaiSensei | 13:bb9669053eb3 | 36 | write_bits(reinterpret_cast<int*>(0x400FC1C8), 4, 7, 0x00); |
GaiSensei | 13:bb9669053eb3 | 37 | } |
GaiSensei | 13:bb9669053eb3 | 38 | } |