Umbhali:TorchIoTBootCamp
Isixhumanisi: https://zhuanlan.zhihu.com/p/339700391
Kusuka ku-:Quora
1. Isingeniso
I-Silicon Labs inikeze isisombululo se-host+NCP se-Zigbee gateway design. Kulesi sakhiwo, umsingathi angakwazi ukuxhumana ne-NCP ngesixhumi esibonakalayo se-UART noma se-SPI. Ngokuvamile, i-UART isetshenziswa njengoba ilula kakhulu kune-SPI.
I-Silicon Labs nayo inikeze iphrojekthi eyisampula yohlelo lomsingathi, okuyisampulaI-Z3GatewayHost
. Isampula isebenza kusistimu efana ne-Unix. Amanye amakhasimende angase afune isampula yomsingathi engasebenza ku-RTOS, kodwa ngeshwa, alikho isampula elisuselwe ku-RTOS lokubamba iqhaza okwamanje. Abasebenzisi badinga ukuthuthukisa uhlelo lwabo lokusingatha olususelwe ku-RTOS.
Kubalulekile ukuqonda iphrothokholi yesango le-UART ngaphambi kokwenza uhlelo lokusingatha ngendlela oyifisayo. Kuzo zombili i-NCP esekelwe ku-UART kanye ne-SPI esekelwe ku-NCP, umsingathi usebenzisa umthetho olandelwayo we-EZSP ukuze axhumane ne-NCP.EZSPkufushaneI-EmberZnet Serial Protocol, futhi ichazwa kuUG100. Ku-NCP esekwe ku-UART, kusetshenziswa umthetho olandelwayo wesendlalelo esiphansi ukuze uphathe idatha ye-EZSP ngokuthembekile nge-UART, lokhoUMLOSHIiphrothokholi, emfushane yokuthiI-Asynchronous Serial Host. Ukuze uthole imininingwane eyengeziwe nge-ASH, sicela ubhekeUG101futhiUG115.
Ubudlelwano phakathi kwe-EZSP ne-ASH bungaboniswa yilo mdwebo olandelayo:
Ifomethi yedatha ye-EZSP kanye nephrothokholi ye-ASH ingaboniswa yilo mdwebo olandelayo:
Kuleli khasi, sizokwethula inqubo yokwenza uzimele idatha ye-UART kanye namanye amafreyimu angukhiye asetshenziswa njalo kusango le-Zigbee.
2. Ukwenza uhlaka
Inqubo yokufaka uzimele evamile ingaboniswa ngeshadi elilandelayo:
Kuleli shadi, idatha isho uhlaka lwe-EZSP. Ngokuvamile, izinqubo zohlaka yilezi: |Cha|Isinyathelo|Inkomba|
|:-|:-|:-|
|1|Gcwalisa Uhlaka lwe-EZSP|UG100|
|2|Data Randomization|Isigaba 4.3 se-UG101|
|3|Engeza i-Control Byte|Chap2 kanye ne-Chap3 ye-UG101|
|4|Bala i-CRC|Isigaba 2.3 se-UG101|
|5|Byte Stuffing|Isigaba 4.2 se-UG101|
|6|Engeza Ifulegi Lokugcina|Isigaba 2.4 se-UG101|
2.1. Gcwalisa Uhlaka lwe-EZSP
Ifomethi yohlaka lwe-EZSP ikhonjisiwe ku-Chap 3 of UG100.
Qaphela ukuthi le fomethi ingase ishintshe lapho i-SDK ithuthuka. Uma ifomethi ishintsha, sizoyinikeza inombolo yenguqulo entsha. Inombolo yakamuva yenguqulo ye-EZSP ithi 8 lapho kubhalwa lesi sihloko (EmberZnet 6.8).
Njengoba ifomethi yohlaka lwe-EZSP ingase yehluke phakathi kwezinguqulo ezihlukene, kunemfuneko eyisibopho yokuthi umsingathi kanye ne-NCPKUMELEsebenza ngenguqulo ye-EZSP efanayo. Uma kungenjalo, abakwazi ukuxhumana ngendlela elindelekile.
Ukufeza lokho, umyalo wokuqala phakathi komsingathi ne-NCP kufanele kube umyalo wenguqulo. Ngamanye amazwi, umsingathi kufanele abuyise inguqulo ye-EZSP ye-NCP ngaphambi kwanoma yikuphi okunye ukuxhumana. Uma inguqulo ye-EZSP ihlukile nenguqulo ye-EZSP yohlangothi lomsingathi, ukuxhumana kufanele kunqanyulwe.
Imfuneko engacacile ngemuva kwalokhu ukuthi ifomethi yomyalelo wenguqulo canUNGAZE USHINTSHE. Ifomethi yomyalo wenguqulo ye-EZSP inje ngezansi:
Umthombo: https://zhuanlan.zhihu.com/p/339700391
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处.
2.2. Ukwenziwa Kwedatha
Inqubo enemininingwane yokwenza okungahleliwe ichazwe esigabeni 4.3 se-UG101. Lonke uhlaka lwe-EZSP luzokwenziwa ngokungahleliwe. I-randomization iwuhlaka-NOMA uzimele we-EZSP kanye nokulandelana okungahleliwe okungahleliwe.
Ngezansi i-algorithm yokukhiqiza ukulandelana okungahleliwe okungahleliwe.
- irandi0 = 0×42
- uma ibhithi elingu-0 lika-randi lingu-0, i-randi+1 = i-randi >> 1
- uma ibhithi elingu-0 lika-randi lingu-1, i-randi+1 = (randi >> 1) ^ 0xB8
2.3. Engeza i-Control Byte
Ibhayithi yokulawula iyidatha yebhayithi eyodwa, futhi kufanele yengezwe ekhanda lohlaka. Ifomethi ikhonjiswe ngethebula elingezansi:
Sekukonke, kunezinhlobo eziyisi-6 zamabhayithi okulawula. Amathathu okuqala asetshenziselwa ozimele abavamile abanedatha ye-EZSP, ehlanganisa i-DATA, ACK ne-NAK. Ezintathu zokugcina zisetshenziswa ngaphandle kwedatha evamile ye-EZSP, ehlanganisa i-RST, i-RSTACK ne-ERROR.
Ifomethi ye-RST, RSTACK ne-ERROR ichazwe esigabeni 3.1 ukuya ku-3.3.
2.4. Bala i-CRC
I-CRC engu-16-bit ibalwa ngamabhayithi kusukela kubhayithi yokulawula kuze kube sekupheleni kwedatha. I-CRCCCITT evamile (g(x) = x16 + x12 + x5 + 1) iqaliswa ukuze ithi 0xFFFF. Ibhayithi ebaluleke kakhulu yandulela ibhayithi ebaluleke kakhulu (imodi ye-indian enkulu).
2.5. I-Byte Stuffing
Njengoba kuchazwe esigabeni 4.2 se-UG101, kukhona amanani ebhayithi agciniwe asetshenziselwa izinjongo ezikhethekile. Lawa manani angatholakala kuthebula elilandelayo:
Uma la manani evela kuhlaka, ukuphathwa okukhethekile kuzokwenziwa kudatha. - Faka ibhayithi yokuphunyuka engu-0x7D ngaphambi kwebhayithi ebekiwe - Buyisela emuva i-bit5 yaleyo byte egodliwe
Ngezansi ezinye izibonelo zale algorithm:
2.6. Engeza Ifulegi Lokugcina
Isinyathelo sokugcina siwukwengeza ifulegi lokugcina elithi 0x7E ekupheleni kohlaka. Ngemva kwalokho, idatha ingathunyelwa echwebeni le-UART.
3. Inqubo yokususa uzimele
Uma idatha itholwa ku-UART, sidinga nje ukwenza izinyathelo ezihlehlayo ukuze siyiqophe.
4. Izikhombo
Isikhathi sokuthumela: Feb-08-2022