Presentation is loading. Please wait.

Presentation is loading. Please wait.

Core Timer Code Development How you could have done the Take- Home Quiz using a test driven development (TDD) approach.

Similar presentations


Presentation on theme: "Core Timer Code Development How you could have done the Take- Home Quiz using a test driven development (TDD) approach."— Presentation transcript:

1 Core Timer Code Development How you could have done the Take- Home Quiz using a test driven development (TDD) approach

2 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada2 / 28 To be tackled today Test driven development example Customer requirements Possible system test provided by customer’s FAE (field application engineer) Development of your unit tests

3 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada3 / 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

4 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada4 / 28 Customer Test – example code Put system into known state We already have these LED utilities (Lab. 2) Here is the sort of thing we need This sort of test detail may indicate that FAE has already tried and failed. Be polite when you deliver code

5 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada5 / 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

6 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada6 / 28 Step 1A – Get a main( ) and a test to compile and link – Design the test

7 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada7 / 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

8 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada8 / 28 Recode till pasts the test

9 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada9 / 28 Step2A – Write the test for void StopCoreTimer(void);

10 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada10 / 28 Step 2B – Write and Test void StopCoreTimerASM(void); Bring a copy of your Take-Home Quiz code to compare

11 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada11 / 28 Step 2C – Fix the test

12 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada12 / 28 3A – Write a test -- unsigned long int ReadCoreTimer( )

13 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada13 / 28 3B – Write the code to pass the test Bring a copy of your Take-Home Quiz code to compare

14 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada14 / 28 4 Write the Test for void StartCoreTimerASM(void)

15 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada15 / 28 4 – Write the code to satisfy the test Bring a copy of your Take-Home Quiz code to compare

16 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada16 / 28 Test failed because

17 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada17 / 28 4 Rewrite the test – prefer new -- unsigned long int StartCoreTimer(void)

18 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada18 / 28 4 -- Need to add unsigned long int SetCoreTimer(ulong, ulong, ulong)

19 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada19 / 28 Needed code – run the tests Bring a copy of your Take-Home Quiz code to compare

20 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada20 / 28 New tests pass – old tests now fail

21 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada21 / 28 Fix StopCoreTimer( )

22 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada22 / 28 Re-examine ReadCoreTimerASM

23 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada23 / 28 4 – Re-examine Test

24 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada24 / 28 Final Test

25 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada25 / 28 Customer Test Put system into known state We already have these LED utilities (Lab. 2) Here is the sort of thing we need This sort of test detail may indicate that FAE has already tried and failed. Be polite when you deliver code

26 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada26 / 28 Oops -- Still missing code for bool CheckIfCoreTimerExpiredASM( ) First – write the test

27 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada27 / 28 Oops - Still missing code for bool CheckIfCoreTimerExpiredASM( ) Now write the code

28 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada28 / 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);

29 6/3/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada29 / 28 Information taken from Analog Devices On-line Manuals with permission http://www.analog.com/processors/resources/technicalLibrary/manuals/ 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.


Download ppt "Core Timer Code Development How you could have done the Take- Home Quiz using a test driven development (TDD) approach."

Similar presentations


Ads by Google