亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bdmcf.c

?? bdm源代碼. coldfire處理器用
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
    Turbo BDM Light ColdFire - bdm routines
    Copyright (C) 2005  Daniel Malik

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include "MC68HC908JB16.h"
#include "options.h"
#include "bdmcf.h"
#include "timer.h"
#include "commands.h"
#include "cmd_processing.h"

#ifdef MULTIPLE_SPEEDS
  /* until more than one set of rx/tx functions is needed the speed of operation can be improved by not using the pointers */

  #pragma DATA_SEG Z_RAM
  /* pointers to Rx & Tx routines */
  unsigned char near (*bdmcf_rx8_ptr)(void) = bdmcf_rx8_1;
  void near (*bdmcf_tx8_ptr)(unsigned char) = bdmcf_tx8_1;
  unsigned char near (*bdmcf_txrx8_ptr)(unsigned char) = bdmcf_txrx8_1;
  unsigned char near (*bdmcf_txrx_start_ptr)(void) = bdmcf_txrx_start_1;

  #pragma DATA_SEG DEFAULT
  /* tables with pointers to Tx & Rx functions */
  unsigned char (* const bdmcf_rx8_ptrs[])(void)=
    {bdmcf_rx8_1};
  void (* const bdmcf_tx8_ptrs[])(unsigned char)=
    {bdmcf_tx8_1};
  unsigned char (* const bdmcf_txrx8_ptrs[])(unsigned char)=
    {bdmcf_txrx8_1};
  unsigned char (* const bdmcf_txrx_start_ptrs[])(void)=
    {bdmcf_txrx_start_1};

#endif

/* halts the target CPU (stops execution of the code and brings the part into BDM mode) */
void bdmcf_halt(void) {
  #ifdef INVERT
    BKPT_OUT=1;   /* assert BKPT */
  #else
    BKPT_OUT=0;
  #endif
  wait_10us(70);   /* wait 700us, this should be enough even for a target running at 2kHz clock and yet it is short enough to fit into a single USB slot */
  #ifdef INVERT
    BKPT_OUT=0;   /* deassert BKPT */
  #else
    BKPT_OUT=1;
  #endif
  bdmcf_complete_chk_rx();  /* added in revision 0.3 */
                            /* it is a workaround for a strange problem: CF CPU V2 seems to ignore the first transfer after a halt */
                            /* I do not admit I know why it happens, but the extra NOP command fixes the problem... */
                            /* the problem has nothing to do with the delay: adding up to 400ms of delay between the halt nad the read did not fix it */
}

/* resets the target CPU either into BDM mode (parameter bkpt=0) or into notmal mode (parameter bkpt!=0) */
/* length of the reset pulse is 50ms, if BKPT is to be asserted it is held active for 50ms after reset is released */
void bdmcf_reset(unsigned char bkpt) {
  RSTI_OUT=0;  		  /* reset is active low */
  RSTI_DIRECTION=1; /* assert it */
  if (bkpt==0) {
    #ifdef INVERT
      BKPT_OUT=1;   /* assert BKPT */
    #else
      BKPT_OUT=0;
    #endif
  }
  wait_1ms(50);     /* 50ms */
  RSTI_DIRECTION=0; /* deassert reset */
  wait_1ms(50);     /* give the reset pin enough time to rise even with slow RC */
  #ifdef INVERT		 
    BKPT_OUT=0;     /* deassert BKPT */
  #else
    BKPT_OUT=1;
  #endif
  cable_status.reset=NO_RESET_ACTIVITY;  /* clear the reset flag */  
  bdmcf_complete_chk_rx();  /* added in revision 0.3 */
}

/* asserts the TA signal for the specified duration */
/* the time is in 10us ticks */
void bdmcf_ta(unsigned char time_10us) {
  TA_OUT=0;  		    /* TA is active low */
  TA_DIRECTION=1;   /* assert it */
  wait_10us(time_10us); /* wait the specified time */
  TA_DIRECTION=0;   /* de-assert it */
}

/* transmits series of 17 bit messages, contents of messages is pointed to by *data */
/* first byte in the buffer is the MSB oft the first message */
void bdmcf_tx(unsigned char count, unsigned char *data) {
  while(count--) {
    bdmcf_txrx_start_ptr();
    bdmcf_tx8_ptr(*(data++));
    bdmcf_tx8_ptr(*(data++));
  }
}

/* waits for command complete indication, to be used with commands which only write data and do not read any result */
/* returns 0 on success and non-zero on error */
/* only checks the status, not the data bits */
unsigned char bdmcf_complete_chk(unsigned int next_cmd) {
  unsigned char i=BDMCF_RETRY;
  unsigned char status;
  do {
    status=bdmcf_txrx_start_ptr();
    bdmcf_tx8_ptr(next_cmd>>8);    /* send in the next command */
    bdmcf_tx8_ptr(next_cmd&0xff);
    if (status==0) return(0);
  } while ((i--)>0);
  return(1);
}

/* waits for command complete indication, to be used with commands which only write data and do not read any result */
/* returns 0 on success and non-zero on error */
/* checks buss error as well as not-ready, but does not send the next command */
unsigned char bdmcf_complete_chk_rx(void) {
  unsigned char i=BDMCF_RETRY;
  unsigned char status;
  unsigned char data;
  do {
    status=bdmcf_txrx_start_ptr();
    bdmcf_tx8_ptr(0);
    data=bdmcf_rx8_ptr();
    if (status==0) return(0);
  } while ((data==0x00)&&((i--)>0));
  return(1);
}

/* receives series of 17 bit messages and stores them into the supplied buffer (MSB of the first message first) */
/* returns zero on success and non-zero on retry error */
unsigned char bdmcf_rx(unsigned char count, unsigned char *data) {
  unsigned char i,status;
  while(count) {
    i=BDMCF_RETRY;
    do {
      status=bdmcf_txrx_start_ptr();
      *(data+0)=bdmcf_rx8_ptr();
      *(data+1)=bdmcf_rx8_ptr();
    } while ((status!=0)&&((*(data+1))==0x00)&&((i--)>0));  /* repeat while status==1 & data+1 == 00 (not ready, come again) */
    if (status!=0) return(1);
    count--;
    data+=2;
  }
  return(0);
}

/* receives series of 17 bit messages and stores them into the supplied buffer (MSB of the first message first) */
/* returns zero on success and non-zero on retry error */
/* transmits the next command while receiving the last message */
unsigned char bdmcf_rxtx(unsigned char count, unsigned char *data, unsigned int next_cmd) {
  unsigned char i,status;
  while(count) {
    i=BDMCF_RETRY;
    count--;
    if (count) {
      do {
        status=bdmcf_txrx_start_ptr();
        *(data+0)=bdmcf_rx8_ptr();
        *(data+1)=bdmcf_rx8_ptr();
      } while ((status!=0)&&((*(data+1))==0x00)&&((i--)>0));
    } else {
      do {                                        /* last message - send the next command */
        status=bdmcf_txrx_start_ptr();
        *(data+0)=bdmcf_txrx8_ptr(next_cmd>>8);
        *(data+1)=bdmcf_txrx8_ptr(next_cmd&0xff);
      } while ((status!=0)&&((*(data+1))==0x00)&&((i--)>0));
    }
    if (status!=0) return(1);
    data+=2;
  }
  return(0);
}

/* transmits a 17 bit message, returns the status bit */
unsigned char bdmcf_tx_msg(unsigned int data) {
  unsigned char status;
  status=bdmcf_txrx_start_ptr();
  bdmcf_tx8_ptr(data>>8);
  bdmcf_tx8_ptr(data&0xff);
  return(status);
}

/* transmits a 17 bit message, returns the least significant byte of the response */
/* to be used for transmitting second message in a multi-message command which can fail (e.g. because target is not halted) */
/* the returned byte identifies what is happening: 00 = Not ready, 01 = Bus error, FF = Illegal command */
/* the correct response in these cases is Not Ready */
unsigned char bdmcf_tx_msg_half_rx(unsigned int data) {
  unsigned char ret_val;
  bdmcf_txrx_start_ptr();
  bdmcf_tx8_ptr(data>>8);
  ret_val=bdmcf_txrx8_ptr(data&0xff);
  return(ret_val);
}

/* receives a 17 bit message, returns the status bit, data is stored into the supplied data buffer MSB first */
unsigned char bdmcf_rx_msg(unsigned char *data) {
  unsigned char status;
  status=bdmcf_txrx_start_ptr();
  *data=bdmcf_rx8_ptr();
  *(data+1)=bdmcf_rx8_ptr();
  return(status);
}

/* transmits & receives a 17 bit message, data in the buffer is transmited and then replaced with received data, returns the status bit */
unsigned char bdmcf_txrx_msg(unsigned char *data) {
  unsigned char status;
  status=bdmcf_txrx_start_ptr();
  *data=bdmcf_txrx8_ptr(*data);
  *(data+1)=bdmcf_txrx8_ptr(*(data+1));
  return(status);
}

/* resynchronizes communication with the target in case of noise of the CLK line, etc. */
/* returns 0 in case of sucess, non-zero in case of error */
unsigned char bdmcf_resync(void) {
  unsigned char i;
  unsigned int data=BDMCF_CMD_NOP;
  bdmcf_tx_msg(BDMCF_CMD_NOP);    /* send in 3 NOPs to clear any error */
  bdmcf_tx_msg(BDMCF_CMD_NOP);
  bdmcf_txrx_msg(&data);
  if ((data&3)==0) return(1);     /* the last NOP did not return the expected value (at least one of the two bits should be 1) */
  for (i=18;i>0;i++) {            /* now start sending in another nop and watch the result */
    if (bdmcf_txrx_start_ptr()==0) break;   /* the first 0 is the status */
  }
  if (i==0) return(1);
  /* transmitted & received the status, finish the nop */
  bdmcf_tx8_ptr(0x00);
  bdmcf_tx8_ptr(0x00);
  return(0);
}
 
/* initialises the BDM interface */
void bdmcf_init(void) {
  PTA  = BDMCF_IDLE;    /* preload idle state into port A data register */
  #ifdef DEBUG
    DDRA = DSI_OUT_MASK | TCLK_OUT_MASK | DSCLK_OUT_MASK | BKPT_OUT_MASK; /* RSTI_OUT and TA_OUT are inactive, the remaining OUT signals are outputs */
  #else
    DDRA = DSI_OUT_MASK | TCLK_OUT_MASK | DSCLK_OUT_MASK | BKPT_OUT_MASK | DDRA_DDRA7; /* PTA7 is unused when not debugging, make sure it is output in such case */
  #endif
  PTC  = 0;
  DDRC = DDRC_DDRC1;    /* make pin PTC1 output (it is not bonded out on the 20 pin package anyway) */
  POCR = POCR_PTE20P;   /* enable pull-ups on PTE0-2 (unused pins) */
  /* RSTO edge capture */
  T1SC = 0;             /* enable timer 1 */
  T1SC0;                /* read the status and control register */
  #ifdef INVERT
    T1SC0 = T1SC0_ELS0A_MASK;   /* capture rising edge (invert), this write will also clear the interrupt flag if set */
  #else
    T1SC0 = T1SC0_ELS0B_MASK;   /* capture falling edge (non-invert), this write will also clear the interrupt flag if set */  
  #endif
  T1SC0 |= T1SC0_CH0IE_MASK;    /* enable input capture interrupt */
  cable_status.reset=NO_RESET_ACTIVITY;  /* clear the reset flag */  
}

/* this interrupt is called whenever an active edge is detected on the RSTO input */
interrupt void rsto_detect(void) {
  T1SC0 &= ~T1SC0_CH0F_MASK;          /* clear the interrupt flag */
  cable_status.reset=RESET_DETECTED;  /* reset of the target was detected, leave it for the debugger to what it believes is appropriate */  
}

/* transmits 8 bits */
void bdmcf_tx8_1(unsigned char data) {
  asm {
    tax           /* move the input data to X */
    #ifdef INVERT
      comx        /* invert the data */
    #endif
    #ifdef DEBUG       
      lda   #(BDMCF_IDLE*2)    
    #else      
      lda   #(BDMCF_IDLE/2)    
    #endif      
    /* transmit bit 7 */
    lslx    		  /* shift MSB into C */
    #ifdef DEBUG
      rora        /* rotate C into A */
    #else
			rola
    #endif      
    sta     PTA   /* create falling edge on DSCLK and write the next bit value to the port */  
    #ifdef DEBUG
      lda   #(BDMCF_IDLE*2)  /* reload idle value into A */
    #else
      lda   #(BDMCF_IDLE/2)
    #endif      
    #ifdef INVERT
      bclr  DSCLK_OUT_BITNUM,DSCLK_OUT_PORT  /* create rising edge on DSCLK */
    #else
      bset  DSCLK_OUT_BITNUM,DSCLK_OUT_PORT
    #endif
    /* transmit bit 6 */
    lslx    		  /* shift MSB into C */
    #ifdef DEBUG
      rora        /* rotate C into A */
    #else
			rola
    #endif      
    sta     PTA   /* create falling edge on DSCLK and write the next bit value to the port */  
    #ifdef DEBUG
      lda   #(BDMCF_IDLE*2)  /* reload idle value into A */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产凹凸在线观看一区二区| 久久综合综合久久综合| jizzjizzjizz欧美| 欧美韩日一区二区三区| 国产一区福利在线| 亚洲精品一区在线观看| 久久精品国产成人一区二区三区| 7777精品伊人久久久大香线蕉完整版 | 国产精品免费视频一区| 国产精品夜夜嗨| 久久久国产精华| 国产成人自拍网| 国产欧美日韩另类一区| 高清久久久久久| 国产精品美女久久久久久久久 | 国产精品一区二区无线| 久久蜜桃av一区精品变态类天堂 | 国产精品国模大尺度视频| 成人免费视频播放| 欧美撒尿777hd撒尿| 中文字幕不卡在线观看| 成人精品国产免费网站| 亚洲色图一区二区| 色哟哟日韩精品| 亚洲国产综合色| 欧美精品精品一区| 毛片一区二区三区| 欧美精品一区二区精品网| 国产精品白丝jk黑袜喷水| 国产精品美女久久福利网站 | 风间由美中文字幕在线看视频国产欧美| 国产亚洲va综合人人澡精品| 成人精品一区二区三区中文字幕| 亚洲欧洲日本在线| 欧美体内she精高潮| 日本美女视频一区二区| 久久亚区不卡日本| av不卡免费在线观看| 一区二区三区四区国产精品| 欧美猛男gaygay网站| 久久成人羞羞网站| 国产精品无码永久免费888| 色呦呦一区二区三区| 三级影片在线观看欧美日韩一区二区 | 成人av在线观| 一区二区三区国产精品| 日韩欧美亚洲另类制服综合在线| 国产一区二区日韩精品| 国产精品免费久久| 欧美日韩一区二区三区高清 | 天天色 色综合| wwww国产精品欧美| 91在线你懂得| 日韩av电影免费观看高清完整版 | 国产女主播在线一区二区| 99久久精品情趣| 婷婷丁香激情综合| 国产日产欧美一区| 欧美日韩在线直播| 国产精品一区二区在线看| 亚洲欧美日韩精品久久久久| 欧美电影在哪看比较好| 国产成人av影院| 午夜精品福利一区二区蜜股av| 亚洲精品一区在线观看| 欧美在线看片a免费观看| 精品午夜一区二区三区在线观看| 亚洲欧美怡红院| 日韩欧美一区二区免费| 91视频一区二区| 麻豆一区二区三| 亚洲男人的天堂在线观看| 欧美成人欧美edvon| 一本久久a久久精品亚洲| 极品少妇一区二区| 亚洲国产欧美在线人成| 国产日产精品一区| 91 com成人网| 色噜噜偷拍精品综合在线| **欧美大码日韩| 91精品国产综合久久精品app | 欧洲av在线精品| 国产精品18久久久久久久久 | 高清不卡一二三区| 日韩精品高清不卡| 亚洲免费观看高清完整版在线观看 | 精品99999| 欧美专区亚洲专区| 成人一区在线看| 美女mm1313爽爽久久久蜜臀| 亚洲日本护士毛茸茸| 精品国产一区二区三区av性色| 色综合久久综合| 国产高清亚洲一区| 日韩av在线播放中文字幕| 中文字幕一区二区日韩精品绯色| 欧美成人vps| 欧美精品一二三| 91久久国产最好的精华液| 国产91富婆露脸刺激对白| 日本特黄久久久高潮| 夜夜爽夜夜爽精品视频| 中文在线一区二区| 精品88久久久久88久久久| 9191成人精品久久| 欧美日韩国产大片| 一本大道久久a久久精二百 | av电影在线观看一区| 韩日av一区二区| 麻豆成人综合网| 午夜私人影院久久久久| 亚洲自拍偷拍图区| 亚洲视频一二三区| 日韩一区在线播放| 中文字幕高清一区| 久久精品网站免费观看| 精品国产一区二区三区忘忧草| 91精品国产综合久久久久久久| 欧美亚洲动漫精品| 在线亚洲人成电影网站色www| a4yy欧美一区二区三区| 成人免费视频一区| 懂色av一区二区三区免费看| 国产黄色精品网站| 欧美日韩小视频| 亚洲免费观看高清完整版在线| 国产精品久99| 国产精品乱人伦中文| 国产精品亲子伦对白| 国产女主播一区| 国产精品美女久久久久aⅴ| 中文字幕一区二区视频| 国产精品国产成人国产三级| 国产精品免费久久| 亚洲色图制服诱惑| 亚洲一区在线免费观看| 亚洲电影欧美电影有声小说| 亚洲成人免费看| 午夜天堂影视香蕉久久| 欧美aaaaaa午夜精品| 麻豆91精品视频| 国产在线看一区| 高清beeg欧美| 91在线播放网址| 一本大道久久精品懂色aⅴ| 欧美亚洲免费在线一区| 欧美日韩国产在线观看| 91精品国产日韩91久久久久久| 日韩免费福利电影在线观看| 精品国产亚洲一区二区三区在线观看| 久久久美女毛片 | 日韩三级免费观看| 精品久久99ma| 国产亚洲精品中文字幕| 国产精品久久久久影院色老大| 亚洲色大成网站www久久九九| 一区二区三区中文免费| 亚洲第一成年网| 麻豆精品视频在线观看| 国产精品自拍在线| 91啪亚洲精品| 欧美男人的天堂一二区| 精品剧情在线观看| 欧美激情一区二区三区四区| 自拍视频在线观看一区二区| 亚洲一区免费观看| 久久精品噜噜噜成人88aⅴ| 国产精品456露脸| 一本一道综合狠狠老| 欧美群妇大交群中文字幕| 精品少妇一区二区三区免费观看 | 欧美日本国产视频| 久久综合色播五月| 亚洲天堂免费看| 日本成人在线看| kk眼镜猥琐国模调教系列一区二区| 欧美在线免费视屏| 久久综合一区二区| 亚洲精品成人天堂一二三| 日本aⅴ亚洲精品中文乱码| 国产白丝网站精品污在线入口| 欧美亚洲一区三区| 精品国产一区久久| 亚洲精品国产一区二区三区四区在线| 日产欧产美韩系列久久99| 国产精品白丝av| 欧美日韩三级在线| 久久精品视频一区| 亚洲福利视频一区| 国产福利视频一区二区三区| 欧美性一二三区| 欧美精品一区二| 亚洲国产欧美一区二区三区丁香婷| 国产一区二区三区免费播放| 91福利国产精品| 爽爽淫人综合网网站| 亚洲美女一区二区三区| 婷婷夜色潮精品综合在线| 成人美女视频在线观看18| 欧美午夜片在线观看|