ljj3166 发表于 2021-5-23 23:30

【短时天气预报系统】indoor装置基本外设使用

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">周末撸一贴</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">打板等了差不多一周才到,xLC越来越慢了</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">上个板图</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">裸板正面</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">裸板背面</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong>必要的logo得有</strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">胡乱撸的一板,高手轻喷</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">垂直走线,感觉也挺好</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">最后的焊接图:</span></strong></span></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">其实除了MCU、天线和一些接插件</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">都是在xLC做的SMT</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">看着质量还行吧</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">把eInk屏装配起来</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;">顺道还手撸了一张图</span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">基本上,indoor装置就长这么个熊样了</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">外壳啥的,就不想了</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">还是想想怎么去薅几片涨价十几倍的传感器吧</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">还好RSL10这块芯片没怎么涨价,目前看来比较良心</span></span></strong></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">来看看基础外设的使用</span></span></strong></p>

<p style="text-align:justify"><span style="font-size:24px;"><strong><span style="font-family:等线">1、GPIO</span></strong></span></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">墨水屏使用到了DIO11-DIO15</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">刚开始的时候,怎么都撸不通</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">就连高低电平都出不来</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">纳闷了好久</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">又翻了翻硬件参考手册</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">发现RSL10默认是支持5线JTAG调试接口</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">DIO13、DIO14、DIO15正好是复用的JTAG端口</span></span></strong></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">所以,想使用DIO13、DIO14、DIO15必须要提前有所动作</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">贴个配置</span></span></strong></p>

<pre>
<code class="language-cpp">// This is for DIO14/DIO15
        DIO_JTAG_SW_PAD_CFG-&gt;CM3_JTAG_DATA_EN_ALIAS =                CM3_JTAG_DATA_DISABLED_BITBAND;

        //This is for DIO13
        DIO_JTAG_SW_PAD_CFG-&gt;CM3_JTAG_TRST_EN_ALIAS =
                        CM3_JTAG_TRST_DISABLED_BITBAND;
</code></pre>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">然后就可以愉快地使用DIO13、DIO14、DIO15为基础IO口了</span></span></strong></p>

<p style="text-align:justify"><span style="font-size:26px;"><strong><span style="font-family:等线">2、SPI</span></strong></span></p>

<p style="text-indent: 0cm;"><strong><span style="font-size:16px;"><span style="font-family:等线">常用接口,用于驱动eInk</span></span></strong></p>

<p style="margin-left:24px; text-indent:0cm; text-align:justify">&nbsp;</p>

<pre>
<code class="language-cpp">/* Initialize spi0 driver structure */
        spi0 = &amp;Driver_SPI0;

        /* Initialize spi0, register callback function */
        spi0-&gt;Initialize(SPI0_Master_CallBack);
</code></pre>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">使用RTE配置</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">很方便,但是记得在头文件中配置相关的管脚</span></span></strong></p>

<p style="margin-left:24px; text-indent:0cm; text-align:justify"></p>

<p style="text-align:justify"><span style="font-size:26px;"><strong><span style="font-family:等线">3、uart和printf</span></strong></span></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">uart基操就不说了</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">GCC里面使用printf和MDK中不太一样</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span lang="EN-US"><span style="font-family:等线">eclipse</span></span><span style="font-family:等线">需要重定向</span><span lang="EN-US"><span style="background:#d4d4d4"><span style="font-family:Consolas"><span style="color:black">_write</span></span></span></span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">撸它</span></span></strong></p>

<pre>
<code class="language-cpp">int _write(int fd, char *pBuffer, int size) {

        uart-&gt;Send(pBuffer, strlen(pBuffer));
          /* Wait for transfer to finish */
          while(uart-&gt;GetStatus().tx_busy);
          memset(pBuffer, '\0', size);
        return size;
}
</code></pre>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">实际使用printf的时候,总是会连续打印上次残留的字符</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">每次发送完毕把pBuffer用空字符塞一下,解决</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">效率估计不高</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">但是还有个问题,这个printf不支持浮点数的打印</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">不知道咋回事,可能是编译优化造成的吧</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">真囧,先不管了</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:26px;">4、FLASH操作</span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">计划中,需要保存一个outdoor设备的mac地址</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">所以需要进行片上flash的操作</span></span></strong></p>

<p><strong><span style="font-size:16px;"><span style="font-family:等线">直接贴代码</span></span></strong></p>

<p></p>

<p><strong><span style="font-size:16px;">非序列写入</span></strong></p>

<p><strong><span style="font-size:16px;"><span style="font-family:等线">一个很奇怪的问题</span></span></strong></p>

<p><strong><span style="font-size:16px;"><span style="font-family:等线">红框中的寄存器操作代码需要执行2次</span></span></strong></p>

<p><strong><span style="font-size:16px;"><span style="font-family:等线">否则写入FLASH会失败</span></span></strong></p>

<p><strong><span style="font-size:16px;"><span style="font-family:等线">调试看了看,返回的code是FLASH操作<i><span lang="EN-US"><span style="background:#d4d4d4"><span style="font-family:Consolas"><span style="color:#0000c0">FLASH_ERR_WRITE_NOT_ENABLED</span></span></span></span></i>写入未使能</span></span></strong></p>

<p><strong><span style="font-size:16px;"><span style="font-family:等线">执行2次就没问题,真奇怪,苟着用吧</span></span></strong></p>

<p><span style="font-size:26px;"><strong>5、ADC</strong></span></p>

<p><strong><span style="font-size:16px;"><span style="font-family:等线">很奇怪,CMSISDriver中没有提供ADC的驱动</span></span></strong></p>

<p></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">只好手撸一个</span></span></strong></p>

<pre>
<code class="language-cpp">void ADCGo(void) {
        ADCInit();
        /* Enable interrupts */
        NVIC_EnableIRQ(ADC_BATMON_IRQn);
}
void ADCStop(void) {
        Sys_ADC_Set_Config(ADC_DISABLE);
        NVIC_DisableIRQ(ADC_BATMON_IRQn);
}
void ADCInit(void) {
        /* Set the ADC configuration */
        Sys_ADC_Set_Config(ADC_VBAT_DIV2_NORMAL | ADC_NORMAL | ADC_PRESCALE_1280H);

        /* Set the battery monitor interrupt configuration */
        Sys_ADC_Set_BATMONIntConfig(INT_EBL_ADC | ADC_INT_CH0);

        /* Configure ADC_CHANNEL input selection to ADC_NEG_INPUT_DIO0 */
        Sys_ADC_InputSelectConfig(ADC_INT_CH0,
                        ADC_POS_INPUT_DIO0 | ADC_NEG_INPUT_GND);
}
</code></pre>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">参照例程撸过来的,通道0</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">能用</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">调试发现配置成15位的ADC,返回值0-16383</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">用的次数也不多,接着苟</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">其他GPIO输入检测之类懒得贴了</span></span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;"><span style="font-family:等线">上个运行动次打次图</span></span></strong></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"><strong><span style="font-size:16px;">发帖的格式</span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;">觉得好凌乱</span></strong></p>

<p style="text-align:justify"><strong><span style="font-size:16px;">调不好,就这吧</span></strong></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-size:20px;"><strong><span style="font-family:等线">以上</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:20px;"><strong><span style="font-family:等线">回见</span></strong></span></p>

soso 发表于 2021-5-24 10:24

<p>感谢楼主分享,期待后续,哈哈</p>

dql2016 发表于 2021-5-24 12:04

<p>&nbsp;</p>

<p>不错</p>

7905 发表于 2021-5-24 13:53

<p>兵贵神速啊,点个赞!</p>

hehung 发表于 2021-5-25 21:45

<p>很棒</p>

lehuijie 发表于 2021-5-30 22:29

<p>撸姐姐你怎么还有芯片</p>

7905 发表于 2021-6-7 20:42

lehuijie 发表于 2021-5-30 22:29
撸姐姐你怎么还有芯片

<p>把名字翻成汉语谐音了<img height="28" src="https://bbs.eeworld.com.cn/static/editor/plugins/hkemoji/sticker/facebook/smiling-face-with-open-mouth-and-cold-sweat_1f605.png" width="28" />,芯片可能从赠板上拆下来的</p>

ljj3166 发表于 2021-6-8 18:42

lehuijie 发表于 2021-5-30 22:29
撸姐姐你怎么还有芯片

<p>渣渣乐,有钱真的可以为所欲为</p>

w494143467 发表于 2021-6-9 16:44

<p>666,这个效果真不错!</p>

freebsder 发表于 2021-6-9 17:45

<p>你为啥要打两个颜色的板?薅羊毛的?</p>

ljj3166 发表于 2021-6-9 22:41

freebsder 发表于 2021-6-9 17:45
你为啥要打两个颜色的板?薅羊毛的?

<p>x立创杂色不收费,下次打个屎色骚一下</p>
页: [1]
查看完整版本: 【短时天气预报系统】indoor装置基本外设使用