root/trunk/tools/lpc21isp/lpc21isp.h

Revision 306, 3.9 kB (checked in by goodea, 2 years ago)

isp

Line 
1 /*****************************************************************************
2  ** This data and information is proprietary to, and a valuable trade
3  ** secret off, Q-Free Products A/S.  It is given in confidence by
4  ** Q-Free Products A/S and may only be used as permitted under the
5  ** license agreement under which it has been distributed, and in no
6  ** other way.
7  **
8  ** Copyright (C) 2004 Q-Free Products A/S. All rights reserved.
9  ****************************************************************************/
10
11 /** \file
12  *
13  * \brief define a function to Upload Binary according to LPC2114 bootloader
14  *        protocol.
15  *
16  * $Author: cyrilh $
17  * $Date: 2006/02/20 14:02:29 $
18  * $Revision: 1.18 $
19  */
20 #ifndef lpc21isp_h
21 #define lpc21isp_h
22
23
24
25 #include "Types.h"
26 #include "Uart.h"
27 #include "QFBCNP.h"
28 #include "lpc210x.h"
29 #include "buff.h"
30 #include "app.h"
31
32
33 /*
34 debug levels
35 0 - very quiet          - Anything at this level gets printed
36 1 - quiet               - Only error messages should be printed
37 2 - indicate progress   - Add progress messages
38 3 - first level debug   - Major level tracing
39 4 - second level debug  - Add detailed deugging
40 5 - log comm's          - log serial I/O
41 */
42
43
44
45 #ifdef COMPILE_FOR_LPC21
46
47 #   define my_level( level ) (          \
48         (level == 0)?   0:              \
49         (level == 1)?   DFLT_LEVEL/2:   \
50         (level == 2)?   DFLT_LEVEL:     \
51         (level == 3)?   0xA0:           \
52         (level == 4)?   0xB0:           \
53                         0xC0            \
54     )
55
56
57 #   define DebugPrintf( level, args... )  { appDebugPrintf( my_level( level ), ##args ); }
58 #   ifdef fflush
59 #       undef fflush
60 #   endif
61 #   define fflush(a) {}
62 #   ifdef time
63 #       undef time
64 #   endif
65 #   define time(a) 0
66
67 #   include "timer.h"
68 #   define Sleep sleep
69
70     static inline void write(int UNUSED fd, const unsigned char *s, int n)
71     {
72         buffSaveData( app_map.nw2serial, s, n );
73     }
74    
75     static inline int read(int UNUSED fd, char* r, int count)
76     {   
77         resetWatchDogIfCritical();
78         return buffDelete( app_map.serial2nw, r, count );
79     }   
80
81 #else
82
83     typedef unsigned char BINARY;   /**< data type used for microcontroller
84                                       *  memory image.                        */
85                                
86     typedef struct
87     {
88         unsigned char TerminalOnly;
89         unsigned char DetectOnly;
90         int           DetectedDevice;       /** index in LPCtypes[] array */
91         char *baud_rate;                    /**< Baud rate to use on the serial
92                                              * port communicating with the
93                                              * microcontroller. Read from the
94                                              * command line.                        */
95                                          
96         char *StringOscillator;             /**< Holds representation of oscillator
97                                               * speed from the command line.         */
98         BINARY *BinaryContent;              /**< Binary image of the
99                                               * microcontroller's memory.             */
100         unsigned long BinaryLength;
101         unsigned long BinaryOffset;
102         unsigned long StartAddress;
103    
104         int fdCom;
105    
106         unsigned serial_timeout_count;   /**< Local used to track
107                                            * timeouts on serial port read. */
108    
109     } ISP_ENVIRONMENT;
110    
111    
112     extern int PhilipsDownload(ISP_ENVIRONMENT *IspEnvironment);
113
114     static inline int UploadBinary( unsigned char *BinaryContent, unsigned long BinaryLength,
115                         unsigned char* StringOscillator )
116     {
117         ISP_ENVIRONMENT environment = {
118             .StringOscillator = StringOscillator,
119             .BinaryContent = BinaryContent,
120             .BinaryLength = BinaryLength
121         };
122         return PhilipsDownload( &environment );
123     }
124 #endif
125
126
127
128 #endif /* !defined(lpc21isp_h) */
129
130 /* EOF lpc21isp.h */
Note: See TracBrowser for help on using the browser.