0001: //wymaga zdefiniowania debug_puts(char*) do wysłania łąńcucha znaków 
0002: // oraz debug_send_char(char) wysyłający pojedynczy znak lub bajt
0003: /*=========================================================================*/
0004: /*!\brief funkcja przetwarza dolny półbajt da ASCII HEX
0005:  *
0006:  *
0007:  *
0008:  * \date 07.06.2011
0009:  *
0010:  * \param       : unsigned char val wartość 0..15 brak wewnętrznej kontroli przekroczenia zakresu
0011:  *
0012:  * \retval
0013:  *
0014:  * \callgraph
0015:  * \callergraph*/
0016: /*=========================================================================*/
0017: char ascii(unsigned char val)
0018: {
0019: // czytelne nie jest szybkie i małe, szybkie i małe nie jest czytelne
0020: #if 1
0021: //szybkie
0022:     if(9<val)
0023:     {
0024:         val=(val+('7'-'0'));
0025:     }
0026:     return (char)(val+'0');
0027: #else
0028: // czytelne
0029:     if(10>val)
0030:     {
0031:         return (char)(val+'0');
0032:     }
0033:     else
0034:     {
0035:         return (char)(val+'7');
0036:     }
0037: #endif
0038: }
0039: 
0040: 
0041: /*=========================================================================*/
0042: /*!\brief funkcja wysyła bajt w postaci ASCII HEX
0043:  *
0044:  *      
0045:  *
0046:  * \date 07.06.2011
0047:  *
0048:  * \param       : 
0049:  *
0050:  * \retval
0051:  *
0052:  * \callgraph
0053:  * \callergraph*/
0054: /*=========================================================================*/
0055: void priv_debug_send_byte(u8_t val)
0056: {
0057:     if(!debug_st.dbg) return;
0058:     debug_send_char(ascii((val>>4)&0x0f));
0059:     debug_send_char(ascii(val&0x0f));
0060: }
0061: 
0062: 
0063: 
0064: /*=========================================================================*/
0065: /*!\brief funkcja wysyła słowo w postaci ASCII HEX
0066:  *
0067:  *      
0068:  *
0069:  * \date 07.06.2011
0070:  *
0071:  * \param       : 
0072:  *
0073:  * \retval
0074:  *
0075:  * \callgraph
0076:  * \callergraph*/
0077: /*=========================================================================*/
0078: void priv_debug_send_word(u16_t val)
0079: {
0080:     if(!debug_st.dbg) return;
0081:     debug_send_byte((u8_t)(val>>8));
0082:     debug_send_byte((u8_t)(val));
0083: }
0084: 
0085: 
0086: 
0087: /*=========================================================================*/
0088: /*!\brief funkcja wysyła podwójne słowo w postaci ASCII HEX
0089:  *
0090:  *      
0091:  *
0092:  * \date 07.06.2011
0093:  *
0094:  * \param       : 
0095:  *
0096:  * \retval
0097:  *
0098:  * \callgraph
0099:  * \callergraph*/
0100: /*=========================================================================*/
0101: void priv_debug_send_long(u32_t val)
0102: {
0103:     if(!debug_st.dbg) return;
0104:     debug_send_word((u16_t)(val>>16));
0105:     debug_send_word((u16_t)(val));
0106: }
0107: 
0108: 
0109: 
0110: /*=========================================================================*/
0111: /*!\brief funkcja wysyła sformatowany blok pamięci  w postaci ASCII HEX
0112:  *
0113:  *
0114:  *
0115:  * \date 07.06.2011
0116:  *
0117:  * \param       :
0118:  *
0119:  * \retval
0120:  *
0121:  * \callgraph
0122:  * \callergraph*/
0123: /*=========================================================================*/
0124: 
0125: void priv_debug_send_block_hex(char* adress, u16_t size)
0126: {
0127:     if(!debug_st.dbg) return;
0128:     u16_t       cnt;
0129:     dbg_printf("\n\r================================================");
0130:     for(cnt=0;cnt<size;cnt++)
0131:     {
0132:         if(0==(cnt%16)) dbg_printf("\n\r");
0133:         priv_debug_send_byte((u8_t)adress[cnt]);
0134:     }
0135:     dbg_printf("\n\n\r");
0136: }
0137: 
0138: 
0139: 
0140: 
0141: /*=========================================================================*/
0142: /*!\brief funkcja wysyła string null terminated
0143:  *
0144:  *
0145:  *
0146:  * \date
0147:  *
0148:  * \param       :
0149:  *
0150:  * \retval
0151:  *
0152:  * \callgraph
0153:  * \callergraph*/
0154: /*========================================================================*/
0155: void priv_dbg_puts(char* ptr)
0156: {
0157:     if(!debug_st.dbg) return;
0158:     while(*ptr)
0159:     {
0160:         debug_send_char(*ptr++);
0161:     }
0162: }
0163: 
0164: 
0165: #define BASE 10
0166: /*=========================================================================*/
0167: /*!\brief funkcja 
0168:  *
0169:  *      
0170:  *
0171:  * \date 07.06.2011
0172:  *
0173:  * \param       : 
0174:  *
0175:  * \retval
0176:  *
0177:  * \callgraph
0178:  * \callergraph*/
0179: /*==========================================================================*/
0180: #if 0
0181: void debug_send_wordSigDec(unsigned char issigned, unsigned short val)
0182: {
0183:     char str[6+1] = "      ";
0184:     if(!dbg) return;
0185: 
0186:     unsigned short u_val = val;
0187:     char *ptr = str+6; //last char in str
0188: 
0189:     if(issigned)//Signed types
0190:     {
0191:         if(u_val & 0x8000) //Value negativ ?
0192:         {
0193:             u_val = ~u_val+1;
0194:             str[0] = '-';
0195:         }
0196:     }
0197: //  *--ptr = 0;
0198:     do
0199:     {
0200:         char ch = u_val % BASE + '0';
0201: #if(BASE>10)
0202:         if(ch > '9')
0203:         {
0204:             ch += 'A' - '9' - 1;
0205:         }
0206: #endif
0207:         *--ptr = ch;
0208:         u_val /= BASE;
0209:     }
0210:     while (u_val);
0211: 
0212: //    UartSendString(str);
0213: //      Uart0_puts_p(str);
0214:     fprintf_P(FDEBUG,str);
0215: 
0216: }
0217: #endif
0218: /*=========================================================================*/
0219: /*!\brief funkcja 
0220:  *
0221:  *      
0222:  *
0223:  * \date 07.06.2011
0224:  *
0225:  * \param       : 
0226:  *
0227:  * \retval
0228:  *
0229:  * \callgraph
0230:  * \callergraph*/
0231: /*=========================================================================*/
0232: void priv_dbg_dump(unsigned char *p, unsigned int size)
0233: {
0234:     if(!debug_st.dbg) return;
0235:     unsigned int ii;
0236:     dbg_printf("\r\nAddress: 0x%x\r\n          ", (u32_t) p);
0237: 
0238:     for(ii=0;ii<15;ii++)
0239:     {
0240:         debug_send_byte(ii);
0241:         if((ii==0x07))
0242:         {
0243:             debug_send_char(' ');
0244:             debug_send_char('-');
0245:             debug_send_char(' ');
0246:         }
0247:         else
0248:         {
0249:             debug_send_char('-');
0250:         }
0251:     }
0252:     debug_send_byte(ii);
0253:     ii=0;
0254:     while (size--)
0255:     {
0256:         if((ii&0x000F)==0x0000)
0257:         {
0258:             debug_send_char('\r');
0259:             debug_send_char('\n');
0260:             debug_send_long((u32_t) p);
0261:             debug_send_char(' ');
0262:             debug_send_char(' ');
0263:         }
0264:         else if((ii&0x0007)==0x0000)
0265:         {
0266:             debug_send_char(' ');
0267:             debug_send_char('-');
0268:             debug_send_char(' ');
0269:         }
0270:         else
0271:         {
0272:             debug_send_char(' ');
0273:         }
0274:         debug_send_byte(*p++);
0275:         ii++;
0276:     }
0277: }
0278: 
0279: //#define SCRATCH 12    //32Bits go up to 4GB + 1 Byte for \0
0280: #define SCRATCH 21      //64Bits go up to
0281: 
0282: //#define dbg_putc(chr) sendchar(chr)
0283: //#define dbg_puts(str) UartSendString(str)
0284: #define get_format(x) (pgm_read_byte(x))
0285: 
0286: /*=========================================================================*/
0287: /*!\brief funkcja wysyła bajt w postaci ASCII BIN
0288:  *
0289:  *
0290:  *
0291:  * \date 07.06.2011
0292:  *
0293:  * \param       :
0294:  *
0295:  * \retval
0296:  *
0297:  * \callgraph
0298:  * \callergraph*/
0299: /*=========================================================================*/
0300: void priv_dbg_bin8(u8_t val)
0301: {
0302:     if(!debug_st.dbg) return;
0303:     u8_t cnt;
0304:     for(cnt=0;cnt<8;cnt++)
0305:     {
0306:         if(0x80&val)
0307:         {
0308:             debug_send_char('1');
0309:         }
0310:         else
0311:         {
0312:             debug_send_char('0');
0313:         };
0314:         val<<=1;
0315:         if (3==cnt)     debug_send_char(' ');
0316:     };
0317: }
0318: 
0319: /*=========================================================================*/
0320: /*!\brief funkcja wysyła słowo w postaci ASCII BIN
0321:  *
0322:  *
0323:  *
0324:  * \date 07.06.2011
0325:  *
0326:  * \param       :
0327:  *
0328:  * \retval
0329:  *
0330:  * \callgraph
0331:  * \callergraph*/
0332: /*=========================================================================*/
0333: void priv_dbg_bin16(u16_t val)
0334: {
0335:     if(!debug_st.dbg) return;
0336:     dbg_bin8((u8_t)(val>>8));
0337:     debug_send_char(' ');
0338:     dbg_bin8((u8_t)val);
0339: 
0340: }
0341: 
0342: 
0343: 
0344: /*=========================================================================*/
0345: /*!\brief funkcja wysyła podwójne słowo w postaci ASCII BIN
0346:  *
0347:  *
0348:  *
0349:  * \date 07.06.2011
0350:  *
0351:  * \param       :
0352:  *
0353:  * \retval
0354:  *
0355:  * \callgraph
0356:  * \callergraph*/
0357: /*=========================================================================*/
0358: void priv_dbg_bin32(u32_t val)
0359: {
0360:     if(!debug_st.dbg) return;
0361:     dbg_bin16((u16_t)(val>>16));
0362:     debug_send_char(' ');
0363:     dbg_bin16((u16_t)val);
0364: }
0365: 
0366: 
0367: 
0368: /*=========================================================================*/
0369: /*!\brief funkcja wysyła poczwórne słowo w postaci ASCII BIN
0370:  *
0371:  *
0372:  *
0373:  * \date 07.06.2011
0374:  *
0375:  * \param       :
0376:  *
0377:  * \retval
0378:  *
0379:  * \callgraph
0380:  * \callergraph*/
0381: /*=========================================================================*/
0382: void priv_dbg_bin64(u64_t val)
0383: {
0384:     if(!debug_st.dbg) return;
0385:     dbg_bin32((u32_t)(val>>32));
0386:     debug_send_char(' ');
0387:     dbg_bin32((u32_t)val);
0388: 
0389: }
0390: 
0391: 
0392: /*=========================================================================*/
0393: /*!\brief funkcja prostego printf-a
0394:  * znaczniki formatujace %l %c %o %s %d %u %x
0395:  *      
0396:  *
0397:  * \date 07.06.2011
0398:  *
0399:  * \param       : 
0400:  *
0401:  * \retval
0402:  *
0403:  * \callgraph
0404:  * \callergraph*/
0405: /*=========================================================================*/
0406: // %c   char    dziala
0407: // %s   char    dziala
0408: // %ld  s64_t   dziala
0409: // %lu  u64_t   dziala
0410: // %o
0411: // %d   s32_t   dziala
0412: // %u   u32_t   dziala
0413: // %x   u32_t   dziala
0414: // %b   dodac
0415: #define USE_OCTAL
0416: int dbg_printf(char const *format, ...)
0417: {
0418:     if(!debug_st.dbg) return 0;
0419:     char scratch[SCRATCH];
0420:     unsigned char format_flag;
0421:     unsigned short base;
0422:     char *ptr;
0423:     char *s=0;
0424:     unsigned char issigned=0;
0425:     va_list ap;
0426: 
0427:     unsigned char islong=0;
0428:     long s_val=0;
0429:     unsigned long u_val=0;
0430: 
0431:     unsigned char fill;
0432:     unsigned char width;
0433: 
0434:     va_start(ap,format);
0435: 
0436:     ptr=(char *)format;
0437: //      for(base=0;base<8;base++)
0438: //      {
0439: //        dbg_putc(get_format(ptr++));
0440: //      }
0441: 
0442:     for (;;)
0443:     {
0444:         while((format_flag=get_format(format++))!='%')
0445:         { // Until '%' or '\0'
0446:             if(!format_flag)
0447:             {
0448:                 va_end(ap);
0449:                 return 0;
0450:             }
0451:             debug_send_char(format_flag);
0452:         }
0453: 
0454:         issigned=0; //default unsigned
0455:         base=10;
0456: 
0457:         format_flag = get_format(format++); //get char after '%'
0458: 
0459:         width=0; //no formatting
0460:         fill=0;  //no formatting
0461:         if(format_flag=='0'||format_flag==' ') //SPACE or ZERO padding  ?
0462:         {
0463:             fill=format_flag;
0464:             format_flag=get_format(format++); //get char after padding char
0465: 
0466:             if(format_flag>='0'&&format_flag<='9')
0467:             {
0468:                 width=format_flag-'0';
0469:                 format_flag=get_format(format++); //get char after width char
0470:             }
0471:             while(format_flag>='0'&&format_flag<='9')
0472:             {
0473:                 width*=10;
0474:                 width+=format_flag - '0';
0475:                 format_flag=get_format(format++); //get next char
0476:             }
0477:         }
0478: 
0479:         islong = 0; //default int value
0480:         if(format_flag=='l') //Long value
0481:         {
0482:             islong = 1;
0483:             format_flag=get_format(format++); //get char after 'l' or 'L'
0484:         }
0485: 
0486:         switch(format_flag)
0487:         {
0488: //      case 't':
0489: //       dbg_putc('\r');
0490: //       dbg_putc('\n');
0491: //       dbg_puts(timestr(get_up_timer()));
0492: //       dbg_putc('.');
0493: //       dbg_puts(lstr((get_sys_timer()%1000), 3));
0494: //       dbg_putc(' ');
0495: //       continue;
0496: //
0497:             case 'c':
0498:                 format_flag=va_arg(ap,int);                             /* no break -> run into default */
0499: 
0500:             default:
0501:                 debug_send_char(format_flag);
0502:                 continue;
0503:             case 's':
0504:                 ptr=(char*)va_arg(ap,char *);
0505:                 /* TODO : add format dependent send */
0506:                 dbg_puts(ptr);
0507:                 //fprintf_p(FDEBUG, ptr);
0508:                 //Uart0_puts_p(ptr);
0509:                 continue;
0510: #ifdef USE_OCTAL
0511:             case 'o':
0512:                 base=8;
0513:                 *s++='0';
0514:                 *s=0;
0515:                 goto CONVERSION_LOOP;
0516: #endif
0517:             case 'd':
0518:                 issigned = 1;
0519:                 // no break -> run into next case
0520:             case 'u':
0521: 
0522:                 //don't insert some case below this if USE_HEX is undefined !
0523:                 //or put       goto CONVERSION_LOOP;  before next case.
0524:                 goto CONVERSION_LOOP;
0525:             case 'x':
0526:                 base=16;
0527: 
0528:                 CONVERSION_LOOP:
0529:                 if(issigned) //Signed types
0530:                 {
0531:                     if(islong)
0532:                     {
0533:                         s_val=va_arg(ap,u64_t);
0534:                     }
0535:                     else
0536:                     {
0537:                         s_val=va_arg(ap,u32_t);
0538:                     }
0539: 
0540:                     if(s_val<0) //Value negativ ?
0541:                     {
0542:                         s_val=-s_val; //Make it positiv
0543:                         debug_send_char('-');
0544:                     }
0545: 
0546:                     u_val=(u64_t)s_val;
0547:                 }
0548:                 else //Unsigned types  /*if(issigned)*/
0549:                 {
0550:                     if(islong)
0551:                     {
0552:                         u_val=va_arg(ap,u64_t);
0553:                     }
0554:                     else
0555:                     {
0556:                         u_val=va_arg(ap,u32_t);
0557:                     }
0558:                 }/* if(issigned) */
0559: 
0560:                 ptr=scratch+SCRATCH;
0561:                 *--ptr=0;
0562:                 do
0563:                 {
0564:                     char ch=u_val%base+'0';
0565:                     if(ch>'9')
0566:                     {
0567:                         ch+='A'-'9'-1;
0568:                     }
0569:                     *--ptr=ch;
0570:                     u_val/=base;
0571:                     if(width) width--; //calculate number of padding chars
0572:                 } while(u_val);
0573:                 while(width--)
0574:                 *--ptr=fill; //insert padding chars
0575:                 dbg_puts(ptr);
0576:         } /* switch(format_flag) */
0577:     } /* for(;;) */
0578:     return 0; /* never here ! */
0579: }
0580: 
0581: 
0582: 
0583: /*============================================================================*/
0584: /*!\brief
0585:  *
0586:  *
0587:  * \param
0588:  *
0589:  * \retval
0590:  *
0591:  * \todo
0592:  *
0593:  * \callgraph
0594:  * \callergraph*/
0595: /*============================================================================*/
0596: void priv_dbg_TIM(TIM_TypeDef *handle)
0597: {
0598:     if(!debug_st.dbg) return;
0599:     u32_t       temp;
0600:     char tmp=0;
0601:     dbg_printf("\n\r===============================================\n\rTIMER ");
0602:     if((char*) handle == (char*) TIM1_BASE)
0603:     {
0604:         tmp = 1;
0605:     };
0606: #ifdef TIM2_BASE
0607:     if((char*) handle == (char*) TIM2_BASE)
0608:     {
0609:         tmp = 2;
0610:     };
0611: #endif
0612:     if((char*) handle == (char*) TIM3_BASE)
0613:     {
0614:         tmp = 3;
0615:     };
0616:     //if((char*)handle == (char*)TIM4_BASE){tmp=0x4;};
0617:     //if((char*)handle == (char*)TIM5_BASE){tmp=0x5;};
0618: #ifdef TIM6_BASE
0619:     if((char*) handle == (char*) TIM6_BASE)
0620:     {
0621:         tmp = 6;
0622:     };
0623: #endif
0624:     //if((char*)handle == (char*)TIM7_BASE){tmp=0x7;};
0625:     //if((char*)handle == (char*)TIM8_BASE){tmp=0x8;};
0626:     //if((char*)handle == (char*)TIM9_BASE){tmp=0x9;};
0627:     //if((char*)handle == (char*)TIM10_BASE){tmp=0x10;};
0628:     //if((char*)handle == (char*)TIM11_BASE){tmp=0x11;};
0629:     //if((char*)handle == (char*)TIM12_BASE){tmp=0x12;};
0630:     //if((char*)handle == (char*)TIM13_BASE){tmp=0x13;};
0631:     if((char*) handle == (char*) TIM14_BASE)
0632:     {
0633:         tmp = 14;
0634:     };
0635: #ifdef TIM15_BASE
0636:     if((char*) handle == (char*) TIM15_BASE)
0637:     {
0638:         tmp = 15;
0639:     };
0640: #endif
0641:     if((char*) handle == (char*) TIM16_BASE)
0642:     {
0643:         tmp = 16;
0644:     };
0645:     if((char*) handle == (char*) TIM17_BASE)
0646:     {
0647:         tmp = 17;
0648:     };
0649:     if(0==tmp)
0650:     {
0651:         dbg_printf("\n\n\rTIMER %u not exist",tmp);
0652:         return;
0653:     }
0654:     dbg_printf("%u",tmp);
0655:     //debug_send_byte(tmp);
0656: 
0657:     dbg_printf("\n\rCR1:  ");
0658:     debug_send_word(handle->CR1);
0659:     dbg_printf("  CR2:  ");
0660:     debug_send_word(handle->CR2);
0661:     dbg_printf("  SMCR: ");
0662:     debug_send_word(handle->SMCR);
0663:     dbg_printf("  DIER: ");
0664:     debug_send_word(handle->DIER);
0665:     dbg_printf("  SR:   ");
0666:     debug_send_word(handle->SR);
0667: 
0668:     dbg_printf("\n\rEGR:  ");
0669:     debug_send_word(handle->EGR);
0670:     dbg_printf("  CCMR1:");
0671:     debug_send_word(handle->CCMR1);
0672:     dbg_printf("  CCMR2:");
0673:     debug_send_word(handle->CCMR2);
0674:     dbg_printf("  CCER: ");
0675:     debug_send_word(handle->CCER);
0676:     dbg_printf("  CNT:  ");
0677:     debug_send_long(   *((u32_t*)&handle->CNT)   );
0678: 
0679:     dbg_printf("\n\rPSC:  ");
0680:     debug_send_word(handle->PSC);
0681:     dbg_printf("  ARR:  ");
0682:     debug_send_word(handle->ARR);
0683:     dbg_printf("  RCR:  ");
0684:     debug_send_word(handle->RCR);
0685:     dbg_printf("  CCR1: ");
0686:     debug_send_long(   *((u32_t*)&handle->CCR1)   );
0687:     dbg_printf("  CCR2: ");
0688:     debug_send_long(   *((u32_t*)&handle->CCR2)   );
0689:     dbg_printf("\n\rCCR3: ");
0690:     debug_send_long(   *((u32_t*)&handle->CCR3)   );
0691: 
0692:     dbg_printf("  CCR4: ");
0693:     debug_send_long(   *((u32_t*)&handle->CCR4)   );
0694:     dbg_printf("  BDTR: ");
0695:     debug_send_word(handle->BDTR);
0696:     dbg_printf("  DCR:  ");
0697:     debug_send_word(handle->DCR);
0698:     dbg_printf("  DMAR: ");
0699:     debug_send_word(handle->DMAR);
0700:     dbg_printf("  OR:   ");
0701:     debug_send_word(handle->OR);
0702:     dbg_printf("\n\r-------------------------------------------------");
0703: /*----------------------------------------------------------------------------------*/
0704:     temp=handle->CR1;
0705:     dbg_printf("\n\n\rTIMER %u is O",tmp);
0706:     if(1 == (temp&0x01))
0707:     {
0708:         dbg_printf("N");
0709:     }
0710:     else
0711:     {
0712:         dbg_printf("FF");
0713:     }
0714: 
0715:     dbg_printf(" and update is ");
0716:     if(1 == ((temp>>1)&0x01))
0717:     {
0718:         dbg_printf("DISABLE");
0719:     }
0720:     else
0721:     {
0722:         dbg_printf("ENABLE");
0723:     }
0724: #if 0
0725:     dbg_printf(" update requests are ");
0726:     if(1 == ((temp>>2)&0x01))
0727:     {
0728:         dbg_printf("DISABLE");
0729:     }
0730:     else
0731:     {
0732:         dbg_printf("ENABLE");
0733:     }
0734: #endif
0735:     if(1 == ((temp>>3)&0x01))
0736:     {
0737:         dbg_printf(" Work in ONE PULSE mode");
0738:     }
0739:     else
0740:     {
0741:         dbg_printf(" Work in CYCLIC mode");
0742:     }
0743: 
0744:     switch ((temp>>5)&0x03)
0745:     {
0746:         case 0 :
0747:         {
0748:             if(1 == ((temp>>4)&0x01))
0749:             {
0750:                 dbg_printf(" DOWN count");
0751:             }
0752:             else
0753:             {
0754:                 dbg_printf(" UP count");
0755:             }
0756:             break;
0757:         }
0758:         case 1 :
0759:         {
0760:             dbg_printf(" Center mode for CCxS=00 TIMx_CCMRx is set for down counter");
0761:             break;
0762:         }
0763:         case 2 :
0764:         {
0765:             dbg_printf(" Center mode for CCxS=00 TIMx_CCMRx is set for up counter");
0766:             break;
0767:         }
0768:         case 3 :
0769:         {
0770:             dbg_printf(" Center mode for CCxS=00 TIMx_CCMRx is set for up and down counter");
0771:             break;
0772:         }
0773:     }
0774:     if(1 == ((temp>>3)&0x01))
0775:     {
0776:         dbg_printf("\n\r ARR is buffered");
0777:     }
0778:     u32_t       timer_clocki_in=(1+(handle->PSC));
0779: 
0780:     dbg_printf("\n\rprescaller divide by        [%u]", timer_clocki_in );
0781:     timer_clocki_in=apb_frequency/timer_clocki_in;
0782:     dbg_printf("\n\rclock in                    [%u] Hz",(1+(handle->PSC))  );
0783:     dbg_printf("\n\rclock autoreload            [%u] Hz",(timer_clocki_in/(handle->ARR))  );
0784: 
0785: }
0786: 
0787: 
0788: 
0789: /*============================================================================*/
0790: /*!\brief
0791:  *
0792:  *
0793:  * \param
0794:  *
0795:  * \retval
0796:  *
0797:  * \todo
0798:  *
0799:  * \callgraph
0800:  * \callergraph*/
0801: /*============================================================================*/
0802: void priv_dbg_GPIO(GPIO_TypeDef *handle)
0803: {
0804:     if(!debug_st.dbg) return;
0805:     char tmp;
0806:     u8_t pos;
0807:     u8_t b_temp;
0808:     u8_t b_pos;
0809:     u32_t maska_pom;
0810:     //u16_t maska1;
0811:     //u32_t maska2;
0812:     /* ----------------------------------------------------------------- */
0813:     dbg_printf("\n\rPORT ");
0814:     if((char*) handle == (char*) GPIOA_BASE) tmp = 'A';
0815:     if((char*) handle == (char*) GPIOB_BASE) tmp = 'B';
0816:     if((char*) handle == (char*) GPIOC_BASE) tmp = 'C';
0817:     if((char*) handle == (char*) GPIOD_BASE) tmp = 'D';
0818: //      if((char*) handle == (char*) GPIOE_BASE) tmp = 'E';
0819:     if((char*) handle == (char*) GPIOF_BASE) tmp = 'F';
0820:     debug_send_char(tmp);
0821: 
0822:     if  (
0823:             0
0824:             !=
0825:             (
0826:                 (RCC->AHBENR)>>( (17+tmp) -'A')
0827:                 &
0828:                 0x01
0829:             )
0830:         )
0831:     {
0832:         dbg_printf(" => CLOCK ENABLE  ");
0833:     }
0834:     else
0835:     {
0836:         dbg_printf(" => CLOCK DISABLE ");
0837:     }
0838: /* -------------------------------------------------------------- */
0839:     dbg_printf("\n\rMODER: ");          debug_send_long(handle->MODER);
0840:     dbg_printf("  OTYPER: ");           debug_send_word(handle->OTYPER);
0841:     dbg_printf("  OSPEEDR:");           debug_send_long(handle->OSPEEDR);
0842:     dbg_printf("  PUPDR:  ");           debug_send_long(handle->PUPDR);
0843:     dbg_printf("\n\rIDR:    ");         debug_send_word(handle->IDR);
0844:     dbg_printf("  ODR:   ");            debug_send_word(handle->ODR);
0845: 
0846:     dbg_printf("  BSRR:   ");           debug_send_word(handle->BSRR);
0847:     dbg_printf("  LCKR:   ");           debug_send_word(handle->LCKR);
0848:     dbg_printf("\n\rAFR[0]: ");         debug_send_long(handle->AFR[0]);
0849:     dbg_printf("  AFR[1]: ");           debug_send_long(handle->AFR[1]);
0850:     dbg_printf("  BRR:   ");            debug_send_word(handle->BRR);
0851: 
0852:     dbg_printf("\n\rPIN   O    I   Pull    mode      speed");
0853:     u16_t       tmp_in=handle->IDR;
0854:     u16_t       tmp_out=handle->ODR;
0855:     for (pos = 0; pos < 16; pos++)
0856:     {
0857:         //maska1 = (1 << pos);
0858:         //maska2 = (3 << (pos + pos));
0859:         dbg_printf("\n\rP%c%x  ", tmp, pos); /* PAn, PBn ... PFn*/
0860: 
0861:         /* ------------ level Out --------------------------------------------- */
0862:         b_pos = (tmp_out & 0x01);
0863:         tmp_out>>=1;
0864:         if(1==b_pos)
0865:         {
0866:             dbg_printf("'H'  "); /* PAn, PBn ... PFn*/
0867:         }
0868:         else
0869:         {
0870:             dbg_printf("'L'  "); /* PAn, PBn ... PFn*/
0871:         }
0872: 
0873:         /* ------------ level In ---------------------------------------------- */
0874:         b_pos = (tmp_in & 0x01); /* in level */
0875:         tmp_in>>=1;
0876:         if(1==b_pos)
0877:         {
0878:             dbg_printf("'H'  "); /* PAn, PBn ... PFn*/
0879:         }
0880:         else
0881:         {
0882:             dbg_printf("'L'  "); /* PAn, PBn ... PFn*/
0883:         }
0884:         /* -------------------------------------------------------------------- */
0885: 
0886:         /*------------------------------------------------------------------------*/
0887:         /* podciaganie : */
0888:         switch ((handle->PUPDR) >> (pos + pos) & 0x03)
0889:         {
0890:             case 1:
0891:             {
0892:                 dbg_printf("Pup     ");
0893:                 break;
0894:             }
0895:             case 2:
0896:             {
0897:                 dbg_printf("Pdown   ");
0898:                 break;
0899:             }
0900:             default:
0901:             {
0902:                 dbg_printf("No pull ");
0903:                 break;
0904:             }
0905:         }/*switch ((handle->PUPDR) >> (pos + pos) & 0x03)*/
0906:         /*------------------------------------------------------------------------*/
0907:         b_temp = ((handle->MODER) >> (pos + pos)) & 0x03;
0908:         switch (b_temp)
0909:         {
0910:             case 0:/*------------------------------------------------------------*/
0911:             {
0912:                 dbg_printf("Input   "); /* PAn, PBn ... PFn*/
0913:                 break;
0914:             }
0915:             case 1:/*------------------------------------------------------------*/
0916:             {
0917:                 /* wyjscie typu: */
0918:                 if(1 == (((handle->OTYPER) >> pos) & 0x01))
0919:                 {
0920:                     dbg_printf("Open-drain "); /* PAn, PBn ... PFn*/
0921:                 }
0922:                 else
0923:                 {
0924:                     dbg_printf("Push-pull  "); /* PAn, PBn ... PFn*/
0925:                 }
0926:                 /* szybkosc wyjscia : */
0927:                 switch ((handle->OSPEEDR) >> (pos + pos) & 0x03)
0928:                 {
0929:                     case 3:
0930:                     {
0931:                         dbg_printf("50MHz"); /* PAn, PBn ... PFn*/
0932:                         break;
0933:                     }
0934:                     case 1:
0935:                     {
0936:                         dbg_printf("10MHz"); /* PAn, PBn ... PFn*/
0937:                         break;
0938:                     }
0939:                     default:
0940:                     {
0941:                         dbg_printf(" 2MHz"); /* PAn, PBn ... PFn*/
0942:                         break;
0943:                     }
0944:                 }
0945:                 break;
0946:             }
0947:             case 2:/*------------------------------------------------------------*/
0948:             {
0949:                 /* wyjscie typu: */
0950:                 if(1 == (((handle->OTYPER) >> pos) & 0x01))
0951:                 {
0952:                     dbg_printf("Open-drain "); /* PAn, PBn ... PFn*/
0953:                 }
0954:                 else
0955:                 {
0956:                     dbg_printf("Push-pull  "); /* PAn, PBn ... PFn*/
0957:                 }
0958:                 /* szybkosc wyjscia : */
0959:                 switch ((handle->OSPEEDR) >> (pos + pos) & 0x03)
0960:                 {
0961:                     case 3:
0962:                     {
0963:                         dbg_printf("50MHz"); /* PAn, PBn ... PFn*/
0964:                         break;
0965:                     }
0966:                     case 1:
0967:                     {
0968:                         dbg_printf("10MHz"); /* PAn, PBn ... PFn*/
0969:                         break;
0970:                     }
0971:                     default:
0972:                     {
0973:                         dbg_printf(" 2MHz"); /* PAn, PBn ... PFn*/
0974:                         break;
0975:                     }
0976:                 }
0977:                 dbg_printf("   "); /* PAn, PBn ... PFn*/
0978: 
0979: 
0980:                 dbg_printf("Alt"); /* PAn, PBn ... PFn*/
0981:                 b_pos = pos;
0982:                 if(8 > pos)
0983:                 {
0984:                     maska_pom = handle->AFR[0];
0985:                 }
0986:                 else
0987:                 {
0988:                     maska_pom = handle->AFR[1];
0989:                     b_pos -= 8;
0990:                 }
0991:                 b_pos = (b_pos << 2);/* b_pos*4 */
0992:                 b_pos = ((maska_pom >> b_pos) & 0x0F);
0993:                 if(('A' != tmp) && (3 < b_pos))
0994:                 {
0995:                     dbg_printf(" ERR "); /* Bledny level Alternative function*/
0996:                 }
0997:                 else
0998:                 {
0999:                     dbg_printf("%u    ", b_pos); /* numer funkcji alternatywnej dla portu*/
1000:                 }
1001:                 break;
1002:             }
1003:             case 3:/*------------------------------------------------------------*/
1004:             {
1005:                 dbg_printf("Analog  "); /* PAn, PBn ... PFn*/
1006:                 break;
1007:             }
1008:         } /*switch (b_temp)*/
1009: #if 0
1010:         if      (
1011:                 1
1012:                 ==
1013:                 (
1014:                         (handle->LCKR >> pos)
1015:                         &
1016:                         0x01
1017:                 )
1018:             )
1019:         {
1020:             dbg_printf("                (Lock)");
1021:         }
1022:         else
1023:         {
1024:             dbg_printf("                (Unlock)");
1025:         }
1026: #endif
1027:     } /*for (pos = 0; pos < 16; pos++) */
1028: 
1029:     dbg_printf("\n\n\n\r");
1030: }
1031: 
1032: 
1033: /*============================================================================*/
1034: /*!\brief
1035:  *
1036:  *
1037:  * \param
1038:  *
1039:  * \retval
1040:  *
1041:  * \todo
1042:  *
1043:  * \callgraph
1044:  * \callergraph*/
1045: /*============================================================================*/
1046: void priv_dbg_RESET_RCC(void)
1047: {
1048:     if(!debug_st.dbg) return;
1049:     u32_t       tmp;
1050:     dbg_printf("\n\r===========  RCC  ==============");
1051:     dbg_printf("\n\r    CR:   ");debug_send_long((u32_t)RCC->CR);
1052:     dbg_printf("\n\r    CFGR: ");debug_send_long((u32_t)RCC->CFGR);
1053:     dbg_printf("\n\r    CFGR2:");debug_send_long((u32_t)RCC->CFGR2);
1054: 
1055: 
1056: 
1057:     tmp=RCC->CR;
1058:     /* ------------------------------------------------- */
1059:     /* -------------------  HSI  ----------------------- */
1060:     {           dbg_printf("\n\n\r=========\n\rHSI internal 8MHz oscilator is ");       }
1061:     if(1==(tmp &        0x01)   )
1062:     {           dbg_printf("ON");       }
1063:     else
1064:     {           dbg_printf("OFF");      }
1065: 
1066:     {           dbg_printf(" and ");    }
1067:     if(1==((tmp>>1) & 1 )       )
1068:     {           dbg_printf("READY");    }
1069:     else
1070:     {           dbg_printf("NOT READY");        }
1071: 
1072: 
1073: 
1074:     /* ------------------------------------------------- */
1075:     /* -------------------  HSE  ----------------------- */
1076:     {           dbg_printf("\n\r=========\n\rHSE External oscilator is ");      }
1077:     if(1==((tmp>>16) & 1)       )
1078:     {           dbg_printf("ON");       }
1079:     else
1080:     {           dbg_printf("OFF");      }
1081: 
1082:     dbg_printf(" and ");
1083:     if(1==((tmp>>17) & 1)       )
1084:     {           dbg_printf("READY");    }
1085:     else
1086:     {           dbg_printf("NOT READY");        }
1087: 
1088:     /* --------------- */
1089:     dbg_printf("\n\rExternal clock by HSE is");
1090:     if(1!=((tmp>>18) & 1        )       )
1091:     {           dbg_printf("n't");      }
1092:     dbg_printf(" bypassed");
1093: 
1094:     /* ------------------------------------------------- */
1095:     /* -------------------  CSS  ----------------------- */
1096:     {           dbg_printf("\n\r=========\n\rClok security system is ");        }
1097:     if(1==((tmp>>19) & 1))
1098:     {           dbg_printf("enabled");  }
1099:     else
1100:     {           dbg_printf("disabled"); }
1101: 
1102:     /* ------------------------------------------------- */
1103:     /* -------------------  PLL  ----------------------- */
1104:     dbg_printf("\n\r=========\n\rPLL is ");
1105:     if(1==((tmp>>24) & 1        )       )
1106:     {           dbg_printf("ON");       }
1107:     else
1108:     {           dbg_printf("OFF");      }
1109:     dbg_printf(" and ");
1110:     if(1==((tmp>>25) & 1        )       )
1111:     {           dbg_printf("READY");    }
1112:     else
1113:     {           dbg_printf("NOT READY");        }
1114:     /* ------------------------------------------------- */
1115:     /* -------------------  PLL  ----------------------- */
1116: 
1117:     tmp=(RCC->CFGR) & 0x03;
1118:     dbg_printf("\n\r=========\n\rSystem clock using ");
1119:     switch (tmp)
1120:     {
1121:         case 0 :
1122:         {
1123:             dbg_printf("HSI 8MHz oscilator");
1124:             break;
1125:         }
1126:         case 1 :
1127:         {
1128:             dbg_printf("HSE External oscilator");
1129:             break;
1130:         }
1131:         case 2 :
1132:         {
1133:             dbg_printf("PLL");
1134:             break;
1135:         }
1136:         case 3 :
1137:         {
1138:             dbg_printf("HSI48MHz");
1139:             break;
1140:         }
1141:     }
1142: 
1143: 
1144:     /* -------------------------------------------------- */
1145:     tmp=((RCC->CFGR)>>2) & 0x03;
1146:     u8_t        pll_is_on=0;
1147:     dbg_printf("\n\r=========\n\rSystem clock is set to ");
1148:     switch (tmp)
1149:     {
1150:         case 0 :
1151:         {
1152:             dbg_printf("HSI 8MHz oscilator");
1153:             sys_clock=8000000;
1154:             break;
1155:         }
1156:         case 1 :
1157:         {
1158:             dbg_printf("HSE External oscilator");
1159:             sys_clock=1600000;
1160:             break;
1161:         }
1162:         case 2 :
1163:         {
1164:             dbg_printf("PLL");
1165:             pll_is_on=1;
1166:             break;
1167:         }
1168:     }
1169:     /* --------------------------------------------------------------------------- */
1170:     /* --------------------------------------------------------------------------- */
1171:     /* PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL */
1172:     /* PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL   PLL */
1173:     /* --------------------------------------------------------------------------- */
1174:     /* --------------------------------------------------------------------------- */
1175:     u8_t        source_pll_divide;
1176:     if(1 == pll_is_on)
1177:     {
1178:         if(  0 == (((RCC->CFGR)>>16) & 0x01)  )
1179:         {
1180:             dbg_printf("HSI 8MHZ divided by 2");
1181:             source_pll_divide=2;
1182:             sys_clock=8000000;
1183:         }
1184:         else
1185:         {
1186:             source_pll_divide=(((u16_t)RCC->CFGR2 & 0x000F) +1);
1187:             sys_clock=16000000;
1188:             dbg_printf("HSE divided by %u", source_pll_divide );
1189:         }
1190:         sys_clock/=source_pll_divide;
1191: 
1192: 
1193: 
1194:         /* ------------------- AHB divider ------------------- */
1195: 
1196:         u8_t    pll_multiplier=(((RCC->CFGR)>>18) & 0x0F)+2;
1197:         if              (17 == pll_multiplier)
1198:         {
1199:             pll_multiplier=16;
1200:         }
1201:         sys_clock*=pll_multiplier;
1202:         dbg_printf("\n\rPLL multiplier is set to clock x %u",pll_multiplier);
1203:         /* ----------------------------------------------------------- */
1204:     } /* if(1 == pll_is_on) */
1205:     /* ------------------- AHB divider ------------------- */
1206:     tmp=((RCC->CFGR)>>4) & 0x0F;
1207:     u16_t       ahb_divider=1;
1208:     dbg_printf("\n\rAHB Divider is set to ");
1209:     switch (tmp)
1210:     {
1211:         case 8 :
1212:         {
1213:             ahb_divider=2;
1214:             break;
1215:         }
1216:         case 9 :
1217:         {
1218:             ahb_divider=4;
1219:             break;
1220:         }
1221:         case 10 :
1222:         {
1223:             ahb_divider=8;
1224:             break;
1225:         }
1226:         case 11 :
1227:         {
1228:             ahb_divider=16;
1229:             break;
1230:         }
1231:         case 12 :
1232:         {
1233:             ahb_divider=64;
1234:             break;
1235:         }
1236:         case 13 :
1237:         {
1238:             ahb_divider=128;
1239:             break;
1240:         }
1241:         case 14 :
1242:         {
1243:             ahb_divider=256;
1244:             break;
1245:         }
1246:         case 15 :
1247:         {
1248:             ahb_divider=512;
1249:             break;
1250:         }
1251:     }
1252:     dbg_printf("%u",ahb_divider);
1253:     /* ----------------------------------------------------------- */
1254:     /* ------------------------ APB divider ---------------------- */
1255:     tmp=((RCC->CFGR)>>8) & 0x0F;
1256:     u8_t        apb_divider=1;
1257:     dbg_printf("\n\rAPB Divider is set to ");
1258:     switch (tmp)
1259:     {
1260:         case 4 :
1261:         {
1262:             apb_divider=2;
1263:             break;
1264:         }
1265:         case 5 :
1266:         {
1267:             apb_divider=4;
1268:             break;
1269:         }
1270:         case 6 :
1271:         {
1272:             apb_divider=8;
1273:             break;
1274:         }
1275:         case 7 :
1276:         {
1277:             apb_divider=16;
1278:             break;
1279:         }
1280:     }
1281:     dbg_printf("%u",apb_divider);
1282:     ahb_frequency=sys_clock/ahb_divider;
1283:     apb_frequency=ahb_frequency/apb_divider;
1284: 
1285:     /* ----------------------------------------------------------- */
1286:     dbg_printf("\n\r=========================\n\rSystem frequency = [%u]\n\rAHB frequency =    [%u]\n\rAPB frequency =    [%u]\n\n\r=========================",sys_clock,ahb_frequency,apb_frequency);
1287: }
1288: 
1289: 
1290: 
1291: /*============================================================================*/
1292: /*!\brief
1293:  *
1294:  *
1295:  * \param
1296:  *
1297:  * \retval
1298:  *
1299:  * \todo
1300:  *
1301:  * \callgraph
1302:  * \callergraph*/
1303: /*============================================================================*/
1304: void priv_dbg_NVIC(void)
1305: {
1306:     if(!debug_st.dbg) return;
1307:     u32_t       int_flags=NVIC->ISPR[0];
1308:     dbg_printf("\n\r=========== Interrupt NVIC stetting: ===========");
1309: 
1310: 
1311:     dbg_printf("\n\rISER[0]:   ");
1312:     debug_send_long(NVIC->ISER[0]);
1313:     dbg_printf("  ICER:  ");
1314:     debug_send_long(NVIC->ICER[0]);
1315:     dbg_printf("  ISPR:  ");
1316:     debug_send_long(NVIC->ISPR[0]);
1317:     dbg_printf("  ICPR: ");
1318:     debug_send_long(NVIC->ICPR[0]);
1319: 
1320:     dbg_printf("\n\rIP[0]: ");
1321:     debug_send_long(NVIC->IP[0]);
1322:     dbg_printf("   IP[1]: ");
1323:     debug_send_long(NVIC->IP[1]);
1324:     dbg_printf("   IP[2]: ");
1325:     debug_send_long(NVIC->IP[2]);
1326:     dbg_printf("   IP[3]: ");
1327:     debug_send_long(NVIC->IP[3]);
1328: 
1329: 
1330:     dbg_printf("\n\rIP[4]: ");
1331:     debug_send_long(NVIC->IP[4]);
1332:     dbg_printf("   IP[5]: ");
1333:     debug_send_long(NVIC->IP[5]);
1334:     dbg_printf("   IP[6]: ");
1335:     debug_send_long(NVIC->IP[6]);
1336:     dbg_printf("   IP[7]: ");
1337:     debug_send_long(NVIC->IP[7]);
1338:     /*=====================================================*/
1339:     u8_t                nr_irq;
1340: 
1341: 
1342:     dbg_printf("\n\r PRZERWANIE   PRIORYTET   FLAGA   PRIORYTET2   ");
1343:     nr_irq=NonMaskableInt_IRQn;
1344:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r NonMaskableInt_IRQn:"); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); }; debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1345: 
1346:     nr_irq=HardFault_IRQn;
1347:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r HardFault_IRQn:    "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));    if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1348:     nr_irq=SVC_IRQn;
1349:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r SVC_IRQn:          "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));    if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1350:     nr_irq=PendSV_IRQn;
1351:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r PendSV_IRQn:       "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));    if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1352:     nr_irq=SysTick_IRQn;
1353:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r SysTick_IRQn:      "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));    if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1354:     nr_irq=WWDG_IRQn;
1355:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r WWDG_IRQn:         "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));    if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1356: #ifdef  PVD_IRQn
1357:     nr_irq=PVD_IRQn;
1358:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r PVD_IRQn:          "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));    if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1359: #endif
1360:     nr_irq=RTC_IRQn;
1361:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r RTC_IRQn:          "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));    if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1362:     nr_irq=FLASH_IRQn;
1363:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r FLASH_IRQn:        "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));    if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1364:     nr_irq=RCC_IRQn;
1365:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r RCC_IRQn:           "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1366:     nr_irq=EXTI0_1_IRQn;
1367:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r EXTI0_1_IRQn:       "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1368:     nr_irq=EXTI2_3_IRQn;
1369:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r EXTI2_3_IRQn:       "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1370:     nr_irq=EXTI4_15_IRQn;
1371:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r EXTI4_15_IRQn:      "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1372: #ifdef TS_IRQn
1373:     nr_irq=TS_IRQn;
1374:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r TS_IRQn:"); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));       if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1375: #endif
1376:     nr_irq=DMA1_Channel1_IRQn;
1377:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r DMA1_Channel1_IRQn:  "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));          if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1378:     nr_irq=DMA1_Channel2_3_IRQn;
1379:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r DMA1_Channel2_3_IRQn:"); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));          if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1380:     nr_irq=DMA1_Channel4_5_IRQn;
1381:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r DMA1_Channel4_5_IRQn:"); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));          if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1382:     nr_irq=ADC1_COMP_IRQn;
1383:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r ADC1_COMP_IRQn:      "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));          if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1384:     nr_irq=TIM1_BRK_UP_TRG_COM_IRQn;
1385:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r TIM1_BRK_UP_TRG_COM_IRQn:"); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));      if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1386:     nr_irq=TIM1_CC_IRQn;
1387:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r TIM1_CC_IRQn:       "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1388: #ifdef  TIM2_IRQn
1389:     nr_irq=TIM2_IRQn;
1390:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r TIM2_IRQn:          "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1391: #endif
1392:     nr_irq=TIM3_IRQn;
1393:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r TIM3_IRQn:          "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1394: #ifdef  TIM6_IRQn
1395:     nr_irq=TIM6_DAC_IRQn;
1396:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r TIM6_DAC_IRQn:      "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1397: #endif
1398:     nr_irq=TIM14_IRQn;
1399:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r TIM14_IRQn:         "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1400: #ifdef  TIM15_IRQn
1401:     nr_irq=TIM15_IRQn;
1402:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r TIM15_IRQn:         "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1403: #endif
1404:     nr_irq=TIM16_IRQn;
1405:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r TIM16_IRQn:         "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1406:     nr_irq=TIM17_IRQn;
1407:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r TIM17_IRQn:         "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1408:     nr_irq=I2C1_IRQn;
1409:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r I2C1_IRQn:          "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1410: #ifdef  I2C2_IRQn
1411:     nr_irq=I2C2_IRQn;
1412:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r I2C2_IRQn:          "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1413: #endif
1414:     nr_irq=SPI1_IRQn;
1415:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r SPI1_IRQn:          "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1416: #ifdef  SPI2_IRQn
1417:     nr_irq=SPI2_IRQn;
1418:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r SPI2_IRQn:          "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1419: #endif
1420:     nr_irq=USART1_IRQn;
1421:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r USART1_IRQn:        "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1422: #ifdef USART2_IRQn
1423:     nr_irq=USART2_IRQn;
1424:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r USART2_IRQn:        "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1425: #endif
1426: #ifdef  CEC_IRQn
1427:     nr_irq=CEC_IRQn;
1428:     if(0!=(NVIC->ISER[0]& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf("\n\r CEC_IRQn:           "); debug_send_byte((u8_t)NVIC_GetPriority(nr_irq));   if(0!=(int_flags& (1<<((      nr_irq      ) & 0x1F)))) {    dbg_printf(" 1"); } else {    dbg_printf(" 0"); };debug_send_char(' '); debug_send_char('['); debug_send_byte((NVIC->IP[nr_irq>>3] >> ((nr_irq&0x03) <<3)) &0xFF);debug_send_char(']');};
1429: #endif
1430: 
1431: #if 0
1432:     typedef struct
1433:     {
1434:       __IO uint32_t ISER[1];                 /*!< Offset: 0x000 (R/W)  Interrupt Set Enable Register           */
1435:            uint32_t RESERVED0[31];
1436:       __IO uint32_t ICER[1];                 /*!< Offset: 0x080 (R/W)  Interrupt Clear Enable Register          */
1437:            uint32_t RSERVED1[31];
1438:       __IO uint32_t ICER[1];                 /*!< Offset: 0x100 (R/W)  Interrupt Set Pending Register           */
1439:            uint32_t RESERVED2[31];
1440:       __IO uint32_t ICPR[1];                 /*!< Offset: 0x180 (R/W)  Interrupt Clear Pending Register         */
1441:            uint32_t RESERVED3[31];
1442:            uint32_t RESERVED4[64];
1443:       __IO uint32_t IP[8];                   /*!< Offset: 0x300 (R/W)  Interrupt Priority Register              */
1444:     }  NVIC_Type;
1445: 
1446: 
1447:     typedef enum IRQn
1448:     {
1449:     /******  Cortex-M0 Processor Exceptions Numbers ******************************************************/
1450:       NonMaskableInt_IRQn         = -14,    /*!< 2 Non Maskable Interrupt                                */
1451:       HardFault_IRQn              = -13,    /*!< 3 Cortex-M0 Hard Fault Interrupt                        */
1452:       SVC_IRQn                    = -5,     /*!< 11 Cortex-M0 SV Call Interrupt                          */
1453:       PendSV_IRQn                 = -2,     /*!< 14 Cortex-M0 Pend SV Interrupt                          */
1454:       SysTick_IRQn                = -1,     /*!< 15 Cortex-M0 System Tick Interrupt                      */
1455:     /******  STM32F-0 specific Interrupt Numbers *********************************************************/
1456: 
1457:       WWDG_IRQn                   = 0,      /*!< Window WatchDog Interrupt                               */
1458:       PVD_IRQn                    = 1,      /*!< PVD through EXTI Line detect Interrupt                  */
1459:       RTC_IRQn                    = 2,      /*!< RTC through EXTI Line Interrupt                         */
1460:       FLASH_IRQn                  = 3,      /*!< FLASH Interrupt                                         */
1461:       RCC_IRQn                    = 4,      /*!< RCC Interrupt                                           */
1462:       EXTI0_1_IRQn                = 5,      /*!< EXTI Line 0 and 1 Interrupts                            */
1463:       EXTI2_3_IRQn                = 6,      /*!< EXTI Line 2 and 3 Interrupts                            */
1464:       EXTI4_15_IRQn               = 7,      /*!< EXTI Line 4 to 15 Interrupts                            */
1465:       TS_IRQn                     = 8,      /*!< TS Interrupt                                            */
1466:       DMA1_Channel1_IRQn          = 9,      /*!< DMA1 Channel 1 Interrupt                                */
1467:       DMA1_Channel2_3_IRQn        = 10,     /*!< DMA1 Channel 2 and Channel 3 Interrupts                 */
1468:       DMA1_Channel4_5_IRQn        = 11,     /*!< DMA1 Channel 4 and Channel 5 Interrupts                 */
1469:       ADC1_COMP_IRQn              = 12,     /*!< ADC1, COMP1 and COMP2 Interrupts                        */
1470:       TIM1_BRK_UP_TRG_COM_IRQn    = 13,     /*!< TIM1 Break, Update, Trigger and Commutation Interrupts  */
1471:       TIM1_CC_IRQn                = 14,     /*!< TIM1 Capture Compare Interrupt                          */
1472:       TIM2_IRQn                   = 15,     /*!< TIM2 Interrupt                                          */
1473:       TIM3_IRQn                   = 16,     /*!< TIM3 Interrupt                                          */
1474:       TIM6_DAC_IRQn               = 17,     /*!< TIM6 and DAC Interrupts                                 */
1475:       TIM14_IRQn                  = 19,     /*!< TIM14 Interrupt                                         */
1476:       TIM15_IRQn                  = 20,     /*!< TIM15 Interrupt                                         */
1477:       TIM16_IRQn                  = 21,     /*!< TIM16 Interrupt                                         */
1478:       TIM17_IRQn                  = 22,     /*!< TIM17 Interrupt                                         */
1479:       I2C1_IRQn                   = 23,     /*!< I2C1 Interrupt                                          */
1480:       I2C2_IRQn                   = 24,     /*!< I2C2 Interrupt                                          */
1481:       SPI1_IRQn                   = 25,     /*!< SPI1 Interrupt                                          */
1482:       SPI2_IRQn                   = 26,     /*!< SPI2 Interrupt                                          */
1483:       USART1_IRQn                 = 27,     /*!< USART1 Interrupt                                        */
1484:       USART2_IRQn                 = 28,     /*!< USART2 Interrupt                                        */
1485:       CEC_IRQn                    = 30      /*!< CEC Interrupt                                           */
1486:     } IRQn_Type;
1487: 
1488:     /**
1489:       * @}
1490:       */
1491: 
1492: 
1493: 
1494: #endif
1495:     dbg_printf("\n\n\n\r");
1496: }
1497: 
1498: 
1499: 
1500: /*============================================================================*/
1501: /*!\brief
1502:  *
1503:  *
1504:  * \param
1505:  *
1506:  * \retval
1507:  *
1508:  * \todo
1509:  *
1510:  * \callgraph
1511:  * \callergraph*/
1512: /*============================================================================*/
1513: void priv_dbg_ADC(void)
1514: {
1515:     if(!debug_st.dbg) return;
1516:     dbg_printf("\n\n\r===========Interrupt ADC stetting ===========\n\rADC1 power is O");
1517:     if(0!=(RCC->APB2ENR & RCC_APB2ENR_ADC1EN))   {dbg_printf("N");}
1518:     else                                                                          {dbg_printf("FF");}
1519:     dbg_printf("\n\rADC->\n\rCCR:    ");debug_send_long(ADC->CCR);
1520:     dbg_printf("\n\rCR:     "); debug_send_long(ADC1->CR);
1521:     dbg_printf("    DR:     ");   debug_send_long(ADC1->DR);
1522:     dbg_printf("\n\rCFGR1:  ");   debug_send_long(ADC1->CFGR1);
1523:     dbg_printf("    CFGR2:  ");   debug_send_long(ADC1->CFGR2);
1524:     dbg_printf("    CHSELR: ");   debug_send_long(ADC1->CHSELR);
1525:     dbg_printf("\n\rIER:    ");   debug_send_long(ADC1->IER);
1526:     dbg_printf("    ISR:    ");   debug_send_long(ADC1->ISR);
1527:     dbg_printf("\n\rSMPR:   ");   debug_send_long(ADC1->SMPR);
1528:     dbg_printf("    TR:     ");   debug_send_long(ADC1->TR);
1529:     dbg_printf("\n\rtryb ");
1530:     if(ADC1->CFGR1&ADC_CFGR1_CONT)
1531:     {
1532:         dbg_printf("ciagly");
1533:     }
1534:     else
1535:     {
1536:         dbg_printf("\n\rtryb pojedynczy");
1537:     };
1538:     dbg_printf(" przetwarzania\n\rwyrownanie danych do ");
1539:     if(ADC1->CFGR1&ADC_CFGR1_ALIGN)
1540:     {
1541:         dbg_printf("le");
1542:     }
1543:     else
1544:     {
1545:         dbg_printf("pra");
1546:     };
1547:     dbg_printf("wej\n\rdane ");
1548: 
1549:     /* zapis tych bitow tylko gdy ADFEN=0*/
1550:     switch((ADC1->CFGR1&ADC_CFGR1_RES)>>3)
1551:     {
1552:         case 0 :        dbg_printf("12-t");
1553:                     break;
1554:         case 1 :        dbg_printf("10-t");
1555:                     break;
1556:         case 2 :        dbg_printf("8-i");
1557:                     break;
1558:         default :       dbg_printf("6-ci");
1559:     };
1560:     dbg_printf("o bitowe");
1561:     /*============================================================================
1562:      * Note: Software is allowed to write these bits only when the ADC is disabled
1563:      * (ADCAL=0, ADSTART=0, ADSTP=0, ADDIS=0 and ADEN=0).
1564:      *============================================================================*/
1565:     dbg_printf("\n\rTaktowanie ");
1566:     switch((ADC1->CFGR1&ADC_CFGR2_CKMODE))
1567:     {
1568:         case 0x00000000 :       dbg_printf("asynchroniczne ADCCLK");
1569:                             break;
1570:         case 0x40000000 :       dbg_printf("synchroniczne PCLK/2");
1571:                             break;
1572:         case 0x80000000 :       dbg_printf("synchroniczne PCLK/4");
1573:                             break;
1574:         default :                       dbg_printf("\rZarezerwowane");
1575:     };
1576: 
1577:     if(ADC1->CFGR2&ADC_CFGR2_CKMODE)
1578:     {
1579:         dbg_printf("\n\rtryb ciagly przetwarzania");
1580:     }
1581:     else
1582:     {
1583:         dbg_printf("\n\rtryb pojedynczy przetwarzania");
1584:     };
1585: 
1586:     dbg_printf("\n\rSampling=");
1587:     switch((ADC1->SMPR&ADC_SMPR_SMP))
1588:     {
1589:         case 0 :        dbg_printf("1");
1590:                     break;
1591:         case 1 :        dbg_printf("7");
1592:                     break;
1593:         case 2 :        dbg_printf("13");
1594:                     break;
1595:         case 3 :        dbg_printf("28");
1596:                     break;
1597:         case 4 :        dbg_printf("41");
1598:                     break;
1599:         case 5 :        dbg_printf("55");
1600:                     break;
1601:         case 6 :        dbg_printf("71");
1602:                     break;
1603:         default :       dbg_printf("239");
1604:     };
1605:     dbg_printf(".5 ADC clock cycles");
1606:     dbg_printf("\n\rADC selected IN ");
1607:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL0) dbg_printf("0");
1608:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL1) dbg_printf("1");
1609:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL2) dbg_printf("2");
1610:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL3) dbg_printf("3");
1611:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL4) dbg_printf("4");
1612:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL5) dbg_printf("5");
1613:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL6) dbg_printf("6");
1614:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL7) dbg_printf("7");
1615:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL8) dbg_printf("8");
1616:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL9) dbg_printf("9");
1617:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL10) dbg_printf("10");
1618:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL11) dbg_printf("11");
1619:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL12) dbg_printf("12");
1620:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL13) dbg_printf("13");
1621:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL14) dbg_printf("14");
1622:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL15) dbg_printf("15");
1623:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL16) dbg_printf("16");
1624:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL17) dbg_printf("17");
1625:     if(ADC1->CHSELR&ADC_CHSELR_CHSEL18) dbg_printf("18");
1626: 
1627:     if(ADC->CCR&ADC_CCR_VBATEN) dbg_printf("\n\rVbat enable");
1628:     if(ADC->CCR&ADC_CCR_TSEN) dbg_printf("\n\rTemp sensor enable");
1629:     if(ADC->CCR&ADC_CCR_VREFEN) dbg_printf("\n\rVoltage reference enable");
1630: }
1631: 
1632: 
1633: 
1634: 
1635: 
1636: /*============================================================================*/
1637: /*!\brief
1638:  *
1639:  *
1640:  * \param
1641:  *
1642:  * \retval
1643:  *
1644:  * \todo
1645:  *
1646:  * \callgraph
1647:  * \callergraph*/
1648: /*============================================================================*/
1649: void priv_dbg_POWER(void)
1650: {
1651:     if(!debug_st.dbg) return;
1652:     dbg_printf("\n\r=========== RCC AHBENR ===========\n\r");
1653:     if(RCC->AHBENR & RCC_AHBENR_TSEN )    dbg_printf("TS   ");
1654:     if(RCC->AHBENR & RCC_AHBENR_GPIOFEN ) dbg_printf("GPIOF   ");
1655:     if(RCC->AHBENR & RCC_AHBENR_GPIODEN ) dbg_printf("GPIOD   ");
1656:     if(RCC->AHBENR & RCC_AHBENR_GPIOCEN ) dbg_printf("GPIOC   ");
1657:     if(RCC->AHBENR & RCC_AHBENR_GPIOBEN ) dbg_printf("GPIOB   ");
1658:     if(RCC->AHBENR & RCC_AHBENR_GPIOAEN ) dbg_printf("GPIOA   ");
1659:     if(RCC->AHBENR & RCC_AHBENR_CRCEN )   dbg_printf("CRC   ");
1660:     if(RCC->AHBENR & RCC_AHBENR_FLITFEN ) dbg_printf("FLITF   ");
1661:     if(RCC->AHBENR & RCC_AHBENR_SRAMEN )  dbg_printf("SRAM   ");
1662:     if(RCC->AHBENR & RCC_AHBENR_DMA1EN )  dbg_printf("RDMA1   ");
1663: 
1664: 
1665:     dbg_printf("\n\r=========== RCC APB2ENR ===========\n\r");
1666:     if(RCC->APB2ENR & RCC_APB2ENR_SYSCFGEN ) dbg_printf("SYSCFG   ");
1667:     if(RCC->APB2ENR & RCC_APB2ENR_ADC1EN )   dbg_printf("ADC1   ");
1668:     if(RCC->APB2ENR & RCC_APB2ENR_TIM1EN )   dbg_printf("TIM1   ");
1669:     if(RCC->APB2ENR & RCC_APB2ENR_SPI1EN )   dbg_printf("SPI1   ");
1670:     if(RCC->APB2ENR & RCC_APB2ENR_USART1EN ) dbg_printf("USART1   ");
1671:     if(RCC->APB2ENR & RCC_APB2ENR_TIM15EN )  dbg_printf("TIM15   ");
1672:     if(RCC->APB2ENR & RCC_APB2ENR_TIM16EN )  dbg_printf("TIM16   ");
1673:     if(RCC->APB2ENR & RCC_APB2ENR_TIM17EN )  dbg_printf("TIM17   ");
1674:     if(RCC->APB2ENR & RCC_APB2ENR_DBGMCUEN ) dbg_printf("DBGMCU   ");
1675: 
1676: 
1677:     dbg_printf("\n\r=========== RCC APB1ENR ===========\n\r");
1678:     if(RCC->APB1ENR & RCC_APB1ENR_TIM2EN )   dbg_printf("TIM2   ");
1679:     if(RCC->APB1ENR & RCC_APB1ENR_TIM3EN )   dbg_printf("TIM3   ");
1680:     if(RCC->APB1ENR & RCC_APB1ENR_TIM6EN )   dbg_printf("TIM6   ");
1681:     if(RCC->APB1ENR & RCC_APB1ENR_TIM14EN )  dbg_printf("TIM14   ");
1682:     if(RCC->APB1ENR & RCC_APB1ENR_WWDGEN )   dbg_printf("WWDG   ");
1683:     if(RCC->APB1ENR & RCC_APB1ENR_SPI2EN )   dbg_printf("SPI2   ");
1684:     if(RCC->APB1ENR & RCC_APB1ENR_USART2EN ) dbg_printf("USART2   ");
1685:     if(RCC->APB1ENR & RCC_APB1ENR_I2C1EN )   dbg_printf("I2C1   ");
1686:     if(RCC->APB1ENR & RCC_APB1ENR_I2C2EN )   dbg_printf("I2C2   ");
1687:     if(RCC->APB1ENR & RCC_APB1ENR_PWREN )    dbg_printf("PWR   ");
1688:     if(RCC->APB1ENR & RCC_APB1ENR_DACEN )    dbg_printf("DAC   ");
1689:     if(RCC->APB1ENR & RCC_APB1ENR_CECEN )    dbg_printf("CEC   ");
1690: 
1691:     dbg_printf("\n\r");
1692:     if(RCC->CSR & RCC_CSR_LSION )    dbg_printf("LSI40kHz   ");
1693: 
1694:     if(RCC->BDCR & RCC_BDCR_RTCEN )    dbg_printf("RTC   ");
1695:     if(RCC->BDCR & 0x01 )    dbg_printf("LSE32kHz   ");
1696: 
1697:     if( RTC_LSE==(RCC->BDCR >> 8))     dbg_printf("RTC OSC = LSE   ");
1698:     if( RTC_LSI==(RCC->BDCR >> 8))     dbg_printf("RTC OSC = LSI   ");
1699:     if( RTC_HSE==(RCC->BDCR >> 8))     dbg_printf("RTC OSC = HSE   ");
1700: 
1701:     if(RCC->CR2&RCC_CR2_HSI14ON)
1702:     {
1703:         dbg_printf("HSI14OSC=ON      ");
1704:         if(RCC->CR2&RCC_CR2_HSI14RDY) dbg_printf("HSI14 is redy  \n\rHSI14 is ");
1705:         if(RCC->CR2&RCC_CR2_HSI14DIS)
1706:         {
1707:             dbg_printf("not");
1708:         }
1709:         dbg_printf("controlled by ADC  \n\r");
1710:         dbg_printf("HSI14MHz_trim=%u    HSI14MHz_cal=%u    ",((RCC_CR2_HSI14TRIM>>3)&0x0000001F),((RCC_CR2_HSI14CAL>>8)&0x000000FF));
1711:     }
1712: 
1713: }
1714: 
1715: 
1716: /*============================================================================*/
1717: /*!\brief
1718:  *
1719:  *
1720:  * \param
1721:  *
1722:  * \retval
1723:  *
1724:  * \todo
1725:  *
1726:  * \callgraph
1727:  * \callergraph*/
1728: /*============================================================================*/
1729: void priv_dbg_IWDG(void)
1730: {
1731:     if(!debug_st.dbg) return;
1732:     if(RCC->CSR & RCC_CSR_LSION )
1733:     {
1734:         dbg_printf("\n\rLSI40kHz is ON");
1735:     }
1736:     else
1737:     {
1738:         dbg_printf("\n\rLSI40kHz is OFF !!!!!");
1739:     }
1740:     if(RCC->CSR & RCC_CSR_LSIRDY )
1741:     {
1742:         dbg_printf("\n\rLSI40kHz is READY");
1743:     }
1744:     else
1745:     {
1746:         dbg_printf("\n\rLSI40kHz isn't READY !!!!!");
1747:     }
1748:     dbg_printf("\n\r===========  IWDG  ===========");
1749:     dbg_printf("\n\rKey register IWDG->KR =%u",IWDG->KR);   /*!< IWDG Key register,       Address offset: 0x00 */
1750:     dbg_printf("\n\rPrescaller   IWDG->PR =%u  div=%u",IWDG->PR,(4<<IWDG->PR));
1751:     dbg_printf("\n\rReload value IWDG->RLR=%u",IWDG->RLR); /* wartos  ladowana do licznika po zaladowaniu klucza 0xAAAA */
1752:     dbg_printf("\n\rstatus       IWDG->SR =%u   \n\rIWDG_SR_WVU=%u   \n\rIWDG_SR_RVU=%u   \n\rIWDG_SR_PVU=%u",IWDG->SR,(IWDG->SR>>2),((IWDG->SR>>1)&1),(IWDG->SR&1));
1753:     dbg_printf("\n\rWindow value IWDG->WINR=%u",IWDG->WINR);
1754: }
1755: 
1756: 
1757: 
1758: /*============================================================================*/
1759: /*!\brief
1760:  *
1761:  *
1762:  * \param
1763:  *
1764:  * \retval
1765:  *
1766:  * \todo
1767:  *
1768:  * \callgraph
1769:  * \callergraph*/
1770: /*============================================================================*/
1771: void priv_dbg_WWDG(void)
1772: {
1773:     if(!debug_st.dbg) return;
1774:     dbg_printf("\n\r===========  WWDG  ===========");
1775:     dbg_printf("\n\rWWDG->CR =%i",WWDG->CR);
1776:     dbg_printf("\n\rWWDG->CFR=%i",WWDG->CFR);
1777:     dbg_printf("\n\rWWDG->SR =%i",WWDG->SR);
1778: 
1779: }
1780: 
1781: 
1782: 
1783: /*============================================================================*/
1784: /*!\brief
1785:  *
1786:  *
1787:  * \param
1788:  *
1789:  * \retval
1790:  *
1791:  * \todo
1792:  *
1793:  * \callgraph
1794:  * \callergraph*/
1795: /*============================================================================*/
1796: void priv_dbg_SPI(SPI_TypeDef* Handle_SPI)
1797: {
1798:     if(!debug_st.dbg) return;
1799:     int tmp=0;
1800: #ifdef SPI1
1801:     if(SPI1==Handle_SPI) tmp=1;
1802: #endif
1803: #ifdef SPI2
1804:     if(SPI2==Handle_SPI) tmp=2;
1805: #endif
1806: #ifdef SPI3
1807:     if(SPI3==Handle_SPI) tmp=3;
1808: #endif
1809: #ifdef SPI4
1810:     if(SPI4==Handle_SPI) tmp=4;
1811: #endif
1812: #ifdef SPI5
1813:     if(SPI5==Handle_SPI) tmp=5;
1814: #endif
1815: #ifdef SPI6
1816:     if(SPI6==Handle_SPI) tmp=6;
1817: #endif
1818: #ifdef SPI7
1819:     if(SPI7==Handle_SPI) tmp=7;
1820: #endif
1821: #ifdef SPI8
1822:     if(SPI8==Handle_SPI) tmp=8;
1823: #endif
1824: #ifdef SPI9
1825:     if(SPI9==Handle_SPI) tmp=9;
1826: #endif
1827:     dbg_printf("\n\r=========== SPI %i ===========",tmp);
1828: 
1829:     dbg_printf("\n\rCR1: ");
1830:     debug_send_long(Handle_SPI->CR1);
1831: 
1832:     dbg_printf("    CR2: ");
1833:     debug_send_long(Handle_SPI->CR2);
1834: 
1835:     dbg_printf("    SR: ");
1836:     debug_send_long(Handle_SPI->SR);
1837:     
1838:     dbg_printf("    DR: ");
1839:     debug_send_long(Handle_SPI->DR);
1840:     
1841:     
1842:     dbg_printf("\n\rCRCPR: ");
1843:     debug_send_long(Handle_SPI->CRCPR);
1844:     
1845:     
1846:     dbg_printf("    RXCRCR: ");
1847:     debug_send_long(Handle_SPI->RXCRCR);
1848:     
1849:     dbg_printf("    TXCRCR: ");
1850:     debug_send_long(Handle_SPI->TXCRCR);
1851:     
1852:     
1853: 
1854: }
1855: 
1856: 
1857: 
1858: /*============================================================================*/
1859: /*!\brief
1860:  *
1861:  *
1862:  * \param
1863:  *
1864:  * \retval
1865:  *
1866:  * \todo
1867:  *
1868:  * \callgraph
1869:  * \callergraph*/
1870: /*============================================================================*/
1871: void dbg_USART(USART_TypeDef *handle)
1872: {
1873:     USART_TypeDef       temp_struct;
1874:     USART_TypeDef*      thandle=&temp_struct;
1875:     thandle->CR1=handle->CR1;
1876:     thandle->CR2=handle->CR2;
1877:     thandle->CR3=handle->CR3;
1878:     thandle->BRR=handle->BRR;
1879:     thandle->RTOR=handle->RTOR;
1880:     thandle->GTPR=handle->GTPR;
1881:     thandle->RQR=handle->RQR;
1882:     thandle->ISR=handle->ISR;
1883:     thandle->ICR=handle->ICR;
1884:     thandle->RDR=handle->RDR;
1885:     thandle->TDR=handle->TDR;
1886: 
1887:     dbg_printf("\n\r=========== USART ===========");
1888:     if((char*) handle == (char*) USART1_BASE) debug_send_char('1');
1889: #ifdef USART2_BASE
1890:     if((char*) handle == (char*) USART2_BASE) debug_send_char('2');
1891: #endif
1892: 
1893:     dbg_printf("\n\rCR1: ");    debug_send_long(thandle->CR1);
1894:     dbg_printf("    CR2: ");    debug_send_long(thandle->CR2);
1895:     dbg_printf("    CR3: ");    debug_send_long(thandle->CR3);
1896:     dbg_printf("    BRR: ");    debug_send_word(thandle->BRR);
1897:     
1898:     
1899:     dbg_printf("\n\rRTOR: ");   debug_send_long(thandle->RTOR);
1900:     dbg_printf("   GTPR: ");    debug_send_word(thandle->GTPR);
1901:     dbg_printf("    RQR: ");    debug_send_word(thandle->RQR);
1902:     
1903:     dbg_printf("\n\rISR: ");    debug_send_long(thandle->ISR);
1904:     dbg_printf("    ICR: ");    debug_send_long(thandle->ICR);
1905:         
1906:     dbg_printf("\n\rRDR: ");    debug_send_word(thandle->RDR);
1907:     dbg_printf("    TDR: ");    debug_send_word(thandle->TDR);
1908:     
1909: }
1910: 
1911: 
1912: 
1913: /*============================================================================*/
1914: /*!\brief
1915:  *
1916:  *
1917:  * \param
1918:  *
1919:  * \retval
1920:  *
1921:  * \todo
1922:  *
1923:  * \callgraph
1924:  * \callergraph*/
1925: /*============================================================================*/
1926: const char T_ENABLE[]=" enable  ";
1927: const char T_DISBLE[]=" disable ";
1928: void priv_dbg_EXTI(void)
1929: {
1930:     if(!debug_st.dbg) return;
1931:     dbg_printf("\n\r =========== DEBUG EXTI ============");
1932:     dbg_printf("\n\rEXTICR[3]: ");      debug_send_long(SYSCFG->EXTICR[3]);
1933:     dbg_printf("    EXTICR[2]: ");      debug_send_long(SYSCFG->EXTICR[2]);
1934:     dbg_printf("    EXTICR[1]: ");      debug_send_long(SYSCFG->EXTICR[1]);
1935:     dbg_printf("    EXTICR[0]: ");      debug_send_long(SYSCFG->EXTICR[0]);
1936: 
1937:     dbg_printf("\n\rEXTI->IMR: ");      debug_send_long(EXTI->IMR);
1938:     dbg_printf("     EMR: ");   debug_send_long(EXTI->EMR);
1939:     dbg_printf("    RTSR: ");   debug_send_long(EXTI->RTSR);
1940:     dbg_printf("    FTSR: ");   debug_send_long(EXTI->FTSR);
1941:     dbg_printf("      PR: ");   debug_send_long(EXTI->PR);
1942: #if 1
1943:     dbg_printf("\n\n\rEXT INT0  PORT"); debug_send_char((SYSCFG->EXTICR[0] & 0x0F)+'A');
1944:     if(0!=(0x01 & (EXTI->IMR >> 0))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
1945:     if(0!=(0x01 & (EXTI->RTSR >> 0))) {dbg_printf("R ");}else {dbg_printf("  ");};
1946:     if(0!=(0x01 & (EXTI->FTSR >> 0))) {dbg_printf("F ");}else {dbg_printf("  ");};
1947:     if(0==(0x01 & (EXTI->EMR >> 0))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
1948: 
1949: 
1950:     dbg_printf("\n\rEXT INT1  PORT");   debug_send_char(((SYSCFG->EXTICR[0]>>4) & 0x0F)+'A');
1951:     if(0!=(0x01 & (EXTI->IMR >> 1))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
1952:     if(0!=(0x01 & (EXTI->RTSR >> 1))) {dbg_printf("R ");}else {dbg_printf("  ");};
1953:     if(0!=(0x01 & (EXTI->FTSR >> 1))) {dbg_printf("F ");}else {dbg_printf("  ");};
1954:     if(0==(0x01 & (EXTI->EMR >> 1))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
1955: 
1956:     dbg_printf("\n\rEXT INT2  PORT");   debug_send_char(((SYSCFG->EXTICR[0]>>8) & 0x0F)+'A');
1957:     if(0!=(0x01 & (EXTI->IMR >> 2))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
1958:     if(0!=(0x01 & (EXTI->RTSR >> 2))) {dbg_printf("R ");}else {dbg_printf("  ");};
1959:     if(0!=(0x01 & (EXTI->FTSR >> 2))) {dbg_printf("F ");}else {dbg_printf("  ");};
1960:     if(0==(0x01 & (EXTI->EMR >> 2))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
1961: 
1962:     dbg_printf("\n\rEXT INT3  PORT");   debug_send_char(((SYSCFG->EXTICR[0]>>12) & 0x0F)+'A');
1963:     if(0!=(0x01 & (EXTI->IMR >> 3))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
1964:     if(0!=(0x01 & (EXTI->RTSR >> 3))) {dbg_printf("R ");}else {dbg_printf("  ");};
1965:     if(0!=(0x01 & (EXTI->FTSR >> 3))) {dbg_printf("F ");}else {dbg_printf("  ");};
1966:     if(0==(0x01 & (EXTI->EMR >> 3))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
1967: 
1968: 
1969:     dbg_printf("\n\rEXT INT4  PORT");   debug_send_char(( SYSCFG->EXTICR[1]      & 0x0F)+'A');
1970:     if(0!=(0x01 & (EXTI->IMR >> 4))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
1971:     if(0!=(0x01 & (EXTI->RTSR >> 4))) {dbg_printf("R ");}else {dbg_printf("  ");};
1972:     if(0!=(0x01 & (EXTI->FTSR >> 4))) {dbg_printf("F ");}else {dbg_printf("  ");};
1973:     if(0==(0x01 & (EXTI->EMR >> 4))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
1974: 
1975:     dbg_printf("\n\rEXT INT5  PORT");   debug_send_char(((SYSCFG->EXTICR[1]>>4)  & 0x0F)+'A');
1976:     if(0!=(0x01 & (EXTI->IMR >> 5))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
1977:     if(0!=(0x01 & (EXTI->RTSR >> 5))) {dbg_printf("R ");}else {dbg_printf("  ");};
1978:     if(0!=(0x01 & (EXTI->FTSR >> 5))) {dbg_printf("F ");}else {dbg_printf("  ");};
1979:     if(0==(0x01 & (EXTI->EMR >> 5))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
1980: 
1981:     dbg_printf("\n\rEXT INT6  PORT");   debug_send_char(((SYSCFG->EXTICR[1]>>8)  & 0x0F)+'A');
1982:     if(0!=(0x01 & (EXTI->IMR >> 6))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
1983:     if(0!=(0x01 & (EXTI->RTSR >> 6))) {dbg_printf("R ");}else {dbg_printf("  ");};
1984:     if(0!=(0x01 & (EXTI->FTSR >> 6))) {dbg_printf("F ");}else {dbg_printf("  ");};
1985:     if(0==(0x01 & (EXTI->EMR >> 6))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
1986: 
1987:     dbg_printf("\n\rEXT INT7  PORT");   debug_send_char(((SYSCFG->EXTICR[1]>>12) & 0x0F)+'A');
1988:     if(0!=(0x01 & (EXTI->IMR >> 7))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
1989:     if(0!=(0x01 & (EXTI->RTSR >> 7))) {dbg_printf("R ");}else {dbg_printf("  ");};
1990:     if(0!=(0x01 & (EXTI->FTSR >> 7))) {dbg_printf("F ");}else {dbg_printf("  ");};
1991:     if(0==(0x01 & (EXTI->EMR >> 7))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
1992: 
1993: 
1994:     dbg_printf("\n\rEXT INT8  PORT");   debug_send_char(( SYSCFG->EXTICR[2]      & 0x0F)+'A');
1995:     if(0!=(0x01 & (EXTI->IMR >> 8))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
1996:     if(0!=(0x01 & (EXTI->RTSR >> 8))) {dbg_printf("R ");}else {dbg_printf("  ");};
1997:     if(0!=(0x01 & (EXTI->FTSR >> 8))) {dbg_printf("F ");}else {dbg_printf("  ");};
1998:     if(0==(0x01 & (EXTI->EMR >> 8))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
1999: 
2000:     dbg_printf("\n\rEXT INT9  PORT");   debug_send_char(((SYSCFG->EXTICR[2]>>4)  & 0x0F)+'A');
2001:     if(0!=(0x01 & (EXTI->IMR >> 9))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
2002:     if(0!=(0x01 & (EXTI->RTSR >> 9))) {dbg_printf("R ");}else {dbg_printf("  ");};
2003:     if(0!=(0x01 & (EXTI->FTSR >> 9))) {dbg_printf("F ");}else {dbg_printf("  ");};
2004:     if(0==(0x01 & (EXTI->EMR >> 9))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
2005: 
2006:     dbg_printf("\n\rEXT INT10 PORT");   debug_send_char(((SYSCFG->EXTICR[2]>>8)  & 0x0F)+'A');
2007:     if(0!=(0x01 & (EXTI->IMR >> 10))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
2008:     if(0!=(0x01 & (EXTI->RTSR >> 10))) {dbg_printf("R ");}else {dbg_printf("  ");};
2009:     if(0!=(0x01 & (EXTI->FTSR >> 10))) {dbg_printf("F ");}else {dbg_printf("  ");};
2010:     if(0==(0x01 & (EXTI->EMR >> 10))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
2011: 
2012:     dbg_printf("\n\rEXT INT11 PORT");   debug_send_char(((SYSCFG->EXTICR[2]>>12) & 0x0F)+'A');
2013:     if(0!=(0x01 & (EXTI->IMR >> 11))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
2014:     if(0!=(0x01 & (EXTI->RTSR >> 11))) {dbg_printf("R ");}else {dbg_printf("  ");};
2015:     if(0!=(0x01 & (EXTI->FTSR >> 11))) {dbg_printf("F ");}else {dbg_printf("  ");};
2016:     if(0==(0x01 & (EXTI->EMR >> 11))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
2017: #endif
2018: 
2019:     dbg_printf("\n\rEXT INT12 PORT");   debug_send_char(( SYSCFG->EXTICR[3]      & 0x0F)+'A');
2020:     if(0!=(0x01 & (EXTI->IMR >> 12))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
2021:     if(0!=(0x01 & (EXTI->RTSR >> 12))) {dbg_printf("R ");}else {dbg_printf("  ");};
2022:     if(0!=(0x01 & (EXTI->FTSR >> 12))) {dbg_printf("F ");}else {dbg_printf("  ");};
2023:     if(0==(0x01 & (EXTI->EMR >> 12))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
2024: 
2025:     dbg_printf("\n\rEXT INT13 PORT");   debug_send_char(((SYSCFG->EXTICR[3]>>4)  & 0x0F)+'A');
2026:     if(0!=(0x01 & (EXTI->IMR >> 13))) {dbg_printf(" enable  ");}else {dbg_printf("%s",T_DISBLE);};
2027:     if(0!=(0x01 & (EXTI->RTSR >> 13))) {dbg_printf("R ");}else {dbg_printf("  ");};
2028:     if(0!=(0x01 & (EXTI->FTSR >> 13))) {dbg_printf("F ");}else {dbg_printf("  ");};
2029:     if(0==(0x01 & (EXTI->EMR >> 13))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
2030: 
2031:     dbg_printf("\n\rEXT INT14 PORT");   debug_send_char(((SYSCFG->EXTICR[3]>>8)  & 0x0F)+'A');
2032:     if(0!=(0x01 & (EXTI->IMR >> 14))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
2033:     if(0!=(0x01 & (EXTI->RTSR >> 14))) {dbg_printf("R ");}else {dbg_printf("  ");};
2034:     if(0!=(0x01 & (EXTI->FTSR >> 14))) {dbg_printf("F ");}else {dbg_printf("  ");};
2035:     if(0==(0x01 & (EXTI->EMR >> 14))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
2036: 
2037:     dbg_printf("\n\rEXT INT15 PORT");   debug_send_char(((SYSCFG->EXTICR[3]>>12) & 0x0F)+'A');
2038:     if(0!=(0x01 & (EXTI->IMR >> 15))) {dbg_printf("%s",T_ENABLE);}else {dbg_printf("%s",T_DISBLE);};
2039:     if(0!=(0x01 & (EXTI->RTSR >> 15))) {dbg_printf("R ");}else {dbg_printf("  ");};
2040:     if(0!=(0x01 & (EXTI->FTSR >> 15))) {dbg_printf("F ");}else {dbg_printf("  ");};
2041:     if(0==(0x01 & (EXTI->EMR >> 15))) {dbg_printf("    ");}else {dbg_printf(" not");};dbg_printf(" masked ");
2042: 
2043: }
2044: 
2045: 
2046: 
2047: /*============================================================================*/
2048: /*!\brief
2049:  *
2050:  *
2051:  * \param
2052:  *
2053:  * \retval
2054:  *
2055:  * \todo
2056:  *
2057:  * \callgraph
2058:  * \callergraph*/
2059: /*============================================================================*/
2060: void priv_dbg_RTC(void)
2061: {
2062:     if(!debug_st.dbg) return;
2063:     dbg_printf("\n\r=========== DEBUG RTC ===========");
2064: 
2065: 
2066:     dbg_printf("\n\r    TR: "); debug_send_long(RTC->TR);
2067:     dbg_printf("       DR: ");  debug_send_long(RTC->DR);
2068:     dbg_printf("       CR: ");  debug_send_long(RTC->CR);
2069:     dbg_printf("      ISR: ");  debug_send_long(RTC->ISR);
2070:     dbg_printf("\n\r  PRER: "); debug_send_long(RTC->PRER);
2071:     dbg_printf("   ALRMAR: ");  debug_send_long(RTC->ALRMAR);
2072:     dbg_printf("      WPR: ");  debug_send_long(RTC->WPR);
2073:     dbg_printf("      SSR: ");  debug_send_long(RTC->SSR);
2074: 
2075:     dbg_printf("\n\rSHIFTR: "); debug_send_long(RTC->SHIFTR);
2076:     dbg_printf("     TSTR: ");  debug_send_long(RTC->TSTR);
2077:     dbg_printf("     TSDR: ");  debug_send_long(RTC->TSDR);
2078:     dbg_printf("    TSSSR: ");  debug_send_long(RTC->TSSSR);
2079: #ifdef CALR
2080:   #ifndef CAL
2081:     dbg_printf("\n\r   CALR: ");        debug_send_long(RTC->CALR);
2082:   #else
2083:     dbg_printf("\n\r   CAL: "); debug_send_long(RTC->CAL);
2084:   #endif
2085: #endif
2086: 
2087:     dbg_printf("    TAFCR: ");  debug_send_long(RTC->TAFCR);
2088:     dbg_printf(" ALRMASSR: ");  debug_send_long(RTC->ALRMASSR);
2089:     dbg_printf("\n\r BKP0R: "); debug_send_long(RTC->BKP0R);
2090:     dbg_printf("    BKP1R: ");  debug_send_long(RTC->BKP1R);
2091:     dbg_printf("    BKP2R: ");  debug_send_long(RTC->BKP2R);
2092:     dbg_printf("    BKP3R: ");  debug_send_long(RTC->BKP3R);
2093:     dbg_printf("\n\r BKP4R: "); debug_send_long(RTC->BKP4R);
2094: }
2095: 
2096: 
2097: 
2098: /*============================================================================*/
2099: /*!\brief
2100:  *
2101:  *
2102:  * \param
2103:  *
2104:  * \retval
2105:  *
2106:  * \todo
2107:  *
2108:  * \callgraph
2109:  * \callergraph*/
2110: /*============================================================================*/
2111: void priv_dbg_DAC(void)
2112: {
2113:     if(!debug_st.dbg) return;
2114:     dbg_printf("\n\r=========== DEBUG DAC ===========");
2115:     if(0!=(RCC->APB1ENR&RCC_APB1ENR_DACEN))
2116:     {
2117:         dbg_printf("\n\rDAC is ON");
2118:     }
2119:     else
2120:     {
2121:         dbg_printf("\n\rDAC is OFF");
2122:     }
2123: 
2124:     dbg_printf("\n\r    CR: "); debug_send_long(DAC->CR);
2125:     dbg_printf("  SWTRIGR: ");  debug_send_long(DAC->SWTRIGR);
2126: 
2127:     dbg_printf("  DHR12R1: ");  debug_send_long(DAC->DHR12R1);
2128:     dbg_printf("  DHR12R1: ");  debug_send_long(DAC->DHR12L1);
2129:     dbg_printf("   DHR8R1: ");  debug_send_long(DAC->DHR8R1);
2130: 
2131:     dbg_printf("\n\r  DOR1: "); debug_send_long(DAC->DOR1);
2132:     dbg_printf("       SR: ");  debug_send_long(DAC->SR);
2133: }
2134: 
2135: 
2136: 
2137: /*============================================================================*/
2138: /*!\brief
2139:  *
2140:  *
2141:  * \param
2142:  *
2143:  * \retval
2144:  *
2145:  * \todo
2146:  *
2147:  * \callgraph
2148:  * \callergraph*/
2149: /*============================================================================*/
2150: void priv_dbg_DAC(void)
2151: {
2152:     if(!debug_st.dbg) return ;
2153:     dbg_printf("\n\r=========== DEBUG DAC clock ===========");
2154:     if(0!=(RCC->APB1ENR & RCC_APB1ENR_DACEN))
2155:     {
2156:         dbg_printf("on");
2157:     }
2158:     else
2159:     {
2160:         dbg_printf("off");
2161:     }
2162: 
2163:     dbg_printf("\n\r       CR: ");      debug_send_long(DAC->CR);
2164:     dbg_printf("  SWTRIGR: ");  debug_send_long(DAC->SWTRIGR);
2165:     dbg_printf("  DHR12R1: ");  debug_send_long(DAC->DHR12R1);
2166:     dbg_printf("  DHR12L1: ");  debug_send_long(DAC->DHR12L1);
2167:     dbg_printf("\n\r   DHR8R1: ");      debug_send_long(DAC->DHR8R1);
2168:     dbg_printf("     DOR1: ");  debug_send_long(DAC->DOR1);
2169:     dbg_printf("      SR: ");   debug_send_long(DAC->SR);
2170: }
2171: 
2172: 
2173: