2 \author Alexey Borisenko <abori021@uottawa.ca>
3 \brief Definitions for Silicon Lab C2 debugging application
4 NOTE: FPDAT register address can be different, based on the device
5 Current address is meant for the 8051f34x
19 #define SETC2CK P3OUT |= C2CK
20 #define CLRC2CK P3OUT &= ~C2CK
21 #define SETC2D P3OUT |= C2D
22 #define CLRC2D P3OUT &= ~C2D
24 #define READC2D (P3IN&C2D?1:0)
26 #define C2CKOUTPUT P3DIR|=C2CK
27 #define C2D_DriverOff P3DIR&=~C2D
28 #define C2D_DriverOn P3DIR|=C2D
30 #define DATA_READ 0x00
31 #define ADDR_READ 0x02
32 #define DATA_WRITE 0x01
33 #define ADDR_WRITE 0x03
36 #define FLASH_SIZE 65536 // FLASH size in bytes
37 #define NUM_PAGES FLASH_SIZE/512 // Number of 512-byte FLASH pages
39 // C2 status return codes
40 #define INVALID_COMMAND 0x00
41 #define COMMAND_FAILED 0x02
42 #define COMMAND_OK 0x0D
44 // C2 interface commands
45 #define GET_VERSION 0x01
46 #define BLOCK_READ 0x06
47 #define BLOCK_WRITE 0x07
48 #define PAGE_ERASE 0x08
49 #define DEVICE_ERASE 0x03
58 #define Poll_OutReady while(!(C2_ReadAR()&0x01))
59 #define Poll_InBusy while((C2_ReadAR()&0x02))
60 #define StrobeC2CK CLRC2CK; SETC2CK
69 void slc2_handle_fn( uint8_t const app,
73 extern app_t const slc2_app;
75 // FLASH programming functions
77 unsigned char C2_GetDevID(void);
78 char C2_BlockRead(void);
79 char C2_BlockWrite(void);
80 char C2_PageErase(void);
81 char C2_DeviceErase(void);
82 // Primitive C2 functions
84 void C2_WriteAR(unsigned char);
85 unsigned char C2_ReadAR(void);
86 void C2_WriteDR(unsigned char);
87 unsigned char C2_ReadDR(void);
88 unsigned char C2_ReadDeviceID(void);
89 unsigned char C2_ReadRevID(void);