df

Dependencies:   mbed

Fork of APP1 by Team APP

Committer:
GaiSensei
Date:
Thu Feb 09 15:55:18 2017 +0000
Revision:
23:2531e72d92b9
Parent:
21:a111be2582be
gh

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dupm2216 21:a111be2582be 1 /////////////////////////////////////////////////////////////
dupm2216 21:a111be2582be 2 // APP 1: Systèmes à microprocesseurs //
dupm2216 21:a111be2582be 3 // //
dupm2216 21:a111be2582be 4 // Université de Sherbrooke //
dupm2216 21:a111be2582be 5 // Génie informatique //
dupm2216 21:a111be2582be 6 // Session 5, Hiver 2017 //
dupm2216 21:a111be2582be 7 // //
dupm2216 21:a111be2582be 8 // Date: 17 janvier 2017 //
dupm2216 21:a111be2582be 9 // //
dupm2216 21:a111be2582be 10 // Auteurs: Maxime Dupuis, dupm2216 //
dupm2216 21:a111be2582be 11 // Bruno Allaire-Lemay, allb2701 //
dupm2216 21:a111be2582be 12 /////////////////////////////////////////////////////////////
dupm2216 21:a111be2582be 13
GaiSensei 13:bb9669053eb3 14 #include "TestHomemadeMbed.hpp"
GaiSensei 13:bb9669053eb3 15 #include "Utility.hpp"
GaiSensei 13:bb9669053eb3 16 #include "HomemadeMbed.hpp"
GaiSensei 13:bb9669053eb3 17
GaiSensei 13:bb9669053eb3 18 #include <cassert>
GaiSensei 13:bb9669053eb3 19 #include <cstdio>
GaiSensei 13:bb9669053eb3 20
GaiSensei 13:bb9669053eb3 21 namespace homemade_mbed
GaiSensei 13:bb9669053eb3 22 {
GaiSensei 13:bb9669053eb3 23 void run_all_tests()
GaiSensei 13:bb9669053eb3 24 {
GaiSensei 13:bb9669053eb3 25 test_read_bits();
GaiSensei 13:bb9669053eb3 26 test_write_bits();
dupm2216 15:b38d9d210e32 27 test_get_reserved_bits_mask();
GaiSensei 13:bb9669053eb3 28 }
GaiSensei 13:bb9669053eb3 29
GaiSensei 13:bb9669053eb3 30 void test_read_bits()
GaiSensei 13:bb9669053eb3 31 {
GaiSensei 13:bb9669053eb3 32 //CLKOUTCFG - 0x400F C1C8
GaiSensei 13:bb9669053eb3 33 //Bits 0-9 all have a reset value of 0
GaiSensei 14:2f89279586cb 34 assert(0x00 == read_bits(reinterpret_cast<unsigned int*>(0x400FC1C8), 0, 9));
GaiSensei 13:bb9669053eb3 35
GaiSensei 13:bb9669053eb3 36 //PCONP - address 0x400F C0C4
GaiSensei 13:bb9669053eb3 37 //Bits 1,2,3,4 all have a reset value of 1
GaiSensei 14:2f89279586cb 38 assert(0x0F == read_bits(reinterpret_cast<unsigned int*>(0x400FC0C4), 1, 4));
GaiSensei 13:bb9669053eb3 39 }
GaiSensei 13:bb9669053eb3 40
GaiSensei 13:bb9669053eb3 41 void test_write_bits()
GaiSensei 13:bb9669053eb3 42 {
GaiSensei 13:bb9669053eb3 43 //CLKOUTCFG - 0x400F C1C8
GaiSensei 13:bb9669053eb3 44 //Bits 0-9 all have a reset value of 0
GaiSensei 14:2f89279586cb 45 assert(0x00 == read_bits(reinterpret_cast<unsigned int*>(0x400FC1C8), 0, 9));
GaiSensei 13:bb9669053eb3 46
GaiSensei 14:2f89279586cb 47 write_bits(reinterpret_cast<unsigned int*>(0x400FC1C8), 4, 7, 0x0F);
GaiSensei 13:bb9669053eb3 48
GaiSensei 14:2f89279586cb 49 assert(0x0F == read_bits(reinterpret_cast<unsigned int*>(0x400FC1C8), 4, 7));
GaiSensei 14:2f89279586cb 50 write_bits(reinterpret_cast<unsigned int*>(0x400FC1C8), 4, 7, 0x00);
GaiSensei 13:bb9669053eb3 51 }
dupm2216 15:b38d9d210e32 52
dupm2216 15:b38d9d210e32 53 void test_get_reserved_bits_mask()
dupm2216 15:b38d9d210e32 54 {
dupm2216 15:b38d9d210e32 55 assert(0x000003FF == get_reserved_bits_mask(reinterpret_cast<unsigned int*>(0x400FC1C8)));
dupm2216 15:b38d9d210e32 56 }
GaiSensei 13:bb9669053eb3 57 }