Debian Codegraph @

cm16flash.h

raw symbols SCIP
1 /***************************************************************************
2 cm16flash.h - header for cm16cflash.cxx.
3 -------------------
4 begin : Wed Sep 25 18:58:35 BST 2002
5 copyright : (C) 2002 by Greg Reynolds, Jim Hawkridge
6 email : [email protected]
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 /*
19
20 This class provides access to all flash ROM functions of the M16C's default
21 boot loader.
22
23 */
24
25 #include "ccomport.h"
26
27 #define ADDRESS_HIGH(x) ((x >> 16) & 0xFF)
28 #define ADDRESS_MIDDLE(x) ((x >> 8) & 0xFF)
29 #define ADDRESS_LOW(x) ((x) & 0xFF)
30
31 #define M16_CPU 1
32 #define R8C_CPU 2
33
34 /* programmer specific defs */
35 #define M16_CONFIRM_CLOCK 0xB0
36 #define M16_DELAY 15000 // 15ms
37 #define M16_READ_PAGE 0xFF
38 #define M16_PAGE_WRITE 0x41
39 #define M16_PAGE_SIZE 256
40 #define M16_READ_SRD 0x70
41 #define M16_CLEAR_SRD 0x50
42 #define M16_READ_VERSION_INFO 0xFB
43 #define M16_ID_CHECK 0xF5
44 #define M16_ID_ADDRESS 0x0FFFDF
45 #define M16_ID_SIZE 0x07
46 #define M16_SR11 0x08
47 #define M16_SR10 0x04
48 #define M16_LOCK_DISABLE 0x75
49 #define M16_ERASE_BLOCK 0x20
50 #define M16_ERASE_VERIFY 0xD0
51
52 #define M16_BLOCK_COUNT 7
53 #define M16_BLOCK6_BEGIN 0x0C0000
54 #define M16_BLOCK5_BEGIN 0x0D0000
55 #define M16_BLOCK4_BEGIN 0x0E0000
56 #define M16_BLOCK3_BEGIN 0x0F0000
57 #define M16_BLOCK2_BEGIN 0x0F8000
58 #define M16_BLOCK1_BEGIN 0x0FA000
59 #define M16_BLOCK0_BEGIN 0x0FC000
60
61 #define R8C_ID_ADDRESS 0x00FFDF
62 #define R8C_BLOCK_COUNT 2
63 #define R8C_BLOCK0_BEGIN 0x0E000
64 #define R8C_BLOCK1_BEGIN 0x0C000
65
66 #include "cmotfile.h"
67
68 class CM16Flash {
69
70 public:
71 CM16Flash(CCOMPort* pPort, unsigned char cuCPUType);
72 ~CM16Flash();
73
74 int initComms();
75 int readPage(CPage* pPage);
76 int readStatusRegisters(unsigned char* pSRD);
77 int clearStatusRegisters();
78 int readVersionInfo(char* pszVersionInfo);
79 int sendID(unsigned int pIDCode[7]);
80 int writePage(CPage* pPage);
81 int eraseBlock(long lAddress);
82 int eraseChip();
83
84 protected:
85 int sendCommandByte(unsigned char ucCommand);
86 int sendByte(unsigned char ucVal);
87
88 CCOMPort* m_pPort;
89
90 unsigned char m_CPUType;
91
92 };
93
94
95