Core Timer Code Development How you could have done the Take- Home Quiz using a test driven...
-
date post
19-Dec-2015 -
Category
Documents
-
view
214 -
download
0
Transcript of Core Timer Code Development How you could have done the Take- Home Quiz using a test driven...
Core Timer Code Development
How you could have done the Take-Home Quiz using a test driven development (TDD) approach
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
2 / 28
To be tackled today
Test driven development example
Customer requirementsPossible system test provided by
customer’s FAE (field application engineer)Development of your unit tests
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
3 / 28
Customer Requirements
Long term goal is that we will be using devices that need to be activated at certain reliable times. Seems like we need a library of timer functions
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
4 / 28
Customer Test – example code
Put system into knownstate
We already have theseLED utilities (Lab. 2)
Here is the sort of thing we need
This sort of test detailmay indicate thatFAE has alreadytried and failed.
Be polite when youdeliver code
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
5 / 28
Define the functions
To be coded in assembly code Convention when dealing with hardware
ulong SetCoreTimer(initial, reload, scale) Initializes the core timer registers, returns old control setting,
places timer in low power mode, stops the clock void StartCoreTimer(void), void StopCoreTimer(void)
Starts and stops the timer. When started the timer is to run continuously.
ulong ReadCoreTimer(void) Returns current value from the timer
bool CheckIfCoreTimerExpired(void) Determines whether or not the core timer registers have been
reloaded
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
6 / 28
Step 1A – Get a main( ) and a test to compile and link – Design the test
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
7 / 28
Step 1B – Get a main( ) and a test to compile and link – Design main
Bring a copy of your Take-Home Quiz code to compare
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
8 / 28
Recode till pasts the test
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
9 / 28
Step2A – Write the test for void StopCoreTimer(void);
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
10 / 28
Step 2B – Write and Test void StopCoreTimerASM(void);
Bring a copy of your Take-Home Quiz code to compare
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
11 / 28
Step 2C – Fix the test
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
12 / 28
3A – Write a test -- unsigned long int ReadCoreTimer( )
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
13 / 28
3B – Write the code to pass the test
Bring a copy of your Take-Home Quiz code to compare
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
14 / 28
4 Write the Test for void StartCoreTimerASM(void)
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
15 / 28
4 – Write the code to satisfy the test
Bring a copy of your Take-Home Quiz code to compare
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
16 / 28
Test failed because
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
17 / 28
4 Rewrite the test – prefer new -- unsigned long int StartCoreTimer(void)
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
18 / 28
4 -- Need to add unsigned long int SetCoreTimer(ulong, ulong, ulong)
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
19 / 28
Needed code – run the tests
Bring a copy of your Take-Home Quiz code to compare
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
20 / 28
New tests pass – old tests now fail
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
21 / 28
Fix StopCoreTimer( )
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
22 / 28
Re-examine ReadCoreTimerASM
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
23 / 28
4 – Re-examine Test
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
24 / 28
Final Test
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
25 / 28
Customer Test
Put system into knownstate
We already have theseLED utilities (Lab. 2)
Here is the sort of thing we need
This sort of test detailmay indicate thatFAE has alreadytried and failed.
Be polite when youdeliver code
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
26 / 28
Oops -- Still missing code forbool CheckIfCoreTimerExpiredASM( )
First – write the test
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
27 / 28
Oops - Still missing code forbool CheckIfCoreTimerExpiredASM( )
Now write the code
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
28 / 28
Tackled today
Test driven development example
Customer requirements Possible system test provided by customer’s FAE
(field application engineer)
Development of your unit tests
You still need to design the test and the code for bool CheckIfCoreTimerExpiredASM(void);
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
29 / 28
Information taken from Analog Devices On-line Manuals with permission http://www.analog.com/processors/resources/technicalLibrary/manuals/
Information furnished by Analog Devices is believed to be accurate and reliable. However, Analog Devices assumes no responsibility for its use or for any infringement of any patent other rights of any third party which may result from its use. No license is granted by implication or otherwise under any patent or patent right of Analog Devices. Copyright Analog Devices, Inc. All rights reserved.