📄 dfujtag.c
字号:
//*----------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name : dfuUsart.c
//* Object : Low level functions for Usart Dfu
//*
//* 1.0 23/03/01 : Creation
//*----------------------------------------------------------------------------
#include <stdio.h>
#include "appli\includes\StructDfu.h"
#include "appli\includes\dchannel.h"
unsigned int global_timeout;
unsigned int *ptr_ram_upload;
//*----------------------------------------------------------------------------
//* Function Name : read_dbg_data
//* Object : read debug communication data register
//* Input Parameters :
//* Output Parameters : R0
//*----------------------------------------------------------------------------
static unsigned int read_dbg_data(void)
{
/* read debug communication channel data register in R0*/
asm("MRC p14, 0, r0, c1, c0");
/*return value = (R0)*/
return ;
}
//*----------------------------------------------------------------------------
//* Function Name : read_dbg_control
//* Object : read debug communication data register
//* Input Parameters :
//* Output Parameters : R0
//*----------------------------------------------------------------------------
static unsigned int read_dbg_control(void)
{
/* read debug communication channel control register in R0*/
asm("MRC p14, 0, r0, c0, c0");
/*return value = (R0)*/
return ;
}
//*----------------------------------------------------------------------------
//* Function Name : read_dbg_control
//* Object : read debug communication data register
//* Input Parameters : Val = R0
//* Output Parameters :
//*----------------------------------------------------------------------------
static void write_dbg_data(unsigned int val)
{
/* read debug communication channel control register in R0*/
asm("MCR p14, 0, r0, c1, c0");
/*return value = (R0)*/
}
//*----------------------------------------------------------------------------
//* Function Name : send_car
//* Object : send a caracter on the debug communication channel
//* Input Parameters : Val = R0
//* Output Parameters :
//*----------------------------------------------------------------------------
void send_car(unsigned int val, unsigned int timeout)
{
while( ((read_dbg_control() & W_BIT) == W_BIT) && timeout-- );
if(timeout == 0)
return ;
write_dbg_data(val);
}
//*----------------------------------------------------------------------------
//* Function Name : send_car
//* Object : send a caracter on the debug communication channel
//* Input Parameters : Val = R0
//* Output Parameters :
//*----------------------------------------------------------------------------
unsigned int read_car(unsigned int timeout)
{
while( ((read_dbg_control() & R_BIT) != R_BIT) && timeout-- );
if(timeout == 0)
return FALSE;
return(read_dbg_data());
}
void flush_dbg_data(unsigned int timeout)
{
while( ((read_dbg_control() & R_BIT) == R_BIT) && timeout-- )
read_dbg_data();
}
//*----------------------------------------------------------------------------
//* Function Name : at91_dchannel_c_handler
//* Object : debug communication channel interrupt handler
//* Input Parameters :
//* Output Parameters : none
//*----------------------------------------------------------------------------
void at91_dchannel_c_handler(void)
{
unsigned int *aic_isr = (unsigned int*)0xfffff108;
unsigned int car = 0;
register unsigned int val; // val is stored inthe first register R0
if (*aic_isr == 31)
{
// *usart_thr = 'T';
}
else if (*aic_isr == 30)
{
*ptr_ram_upload++ = read_car(RD_DBG_TIMEOUT);
global_timeout = TIMEOUT_DBG_UPLOAD;
}
}
//*----------------------------------------------------------------------------
//* Function Name : Send()
//* Object : Send a buffer with the PDC
//* Input Parameters : SBuffer
//* Output Parameters : none
//*----------------------------------------------------------------------------
void SendJtag(struct _Speriph *pPeriph)
{
char *pData;
unsigned int SizeWrite;
pData = pPeriph->pBuffer->Read(pPeriph->pBuffer, &SizeWrite);
}
//*----------------------------------------------------------------------------
//* Function Name : Receive()
//* Object : Receive a buffer with the PDC
//* Input Parameters : SBuffer
//* Output Parameters : none
//*----------------------------------------------------------------------------
unsigned int ReceiveJtag(struct _Speriph *pPeriph)
{
char *pData;
unsigned int SizeRead;
pData = pPeriph->pBuffer->Write(pPeriph->pBuffer, &SizeRead);
}
//*----------------------------------------------------------------------------
//* Function Name : GetStatus()
//* Object : Return the status of the usart
//* Input Parameters :
//* Output Parameters : none
//*----------------------------------------------------------------------------
unsigned int GetStatusJtag(struct _Speriph *pPeriph)
{
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -