| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 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 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 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; |
|---|
| 84 |
* memory image. */ |
|---|
| 85 |
|
|---|
| 86 |
typedef struct |
|---|
| 87 |
{ |
|---|
| 88 |
unsigned char TerminalOnly; |
|---|
| 89 |
unsigned char DetectOnly; |
|---|
| 90 |
int DetectedDevice; |
|---|
| 91 |
char *baud_rate; |
|---|
| 92 |
* port communicating with the |
|---|
| 93 |
* microcontroller. Read from the |
|---|
| 94 |
* command line. */ |
|---|
| 95 |
|
|---|
| 96 |
char *StringOscillator; |
|---|
| 97 |
* speed from the command line. */ |
|---|
| 98 |
BINARY *BinaryContent; |
|---|
| 99 |
|
|---|
| 100 |
unsigned long BinaryLength; |
|---|
| 101 |
unsigned long BinaryOffset; |
|---|
| 102 |
unsigned long StartAddress; |
|---|
| 103 |
|
|---|
| 104 |
int fdCom; |
|---|
| 105 |
|
|---|
| 106 |
unsigned serial_timeout_count; |
|---|
| 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 |
|---|
| 129 |
|
|---|
| 130 |
|
|---|