/******************** (C) COPYRIGHT 2012 STMicroelectronics ********************
* File Name : STUARTBLLIB.cpp
* Author : MCD Application Team
* Version : v2.6.0
* Date : 07-November-2012
* Description : Implements the UART boot loader protocol interface
********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
********************************************************************************
* FOR MORE INFORMATION PLEASE CAREFULLY READ THE LICENSE AGREEMENT FILE
* "MCD-ST Liberty SW License Agreement V2.pdf"
*******************************************************************************/
#include <malloc.h>
//#include <mem.h>
#include "stdafx.h"
#include "STUARTBLLIB.h"
/* Options Bytes Areas*/
DWORD ADDR_F1_OPB = 0x1FFFF800;
DWORD ADDR_F2_OPB = 0x1FFFC000;
DWORD ADDR_L1_OPB = 0x1FF80000;
/* STM32F1 Series*/
DWORD ADDR_USER_OPB = 0x1FFFF800;
DWORD ADDR_DATA_OPB = 0x1FFFF804;
DWORD ADDR_RDP_OPB = 0x1FFFF800;
DWORD ADDR_WRP0_OPB = 0x1FFFF808;
DWORD ADDR_WRP2_OPB = 0x1FFFF80C;
DWORD MAX_DATA_SIZE = 0xFF; // Packet size(in byte)
BYTE ACK = 0x79 ;
BYTE NACK = 0x1F ;
ACKS ACK_VALUE = ST79;
LPTARGET_DESCRIPTOR Target;
CRS232 Cur_COM;
ACKS McuTarget;
DWORD Progress;
DWORD ActivityTime ;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH :{
McuTarget = UNDEFINED;
Target = (LPTARGET_DESCRIPTOR)malloc(sizeof(TARGET_DESCRIPTOR));
Target->Version = 0x00;
Target->CmdCount = 0x00;
Target->PIDLen = 0x00;
Target->PID = (LPBYTE)malloc(1);
Target->ROPE = 0x00;
Target->ROPD = 0x00;
Target->GET_CMD = FALSE ; //Get the version and the allowed commands supported by the current version of the boot loader
Target->GET_VER_ROPS_CMD = FALSE ; //Get the BL version and the Read Protection status of the NVM
Target->GET_ID_CMD = FALSE ; //Get the chip ID
Target->READ_CMD = FALSE ; //Read up to 256 bytes of memory starting from an address specified by the user
Target->GO_CMD = FALSE ; //Jump to an address specified by the user to execute (a loaded) code
Target->WRITE_CMD = FALSE ; //Write maximum 256 bytes to the RAM or the NVM starting from an address specified by the user
Target->ERASE_CMD = FALSE ; //Erase from one to all the NVM sectors
Target->ERASE_EXT_CMD = FALSE ; //Erase from one to all the NVM sectors
Target->WRITE_PROTECT_CMD = FALSE ; //Enable the write protection in a permanent way for some sectors
Target->WRITE_TEMP_UNPROTECT_CMD = FALSE ; //Disable the write protection in a temporary way for all NVM sectors
Target->WRITE_PERM_UNPROTECT_CMD = FALSE ; //Disable the write protection in a permanent way for all NVM sectors
Target->READOUT_PERM_PROTECT_CMD = FALSE ; //Enable the readout protection in a permanent way
Target->READOUT_TEMP_UNPROTECT_CMD = FALSE ; //Disable the readout protection in a temporary way
Target->READOUT_PERM_UNPROTECT_CMD = FALSE ; //Disable the readout protection in a permanent way
}break;
case DLL_THREAD_ATTACH :{
/*McuTarget = UNDEFINED;
Target = (LPTARGET_DESCRIPTOR)malloc(sizeof(TARGET_DESCRIPTOR));
Target->Version = 0x00;
Target->CmdCount = 0x00;
Target->PIDLen = 0x00;
Target->PID = (LPBYTE)malloc(1);
Target->ROPE = 0x00;
Target->ROPD = 0x00;
Target->GET_CMD = FALSE ; //Get the version and the allowed commands supported by the current version of the boot loader
Target->GET_VER_ROPS_CMD = FALSE ; //Get the BL version and the Read Protection status of the NVM
Target->GET_ID_CMD = FALSE ; //Get the chip ID
Target->READ_CMD = FALSE ; //Read up to 256 bytes of memory starting from an address specified by the user
Target->GO_CMD = FALSE ; //Jump to an address specified by the user to execute (a loaded) code
Target->WRITE_CMD = FALSE ; //Write maximum 256 bytes to the RAM or the NVM starting from an address specified by the user
Target->ERASE_CMD = FALSE ; //Erase from one to all the NVM sectors
Target->WRITE_PROTECT_CMD = FALSE ; //Enable the write protection in a permanent way for some sectors
Target->WRITE_TEMP_UNPROTECT_CMD = FALSE ; //Disable the write protection in a temporary way for all NVM sectors
Target->WRITE_PERM_UNPROTECT_CMD = FALSE ; //Disable the write protection in a permanent way for all NVM sectors
Target->READOUT_PERM_PROTECT_CMD = FALSE ; //Enable the readout protection in a permanent way
Target->READOUT_TEMP_UNPROTECT_CMD = FALSE ; //Disable the readout protection in a temporary way
Target->READOUT_PERM_UNPROTECT_CMD = FALSE ; //Disable the readout protection in a permanent way
*/}break;
case DLL_THREAD_DETACH :{}break;
case DLL_PROCESS_DETACH :{}break;
}
return TRUE;
}
/************************************************************************************/
/* SET COMMUNICATION INTERFACE TYPE
/* UART - ...
/*
/************************************************************************************/
STUARTBLLIB_API BYTE TARGET_SetComIntType(BYTE com_int_type)
{
return 0;
}
/************************************************************************************/
/*
/*
/*
/************************************************************************************/
STUARTBLLIB_API BYTE SetCOMSettings(int numPort, long speedInBaud, int nbBit,
int parity, float nbStopBit)
{
if (Cur_COM.isConnected) return COM_ALREADY_OPENED;
if(numPort<1 || numPort>99)
return INPUT_PARAMS_ERROR;
if(speedInBaud<1)
return INPUT_PARAMS_ERROR;
if(nbBit<5 || nbBit > 9)
return INPUT_PARAMS_ERROR;
if(parity<0 || parity > 2)
return INPUT_PARAMS_ERROR;
if(nbStopBit<1 || nbStopBit > 2)
return INPUT_PARAMS_ERROR;
Cur_COM.numPort = numPort;
Cur_COM.speedInBaud = speedInBaud;
Cur_COM.nbBit = nbBit;
Cur_COM.parity = parity;
Cur_COM.nbStopBit = nbStopBit;
return SUCCESS;
}
STUARTBLLIB_API BYTE Send_RQ(LPSTBL_Request pRQ)
{
BYTE DataSize = 1;
if (!Cur_COM.isConnected) return NO_CON_AVAILABLE;
if (!Target) Target = (LPTARGET_DESCRIPTOR)malloc(sizeof(TARGET_DESCRIPTOR));
LPBYTE RQ_Buffer = (LPBYTE) malloc(2);
// put command code in the buffer
RQ_B
没有合适的资源?快使用搜索试试~ 我知道了~
STMFlashLoader源码
共203个文件
stmap:118个
s19:20个
h:18个
5星 · 超过95%的资源 需积分: 23 35 下载量 79 浏览量
2014-07-31
23:29:27
上传
评论
收藏 1021KB ZIP 举报
温馨提示
STM公司出品的STM32F10X系列CPU串口下载软件STMFlashLoader的源码
资源推荐
资源详情
资源评论
收起资源包目录
STMFlashLoader源码 (203个子文件)
Default.conf 2KB
Default.conf 2KB
STUARTBLLIB.cpp 66KB
STMFlashLoader.cpp 58KB
image.cpp 38KB
STBLLIB.cpp 35KB
Ini.cpp 30KB
Ini.cpp 30KB
STFILE.CPP 14KB
rs232.cpp 10KB
Files.cpp 10KB
StdAfx.cpp 306B
StdAfx.cpp 298B
StdAfx.cpp 298B
StdAfx.cpp 209B
Files.def 522B
Files.dll 1.38MB
STUARTBLLIB.dll 284KB
STBLLIB.dll 276KB
Files.dll 164KB
STUARTBLLIB.dll 76KB
STBLLIB.dll 68KB
Files.dsp 5KB
STUARTBLLIB.dsp 4KB
STBLLIB.dsp 4KB
STMFlashLoader.dsp 4KB
STMicroelectronics Flash Loader project.dsw 1KB
STUARTBLLIB.h 23KB
STBLLIB.h 23KB
Ini.h 9KB
Ini.h 8KB
Files.h 4KB
rs232.h 4KB
STFILE.H 3KB
Image.h 3KB
Errors.h 2KB
FilesInc.h 2KB
StdAfx.h 1KB
StdAfx.h 698B
StdAfx.h 667B
StdAfx.h 667B
resource.h 418B
resource.h 415B
resource.h 411B
Resource.h 409B
STUARTBLLIB.lib 12KB
STUARTBLLIB.lib 12KB
STBLLIB.lib 11KB
STBLLIB.lib 11KB
Files.lib 5KB
Files.lib 5KB
Files.rc 3KB
STUARTBLLIB.rc 3KB
STBLLIB.rc 3KB
STMFlashLoader.rc 2KB
Files.rc2 397B
STUARTBLLIB.res 984B
STUARTBLLIB.res 984B
STBLLIB.res 984B
STBLLIB.res 984B
E_W_ROUTINEs_128K_ver_2.1.s19 1016B
E_W_ROUTINEs_128K_ver_2.1.s19 1016B
E_W_ROUTINEs_256K_ver_1.0.s19 896B
E_W_ROUTINEs_256K_ver_1.0.s19 896B
E_W_ROUTINEs_32K_ver_1.2.s19 882B
E_W_ROUTINEs_32K_ver_1.3.s19 882B
E_W_ROUTINEs_32K_ver_1.2.s19 882B
E_W_ROUTINEs_32K_ver_1.3.s19 882B
E_W_ROUTINEs_32K_ver_1.4.s19 848B
E_W_ROUTINEs_128K_ver_2.2.s19 848B
E_W_ROUTINEs_128K_ver_2.4.s19 848B
E_W_ROUTINEs_32K_ver_1.4.s19 848B
E_W_ROUTINEs_128K_ver_2.2.s19 848B
E_W_ROUTINEs_128K_ver_2.4.s19 848B
E_W_ROUTINEs_128K_ver_2.0.s19 764B
E_W_ROUTINEs_128K_ver_2.0.s19 764B
E_W_ROUTINEs_32K_ver_1.0.s19 638B
E_W_ROUTINEs_32K_ver_1.0.s19 638B
E_W_ROUTINEs_32K_verL_1.0.s19 0B
E_W_ROUTINEs_32K_verL_1.0.s19 0B
STMicroelectronics Flash Loader project.sln 3KB
STM32L_High-density-384K.STmap 134KB
STM32L_High-density-384K.STmap 134KB
STM32L_High-density-256K.STmap 89KB
STM32L_High-density-256K.STmap 89KB
STM32L_Med-density-Plus-256K.STmap 89KB
STM32L_Med-density-Plus-256K.STmap 89KB
STM32_XL-density_768K.STmap 67KB
STM32_XL-density_768K.STmap 67KB
STM32_XL-density_1024K.STmap 45KB
STM32_XL-density_1024K.STmap 45KB
STM32L_Med-density-128K.STmap 43KB
STM32L_Med-density-128K.STmap 43KB
STM32_High-density-value_512K.STmap 23KB
STM32_High-density-value_512K.STmap 23KB
STM32_High-density_512K.STmap 23KB
STM32_High-density_512K.STmap 23KB
STM32L_Med-density-64K.STmap 22KB
STM32L_Med-density-64K.STmap 22KB
STM32_High-density-value_384K.STmap 17KB
共 203 条
- 1
- 2
- 3
资源评论
- ZD7393746632014-10-16二次开发一下还行,不错。
- lingzhi02022016-08-29作为例程进行二次开发
普通网友
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功