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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
#include <stdio.h>
#include <windows.h>
#include "portcom.h"
#define true (1)
#define false (0)
#define EEPROM_ADRS 0XB600
#define ROM_ADRS 0XD000
#define EEPROM_SIZE 512
#define ROM_SISE 12288
#define Write_EEPROM 0X57
#define Read_EEPROM 0X52
DCB dcb;
HANDLE hCom;
//DWORD voir;
//FILE *file;
COMSTAT Rstatus;
COMMTIMEOUTS CT;
unsigned char Buffer[1000] = {0};
unsigned char BootLoader[] = { /* chargeur pour micro motorola MC68HC11E9 */
0xCE,0x10,0x00,0x6F,0x2C,0x86,0x30,0xA7,0x2B,0x86,0x0C,0xA7,0x2D,0x6F,0x35,0x86,
0x10,0x8D,0x41,0x4A,0x26,0xFB,0x86,0xA5,0xA7,0x2F,0x1F,0x2E,0x20,0xFC,0xA6,0x2F,
0x81,0x52,0x27,0x4C,0x81,0x57,0x27,0x02,0x20,0xF0,0x8D,0x4A,0x1F,0x2E,0x20,0xFC,
0xA6,0x2F,0xC6,0x16,0xE7,0x3B,0x18,0xE7,0x00,0xC6,0x17,0xE7,0x3B,0x8D,0x15,0x6F,
0x3B,0xC6,0x02,0xE7,0x3B,0x18,0xA7,0x00,0xC6,0x03,0xE7,0x3B,0x8D,0x06,0x6F,0x3B,
0x8D,0x14,0x20,0xC6,0x36,0xEC,0x0E,0xC3,0x9C,0x40,0xED,0x1C,0x86,0x10,0xA7,0x23,
0x1F,0x23,0x10,0xFC,0x32,0x39,0x1F,0x2E,0x80,0xFC,0x18,0xA6,0x00,0xA7,0x2F,0x39,
0x8D,0x04,0x8D,0xF2,0x20,0xA4,0x1F,0x2E,0x20,0xFC,0xA6,0x2F,0x1F,0x2E,0x20,0xFC,
0xE6,0x2F,0x18,0x8F,0x39,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
int main(void)
{
/*
file = fopen("c:\BootLoader.bin","rb");
if(file != NULL){
fgets(Buffer,256,file);
}*/
hCom = CreateFile("COM1",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,0, NULL);
if (hCom == 0 )
{
printf ("Error CreatFile Fonction !\n");
}
/*la re mis a zero de structures */
ZeroMemory(&Rstatus, sizeof(COMSTAT));
ZeroMemory(&CT, sizeof(COMMTIMEOUTS));
ZeroMemory(&dcb, sizeof(DCB));
dcb.DCBlength = sizeof(DCB);
/*----------------------------------------*/
/* initial structure COMMTIMEOUTS */
CT.ReadTotalTimeoutMultiplier = 4;
CT.ReadTotalTimeoutConstant = 200;
CT.WriteTotalTimeoutMultiplier = 20;
CT.WriteTotalTimeoutConstant = 200;
if(! SetCommTimeouts(hCom,&CT))
{
printf("Erreur init COMMTIMEOUTS Structure !\n");
return false;
}
/*-------------------------------------------------------------*/
if(!SetupComm(hCom,1000,1000))
{
printf("Erreur number de buffers d'Entrée et Sortie !\n");
}
/*-------------------------------------------------------*/
// Initialize the DCB structure.
if(!GetCommState(hCom, &dcb))
{
printf("Erreur GetCommState Fonction !\n");
}
/* initial Structure DCB */
dcb.BaudRate = CBR_600;
dcb.ByteSize = 8;
dcb.fBinary = 1;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
dcb.fRtsControl = RTS_CONTROL_TOGGLE;
if(!SetCommState(hCom, &dcb))
{
printf("Erreur SetCommState Fonction !\n");
}
/*----------------------------------------------------------------*/
/* if(!SetRTS(1))
{
printf("Erreur de remis a zero de la Pin RTS !\n");
}
printf("RTS = 0 !\n");
if(!SetRTS(0))
{
printf("Erreur de Positionnement de la Pin RTS !\n");
}
printf("RTS = 1 !\n"); */
/*-----*/
//ClearCommError(hCom, &voir, &Rstatus);
/*--------------------------------------------------------------------*/
printf("start l'envoi\n");
printf("le numbre d'octet envoyer est %d !\n",SendData(256, BootLoader));
//printf("start reception \n");
//printf("le numbre d'octet a lire est %d !\n",ReceiveData(256, Buffer));
while(1){}
return false;
} |
Partager