annotate gsm-fw/L1/dsp/leadapi.c @ 926:3f178b3ac50a

gsm-fw: preparations for building with L1_DYN_DSP_DWNLD enabled
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Thu, 22 Oct 2015 18:41:05 +0000
parents 25a3095e8a98
children
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
586
25a3095e8a98 L1: dsp subdir added to the build
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 558
diff changeset
36 #include "../../include/config.h"
25a3095e8a98 L1: dsp subdir added to the build
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 558
diff changeset
37 #include "../../include/sys_types.h"
558
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38
586
25a3095e8a98 L1: dsp subdir added to the build
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 558
diff changeset
39 #include "../../bsp/mem.h"
25a3095e8a98 L1: dsp subdir added to the build
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 558
diff changeset
40 #include "../../bsp/clkm.h"
558
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 #include "leadapi.h"
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 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
45 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 (*(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
47 }
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 * LA_StartLead
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 * 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
53 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 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
55 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 volatile int j;
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 #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
59 // Set PLL
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 (*(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
61
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 // 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
63 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
64 #endif
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65
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_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
67 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 * LA_InitialLeadBoot16
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 * 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
74 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 * 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
76 * 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
77 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 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
79 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 int i;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 SYS_UWORD16 *origin;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 SYS_UWORD16 *destination;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 SYS_UWORD16 *currentSection;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 (*(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
86
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 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
88
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 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
90 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 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
92 destination = (SYS_UWORD16 *)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 (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
94 // 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
95 // (*(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
96
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 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
98 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 *destination = *origin++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 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
101 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 currentSection = origin;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 }
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
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106
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 * LA_InitialLeadBoot
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 * 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
111 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 * 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
113 * 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
114 *
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 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
117 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 int i;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 short error = NULL;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 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
121 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
122 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
123
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 (*(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
125
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 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
127
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 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
129
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 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
131
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 // 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
133 size = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 size_ext = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 dsp_address = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 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
137
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 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
139 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
140 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
141
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 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
143 *destinationPtr++ = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 // next section
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 size = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 size_ext = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 dsp_address = *bootCodePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 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
151 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 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
154 size = NULL;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 }
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_VERSION;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 }
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 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 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
164 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 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
167 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
168 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 }
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 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 * LA_LoadPage
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 * 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
176 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177 * 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
178 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 * 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
180 * 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
181 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 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
183 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 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
185 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
186 int i = NULL;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 short error = NULL;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196 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
197 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
198
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199 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
200
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201 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
202
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203 // 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
204 //-------------------
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205 // 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
206 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207 do
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 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
210 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211 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
212 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
213 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214 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
215
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 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
217 *destinationPtr = page;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218 *(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
219
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 // 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
221 //-----------------------------------
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 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
223 size = *codePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 size_ext = *codePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225 dsp_address = *codePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 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
227
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 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
229
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 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
231
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232 // 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
233 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 do
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 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
237 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 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
239 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
240 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241 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
242
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 // 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
244 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
245 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
246 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
247 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
248 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
249
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 // 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
251 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
252 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
253 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
254 else
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
255 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
256 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
258 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
259 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
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
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
264 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
265 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266 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
267 }
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 // 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
270 *(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
271 *(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
272 *(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
273
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
274 // perform the copy
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
275 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
276 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
277 *destinationPtr++ = *codePtr++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
278 }
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 // 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
281 *(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
282 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
283 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
284 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
285 } 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
286
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
287 // 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
288 //---------------------------------------------
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
289 // 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
290 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
291 do
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 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
294 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
295 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
296 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
297 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
298 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
299
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
300 /* 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
301 /* 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
302 /* 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
303 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
304 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
305 *destinationPtr++ = 0x0000;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
306 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
307
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
308 if (start)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
309 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
310 /* 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
311 *(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
312 *(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
313 *(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
314 *(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
315 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
316
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
317 return(LA_SUCCESS);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
318 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
319 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
320 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
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 else {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
324 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
325 }
586
25a3095e8a98 L1: dsp subdir added to the build
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 558
diff changeset
326
25a3095e8a98 L1: dsp subdir added to the build
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 558
diff changeset
327 if (error != NULL) // if an error was detected in the coff2c format,
558
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328 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
329 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
330 }
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 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 * LA_LoadPage16
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 * 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
337 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
338 * 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
339 *
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
340 * 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
341 * 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
342 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343 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
344 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
345 int i = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
346 int remainingSize, currentBlockSize;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347 volatile int j;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348 int t;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
349 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
350
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
351 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
352 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
353 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
354 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
355
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356 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
357 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
358
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 // 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
360 if (page == 1)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
361 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
362 // 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
363 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
364 do
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 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
367 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
368 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
369 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
370
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
371 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
372 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
373
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
374 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
375 *destination = 1;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
376 *(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
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
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
380 do
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
381 { /* 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
382 origin = currentSection + 2;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
383 size = *currentSection;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
384 addr = *(currentSection+1);
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 remainingSize = size;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
388 while (remainingSize)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
389 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
390 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
391 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
392 else
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
393 currentBlockSize = remainingSize;
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 /* 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
396 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
397 do
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
398 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
399 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
400 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
401 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
402 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
403
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
404 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
405 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
406
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
407 /* 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
408 *(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
409 *(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
410
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
411 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
412 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
413 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
414 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
415
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
416 /* Copy the block */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
417 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
418 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
419 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
420 *destination = *origin++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
421 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
422 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
423
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
424 *(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
425
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
426 remainingSize -= currentBlockSize;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
427 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
428 currentSection = origin;
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 while (size != 0);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
431
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
432 /* 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
433 t = 0;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
434 do
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
435 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
436 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
437 t++;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
438 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
439 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
440
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
441 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
442 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
443
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
444
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
445 /* 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
446 /* 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
447 /* 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
448 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
449 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
450 *destination++ = 0x0000;
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
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
453 if (start)
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
454 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
455 /* 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
456 *(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
457 *(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
458 *(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
459 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
460
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
461 return(LA_SUCCESS);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
462 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
463
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
464 /*
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
465 * LeadBoot
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 * 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
468 */
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
469 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
470 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
471 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
472 short res;
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 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
475 section[1] = entryPoint;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
476
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
477 #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
478 CLKM_RELEASELEADRESET;
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
479 #else
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
480 LA_StartLead(pll);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
481 #endif
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
482
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
483 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
484 return(res);
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
485
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
486 }
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
487
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
488
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 * LA_ReleaseLead
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
491 *
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 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
494 {
565bf963c3a2 gsm-fw/L1/dsp/leadapi.[ch]: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
495 (*(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
496 }