PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
sd.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3 *
4 * This software is owned and published by:
5 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6 *
7 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9 *
10 * This software contains source code for use with Spansion
11 * components. This software is licensed by Spansion to be adapted only
12 * for use in systems utilizing Spansion components. Spansion shall not be
13 * responsible for misuse or illegal use of this software for devices not
14 * supported herein. Spansion is providing this software "AS IS" and will
15 * not be responsible for issues arising from incorrect user implementation
16 * of the software.
17 *
18 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23 * WARRANTY OF NONINFRINGEMENT.
24 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30 * SAVINGS OR PROFITS,
31 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34 * FROM, THE SOFTWARE.
35 *
36 * This software may be replicated in part or whole for the licensed use,
37 * with the restriction that this Disclaimer and Copyright notice must be
38 * included with each copy of this software, whether used in part or whole,
39 * at all times.
40 */
41 /******************************************************************************/
52 /******************************************************************************/
53 /* Include files */
54 /******************************************************************************/
55 #include "sd.h"
56 
57 #if (defined(PDL_PERIPHERAL_SD_ACTIVE))
58 
64 
65 /******************************************************************************/
66 /* Local pre-processor symbols/macros ('#define') */
67 /******************************************************************************/
68 #define SD_PCG 0x4003C120
69 #define PCG_ENABLE (1UL<<8)
70 #define DELAYUNIT 5000
71 #define WAITTIME 50000
72 #define RETRYTIMES 100
73 
74 /******************************************************************************/
75 /* Global variable definitions (declared in header file with 'extern') */
76 /******************************************************************************/
79 volatile stc_sd_t *Sd_stcCtrl = (volatile stc_sd_t *)FM4_SDIF_BASE;
80 
81 /******************************************************************************/
82 /* Local type definitions ('typedef') */
83 /******************************************************************************/
84 
85 /******************************************************************************/
86 /* Local function prototypes ('static') */
87 /******************************************************************************/
88 
89 /******************************************************************************/
90 /* Local variable definitions ('static') */
91 /******************************************************************************/
92 
93 /******************************************************************************/
94 /* Function implementation - global ('extern') and local ('static') */
95 /******************************************************************************/
96 
97 /******************************************************************************/
98 /* Local Functions */
99 /******************************************************************************/
100 
108 static void dly_1unit (uint32_t u32Delay)
109 {
110  volatile uint32_t u32i;
111 
112  for(;u32Delay;--u32Delay)
113  {
114  for(u32i = DELAYUNIT;u32i;--u32i);
115  }
116 }
117 
132 static void SdInitPins(void)
133 {
134  FM4_GPIO->ADE &= ~(uint32_t)(1<<19);
135  FM4_GPIO->PFR0 |= 0x7E00;
136  FM4_GPIO->PFR6 |= 0x000C;
137 
138 #if (BUSWIDTH == BIT4)
139  FM4_GPIO->PCR0 |= 0x1E00;
140  FM4_GPIO->PCR0 &= ~0x0400; // DATA3 pull down
141 #else
142  FM4_GPIO->PCR0 |= 0x0800;
143 #endif
144 
145  FM4_GPIO->EPFR18 |= 0x01554000;
146 }
147 
153 static boolean_t SdEnablePCG(void)
154 {
155  uint32_t u32psg = 0;
156  volatile uint32_t * p32Sdpcg = (uint32_t *)SD_PCG;
157 
158  *p32Sdpcg |= PCG_ENABLE;
159  u32psg = *p32Sdpcg;
160  if(PCG_ENABLE == (u32psg & PCG_ENABLE))
161  {
162  return TRUE;
163  }
164  else
165  {
166  return FALSE;
167  }
168 }
169 
175 static void SdDisablePCG(void)
176 {
177  *((uint32_t *)SD_PCG) &= ~(1<<8);
178 }
179 
188 static void SdInitHostInternalData(volatile stc_sd_config_t *pstcSdCfg,stc_sd_comdconfig_t *pstcCmdCfg)
189 {
190 #if (BUSWIDTH == BIT4 )
191  pstcSdCfg->enBusWidth = BIT_4;
192 #else
193  pstcSdCfg->enBusWidth = BIT_1;
194 #endif
195  pstcSdCfg->enExist = REMOVAL;
196  pstcSdCfg->bCmdComplete = FALSE;
197  pstcSdCfg->bSendComplete = FALSE;
198  pstcSdCfg->bDMAComplete = FALSE;
199  pstcSdCfg->pfnErrorCallback = NULL;
200  pstcSdCfg->pfnRxCallback = NULL;
201  pstcSdCfg->pfnTxCallback = NULL;
202  pstcSdCfg->pfnWakeupCallback = NULL;
203 
204  pstcCmdCfg->enResponse = NO_RSP;
205  //pstcCmdCfg->enReadWrite = SD_READ;
206  pstcCmdCfg->enCmdType = NORMAL;
207  pstcCmdCfg->bDataPresent = FALSE;
208  pstcCmdCfg->u8Index = 0;
209  pstcCmdCfg->enAutoCmd = AUTO_DISABLE;
210  pstcCmdCfg->u16BlockCount = 0;
211  pstcCmdCfg->u16BlockSize = 0;
212  pstcCmdCfg->u32Argument1 = 0;
213 #ifdef SD_DMA
214  pstcCmdCfg->u32SysAddr_Arg2 = 0xFFFFFFFF;
215  pstcCmdCfg->enbound = BOUND_4K;
216 #endif
217  pstcCmdCfg->pu32Buffer = NULL;
218  pstcCmdCfg->pfnErrorResponseCallback = NULL;
219 }
220 
230 {
231  if(TRUE == Sd_stcCtrl->SNINTST_f.CMDCMPLT) //command complete?
232  {
233  Sd_stcCfg.bCmdComplete = TRUE;
234  }
235  else
236  {
237  Sd_stcCfg.bCmdComplete = FALSE;
238  }
239 
240  return (Sd_stcCfg.bCmdComplete);
241 }
242 
248 static void SdClearCmdComplete(void)
249 {
250  Sd_stcCfg.bCmdComplete = FALSE;
251 }
252 
262 {
263  if(1 == Sd_stcCtrl->SNINTST_f.TRSFCMPLT) //Transfer complete
264  {
265  Sd_stcCfg.bSendComplete = TRUE;
266  }
267  else
268  {
269  Sd_stcCfg.bSendComplete = FALSE;
270  }
271 
272  return (Sd_stcCfg.bSendComplete);
273 }
274 
283 static void SdGetCardStatus(volatile stc_sd_t* pstcSd,volatile stc_sd_config_t* pstcCfg)
284 {
285  uint16_t waittime = WAITTIME;
286 
287  while((pstcSd->SPRSTAT_f.CARDSTB == 0) && (waittime > 0))
288  {
289  waittime--;
290  dly_1unit(1);
291  }
292 
293  if(1 == pstcSd->SPRSTAT_f.CARDINS)
294  {
295  pstcCfg->enExist= INSERTED;
296  }
297  else
298  {
299  pstcCfg->enExist= REMOVAL;
300  }
301 }
302 
308 static void SdIrqHandler(void)
309 {
310  /* To do ... */
311 }
312 
324 static void SdGetResponse(volatile stc_sd_t* pstcSd,en_sd_response_t enSdresponse,uint32_t* pu32Buf)
325 {
326  switch(enSdresponse)
327  {
328  case R1NORMAL_R5_R6_R7:
329  case R1B_NORMAL:
330  case R3_R4:
331  case R5B:
332  pu32Buf[0] = pstcSd->SRESP0;
333  pu32Buf[0] |=((uint32_t)pstcSd->SRESP1<<16);
334  break;
335  case R1AUTO:
336  case R1B_AUTO:
337  pu32Buf[0] = pstcSd->SRESP6;
338  pu32Buf[0] |=((uint32_t)pstcSd->SRESP7<<16);
339  break;
340  case R2: //120 bits
341  pu32Buf[0] = pstcSd->SRESP0;
342  pu32Buf[0] |=(uint32_t)pstcSd->SRESP1<<16;
343  pu32Buf[1] = pstcSd->SRESP2;
344  pu32Buf[1] |=(uint32_t)pstcSd->SRESP3<<16;
345  pu32Buf[2] = pstcSd->SRESP4;
346  pu32Buf[2] |=(uint32_t)pstcSd->SRESP5<<16;
347  pu32Buf[3] = pstcSd->SRESP6;
348  pu32Buf[3] |=((uint32_t)pstcSd->SRESP7&0x00FF)<<16;
349  break;
350  default :
351  break;
352  }
353 }
354 
366 static boolean_t SdSendCmdOnly(volatile stc_sd_t* pstcSd, stc_sd_comdconfig_t * pstcCmdCfg)
367 {
368  boolean_t result = FALSE;
369  uint8_t u8Index = pstcCmdCfg->u8Index & 0x3F;
370  uint16_t waittime = RETRYTIMES;
371 
372  /* Wait for data line free */
373  while((TRUE == pstcSd->SPRSTAT_f.CMDDATINH) && (waittime > 0))
374  {
375  waittime--;
376  dly_1unit(1);
377  }
378 
379  /* Wait for command line free */
380  waittime = RETRYTIMES;
381 
382  while((TRUE == pstcSd->SPRSTAT_f.CMDINH) && (waittime > 0))
383  {
384  waittime--;
385  dly_1unit(1);
386  }
387 
388  pstcSd->SSA1 = pstcCmdCfg->u32Argument1;
389  pstcSd->SBSIZE_f.TRSFBLCKSZ = pstcCmdCfg->u16BlockSize;
390  pstcSd->STRSFMD_f.DTTRSFDIR = pstcCmdCfg->enReadWrite;
391 
392  /* set the response type,index check enable and CRC check enable of command register*/
393  switch(pstcCmdCfg->enResponse)
394  {
395  case R1NORMAL_R5_R6_R7:
396  case R1AUTO:
397  pstcSd->SCMMD = 0x0002|(u8Index<<8)|0x0018|(pstcCmdCfg->bDataPresent<<5);
398  break;
399  case R1B_NORMAL:
400  case R1B_AUTO:
401  case R5B:
402  pstcSd->SCMMD = 0x0003|(u8Index<<8)|0x0018;
403  break;
404  case R2:;
405  pstcSd->SCMMD = 0x0001|(u8Index<<8)|0x0008;
406  break;
407  case R3_R4:
408  pstcSd->SCMMD = 0x0002|(u8Index<<8);
409  break;
410  default :
411  pstcSd->SCMMD &= 0x0000;
412  break;
413  }
414 
415  waittime = RETRYTIMES;
416 
417  /* Wait for command line free */
418  while((TRUE == pstcSd->SPRSTAT_f.CMDINH) && (waittime > 0))
419  {
420  waittime--;
421  dly_1unit(1);
422  }
423 
424  waittime = RETRYTIMES;
425 
426  /* Wait for data line free */
427  while((TRUE == pstcSd->SPRSTAT_f.CMDDATINH) && (waittime > 0))
428  {
429  waittime--;
430  dly_1unit(1);
431  }
432 
433  if(TRUE == SdGetCmdComplete())
434  {
436  result = TRUE;
437  }
438  else
439  {
440  result = FALSE;
441  }
442 
443  return result;
444 }
445 
457 static boolean_t SdSendCmdDatLine(volatile stc_sd_t* pstcSd, stc_sd_comdconfig_t * pstcCmdCfg)
458 {
459  uint8_t result = FALSE;
460  uint16_t blockcount= pstcCmdCfg->u16BlockCount;
461 
462  pstcSd->SBSIZE_f.TRSFBLCKSZ =pstcCmdCfg->u16BlockSize & 0x0FFF;
463 
464  if(blockcount == 1) //single block
465  {
466  pstcSd->SBLCNT = 1;
467  pstcSd->STRSFMD_f.BLCKCNTSEL = 0;
468  }
469  else //multiple block
470  {
471  pstcSd->STRSFMD_f.BLCKCNTSEL = 1;
472  pstcSd->STRSFMD_f.BLCKCNTEN = 1;
473  pstcSd->STRSFMD_f.AUTOCMDEN = pstcCmdCfg->enAutoCmd;
474  pstcSd->SBLCNT = blockcount;
475  }
476 
477  result = SdSendCmdOnly(pstcSd,pstcCmdCfg) ;
478 
479  return result;
480 }
481 
494 static boolean_t SdTxData(volatile stc_sd_t* pstcSd, stc_sd_comdconfig_t * pstcCmdCfg,uint32_t* pu32Buf)
495 {
496  uint16_t i ;
497  uint16_t u16blocksize= pstcCmdCfg->u16BlockSize; //unit of Bytes
498  uint32_t* pbuf = pu32Buf;
499  uint8_t result = FALSE;
500 
501  while(TRUE != pstcSd->SNINTST_f.BUFWRRDY);// endless loop
502 
503  pstcSd->SNINTST_f.BUFWRRDY = 0;
504 
505  for(i=u16blocksize>>2;i!=0;i--)
506  {
507  if((pstcSd->SEINTST_f.DTTOERR == 1)
508  ||(pstcSd->SEINTST_f.DTEBERR == 1)
509  ||(pstcSd->SEINTST_f.DTCRCERR == 1))
510  {
511  //clear the int status
512  pstcSd->SEINTST_f.DTTOERR = 1;
513  pstcSd->SEINTST_f.DTEBERR = 1;
514  pstcSd->SEINTST_f.DTCRCERR = 1;
515  return result;
516  }
517 
518  while(pstcSd->SPRSTAT_f.BUFWREN == 0) ;//endless loop
519  pstcSd->SBUFDP = *pbuf;
520  pbuf++;
521  }
522 
523  while(TRUE != SdGetTrsComplete());
524 
525  result = TRUE;
526 
527  return result;
528 }
529 
542 static boolean_t SdRxRsp(volatile stc_sd_t* pstcSd,stc_sd_comdconfig_t * pstcCmdCfg,uint32_t* pu32Buf)
543 {
544  boolean_t result = FALSE;
545 
546  //clear the buffer
547  pu32Buf[0] = 0;
548  pu32Buf[1] = 0;
549  pu32Buf[2] = 0;
550  pu32Buf[3] = 0;
551 
552  //get response data
553  SdGetResponse(pstcSd,pstcCmdCfg->enResponse,pu32Buf);
554 
555  //check the error in response data
556  if(NULL != pstcCmdCfg->pfnErrorResponseCallback)
557  {
558  pstcCmdCfg->pfnErrorResponseCallback(pstcSd);
559  }
560  else
561  {
562  result = TRUE;
563  }
564 
565  return result;
566 }
567 
580 static boolean_t SdRxData(volatile stc_sd_t* pstcSd, stc_sd_comdconfig_t * pstcCmdCfg, uint32_t* pu32Buf)
581 {
582  uint16_t i ;
583  uint16_t u16blocksize= pstcCmdCfg->u16BlockSize; //unit of Bytes
584  uint32_t* pbuf = pu32Buf;
585  uint8_t result = FALSE;
586 
587  while(TRUE != pstcSd->SNINTST_f.BUFRDRDY);//endless loop
588 
589  for(i=u16blocksize>>2;i!=0;i--)
590  {
591  if((pstcSd->SEINTST_f.DTTOERR == 1) //DataTimeout Error
592  ||(pstcSd->SEINTST_f.DTEBERR==1) //Data End Bit Error
593  ||(pstcSd->SEINTST_f.DTCRCERR==1)) //Data CRC Error
594  {
595  //clear the int status
596  pstcSd->SEINTST_f.DTTOERR = 1;
597  pstcSd->SEINTST_f.DTEBERR=1;
598  pstcSd->SEINTST_f.DTCRCERR=1;
599  return result;
600  }
601 
602  while(pstcSd->SPRSTAT_f .BUFRDEN == 0) ;//endless loop
603  *pbuf = pstcSd->SBUFDP;
604  pbuf++ ;
605  }
606 
607  result = TRUE;
608 
609  return result;
610 }
611 
612 /******************************************************************************/
613 /* Global Functions */
614 /******************************************************************************/
625 {
626  if(NULL == pstcSd)
627  {
628  return ErrorInvalidParameter;
629  }
630 
631  //buffer read&write ready int
632  pstcSd->SNINTSTE_f.BUFRDRDYS = 1;
633  pstcSd->SNINTSTE_f.BUFWRRDYS = 1;
634 
635  //Transfer & command complete
636  pstcSd->SNINTSTE_f.TRSFCMPLTS = 1;
637  pstcSd->SNINTSTE_f.CMDCMPLTS = 1;
638 
639  return Ok;
640 }
641 
652 {
653  if(NULL == pstcSd)
654  {
655  return ErrorInvalidParameter;
656  }
657 
658  //buffer read&write ready int
659  pstcSd->SNINTSTE_f.BUFRDRDYS = 0;
660  pstcSd->SNINTSTE_f.BUFWRRDYS = 0;
661 
662  //Transfer & command complete
663  pstcSd->SNINTSTE_f.TRSFCMPLTS = 0;
664  pstcSd->SNINTSTE_f.CMDCMPLTS = 0;
665 
666  return Ok;
667 }
668 
681 {
682  if(NULL == pstcCmdCfg)
683  return DEBOUNCING;
684  else
685  return (pstcCmdCfg->enExist);
686 }
687 
699 {
700  uint8_t u8baseclock;
701  uint16_t u16divider;
702  u8baseclock = pstcSd->CAPBLTY0_f.SDBASECLK;//read hardware init value of the capability reigister
703 
704  if(NULL == pstcSd)
705  {
706  return ErrorInvalidParameter;
707  }
708 
709  //set the 10 bit divider of Clock control register, N=baseclock/(2*enClk)
710  if(u8baseclock)
711  {
712  if(u8baseclock== enClk)
713  {
714  u16divider = 0x0000;
715  }
716  else
717  {
718  u16divider = (u8baseclock>>1)/enClk;
719  }
720 
721  pstcSd->SCLKCTL_f.SDCLKSEL = (uint8_t)(u16divider &0x00FF);//lower 8bits
722  pstcSd->SCLKCTL_f.UPSDCLKSEL = (u16divider &0x0300)>>8; //higher 2bits
723  }
724  else //if the base clock frequenct register value is 0,using the default value 160 Mhz
725  {
726  pstcSd->SHCTL2_f.PREVALEN = 1;// automatic selection by preset value (4)
727  }
728 
729  pstcSd->SCLKCTL_f.INTLCLCKEN = 1;
730 
731  while (!pstcSd->SCLKCTL_f.INTLCLCKST);
732 
733  pstcSd->SCLKCTL_f.SDCLCKEN = 1;
734  return Ok;
735 }
736 
746 {
747  if(pstcSd == NULL)
748  {
749  return ErrorInvalidParameter;
750  }
751 
752  pstcSd->SCLKCTL_f.SDCLCKEN = 0;
753  return Ok;
754 }
755 
766 {
767  if((NULL == pstcSd) || (enVoltage > V3_3) || (enVoltage < V1_8))
768  {
769  return ErrorInvalidParameter;
770  }
771 
772  pstcSd->SPWRCTL_f.SDBUSVLSEL = enVoltage;
773  pstcSd->SPWRCTL_f.SDBUSPWR = 1;
774  return Ok;
775 }
776 
790 boolean_t Sd_SendCmd(en_sd_transaction_t enTran,volatile stc_sd_t* pstcSd,stc_sd_comdconfig_t * pstcCmdCfg,uint32_t* pu32Buf)
791 {
792  boolean_t result = FALSE;
793 
794  switch(enTran)
795  {
796  case NO_RESPONSE:
797  result = SdSendCmdOnly(pstcSd,pstcCmdCfg);
798  break;
799  case NO_DATA:
800  if(TRUE == SdSendCmdOnly(pstcSd,pstcCmdCfg))
801  {
802  result = SdRxRsp(pstcSd,pstcCmdCfg,pu32Buf);
803  }
804  break;
805  case SINGLE_BLOCK:
806  if(TRUE == SdSendCmdDatLine(pstcSd,pstcCmdCfg))
807  {
808  result = SdRxRsp(pstcSd,pstcCmdCfg,pu32Buf);
809  }
810  break;
811  case MULTI_BLOCK:
812  //To Do
813  break;
814  default:
815  break;
816  }
817  return result;
818 }
819 
832 boolean_t Sd_TxData(volatile stc_sd_t* pstcSd,stc_sd_comdconfig_t * pstcCmdCfg,uint32_t* pu32Buf)
833 {
834  boolean_t result = FALSE;
835 
836  result = SdTxData(pstcSd,pstcCmdCfg,pu32Buf);
837 
838  return result;
839 }
840 
854 boolean_t Sd_RxData(en_sd_transaction_t enTran,volatile stc_sd_t* pstcSd,stc_sd_comdconfig_t * pstcCmdCfg,uint32_t* pu32Buf)
855 {
856  boolean_t result = FALSE;
857  uint8_t waittime = RETRYTIMES;
858 
859  //wait for read buffer is ready
860  while((0 == pstcSd->SPRSTAT_f.BUFRDEN) && (waittime > 0))
861  {
862  waittime--;
863  dly_1unit(1);
864  }
865 
866  switch(enTran)
867  {
868  case SINGLE_BLOCK:
869  result = SdRxData(pstcSd,pstcCmdCfg,pu32Buf);
870  break;
871  case MULTI_BLOCK:
872  //To Do
873  break;
874  default:
875  break;
876  }
877  return result;
878 }
879 
890 en_result_t Sd_SoftwareReset( volatile stc_sd_t* pstcSd,uint8_t u8reset)
891 {
892  if(NULL == pstcSd)
893  {
894  return ErrorInvalidParameter;
895  }
896 
897  pstcSd->SSRST |= u8reset;
898 
899  while(pstcSd->SSRST & (~u8reset)); //endless loop
900 
901  pstcSd->SSRST &= ~u8reset;
902 
903  return Ok;
904 }
905 
911 void Sd_Handler(void)
912 {
913  SdIrqHandler();
914 }
915 
925 {
926  SdInitPins();
927 
928  if (TRUE == SdEnablePCG())
929  {
930  SdInitHostInternalData(&Sd_stcCfg, &Sd_stcCmdCfg);
931  SdGetCardStatus(Sd_stcCtrl,&Sd_stcCfg);
932 
933  if(INSERTED == Sd_CardDetect(&Sd_stcCfg))
934  {
938  return Ok;
939  }
940  else
941  {
942  return Error;
943  }
944  }
945  else
946  {
947  return Error;
948  }
949 }
950 
959 {
962  SdDisablePCG();
963  return Ok;
964 }
965 
967 
968 #endif // #if (defined(PDL_PERIPHERAL_SD_ACTIVE))
969 
970 /******************************************************************************/
971 /* EOF (not truncated) */
972 /******************************************************************************/
973