| 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"cxx . . $ `<file>/ccomport.h`/ |
| 26 | |
| 27 | #define ADDRESS_HIGHcxx . . $ `cm16flash.h:27:9`!(x) ((x >> 16) & 0xFF) |
| 28 | #define ADDRESS_MIDDLEcxx . . $ `cm16flash.h:28:9`!(x) ((x >> 8) & 0xFF) |
| 29 | #define ADDRESS_LOWcxx . . $ `cm16flash.h:29:9`!(x) ((x) & 0xFF) |
| 30 | |
| 31 | #define M16_CPUcxx . . $ `cm16flash.h:31:9`! 1 |
| 32 | #define R8C_CPUcxx . . $ `cm16flash.h:32:9`! 2 |
| 33 | |
| 34 | /* programmer specific defs */ |
| 35 | #define M16_CONFIRM_CLOCKcxx . . $ `cm16flash.h:35:9`! 0xB0 |
| 36 | #define M16_DELAYcxx . . $ `cm16flash.h:36:9`! 15000 // 15ms |
| 37 | #define M16_READ_PAGEcxx . . $ `cm16flash.h:37:9`! 0xFF |
| 38 | #define M16_PAGE_WRITEcxx . . $ `cm16flash.h:38:9`! 0x41 |
| 39 | #define M16_PAGE_SIZEcxx . . $ `cm16flash.h:39:9`! 256 |
| 40 | #define M16_READ_SRDcxx . . $ `cm16flash.h:40:9`! 0x70 |
| 41 | #define M16_CLEAR_SRDcxx . . $ `cm16flash.h:41:9`! 0x50 |
| 42 | #define M16_READ_VERSION_INFOcxx . . $ `cm16flash.h:42:9`! 0xFB |
| 43 | #define M16_ID_CHECKcxx . . $ `cm16flash.h:43:9`! 0xF5 |
| 44 | #define M16_ID_ADDRESScxx . . $ `cm16flash.h:44:9`! 0x0FFFDF |
| 45 | #define M16_ID_SIZEcxx . . $ `cm16flash.h:45:9`! 0x07 |
| 46 | #define M16_SR11cxx . . $ `cm16flash.h:46:9`! 0x08 |
| 47 | #define M16_SR10cxx . . $ `cm16flash.h:47:9`! 0x04 |
| 48 | #define M16_LOCK_DISABLEcxx . . $ `cm16flash.h:48:9`! 0x75 |
| 49 | #define M16_ERASE_BLOCKcxx . . $ `cm16flash.h:49:9`! 0x20 |
| 50 | #define M16_ERASE_VERIFYcxx . . $ `cm16flash.h:50:9`! 0xD0 |
| 51 | |
| 52 | #define M16_BLOCK_COUNTcxx . . $ `cm16flash.h:52:9`! 7 |
| 53 | #define M16_BLOCK6_BEGINcxx . . $ `cm16flash.h:53:9`! 0x0C0000 |
| 54 | #define M16_BLOCK5_BEGINcxx . . $ `cm16flash.h:54:9`! 0x0D0000 |
| 55 | #define M16_BLOCK4_BEGINcxx . . $ `cm16flash.h:55:9`! 0x0E0000 |
| 56 | #define M16_BLOCK3_BEGINcxx . . $ `cm16flash.h:56:9`! 0x0F0000 |
| 57 | #define M16_BLOCK2_BEGINcxx . . $ `cm16flash.h:57:9`! 0x0F8000 |
| 58 | #define M16_BLOCK1_BEGINcxx . . $ `cm16flash.h:58:9`! 0x0FA000 |
| 59 | #define M16_BLOCK0_BEGINcxx . . $ `cm16flash.h:59:9`! 0x0FC000 |
| 60 | |
| 61 | #define R8C_ID_ADDRESScxx . . $ `cm16flash.h:61:9`! 0x00FFDF |
| 62 | #define R8C_BLOCK_COUNTcxx . . $ `cm16flash.h:62:9`! 2 |
| 63 | #define R8C_BLOCK0_BEGINcxx . . $ `cm16flash.h:63:9`! 0x0E000 |
| 64 | #define R8C_BLOCK1_BEGINcxx . . $ `cm16flash.h:64:9`! 0x0C000 |
| 65 | |
| 66 | #include "cmotfile.h"cxx . . $ `<file>/cmotfile.h`/ |
| 67 | |
| 68 | class CM16Flashcxx . . $ CM16Flash# { |
| 69 | |
| 70 | public: |
| 71 | CM16Flashcxx . . $ CM16Flash#CM16Flash(12ac35f22111cf35).(CCOMPortcxx . . $ CCOMPort#* pPort, unsigned char cuCPUType); |
| 72 | ~cxx . . $ CM16Flash#`~CM16Flash`(ced63f7c635d850d).CM16Flashcxx . . $ CM16Flash#(); |
| 73 | |
| 74 | int initCommscxx . . $ CM16Flash#initComms(b126dc7c1de90089).(); |
| 75 | int readPagecxx . . $ CM16Flash#readPage(e0fa5e7da13f4c7b).(CPagecxx . . $ CPage#* pPage); |
| 76 | int readStatusRegisterscxx . . $ CM16Flash#readStatusRegisters(b2e27cdb9bef2230).(unsigned char* pSRD); |
| 77 | int clearStatusRegisterscxx . . $ CM16Flash#clearStatusRegisters(b126dc7c1de90089).(); |
| 78 | int readVersionInfocxx . . $ CM16Flash#readVersionInfo(1ef8e6ec083aabb9).(char* pszVersionInfo); |
| 79 | int sendIDcxx . . $ CM16Flash#sendID(4ebf403dd87dd80).(unsigned int pIDCode[7]); |
| 80 | int writePagecxx . . $ CM16Flash#writePage(e0fa5e7da13f4c7b).(CPagecxx . . $ CPage#* pPage); |
| 81 | int eraseBlockcxx . . $ CM16Flash#eraseBlock(a9e4e82268fd7bfa).(long lAddress); |
| 82 | int eraseChipcxx . . $ CM16Flash#eraseChip(b126dc7c1de90089).(); |
| 83 | |
| 84 | protected: |
| 85 | int sendCommandBytecxx . . $ CM16Flash#sendCommandByte(b27dbea426b7b93).(unsigned char ucCommand); |
| 86 | int sendBytecxx . . $ CM16Flash#sendByte(b27dbea426b7b93).(unsigned char ucVal); |
| 87 | |
| 88 | CCOMPortcxx . . $ CCOMPort#* m_pPortcxx . . $ CM16Flash#m_pPort.; |
| 89 | |
| 90 | unsigned char m_CPUTypecxx . . $ CM16Flash#m_CPUType.; |
| 91 | |
| 92 | }; |
| 93 | |
| 94 | |
| 95 |