⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 download._h

📁 单片机中的中断处理模块
💻 _H
字号:



/* Function numbers for message which download mode must support: */ /*05.12.20.att*/
#define MID1_OLD_ERASE		3   /* Old DDEC3 block erase function */
#define MID1_MEMORY_READ	4   /* Read (and return) memory contents */
#define MID1_MEMORY_WRITE	5   /* Write message bytes to memory */
#define MID1_MEMORY_CHECKSUM 6   /* Calculate a 2-byte checksum */
#define MID1_BOOT_UPDATE	7   /* UPDATE BOOT tao_add07.01.26*/
#define MID1_VECTOR_BOOT	10  /* Vector to BOOT ROM *///download mode
#define MID1_FACTOTY_TEST	11  /* Execute 'Factory Test' code change tao1012*/
#define MID1_VECTOR_MAIN    12  /* Execute main program change tao1012*/
#define MID1_BLOCK_WRITE	14  /* Clear/fill bytes in memory */
#define MID1_COPY		15  /* Copy bytes from/to in memory */
#define MID1_VECTOR_ADDRESS	16  /* Execute code from address supplied */
#define MID1_BLOCK_ERASE	17  /* FRAM block/total erase command */
#define MID1_CHANGE_BAUD	21  /* Change J1708 bus baud-rate. */
#define MID1_COMPLETED_PROGRAMMING  22	/* Commit page buffer to int. FRAM */
#define MID1_REQUEST_BOOT_VERSION   23	/* Return versions of h/w and s/w */
#define MID1_DOWNLOAD_START	24  /* Execute 'Factory Test' code change tao1012*/
#define MID1_DOWNLOAD_END 25  /* Execute main program change tao1012*/

/*
 * Maximum length of a J1708 message that can be received in download mode,
 */
#define J1708_MAX_MSG_LEN	(40)

/* Length of a J1708 global response message, including the checksum. */
#define J1708_GBL_MSG_LEN	(5)

#define J1708_ERR_MSG_LEN	(7)
#define J1708_ERR_MSG_NUM	(9)

/* Message IDs used by the Controller in download mode. */
#define SYSTEM_REQUEST_MID	1
#define SYSTEM_RESPONSE_MID	2

/*
 * The following macros give the number of bytes before and after the data in
 * a J1708 message.
 */
#define J1708_HEADER_SIZE	(2)	/* Bytes in message pre-amble */
#define J1708_CHECKSUM_SIZE	(1)	/* Message checksum byte */


/* Decoding received messages */
#define DECODE_START_ADDRESS(msg) \
	(((UNS32)(msg)[3] << 16) | ((UNS32)(msg)[4] << 8) | (UNS32)(msg)[5])
#define DECODE_END_ADDRESS(msg) \
	(((UNS32)(msg)[6] << 16) | ((UNS32)(msg)[7] << 8) | (UNS32)(msg)[8])


/*
 * The state machine which implements download mode on the J1708 serial bus
 * uses the following macros for the states.
 */

typedef enum
{   	
    CM_DOWNLOAD,		/* This corresponds to the state UNSYCHRONISED */
    CM_MSG,		/* This corresponds to the state IDLE */
} J1708_STATE;

typedef  enum	/* Status of memory-handling functions */
{
    FUNC_SUCCESSFUL = 0,    /* The memory access was handled successfully */
    FUNC_FAILED_NON_DESCRIPT = 1,   /* Did not complete successfully */
    FUNC_BOOT_OVERWRITE = 5,	/* Mem access attempted to alter boot code */
    FUNC_FAILED_NO_VPP = 253,	/* Mem access failed: no programming voltage*/
    FUNC_FAILED_DEV_FAULT = 254, /* Mem access failed due to a device fault*/
    FUNC_FRAM_STILL_ERASING = 255   /* Mem erase is not yet completed */
} BR_STATUS;

/*
 * The following structure is used to buffer J1708 messages during
 * transmit and receive:
 */
typedef struct
{
    /*
     * next_byte has two interpretations; the location in the array data for
     * the next byte received or to be transmitted, and the number of bytes
     * currently received or transmitted.
     */
    UNS8 next_byte;

    /* msg_length holds the total number of bytes in the message. */
    UNS8 msg_length;

    /* data[] is an array used to store a J1708 message. */
    UNS8 data[J1708_MAX_MSG_LEN];

} MESSAGE_J1708;


J1708_STATE process_j1708_message (			/*05.12.30.att----MID1_VECTOR_MAIN*/  
UNS8 *message,	    /* The message to process */
UNS8 msg_length	    /* The length of the message */
);

void queue_j1708_message (
UNS8 *msg_buffer,	/* Message is stored here */
UNS8 msg_length		/* Length of the message in bytes */
);

void global_j1708_response (
UNS8 function_no,   /* The two parameters are stored as part of the message */
BR_STATUS status
);

UNS8 j1708_checksum (UNS8 * message, int length);


BR_STATUS memory_write_bytes (
UNS8* src_ptr,      /* Address of data to write from */
UNS32 dest_addr,    /* Destination address to write to */
UNS32 length       /* In bytes */
);

BR_STATUS memory_erase_bytes (
UNS32 src_ptr     /* Address of data to write from */
);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -