|
发表于 2007-11-9 22:27:03
|
显示全部楼层
S51/52可读FLASH、可读芯片ID码、可加密,现时不能对S51/52写入FLASH。
/* Name: app_cfg.h
* Project: AVRmini
* Author: Simon Qian
* License: will add soon
* Last Update: 2007-11-7 0:40:52
*/
#define AVR_DEVICE_AVRISP_MKII 0x01
#define AVR_DEVICE_JTAGICE_MKII 0x02
#define AVR_DEVICE_AVRDRAGON 0x03
#define AVR_DEVICE_AVRPHENIX 0x80
#define AVRmini 0x10
#define USBASP 0x20
#define HARDWARE_SELECTION AVRmini
#define AVR_DEVICE (AVR_DEVICE_AVRISP_MKII)
#define AVR_DEVICE_ATMEL (AVR_DEVICE & 0x0F)
#define AVR_DEVICE_OFFLINE_EN (AVR_DEVICE & AVR_DEVICE_AVRPHENIX)
/*************************** ADC *****************************/
// devices like USBasp has no AD connected to target VCC,just define AD_En to 0
#define AD_En 0
#define AD_VCC_MUX (ADC_VREF_BANDGAP | ADC_CHANNEL_ADC0)
#define ADVref 11
#define AD_VCC_RATE 5
/*************************** LED *****************************/
#if HARDWARE_SELECTION == USBASP
#define LED_Green (1 << 1)
#define LED_Red (1 << 3)
#define LED_Init() do{PortD_SetPin(LED_Green | LED_Red);PortD_SetOutput(LED_Green | LED_Red);}while(0)
#define LED_On(led) PortD_ClrPin(led)
#define LED_Off(led) PortD_SetPin(led)
#else
#define LED_Green (1 << 0)
#define LED_Red (1 << 1)
#define LED_Init() do{PortC_SetPin(LED_Green | LED_Red);PortC_SetOutput(LED_Green | LED_Red);}while(0)
#define LED_On(led) PortC_ClrPin(led)
#define LED_Off(led) PortC_SetPin(led)
#endif
/*************************** JTAG *****************************/
#define JTAG_TAP_TMS P(6)
#define JTAG_TAP_TCK P(5) // MUST be the same PIN as SPI_SCK
#define JTAG_TAP_TDI P(3) // MUST be the same PIN as SPI_MOSI
#define JTAG_TAP_TDO P(4) // MUST be the same PIN as SPI_MISO
#define JTAG_TAP_TMS_SETOUTPUT() PortD_SetOutput(JTAG_TAP_TMS)
#define JTAG_TAP_TMS_SETINPUT() PortD_SetInput(JTAG_TAP_TMS)
#define JTAG_TAP_TMS_SET() PortD_SetPin(JTAG_TAP_TMS)
#define JTAG_TAP_TMS_CLR() PortD_ClrPin(JTAG_TAP_TMS)
#define JTAG_TAP_TCK_SETOUTPUT() PortB_SetOutput(JTAG_TAP_TCK)
#define JTAG_TAP_TCK_SETINPUT() PortB_SetInput(JTAG_TAP_TCK)
#define JTAG_TAP_TCK_SET() PortB_SetPin(JTAG_TAP_TCK)
#define JTAG_TAP_TCK_CLR() PortB_ClrPin(JTAG_TAP_TCK)
#define JTAG_TAP_TDI_SETOUTPUT() PortB_SetOutput(JTAG_TAP_TDI)
#define JTAG_TAP_TDI_SETINPUT() PortB_SetInput(JTAG_TAP_TDI)
#define JTAG_TAP_TDI_SET() PortB_SetPin(JTAG_TAP_TDI)
#define JTAG_TAP_TDI_CLR() PortB_ClrPin(JTAG_TAP_TDI)
#define JTAG_TAP_TDO_SETINPUT() PortB_SetInput(JTAG_TAP_TDO)
#define JTAG_TAP_TDO_GET() PortB_GetPin(JTAG_TAP_TDO)
#define JTAG_TAP_TDO_SET() PortB_SetPin(JTAG_TAP_TDO)
#define JTAG_TAP_TDO_CLR() PortB_ClrPin(JTAG_TAP_TDO)
/*************************** ISP *****************************/
// SPI Port for ISP(SPI0 Must be used)
#define SPI_MISO P(4)
#define SPI_MOSI P(3)
#define SPI_SCK P(5)
#define SPI_SetMOSIOutput() PortB_SetOutput(SPI_MOSI)
#define SPI_SetMOSIInput() PortB_SetInput(SPI_MOSI)
#define SPI_SetMOSI() PortB_SetPin(SPI_MOSI)
#define SPI_ClrMOSI() PortB_ClrPin(SPI_MOSI)
#define SPI_SetMISOInput() PortB_SetInput(SPI_MISO)
#define SPI_GetMISO() PortB_GetPin(SPI_MISO)
#define SPI_SetSCKOutput() PortB_SetOutput(SPI_SCK)
#define SPI_SetSCKInput() PortB_SetInput(SPI_SCK)
#define SPI_SetSCK() PortB_SetPin(SPI_SCK)
#define SPI_ClrSCK() PortB_ClrPin(SPI_SCK)
#if HARDWARE_SELECTION == USBASP
#define ISP_RST P(7)
#define ISP_SetRST() PortD_SetPin(ISP_RST)
#define ISP_ClrRST() PortD_ClrPin(ISP_RST)
#define ISP_SetRSTOutput() PortD_SetOutput(ISP_RST)
#define ISP_SetRSTInput() PortD_SetInput(ISP_RST)
#else
#define ISP_RST P(2)
#define ISP_SetRST() PortB_SetPin(ISP_RST)
#define ISP_ClrRST() PortB_ClrPin(ISP_RST)
#define ISP_SetRSTOutput() PortB_SetOutput(ISP_RST)
#define ISP_SetRSTInput() PortB_SetInput(ISP_RST)
#endif
/*************************** AVRUSB *****************************/
/* ---------------------------- Hardware Config ---------------------------- */
#if HARDWARE_SELECTION == USBASP
#define USB_CFG_IOPORTNAME D
/* This is the port where the USB bus is connected. When you configure it to
* "B", the registers PORTB, PINB and DDRB will be used.
*/
#define USB_CFG_DMINUS_BIT 4
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
* This may be any bit in the port.
*/
#define USB_CFG_DPLUS_BIT 2
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
* This may be any bit in the port. Please note that D+ must also be connected
* to interrupt pin INT0!
*/
#else
#define USB_CFG_IOPORTNAME B
/* This is the port where the USB bus is connected. When you configure it to
* "B", the registers PORTB, PINB and DDRB will be used.
*/
#define USB_CFG_DMINUS_BIT 0
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
* This may be any bit in the port.
*/
#define USB_CFG_DPLUS_BIT 1
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
* This may be any bit in the port. Please note that D+ must also be connected
* to interrupt pin INT0!
*/
#endif
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
/* Clock rate of the AVR in MHz. Legal values are 12000, 15000, 16000 or 16500.
* The 16.5 MHz version of the code requires no crystal, it tolerates +/- 1%
* deviation from the nominal frequency. All other rates require a precision
* of 2000 ppm and thus a crystal!
* Default if not specified: 12 MHz
*/
/* ----------------------- Optional Hardware Config ------------------------ */
/* #define USB_CFG_PULLUP_IOPORTNAME D */
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
* V+, you can connect and disconnect the device from firmware by calling
* the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
* This constant defines the port on which the pullup resistor is connected.
*/
/* #define USB_CFG_PULLUP_BIT 4 */
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
* above) where the 1.5k pullup resistor is connected. See description
* above for details.
*/
/*************************** KEY *****************************/
#if AVR_DEVICE_USBASP
#define PROGKEY_Pin (1 << 2)
#define PROGKEY_Init() do{PortD_SetPin(PROGKEY_Pin);PortD_SetInput(PROGKEY_Pin);}while(0)
#define PROGKEY_IsDown() PortD_GetPin(PROGKEY_Pin)
#else
#define PROGKEY_Pin (1 << 2)
#define PROGKEY_Init() do{PortC_SetPin(PROGKEY_Pin);PortC_SetInput(PROGKEY_Pin);}while(0)
#define PROGKEY_IsDown() PortC_GetPin(PROGKEY_Pin)
#endif
/*************************** Dataflash *****************************/ |
|