Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface mbed-rtos
Timer1ExecutionContext.cpp@7:6c7af1d50fb3, 2013-08-29 (annotated)
- Committer:
- ysuga
- Date:
- Thu Aug 29 05:29:55 2013 +0000
- Revision:
- 7:6c7af1d50fb3
- Parent:
- 0:5f7bc45bc2e8
update v5
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| ysuga | 0:5f7bc45bc2e8 | 1 | #define RTNO_SUBMODULE_DEFINE | 
| ysuga | 0:5f7bc45bc2e8 | 2 | |
| ysuga | 0:5f7bc45bc2e8 | 3 | #include <stdint.h> | 
| ysuga | 0:5f7bc45bc2e8 | 4 | #include "RTno.h" | 
| ysuga | 0:5f7bc45bc2e8 | 5 | #include "Packet.h" | 
| ysuga | 0:5f7bc45bc2e8 | 6 | #include "Timer1ExecutionContext.h" | 
| ysuga | 0:5f7bc45bc2e8 | 7 | //#include <avr/io.h> | 
| ysuga | 0:5f7bc45bc2e8 | 8 | //#include <avr/interrupt.h> | 
| ysuga | 0:5f7bc45bc2e8 | 9 | |
| ysuga | 0:5f7bc45bc2e8 | 10 | static float m_Period; | 
| ysuga | 0:5f7bc45bc2e8 | 11 | //static uint8_t m_ClockSetting; | 
| ysuga | 0:5f7bc45bc2e8 | 12 | |
| ysuga | 0:5f7bc45bc2e8 | 13 | Ticker *m_pTimer; | 
| ysuga | 0:5f7bc45bc2e8 | 14 | |
| ysuga | 0:5f7bc45bc2e8 | 15 | void Timer1EC_start(); | 
| ysuga | 0:5f7bc45bc2e8 | 16 | void Timer1EC_suspend(); | 
| ysuga | 0:5f7bc45bc2e8 | 17 | void Timer1EC_resume(); | 
| ysuga | 0:5f7bc45bc2e8 | 18 | |
| ysuga | 0:5f7bc45bc2e8 | 19 | void tick () { | 
| ysuga | 0:5f7bc45bc2e8 | 20 | EC_execute(); | 
| ysuga | 0:5f7bc45bc2e8 | 21 | } | 
| ysuga | 0:5f7bc45bc2e8 | 22 | |
| ysuga | 0:5f7bc45bc2e8 | 23 | |
| ysuga | 0:5f7bc45bc2e8 | 24 | void Timer1EC_init(double rate) | 
| ysuga | 0:5f7bc45bc2e8 | 25 | { | 
| ysuga | 0:5f7bc45bc2e8 | 26 | EC_init(0x22); | 
| ysuga | 0:5f7bc45bc2e8 | 27 | m_pTimer = new Ticker(); | 
| ysuga | 0:5f7bc45bc2e8 | 28 | // Initialize Period | 
| ysuga | 0:5f7bc45bc2e8 | 29 | m_Period = (1.0 / rate); | 
| ysuga | 0:5f7bc45bc2e8 | 30 | EC_start = Timer1EC_start; | 
| ysuga | 0:5f7bc45bc2e8 | 31 | EC_suspend = Timer1EC_suspend; | 
| ysuga | 0:5f7bc45bc2e8 | 32 | EC_resume = Timer1EC_resume; | 
| ysuga | 0:5f7bc45bc2e8 | 33 | } | 
| ysuga | 0:5f7bc45bc2e8 | 34 | |
| ysuga | 0:5f7bc45bc2e8 | 35 | void Timer1EC_start() | 
| ysuga | 0:5f7bc45bc2e8 | 36 | { | 
| ysuga | 0:5f7bc45bc2e8 | 37 | m_pTimer->attach(tick, m_Period); | 
| ysuga | 0:5f7bc45bc2e8 | 38 | } | 
| ysuga | 0:5f7bc45bc2e8 | 39 | |
| ysuga | 0:5f7bc45bc2e8 | 40 | void Timer1EC_suspend() | 
| ysuga | 0:5f7bc45bc2e8 | 41 | { | 
| ysuga | 0:5f7bc45bc2e8 | 42 | m_pTimer->detach(); | 
| ysuga | 0:5f7bc45bc2e8 | 43 | } | 
| ysuga | 0:5f7bc45bc2e8 | 44 | |
| ysuga | 0:5f7bc45bc2e8 | 45 | void Timer1EC_resume() | 
| ysuga | 0:5f7bc45bc2e8 | 46 | { | 
| ysuga | 0:5f7bc45bc2e8 | 47 | Timer1EC_start(); | 
| ysuga | 0:5f7bc45bc2e8 | 48 | } | 
| ysuga | 0:5f7bc45bc2e8 | 49 | |
| ysuga | 0:5f7bc45bc2e8 | 50 |