REG= { PWMA_PPR=1074003968, PWMA_CSR=1074003972, PWMA_PCR=1074003976, PWMA_CNR0=1074003980, PWMA_CMR0=1074003984, PWMA_PDR0=1074003988, PWMA_CNR1=1074003992, PWMA_CMR1=1074003996, PWMA_PDR1=1074004000, PWMA_CNR2=1074004004, PWMA_CMR2=1074004008, PWMA_PDR2=1074004012, PWMA_CNR3=1074004016, PWMA_CMR3=1074004020, PWMA_PDR3=1074004024, PWMA_PBCR=1074004028, PWMA_PIER=1074004032, PWMA_PIIR=1074004036, PWMA_CCR0=1074004048, PWMA_CCR2=1074004052, PWMA_CRLR0=1074004056, PWMA_CFLR0=1074004060, PWMA_CRLR1=1074004064, PWMA_CFLR1=1074004068, PWMA_CRLR2=1074004072, PWMA_CFLR2=1074004076, PWMA_CRLR3=1074004080, PWMA_CFLR3=1074004084, PWMA_CAPENR=1074004088, PWMA_POE=1074004092, PWMB_PPR=1075052544, PWMB_CSR=1075052548, PWMB_PCR=1075052552, PWMB_CNR0=1075052556, PWMB_CMR0=1075052560, PWMB_PDR0=1075052564, PWMB_CNR1=1075052568, PWMB_CMR1=1075052572, PWMB_PDR1=1075052576, PWMB_CNR2=1075052580, PWMB_CMR2=1075052584, PWMB_PDR2=1075052588, PWMB_CNR3=1075052592, PWMB_CMR3=1075052596, PWMB_PDR3=1075052600, PWMB_PBCR=1075052604, PWMB_PIER=1075052608, PWMB_PIIR=1075052612, PWMB_CCR0=1075052624, PWMB_CCR2=1075052628, PWMB_CRLR0=1075052632, PWMB_CFLR0=1075052636, PWMB_CRLR1=1075052640, PWMB_CFLR1=1075052644, PWMB_CRLR2=1075052648, PWMB_CFLR2=1075052652, PWMB_CRLR3=1075052656, PWMB_CFLR3=1075052660, PWMB_CAPENR=1075052664, PWMB_POE=1075052668, ADC_ADDR0=1074659328, ADC_ADDR1=1074659332, ADC_ADDR2=1074659336, ADC_ADDR3=1074659340, ADC_ADDR4=1074659344, ADC_ADDR5=1074659348, ADC_ADDR6=1074659352, ADC_ADDR7=1074659356, ADC_ADCR=1074659360, ADC_ADCHER=1074659364, ADC_ADCMPR0=1074659368, ADC_ADCMPR1=1074659372, ADC_ADSR=1074659376, ADC_ADCALR=1074659380, ADC_ADPDMA=1074659392, CAN_CAN_CON=1075314688, CAN_CAN_STATUS=1075314692, CAN_CAN_ERR=1075314696, CAN_CAN_BTIME=1075314700, CAN_CAN_IIDR=1075314704, CAN_CAN_TEST=1075314708, CAN_CAN_BRPE=1075314712, CAN_CAN_IF1_CREQ=1075314720, CAN_CAN_IF1_CMASK=1075314724, CAN_CAN_IF1_MASK1=1075314728, CAN_CAN_IF1_MASK2=1075314732, CAN_CAN_IF1_ARB1=1075314736, CAN_CAN_IF1_ARB2=1075314740, CAN_CAN_IF1_MCON=1075314744, CAN_CAN_IF1_DAT_A1=1075314748, CAN_CAN_IF1_DAT_A2=1075314752, CAN_CAN_IF1_DAT_B1=1075314756, CAN_CAN_IF1_DAT_B2=1075314760, CAN_CAN_IF2_CREQ=1075314816, CAN_CAN_IF2_CMASK=1075314820, CAN_CAN_IF2_MASK1=1075314824, CAN_CAN_IF2_MASK2=1075314828, CAN_CAN_IF2_ARB1=1075314832, CAN_CAN_IF2_ARB2=1075314836, CAN_CAN_IF2_MCON=1075314840, CAN_CAN_IF2_DAT_A1=1075314844, CAN_CAN_IF2_DAT_A2=1075314848, CAN_CAN_IF2_DAT_B1=1075314852, CAN_CAN_IF2_DAT_B2=1075314856, CAN_CAN_TXREQ1=1075314944, CAN_CAN_TXREQ2=1075314948, CAN_CAN_NDAT1=1075314976, CAN_CAN_NDAT2=1075314980, CAN_CAN_IPND1=1075315008, CAN_CAN_IPND2=1075315012, CAN_CAN_MVLD1=1075315040, CAN_CAN_MVLD2=1075315044, CAN_CAN_WU_EN=1075315048, CAN_CAN_WU_STATUS=1075315052, CLK_PWRCON=1342177792, CLK_AHBCLK=1342177796, CLK_APBCLK=1342177800, CLK_CLKSTATUS=1342177804, CLK_CLKSEL0=1342177808, CLK_CLKSEL1=1342177812, CLK_CLKDIV=1342177816, CLK_CLKSEL2=1342177820, CLK_PLLCON=1342177824, CLK_FRQDIV=1342177828, CLK_APBCLK1=1342177840, CLK_CLKSEL3=1342177844, CLK_CLKDIV1=1342177848, CMP_CMP0CR=1074593792, CMP_CMP1CR=1074593796, CMP_CMPSR=1074593800, EBI_EBICON=1342242816, EBI_EXTIME=1342242820, FMC_ISPCON=1342226432, FMC_ISPADR=1342226436, FMC_ISPDAT=1342226440, FMC_ISPCMD=1342226444, FMC_ISPTRG=1342226448, FMC_DFBADR=1342226452, FMC_FATCON=1342226456, GCR_PDID=1342177280, GCR_RSTSRC=1342177284, GCR_IPRSTC1=1342177288, GCR_IPRSTC2=1342177292, GCR_BODCR=1342177304, GCR_TEMPCR=1342177308, GCR_PORCR=1342177316, GCR_GPA_MFP=1342177328, GCR_GPB_MFP=1342177332, GCR_GPC_MFP=1342177336, GCR_GPD_MFP=1342177340, GCR_GPE_MFP=1342177344, GCR_GPF_MFP=1342177348, GCR_ALT_MFP=1342177360, GCR_ALT_MFP1=1342177368, GCR_IRCTRIMCTL=1342177408, GCR_REGWRPROT=1342177536, GPA_PMD=1342193664, GPA_OFFD=1342193668, GPA_DOUT=1342193672, GPA_DMASK=1342193676, GPA_PIN=1342193680, GPA_DBEN=1342193684, GPA_IMD=1342193688, GPA_IEN=1342193692, GPA_ISRC=1342193696, GPB_PMD=1342193728, GPB_OFFD=1342193732, GPB_DOUT=1342193736, GPB_DMASK=1342193740, GPB_PIN=1342193744, GPB_DBEN=1342193748, GPB_IMD=1342193752, GPB_IEN=1342193756, GPB_ISRC=1342193760, GPC_PMD=1342193792, GPC_OFFD=1342193796, GPC_DOUT=1342193800, GPC_DMASK=1342193804, GPC_PIN=1342193808, GPC_DBEN=1342193812, GPC_IMD=1342193816, GPC_IEN=1342193820, GPC_ISRC=1342193824, GPD_PMD=1342193856, GPD_OFFD=1342193860, GPD_DOUT=1342193864, GPD_DMASK=1342193868, GPD_PIN=1342193872, GPD_DBEN=1342193876, GPD_IMD=1342193880, GPD_IEN=1342193884, GPD_ISRC=1342193888, GPE_PMD=1342193920, GPE_OFFD=1342193924, GPE_DOUT=1342193928, GPE_DMASK=1342193932, GPE_PIN=1342193936, GPE_DBEN=1342193940, GPE_IMD=1342193944, GPE_IEN=1342193948, GPE_ISRC=1342193952, GPF_PMD=1342193984, GPF_OFFD=1342193988, GPF_DOUT=1342193992, GPF_DMASK=1342193996, GPF_PIN=1342194000, GPF_DBEN=1342194004, GPF_IMD=1342194008, GPF_IEN=1342194012, GPF_ISRC=1342194016, GPIO_DBNCECON=1342194048, GPA_BITS_DOUT0=1342194176, GPA_BITS_DOUT1=1342194180, GPA_BITS_DOUT2=1342194184, GPA_BITS_DOUT3=1342194188, GPA_BITS_DOUT4=1342194192, GPA_BITS_DOUT5=1342194196, GPA_BITS_DOUT6=1342194200, GPA_BITS_DOUT7=1342194204, GPA_BITS_DOUT8=1342194208, GPA_BITS_DOUT9=1342194212, GPA_BITS_DOUT10=1342194216, GPA_BITS_DOUT11=1342194220, GPA_BITS_DOUT12=1342194224, GPA_BITS_DOUT13=1342194228, GPA_BITS_DOUT14=1342194232, GPA_BITS_DOUT15=1342194236, GPB_BITS_DOUT0=1342194240, GPB_BITS_DOUT1=1342194244, GPB_BITS_DOUT2=1342194248, GPB_BITS_DOUT3=1342194252, GPB_BITS_DOUT4=1342194256, GPB_BITS_DOUT5=1342194260, GPB_BITS_DOUT6=1342194264, GPB_BITS_DOUT7=1342194268, GPB_BITS_DOUT8=1342194272, GPB_BITS_DOUT9=1342194276, GPB_BITS_DOUT10=1342194280, GPB_BITS_DOUT11=1342194284, GPB_BITS_DOUT12=1342194288, GPB_BITS_DOUT13=1342194292, GPB_BITS_DOUT14=1342194296, GPB_BITS_DOUT15=1342194300, GPC_BITS_DOUT0=1342194304, GPC_BITS_DOUT1=1342194308, GPC_BITS_DOUT2=1342194312, GPC_BITS_DOUT3=1342194316, GPC_BITS_DOUT4=1342194320, GPC_BITS_DOUT5=1342194324, GPC_BITS_DOUT6=1342194328, GPC_BITS_DOUT7=1342194332, GPC_BITS_DOUT8=1342194336, GPC_BITS_DOUT9=1342194340, GPC_BITS_DOUT10=1342194344, GPC_BITS_DOUT11=1342194348, GPC_BITS_DOUT12=1342194352, GPC_BITS_DOUT13=1342194356, GPC_BITS_DOUT14=1342194360, GPC_BITS_DOUT15=1342194364, GPD_BITS_DOUT0=1342194368, GPD_BITS_DOUT1=1342194372, GPD_BITS_DOUT2=1342194376, GPD_BITS_DOUT3=1342194380, GPD_BITS_DOUT4=1342194384, GPD_BITS_DOUT5=1342194388, GPD_BITS_DOUT6=1342194392, GPD_BITS_DOUT7=1342194396, GPD_BITS_DOUT8=1342194400, GPD_BITS_DOUT9=1342194404, GPD_BITS_DOUT10=1342194408, GPD_BITS_DOUT11=1342194412, GPD_BITS_DOUT12=1342194416, GPD_BITS_DOUT13=1342194420, GPD_BITS_DOUT14=1342194424, GPD_BITS_DOUT15=1342194428, GPE_BITS_DOUT0=1342194432, GPE_BITS_DOUT1=1342194436, GPE_BITS_DOUT2=1342194440, GPE_BITS_DOUT3=1342194444, GPE_BITS_DOUT4=1342194448, GPE_BITS_DOUT5=1342194452, GPE_BITS_DOUT6=1342194456, GPE_BITS_DOUT7=1342194460, GPE_BITS_DOUT8=1342194464, GPE_BITS_DOUT9=1342194468, GPE_BITS_DOUT10=1342194472, GPE_BITS_DOUT11=1342194476, GPE_BITS_DOUT12=1342194480, GPE_BITS_DOUT13=1342194484, GPE_BITS_DOUT14=1342194488, GPE_BITS_DOUT15=1342194492, GPF_BITS_DOUT0=1342194496, GPF_BITS_DOUT1=1342194500, GPF_BITS_DOUT2=1342194504, GPF_BITS_DOUT3=1342194508, I2C0_I2CON=1073872896, I2C0_I2CADDR0=1073872900, I2C0_I2CDAT=1073872904, I2C0_I2CSTATUS=1073872908, I2C0_I2CLK=1073872912, I2C0_I2CTOC=1073872916, I2C0_I2CADDR1=1073872920, I2C0_I2CADDR2=1073872924, I2C0_I2CADDR3=1073872928, I2C0_I2CADM0=1073872932, I2C0_I2CADM1=1073872936, I2C0_I2CADM2=1073872940, I2C0_I2CADM3=1073872944, I2C1_I2CON=1074921472, I2C1_I2CADDR0=1074921476, I2C1_I2CDAT=1074921480, I2C1_I2CSTATUS=1074921484, I2C1_I2CLK=1074921488, I2C1_I2CTOC=1074921492, I2C1_I2CADDR1=1074921496, I2C1_I2CADDR2=1074921500, I2C1_I2CADDR3=1074921504, I2C1_I2CADM0=1074921508, I2C1_I2CADM1=1074921512, I2C1_I2CADM2=1074921516, I2C1_I2CADM3=1074921520, I2S_I2S_CON=1075445760, I2S_I2S_CLKDIV=1075445764, I2S_I2S_IE=1075445768, I2S_I2S_STATUS=1075445772, I2S_I2S_TXFIFO=1075445776, I2S_I2S_RXFIFO=1075445780, INT_IRQ0_SRC=1342178048, INT_IRQ1_SRC=1342178052, INT_IRQ2_SRC=1342178056, INT_IRQ3_SRC=1342178060, INT_IRQ4_SRC=1342178064, INT_IRQ5_SRC=1342178068, INT_IRQ6_SRC=1342178072, INT_IRQ7_SRC=1342178076, INT_IRQ8_SRC=1342178080, INT_IRQ9_SRC=1342178084, INT_IRQ10_SRC=1342178088, INT_IRQ11_SRC=1342178092, INT_IRQ12_SRC=1342178096, INT_IRQ13_SRC=1342178100, INT_IRQ14_SRC=1342178104, INT_IRQ15_SRC=1342178108, INT_IRQ16_SRC=1342178112, INT_IRQ17_SRC=1342178116, INT_IRQ18_SRC=1342178120, INT_IRQ19_SRC=1342178124, INT_IRQ20_SRC=1342178128, INT_IRQ21_SRC=1342178132, INT_IRQ22_SRC=1342178136, INT_IRQ23_SRC=1342178140, INT_IRQ24_SRC=1342178144, INT_IRQ25_SRC=1342178148, INT_IRQ26_SRC=1342178152, INT_IRQ27_SRC=1342178156, INT_IRQ28_SRC=1342178160, INT_IRQ29_SRC=1342178164, INT_IRQ30_SRC=1342178168, INT_IRQ31_SRC=1342178172, INT_NMI_SEL=1342178176, INT_MCU_IRQ=1342178180, PDMA0_PDMA_CSRx=1342210048, PDMA0_PDMA_SARx=1342210052, PDMA0_PDMA_DARx=1342210056, PDMA0_PDMA_BCRx=1342210060, PDMA0_PDMA_POINTx=1342210064, PDMA0_PDMA_CSARx=1342210068, PDMA0_PDMA_CDARx=1342210072, PDMA0_PDMA_CBCRx=1342210076, PDMA0_PDMA_IERx=1342210080, PDMA0_PDMA_ISRx=1342210084, PDMA0_PDMA_SBUF0_cx=1342210176, PDMA1_PDMA_CSRx=1342210304, PDMA1_PDMA_SARx=1342210308, PDMA1_PDMA_DARx=1342210312, PDMA1_PDMA_BCRx=1342210316, PDMA1_PDMA_POINTx=1342210320, PDMA1_PDMA_CSARx=1342210324, PDMA1_PDMA_CDARx=1342210328, PDMA1_PDMA_CBCRx=1342210332, PDMA1_PDMA_IERx=1342210336, PDMA1_PDMA_ISRx=1342210340, PDMA1_PDMA_SBUF0_cx=1342210432, PDMA2_PDMA_CSRx=1342210560, PDMA2_PDMA_SARx=1342210564, PDMA2_PDMA_DARx=1342210568, PDMA2_PDMA_BCRx=1342210572, PDMA2_PDMA_POINTx=1342210576, PDMA2_PDMA_CSARx=1342210580, PDMA2_PDMA_CDARx=1342210584, PDMA2_PDMA_CBCRx=1342210588, PDMA2_PDMA_IERx=1342210592, PDMA2_PDMA_ISRx=1342210596, PDMA2_PDMA_SBUF0_cx=1342210688, PDMA3_PDMA_CSRx=1342210816, PDMA3_PDMA_SARx=1342210820, PDMA3_PDMA_DARx=1342210824, PDMA3_PDMA_BCRx=1342210828, PDMA3_PDMA_POINTx=1342210832, PDMA3_PDMA_CSARx=1342210836, PDMA3_PDMA_CDARx=1342210840, PDMA3_PDMA_CBCRx=1342210844, PDMA3_PDMA_IERx=1342210848, PDMA3_PDMA_ISRx=1342210852, PDMA3_PDMA_SBUF0_cx=1342210944, PDMA4_PDMA_CSRx=1342211072, PDMA4_PDMA_SARx=1342211076, PDMA4_PDMA_DARx=1342211080, PDMA4_PDMA_BCRx=1342211084, PDMA4_PDMA_POINTx=1342211088, PDMA4_PDMA_CSARx=1342211092, PDMA4_PDMA_CDARx=1342211096, PDMA4_PDMA_CBCRx=1342211100, PDMA4_PDMA_IERx=1342211104, PDMA4_PDMA_ISRx=1342211108, PDMA4_PDMA_SBUF0_cx=1342211200, PDMA5_PDMA_CSRx=1342211328, PDMA5_PDMA_SARx=1342211332, PDMA5_PDMA_DARx=1342211336, PDMA5_PDMA_BCRx=1342211340, PDMA5_PDMA_POINTx=1342211344, PDMA5_PDMA_CSARx=1342211348, PDMA5_PDMA_CDARx=1342211352, PDMA5_PDMA_CBCRx=1342211356, PDMA5_PDMA_IERx=1342211360, PDMA5_PDMA_ISRx=1342211364, PDMA5_PDMA_SBUF0_cx=1342211456, PDMA6_PDMA_CSRx=1342211584, PDMA6_PDMA_SARx=1342211588, PDMA6_PDMA_DARx=1342211592, PDMA6_PDMA_BCRx=1342211596, PDMA6_PDMA_POINTx=1342211600, PDMA6_PDMA_CSARx=1342211604, PDMA6_PDMA_CDARx=1342211608, PDMA6_PDMA_CBCRx=1342211612, PDMA6_PDMA_IERx=1342211616, PDMA6_PDMA_ISRx=1342211620, PDMA6_PDMA_SBUF0_cx=1342211712, PDMA7_PDMA_CSRx=1342211840, PDMA7_PDMA_SARx=1342211844, PDMA7_PDMA_DARx=1342211848, PDMA7_PDMA_BCRx=1342211852, PDMA7_PDMA_POINTx=1342211856, PDMA7_PDMA_CSARx=1342211860, PDMA7_PDMA_CDARx=1342211864, PDMA7_PDMA_CBCRx=1342211868, PDMA7_PDMA_IERx=1342211872, PDMA7_PDMA_ISRx=1342211876, PDMA7_PDMA_SBUF0_cx=1342211968, PDMA8_PDMA_CSRx=1342212096, PDMA8_PDMA_SARx=1342212100, PDMA8_PDMA_DARx=1342212104, PDMA8_PDMA_BCRx=1342212108, PDMA8_PDMA_POINTx=1342212112, PDMA8_PDMA_CSARx=1342212116, PDMA8_PDMA_CDARx=1342212120, PDMA8_PDMA_CBCRx=1342212124, PDMA8_PDMA_IERx=1342212128, PDMA8_PDMA_ISRx=1342212132, PDMA8_PDMA_SBUF0_cx=1342212224, PDMA_GCR_PDMA_GCRCSR=1342213888, PDMA_GCR_PDSSR0=1342213892, PDMA_GCR_PDSSR1=1342213896, PDMA_GCR_PDMA_GCRISR=1342213900, PDMA_GCR_PDSSR2=1342213904, PS2_PS2CON=1074790400, PS2_PS2TXDATA0=1074790404, PS2_PS2TXDATA1=1074790408, PS2_PS2TXDATA2=1074790412, PS2_PS2TXDATA3=1074790416, PS2_PS2RXDATA=1074790420, PS2_PS2STATUS=1074790424, PS2_PS2INTID=1074790428, RTC_INIR=1073774592, RTC_AER=1073774596, RTC_FCR=1073774600, RTC_TLR=1073774604, RTC_CLR=1073774608, RTC_TSSR=1073774612, RTC_DWR=1073774616, RTC_TAR=1073774620, RTC_CAR=1073774624, RTC_LIR=1073774628, RTC_RIER=1073774632, RTC_RIIR=1073774636, RTC_TTR=1073774640, SCS_SYST_CSR=3758153744, SCS_SYST_RVR=3758153748, SCS_SYST_CVR=3758153752, SCS_NVIC_ISER=3758153984, SCS_NVIC_ICER=3758154112, SCS_NVIC_ISPR=3758154240, SCS_NVIC_ICPR=3758154368, SCS_NVIC_IPR0=3758154752, SCS_NVIC_IPR1=3758154756, SCS_NVIC_IPR2=3758154760, SCS_NVIC_IPR3=3758154764, SCS_NVIC_IPR4=3758154768, SCS_NVIC_IPR5=3758154772, SCS_NVIC_IPR6=3758154776, SCS_NVIC_IPR7=3758154780, SCS_CPUID=3758157056, SCS_ICSR=3758157060, SCS_AIRCR=3758157068, SCS_SCR=3758157072, SCS_SHPR2=3758157084, SCS_SHPR3=3758157088, SPI0_SPI_CNTRL=1073938432, SPI0_SPI_DIVIDER=1073938436, SPI0_SPI_SSR=1073938440, SPI0_SPI_RX0=1073938448, SPI0_SPI_RX1=1073938452, SPI0_SPI_TX0=1073938464, SPI0_SPI_TX1=1073938468, SPI0_SPI_VARCLK=1073938484, SPI0_SPI_DMA=1073938488, SPI0_SPI_CNTRL2=1073938492, SPI1_SPI_CNTRL=1073954816, SPI1_SPI_DIVIDER=1073954820, SPI1_SPI_SSR=1073954824, SPI1_SPI_RX0=1073954832, SPI1_SPI_RX1=1073954836, SPI1_SPI_TX0=1073954848, SPI1_SPI_TX1=1073954852, SPI1_SPI_VARCLK=1073954868, SPI1_SPI_DMA=1073954872, SPI1_SPI_CNTRL2=1073954876, SPI2_SPI_CNTRL=1074987008, SPI2_SPI_DIVIDER=1074987012, SPI2_SPI_SSR=1074987016, SPI2_SPI_RX0=1074987024, SPI2_SPI_RX1=1074987028, SPI2_SPI_TX0=1074987040, SPI2_SPI_TX1=1074987044, SPI2_SPI_VARCLK=1074987060, SPI2_SPI_DMA=1074987064, SPI2_SPI_CNTRL2=1074987068, SPI3_SPI_CNTRL=1075003392, SPI3_SPI_DIVIDER=1075003396, SPI3_SPI_SSR=1075003400, SPI3_SPI_RX0=1075003408, SPI3_SPI_RX1=1075003412, SPI3_SPI_TX0=1075003424, SPI3_SPI_TX1=1075003428, SPI3_SPI_VARCLK=1075003444, SPI3_SPI_DMA=1075003448, SPI3_SPI_CNTRL2=1075003452, TMR0_TCSR=1073807360, TMR0_TCMPR=1073807364, TMR0_TISR=1073807368, TMR0_TDR=1073807372, TMR1_TCSR=1073807392, TMR1_TCMPR=1073807396, TMR1_TISR=1073807400, TMR1_TDR=1073807404, TMR2_TCSR=1074855936, TMR2_TCMPR=1074855940, TMR2_TISR=1074855944, TMR2_TDR=1074855948, TMR3_TCSR=1074855968, TMR3_TCMPR=1074855972, TMR3_TISR=1074855976, TMR3_TDR=1074855980, UART0_UA_RBR=1074069504, UART0_UA_THR=1074069504, UART0_UA_IER=1074069508, UART0_UA_FCR=1074069512, UART0_UA_LCR=1074069516, UART0_UA_MCR=1074069520, UART0_UA_MSR=1074069524, UART0_UA_FSR=1074069528, UART0_UA_ISR=1074069532, UART0_UA_TOR=1074069536, UART0_UA_BAUD=1074069540, UART0_UA_IRCR=1074069544, UART0_UA_ALT_CSR=1074069548, UART0_UA_FUN_SEL=1074069552, UART1_UA_RBR=1075118080, UART1_UA_THR=1075118080, UART1_UA_IER=1075118084, UART1_UA_FCR=1075118088, UART1_UA_LCR=1075118092, UART1_UA_MCR=1075118096, UART1_UA_MSR=1075118100, UART1_UA_FSR=1075118104, UART1_UA_ISR=1075118108, UART1_UA_TOR=1075118112, UART1_UA_BAUD=1075118116, UART1_UA_IRCR=1075118120, UART1_UA_ALT_CSR=1075118124, UART1_UA_FUN_SEL=1075118128, UART2_UA_RBR=1075134464, UART2_UA_THR=1075134464, UART2_UA_IER=1075134468, UART2_UA_FCR=1075134472, UART2_UA_LCR=1075134476, UART2_UA_MCR=1075134480, UART2_UA_MSR=1075134484, UART2_UA_FSR=1075134488, UART2_UA_ISR=1075134492, UART2_UA_TOR=1075134496, UART2_UA_BAUD=1075134500, UART2_UA_IRCR=1075134504, UART2_UA_ALT_CSR=1075134508, UART2_UA_FUN_SEL=1075134512, USB_USB_INTEN=1074135040, USB_USB_INTSTS=1074135044, USB_USB_FADDR=1074135048, USB_USB_EPSTS=1074135052, USB_USB_ATTR=1074135056, USB_USB_FLDET=1074135060, USB_USB_BUFSEG=1074135064, USB_USB_BUFSEG0=1074135072, USB_USB_MXPLD0=1074135076, USB_USB_CFG0=1074135080, USB_USB_CFGP0=1074135084, USB_USB_BUFSEG1=1074135088, USB_USB_MXPLD1=1074135092, USB_USB_CFG1=1074135096, USB_USB_CFGP1=1074135100, USB_USB_BUFSEG2=1074135104, USB_USB_MXPLD2=1074135108, USB_USB_CFG2=1074135112, USB_USB_CFGP2=1074135116, USB_USB_BUFSEG3=1074135120, USB_USB_MXPLD3=1074135124, USB_USB_CFG3=1074135128, USB_USB_CFGP3=1074135132, USB_USB_BUFSEG4=1074135136, USB_USB_MXPLD4=1074135140, USB_USB_CFG4=1074135144, USB_USB_CFGP4=1074135148, USB_USB_BUFSEG5=1074135152, USB_USB_MXPLD5=1074135156, USB_USB_CFG5=1074135160, USB_USB_CFGP5=1074135164, USB_USB_DRVSE0=1074135184, USB_USB_PDMA=1074135204, WDT_WTCR=1073758208, SC0_SC_RBR=1075380224, SC0_SC_THR=1075380224, SC0_SC_CTL=1075380228, SC0_SC_ALTCTL=1075380232, SC0_SC_EGTR=1075380236, SC0_SC_RFTMR=1075380240, SC0_SC_ETUCR=1075380244, SC0_SC_IER=1075380248, SC0_SC_ISR=1075380252, SC0_SC_TRSR=1075380256, SC0_SC_PINCSR=1075380260, SC0_SC_TMR0=1075380264, SC0_SC_TMR1=1075380268, SC0_SC_TMR2=1075380272, SC0_SC_TDRA=1075380280, SC0_SC_TDRB=1075380284, SC1_SC_RBR=1075396608, SC1_SC_THR=1075396608, SC1_SC_CTL=1075396612, SC1_SC_ALTCTL=1075396616, SC1_SC_EGTR=1075396620, SC1_SC_RFTMR=1075396624, SC1_SC_ETUCR=1075396628, SC1_SC_IER=1075396632, SC1_SC_ISR=1075396636, SC1_SC_TRSR=1075396640, SC1_SC_PINCSR=1075396644, SC1_SC_TMR0=1075396648, SC1_SC_TMR1=1075396652, SC1_SC_TMR2=1075396656, SC1_SC_TDRA=1075396664, SC1_SC_TDRB=1075396668, SC2_SC_RBR=1075412992, SC2_SC_THR=1075412992, SC2_SC_CTL=1075412996, SC2_SC_ALTCTL=1075413000, SC2_SC_EGTR=1075413004, SC2_SC_RFTMR=1075413008, SC2_SC_ETUCR=1075413012, SC2_SC_IER=1075413016, SC2_SC_ISR=1075413020, SC2_SC_TRSR=1075413024, SC2_SC_PINCSR=1075413028, SC2_SC_TMR0=1075413032, SC2_SC_TMR1=1075413036, SC2_SC_TMR2=1075413040, SC2_SC_TDRA=1075413048, SC2_SC_TDRB=1075413052, } g_NUC1xx_regs=REG function read_NUC100_Registers(t,t,t,e) local n=true local t={ NUC101_BN_QFN36=1, NUC101_BN_LQFP48=1, NUC120_AN_LQFP48=1, NUC120_BN_LQFP48=1, NUC120_DN_LQFP48=1, NUC122_AN_QFN33=1, NUC122_AN_LQFP48=1, NUC122_AN_LQFP64=1, NUC130_CN_LQFP48=1, NUC140_CN_LQFP48=1, NUC140_CN_LQFP64=1} if t[e]~=nil then n=false end local s=false local t={ NUC100_DN_LQFP48=1, NUC100_DN_LQFP64=1, NUC100_DN_LQFP100=1, NUC120_DN_LQFP48=1, NUC120_DN_LQFP64=1, NUC120_DN_LQFP100=1} if t[e]~=nil then s=true end local i=false local t={ NUC100_DN_LQFP48=1, NUC100_DN_LQFP64=1, NUC100_DN_LQFP100=1, NUC120_DN_LQFP48=1, NUC120_DN_LQFP64=1, NUC120_DN_LQFP100=1} if t[e]~=nil then i=true end local a=false local t={ NUC130_CN_LQFP48=1, NUC130_CN_LQFP64=1, NUC130_CN_LQFP100=1, NUC140_CN_LQFP48=1, NUC140_CN_LQFP64=1, NUC140_CN_LQFP100=1} if t[e]~=nil then a=true end local t=false local o={ NUC100_BN_LQFP64=1, NUC120_BN_LQFP64=1, NUC130_CN_LQFP64=1, NUC130_CN_LQFP100=1, NUC140_CN_LQFP64=1, NUC140_CN_LQFP100=1, NUC100_DN_LQFP48=1, NUC100_DN_LQFP64=1, NUC100_DN_LQFP100=1, NUC120_DN_LQFP48=1, NUC120_DN_LQFP64=1, NUC120_DN_LQFP100=1} if o[e]~=nil then t=true end local o=false local h={ NUC100_DN_LQFP48=1, NUC100_DN_LQFP64=1, NUC100_DN_LQFP100=1, NUC120_DN_LQFP48=1, NUC120_DN_LQFP64=1, NUC120_DN_LQFP100=1} if h[e]~=nil then o=true end local e={} e["GCR_GPA_MFP"], e["GCR_GPB_MFP"], e["GCR_GPC_MFP"], e["GCR_GPD_MFP"], e["GCR_GPE_MFP"], e["GCR_GPF_MFP"], e["REG_DUMMY0"], e["REG_DUMMY1"], e["GCR_ALT_MFP"]=ice:ReadMem32(g_NUC1xx_regs.GCR_GPA_MFP,9) if i then e["GCR_ALT_MFP1"]=ice:ReadMem32(g_NUC1xx_regs.GCR_ALT_MFP1) end e["GCR_IRCTRIMCTL"]=ice:ReadMem32(g_NUC1xx_regs.GCR_IRCTRIMCTL) e["GPA_PMD"], e["GPA_OFFD"], e["GPA_DOUT"], e["GPA_DMASK"], e["GPA_PIN"]=ice:ReadMem32(g_NUC1xx_regs.GPA_PMD,5) e["GPB_PMD"], e["GPB_OFFD"], e["GPB_DOUT"], e["GPB_DMASK"], e["GPB_PIN"]=ice:ReadMem32(g_NUC1xx_regs.GPB_PMD,5) e["GPC_PMD"], e["GPC_OFFD"], e["GPC_DOUT"], e["GPC_DMASK"], e["GPC_PIN"]=ice:ReadMem32(g_NUC1xx_regs.GPC_PMD,5) e["GPD_PMD"], e["GPD_OFFD"], e["GPD_DOUT"], e["GPD_DMASK"], e["GPD_PIN"]=ice:ReadMem32(g_NUC1xx_regs.GPD_PMD,5) if n then e["GPE_PMD"], e["GPE_OFFD"], e["GPE_DOUT"], e["GPE_DMASK"], e["GPE_PIN"]=ice:ReadMem32(g_NUC1xx_regs.GPE_PMD,5) end if s then e["GPF_PMD"], e["GPF_OFFD"], e["GPF_DOUT"], e["GPF_DMASK"], e["GPF_PIN"]=ice:ReadMem32(g_NUC1xx_regs.GPF_PMD,5) end e["ADC_ADCR"], e["I2S_I2S_CON"], e["I2S_I2S_CLKDIV"]=ice:ReadMemMulti(g_NUC1xx_regs.ADC_ADCR, g_NUC1xx_regs.I2S_I2S_CON, g_NUC1xx_regs.I2S_I2S_CLKDIV) if t then e["EBI_EBICON"]=ice:ReadMem32(g_NUC1xx_regs.EBI_EBICON) end if a then e["CAN_CAN_BTIME"], e["CAN_CAN_BRPE"]=ice:ReadMemMulti(g_NUC1xx_regs.CAN_CAN_BTIME, g_NUC1xx_regs.CAN_CAN_BRPE) end e["CLK_PWRCON"], e["CLK_AHBCLK"], e["CLK_APBCLK"], e["CLK_CLKSTATUS"], e["CLK_CLKSEL0"], e["CLK_CLKSEL1"], e["CLK_CLKDIV"], e["CLK_CLKSEL2"], e["CLK_PLLCON"], e["CLK_FRQDIV"]=ice:ReadMem32(g_NUC1xx_regs.CLK_PWRCON,10) e["CLK_APBCLK1"], e["CLK_CLKSEL3"], e["CLK_CLKDIV1"]=ice:ReadMem32(g_NUC1xx_regs.CLK_APBCLK1,3) e["I2C0_I2CON"], e["I2C0_I2CLK"], e["I2C1_I2CON"], e["I2C1_I2CLK"]=ice:ReadMemMulti(g_NUC1xx_regs.I2C0_I2CON, g_NUC1xx_regs.I2C0_I2CLK, g_NUC1xx_regs.I2C1_I2CON, g_NUC1xx_regs.I2C1_I2CLK) e["PWMA_PPR"], e["PWMA_CSR"], e["PWMB_PPR"], e["PWMB_CSR"]=ice:ReadMemMulti(g_NUC1xx_regs.PWMA_PPR, g_NUC1xx_regs.PWMA_CSR, g_NUC1xx_regs.PWMB_PPR, g_NUC1xx_regs.PWMB_CSR) e["SPI0_SPI_CNTRL"], e["SPI0_SPI_DIVIDER"], e["SPI1_SPI_CNTRL"], e["SPI1_SPI_DIVIDER"]=ice:ReadMemMulti(g_NUC1xx_regs.SPI0_SPI_CNTRL, g_NUC1xx_regs.SPI0_SPI_DIVIDER, g_NUC1xx_regs.SPI1_SPI_CNTRL, g_NUC1xx_regs.SPI1_SPI_DIVIDER) e["SPI2_SPI_CNTRL"], e["SPI2_SPI_DIVIDER"], e["SPI3_SPI_CNTRL"], e["SPI3_SPI_DIVIDER"]=ice:ReadMemMulti(g_NUC1xx_regs.SPI2_SPI_CNTRL, g_NUC1xx_regs.SPI2_SPI_DIVIDER, g_NUC1xx_regs.SPI3_SPI_CNTRL, g_NUC1xx_regs.SPI3_SPI_DIVIDER) e["SPI0_SPI_CNTRL2"], e["SPI1_SPI_CNTRL2"], e["SPI2_SPI_CNTRL2"], e["SPI3_SPI_CNTRL2"]=ice:ReadMemMulti(g_NUC1xx_regs.SPI0_SPI_CNTRL2, g_NUC1xx_regs.SPI1_SPI_CNTRL2, g_NUC1xx_regs.SPI2_SPI_CNTRL2, g_NUC1xx_regs.SPI3_SPI_CNTRL2) e["UART0_UA_BAUD"], e["UART1_UA_BAUD"], e["UART2_UA_BAUD"]=ice:ReadMemMulti(g_NUC1xx_regs.UART0_UA_BAUD, g_NUC1xx_regs.UART1_UA_BAUD, g_NUC1xx_regs.UART2_UA_BAUD) e["TMR0_TCSR"], e["TMR1_TCSR"], e["TMR2_TCSR"], e["TMR3_TCSR"]=ice:ReadMemMulti(g_NUC1xx_regs.TMR0_TCSR, g_NUC1xx_regs.TMR1_TCSR, g_NUC1xx_regs.TMR2_TCSR, g_NUC1xx_regs.TMR3_TCSR) if o then e["SC0_SC_CTL"], e["SC1_SC_CTL"], e["SC2_SC_CTL"]=ice:ReadMemMulti(g_NUC1xx_regs.SC0_SC_CTL, g_NUC1xx_regs.SC1_SC_CTL, g_NUC1xx_regs.SC2_SC_CTL) end return e end local n={ [0]=kPinDirection_In, [1]=kPinDirection_PushPullOut, [2]=kPinDirection_OpenDrainOut, [3]=kPinDirection_Bi, } local u={ [0]="INPUT", [1]="OUTPUT", [2]="Open-Drain", [3]="Quasi-bidirectional", } function get_mfp_regs(a,e,o,t) local e={"GCR_GP"..e.."_MFP"} if o~=nil then table.insert(e,o)end if t~=nil then table.insert(e,t)end if#e>1 then return reg2str("Multi-Function registers",g_NUC1xx_regs,a,e) else return reg2str("Multi-Function register",g_NUC1xx_regs,a,e) end end function fill_NUC100_GPIO(o,s,t,e,r,c,m) local i if r==nil then r=string.format("P%s.%d",t,e)end local a=s["GP"..t.."_PMD"] local f=s["GP"..t.."_OFFD"] local l=s["GP"..t.."_DOUT"] local h=s["GP"..t.."_DMASK"] local d=s["GP"..t.."_PIN"] o["highlight_text"]=r o["normal_color"]=kColor_Invalid o["highlight_color"]=kColor_GPIO o["pin_bg_color"]=kBgColor_GPIO i=ext.band(ext.rshift(a,e*2),3) o["direction"]=n[i] if n[i]==kPinDirection_In or n[i]==kPinDirection_Bi then if ext.band(d,ext.lshift(1,e))==0 then o["status"]=kPinStatus_Low else o["status"]=kPinStatus_High end else if ext.band(h,ext.lshift(1,e))~=0 then o["status"]=kPinStatus_Unknown elseif ext.band(l,ext.lshift(1,e))==0 then o["status"]=kPinStatus_Low else o["status"]=kPinStatus_High end end local a=string.format("P%s.%d is in %s mode
", t,e,u[i]) if n[i]==kPinDirection_In or n[i]==kPinDirection_Bi then if ext.band(d,ext.lshift(1,e))==0 then a=a.."Pin input low
" else a=a.."Pin input high
" end end if n[i]==kPinDirection_PushPullOut or n[i]==kPinDirection_OpenDrainOut or n[i]==kPinDirection_Bi then if ext.band(h,ext.lshift(1,e))~=0 then a=a.."Pin output masked
" elseif ext.band(l,ext.lshift(1,e))==0 then a=a.."Pin output low
" else a=a.."Pin output high
" end end if ext.band(f,ext.lshift(1,e+16))==0 then a=a.."IO digital input path enabled
" else a=a.."IO digital input path disabled(digital input tied to low)
" end local h="" if n[i]==kPinDirection_PushPullOut or n[i]==kPinDirection_Bi then if ext.band(l,ext.lshift(1,e))==0 and ext.band(d,ext.lshift(1,e))~=0 then h=string.format("Leakage warning: GP%s_DOUT[%d] = 0, GP%s_PIN[%d] = 1
",t,e,t,e) elseif ext.band(l,ext.lshift(1,e))~=0 and ext.band(d,ext.lshift(1,e))==0 then h=string.format("Leakage warning: GP%s_DOUT[%d] = 1, GP%s_PIN[%d] = 0
",t,e,t,e) end end if h~=""then o["pin_no_color"]=kBgColor_Error h=""..h.."" end local e={ "GP"..t.."_PMD", "GP"..t.."_OFFD", "GP"..t.."_DOUT", "GP"..t.."_DMASK", "GP"..t.."_PIN"} local e=reg2str("GPIO setting registers",g_NUC1xx_regs,s,e) o["information"]=string.format("%s
%s
".. "%s%s".. "Information
".. "%s", r, h, get_mfp_regs(s,t,c,m), e, a) end function fill_invalid_GPIO(e,s,t,a,i,n) e["highlight_text"]=string.format("P%s.%d",t,a) e["normal_color"]=kColor_Invalid e["highlight_color"]=kColor_Invalid e["pin_bg_color"]=kBgColor_Invalid e["direction"]=kPinDirection_Unknown e["status"]=kPinStatus_Unknown e["pin_no_color"]=kBgColor_Error local o="Undefined setting in Multi-Function registers for this pin
" e["information"]=string.format("P%s.%d
%s
".. "%s", t,a, o, get_mfp_regs(s,t,i,n)) end function get_XTL12M_clock(a,o) local t local e table.insert(o,"CLK_PWRCON") local a=ext.band(a["CLK_PWRCON"],1) if a==0 then t=0 e="invalid external 4~24M high speed crystal clock (see PWRCON[0].XTL12M_EN)" else t=12000000 e="external 4~24M high speed crystal clock, when external input clock is 12M" end return t,e end function get_XTL32K_clock(a,o) local e local t table.insert(o,"CLK_PWRCON") local a=ext.band(a["CLK_PWRCON"],2) if a==0 then e=0 t="invalid external 32.768kHz low speed crystal clock (see PWRCON[1].XTL32K_EN)" else e=32768 t="external 32.768kHz low speed crystal clock" end return e,t end function get_OSC22M_clock(o,a) local e local t table.insert(a,"CLK_PWRCON") local i=ext.band(o["CLK_PWRCON"],4) if i==0 then e=0 t="invalid internal 22.1184MHz high speed oscillator clock (see PWRCON[2].OSC22M_EN)" else local i=get_chip_info()["series_group"] if i==3 then table.insert(a,"GCR_IRCTRIMCTL") local a=ext.band(o["GCR_IRCTRIMCTL"],3) if a==0 then e=22118400 t="internal 22.1184MHz high speed oscillator clock" elseif a==1 then e=22118400 t="internal 22.1184MHz high speed oscillator clock (auto trim)" elseif a==2 then e=24000000 t="internal 24MHz high speed oscillator clock (auto trim)" else e=0 t="invalid HIRC trim frequency selection (see GCR_IRCTRIMCTL[1:0].TRIM_SEL)" end else e=22118400 t="internal 22.1184MHz high speed oscillator clock" end end return e,t end function get_OSC10K_clock(o,a) local e local t table.insert(a,"CLK_PWRCON") local a=ext.band(o["CLK_PWRCON"],8) if a==0 then e=0 t="invalid internal 10kHz low speed oscillator clock (see PWRCON[3].OSC10K_EN)" else e=10000 t="internal 10kHz low speed oscillator clock" end return e,t end function get_PLL_clock(a,o) local t local e table.insert(o,"CLK_PLLCON") if ext.band(a["CLK_PLLCON"],65536)~=0 then t=0 e="invalid PLL clock, PLL is in power down mode (see PLLCON[16].PD)" else if ext.band(a["CLK_PLLCON"],524288)~=0 then t,e=get_OSC22M_clock(a,o) else t,e=get_XTL12M_clock(a,o) end if t~=0 then if ext.band(a["CLK_PLLCON"],131072)~=0 then e=string.format("PLL clock (%sHz), bypassed from %s",val2str(t),e) else local n={1,2,2,4} local i=ext.band(a["CLK_PLLCON"],511)+2 local o=ext.rshift(ext.band(a["CLK_PLLCON"],15872),9)+2 local a=n[ext.rshift(ext.band(a["CLK_PLLCON"],49152),14)+1] t=t*i/o/a e=string.format("PLL clock (%sHz), from %s",val2str(t),e) end else e="PLL clock from "..e end end return t,e end function get_sys_clock(a,o,n) table.insert(o,"CLK_CLKSEL0") local i=ext.band(a["CLK_CLKSEL0"],7) local t local e if i==0 then t,e=get_XTL12M_clock(a,o) elseif i==2 then t,e=get_PLL_clock(a,o) elseif i==3 then t,e=get_OSC10K_clock(a,o) elseif i==7 then t,e=get_OSC22M_clock(a,o) elseif i==1 then t,e=get_XTL32K_clock(a,o) else t=0 e="invalid "..n.." clock (see CLKSEL0[2:0].HCLK_S)" return t,e end if t==0 then e=""..n.." clock from "..e else table.insert(o,"CLK_CLKDIV") local a=ext.band(a["CLK_CLKDIV"],15) t=t/(a+1) e=string.format("%s clock (%sHz), from %s",n,val2str(t),e) end return t,e end function get_HCLK_clock(e,t) return get_sys_clock(e,t,"HCLK") end function get_PCLK_clock(t,e) return get_sys_clock(t,e,"PCLK") end function get_clk_informnation(e,t) return reg2str("Clock setting registers",g_NUC1xx_regs,e,t) end function fill_NUC100_PS2(e,o,n) local a="" local t="" local i={} e["highlight_text"]=n e["normal_color"]=kColor_Invalid e["highlight_color"]=kColor_Normal e["pin_bg_color"]=kBgColor_Normal e["direction"]=kPinDirection_Unknown e["status"]=kPinStatus_Unknown table.insert(i,"CLK_APBCLK") if ext.band(o["CLK_APBCLK"],2147483648)~=0 then local n local e n,e=get_OSC22M_clock(o,i) if n~=0 then a="PS2 clock from "..e..".
" else t="PS2 clock is not available, "..e..".
" end else t="PS2 clock is not available (see APBCLK[31].PS2_EN).
" end if t~=""then t=""..t.."" e["pin_no_color"]=kBgColor_Error end if a~=""then a="Information
"..a end e["information"]=string.format( "%s
%s
".. "%s%s", n, t, get_clk_informnation(o,i), a) end function fill_NUC100_ACMP(e,a,s,t,o,h,n) local t="" local i={} e["highlight_text"]=o e["normal_color"]=kColor_Invalid e["highlight_color"]=kColor_CMP e["pin_bg_color"]=kBgColor_CMP e["direction"]=kPinDirection_In e["status"]=kPinStatus_Unknown table.insert(i,"CLK_APBCLK") if ext.band(a["CLK_APBCLK"],1073741824)==0 then t="ACMP clock is not available (see APBCLK[30].ACMP_EN).
" t=""..t.."" e["pin_no_color"]=kBgColor_Error end e["information"]=string.format( "%s
%s
".. "%s%s", o, t, get_mfp_regs(a,s,h,n), get_clk_informnation(a,i)) end function fill_NUC100_I2S(i,t,d,e,h,r,l) local e="" local n="" local o={} i["highlight_text"]=h i["normal_color"]=kColor_Invalid i["highlight_color"]=kColor_I2S i["pin_bg_color"]=kBgColor_I2S i["direction"]=kPinDirection_Unknown i["status"]=kPinStatus_Unknown table.insert(o,"CLK_APBCLK") if ext.band(t["CLK_APBCLK"],536870912)~=0 then table.insert(o,"CLK_CLKSEL2") local s=ext.band(t["CLK_CLKSEL2"],3) local a local i if s==0 then a,i=get_XTL12M_clock(t,o) elseif s==1 then a,i=get_PLL_clock(t,o) elseif s==2 then a,i=get_HCLK_clock(t,o) else a,i=get_OSC22M_clock(t,o) end if a~=0 then table.insert(o,"I2S_I2S_CLKDIV") table.insert(o,"I2S_I2S_CON") local o=ext.band(t["I2S_I2S_CON"],1) if o~=0 then e="I2S is enabled
" else e="I2S is disabled, (see I2S_CON[0].I2SEN)
" end e=e..string.format("I2S_CLK frequency: %sHz, from %s.
",val2str(a),i) local o=ext.band(ext.rshift(t["I2S_I2S_CLKDIV"],8),255) local t=ext.band(t["I2S_I2S_CLKDIV"],7) local i=a/(2*(o+1)) local o=a if t~=0 then o=a/(2*t) end e=e..string.format("I2S BCLK frequency: %sHz
",val2str(i)) e=e..string.format("I2S MCLK frequency: %sHz
",val2str(o)) else n="I2S clock is not available, "..i..".
" end else n="I2S clock is not available (see APBCLK[29].I2S_EN).
" end if n~=""then n=""..n.."" i["pin_no_color"]=kBgColor_Error end if e~=""then e="Information
"..e end i["information"]=string.format("%s
%s
%s%s%s", h, n, get_mfp_regs(t,d,r,l), get_clk_informnation(t,o), e) end function fill_NUC100_UART(i,e,l,t,d,a,c,u) local n="" local t="" local o={} local s=0 i["highlight_text"]=d i["normal_color"]=kColor_Invalid i["highlight_color"]=kColor_UART i["pin_bg_color"]=kBgColor_UART i["direction"]=kPinDirection_Unknown i["status"]=kPinStatus_Unknown function get_uart_baudate(n) local s=string.format("UART%d",a) local t=string.format("UART%d_UA_BAUD",a) table.insert(o,t) local o=ext.band(e[t],536870912) local i=ext.band(e[t],268435456) local h=ext.rshift(ext.band(e[t],251658240),24) local t=ext.band(e[t],65535) local a=0 local e="" if o==0 and i==0 then a=n/(16*(t+2)) elseif o~=0 and i==0 then if h>=8 then a=n/((h+1)*(t+2)) else e="invalid "..s.."'s UA_BAUD value, DIVIDER_X must >= 8" end elseif o~=0 and i~=0 then if t>=3 then a=n/(t+2) else e="invalid "..s.."'s UA_BAUD value, BRD must >= 3" end else e="invalid "..s.."'s UA_BAUD value" end return a,e end table.insert(o,"CLK_APBCLK") if ext.band(e["CLK_APBCLK"],ext.lshift(65536,a))~=0 then table.insert(o,"CLK_CLKSEL1") local r=ext.band(ext.rshift(e["CLK_CLKSEL1"],24),3) local d=ext.band(ext.rshift(e["CLK_CLKDIV"],8),15) local h local i if r==0 then h,i=get_XTL12M_clock(e,o) elseif r==1 then h,i=get_PLL_clock(e,o) elseif r==3 then h,i=get_OSC22M_clock(e,o) else t=string.format("UART%d clock is not available (see CLKSEL1[25:24].UART_S).
",a) end if t==""then s=h/(d+1) if s~=0 then table.insert(o,"CLK_CLKDIV") n=string.format("UART%d clock frequency: %sHz, from %s.
",a,val2str(s),i) else t=string.format("UART%d clock is not available, %s.
",a,i) end end else t=string.format("UART%d clock is not available (see APBCLK[%d].UART%d_EN).
", a,a+16,a) end if t==""then local e,a=get_uart_baudate(s) if e~=0 then n=n..string.format("UART baudrate: %d
",e) else t=a..".
" end end if t~=""then t=""..t.."" i["pin_no_color"]=kBgColor_Error end if n~=""then n="Information
"..n end i["information"]=string.format( "%s
%s
".. "%s%s%s", d, t, get_mfp_regs(e,l,c,u), get_clk_informnation(e,o), n) end function fill_NUC100_SPI(s,t,m,a,l,e,c,u) local r=get_chip_info()["series_group"] local a="" local h="" local o={} s["highlight_text"]=l s["normal_color"]=kColor_Invalid s["highlight_color"]=kColor_SPI s["pin_bg_color"]=kBgColor_SPI s["direction"]=kPinDirection_Unknown s["status"]=kPinStatus_Unknown table.insert(o,"CLK_APBCLK") if ext.band(t["CLK_APBCLK"],ext.lshift(4096,e))~=0 then local i,n if r==3 then table.insert(o,"CLK_CLKSEL1") local e=ext.band(ext.rshift(t["CLK_CLKSEL1"],e+4),1) if e==0 then i,n=get_PLL_clock(t,o) else i,n=get_HCLK_clock(t,o) end else i,n=get_PCLK_clock(t,o) end if i~=0 then local d=string.format("SPI%d_SPI_CNTRL",e) local h=string.format("SPI%d_SPI_CNTRL2",e) local s=string.format("SPI%d_SPI_DIVIDER",e) table.insert(o,d) local l=ext.band(t[d],262144) if l~=0 then a=string.format("SPI%d is in slave mode.
",e) else a=string.format("SPI%d is in master mode.
",e) if r==3 then table.insert(o,s) table.insert(o,h) local r=ext.band(t[s],255) local s=ext.band(ext.rshift(t[s],16),255) local h=ext.band(t[h],2147483648) local o=0 if h~=0 then o=i/(r+1) else o=i/((r+1)*2) end local i=i/((s+1)*2) local t=ext.band(t[d],8388608) if t~=0 then a=a..string.format("SPI%d clock frequency is variable: %sHz or %sHz, from %s.
", e,val2str(o),val2str(i),n) else a=a..string.format("SPI%d clock frequency: %sHz, from %s.
", e,val2str(o),n) end else if r==2 then table.insert(o,h) end local h=ext.band(t[h],1) if r==2 and h~=0 then a=a..string.format("SPI%d clock frequency: %sHz, from %s.
", e,val2str(i),n) else table.insert(o,s) local o=ext.band(t[s],65535) local s=ext.band(ext.rshift(t[s],16),65535) local o=i/((o+1)*2) local i=i/((s+1)*2) local t=ext.band(t[d],8388608) if t~=0 then a=a..string.format("SPI%d clock frequency is variable: %sHz or %sHz, from %s.
", e,val2str(o),val2str(i),n) else a=a..string.format("SPI%d clock frequency: %sHz, from %s.
", e,val2str(o),n) end end end end else h=string.format("SPI%d clock is not available, %s.
",e,n) end else h=string.format("SPI%d clock is not available (see APBCLK[%d].SPI%d_EN).
",e,e+12,e) end if h~=""then h=""..h.."" s["pin_no_color"]=kBgColor_Error end if a~=""then a="Information
"..a end s["information"]=string.format( "%s
%s
".. "%s%s%s", l, h, get_mfp_regs(t,m,c,u), get_clk_informnation(t,o), a) end function fill_NUC100_SPI_IO(e,o,a,t) local a=string.format("SPI%d_SPI_CNTRL",a) local a=ext.band(o[a],262144) if a==0 then if t then e["direction"]=kPinDirection_In else e["direction"]=kPinDirection_PushPullOut end else if t then e["direction"]=kPinDirection_PushPullOut else e["direction"]=kPinDirection_In end end end function fill_NUC100_ADC(a,e,l,t,h,u,d) local r=get_chip_info()["series_group"] local i="" local t="" local o={} a["highlight_text"]=h a["normal_color"]=kColor_Invalid a["highlight_color"]=kColor_ADC a["pin_bg_color"]=kBgColor_ADC a["direction"]=kPinDirection_In a["status"]=kPinStatus_Unknown table.insert(o,"CLK_APBCLK") if ext.band(e["CLK_APBCLK"],268435456)~=0 then table.insert(o,"CLK_CLKSEL1") local s=ext.rshift(ext.band(e["CLK_CLKSEL1"],12),2) local h=ext.rshift(ext.band(e["CLK_CLKDIV"],16711680),16) local n local a if s==0 then n,a=get_XTL12M_clock(e,o) elseif s==1 then n,a=get_PLL_clock(e,o) elseif s==3 then n,a=get_OSC22M_clock(e,o) elseif s==2 and r==3 then n,a=get_HCLK_clock(e,o) else t="ADC clock is not available (see CLKSEL1[3:2].ADC_S).
" end if t==""then local e=n/(h+1) if e~=0 then table.insert(o,"CLK_CLKDIV") i=string.format("ADC clock frequency: %sHz, from %s.
",val2str(e),a) else t="ADC clock is not available, "..a..".
" end end else t="ADC clock is not available (see APBCLK[28].ADC_EN).
" end if t~=""then t=""..t.."" a["pin_no_color"]=kBgColor_Error end if i~=""then i="Information
"..i end a["information"]=string.format("%s
%s
%s%s%s", h, t, get_mfp_regs(e,l,u,d), get_clk_informnation(e,o), i) end function fill_NUC100_USB(e,i,s) local a="" local t="" local o={} e["highlight_text"]=s e["normal_color"]=kColor_Invalid e["highlight_color"]=kColor_USB e["pin_bg_color"]=kBgColor_USB e["direction"]=kPinDirection_Unknown e["status"]=kPinStatus_Unknown table.insert(o,"CLK_APBCLK") if ext.band(i["CLK_APBCLK"],134217728)~=0 then local n local e n,e=get_PLL_clock(i,o) if n~=0 then table.insert(o,"CLK_CLKDIV") local t=ext.band(ext.rshift(i["CLK_CLKDIV"],4),15) local t=n/(t+1) a=string.format("USB clock frequency: %sHz, from %s.
",val2str(t),e) else t="USB clock is not available, "..e..".
" end else t="USB clock is not available (see APBCLK[27].USBD_EN).
" end if t~=""then t=""..t.."" e["pin_no_color"]=kBgColor_Error end if a~=""then a="Information
"..a end e["information"]=string.format( "%s
%s
".. "%s%s", s, t, get_clk_informnation(i,o), a) end function fill_NUC100_CAN(t,e,h,a,s,d,r) local o="" local a="" local i={} t["highlight_text"]=s t["normal_color"]=kColor_Invalid t["highlight_color"]=kColor_CAN t["pin_bg_color"]=kBgColor_CAN t["status"]=kPinStatus_Unknown function get_can_bitrate(a) table.insert(i,"CAN_CAN_BTIME") table.insert(i,"CAN_CAN_BRPE") local o=ext.band(ext.rshift(e["CAN_CAN_BTIME"],8),15) local t=ext.band(ext.rshift(e["CAN_CAN_BTIME"],12),7) local e= ext.bor(ext.band(e["CAN_CAN_BTIME"],63), ext.lshift(ext.band(e["CAN_CAN_BRPE"],15),6)) local e=a/(e+1)/(o+t+3)/1000 return e end table.insert(i,"CLK_APBCLK") if ext.band(e["CLK_APBCLK"],16777216)~=0 then local n local t n,t=get_PCLK_clock(e,i) if n~=0 then local e=get_can_bitrate(n) o=string.format("CAN bitrate: %sHz, from %s.
",val2str(e),t) else a="CAN clock is not available, "..t..".
" end else a="CAN clock is not available (see APBCLK[24].CAN_EN).
" end if a~=""then a=""..a.."" t["pin_no_color"]=kBgColor_Error end if o~=""then o="Information
"..o end t["information"]=string.format( "%s
%s
".. "%s%s%s", s, a, get_mfp_regs(e,h,d,r), get_clk_informnation(e,i), o) end function fill_NUC100_I2C(t,o,d,a,s,e,l,r) local i="" local a="" local n={} t["highlight_text"]=s t["normal_color"]=kColor_Invalid t["highlight_color"]=kColor_I2C t["pin_bg_color"]=kBgColor_I2C t["direction"]=kPinDirection_Unknown t["status"]=kPinStatus_Unknown table.insert(n,"CLK_APBCLK") if ext.band(o["CLK_APBCLK"],ext.lshift(256,e))~=0 then local t=string.format("I2C%d_I2CON",e) local h=string.format("I2C%d_I2CLK",e) table.insert(n,t) local t=ext.band(o[t],64) if t~=0 then local s,t=get_PCLK_clock(o,n) if s~=0 then table.insert(n,h) local a=ext.band(o[h],255) local a=s/(4*(a+1)) i=string.format("I2C%d clock frequency: %sHz, from %s.
",e,val2str(a),t) else a=string.format("I2C%d clock is not available, %s.
",e,t) end else a=string.format("I2C%d controller disabled (see I2C%d.I2CON[6].ENS1).
",e,e) end else a=string.format("I2C%d clock is not available (see APBCLK[%d].I2C%d_EN).
",e,8+e,e) end if a~=""then a=""..a.."" t["pin_no_color"]=kBgColor_Error end if i~=""then i="Information
"..i end t["information"]=string.format( "%s
%s
".. "%s%s%s", s, a, get_mfp_regs(o,d,l,r), get_clk_informnation(o,n), i) end function fill_NUC100_CLKO(o,e,l,t,h,d,r) local i="" local t="" local a={} o["highlight_text"]=h o["normal_color"]=kColor_Invalid o["highlight_color"]=kColor_CLK o["pin_bg_color"]=kBgColor_CLK o["direction"]=kPinDirection_PushPullOut o["status"]=kPinStatus_Unknown table.insert(a,"CLK_APBCLK") if ext.band(e["CLK_APBCLK"],64)~=0 then table.insert(a,"CLK_FRQDIV") if ext.band(e["CLK_FRQDIV"],16)~=0 then table.insert(a,"CLK_CLKSEL2") local s=ext.rshift(ext.band(e["CLK_CLKSEL2"],12),2) local h=ext.band(e["CLK_FRQDIV"],15) local n local o if s==0 then n,o=get_XTL12M_clock(e,a) elseif s==1 then n,o=get_XTL32K_clock(e,a) elseif s==2 then n,o=get_HCLK_clock(e,a) elseif s==3 then n,o=get_OSC22M_clock(e,a) else t="Frequency divider is not available (see CLKSEL2[3:2].FRQDIV_S).
" end if t==""then local e=n/ext.lshift(1,(h+1)) if e~=0 then table.insert(a,"CLK_FRQDIV") i=string.format("FRQDIV clock frequency: %sHz, from %s.
",val2str(e),o) else t="FRQDIV clock is not available, "..o..".
" end end else t="Frequency divider disabled (see FRQDIV[4].DIVIDER_EN).
" end else t="FRQDIV clock is not available (see APBCLK[6].FDIV_EN).
" end if t~=""then t=""..t.."" o["pin_no_color"]=kBgColor_Error end if i~=""then i="Information
"..i end o["information"]=string.format( "%s
%s
".. "%s%s%s", h, t, get_mfp_regs(e,l,d,r), get_clk_informnation(e,a), i) end function fill_NUC100_PWM(d,t,y,e,f,v,p) local w=get_chip_info()["series_group"] local c="" local s="" local a={} local o=tonumber((f:gsub("^PWM",""))) local e=ext.rshift(o,1) local r=ext.rshift(e,1) local m=({'PWMA','PWMB'})[1+r] d["highlight_text"]=f d["normal_color"]=kColor_Invalid d["highlight_color"]=kColor_PWM d["pin_bg_color"]=kBgColor_PWM d["direction"]=kPinDirection_Unknown d["status"]=kPinStatus_Unknown table.insert(a,"CLK_APBCLK") local n=ext.band(t["CLK_APBCLK"],ext.lshift(1048576,e)) local i local u if n~=0 then local d local l if e==0 then d="CLKSEL1" l="[29:28]" i=ext.rshift(ext.band(t["CLK_CLKSEL1"],805306368),28) elseif e==1 then d="CLKSEL1" l="[31:30]" i=ext.rshift(ext.band(t["CLK_CLKSEL1"],3221225472),30) elseif e==2 then d="CLKSEL2" l="[5:4]" i=ext.rshift(ext.band(t["CLK_CLKSEL2"],48),4) else d="CLKSEL2" l="[7:6]" i=ext.rshift(ext.band(t["CLK_CLKSEL2"],192),6) end if w==3 then table.insert(a,"CLK_CLKSEL2") u=ext.band(ext.rshift(t["CLK_CLKSEL2"],8+e),1) end table.insert(a,"CLK_"..d) local n local h if w==3 then if u==0 and i==0 then n,h=get_XTL12M_clock(t,a) elseif u==0 and i==1 then n,h=get_XTL32K_clock(t,a) elseif u==0 and i==2 then n,h=get_HCLK_clock(t,a) elseif u==0 and i==3 then n,h=get_OSC22M_clock(t,a) elseif u==1 and i==3 then n,h=get_OSC10K_clock(t,a) else s=string.format("PWM%d clock is not available (see "..d.. l..".PWM%d%d_S and CLKSEL2[%d].PWM%d%d_S_E(S2)).
", o,e*2,e*2+1,e+8,e*2,e*2+1) end else if i==0 then n,h=get_XTL12M_clock(t,a) elseif i==1 then n,h=get_XTL32K_clock(t,a) elseif i==2 then n,h=get_HCLK_clock(t,a) elseif i==3 then n,h=get_OSC22M_clock(t,a) else s=string.format("PWM%d clock is not available (see "..d..l..".PWM%d%d_S).
", o,e*2,e*2+1) end end if s==""then if n==0 then s=string.format("PWM%d clock is not available, %s.
",o,h) else local d=m.."_CSR" local i=m.."_PPR" table.insert(a,d) table.insert(a,i) local a=ext.band(ext.rshift(t[d],4*(o-4*r)),7) local a=({2,4,8,16,1,0,0,0})[a+1] local t=ext.band(ext.rshift(t[i],8*(e-2*r)),255) if t==0 then s=string.format("PWM%d counter will be stopped since %s_PPR[%d:%d].CP%d%d = 0
", o,m, 8*(e-2*r)+7, 8*(e-2*r), (e-2*r)*2, (e-2*r)*2+1) elseif a==0 then s=string.format("PWM%d counter clock is not available (see %s_CSR[%d:%d].CSR%d).
", o,m, 4*(o-4*r)+3, 4*(o-4*r), (o-4*r)) else local e=n/(t+1) local t=e/a c=string.format("PWM%d clock frequency: %sHz (Pre-Scaled), from %s.
".. "PWM%d counter frequency: %sHz
", o,val2str(e),h, o,val2str(t) ) end end end else s=string.format("PWM%d clock is not available (see APBCLK[%d].PWM%d%d_EN).
", o,e+20,e*2,e*2+1) end if s~=""then s=""..s.."" d["pin_no_color"]=kBgColor_Error end if c~=""then c="Information
"..c end d["information"]=string.format( "%s
%s
".. "%s%s%s", f, s, get_mfp_regs(t,y,v,p), get_clk_informnation(t,a), c) end function fill_NUC100_TM(n,t,c,a,r,e,d,l) local u=get_chip_info()["series_group"] local h="" local o="" local a={} n["highlight_text"]=r n["normal_color"]=kColor_Invalid n["highlight_color"]=kColor_TM n["pin_bg_color"]=kBgColor_TM n["direction"]=kPinDirection_Unknown n["status"]=kPinStatus_Unknown table.insert(a,"CLK_APBCLK") local i=ext.band(t["CLK_APBCLK"],ext.lshift(4,e)) local s if i~=0 then local i=string.format("TMR%d_TCSR",e) table.insert(a,i) local i=ext.band(t[i],16777216) if i~=0 then h=string.format("Timer%d external counter mode enabled.
",e) else table.insert(a,"CLK_CLKSEL1") s=ext.band(ext.rshift(t["CLK_CLKSEL1"],8+e*4),7) local n local i if s==0 then n,i=get_XTL12M_clock(t,a) elseif s==2 then n,i=get_HCLK_clock(t,a) elseif s==7 then n,i=get_OSC22M_clock(t,a) else if u==3 then if s==1 then n,i=get_XTL32K_clock(t,a) elseif s==3 then h=string.format("Timer%d clock source is from external trigger.
",e) elseif s==5 then n,i=get_OSC10K_clock(t,a) else o=string.format("Timer%d clock source is undefined (see CLKSEL1[%d:%d].TMR%d_S).
", e,8+e*4+2,8+e*4,e) end else if s==1 then n,i=get_XTL32K_clock(t,a) else o=string.format("Timer%d clock source is undefined (see CLKSEL1[%d:%d].TMR%d_S).
", e,8+e*4+2,8+e*4,e) end end end if o==""and h==""then if n~=0 then h=string.format("Timer%d clock frequency: %sHz, from %s
", e,val2str(n),i) else o=string.format("Timer%d clock is not available, %s.
",e,i) end end end else o=string.format("Timer%d clock is disabled (see APBCLK[%d].TMR%d_EN).
",e,(e+2),e) end if o~=""then o=""..o.."" n["pin_no_color"]=kBgColor_Error end if h~=""then h="Information
"..h end n["information"]=string.format( "%s
%s
".. "%s%s%s", r, o, get_mfp_regs(t,c,d,l), get_clk_informnation(t,a), h) end function fill_NUC100_EBI(t,a,h,e,s,d,r) local e="" local o="" local i={} t["highlight_text"]=s t["normal_color"]=kColor_Invalid t["highlight_color"]=kColor_EBI t["pin_bg_color"]=kBgColor_EBI t["direction"]=kPinDirection_PushPullOut t["status"]=kPinStatus_Unknown table.insert(i,"CLK_AHBCLK") local n=ext.band(a["CLK_AHBCLK"],8) if n~=0 then local t local n t,n=get_HCLK_clock(a,i) if t~=0 then table.insert(i,"EBI_EBICON") local o=ext.band(ext.rshift(a["EBI_EBICON"],8),7) local i=t if o<=5 then i=ext.rshift(t,o) end e=e..string.format("EBI MCLK frequency: %sHz, from %s
", val2str(i),n) local o=ext.band(ext.rshift(a["EBI_EBICON"],1),1) local t=ext.band(a["EBI_EBICON"],1) if t~=0 then e=e..string.format("EBI Bank: address/data bus multiplex mode, and data width %d-bit
", (o~=0)and 16 or 8) else e=e..string.format("EBI Bank disabled
") end else o=string.format("EBI clock is not available, %s.
",n) end else o="EBI clock is disabled (see AHBCLK[3].EBI_EN).
" end if o~=""then o=""..o.."" t["pin_no_color"]=kBgColor_Error end if e~=""then e="Information
"..e end t["information"]=string.format( "%s
%s
".. "%s%s%s", s, o, get_mfp_regs(a,h,d,r), get_clk_informnation(a,i), e) end function fill_NUC100_SC(o,e,u,a,r,t,d,l) local s="" local i="" local a={} o["highlight_text"]=r o["normal_color"]=kColor_Invalid o["highlight_color"]=kColor_SC o["pin_bg_color"]=kBgColor_SC o["direction"]=kPinDirection_PushPullOut o["status"]=kPinStatus_Unknown table.insert(a,"CLK_APBCLK1") if ext.band(e["CLK_APBCLK1"],ext.lshift(1,t))~=0 then local h=string.format("SC%d_SC_CTL",t) table.insert(a,h) if ext.band(e[h],1)~=0 then table.insert(a,"CLK_CLKSEL3") local h=ext.band(ext.rshift(e["CLK_CLKSEL3"],t*2),3) local n local o if h==0 then n,o=get_XTL12M_clock(e,a) elseif h==1 then n,o=get_PLL_clock(e,a) elseif h==2 then n,o=get_HCLK_clock(e,a) else n,o=get_OSC22M_clock(e,a) end local e=ext.band(ext.rshift(e["CLK_CLKDIV1"],t*8),255) local e=n/(e+1) if e~=0 then table.insert(a,"CLK_CLKDIV1") s=string.format("SC%d clock frequency: %sHz, from %s.
",t,val2str(e),o) else i=string.format("SC%d clock is not available, ",t)..o..".
" end else i=string.format("SC%d engine disable (see %s[0].SC_CEN).
",t,h) end else i=string.format("SC%d clock is not available (see APBCLK1[%d].SC%d_EN).
",t,t,t) end if i~=""then i=""..i.."" o["pin_no_color"]=kBgColor_Error end if s~=""then s="Information
"..s end o["information"]=string.format("%s
%s
%s%s%s", r, i, get_mfp_regs(e,u,d,l), get_clk_informnation(e,a), s) end function fill_NUC100_Normal(e,i,a,o,t,n,h) local s="" e["highlight_text"]=t e["normal_color"]=kColor_Invalid e["highlight_color"]=kColor_Normal e["pin_bg_color"]=kBgColor_Normal e["direction"]=kPinDirection_Unknown e["status"]=kPinStatus_Unknown s=t.."
" if a==nil or o==nil then e["information"]=string.format( "%s
", t) else e["information"]=string.format( "%s

".. "%s", t, get_mfp_regs(i,a,n,h)) end end