@@ -47,6 +47,7 @@ void Widget::load_data_to_dir()
4747 write_data_to_kconfig ();
4848 write_data_to_maincpp ();
4949 write_data_to_mainscons ();
50+ write_data_to_readme ();
5051 QMessageBox::StandardButton result = QMessageBox::question ( this ," 成功" ," 代码生成成功,是否打开资源所在目录?" );
5152
5253 if (result == QMessageBox::No)
@@ -95,6 +96,9 @@ void Widget::write_data_to_cfile()
9596 if (pmap->io_name == ui->s3box ->currentText ())
9697 pmap->io_notes = " /* Serial3-" + pmap->pin_func +" */" ;
9798
99+ if (pmap->io_name == " usb" )
100+ pmap->io_notes = " /* SerialUSB-" + pmap->pin_func +" */" ;
101+
98102 if (pmap->pin_func == " INTVOL" )
99103 pmap->io_notes = " /* ADC, On-Chip: internal reference voltage, ADC_CHANNEL_VREFINT */" ;
100104
@@ -526,3 +530,92 @@ void Widget::write_data_to_mainscons()
526530 out << " Return('group')\n " ;
527531}
528532
533+ void Widget::write_data_to_readme ()
534+ {
535+ QString index,ardpin,rttpin,vol53,note;
536+ QFile readmefile (rttBspdirpath+" /applications/arduino_pinout/README.md" );
537+ if (!readmefile.open (QIODevice::WriteOnly | QIODevice::Text|QFile::Truncate))
538+ {
539+ return ;
540+ }
541+
542+ QTextStream out (&readmefile);
543+ out.setCodec (" UTF-8" );
544+
545+ out << tr (" # xxx 开发板的Arduino生态兼容说明\n\n " );
546+ out << tr (" ## 1 RTduino - RT-Thread的Arduino生态兼容层\n\n " );
547+ out << tr (" xxx 开发板已经完整适配了[RTduino软件包](https://github.com/RTduino/RTduino),即RT-Thread的Arduino" \
548+ " 生态兼容层。用户可以按照Arduino的编程习惯来操作该BSP,并且可以使用大量Arduino社区丰富的库,是" \
549+ " 对RT-Thread生态的极大增强。更多信息,请参见[RTduino软件包说明文档](https://github.com/RTduino/RTduino)。\n\n " );
550+ out << tr (" ### 1.1 如何开启针对本BSP的Arduino生态兼容层\n\n " );
551+ out << tr (" Env 工具下敲入 menuconfig 命令,或者 RT-Thread Studio IDE 下选择 RT-Thread Settings:\n\n " );
552+ out << tr (" ```Kconfig\n " );
553+ out << tr (" Hardware Drivers Config --->\n " );
554+ out << tr (" Onboard Peripheral Drivers --->\n " );
555+ out << tr (" [*] Compatible with Arduino Ecosystem (RTduino)\n " );
556+ out << tr (" ```\n\n " );
557+ out << tr (" ## 2 Arduino引脚排布\n\n " );
558+ out << tr (" 更多引脚布局相关信息参见 [pins_arduino.c](pins_arduino.c) 和 [pins_arduino.h](pins_arduino.h)。\n\n " );
559+ out << tr (" \n " );
560+ out << tr (" | Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |\n " );
561+ out << tr (" | ------------------- | --------- | ---- | ------------------------------------------------------------------------- |\n " );
562+ foreach (auto pmap , pinmaplist.Allpinlist )
563+ {
564+ index = QString::number (pinmaplist.Allpinlist .indexOf (pmap));
565+ ardpin = pmap->arduino_pin ;
566+ if (pmap->rtthread_pin == " RT_NULL" )
567+ rttpin = " --" ;
568+ else
569+ rttpin = " P" + pmap->rtthread_pin .mid (8 ,1 )+pmap->rtthread_pin .mid (10 ,pmap->rtthread_pin .size ()-11 );
570+
571+ if (pmap->pin_func == " INTVOL" )
572+ vol53 = " " ;
573+ else if (pmap->pin_func == " INTTEP" )
574+ vol53 = " " ;
575+ else
576+ vol53 = " 是/否" ;
577+
578+ if (pmap->io_name .mid (0 ,3 ) == " pwm" )
579+ note = pmap->io_name .toUpper ()+" -CH" +QString::number (pmap->io_channel .toInt ())+" ,默认被RT-Thread的PWM设备框架" +pmap->io_name +" 接管" ;
580+ else if (pmap->io_name .mid (0 ,3 ) == " adc" )
581+ {
582+ if (pmap->pin_func == " INTVOL" )
583+ note = " 芯片内部参考电压 ADC,默认被RT-Thread的ADC设备框架adc1接管" ;
584+ else if (pmap->pin_func == " INTTEP" )
585+ note = " 芯片内部温度 ADC,默认被RT-Thread的ADC设备框架adc1接管" ;
586+ else
587+ note = pmap->io_name .toUpper ()+" -CH" +QString::number (pmap->io_channel .toInt ())+" ,默认被RT-Thread的ADC设备框架" +pmap->io_name +" 接管" ;
588+ }
589+ else if (pmap->io_name .mid (0 ,3 ) == " dac" )
590+ note = pmap->io_name .toUpper ()+" -CH" +QString::number (pmap->io_channel .toInt ())+" ,默认被RT-Thread的DAC设备框架" +pmap->io_name +" 接管" ;
591+ else if (pmap->io_name .mid (0 ,3 ) == " i2c" )
592+ note = pmap->io_name .toUpper ()+" -" +pmap->pin_func +" ,默认被RT-Thread的I2C设备框架" +pmap->io_name +" 接管" ;
593+ else if (pmap->io_name .mid (0 ,3 ) == " spi" )
594+ note = pmap->io_name .toUpper ()+" -" +pmap->pin_func +" ,默认被RT-Thread的SPI设备框架" +pmap->io_name +" 接管" ;
595+ else if (pmap->io_name .mid (0 ,3 ) == " usb" )
596+ note = pmap->io_name .toUpper ()+" -" +pmap->pin_func +" ,默认被 [TinyUSB软件包](https://github.com/RT-Thread-packages/tinyusb) 接管" ;
597+ else if (pmap->io_name .mid (0 ,4 ) == " uart" )
598+ {
599+ if (pmap->io_name == ui->s2box ->currentText ())
600+ note = " Serial2-" +pmap->pin_func +" ,默认被RT-Thread的UART设备框架" +pmap->io_name +" 接管" ;
601+ else if (pmap->io_name == ui->s3box ->currentText ())
602+ note = " Serial3-" +pmap->pin_func +" ,默认被RT-Thread的UART设备框架" +pmap->io_name +" 接管" ;
603+ else
604+ note = " Serial-" +pmap->pin_func +" ,默认被RT-Thread的UART设备框架" +pmap->io_name +" 接管" ;
605+ }
606+ else if (pmap->arduino_pin == ui->spissbox ->currentText ())
607+ note = " SPI片选默认引脚" ;
608+ else if (pmap->arduino_pin == ui->ledbox ->currentText ())
609+ note = " 板载用户LED" ;
610+ else
611+ note = " " ;
612+ out << " | " +index+" (" +ardpin+ " ) | " +rttpin+ " | " +vol53+ " | " +note+ " |\n " ;
613+ }
614+ out << tr (" \n " );
615+ out << tr (" > 注意:\n " );
616+ out << tr (" >\n " );
617+ out << tr (" > 1. xxxxxxxxx\n " );
618+ out << tr (" > 2. xxxxxxxxx\n " );
619+ }
620+
621+
0 commit comments