📄 lcc_modulate.c
字号:
/******************************************************************************
* Power Task (pwr)
* Design and coding by Svend Kristian Lindholm, skl@ti.com
*
* PWR SW Modulation
*
* $Id: lcc_modulate.c,v 1.1.1.1 2004/06/19 06:00:29 root Exp $
*
******************************************************************************/
#include <string.h>
#include "lcc.h"
#include "lcc_trace.h"
#include "lcc_modulate.h"
#include "lcc_cfg_i.h"
#include "abb.h"
/******************************************************************************
* Function prototypes
******************************************************************************/
void pwr_modulate_init(void);
void pwr_modulate_on(void);
void pwr_modulate_off(void);
#if (USE_Q401_CHG_CIRCUIT == 1)
extern T_PWR_CFG_BLOCK *pwr_cfg;
#endif
void pwr_modulate_init(void) {
ttw(ttr(TTrEventLow,"pwr_modulate_init(%d)" NL, 0));
#ifdef USE_PWL_AS_MODULATOR
BUZZ_LIGHT_REG |= 0x02;
PWL_LEVEL_REG = 0xFF; // Full envelope function
PWL_CTRL_REG = 0x00; // No 32KHz clock
#else
// Set GPIO 6 HIGH
*((volatile uint16 *) 0xfffe4806) |= 0x0020; // Enable GPIO module
*((volatile uint16 *) 0xfffe4804) &= 0xffbf; // Set GPIO-6 = output
*((volatile uint16 *) 0xfffe4802) |= 0x0080; // Set GPIO-6 = HIGH
#endif
ttw(ttr(TTrEventLow,"pwr_modulate_init(%d)" NL, 0xff));
}
void pwr_modulate_on(void) {
ttw(ttr(TTrEventLow,"pwr_modulate_on(%d)" NL, 0));
#if (USE_Q401_CHG_CIRCUIT== 1)
/* Program the DAC with the constant current value taken from /pwr/chg/chg<N>.cfg multiplied by k/255, where current k is in [1..255] */
/* Robert.Chen modified, 2004-04-28 */
/* from */
//ABB_Write_Register_on_page(PAGE0, CHGREG, (pwr_cfg->data.k * pwr_cfg->chg.ichg_max) / 255);
/* to */
ABB_Write_Register_on_page(PAGE0, CHGREG, (pwr_cfg->data.k * pwr_cfg->chg.ichg_max) / 500);
/* end */
#endif
#if (USE_Q402_CHG_CIRCUIT == 1)
#ifdef USE_PWL_AS_MODULATOR
BUZZ_LIGHT_REG |= 0x02;
PWL_LEVEL_REG = 0xFF; // Full envelope function
PWL_CTRL_REG = 0x00; // No 32KHz clock
#else
// Use GPIO 6
*((volatile uint16 *) 0xfffe4806) |= 0x0020; // Enable GPIO module
*((volatile uint16 *) 0xfffe4804) &= 0xffbf; // Set GPIO-6 = output
*((volatile uint16 *) 0xfffe4802) |= 0x0080; // Set GPIO-6 = HIGH
#endif
#endif
ttw(ttr(TTrEventLow,"pwr_modulate_on(%d)" NL, 0xFF));
}
void pwr_modulate_off(void) {
ttw(ttr(TTrEventLow,"pwr_modulate_off(%d)" NL, 0));
#if (USE_Q401_CHG_CIRCUIT == 1)
// Don't do anything - FET is fully controlled in pwr_modulate_on()
#endif
#if (USE_Q402_CHG_CIRCUIT == 1)
#ifdef USE_PWL_AS_MODULATOR
BUZZ_LIGHT_REG &= 0xfd;
PWL_LEVEL_REG = 0x00; // No envelope function
PWL_CTRL_REG = 0x00; // No 32KHz clock
#else
// Use GPIO 6
*((volatile uint16 *) 0xfffe4806) |= 0x0020; // Enable GPIO module
*((volatile uint16 *) 0xfffe4804) &= 0xffbf; // Set GPIO-6 = output
*((volatile uint16 *) 0xfffe4802) &= 0x007f; // Set GPIO-6 = LOW
#endif
#endif
ttw(ttr(TTrEventLow,"pwr_modulate_off(%d)" NL, 0xFF));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -