AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
network.h
1 
21 #ifndef _AVRIO_WUSB_NETWORK_H_
22 #define _AVRIO_WUSB_NETWORK_H_
23 
24 #include <avrio/task.h>
25 #include <avrio/state.h>
26 #include <avrio/wusb/net/device/device.h>
27 #include <avrio/wusb/net/packet.h>
28 
29 __BEGIN_C_DECLS
30 /* ========================================================================== */
40 /* constants ================================================================ */
41 
45 #define WNET_MAJOR 1
46 
50 #define WNET_MINOR 0
51 
55 #define WNET_VERSION "1.0"
56 
57 /* == <API> == public application interface ========class WusbNetwork======= */
61 #define WNET_BIND_PNCODE 0
62 
66 #define WNET_BIND_CHANNEL 0
67 
71 #define WNET_INVALID_DEVICEID 0xFFFF
72 
79 typedef enum {
80 
82  WNET_TIMEOUT = -1,
84  WNET_LAST_ERROR = WNET_CORRUPTED_PACKET_ERROR
86 
99 typedef enum {
100 
101  /* Etat */
104  /* Contrôle */
108 
113 typedef struct xWNetConfig {
114 
115  uint8_t ucChannel;
116  uint8_t ucPnCode;
117  uint8_t ucChecksumSeed;
118  uint8_t ucCrcSeed;
119  uint8_t ucStatus;
120 } xWNetConfig;
121 
122 #if defined(__DOXYGEN__)
123 
134 void vWNetInit(eWDevDataRate eDataRate);
135 
139 inline const xWNetConfig * pxWNetCurrentConfig(void);
140 
144 void vWNetSetConfig(const xWNetConfig * pxConfig);
145 
149 void vWNetSaveConfigToEEPROM(void);
150 
166 inline void vWNetTxPktSend(void);
167 
173 void vWNetTxPktAddTrailer (void);
174 
178 void vWNetTxPktNew (uint8_t ucPacketType);
179 
183 inline void vWNetTxPktSetType (uint8_t ucPacketType);
184 
188 inline void vWNetTxPktSetHeader (uint8_t ucHeader);
189 
193 inline void vWNetTxPktSetFlag (uint8_t ucIndex, bool ucValue);
194 
198 inline void vWNetTxPktToggleFlag (uint8_t ucIndex);
199 
203 inline void vWNetTxPktSetAllFlags (uint8_t ucFlags);
204 
209 void vWNetTxPktAddDeviceId (uint16_t usDeviceId);
210 
214 inline void vWNetTxPktAddByte (uint8_t ucByte);
215 
219 inline void vWNetTxPktAddWord (uint16_t usWord);
220 
224 inline void vWNetTxPktAddBytes (const uint8_t * pucBytes, uint8_t ucLength);
225 
229 inline void vWNetTxPktAddBytes_P (const uint8_t * pucBytes, uint8_t ucLength);
230 
235 inline void vWNetTxPktAddStr (const char * pcStr);
236 
241 inline void vWNetTxPktAddStr_P (const char * pcStr);
242 
246 inline xWusbPacket * pxWNetTxPacket (void);
247 
265 eWNetErrorCode eWNetRxPktWait(int16_t iTimeoutMs);
266 
272 inline uint8_t ucWNetAckTimeout (void);
273 
279 inline uint8_t ucWNetBindTimeout (void);
280 
286 inline uint8_t ucWNetPingTimeout (void);
287 
291 inline uint8_t ucWNetRxPktType (void);
292 
296 inline uint8_t ucWNetRxPktHeader (void);
297 
301 inline bool xWNetRxPktFlag (uint8_t ucIndex);
302 
307 inline uint8_t ucWNetRxPktByte (uint8_t ucOffset);
308 
312 inline uint16_t usWNetRxPktWord (uint8_t ucOffset);
313 
317 inline uint32_t ulWNetRxPktDword (uint8_t ucOffset);
318 
322 inline uint8_t * pucWNetRxPktBytes (uint8_t ucOffset);
323 
330 uint16_t usWNetRxPktDeviceId (void);
331 
336 inline uint8_t * pucWNetRxPktDataPayload (void);
337 
342 inline uint8_t ucWNetRxPktDataPayloadLength (void);
343 
347 inline xWusbPacket * pxWNetRxPacket (void);
348 
359 inline uint8_t ucWNetChannel(void);
360 
366 bool xWNetSetChannel(uint8_t ucIndex);
367 
371 void vWNetGoToNextChannel(void);
372 
376 inline uint8_t ucWNetNumberOfChannelsUsed (void);
377 
381 inline uint8_t ucWNetNumberOfSubsets (void);
382 
386 inline uint8_t ucWNetPnCode(void);
387 
393 bool xWNetSetPnCode(uint8_t ucValue);
394 
398 uint8_t ucWNetNumberOfPnCodes (void);
399 
403 inline uint8_t ucWNetChecksumSeed(void);
404 
408 inline void vWNetSetChecksumSeed(uint8_t ucValue);
409 
413 inline uint8_t ucWNetCrcSeed(void);
414 
418 inline void vWNetSetCrcSeed(uint8_t ucValue);
419 
423 inline bool xWNetStatus (eWNetStatusCode eFlag);
424 
428 void vWNetSetStatus (eWNetStatusCode eFlag, bool ucValue);
429 
434 
438 inline bool xWNetSingleByteDeviceId (void);
439 
443 inline void vWNetSetSingleByteDeviceId (bool xEnable);
444 
453 inline eWNetErrorCode eWNetError(void);
454 
458 inline void vWNetWaitIdle (void);
459 
465 uint8_t ucWNetRand (void);
466 
467 /* == <API-END> == public application interface ====class WusbNetwork======= */
473 #else /* __DOXYGEN__ defined */
474 # include "wusb-config.h"
475 
476 /* constants ================================================================ */
477 /*---- Channel configuration table -------------------------------------------*/
478 #if WUSB_CONFIG_NETWORK_CHANNEL_CONFIG == 1
479  #define WNET_NUM_OF_SUBSETS 6
480  #define WNET_NUM_OF_CH_PER_SUBSET 13
481  #define WNET_NUM_OF_CH_USED 78
482 #elif WUSB_CONFIG_NETWORK_CHANNEL_CONFIG == 2
483  #define WNET_NUM_OF_SUBSETS 7
484  #define WNET_NUM_OF_CH_PER_SUBSET 11
485  #define WNET_NUM_OF_CH_USED 77
486 #elif WUSB_CONFIG_NETWORK_CHANNEL_CONFIG == 3
487  #define WNET_NUM_OF_SUBSETS 8
488  #define WNET_NUM_OF_CH_PER_SUBSET 9
489  #define WNET_NUM_OF_CH_USED 72
490 #elif WUSB_CONFIG_NETWORK_CHANNEL_CONFIG == 4
491  #define WNET_NUM_OF_SUBSETS 9
492  #define WNET_NUM_OF_CH_PER_SUBSET 8
493  #define WNET_NUM_OF_CH_USED 72
494 #elif WUSB_CONFIG_NETWORK_CHANNEL_CONFIG == 5
495  #define WNET_NUM_OF_SUBSETS 10
496  #define WNET_NUM_OF_CH_PER_SUBSET 7
497  #define WNET_NUM_OF_CH_USED 70
498 #elif WUSB_CONFIG_NETWORK_CHANNEL_CONFIG == 6
499  #define WNET_NUM_OF_SUBSETS 11
500  #define WNET_NUM_OF_CH_PER_SUBSET 7
501  #define WNET_NUM_OF_CH_USED 77
502 #elif WUSB_CONFIG_NETWORK_CHANNEL_CONFIG == 7
503  #define WNET_NUM_OF_SUBSETS 12
504  #define WNET_NUM_OF_CH_PER_SUBSET 6
505  #define WNET_NUM_OF_CH_USED 72
506 #elif WUSB_CONFIG_NETWORK_CHANNEL_CONFIG == 8
507  #define WNET_NUM_OF_SUBSETS 13
508  #define WNET_NUM_OF_CH_PER_SUBSET 6
509  #define WNET_NUM_OF_CH_USED 78
510 #else
511  #error Unsupported CHANNEL_CONFIG value
512 #endif
513 
514 /* structures =============================================================== */
515 typedef struct WusbNetwork {
516 
517  xWusbPacket pxRxPacket;
518  xWusbPacket pxRxValid;
519  xWusbPacket pxTxPacket;
520  uint16_t usCorruptError;
521  xTaskHandle xTimeoutTask;
522  xState xRxStatus;
523  xState xError;
524  xWNetConfig xConfig;
525 } WusbNetwork;
526 
527 /* internal public functions ================================================ */
528 void vWNetInit(eWDevDataRate eDataRate);
529 void vWNetSetConfig(const xWNetConfig * pxConfig);
530 void vWNetSaveConfigToEEPROM(void);
531 bool xWNetSetChannel(uint8_t ucValue);
532 void vWNetGoToNextChannel(void);
533 bool xWNetSetPnCode(uint8_t ucValue);
534 void vWNetTxPktNew (uint8_t ucType);
535 void vWNetTxPktAddDeviceId (uint16_t usDeviceId);
536 void vWNetTxPktAddTrailer (void);
537 eWNetErrorCode eWNetRxPktWait(int16_t iTimeoutMs);
538 uint16_t usWNetRxPktDeviceId (void);
539 uint8_t ucWNetRand (void);
540 uint8_t ucWNetNumberOfPnCodes (void);
541 
542 /* public variables ========================================================= */
543 extern WusbNetwork dNet;
544 
545 /* inline public functions ================================================== */
546 // -----------------------------------------------------------------------------
547 __STATIC_ALWAYS_INLINE (void
548  vWNetTxPktSend(void)) {
549 
550  vWDevTransmit (pucWPktRaw (&dNet.pxTxPacket), xWPktLength (&dNet.pxTxPacket));
551 }
552 
553 // -----------------------------------------------------------------------------
554 __STATIC_ALWAYS_INLINE (uint8_t
555  ucWNetAckTimeout (void)) {
556 
557  return (WUSB_CONFIG_NETWORK_DEFAULT_TIMEOUT_ACK * (3-eWDevGetDataRate()));
558 }
559 
560 // -----------------------------------------------------------------------------
561 __STATIC_ALWAYS_INLINE (uint8_t
562  ucWNetBindTimeout (void)) {
563 
564  return (WUSB_CONFIG_NETWORK_DEFAULT_TIMEOUT_BIND * (3-eWDevGetDataRate()));
565 }
566 
567 __STATIC_ALWAYS_INLINE (uint8_t
568  ucWNetPingTimeout (void)) {
569 
570  return (WUSB_CONFIG_NETWORK_DEFAULT_TIMEOUT_PING * (3-eWDevGetDataRate()));
571 }
572 
573 /*------------ Getters Net Config -------------*/
574 // -----------------------------------------------------------------------------
575 __STATIC_ALWAYS_INLINE (void
576  vWNetWaitIdle (void)) {
577 
579 }
580 
581 // -----------------------------------------------------------------------------
582 __STATIC_ALWAYS_INLINE (const xWNetConfig *
583  pxWNetCurrentConfig(void)) {
584 
585  return &dNet.xConfig;
586 }
587 
588 // -----------------------------------------------------------------------------
589 __STATIC_ALWAYS_INLINE (uint8_t
590  ucWNetChannel(void)) {
591 
592  return dNet.xConfig.ucChannel;
593 }
594 
595 // -----------------------------------------------------------------------------
596 __STATIC_ALWAYS_INLINE (uint8_t
597  ucWNetChecksumSeed(void)) {
598 
599  return dNet.xConfig.ucChecksumSeed;
600 }
601 
602 // -----------------------------------------------------------------------------
603 __STATIC_ALWAYS_INLINE (uint8_t
604  ucWNetCrcSeed(void)) {
605 
606  return dNet.xConfig.ucCrcSeed;
607 }
608 
609 // -----------------------------------------------------------------------------
610 __STATIC_ALWAYS_INLINE (uint8_t
611  ucWNetPnCode(void)) {
612 
613  return dNet.xConfig.ucPnCode;
614 }
615 
616 // -----------------------------------------------------------------------------
617 __STATIC_ALWAYS_INLINE (bool
618  xWNetStatus (eWNetStatusCode eFlag)) {
619 
620  return xWPktBit (dNet.xConfig.ucStatus, eFlag);
621 }
622 
623 // -----------------------------------------------------------------------------
624 __STATIC_ALWAYS_INLINE (bool
625  xWNetSingleByteDeviceId (void)) {
626 
627  return xWNetStatus (WNET_SINGLEBYTE);
628 }
629 
630 // -----------------------------------------------------------------------------
631 __STATIC_ALWAYS_INLINE (uint8_t
633 
634  return WNET_NUM_OF_CH_USED;
635 }
636 
637 // -----------------------------------------------------------------------------
638 __STATIC_ALWAYS_INLINE (uint8_t
639  ucWNetNumberOfSubsets (void)) {
640 
641  return WNET_NUM_OF_SUBSETS;
642 }
643 
644 /*------------ Getters Net Error -------------*/
645 __STATIC_ALWAYS_INLINE (eWNetErrorCode
646  eWNetError(void)) {
647 
648  return (eWNetErrorCode) xStateGet(&dNet.xError);
649 }
650 
651 /*------------ Getters Net Tx Packet -------------*/
652 // -----------------------------------------------------------------------------
653 __STATIC_ALWAYS_INLINE (xWusbPacket *
654  pxWNetTxPacket(void)) {
655 
656  return &dNet.pxTxPacket;
657 }
658 
659 /*------------ Getters Net Rx Packet -------------*/
660 // -----------------------------------------------------------------------------
661 __STATIC_ALWAYS_INLINE (xWusbPacket *
662  pxWNetRxPacket(void)) {
663 
664  return &dNet.pxRxPacket;
665 }
666 
667 // -----------------------------------------------------------------------------
668 __STATIC_ALWAYS_INLINE (uint8_t
669  ucWNetRxPktType (void)) {
670 
671  return ucWPktType (pxWNetRxPacket());
672 }
673 
674 // -----------------------------------------------------------------------------
675 __STATIC_ALWAYS_INLINE (uint8_t
676  ucWNetRxPktHeader (void)) {
677 
678  return ucWPktHeader (pxWNetRxPacket());
679 }
680 
681 // -----------------------------------------------------------------------------
682 __STATIC_ALWAYS_INLINE (bool
683  xWNetRxPktFlag (uint8_t ucIndex)) {
684 
685  return xWPktFlag (pxWNetRxPacket(), ucIndex);
686 }
687 
688 // -----------------------------------------------------------------------------
689 __STATIC_ALWAYS_INLINE (uint8_t
690  ucWNetRxPktByte (uint8_t ucOffset)) {
691 
692  return ucWPktByte (pxWNetRxPacket(), ucOffset);
693 }
694 
695 // -----------------------------------------------------------------------------
696 __STATIC_ALWAYS_INLINE (uint16_t
697  usWNetRxPktWord (uint8_t ucOffset)) {
698 
699  return usWPktWord (pxWNetRxPacket(), ucOffset);
700 }
701 
702 // -----------------------------------------------------------------------------
703 __STATIC_ALWAYS_INLINE (uint32_t
704  ulWNetRxPktDword (uint8_t ucOffset)) {
705 
706  return ulWPktDword (pxWNetRxPacket(), ucOffset);
707 }
708 
709 // -----------------------------------------------------------------------------
710 __STATIC_ALWAYS_INLINE (uint8_t *
711  pucWNetRxPktBytes (uint8_t ucOffset)) {
712 
713  return &pucWPktRaw(pxWNetRxPacket())[ucOffset];
714 
715 }
716 
717 // -----------------------------------------------------------------------------
718 __STATIC_ALWAYS_INLINE (uint8_t *
719  pucWNetRxPktDataPayload (void)) {
720 
722 }
723 
724 // -----------------------------------------------------------------------------
725 __STATIC_ALWAYS_INLINE (uint8_t
727 
729 }
730 
731 /*------------ Setters Net Config -------------*/
732 // -----------------------------------------------------------------------------
733 __STATIC_ALWAYS_INLINE (void
734  vWNetSetChecksumSeed(uint8_t ucValue)) {
735 
736  dNet.xConfig.ucChecksumSeed = ucValue;
737 }
738 
739 // -----------------------------------------------------------------------------
740 __STATIC_ALWAYS_INLINE (void
741 vWNetSetCrcSeed(uint8_t ucValue)) {
742 
743  dNet.xConfig.ucCrcSeed = ucValue;
744 }
745 
746 // -----------------------------------------------------------------------------
747 __STATIC_ALWAYS_INLINE (void
748  vWNetSetStatus (eWNetStatusCode eFlag, bool ucValue)) {
749 
750  vWPktSetBit (&dNet.xConfig.ucStatus, eFlag, ucValue);
751 }
752 
753 // -----------------------------------------------------------------------------
754 __STATIC_ALWAYS_INLINE (void
755  vWNetSetSingleByteDeviceId (bool xEnable)) {
756 
757  vWNetSetStatus (WNET_SINGLEBYTE, xEnable);
758 }
759 
760 // -----------------------------------------------------------------------------
761 __STATIC_ALWAYS_INLINE (void
763 
764  dNet.xConfig.ucStatus ^= 1<<eFlag;
765 }
766 
767 /*------------ Setters Net Tx Packet -------------*/
768 // -----------------------------------------------------------------------------
769 __STATIC_ALWAYS_INLINE (void
770  vWNetTxPktAddByte (uint8_t ucByte)) {
771 
772  vWPktAddByte (pxWNetTxPacket(), ucByte);
773 }
774 
775 // -----------------------------------------------------------------------------
776 __STATIC_ALWAYS_INLINE (void
777  vWNetTxPktAddBytes (const uint8_t * pucBytes, uint8_t ucLength)) {
778 
779  vWPktAddBytes (pxWNetTxPacket(), pucBytes, ucLength);
780 }
781 
782 // -----------------------------------------------------------------------------
783 __STATIC_ALWAYS_INLINE (void
784  vWNetTxPktAddBytes_P (const uint8_t * pucBytes, uint8_t ucLength)) {
785 
786  vWPktAddBytes_P (pxWNetTxPacket(), pucBytes, ucLength);
787 }
788 
789 // -----------------------------------------------------------------------------
790 __STATIC_ALWAYS_INLINE (void
791  vWNetTxPktAddStr (const char * pcStr)) {
792 
793  vWPktAddStr (pxWNetTxPacket(), pcStr);
794 }
795 
796 // -----------------------------------------------------------------------------
797 __STATIC_ALWAYS_INLINE (void
798  vWNetTxPktAddStr_P (const char * pcStr)) {
799 
800  vWPktAddStr_P (pxWNetTxPacket(), pcStr);
801 }
802 
803 // -----------------------------------------------------------------------------
804 __STATIC_ALWAYS_INLINE (void
805  vWNetTxPktAddWord (uint16_t usWord)) {
806 
807  vWPktAddWord (pxWNetTxPacket(), usWord);
808 }
809 
810 // -----------------------------------------------------------------------------
811 __STATIC_ALWAYS_INLINE (void
812  vWNetTxPktSetAllFlags (uint8_t ucFlags)) {
813 
814  xWPktSetAllFlags (pxWNetTxPacket(), ucFlags);
815 }
816 
817 // -----------------------------------------------------------------------------
818 __STATIC_ALWAYS_INLINE (void
819  vWNetTxPktSetFlag (uint8_t ucIndex, bool ucValue)) {
820 
821  vWPktSetFlag (pxWNetTxPacket(), ucIndex, ucValue);
822 }
823 
824 // -----------------------------------------------------------------------------
825 __STATIC_ALWAYS_INLINE (void
826 vWNetTxPktSetHeader (uint8_t ucHeader)) {
827 
828  vWPktSetHeader (pxWNetTxPacket(), ucHeader);
829 }
830 
831 // -----------------------------------------------------------------------------
832 __STATIC_ALWAYS_INLINE (void
833  vWNetTxPktSetType (uint8_t ucPacketType)) {
834 
835  vWPktSetType (pxWNetTxPacket(), ucPacketType);
836 }
837 
838 // -----------------------------------------------------------------------------
839 __STATIC_ALWAYS_INLINE (void
840  vWNetTxPktToggleFlag (uint8_t ucIndex)) {
841 
842  vWPktToggleFlag (pxWNetTxPacket(), ucIndex);
843 }
844 
845 /* ========================================================================== */
846 /* Tests unitaires (non documentés) */
847 /* ========================================================================== */
848 /* structures =============================================================== */
849  typedef struct xWNetTestResult {
850 
851  uint16_t usSended;
852  uint16_t usReceived;
853  uint16_t usCorrupted;
854  } xWNetTestResult;
855 
856 #ifdef WNET_TEST
857 /* internal public functions ================================================ */
858  int iWNetTestSetup (void);
859 
860  /*
861  * Attends un paquet:
862  * - Si paquet correct reçu, vérifie le type:
863  * - Si le type est un WPKT_DATA_PACKET, un WPKT_ACK_PACKET est renvoyé (V=1)
864  * - Si le type est un WPKT_BIND_REQUEST_PACKET, un WPKT_BIND_RESPONSE_PACKET
865  * est renvoyé
866  * - Pour les autres types, ne renvoie rien
867  * - Si paquet incorrect, ne fait rien
868  * @return true si paquet correct reçu
869  */
870  eWNetErrorCode eWNetTestHub (int16_t iTimeoutMs);
871  /*
872  * Envoi paquet DATA et attends la réponse HUB en recommancant tant que le HUB
873  * n'a pas répondu correctement.
874  */
875  eWNetErrorCode eWNetTestSensorPing (uint16_t usCount, uint16_t usInterval,
876  xWNetTestResult * pxResult);
877  /*
878  * Envoi paquet BIND_REQUEST et attends réponse HUB en recommancant tant que
879  * le HUB n'a pas répondu correctement.
880  */
881  eWNetErrorCode eWNetTestSensorBind (uint16_t usMaxRetries, uint16_t usInterval,
882  xWNetTestResult * pxResult);
883 #else /* WNET_TEST defined */
884  #define iWNetTestSetup() (0)
885  #define eWNetTestHub(t) (WNET_SUCCESS)
886  #define eWNetTestSensorPing(c,i,r) (WNET_SUCCESS)
887  #define eWNetTestSensorBind(m,i,r) (WNET_SUCCESS)
888 #endif /* WNET_TEST defined */
889 
890 #ifdef WNET_DEBUG_ONUART
891  void vWNetDbgDumpConfig(void);
892  void vWNetDbgDumpRxPacket(void);
893  void vWNetDbgDumpTxPacket(void);
894  void vWNetDbgNoResp(void);
895  void vWNetDbgSend(void);
896 #else
897  #define vWNetDbgDumpConfig()
898  #define vWNetDbgDumpRxPacket()
899  #define vWNetDbgDumpTxPacket()
900  #define vWNetDbgNoResp()
901  #define vWNetDbgSend()
902 #endif /* WNET_DEBUG_ONUART defined */
903 
904 #endif /* __DOXYGEN__ not defined */
905 /* ========================================================================== */
906 __END_C_DECLS
907 #endif /* _AVRIO_WUSB_NETWORK_H_ */
void vWPktSetFlag(xWusbPacket *pxPkt, uint8_t ucIndex, bool xValue)
Modifie l&#39;état d&#39;un bit de flag de l&#39;entête d&#39;un paquet.
uint8_t ucWNetAckTimeout(void)
Renvoie le délai d&#39;attente pour la réception d&#39;un paquet ACK La valeur renvoyée tient compte des para...
bool xWNetStatus(eWNetStatusCode eFlag)
Etat logique d&#39;un bit d&#39;état ou de contrôle de la configuration du réseau.
bool xWNetSingleByteDeviceId(void)
Renvoie true si les Device ID sont codés sur un octet.
void vWPktAddBytes_P(xWusbPacket *pxPkt, const uint8_t *pucBytes, uint8_t ucLength)
Ajoute une suite d&#39;octets au paquet.
void vWNetTxPktSetType(uint8_t ucPacketType)
Modifie le type du paquet TX.
void vWPktSetHeader(xWusbPacket *pxPkt, uint8_t ucValue)
Modifie l&#39;en-tête préexistant du paquet.
uint8_t ucWNetCrcSeed(void)
CRC seed courant.
bool xWPktBit(uint8_t Byte, uint8_t Bit)
Renvoie l&#39;état du bit de rang Bit de l&#39;octet Byte.
void vWNetTxPktNew(uint8_t ucPacketType)
Initialise une nouveau paquet de type ucPacketType.
bool xWNetRxPktFlag(uint8_t ucIndex)
Etat du flag d&#39;index ucIndex de l&#39;entête du paquet reçu.
void vWNetTxPktAddByte(uint8_t ucByte)
Ajoute un octet au paquet TX.
int8_t xTaskHandle
xTaskHandle Identifiant d&#39;une tâche
Definition: task.h:58
void vWNetSaveConfigToEEPROM(void)
Sauvegarde la configuration courante en EEPROM.
Configuration du réseau Nto1.
Definition: network.h:113
void vWNetTxPktAddDeviceId(uint16_t usDeviceId)
Ajoute le Device ID au paquet TX L&#39;ajout se fait en respectant le flag WNET_SINGLEBYTE de mode du rés...
uint8_t ucPnCode
Definition: network.h:116
uint8_t * pucWNetRxPktBytes(uint8_t ucOffset)
Pointeur sur l&#39;octet d&#39;offset ucOffset du paquet reçu.
xWusbPacket * pxWNetTxPacket(void)
Renvoie un pointeur sur le paquet de transmission.
uint8_t ucChannel
Definition: network.h:115
uint8_t xStateGet(xState *pxState)
Lit la valeur d&#39;une machine d&#39;état de façon atomique.
Paquet réseau WirelessUSB™
Definition: packet.h:87
void vWNetTxPktAddWord(uint16_t usWord)
Ajoute un mot de 16 bits au paquet TX.
uint8_t ucWNetBindTimeout(void)
Renvoie le délai d&#39;attente pour la réception d&#39;un paquet BIND La valeur renvoyée tient compte des par...
const xWNetConfig * pxWNetCurrentConfig(void)
Configuration courante.
void vWNetToggleStatus(eWNetStatusCode eFlag)
Bascule l&#39;état d&#39;un bit d&#39;état ou de contrôle de la configuration du réseau.
eWNetStatusCode
Indice des bits de mode et d&#39;état utilisés par le réseau.
Definition: network.h:99
uint16_t usWNetRxPktDeviceId(void)
Device ID du paquet reçu Cette fonction s&#39;adapte en fonction du bit WPKT_SINGLE reçu. Si ce bit est à 1 dans le paquet reçu, le Device ID est lu comme un octet et converti en uint16_t. Cette fonction ne doit être utilisée que si le paquet reçu est de type DATA, ACK ou BIND_RESPONSE.
void vWNetInit(eWDevDataRate eDataRate)
Initialise le réseau L&#39;initialisation du réseau se fait avec les valeurs sauvegardées en EEPROM...
eWNetErrorCode
Codes d&#39;erreurs et d&#39;état du réseau Nto1 0 signifie "Aucune erreur", une valeur négative indique une ...
Definition: network.h:79
uint8_t ucWNetPnCode(void)
Index du Pn Code courant.
uint8_t ucWNetRand(void)
Renvoie un nombre pseudo aléatoire compris entre 1 et 31 Le générateur pseudo aléatoire est initilial...
void vWNetSetConfig(const xWNetConfig *pxConfig)
Modifie la configuration à partir d&#39;une structure xWNetConfig.
void vWNetTxPktSetHeader(uint8_t ucHeader)
Modifie l&#39;entête du paquet TX.
uint8_t ucWNetRxPktHeader(void)
Entête du paquet reçu.
void vWNetTxPktSetFlag(uint8_t ucIndex, bool ucValue)
Modifie l&#39;état d&#39;un bit de flag d&#39;index ucIndex dans l&#39;entête du paquet TX.
void vWPktAddWord(xWusbPacket *pxPkt, uint16_t usValue)
Ajoute un mot de 16 bits (little endian) au paquet.
uint8_t ucStatus
Definition: network.h:119
uint8_t ucWNetChannel(void)
Index du canal courant.
uint8_t ucCrcSeed
Definition: network.h:118
uint8_t xWPktDataPayloadLength(xWusbPacket *pxPkt)
Renvoie le nombre d&#39;octets du payload.
void vWPktSetType(xWusbPacket *pxPkt, uint8_t ucValue)
Modifie le type de paquet.
xWusbPacket * pxWNetRxPacket(void)
Pointeur sur le paquet de réception.
uint8_t ucWNetNumberOfSubsets(void)
Nombre de sous-ensembles de canaux.
uint8_t ucWNetChecksumSeed(void)
Checksum seed courant.
uint32_t ulWNetRxPktDword(uint8_t ucOffset)
Mot de 32 bits d&#39;offset ucOffset du paquet reçu.
volatile uint8_t xState
Le type xState est une variable atomique qui peut évoluer entre 0 et 255.
Definition: state.h:46
void vWNetSetSingleByteDeviceId(bool xEnable)
Active le codage des Device ID sur un octet.
void vWPktSetBit(uint8_t *Byte, uint8_t Bit, bool xValue)
Modifie l&#39;état du bit de rang Bit de l&#39;octet pointé par Byte.
void vWNetTxPktSend(void)
Envoie le paquet Tx sur le réseau Le paquet doit être préparé avec les différentes fonctions d&#39;assert...
uint16_t usWPktWord(xWusbPacket *pxPkt, uint8_t Offset)
Renvoie la valeur d&#39;un mot de 16 bits (little endian) du paquet.
void vWPktAddStr(xWusbPacket *pxPkt, const char *pcStr)
Ajoute une chaîne de caractères sans le zéro terminal au paquet.
void vWNetGoToNextChannel(void)
Passe au canal suivant dans le subset utilisé
eWNetErrorCode eWNetError(void)
Renvoie la dernière erreur.
void vWNetTxPktAddBytes(const uint8_t *pucBytes, uint8_t ucLength)
Ajoute une suite d&#39;octets au paquet TX.
uint8_t ucWPktType(xWusbPacket *pxPkt)
Renvoie le type du paquet.
uint8_t ucChecksumSeed
Definition: network.h:117
void vWDevWaitStatus(eWDevStatus eStatus)
Attends que le module passe à l&#39;état Status.
eWDevDataRate
Différentes vitesse de transmission.
Definition: device.h:53
void vWNetWaitIdle(void)
Attends que le réseau passe à l&#39;état Disponible.
uint8_t ucWNetRxPktDataPayloadLength(void)
Longueur du payload du paquet DATA reçu Si le paquet reçu n&#39;est pas un paquet DATA, cette fonction renvoie 0.
void vWNetTxPktAddTrailer(void)
Ajoute le CRC et le checksum en queue de paquet Cette fonction modifie le bit Signle Byte Device ID (...
void vWNetSetChecksumSeed(uint8_t ucValue)
Modifie le checksum seed.
void vWNetTxPktAddStr(const char *pcStr)
Ajoute une chaîne de caractères à zéro terminal au paquet TX Le zéro final n&#39;est pas ajouté au paquet...
bool xWNetSetChannel(uint8_t ucIndex)
Modifie le canal.
bool xWNetSetPnCode(uint8_t ucValue)
Modifie le Pn Code du réseau.
uint8_t xWPktLength(xWusbPacket *pxPkt)
Renvoie le nombre d&#39;octets stockés dans le paquet.
uint8_t * pucWNetRxPktDataPayload(void)
Pointeur sur le premier octet du payload du paquet DATA reçu Si le paquet reçu n&#39;est pas un paquet DA...
uint8_t ucWNetRxPktType(void)
Type du paquet reçu.
void vWPktAddByte(xWusbPacket *pxPkt, uint8_t ucValue)
Ajoute un octet au paquet.
uint8_t ucWPktHeader(xWusbPacket *pxPkt)
Renvoie la valeur de l&#39;en-tête du paquet.
void vWDevTransmit(const uint8_t *Data, uint8_t Length)
Transmission d&#39;un message.
uint8_t ucWNetNumberOfPnCodes(void)
Nombre de PnCode possibles.
void vWNetSetStatus(eWNetStatusCode eFlag, bool ucValue)
Modifie l&#39;état d&#39;un bit d&#39;état ou de contrôle de la configuration du réseau.
uint8_t ucWPktByte(xWusbPacket *pxPkt, uint8_t Offset)
Renvoie la valeur d&#39;un octet du paquet.
void vWPktAddStr_P(xWusbPacket *pxPkt, const char *pcStr)
Ajoute une chaîne de caractères sans le zéro terminal au paquet.
void vWNetSetCrcSeed(uint8_t ucValue)
Modifie le crc seed.
uint8_t ucWNetRxPktByte(uint8_t ucOffset)
Octet d&#39;offset ucOffset du paquet reçu L&#39;offset 0 correspond à l&#39;entête du paquet.
uint16_t usWNetRxPktWord(uint8_t ucOffset)
Mot de 16 bits d&#39;offset ucOffset du paquet reçu.
uint8_t ucWNetNumberOfChannelsUsed(void)
Nombre de canaux possibles.
void vWNetTxPktAddBytes_P(const uint8_t *pucBytes, uint8_t ucLength)
Ajoute une suite d&#39;octets résidant en mémoire programme au paquet TX.
void vWPktAddBytes(xWusbPacket *pxPkt, const uint8_t *pucBytes, uint8_t ucLength)
Ajoute une suite d&#39;octets au paquet.
uint8_t ucWNetPingTimeout(void)
Renvoie le délai d&#39;attente pour la réception d&#39;un paquet PING La valeur renvoyée tient compte des par...
void vWPktToggleFlag(xWusbPacket *pxPkt, uint8_t ucIndex)
Bascule l&#39;état d&#39;un drapeau du paquet.
uint8_t * pucWPktRaw(xWusbPacket *pxPkt)
Renvoie un pointeur sur la zone mémoire où sont stockés les octets du paquet.
void vWNetTxPktToggleFlag(uint8_t ucIndex)
Bascule le flag d&#39;index ucIndex dans l&#39;entête du paquet TX.
bool xWPktSetAllFlags(xWusbPacket *pxPkt, uint8_t ucFlags)
Modifie l&#39;état des bits de flag de l&#39;entête d&#39;un paquet.
bool xWPktFlag(xWusbPacket *pxPkt, uint8_t ucIndex)
Renvoie l&#39;état d&#39;un drapeau du paquet.
uint32_t ulWPktDword(xWusbPacket *pxPkt, uint8_t Offset)
Renvoie la valeur d&#39;un mot de 16 bits (little endian) du paquet.
uint8_t * pucWPktDataPayload(xWusbPacket *pxPkt)
Renvoie un pointeur sur la zone mémoire où sont stockés les octets du payload.
eWDevDataRate eWDevGetDataRate(void)
Renvoie la vitesse de transmission.
eWNetErrorCode eWNetRxPktWait(int16_t iTimeoutMs)
Attends la réception d&#39;un paquet. Si iTimeoutMs négatif, la fonction attends indéfiniment et sort uni...
void vWNetTxPktAddStr_P(const char *pcStr)
Ajoute une chaîne de caractères à zéro terminal résidant en mémoire programme au paquet TX Le zéro fi...