FreeCalypso > hg > tcs211-l1-reconst
comparison chipsetsw/drivers/drv_app/lcc/lcc_modulate.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /****************************************************************************** | |
2 * Power Task (pwr) | |
3 * Design and coding by Svend Kristian Lindholm, skl@ti.com | |
4 * | |
5 * PWR SW Modulation | |
6 * | |
7 * $Id: pwr_modulate.c 1.1 Wed, 20 Aug 2003 10:22:37 +0200 skl $ | |
8 * | |
9 ******************************************************************************/ | |
10 #include <string.h> | |
11 #include "lcc/lcc.h" | |
12 #include "lcc/lcc_trace.h" | |
13 #include "lcc/lcc_modulate.h" | |
14 #include "lcc/lcc_cfg_i.h" | |
15 #include "lcc/lcc_cfg.h" | |
16 #include "rv/rv_defined_swe.h" | |
17 #include "abb/abb.h" | |
18 | |
19 /****************************************************************************** | |
20 * Function prototypes | |
21 ******************************************************************************/ | |
22 | |
23 void pwr_modulate_init(void); | |
24 void pwr_modulate_on(void); | |
25 void pwr_modulate_off(void); | |
26 | |
27 | |
28 #if (USE_Q401_CHG_CIRCUIT == 1) | |
29 extern T_PWR_CFG_BLOCK *pwr_cfg; | |
30 #endif | |
31 | |
32 void pwr_modulate_init(void) { | |
33 ttw(ttr(TTrEventLow,"pwr_modulate_init(%d)" NL, 0)); | |
34 #if (USE_PWL_AS_MODULATOR == 1) | |
35 BUZZ_LIGHT_REG |= 0x02; | |
36 PWL_LEVEL_REG = 0xFF; // Full envelope function | |
37 PWL_CTRL_REG = 0x00; // No 32KHz clock | |
38 #else | |
39 // Set GPIO 6 HIGH | |
40 *((volatile uint16 *) 0xfffe4806) |= 0x0020; // Enable GPIO module | |
41 *((volatile uint16 *) 0xfffe4804) &= 0xffbf; // Set GPIO-6 = output | |
42 *((volatile uint16 *) 0xfffe4802) |= 0x0080; // Set GPIO-6 = HIGH | |
43 #endif | |
44 ttw(ttr(TTrEventLow,"pwr_modulate_init(%d)" NL, 0xff)); | |
45 } | |
46 | |
47 void pwr_modulate_on(void) { | |
48 ttw(ttr(TTrEventLow,"pwr_modulate_on(%d)" NL, 0)); | |
49 #if (USE_Q401_CHG_CIRCUIT== 1) | |
50 /* 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] */ | |
51 ABB_Write_Register_on_page(PAGE0, CHGREG, (pwr_cfg->data.k * pwr_cfg->chg.ichg_max) / 255); | |
52 #endif | |
53 #if (USE_Q402_CHG_CIRCUIT == 1) | |
54 #if (USE_PWL_AS_MODULATOR == 1) | |
55 BUZZ_LIGHT_REG |= 0x02; | |
56 PWL_LEVEL_REG = 0xFF; // Full envelope function | |
57 PWL_CTRL_REG = 0x00; // No 32KHz clock | |
58 #else | |
59 // Use GPIO 6 | |
60 *((volatile uint16 *) 0xfffe4806) |= 0x0020; // Enable GPIO module | |
61 *((volatile uint16 *) 0xfffe4804) &= 0xffbf; // Set GPIO-6 = output | |
62 *((volatile uint16 *) 0xfffe4802) |= 0x0080; // Set GPIO-6 = HIGH | |
63 #endif | |
64 #endif | |
65 ttw(ttr(TTrEventLow,"pwr_modulate_on(%d)" NL, 0xFF)); | |
66 | |
67 } | |
68 | |
69 void pwr_modulate_off(void) { | |
70 ttw(ttr(TTrEventLow,"pwr_modulate_off(%d)" NL, 0)); | |
71 #if (USE_Q401_CHG_CIRCUIT == 1) | |
72 // Don't do anything - FET is fully controlled in pwr_modulate_on() | |
73 #endif | |
74 #if (USE_Q402_CHG_CIRCUIT == 1) | |
75 #ifdef USE_PWL_AS_MODULATOR | |
76 BUZZ_LIGHT_REG &= 0xfd; | |
77 PWL_LEVEL_REG = 0x00; // No envelope function | |
78 PWL_CTRL_REG = 0x00; // No 32KHz clock | |
79 #else | |
80 // Use GPIO 6 | |
81 *((volatile uint16 *) 0xfffe4806) |= 0x0020; // Enable GPIO module | |
82 *((volatile uint16 *) 0xfffe4804) &= 0xffbf; // Set GPIO-6 = output | |
83 *((volatile uint16 *) 0xfffe4802) &= 0x007f; // Set GPIO-6 = LOW | |
84 #endif | |
85 #endif | |
86 ttw(ttr(TTrEventLow,"pwr_modulate_off(%d)" NL, 0xFF)); | |
87 } | |
88 |