forked from MSP-EricLoeffler/MSPBSL_Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.cpp
76 lines (59 loc) · 2.66 KB
/
Test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// this file is just for testing!
#include "stdafx.h"
#include <boost/thread.hpp>
#include <string>
#include <fstream>
#include <streambuf>
#include "MSPBSL_PhysicalInterfaceSerialUART.h"
#include "MSPBSL_Connection5xxUSB.h"
#include "MSPBSL_PacketHandler5xxUART.h"
#include "MSPBSL_PacketHandler1xx_2xx_4xxUART.h"
#include "MSPBSL_Factory.h"
#include "MSPBSL_Connection5xxUART.h"
#include "MSPBSL_Connection1xx_2xx_4xx.h"
#include "MSPBSL_Connection_v1_10.h"
#include "MSPBSL_ConnectionFRAMFamily.h"
#include "MSPBSL_CRCEngine.h"
#include "MSPBSL_Connection_v1_6x.h"
#include "MSPBSL_Connection_v2_xx.h"
#include "MSPBSL_Connection_v2_1x.h"
#include "MSPBSL_Connection_v1_4x.h"
#include "MSPBSL_Connection_v1_3x.h"
#define STANDARD_INVOKE 0x01
#define BSL_XXXX_INVOKE 0x02
int _tmain(int argc, _TCHAR* argv[])
{
uint32_t i,j;
string initString = "DEVICE:MSP430F1232";
MSPBSL_Connection* theBSLConnection = MSPBSL_Factory::getMSPBSL_Connection(initString);
((theBSLConnection->getPacketHandler())->getPhysicalInterface())->invokeBSL();
//Example for getting a connection manually (without Factory)
//string initString = " COM:COM1 BAUD:9600 PARITY:EVEN INVOKE:1 ";
//MSPBSL_PhysicalInterfaceSerialUART* s = new MSPBSL_PhysicalInterfaceSerialUART( initString ); // Parity handled in object;
//MSPBSL_PacketHandler1xx_2xx_4xxUART* p = new MSPBSL_PacketHandler1xx_2xx_4xxUART( initString );
//MSPBSL_Connection_v1_4x* theBSLConnection = new MSPBSL_Connection_v1_4x( initString );
//p->setPhysicalInterface( s );
//theBSLConnection->setPacketHandler(p);
//some buffers for testing
uint8_t databuf[0x20000];
uint8_t returnbuf[0x20000];
string returnbuf2;
for(i=0; i<0x20000; i++)
databuf[i]=(0x00FF & i);
for(i=0; i<0x20000; i++)
returnbuf[i]=(0);
//some example commands
i=((MSPBSL_Connection_v1_6x*)theBSLConnection)->massErase();
i=((MSPBSL_Connection_v1_6x*)theBSLConnection)->RX_Password();
i=((MSPBSL_Connection_v1_6x*)theBSLConnection)->RX_DataBlock(databuf, 0x0021C, 0x2);
i=((MSPBSL_Connection_v1_6x*)theBSLConnection)->loadFile("parser_testfile.txt");
i=((MSPBSL_Connection_v1_6x*)theBSLConnection)->TX_DataBlock(databuf, 0x9000, 0x11000);
i=theBSLConnection->TX_DataBlock(returnbuf, 0x0FFA, 2);
i=theBSLConnection->RX_DataBlock(databuf, 0xE000, 0x0200);
i=((MSPBSL_Connection_v2_1x*)theBSLConnection)->eraseCheck(0xE008, 8);
i=theBSLConnection->TX_DataBlock(returnbuf, 0x0E140, 8);
i=((MSPBSL_Connection_v2_1x*)theBSLConnection)->eraseSegment(0xE000);
i=((MSPBSL_Connection_v2_1x*)theBSLConnection)->eraseInfoMain(0xFFFF);
i=((MSPBSL_Connection_v2_1x*)theBSLConnection)->changeBaudrate(0x80, 0x85, 0x00);
return 0;
}