1 /* main program of Free Software for Calypso Phone */
3 /* (C) 2010 by Harald Welte <laforge@gnumonks.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #include <abb/twl3025.h>
34 #include <display/st7558.h>
35 #include <rf/trf6151.h>
37 #include <comm/sercomm.h>
38 #include <comm/timer.h>
40 #include <calypso/clock.h>
41 #include <calypso/tpu.h>
42 #include <calypso/tsp.h>
43 #include <calypso/irq.h>
44 #include <calypso/misc.h>
46 #include <layer1/sync.h>
47 #include <layer1/tpu_window.h>
49 /* FIXME: We need proper calibrated delay loops at some point! */
50 void delay_us(unsigned int us)
52 volatile unsigned int i;
54 for (i= 0; i < us*4; i++) { i; }
57 void delay_ms(unsigned int ms)
59 volatile unsigned int i;
61 for (i= 0; i < ms*1300; i++) { i; }
64 const char *hr = "======================================================================\n";
66 /* MAIN program **************************************************************/
68 /* completion call-back for the L1 Sync Pwer Measurement */
69 static void l1s_signal_cb(struct l1_signal *sig)
71 uint16_t i, next_arfcn;
73 switch (sig->signum) {
81 static void key_handler(enum key_codes code, enum key_states state);
86 puts("\n\nHello World from " __FILE__ " program code\n");
89 /* Dump device identification */
93 keypad_set_handler(&key_handler);
95 /* Dump clock config aftee PLL set */
99 st7558_set_attr(DISP_ATTR_INVERT);
100 st7558_puts("layer1.bin");
103 l1s_set_handler(&l1s_signal_cb);
105 tpu_frame_irq_en(1, 1);
116 static int8_t vga_gain = 40;
117 static int high_gain = 0;
118 static int afcout = 0;
120 static void update_vga_gain(void)
122 printf("VGA Gain: %u %s\n", vga_gain, high_gain ? "HIGH" : "LOW");
123 trf6151_set_gain(vga_gain, high_gain);
129 static void tspact_toggle(uint8_t num)
131 printf("TSPACT%u toggle\n", num);
132 tsp_act_toggle((1 << num));
138 static void key_handler(enum key_codes code, enum key_states state)
140 if (state != PRESSED)
144 case KEY_1: /* VGA gain decrement */
150 case KEY_2: /* High/Low Rx gain */
154 case KEY_3: /* VGA gain increment */
161 tspact_toggle(6); /* TRENA (RFFE) */
164 tspact_toggle(8); /* GSM_TXEN (RFFE) */
167 tspact_toggle(1); /* PAENA (RFFE) */
169 case KEY_7: /* decrement AFC OUT */
173 twl3025_afc_set(afcout);
174 printf("AFC OUT: %u\n", twl3025_afcout_get());
176 case KEY_9: /* increase AFC OUT */
180 twl3025_afc_set(afcout);
181 printf("AFC OUT: %u\n", twl3025_afcout_get());