Abubuwan da aka bayar na Zigbee EZSP UART

Marubuci:TorchIoTBootCamp
Yanar Gizo: https://zhuanlan.zhihu.com/p/339700391
Daga: Quora

1. Gabatarwa

Silicon Labs ya ba da mafita + NCP mai watsa shiri don ƙirar ƙofar Zigbee. A cikin wannan gine-gine, mai watsa shiri na iya sadarwa tare da NCP ta hanyar UART ko SPI. Mafi yawanci, ana amfani da UART kamar yadda ya fi SPI sauƙi.

Silicon Labs kuma ya ba da samfurin samfurin don shirin shirin, wanda shine samfurinZ3GatewayHost. Samfurin yana gudana akan tsarin kamar Unix. Wasu abokan ciniki na iya son samfurin rundunar wanda zai iya gudana akan RTOS, amma rashin alheri, babu samfurin tushen tushen RTOS na yanzu. Masu amfani suna buƙatar haɓaka shirin rundunansu bisa RTOS.

Yana da mahimmanci a fahimci ka'idar ƙofa ta UART kafin haɓaka shirin mai masaukin baki na musamman. Domin duka UART tushen NCP da SPI tushen NCP, mai watsa shiri yana amfani da ka'idar EZSP don sadarwa tare da NCP.Farashin EZSPgajere ne donEmberZnet Serial Protocol, kuma an ayyana shi a cikiFarashin UG100. Don NCP na tushen UART, ana aiwatar da ƙaƙƙarfan ƙa'idar Layer don ɗaukar bayanan EZSP da dogaro akan UART, wannan shineASHyarjejeniya, gajere donAsynchronous Serial Mai watsa shiri. Don ƙarin bayani game da ASH, da fatan za a dubaFarashin UG101kumaFarashin UG115.

Ana iya misalta alakar dake tsakanin EZSP da ASH ta wannan zane mai zuwa:

1

Za a iya misalta tsarin bayanai na EZSP da ka'idar ASH ta wannan zane mai zuwa:

2

A cikin wannan shafi, za mu gabatar da tsarin tsara bayanan UART da wasu maɓalli masu mahimmanci waɗanda ake yawan amfani da su a ƙofar Zigbee.

2. Tsarin tsari

Za'a iya misalta tsarin ƙirar gaba ɗaya ta ginshiƙi mai zuwa:

3

A cikin wannan ginshiƙi, bayanan yana nufin firam ɗin EZSP. Gabaɗaya, hanyoyin ƙirar ƙira sune: |A'a|Mataki|Reference|

|::-|:-|:-|

|1|Cika Tsarin EZSP|UG100|

|2|Bayyana Bayanan | Sashe na 4.3 na UG101|

|3|Ƙara Ƙarfafa Byte|Chap2 da Chap3 na UG101|

|4|Kididdige CRC|Sashe na 2.3 na UG101|

|5|Kayan Byte | Sashe na 4.2 na UG101|

|6|Ƙara Tutar Ƙarshen | Sashe na 2.4 na UG101|

2.1. Cika Tsarin EZSP

An kwatanta tsarin firam ɗin EZSP a Babi na 3 na UG100.

4

Kula cewa wannan tsari na iya canzawa lokacin da SDK ya inganta. Lokacin da tsarin ya canza, za mu ba shi sabuwar lambar sigar. Sabuwar lambar sigar EZSP ita ce 8 lokacin da aka rubuta wannan labarin (EmberZnet 6.8).

Kamar yadda tsarin firam ɗin EZSP na iya bambanta tsakanin nau'ikan daban-daban, akwai buƙatu na wajibi cewa mai watsa shiri da NCPDOLEYi aiki tare da nau'in EZSP iri ɗaya. In ba haka ba, ba za su iya sadarwa kamar yadda ake tsammani ba.

Don cimma hakan, umarni na farko tsakanin mai watsa shiri da NCP dole ne ya zama umarnin sigar. A wasu kalmomi, dole ne mai watsa shiri ya dawo da nau'in EZSP na NCP kafin kowace hanyar sadarwa. Idan nau'in EZSP ya bambanta da nau'in EZSP na bangaren mai watsa shiri, dole ne a soke sadarwar.

Babban abin da ake buƙata a bayan wannan shine cewa tsarin umarnin sigar zai iyaKADA KA CANZA. Tsarin umarnin sigar EZSP yana kama da ƙasa:

5

Ana iya samun bayanin filin siga da tsarin sigar amsa a Babi na 4 na UG100. Filin siga shine sigar EZSP na shirin mai masaukin baki. Lokacin da aka rubuta wannan labarin, 8 ne.
7
Bayani:TorchIoTBootCamp
Yanar Gizo: https://zhuanlan.zhihu.com/p/339700391
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

2.2. Bazuwar Bayanai

An bayyana cikakken tsarin bazuwar a cikin sashe na 4.3 na UG101. Dukkan firam ɗin EZSP za a bazu. Bazuwar shine keɓance-KO firam ɗin EZSP da jerin bazuwar.

A ƙasa akwai algorithm na samar da jeri-bazuwar.

  • Rand0 = 0×42
  • idan bit 0 na randi shine 0, randi+1 = randi >> 1
  • idan bit 0 na randi shine 1, randi+1 = (randi >> 1) ^ 0xB8

2.3. Ƙara Ƙarfafa Byte

Ƙarfin sarrafawa bayanan byte ɗaya ne, kuma yakamata a ƙara shi zuwa kan firam ɗin. An kwatanta tsarin tare da teburin da ke ƙasa:

6

Gabaɗaya, akwai nau'ikan bytes masu sarrafawa guda 6. Ana amfani da ukun farko don firam ɗin gama gari tare da bayanan EZSP, gami da DATA, ACK da NAK. Ana amfani da uku na ƙarshe ba tare da bayanan EZSP na gama gari ba, gami da RST, RSTACK da ERROR.

An kwatanta tsarin RST, RSTACK da ERROR a cikin sashe na 3.1 zuwa 3.3.

2.4. Yi lissafin CRC

Ana ƙididdige CRC 16-bit akan bytes daga byte mai sarrafawa har zuwa ƙarshen bayanan. Daidaitaccen CRCCCITT (g(x) = x16 + x12 + x5 + 1) an fara shi zuwa 0xFFFF. Mafi mahimmancin byte yana gaba da mafi ƙarancin mahimmancin byte (yanayin babban-endian).

2.5. Kayayyakin Byte

Kamar yadda aka bayyana a sashe na 4.2 na UG101, akwai wasu kimar byte da aka keɓance da aka yi amfani da su don manufa ta musamman. Ana iya samun waɗannan ƙimar a cikin tebur mai zuwa:

7

Lokacin da waɗannan ƙimar suka bayyana a cikin firam, za a yi jiyya ta musamman ga bayanan. - Saka 0x7D ta hanyar tserewa a gaban byte da aka tanada - Mai da bit5 na waccan byte da aka tanada.

A ƙasa akwai wasu misalan wannan algorithm:

8

2.6. Ƙara Tutar Ƙarshen

Mataki na ƙarshe shine ƙara alamar ƙarshen 0x7E zuwa ƙarshen firam. Bayan haka, ana iya aika bayanan zuwa tashar tashar UART.

3. Tsare-tsare-tsare

Lokacin da aka karɓi bayanai daga UART, kawai muna buƙatar yin matakan baya don yanke shi.

4. Magana


Lokacin aikawa: Fabrairu-08-2022
WhatsApp Online Chat!