📄 its_mcu.c
字号:
/******************************************************************************
Filename: ITS_mcu.c
Copyright 2007 Texas Instruments, Inc.
******************************************************************************/
#include "ITS_types.h"
#include "ITS_defs.h"
#include "ITS_board.h"
#include "ITS_mcu.h"
//-----------------------------------------------------------------------------
// void ITSMcuWaitUs(uint16 usec)
//
// DESCRIPTION:
// Busy wait function. Waits the specified number of microseconds. Use
// assumptions about number of clock cycles needed for the various instructions.
// The duration of one cycle depends on MCLK. In this HAL, it is set
// to 4 MHz, thus 4 cycles per usec.
//
// NB! This function is highly dependent on architecture and compiler!
//-----------------------------------------------------------------------------
void ITSMcuWaitUs(uint16 usec) // 5 cycles for calling
{
// The least we can wait is 3 usec:
// ~1 usec for call, 1 for first compare and 1 for return
while(usec > 3) // 2 cycles for compare
{ // 2 cycles for jump
asm("NOP"); // 1 cycles for nop
asm("NOP"); // 1 cycles for nop
asm("NOP"); // 1 cycles for nop
asm("NOP"); // 1 cycles for nop
asm("NOP"); // 1 cycles for nop
usec -= 2; // 1 cycles for optimized decrement
}
} // 4 cycles for returning
//-----------------------------------------------------------------------------
// void ITSMcuSetLowPowerMode(uint8 mode)
//
// DESCRIPTION:
// Sets the MCU in a low power mode. Will turn global interrupts on at
// the same time as entering the LPM mode. The MCU must be waken from
// an interrupt (status register on stack must be modified).
//-----------------------------------------------------------------------------
void ITSMcuSetLowPowerMode(uint8 mode)
{
switch (mode)
{
case HAL_MCU_LPM_0:
__low_power_mode_0();
break;
case HAL_MCU_LPM_1:
__low_power_mode_1();
break;
case HAL_MCU_LPM_2:
__low_power_mode_2();
break;
case HAL_MCU_LPM_3:
__low_power_mode_3();
break;
case HAL_MCU_LPM_4:
__low_power_mode_4();
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -