Chipcon refactoring, debugging.
[goodfet] / firmware / include / chipcon.h
1 /*! \file chipcon.h
2   \author Travis Goodspeed
3   \brief Chipcon application functions.
4 */
5
6
7 //Chipcon command definitions.
8 #define CCCMD_CHIP_ERASE 0x14
9 #define CCCMD_WR_CONFIG 0x1D
10 #define CCCMD_RD_CONFIG 0x24
11 #define CCCMD_READ_STATUS 0x34
12 #define CCCMD_GET_CHIP_ID 0x68
13 #define CCCMD_GET_PC 0x28
14 #define CCCMD_HALT 0x44
15 #define CCCMD_RESUME 0x4C
16 #define CCCMD_STEP_INSTR 0x5C
17 #define CCCMD_DEBUG_INSTR 0x54
18
19 //! Erase a chipcon chip.
20 void cc_chip_erase();
21 //! Write the configuration byte.
22 void cc_wr_config(unsigned char config);
23 //! Read the configuration byte.
24 unsigned char cc_rd_config();
25 //! Read the status register.
26 unsigned char cc_read_status();
27 //! Read the CHIP ID bytes.
28 unsigned short cc_get_chip_id();
29 //! Get the PC
30 unsigned short cc_get_pc();
31 //! Set a hardware breakpoint.
32 void cc_set_hw_brkpnt(unsigned short);
33 //! Debug an instruction, for remote use.
34 void cc_debug_instr(unsigned char);
35 //!Read a byte of code memory.
36 unsigned char cc_peekcodebyte(unsigned long adr);
37 //!Read a byte of data memory.
38 unsigned char cc_peekdatabyte(unsigned int adr);
39 //! Set a byte of data memory.
40 unsigned char cc_pokedatabyte(unsigned int adr,
41                               unsigned char val);
42 //! Debug an instruction, for local use.
43 unsigned char cc_debug(unsigned char len,
44                        unsigned char a,
45                        unsigned char b,
46                        unsigned char c);
47
48 //! Halt the CPU.
49 void cc_halt();
50 //! Resume the CPU.
51 void cc_resume();
52 //! Step an instruction
53 void cc_step_instr();
54
55
56 //CHIPCON commands
57 #define CC_CHIP_ERASE 0x80
58 #define CC_WR_CONFIG 0x81
59 #define CC_RD_CONFIG 0x82
60 #define CC_GET_PC 0x83
61 #define CC_READ_STATUS 0x84
62 #define CC_SET_HW_BRKPNT 0x85
63 #define CC_HALT 0x86
64 #define CC_RESUME 0x87
65 #define CC_DEBUG_INSTR 0x88
66 #define CC_STEP_INSTR 0x89
67 #define CC_STEP_REPLACE 0x8a
68 #define CC_GET_CHIP_ID 0x8b
69 //CHIPCON macros
70 #define CC_READ_CODE_MEMORY 0x90
71 #define CC_READ_XDATA_MEMORY 0x91
72 #define CC_WRITE_XDATA_MEMORY 0x92
73 #define CC_SET_PC 0x93
74 #define CC_CLOCK_INIT 0x94
75 #define CC_WRITE_FLASH_PAGE 0x95
76 #define CC_READ_FLASH_PAGE 0x96
77 #define CC_MASS_ERASE_FLASH 0x97
78 #define CC_PROGRAM_FLASH 0x98