CC1310 Timer

来源:互联网 发布:淘宝卖家在哪里发微淘 编辑:程序博客网 时间:2024/06/08 12:21
// Convenience macro to make the code more readable// Set Clock.tickPeriod in the .cfg file#define Clock_convertSecondsToTicks(seconds) \    (((seconds) * 1000000) / (Clock_tickPeriod))// Solution 1// ----------// Reserve memory for the clock objectClock_Struct clock;uint32_t timeoutTicks = Clock_convertSecondsToTicks(30);// Create a one-shot timerClock_construct(&clock, &Serial_TimerCallback, timeoutTicks, NULL);// Start the timerClock_start(Clock_handle(&clock));// Solution 2// ----------uint32_t timeoutTicks = Clock_convertSecondsToTicks(30);// Create a one-shot timer somewhere on the heapClock_Handle clock = Clock_create(&Serial_TimerCallback, timeoutTicks, NULL, NULL);// Start the timerClock_start(clock);// Solution 3// ----------// Create a static clock object in the .cfg file// The init code is automatically generated by xdctoolsvar clock0Params = new Clock.Params();clock0Params.instance.name = "clock";Program.global.clock = Clock.create("&Serial_TimerCallback", 30, clock0Params);// Start the clock somewhere in your programextern const Clock_Handle clock;Clock_start(clock);

原创粉丝点击