annotate gsm-fw/L1/dsp/leadapi.c @ 573:976aeaa2e6e1

gsm-fw/L1/include/l1_pwmgr.h: L1_PWMGR_APP_OFFSET definition needed for l1_trace.c to compile
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 11 Aug 2014 01:46:50 +0000
parents 565bf963c3a2
children 25a3095e8a98
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
558
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /********************************************************************************
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 Property of Texas Instruments -- For Unrestricted Internal Use Only
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 Unauthorized reproduction and/or distribution is strictly prohibited. This
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 product is protected under copyright law and trade secret law as an
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 unpublished work. Created 1987, (C) Copyright 1997 Texas Instruments. All
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 rights reserved.
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 Filename : leadapi.c
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 Description : Boot the LEAD through the API
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 Target : Arm
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 Project :
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 Author : A0917556
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 Version number : 1.7
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 Date and time : 01/30/01 10:22:25
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 Previous delta : 12/19/00 14:27:48
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 SCCS file : /db/gsm_asp/db_ht96/dsp_0/gsw/rel_0/mcu_l1/release_gprs/RELEASE_GPRS/drivers1/common/SCCS/s.leadapi.c
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 Sccs Id (SID) : '@(#) leadapi.c 1.7 01/30/01 10:22:25 '
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 *****************************************************************************/
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 #define LEADAPI_C 1
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 #include "l1sw.cfg"
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 #include "chipset.cfg"
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 #if (OP_L1_STANDALONE == 0)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 #include "main/sys_types.h"
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 #else
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 #include "sys_types.h"
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 #endif
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 #include "memif/mem.h"
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 #include "clkm/clkm.h"
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 #include "leadapi.h"
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 void LA_ResetLead(void)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 (*(SYS_UWORD16 *) CLKM_CNTL_RST) |= CLKM_LEAD_RST;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 * LA_StartLead
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 * Parameter : pll is the value to set in the PLL register
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 void LA_StartLead(SYS_UWORD16 pll)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 volatile int j;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 #if ((CHIPSET == 2) || (CHIPSET == 3) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 9))
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 // Set PLL
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 (*(SYS_UWORD16 *) CLKM_LEAD_PLL_CNTL) = pll;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 // Wait 100 microseconds for PLL to start
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 wait_ARM_cycles(convert_nanosec_to_cycles(100000));
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 #endif
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 (*(SYS_UWORD16 *) CLKM_CNTL_RST) &= ~CLKM_LEAD_RST;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 * LA_InitialLeadBoot16
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 * For RAM-based LEAD
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 * Copy all sections to API
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 * Dedicated with coff2c with 16-bit size and address (used with coff version 1 until DSP v1110)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 void LA_InitialLeadBoot16(const unsigned char bootCode[])
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 int i;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 SYS_UWORD16 *origin;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 SYS_UWORD16 *destination;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 SYS_UWORD16 *currentSection;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 (*(SYS_UWORD16 *) CLKM_CNTL_RST) |= CLKM_LEAD_RST; // Reset Lead
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 currentSection = (SYS_UWORD16*) bootCode;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 while (*currentSection != 0) // *currentSection is "size"
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 origin = currentSection + 2; // origin points on 1st word of current section
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 destination = (SYS_UWORD16 *)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 (BASE_API_ARM + ((*(currentSection+1) - BASE_API_LEAD) * 2));
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 // destination is "addr" in API
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 // (*(currentSection+1) is "size" of current section
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 for (i=0 ; i< *currentSection ; i++)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 *destination = *origin++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 destination = destination + 1; // destination is UNSIGNED16
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 currentSection = origin;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 * LA_InitialLeadBoot
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 * For RAM-based LEAD
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 * Copy all sections to API
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 * Dedicated with coff2c with 32-bit size and address (perl or v3 version used with coff version 2 from v1500)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 void LA_InitialLeadBoot(const unsigned char bootCode[])
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 int i;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 short error = NULL;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 SYS_UWORD16 size, size_ext; // dsp_addr[0:15] and dsp_addr[16:31] of the current section as specified in bootCode[] array
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 SYS_UWORD16 dsp_address, dsp_ext_address; // size[0:15] and size[16:31] of the current section as specified in bootCode[] array
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 SYS_UWORD16 *bootCodePtr, *destinationPtr; // pointer in bootCode[] array and pointer in the API (MCU addresses)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 (*(SYS_UWORD16 *) CLKM_CNTL_RST) |= CLKM_LEAD_RST; // reset Lead
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 bootCodePtr = (SYS_UWORD16 *) bootCode; // initialisation of bootCodePtr on the first word of the C array
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 if ( (NULL == *bootCodePtr++) && (NULL == *bootCodePtr++) ) { // NULL TAG detection
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 if ( ( 3 == *bootCodePtr++) && (NULL == *bootCodePtr++) ) { // coff2c version number detection
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 // initialization for the first section
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 size = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 size_ext = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 dsp_address = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 dsp_ext_address = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 while (size != NULL) { // loop until last section whose size is null
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 if ( (NULL == size_ext) && (NULL == dsp_ext_address) ) {// size and address must 16-bit values in LA_InitialLeadBoot()
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 destinationPtr = (SYS_UWORD16 *) (BASE_API_ARM + (dsp_address - BASE_API_LEAD) * 2); // destination in API from the MCU side
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 for (i=0 ; i<size ; i++) {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 *destinationPtr++ = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 // next section
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 size = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 size_ext = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 dsp_address = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 dsp_ext_address = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 error = LA_BAD_EXT_VALUE;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 size = NULL;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 error = LA_BAD_VERSION;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 error = LA_BAD_TAG;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 if (error != NULL) { // if an error was detected in the coff2c format,
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 LA_InitialLeadBoot16(bootCode); // try to download a coff-v1.0 coff2c output
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 * LA_LoadPage
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181 * Final LEAD boot - needs to communicate with initial LEAD Boot program
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 * Copy all sections to API
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 * Parameters : pointer to code, LEAD page, flag to start executing
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186 * Return value : 0 for success, 1 for timeout
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 short LA_LoadPage(const unsigned char code[], SYS_UWORD16 page, SYS_UWORD16 start)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 int t; // time counter for synchronization
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191 SYS_UWORD16 stat; // status parameter for synchronization
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192 int i = NULL;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 short error = NULL;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 SYS_UWORD16 current_block_size; // size of the current block to be copied into API
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195 int remaining_size32; // remaining size of the current section to be copied after the last block
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196 int remaining_size_DSPpage32; // size remaining in the current DSP page
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 int max_block_size; //biggest block size used during the patch download
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 SYS_UWORD16 size, size_ext; // size[0:15] and size[16:31] of the current section as specified in code[] array
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199 SYS_UWORD16 dsp_address, dsp_ext_address; // dsp_addr[0:15] and dsp_addr[16:31] of the current section as specified in code[] array
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
200 SYS_UWORD16 *codePtr, *destinationPtr; // pointer in code[] array and pointer in the API (MCU addresses)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
202 codePtr = (SYS_UWORD16 *) code; // initialisation of codePtr on the first word of the C array
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203 max_block_size = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205 if ( (NULL == *codePtr++) && (NULL == *codePtr++)) { // NULL TAG detection
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207 if ( (3 == *codePtr++) && (NULL == *codePtr++)) { // coff2c version number detection
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209 // Set the data page
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 //-------------------
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211 // Wait until LEAD is ready
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
212 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 do
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
215 stat = *((volatile SYS_UWORD16 *) DOWNLOAD_STATUS);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
217 if (t > LA_TIMEOUT)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218 return(LA_ERR_TIMEOUT);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 while (stat != LEAD_READY);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
221
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 destinationPtr = (SYS_UWORD16 *) BASE_API_ARM;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223 *destinationPtr = page;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 *(volatile SYS_UWORD16 *) DOWNLOAD_STATUS = PAGE_SELECTION;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 // Code/Data download block by block
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 //-----------------------------------
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 do { // SECTION BY SECTION COPY
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229 size = *codePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 size_ext = *codePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
231 dsp_address = *codePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232 dsp_ext_address = *codePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 remaining_size32 = (size_ext << 16) + size; // reconstruction of the total 32-bit size of the section
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
235
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236 while (remaining_size32) { // BLOCK BY BLOCK COPY
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 // Wait until LEAD is ready
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
240 do
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
242 stat = *((volatile SYS_UWORD16 *) DOWNLOAD_STATUS);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
244 if (t > LA_TIMEOUT)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
245 return(LA_ERR_TIMEOUT);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
246 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
247 while (stat != LEAD_READY);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
248
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
249 // DSP address managment including the extended page
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 remaining_size_DSPpage32 = MAX_UINT - dsp_address +1; // calculate the max available size in the current DSP page (MAX_UINT=65535)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
251 if (NULL == remaining_size_DSPpage32) {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
252 dsp_address = 0; // continue on the next DSP page
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
253 dsp_ext_address += 1;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
254 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
255
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
256 // partitionning of the current section into blocks
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 if (remaining_size32 >= MAX_BLOCK_SIZE) {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
258 if (MAX_BLOCK_SIZE <= remaining_size_DSPpage32)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
259 current_block_size = MAX_BLOCK_SIZE; // block by block partitioning
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
260 else
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
261 current_block_size = remaining_size_DSPpage32;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
262 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
263 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
264 if(remaining_size32 <= remaining_size_DSPpage32)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
265 current_block_size = remaining_size32; // the end of the section fits and is copied
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266 else
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
267 current_block_size = remaining_size_DSPpage32;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
268 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
269
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
270 if ( current_block_size > max_block_size )
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
271 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
272 max_block_size = current_block_size;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
273 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
274
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
275 // set parameters in the share memory
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
276 *(volatile SYS_UWORD16 *) DOWNLOAD_SIZE = current_block_size;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
277 *(volatile SYS_UWORD16 *) DOWNLOAD_ADDR = dsp_address;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
278 *(volatile SYS_UWORD16 *) DOWNLOAD_EXT_PAGE = dsp_ext_address;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
279
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
280 // perform the copy
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
281 destinationPtr = (SYS_UWORD16 *) BASE_API_ARM;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
282 for (i=0 ; i<current_block_size ; i++) {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
283 *destinationPtr++ = *codePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
284 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
285
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
286 // synchronize and prepare the next step
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
287 *(volatile SYS_UWORD16 *) DOWNLOAD_STATUS = BLOCK_READY;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
288 dsp_address += current_block_size;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
289 remaining_size32 -= current_block_size;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
290 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
291 } while ( (size != NULL) || (size_ext != NULL) );
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
292
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
293 // Setting of the starting address if required
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
294 //---------------------------------------------
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
295 // Wait until LEAD is ready
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
296 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
297 do
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
298 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
299 stat = *((volatile SYS_UWORD16 *) DOWNLOAD_STATUS);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
300 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
301 if (t > LA_TIMEOUT)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
302 return(LA_ERR_TIMEOUT);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
303 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
304 while (stat != LEAD_READY);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
305
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
306 /* the part of the API used for the download must be reseted at end of download */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
307 /* in case some values are not initialized within API before DSP start:*/
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
308 /* DSP start after DOWNLOAD_SIZE is set to zero.*/
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
309 destinationPtr = (SYS_UWORD16 *) BASE_API_ARM;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
310 for (i=0 ; i<max_block_size ; i++) {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
311 *destinationPtr++ = 0x0000;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
312 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
313
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
314 if (start)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
315 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
316 /* Set the last block, which is the starting address */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
317 *(volatile SYS_UWORD16 *) DOWNLOAD_SIZE = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
318 *(volatile SYS_UWORD16 *) DOWNLOAD_ADDR = dsp_address;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
319 *(volatile SYS_UWORD16 *) DOWNLOAD_EXT_PAGE = dsp_ext_address;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
320 *(volatile SYS_UWORD16 *) DOWNLOAD_STATUS = BLOCK_READY;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
321 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
322
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
323 return(LA_SUCCESS);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
324 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
325 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
326 error = LA_BAD_VERSION;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
327 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
329 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
330 error = LA_BAD_TAG;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
331 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
332
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
333 /* if (error != NULL) { */ // if an error was detected in the coff2c format,
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 error = LA_LoadPage16(code, page, start); // try to download a coff-v1.0 coff2c output
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335 return(error); // and return its result
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 /* } */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
337 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
338
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
339
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
340 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
341 * LA_LoadPage16
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
342 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343 * Final LEAD boot - needs to communicate with initial LEAD Boot program
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
344 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
345 * Copy all sections to API
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
346 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347 * Parameters : pointer to code, LEAD page, flag to start executing
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348 * Return value : 0 for success, 1 for timeout
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
349 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
350 short LA_LoadPage16(const unsigned char code[], SYS_UWORD16 page, SYS_UWORD16 start)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
351 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
352 int i = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
353 int remainingSize, currentBlockSize;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
354 volatile int j;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
355 int t;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356 int max_block_size; //biggest block size used during the patch download
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
357
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
358 volatile SYS_UWORD16 *origin;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 volatile SYS_UWORD16 *destination;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
360 volatile SYS_UWORD16 *currentSection;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
361 SYS_UWORD16 addr, size, stat;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
362
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
363 currentSection = (SYS_UWORD16*) code; /* Take GSM application s/w */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
364 max_block_size = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
365
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
366 // Set the data page if needed
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
367 if (page == 1)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
368 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
369 // Wait until LEAD is ready
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
370 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
371 do
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
372 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
373 stat = *((volatile SYS_UWORD16 *) DOWNLOAD_STATUS);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
374 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
375 if (t > LA_TIMEOUT)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
376 return(LA_ERR_TIMEOUT);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
377
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
378 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
379 while ( stat != LEAD_READY);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
380
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
381 destination = (volatile SYS_UWORD16 *) BASE_API_ARM;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
382 *destination = 1;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
383 *(volatile SYS_UWORD16 *) DOWNLOAD_STATUS = PAGE_SELECTION;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
384 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
385
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
386
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387 do
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
388 { /* while there is a section to transfer */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
389 origin = currentSection + 2;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
390 size = *currentSection;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
391 addr = *(currentSection+1);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
392
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
393 remainingSize = size;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
394
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
395 while (remainingSize)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
396 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
397 if (remainingSize > MAX_BLOCK_SIZE)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
398 currentBlockSize = MAX_BLOCK_SIZE;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
399 else
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
400 currentBlockSize = remainingSize;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
401
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
402 /* Wait until LEAD is ready */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
403 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
404 do
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
405 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
406 stat = *((volatile SYS_UWORD16 *) DOWNLOAD_STATUS);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
407 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
408 if (t > LA_TIMEOUT)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
409 return(LA_ERR_TIMEOUT);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
410
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
411 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
412 while (stat != LEAD_READY);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
413
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
414 /* Set the block size and address in shared memory */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
415 *(volatile SYS_UWORD16 *) DOWNLOAD_SIZE = currentBlockSize;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
416 *(volatile SYS_UWORD16 *) DOWNLOAD_ADDR = addr + size - remainingSize;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
417
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
418 if ( currentBlockSize > max_block_size )
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
419 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
420 max_block_size = currentBlockSize;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
421 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
422
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
423 /* Copy the block */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
424 destination = (volatile SYS_UWORD16 *) BASE_API_ARM;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
425 for (i=0 ; i< currentBlockSize ; i++)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
426 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
427 *destination = *origin++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
428 destination += 1; // API is really 16-bit wide for MCU now !
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
429 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
430
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
431 *(volatile SYS_UWORD16 *) DOWNLOAD_STATUS = BLOCK_READY;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
432
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
433 remainingSize -= currentBlockSize;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
434 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
435 currentSection = origin;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
436 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
437 while (size != 0);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
438
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
439 /* Wait until LEAD is ready */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
440 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
441 do
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
442 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
443 stat = *((volatile SYS_UWORD16 *) DOWNLOAD_STATUS);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
444 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
445 if (t > LA_TIMEOUT)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
446 return(LA_ERR_TIMEOUT);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
447
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
448 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
449 while (stat != LEAD_READY);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
450
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
451
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
452 /* the part of the API used for the download must be reseted at end of download */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
453 /* in case some values are not initialized within API before DSP start:*/
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
454 /* DSP start after DOWNLOAD_SIZE is set to zero.*/
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
455 destination = (SYS_UWORD16 *) BASE_API_ARM;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
456 for (i=0 ; i<max_block_size ; i++) {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
457 *destination++ = 0x0000;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
458 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
459
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
460 if (start)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
461 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
462 /* Set the last block, which is the starting address */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
463 *(volatile SYS_UWORD16 *) DOWNLOAD_SIZE = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
464 *(volatile SYS_UWORD16 *) DOWNLOAD_ADDR = addr;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
465 *(volatile SYS_UWORD16 *) DOWNLOAD_STATUS = BLOCK_READY;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
466 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
467
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
468 return(LA_SUCCESS);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
469 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
470
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
471 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
472 * LeadBoot
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
473 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
474 * Start the LEAD without downloading any code
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
475 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
476 short LeadBoot(SYS_UWORD16 entryPoint, SYS_UWORD16 pll)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
477 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
478 SYS_UWORD16 section[2];
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
479 short res;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
480
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
481 section[0] = 0; // null size
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
482 section[1] = entryPoint;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
483
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
484 #if ((CHIPSET == 4) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12))
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
485 CLKM_RELEASELEADRESET;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
486 #else
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
487 LA_StartLead(pll);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
488 #endif
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
489
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
490 res = LA_LoadPage((const unsigned char *) section, 0, 1);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
491 return(res);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
492
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
493 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
494
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
495
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
496 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
497 * LA_ReleaseLead
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
498 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
499 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
500 void LA_ReleaseLead(void)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
501 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
502 (*(unsigned short *) CLKM_CNTL_RST) &= ~CLKM_LEAD_RST;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
503 }