forked from SoCXin/CH579
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
239 changed files
with
45,510 additions
and
1,687 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/********************************** (C) COPYRIGHT ******************************* | ||
* File Name : ota.h | ||
* Author : WCH | ||
* Version : V1.10 | ||
* Date : 2018/12/14 | ||
* Description : oad相关配置定义 | ||
*******************************************************************************/ | ||
|
||
|
||
/******************************************************************************/ | ||
#ifndef __OTA_H | ||
#define __OTA_H | ||
|
||
|
||
/* ------------------------------------------------------------------------------------------------ | ||
* OTA FLASH | ||
* ------------------------------------------------------------------------------------------------ | ||
*/ | ||
|
||
/* 整个用户code区分成三块,120K,120K,10K,下面分别叫做imageA(用户代码),imageB (备份代码)和imageIAP*/ | ||
|
||
/* FLASH定义 */ | ||
#define FLASH_BLOCK_SIZE 512 | ||
#define IMAGE_SIZE 120*1024 | ||
|
||
/* imageA定义 */ | ||
#define IMAGE_A_FLAG 0x01 | ||
#define IMAGE_A_START_ADD 0 | ||
#define IMAGE_A_SIZE IMAGE_SIZE | ||
#define IMAGE_A_ENTRY_ADD (IMAGE_A_START_ADD + 4) | ||
|
||
/* imageB定义 */ | ||
#define IMAGE_B_FLAG 0x02 | ||
#define IMAGE_B_START_ADD (IMAGE_A_START_ADD + IMAGE_SIZE) | ||
#define IMAGE_B_SIZE IMAGE_SIZE | ||
#define IMAGE_B_ENTRY_ADD (IMAGE_B_START_ADD + 4) | ||
|
||
/* imageIAP定义 */ | ||
#define IMAGE_IAP_FLAG 0x03 | ||
#define IMAGE_IAP_START_ADD (IMAGE_B_START_ADD + IMAGE_SIZE) | ||
#define IMAGE_IAP_SIZE 10*1024 | ||
#define IMAGE_IAP_ENTRY_ADD (IMAGE_IAP_START_ADD + 4) | ||
|
||
/* IAP定义 */ | ||
/* 以下为IAP下载命令定义 */ | ||
#define CMD_IAP_PROM 0x80 // IAP编程命令 | ||
#define CMD_IAP_ERASE 0x81 // IAP擦除命令 | ||
#define CMD_IAP_VERIFY 0x82 // IAP校验命令 | ||
#define CMD_IAP_END 0x83 // IAP结束标志 | ||
#define CMD_IAP_INFO 0x84 // IAP获取设备信息 | ||
|
||
|
||
/* 数据帧长度定义 */ | ||
#define IAP_LEN 20 | ||
|
||
/* 存放在DataFlash地址,不能占用蓝牙的位置 */ | ||
#define OTA_DATAFLASH_ADD 0x0003E800 | ||
|
||
|
||
/* 存放在DataFlash里的OTA信息 */ | ||
typedef struct | ||
{ | ||
unsigned char ImageFlag; //记录的当前的image标志 | ||
unsigned char Revd[3]; | ||
}OTADataFlashInfo_t; | ||
|
||
/* OTA IAP通讯协议定义 */ | ||
/* 地址使用4倍偏移 */ | ||
typedef union | ||
{ | ||
struct | ||
{ | ||
unsigned char cmd; /* 命令码 0x81 */ | ||
unsigned char len; /* 后续数据长度 */ | ||
unsigned char addr[2]; /* 擦除地址 */ | ||
unsigned char block_num[2]; /* 擦除块数 */ | ||
|
||
} erase; /* 擦除命令 */ | ||
struct | ||
{ | ||
unsigned char cmd; /* 命令码 0x83 */ | ||
unsigned char len; /* 后续数据长度 */ | ||
unsigned char status[2]; /* 两字节状态,保留 */ | ||
} end; /* 结束命令 */ | ||
struct | ||
{ | ||
unsigned char cmd; /* 命令码 0x82 */ | ||
unsigned char len; /* 后续数据长度 */ | ||
unsigned char addr[2]; /* 校验地址 */ | ||
unsigned char buf[IAP_LEN-4]; /* 校验数据 */ | ||
} verify; /* 校验命令 */ | ||
struct | ||
{ | ||
unsigned char cmd; /* 命令码 0x80 */ | ||
unsigned char len; /* 后续数据长度 */ | ||
unsigned char addr[2]; /* 地址 */ | ||
unsigned char buf[IAP_LEN-4]; /* 后续数据 */ | ||
} program; /* 编程命令 */ | ||
struct | ||
{ | ||
unsigned char cmd; /* 命令码 0x84 */ | ||
unsigned char len; /* 后续数据长度 */ | ||
unsigned char buf[IAP_LEN-2]; /* 后续数据 */ | ||
} info; /* 编程命令 */ | ||
struct | ||
{ | ||
unsigned char buf[IAP_LEN]; /* 接收数据包*/ | ||
} other; | ||
} OTA_IAP_CMD_t; | ||
|
||
|
||
/* 记录当前的Image */ | ||
extern unsigned char CurrImageFlag; | ||
|
||
|
||
#endif | ||
|
||
/******************************** endfile @ oad ******************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/********************************** (C) COPYRIGHT ******************************* | ||
* File Name : peripheral.h | ||
* Author : WCH | ||
* Version : V1.0 | ||
* Date : 2018/12/11 | ||
* Description : | ||
*******************************************************************************/ | ||
|
||
#ifndef PERIPHERAL_H | ||
#define PERIPHERAL_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
/********************************************************************* | ||
* INCLUDES | ||
*/ | ||
|
||
/********************************************************************* | ||
* CONSTANTS | ||
*/ | ||
|
||
|
||
// Simple BLE Peripheral Task Events | ||
#define SBP_START_DEVICE_EVT 0x0001 | ||
#define SBP_PERIODIC_EVT 0x0002 | ||
#define OTA_FLASH_ERASE_EVT 0x0004 //OTA Flash²Á³ýÈÎÎñ | ||
|
||
|
||
|
||
/********************************************************************* | ||
* MACROS | ||
*/ | ||
|
||
/********************************************************************* | ||
* FUNCTIONS | ||
*/ | ||
|
||
/* | ||
* Task Initialization for the BLE Application | ||
*/ | ||
extern void Peripheral_Init( void ); | ||
|
||
/* | ||
* Task Event Processor for the BLE Application | ||
*/ | ||
extern uint16 Peripheral_ProcessEvent( uint8 task_id, uint16 events ); | ||
|
||
/********************************************************************* | ||
*********************************************************************/ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.