blob: fc6bcb1eed0b09d667f26bf2f39c1ff3695d3364 [file] [log] [blame]
Jörg Hohensohn6a4e4c82003-11-30 11:37:43 +00001#ifndef NULL
2#define NULL ((void*)0)
3#endif
4
5#define TRUE 1
6#define FALSE 0
7
8// scalar types
9typedef unsigned char UINT8;
10typedef unsigned short UINT16;
11typedef unsigned long UINT32;
12typedef int BOOL;
13
14typedef void(*tpFunc)(void); // type for execute
15typedef int(*tpMain)(void); // type for start vector to main()
16
17
18// structure of an image in the flash
19typedef struct
20{
21 UINT32* pDestination; // address to copy it to
22 UINT32 size; // how many bytes of payload (to the next header)
23 tpFunc pExecute; // entry point
24 UINT32 flags; // uncompressed or compressed
25 // end of header, now comes the payload
26 UINT32 image[]; // the binary image starts here
27 // after the payload, the next header may follow, all 0xFF if none
28} tImage;
29
30// flags valid for image header
31#define IF_NONE 0x00000000
32#define IF_UCL_2E 0x00000001 // image is compressed with UCL, algorithm 2e
33
34
35// resolve platform dependency of F1 button check
36#if defined PLATFORM_PLAYER
Jens Arnoldb8b94f12004-11-19 23:49:21 +000037#define F1_MASK 0x0001 // Player has no F1 button, so we use "-"
38#define F2_MASK 0x0008 // Player has no F2 button, so we use "Play"
39#define F3_MASK 0x0004 // Player has no F3 button, so we use "+"
40
Jörg Hohensohn6a4e4c82003-11-30 11:37:43 +000041#elif defined PLATFORM_RECORDER
Jens Arnoldb8b94f12004-11-19 23:49:21 +000042#define USE_ADC
Jörg Hohensohn6a4e4c82003-11-30 11:37:43 +000043#define CHANNEL 4
44#define F1_LOWER 250
45#define F1_UPPER 499
46#define F2_LOWER 500
47#define F2_UPPER 699
48#define F3_LOWER 900
49#define F3_UPPER 1023
Jens Arnoldb8b94f12004-11-19 23:49:21 +000050
Jörg Hohensohn6a4e4c82003-11-30 11:37:43 +000051#elif defined PLATFORM_FM
Jens Arnoldb8b94f12004-11-19 23:49:21 +000052#define USE_ADC
Jörg Hohensohn6a4e4c82003-11-30 11:37:43 +000053#define CHANNEL 4
54#define F1_LOWER 150
55#define F1_UPPER 384
56#define F2_LOWER 385
57#define F2_UPPER 544
58#define F3_LOWER 700
59#define F3_UPPER 1023
Jens Arnoldb8b94f12004-11-19 23:49:21 +000060
Jörg Hohensohn4e423102004-09-29 21:54:29 +000061#elif defined PLATFORM_ONDIO
Jens Arnoldb8b94f12004-11-19 23:49:21 +000062#define USE_ADC
Jörg Hohensohn4e423102004-09-29 21:54:29 +000063#define CHANNEL 4
64#define F1_LOWER 0x2EF // Ondio has no F1 button,
Jens Arnoldb8b94f12004-11-19 23:49:21 +000065#define F1_UPPER 0x3FF // so we use "Left".
Jörg Hohensohn4e423102004-09-29 21:54:29 +000066#define F2_LOWER 0x19D // Ondio has no F2 button,
67#define F2_UPPER 0x245 // so we use "Up".
68#define F3_LOWER 0x246 // Ondio has no F3 button,
Jens Arnoldb8b94f12004-11-19 23:49:21 +000069#define F3_UPPER 0x2EE // so we use "Right".
70
Jörg Hohensohn6a4e4c82003-11-30 11:37:43 +000071#else
72#error ("No platform given!")
73#endif
74
Jens Arnoldb8b94f12004-11-19 23:49:21 +000075
Jörg Hohensohn6a4e4c82003-11-30 11:37:43 +000076#define FLASH_BASE 0x02000000 // start of the flash memory
77#define FW_VERSION *(unsigned short*)(FLASH_BASE + 0xFE) // firmware version
78
79
80// prototypes
81void _main(void) __attribute__ ((section (".startup")));
82int main(void);
83void PlatformInit(void);
84void DramInit(void);
85int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len);
86void DecompressStart(tImage* pImage);
Jens Arnoldb8b94f12004-11-19 23:49:21 +000087#ifdef USE_ADC
Jörg Hohensohn6a4e4c82003-11-30 11:37:43 +000088int ReadADC(int channel);
Jens Arnoldb8b94f12004-11-19 23:49:21 +000089#endif
Jörg Hohensohn6a4e4c82003-11-30 11:37:43 +000090int ButtonPressed(void);
91tImage* GetStartImage(int nPreferred);
92// test functions
93void SetLed(BOOL bOn);
94void UartInit(void);
95UINT8 UartRead(void);
96void UartWrite(UINT8 byte);
97void MiniMon(void);
98
99
100// minimon commands
101#define BAUDRATE 0x00 // followed by BRR value; response: command byte
102#define ADDRESS 0x01 // followed by 4 bytes address; response: command byte
103#define BYTE_READ 0x02 // response: 1 byte content
104#define BYTE_WRITE 0x03 // followed by 1 byte content; response: command byte
105#define BYTE_READ16 0x04 // response: 16 bytes content
106#define BYTE_WRITE16 0x05 // followed by 16 bytes; response: command byte
107#define BYTE_FLASH 0x06 // followed by 1 byte content; response: command byte
108#define BYTE_FLASH16 0x07 // followed by 16 bytes; response: command byte
109#define HALFWORD_READ 0x08 // response: 2 byte content
110#define HALFWORD_WRITE 0x09 // followed by 2 byte content; response: command byte
111#define EXECUTE 0x0A // response: command byte if call returns
112#define VERSION 0x0B // response: version
113
114
115// linker symbols
116extern UINT32 begin_text[];
117extern UINT32 end_text[];
118extern UINT32 begin_data[];
119extern UINT32 end_data[];
120extern UINT32 begin_bss[];
121extern UINT32 end_bss[];
122extern UINT32 begin_stack[];
123extern UINT32 end_stack[];
124extern UINT32 begin_iramcopy[];
125extern UINT32 total_size[];