Functions
GPT Functions
GPT

Functions

CSL_Handle GPT_open (CSL_Instance instance, CSL_GptObj *gptObj, CSL_Status *status)
CSL_Status GPT_reset (CSL_Handle hGpt)
CSL_Status GPT_close (CSL_Handle hGpt)
CSL_Status GPT_start (CSL_Handle hGpt)
CSL_Status GPT_stop (CSL_Handle hGpt)
CSL_Status GPT_getCnt (CSL_Handle hGpt, Uint32 *timeCnt)
CSL_Status GPT_config (CSL_Handle hGpt, CSL_Config *hwConfig)

Function Documentation

CSL_Status GPT_close ( CSL_Handle  hGpt)

===========================================================================
GPT_close

Description
This function close GPT operation.

Arguments

            hGpt            Handle to the GPT
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
GPT_open() must be called before this function call.

Post Condition
After calling this function no other function can call.

Modifies
None

Example

            CSL_status           status;
            CSL_Handle 			 hGpt;
            ...

           hgpt = GPT_open(GPT_0, &gptObj, &status);
           status = GPT_close(hgpt);
     

===========================================================================

References GPT_0, GPT_1, GPT_2, CSL_GptObj::Instance, and CSL_GptObj::regs.

CSL_Status GPT_config ( CSL_Handle  hGpt,
CSL_Config hwConfig 
)

===========================================================================
GPT_config

Description
This function is to Configure the GPT haware related registers

Arguments

            hGpt            Handle to the GPT
			hwConfig        configuration structure.
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
GPT_open() must be called before this function call.

Post Condition
After calling this function GPT_reset() API should call to close gpt operation.

Modifies
This function modifies the GPT object structure.

Example

            CSL_status           status;
            CSL_Handle 			 hGpt;
             CSL_Config          hwConfig;
            ...
			hwConfig.autoLoad 		= GPT_AUTO_ENABLE;
	        hwConfig.ctrlTim 		= GPT_TIMER_ENABLE;
	        hwConfig.preScaleDiv 	= GPT_PRE_SC_DIV_3;
	        hwConfig.prdLow 		= 0xFFFF;
	        hwConfig.prdHigh 		= 0x0000;

           hgpt = GPT_open(GPT_0, &gptObj, &status);
		   status = GPT_config(hgpt, &hwConfig);
     

===========================================================================

References CSL_Config::autoLoad, CSL_Config::ctrlTim, CSL_Config::prdHigh, CSL_Config::prdLow, CSL_Config::preScaleDiv, and CSL_GptObj::regs.

CSL_Status GPT_getCnt ( CSL_Handle  hGpt,
Uint32 *  timeCnt 
)

===========================================================================
GPT_getCnt

Description
This function is to get condown value from countdown register

Arguments

            hGpt            Handle to the GPT
			timeCnt         Pointer to the countdown value
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
GPT_start() must be called before this function call.

Post Condition
After calling this function GPT_close() API should call to close gpt operation.

Modifies
None

Example

            CSL_status           status;
            CSL_Handle 			 hGpt;
            Uint32               timeCnt;
            ...

           status = GPT_start(hgpt);
		   status = GPT_getCnt(hgpt, &timeCnt);
     

===========================================================================

References CSL_GptObj::regs.

CSL_Handle GPT_open ( CSL_Instance  instance,
CSL_GptObj gptObj,
CSL_Status *  status 
)

===========================================================================
GPT_open

Description
This is the initialization function for the GPT CSL. The function must be called before calling any other API from this CSL. This function is idem-potent. Currently, the function just returns handler to application.

Arguments

     

Return Value CSL_Status

  • CSL_SOK - Always returns

CSL_Handle Pointer to the object structure. Pre Condition
This should be call first before calling any other GPT Function.

Post Condition
The status is updated in the status variable. If status returned is

  • CSL_SOK - Valid GPT handle is returned
  • CSL_ESYS_INVPARAMS - Invalid parameter

Modifies
1. The status variable
2. The object structure handler.

Example

            CSL_Handle		hgpt;
            CSL_Instance	instance;
			CSL_GptObj		gptObj;
		  	CSL_Status 		status;
			....
			....
			instance = GPT_0.

            hgpt = GPT_open(GPT_0, &gptObj, &status);
     

===========================================================================

References GPT_0, GPT_1, GPT_2, GPT_INVALID, CSL_GptObj::Instance, and CSL_GptObj::regs.

CSL_Status GPT_reset ( CSL_Handle  hGpt)

===========================================================================
GPT_reset

Description
This function reset specific register to GPT.

Arguments

            hGpt            Handle to the GPT
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
GPT_open() must be called before this function call.

Post Condition
After calling this function GPT_close() API should call to close gpt operation.

Modifies
1. The object structure handler.

Example

            CSL_status           status;
            CSL_Handle 			 hGpt;
            ...

           hgpt = GPT_open(GPT_0, &gptObj, &status);
           status = GPT_reset(hgpt);
     

===========================================================================

References CSL_IAFR_REGS, CSL_IAFR_TIMER_FLAG_0_RESETVAL, CSL_IAFR_TIMER_FLAG_1_RESETVAL, CSL_IAFR_TIMER_FLAG_2_RESETVAL, GPT_0, GPT_1, GPT_2, CSL_GptObj::Instance, and CSL_GptObj::regs.

CSL_Status GPT_start ( CSL_Handle  hGpt)

===========================================================================
GPT_start

Description
This function start to load value from period register to count down register.

Arguments

            hGpt            Handle to the GPT
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
GPT_config() must be called before this function call.

Post Condition
After calling this function GPT_stop() function can call to stop loading from period register to countdown register.

Modifies
None

Example

            CSL_status           status;
            CSL_Handle 			 hGpt;
            ...

           hgpt = GPT_config(hGpt, &hwConfig);
           status = GPT_start(hgpt);
     

===========================================================================

References CSL_GptObj::regs.

CSL_Status GPT_stop ( CSL_Handle  hGpt)

===========================================================================
GPT_stop

Description
This function stop to load value from period register to count down register.

Arguments

            hGpt            Handle to the GPT
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
GPT_config() must be called before this function call.

Post Condition
After calling this function GPT_close() API should call to close gpt operation.

Modifies
None

Example

            CSL_status           status;
            CSL_Handle 			 hGpt;
            ...

           status = GPT_start(hgpt);
		   status = GPT_stop(hgpt);
     

===========================================================================

References CSL_GptObj::regs.