123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- /**
- ******************************************************************************
- * @file eeprom.h
- * @author Vincent
- * @version V1.0.0
- * @date 23-12-2015
- * @brief AT24C02 eeprom read and write function.
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
- /* Define to prevent recursive inclusion -------------------------------------*/
- #ifndef __PROTOCOL_H__
- #define __PROTOCOL_H__
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f1xx_hal.h"
- /* Define to variables declare---------------------------------------------------*/
- //通信协议命令字
- //#ifdef HEAD1
- //#define PRO_HEAD1 HEAD1
- //#else
- //#define PRO_HEAD1 1
- //#endif
- //#ifdef HEAD1
- //#define PRO_HEAD2 HEAD2
- //#else
- //#define PRO_HEAD2 2
- //#endif
- #define FRAME_HEAD1 0x55
- #define FRAME_HEAD2 0xAA
- #define PRO_HEAD1 0x55
- #define PRO_HEAD2 0xAA
- #define PRO_TAIL 0xF0 //帧尾
- #define FRAME_MODE_WRITE 0x16
- #define FILE_HEAD 0x01 //文件头
- #define FILE_BODY 0x02 //文件体
- #define FILE_TAIL 0x03 //文件体
- #define CMD_UPDATA 0xA10B
- #define CMD_PACKAGE_INFO 0xA204
- #define CMD_PACKAGE_DATA 0xA385
- #define CMD_UPDATA_END 0xA401
- #define CMD_BOOT_INFO 0xC109
- #define CMD_ACK_OK 0xC202
- #define CMD_ACK_ERR 0xC302
- #define CMD_ACK_REQ 0xC402
- #define CMD_ACK_EOT 0xC502
- #define CMD_ACK_ERR_FLASH 0xC602
- #define ACK_OK 0x06 //应答确认
- #define ACK_ERROR 0x15 //文件错误
- #define MODEM_CANCLE 0x18 //取消传输
- #define ACK_REQ 0x43 //请求传输
- #define PACKET_128B_SIZE ((uint8_t)128)
- #define PACKET_1K_SIZE ((uint16_t)1024)
- #define PACKET_128B_TOTAL_SIZE (PACKET_128B_SIZE+PACKET_OVERHEAD)
- #define PACKET_1K_TOTAL_SIZE (PACKET_1K_SIZE+PACKET_OVERHEAD)
- #define FRAME_HEAD ((uint8_t)6)
- #define FRAME_TRAIL ((uint8_t)5)
- #define FRAME_HEAD_TRAIL (FRAME_HEAD + FRAME_TRAIL)
- #define PACKAGE_DATA_HEAD ((uint8_t)5)
- #define FRAME_DATA_SIZE (PACKET_128B_SIZE + PACKAGE_DATA_HEAD + FRAME_HEAD_TRAIL)
- /**************************************************************************/
- #define FILE_HEAD 0x01 //文件头
- #define FILE_BODY 0x02 //文件体
- #define FILE_TAIL 0x03 //文件体
- #define ACK_OK 0x06 //应答确认
- #define ACK_ERROR 0x15 //文件错误
- #define MODEM_CANCLE 0x18 //取消传输
- #define ACK_REQ 0x43 //请求传输
- #define PACKET_HEADER ((uint8_t)5)
- #define PACKET_TRAILER ((uint8_t)3)
- #define PACKET_OVERHEAD (PACKET_HEADER + PACKET_TRAILER)
- #define PACKET_128B_SIZE ((uint8_t)128)
- #define PACKET_1K_SIZE ((uint16_t)1024)
- #define PACKET_128B_TOTAL_SIZE (PACKET_128B_SIZE+PACKET_OVERHEAD)
- #define PACKET_1K_TOTAL_SIZE (PACKET_1K_SIZE+PACKET_OVERHEAD)
- /*************************************************************************/
- /* Private variables declare---------------------------------------------------*/
- extern uint16_t __CC(uint8_t* ucDataBuf,uint32_t size);
- /*Private function declare---------------------------------------------------*/
- #endif /*__PROTOCOL_H__ */
- /*---------------------------- file end -------------------------------------*/
|