Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Initialization from python (using py-uio):
- // pruss.ecap.pwm.initialize( PERIOD ) where PERIOD (in PRU cycles) is max 2**32
- struct Timestamp {
- uint32_t major; // number of times the ecap counter has wrapped
- uint32_t minor; // number of cycles since last time it wrapped
- };
- // note: total number of cycles (since ecap initialized) is major * PERIOD + minor
- // Get timestamp.
- // Must be called at least once every PERIOD cycles to ensure correct timekeeping.
- struct Timestamp timestamp()
- {
- static struct Timestamp now = { 0, 0 };
- uint32_t minor = CT_ECAP.TSCTR;
- if( minor < now.minor ) // ecap counter has wrapped
- ++now.major;
- now.minor = minor;
- return now;
- }
Add Comment
Please, Sign In to add comment