#include "Cyton_SysApi.h"
#include "usart.h"	
#include <string.h>
#include "delay.h"       
#include "led.h"       
#include "key.h"
#include "Timer.h"
#include "ADS129x.h"

#include "myQueue.h"


static CYTON_SYS_API_TIMER_CB g_pfCollectorTimerCB = NULL;
static int g_iSysApi_collectorTIndex = 0;


void CytonSys_CollectorTimerStart(int iHz, CYTON_SYS_API_TIMER_CB pfCB)
{
    int iArr = 0;
    g_pfCollectorTimerCB = pfCB;

    /* 10000 1s CB.*/
    iArr = 10000 / iHz;

    /* 7200 0000 */
    TIM1_Init(iArr, 7200);
    TIM1_Start();
}

void CytonSys_Stop()
{
    TIM1_Stop();
}

void CytonSys_CollectorCB()
{
    g_iSysApi_collectorTIndex ++;
    if (g_pfCollectorTimerCB) {
        (*g_pfCollectorTimerCB)(g_iSysApi_collectorTIndex);
    }
}