SoftUart.s43
上传用户:xhjmsc
上传日期:2019-09-13
资源大小:389k
文件大小:13k
源码类别:

传真(Fax)编程

开发平台:

C/C++

  1.         NAME SoftUart
  2.         RTMODEL "__double_size", "32"
  3.         RTMODEL "__pic", "no"
  4.         RTMODEL "__reg_r4", "free"
  5.         RTMODEL "__reg_r5", "free"
  6.         RTMODEL "__rt_version", "1"
  7.         RSEG CSTACK:DATA:SORT:NOROOT(1)
  8.         EXTERN gucGeneralStatus
  9.         EXTERN delay1us
  10.         FUNCTION delay1us,0202H
  11.         EXTERN gucFrhErrorStatus
  12.         EXTERN gwTimeOverflowCount
  13.         EXTERN ?longjmp_r4
  14.         EXTERN ?longjmp_r5
  15.         EXTERN ?setjmp_r4
  16.         EXTERN ?setjmp_r5
  17.         PUBWEAK ?setjmp_save_r4
  18.         PUBWEAK ?setjmp_save_r5
  19.         PUBLIC Delay1us
  20.         FUNCTION Delay1us,0203H
  21.         LOCFRAME CSTACK, 2, STACK
  22.         PUBWEAK P1IN
  23.         PUBWEAK P6IN
  24.         PUBWEAK P6OUT
  25.         PUBLIC SoftUartDelay
  26.         FUNCTION SoftUartDelay,0203H
  27.         LOCFRAME CSTACK, 2, STACK
  28.         PUBLIC SoftUartDelay7us
  29.         FUNCTION SoftUartDelay7us,0203H
  30.         LOCFRAME CSTACK, 2, STACK
  31.         PUBLIC SoftUartDelay8p7us
  32.         FUNCTION SoftUartDelay8p7us,0203H
  33.         LOCFRAME CSTACK, 2, STACK
  34.         PUBLIC SoftUartDelayHalf
  35.         FUNCTION SoftUartDelayHalf,0203H
  36.         LOCFRAME CSTACK, 2, STACK
  37.         PUBLIC SoftUartRxOneFrame
  38.         FUNCTION SoftUartRxOneFrame,021203H
  39.         LOCFRAME CSTACK, 6, STACK
  40.         PUBLIC SoftUartTxOneFrame
  41.         FUNCTION SoftUartTxOneFrame,021203H
  42.         LOCFRAME CSTACK, 6, STACK
  43.         
  44.         CFI Names cfiNames0
  45.         CFI StackFrame CFA SP DATA
  46.         CFI Resource PC:16, SP:16, SR:16, R4:16, R5:16, R6:16, R7:16, R8:16
  47.         CFI Resource R9:16, R10:16, R11:16, R12:16, R13:16, R14:16, R15:16
  48.         CFI EndNames cfiNames0
  49.         
  50.         CFI Common cfiCommon0 Using cfiNames0
  51.         CFI CodeAlign 2
  52.         CFI DataAlign 2
  53.         CFI ReturnAddress PC CODE
  54.         CFI CFA SP+2
  55.         CFI PC Frame(CFA, -2)
  56.         CFI SR Undefined
  57.         CFI R4 SameValue
  58.         CFI R5 SameValue
  59.         CFI R6 SameValue
  60.         CFI R7 SameValue
  61.         CFI R8 SameValue
  62.         CFI R9 SameValue
  63.         CFI R10 SameValue
  64.         CFI R11 SameValue
  65.         CFI R12 Undefined
  66.         CFI R13 Undefined
  67.         CFI R14 Undefined
  68.         CFI R15 Undefined
  69.         CFI EndCommon cfiCommon0
  70.         
  71. // E:projectFaxProgramVson_Bryan_Fax_Conexant_070423filesSoftUart.c
  72. //    1 //soft UART
  73. //    2 //new bryan Jan. 23, 2007
  74. //    3 //
  75. //    4 
  76. //    5 #include "includeH.h"
  77.         ASEGN DATA16_AN:DATA:NOROOT,020H
  78. // unsigned char const volatile __data P1IN
  79. P1IN:
  80.         DS8 1
  81.         ASEGN DATA16_AN:DATA:NOROOT,034H
  82. // unsigned char const volatile __data P6IN
  83. P6IN:
  84.         DS8 1
  85.         ASEGN DATA16_AN:DATA:NOROOT,035H
  86. // unsigned char volatile __data P6OUT
  87. P6OUT:
  88.         DS8 1
  89. //    6 
  90. //    7 
  91. //    8 
  92.         RSEG CODE:CODE:NOROOT(1)
  93. //    9 unsigned char SoftUartRxOneFrame(void)
  94. SoftUartRxOneFrame:
  95.         CFI Block cfiBlock0 Using cfiCommon0
  96.         CFI Function SoftUartRxOneFrame
  97. //   10 {
  98.         FUNCALL SoftUartRxOneFrame, delay1us
  99.         LOCFRAME CSTACK, 6, STACK
  100.         FUNCALL SoftUartRxOneFrame, delay1us
  101.         LOCFRAME CSTACK, 6, STACK
  102.         FUNCALL SoftUartRxOneFrame, delay1us
  103.         LOCFRAME CSTACK, 6, STACK
  104. PUSH.W R10
  105.         CFI R10 Frame(CFA, -4)
  106.         CFI CFA SP+4
  107. PUSH.W R11
  108.         CFI R11 Frame(CFA, -6)
  109.         CFI CFA SP+6
  110. //   11      unsigned char ucGeneralCount=0,ucSoftUartRxData=0;
  111. MOV.B #0x0, R11
  112. MOV.B #0x0, R10
  113. //   12      while ((SOFTUART_PORT_IN & bitSOFTUARTRX) == bitSOFTUARTRX)//wait start bit Low
  114. ??SoftUartRxOneFrame_0:
  115. BIT.B #0x2, &0x34
  116. JNC ??SoftUartRxOneFrame_3
  117. //   13      {  
  118. //   14       if ((gucGeneralStatus & bitModemActive) == bitModemActive)
  119. BIT.B #0x2, &gucGeneralStatus
  120. JC ??SoftUartRxOneFrame_3
  121. //   15         break;
  122. //   16       if (((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) || 
  123. //   17         ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ||
  124. //   18         ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode) ||
  125. //   19         ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode)) //||
  126. BIT.B #0x1, &0x20
  127. JNC ??SoftUartRxOneFrame_3
  128. BIT.B #0x2, &0x20
  129. JNC ??SoftUartRxOneFrame_3
  130. BIT.B #0x4, &0x20
  131. JNC ??SoftUartRxOneFrame_3
  132. BIT.B #0x8, &0x20
  133. JC ??SoftUartRxOneFrame_0
  134. //   20         //((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal))
  135. //   21         break;
  136. //   22      } 
  137. //   23      if ( (SOFTUART_PORT_IN & bitSOFTUARTRX) != bitSOFTUARTRX)
  138. ??SoftUartRxOneFrame_3:
  139. BIT.B #0x2, &0x34
  140. JC ??SoftUartRxOneFrame_4
  141. //   24      {
  142. //   25      delay1us(6);//SoftUartDelay();
  143. MOV.W #0x6, R12
  144. CALL #delay1us
  145. //   26      for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
  146. MOV.B #0x0, R11
  147. ??SoftUartRxOneFrame_1:
  148. CMP.B #0x8, R11
  149. JC ??SoftUartRxOneFrame_2
  150. //   27      {
  151. //   28         delay1us(2);//SoftUartDelayHalf();
  152. MOV.W #0x2, R12
  153. CALL #delay1us
  154. //   29         ucSoftUartRxData=ucSoftUartRxData>>1;
  155. CLRC
  156. RRC.B R10
  157. //   30         if ((SOFTUART_PORT_IN & bitSOFTUARTRX) == bitSOFTUARTRX)
  158. BIT.B #0x2, &0x34
  159. JNC ??SoftUartRxOneFrame_5
  160. //   31           ucSoftUartRxData |= BIT7;//BIT7;//(1<<ucGeneralCount);//set   Rx bit
  161. BIS.B #0x80, R10
  162. JMP ??SoftUartRxOneFrame_6
  163. //   32         else
  164. //   33           {ucSoftUartRxData &= ~BIT7;__no_operation();__no_operation();__no_operation();}//~BIT7;//~(1<<ucGeneralCount);//set   Rx bit
  165. ??SoftUartRxOneFrame_5:
  166. BIC.B #0x80, R10
  167. NOP
  168. NOP
  169. NOP
  170. //   34         
  171. //   35         delay1us(2);//SoftUartDelayHalf();
  172. ??SoftUartRxOneFrame_6:
  173. MOV.W #0x2, R12
  174. CALL #delay1us
  175. //   36         __no_operation();
  176. NOP
  177. //   37         __no_operation();
  178. NOP
  179. //   38         __no_operation();
  180. NOP
  181. //   39         __no_operation();
  182. NOP
  183. //   40         __no_operation();  
  184. NOP
  185. //   41      }
  186. ADD.B #0x1, R11
  187. JMP ??SoftUartRxOneFrame_1
  188. //   42      //delay1us(6);
  189. //   43      while ((SOFTUART_PORT_IN & bitSOFTUARTRX) != bitSOFTUARTRX) //wait stop bit High
  190. ??SoftUartRxOneFrame_2:
  191. BIT.B #0x2, &0x34
  192. JC ??SoftUartRxOneFrame_4
  193. //   44      {  
  194. //   45       if ((SOFTUART_PORT_IN & bitSOFTUARTRX) == bitSOFTUARTRX)
  195. BIT.B #0x2, &0x34
  196. JC ??SoftUartRxOneFrame_4
  197. //   46         break;
  198. //   47       gucFrhErrorStatus=0x00;//
  199. MOV.B #0x0, &gucFrhErrorStatus
  200. //   48         if (gwTimeOverflowCount++ == 0xffff)
  201. MOV.W &gwTimeOverflowCount, R14
  202. MOV.W #0x1, R15
  203. ADD.W R14, R15
  204. MOV.W R15, &gwTimeOverflowCount
  205. CMP.W #0xffff, R14
  206. JNE ??SoftUartRxOneFrame_2
  207. //   49            {gucFrhErrorStatus=0x03;gwTimeOverflowCount=0;break;}
  208. MOV.B #0x3, &gucFrhErrorStatus
  209. MOV.W #0x0, &gwTimeOverflowCount
  210. //   50      }
  211. //   51      //delay1us(6);//SoftUartDelay();
  212. //   52      }
  213. //   53      return ucSoftUartRxData;       
  214. ??SoftUartRxOneFrame_4:
  215. MOV.B R10, R12
  216. POP.W R11
  217.         CFI R11 SameValue
  218.         CFI CFA SP+4
  219. POP.W R10
  220.         CFI R10 SameValue
  221.         CFI CFA SP+2
  222. RET
  223.         CFI EndBlock cfiBlock0
  224. //   54 }
  225. //   55 
  226.         RSEG CODE:CODE:NOROOT(1)
  227. //   56 void SoftUartTxOneFrame(unsigned char ucSoftUartTxData)
  228. SoftUartTxOneFrame:
  229.         CFI Block cfiBlock1 Using cfiCommon0
  230.         CFI Function SoftUartTxOneFrame
  231. //   57 {
  232.         FUNCALL SoftUartTxOneFrame, delay1us
  233.         LOCFRAME CSTACK, 6, STACK
  234.         FUNCALL SoftUartTxOneFrame, delay1us
  235.         LOCFRAME CSTACK, 6, STACK
  236.         FUNCALL SoftUartTxOneFrame, delay1us
  237.         LOCFRAME CSTACK, 6, STACK
  238. PUSH.W R10
  239.         CFI R10 Frame(CFA, -4)
  240.         CFI CFA SP+4
  241. PUSH.W R11
  242.         CFI R11 Frame(CFA, -6)
  243.         CFI CFA SP+6
  244. MOV.B R12, R10
  245. //   58      unsigned char ucGeneralCount=0;
  246. MOV.B #0x0, R11
  247. //   59      __disable_interrupt();
  248. DINT
  249. //   60      SOFTUART_PORT_OUT &= ~bitSOFTUARTTX; //reset Tx bit
  250. BIC.B #0x1, &0x35
  251. //   61      delay1us(7);//115 9600//57 19200//17 57600 //7 115200
  252. MOV.W #0x7, R12
  253. CALL #delay1us
  254. //   62      //__no_operation();
  255. //   63      //__no_operation();
  256. //   64      //__no_operation();
  257. //   65      //delay1us(8);
  258. //   66      for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
  259. MOV.B #0x0, R11
  260. ??SoftUartTxOneFrame_0:
  261. CMP.B #0x8, R11
  262. JC ??SoftUartTxOneFrame_1
  263. //   67      {
  264. //   68 
  265. //   69         if ((ucSoftUartTxData & BIT0) == BIT0)
  266. BIT.B #0x1, R10
  267. JNC ??SoftUartTxOneFrame_2
  268. //   70           {SOFTUART_PORT_OUT |= bitSOFTUARTTX;} //set   Tx bit
  269. BIS.B #0x1, &0x35
  270. JMP ??SoftUartTxOneFrame_3
  271. //   71         else
  272. //   72           {SOFTUART_PORT_OUT &= ~bitSOFTUARTTX;__no_operation();__no_operation();__no_operation();} //reset Tx bit
  273. ??SoftUartTxOneFrame_2:
  274. BIC.B #0x1, &0x35
  275. NOP
  276. NOP
  277. NOP
  278. //   73         delay1us(6);//115 9600 //56 19200//16 57600 //6 115200
  279. ??SoftUartTxOneFrame_3:
  280. MOV.W #0x6, R12
  281. CALL #delay1us
  282. //   74         //__no_operation();
  283. //   75         __no_operation();
  284. NOP
  285. //   76         ucSoftUartTxData=ucSoftUartTxData>>1;
  286. CLRC
  287. RRC.B R10
  288. //   77         
  289. //   78      }
  290. ADD.B #0x1, R11
  291. JMP ??SoftUartTxOneFrame_0
  292. //   79      __no_operation();
  293. ??SoftUartTxOneFrame_1:
  294. NOP
  295. //   80      __no_operation();
  296. NOP
  297. //   81      SOFTUART_PORT_OUT |= bitSOFTUARTTX;  //set   Tx bit
  298. BIS.B #0x1, &0x35
  299. //   82      delay1us(7);//115 9600 //17 57600//7 115200
  300. MOV.W #0x7, R12
  301. CALL #delay1us
  302. //   83      _EINT();                             //enable interrupt   
  303. EINT
  304. //   84 }
  305. POP.W R11
  306.         CFI R11 SameValue
  307.         CFI CFA SP+4
  308. POP.W R10
  309.         CFI R10 SameValue
  310.         CFI CFA SP+2
  311. RET
  312.         CFI EndBlock cfiBlock1
  313. //   85 
  314. //   86 
  315.         RSEG CODE:CODE:NOROOT(1)
  316. //   87 void SoftUartDelay7us(void)
  317. SoftUartDelay7us:
  318.         CFI Block cfiBlock2 Using cfiCommon0
  319.         CFI Function SoftUartDelay7us
  320. //   88 {
  321. //   89    unsigned wGeneralCount=0;
  322. MOV.W #0x0, R14
  323. //   90    //BauRate1200 wGeneralCount<831 BauRate9600 wGeneralCount<96 BauRate115200 6 42 19200
  324. //   91    for (wGeneralCount=0;wGeneralCount<4;wGeneralCount++)
  325. MOV.W #0x0, R14
  326. ??SoftUartDelay7us_0:
  327. CMP.W #0x4, R14
  328. JC ??SoftUartDelay7us_1
  329. //   92    {
  330. //   93      __no_operation();
  331. NOP
  332. //   94    }
  333. ADD.W #0x1, R14
  334. JMP ??SoftUartDelay7us_0
  335. //   95 
  336. //   96 }
  337. ??SoftUartDelay7us_1:
  338. RET
  339.         CFI EndBlock cfiBlock2
  340. //   97 
  341.         RSEG CODE:CODE:NOROOT(1)
  342. //   98 void SoftUartDelay8p7us(void)
  343. SoftUartDelay8p7us:
  344.         CFI Block cfiBlock3 Using cfiCommon0
  345.         CFI Function SoftUartDelay8p7us
  346. //   99 {
  347. //  100    unsigned wGeneralCount=0;
  348. MOV.W #0x0, R14
  349. //  101    //BauRate1200 wGeneralCount<831 BauRate9600 wGeneralCount<96 BauRate115200 6 42 19200
  350. //  102    for (wGeneralCount=0;wGeneralCount<4;wGeneralCount++)
  351. MOV.W #0x0, R14
  352. ??SoftUartDelay8p7us_0:
  353. CMP.W #0x4, R14
  354. JC ??SoftUartDelay8p7us_1
  355. //  103    {
  356. //  104      __no_operation();
  357. NOP
  358. //  105      __no_operation();
  359. NOP
  360. //  106    }
  361. ADD.W #0x1, R14
  362. JMP ??SoftUartDelay8p7us_0
  363. //  107 
  364. //  108 }
  365. ??SoftUartDelay8p7us_1:
  366. RET
  367.         CFI EndBlock cfiBlock3
  368. //  109 
  369.         RSEG CODE:CODE:NOROOT(1)
  370. //  110 void SoftUartDelay(void)
  371. SoftUartDelay:
  372.         CFI Block cfiBlock4 Using cfiCommon0
  373.         CFI Function SoftUartDelay
  374. //  111 {
  375. //  112    unsigned wGeneralCount=0;
  376. MOV.W #0x0, R14
  377. //  113    //BauRate1200 wGeneralCount<831 BauRate9600 wGeneralCount<96 BauRate115200 6 42 19200
  378. //  114    for (wGeneralCount=0;wGeneralCount<96;wGeneralCount++)
  379. MOV.W #0x0, R14
  380. ??SoftUartDelay_0:
  381. CMP.W #0x60, R14
  382. JC ??SoftUartDelay_1
  383. //  115    {
  384. //  116      __no_operation();
  385. NOP
  386. //  117    }
  387. ADD.W #0x1, R14
  388. JMP ??SoftUartDelay_0
  389. //  118 }   
  390. ??SoftUartDelay_1:
  391. RET
  392.         CFI EndBlock cfiBlock4
  393. //  119 
  394.         RSEG CODE:CODE:NOROOT(1)
  395. //  120 void SoftUartDelayHalf(void)
  396. SoftUartDelayHalf:
  397.         CFI Block cfiBlock5 Using cfiCommon0
  398.         CFI Function SoftUartDelayHalf
  399. //  121 {
  400. //  122    unsigned wGeneralCount=0;
  401. MOV.W #0x0, R14
  402. //  123    for (wGeneralCount=0;wGeneralCount<48;wGeneralCount++)//BauRate1200 wGeneralCount<831 BauRate9600 wGeneralCount<96
  403. MOV.W #0x0, R14
  404. ??SoftUartDelayHalf_0:
  405. CMP.W #0x30, R14
  406. JC ??SoftUartDelayHalf_1
  407. //  124    {
  408. //  125      __no_operation();
  409. NOP
  410. //  126    }
  411. ADD.W #0x1, R14
  412. JMP ??SoftUartDelayHalf_0
  413. //  127 
  414. //  128 }
  415. ??SoftUartDelayHalf_1:
  416. RET
  417.         CFI EndBlock cfiBlock5
  418. //  129 
  419.         RSEG CODE:CODE:SORT:NOROOT(1)
  420. //  130 void Delay1us(void)
  421. Delay1us:
  422.         CFI Block cfiBlock6 Using cfiCommon0
  423.         CFI Function Delay1us
  424. //  131 {
  425. //  132      __no_operation();
  426. NOP
  427. //  133      __no_operation();
  428. NOP
  429. //  134      __no_operation();
  430. NOP
  431. //  135      __no_operation();
  432. NOP
  433. //  136      __no_operation();
  434. NOP
  435. //  137      __no_operation();
  436. NOP
  437. //  138      __no_operation();
  438. NOP
  439. //  139      __no_operation();
  440. NOP
  441. //  140 
  442. //  141 } 
  443. RET
  444.         CFI EndBlock cfiBlock6
  445.         RSEG CODE:CODE:NOROOT(1)
  446. ?setjmp_save_r4:
  447. REQUIRE ?setjmp_r4
  448. REQUIRE ?longjmp_r4
  449.         RSEG CODE:CODE:NOROOT(1)
  450. ?setjmp_save_r5:
  451. REQUIRE ?setjmp_r5
  452. REQUIRE ?longjmp_r5
  453.         END
  454. // 
  455. // 344 bytes in segment CODE
  456. //   3 bytes in segment DATA16_AN
  457. // 
  458. // 344 bytes of CODE memory
  459. //   0 bytes of DATA memory (+ 3 bytes shared)
  460. //
  461. //Errors: none
  462. //Warnings: none