⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm.h

📁 TDK 6521 SOC 芯片 DEMO程序
💻 H
字号:
/***************************************************************************
 * This code and information is provided "as is" without warranty of any   *
 * kind, either expressed or implied, including but not limited to the     *
 * implied warranties of merchantability and/or fitness for a particular   *
 * purpose.                                                                *
 *                                                                         *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 ***************************************************************************/
//**************************************************************************
//    
//  DESCRIPTION: 71M652x POWER METER - Soft Timer Definitions.
// 
//  AUTHOR:  MTF/RGV
//
//  HISTORY: see end of file
//
//**************************************************************************
//               
// File:    STM.H
//               
////////////////////////////////////////////////////////////////////////////
//**************************************************************************
//* TIMER OPERATION
//**************************************************************************
////////////////////////////////////////////////////////////////////////////
#ifndef STM_H
#define STM_H 1
#if TIMERS

//  Several 10ms timers can be active concurrently.

// convert ordinary time to timer tick counts
#define CLK_TCK 100
#define milliseconds(_v_) (min(UINT16_MAX,((_v_ + 9)/10)))
#define seconds(_v_) (min(UINT16_MAX,(_v_*100)))

//**************************************************************************
//  stm_init
//**************************************************************************
//  Purpose: Initialize software timer.
//
//  Inputs:  None.
//
//  Synopsis:

void stm_init(void);

//**************************************************************************
//  stm_wait
//**************************************************************************
//  Purpose: Wait using a software timer
//
//  Inputs:  t         // Wait duration in ticks.
//
//  Synopsis:

void stm_wait (uint16_t t);             

//**************************************************************************
// stm_start
//**************************************************************************
//  Purpose: Add another countdown timer to the list of timers and, 
//           on timer expiring (*tick_count_ptr == 0), it is automatically 
//           removed and *fn_ptr() is called.
//           Similar to tmr0-start() and tmr1-start()
//
//  Inputs:  tick_count           // count of ticks.
//           restart              // FALSE = timer should not restart by itself
//           code *fn_ptr         // Pointer to Function to execute when 
//                                // timer expires.
//
//  Outputs: uint16x_t *          // Pointer to the current tick count.
//  Synopsis:

typedef uint16x_t * STM;
// volatile STM stm_start (uint16_t tick_count, uint8_t restart, void (*fn_ptr) (void)) small reentrant;
volatile uint16x_t * stm_start (uint16_t tick_count, uint8_t restart, void (*fn_ptr) (void)) small reentrant;
                                      
//  NOTE:  On timer expiring (*tick_count_ptr == 0), it is automatically 
//  removed.  If there is no room for another timer, 
//  then a NULL pointer will be returned.
//
//  'stm_run()' needs to be called to keep the timers running
//**************************************************************************

//**************************************************************************
//   stm_stop
//**************************************************************************
//
//  Purpose: stops a software timer.
//           Similar to tmr0-stop() and tmr1-stop()
//
//  Inputs:  uint16x_t *tick_count_ptr;
//
//  Outputs: None
//
//  Synopsis:

void stm_stop (STM tick_count_ptr) small reentrant;

//  NOTE:  'tick_count_ptr' is value returned by 'stm_start()'.
//**************************************************************************

//**************************************************************************
//  stm_running
//**************************************************************************
//
//  Purpose: tests whether a software timer is running.
//           Similar to tmr0-running() and tmr1-running()
//
//  Inputs:  uint16x_t *tick_count_ptr;
//
//  Outputs: None
//
//  Synopsis:
//
#define stm_running(_v_) ( 0 != (* _v_ ))

//  NOTE:  'tick_count_ptr' is value returned by 'stm_start()'.
//**************************************************************************

//**************************************************************************
//  stm_run
//**************************************************************************
//
//  Purpose: Keep the software timers updated and current.
//
//  Inputs:  None
//
//  Outputs: None
//
//  Synopsis:

void stm_run(void);
 
// Note: This routine needs to be called from foreground loop.
//**************************************************************************

// Note: this routine should be called before any other call
// to stm
void stm_init(void);

/***************************************************************************
 * History:
 * $Log: stm.h,v $
 * Revision 1.13  2006/09/09 01:16:05  gmikef
 * *** empty log message ***
 *
 * Revision 1.12  2006/06/06 05:15:57  tvander
 * clean build
 *
 * Revision 1.10  2005/12/21 01:37:10  tvander
 * 6513
 *
 * Revision 1.9  2005/09/22 23:45:30  tvander
 * Clean build all models and unit tests, updated copyright to be fore Teridian
 *
 * Revision 1.8  2005/09/11 00:34:09  tvander
 * Clean compiles
 *
 * Revision 1.7  2005/05/03 00:39:48  tvander
 * Incorporated event reporting in tmr0,tmr1 and unit tests.
 * Retested stm, trm0, tmr1.
 * Incorporated untested changes in io651x.h
 *
 * Revision 1.6  2005/04/30 02:21:25  gmikef
 * *** empty log message ***
 *
 * Revision 1.5  2005/04/28 19:12:28  tvander
 * Comments only!  Restored history comments.
 *
 * Revision 1.4  2005/04/27 23:49:58  gmikef
 * Some MATH rountines now use 'idata'.
 * Added MATH_FAST flag to 'options.h".
 * Changed "6521B.Uv2" to max optimization.
 *
 *
 * Revision 1.3  2005/04/26 17:48:07  tvander
 * Successful test of software timers.
 *
 * Revision 1.2  2005/04/21 02:09:58  gmikef
 * *** empty log message ***
 *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 * this program is fully protected by the United States copyright          *
 * laws and is the property of Teridian Semiconductor Corporation.         *
 ***************************************************************************/
#endif // TIMERS
#endif // ifdef STM_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -