CC1310 RTC

The RTC is used by TI-RTOS as the time base for the ti.sysbios.Clock module. It continues to run even when the processor is in standby mode and will wake the processor whenever a Clock object times out.

Clock objects are used to implement the timeouts for BIOS APIs such as Task_sleep(), Semaphore_pend(), Event_pend(), etc. They are also used internally by various TI-RTOS driver functions when a timeout is required.

The RTC is also used as the timebase for the ti.sysbios.hal.Seconds module which can be used to provide time-of-day information to your application.

/*
 *  ======== clock.c ========
 */

/* XDC module Headers */
#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* BIOS module Headers */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>

/* Example/Board Header files */
#include "Board.h"

Void clk0Fxn(UArg arg0);
Void clk1Fxn(UArg arg0);

Clock_Struct clk0Struct, clk1Struct;
Clock_Handle clk2Handle;

/*
 *  ======== main ========
 */
Int main()
{
    /* Construct BIOS Objects */
    Clock_Params clkParams;

    /* Call driver init functions */
    Board_initGeneral();

    Clock_Params_init(&clkParams);
    clkParams.period = 5000/Clock_tickPeriod;
    clkParams.startFlag = TRUE;

    /* Construct a periodic Clock Instance */
    Clock_construct(&clk0Struct, (Clock_FuncPtr)clk0Fxn,
                    5000/Clock_tickPeriod, &clkParams);

    clkParams.period = 0;
    clkParams.startFlag = FALSE;

    /* Construct a one-shot Clock Instance */
    Clock_construct(&clk1Struct, (Clock_FuncPtr)clk1Fxn,
                    11000/Clock_tickPeriod, &clkParams);

    clk2Handle = Clock_handle(&clk1Struct);

    Clock_start(clk2Handle);

    BIOS_start();    /* does not return */
    return(0);
}

/*
 *  ======== clk0Fxn =======
 */
Void clk0Fxn(UArg arg0)
{
    UInt32 time;

    time = Clock_getTicks();
    System_printf("System time in clk0Fxn = %lu\n", (ULong)time);
}

/*
 *  ======== clk1Fxn =======
 */
Void clk1Fxn(UArg arg0)
{
    UInt32 time;

    time = Clock_getTicks();
    System_printf("System time in clk1Fxn = %lu\n", (ULong)time);
    System_printf("Calling BIOS_exit() from clk1Fxn\n");
    BIOS_exit(0);
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值