You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* This file contains NetX-specific debug helpers. */
9
+
10
+
/* API */
11
+
constchar*nx_status_toString(UINTstatus); /* Converts a NetX status macro to a printable string. Meant to be used with DEBUG_PRINTLN() (defined in another file). */
* NOTE: This file can only be used in projects that include NetXDuo.
8
+
*/
9
+
10
+
#include<stdint.h>
11
+
#include"nx_api.h"
12
+
13
+
/* CONFIG */
14
+
#defineETH_UDP_PORT 2006 /* UDP port for communication */
15
+
#defineETH_MESSAGE_SIZE 8 /* Maximum ethernet message size in bytes. */
16
+
#defineETH_MAX_PACKETS 10 /* Maximum number of packets we wanna handle simultaneously */
17
+
#defineETH_NUMBER_OF_NODES 8 /* Number of nodes in the network. */
18
+
19
+
typedefenum {
20
+
VCU= (1 << 0), // 0b00000001
21
+
COMPUTE= (1 << 1), // 0b00000010
22
+
TPU= (1 << 2), // 0b00000100
23
+
MSB1= (1 << 3), // 0b00001000
24
+
MSB2= (1 << 4), // 0b00010000
25
+
MSB3= (1 << 5), // 0b00100000
26
+
MSB4= (1 << 6), // 0b01000000
27
+
NODE8= (1 << 7), // 0b10000000
28
+
} ethernet_node_t;
29
+
#defineETH_IP(node) IP_ADDRESS(239, 0, 0, node)
30
+
/* END CONFIG */
31
+
32
+
typedefstruct {
33
+
uint8_tsender_id;
34
+
uint8_trecipient_id;
35
+
uint8_tmessage_id;
36
+
uint8_tdata_length;
37
+
uint8_tdata[ETH_MESSAGE_SIZE];
38
+
} ethernet_message_t;
39
+
40
+
/* Function Pointers (for initialization). */
41
+
typedefvoid (*DriverFunction)(NX_IP_DRIVER*); /* User-supplied network driver used to send and receive IP packets. */
42
+
typedefvoid (*OnRecieve)(ethernet_message_tmessage); /* User-supplied function that will be called whenever an ethernet message is recieved. */
43
+
44
+
/**
45
+
* @brief Initializes the NetX ethernet system in a repo.
46
+
* @param node_id The ID (ethernet_node_t) of this node.
47
+
* @param driver User-supplied network driver function. Should be set to nx_stm32_eth_driver (from "nx_stm32_eth_driver.h") for STM32 projects.
48
+
* @param on_recieve User-supplied function to be called whenever an ethernet message is recieved. The function's only parameter is an ethernet_message_t instance containing the recieved message.
0 commit comments