[69] | 1 | /* USER CODE BEGIN Header */ |
---|
| 2 | /** |
---|
| 3 | ****************************************************************************** |
---|
| 4 | * @file app_netxduo.c |
---|
| 5 | * @author MCD Application Team |
---|
| 6 | * @brief NetXDuo applicative file |
---|
| 7 | ****************************************************************************** |
---|
| 8 | * @attention |
---|
| 9 | * |
---|
| 10 | * Copyright (c) 2020-2021 STMicroelectronics. |
---|
| 11 | * All rights reserved. |
---|
| 12 | * |
---|
| 13 | * This software is licensed under terms that can be found in the LICENSE file |
---|
| 14 | * in the root directory of this software component. |
---|
| 15 | * If no LICENSE file comes with this software, it is provided AS-IS. |
---|
| 16 | * |
---|
| 17 | ****************************************************************************** |
---|
| 18 | */ |
---|
| 19 | |
---|
| 20 | /* USER CODE END Header */ |
---|
| 21 | |
---|
| 22 | /* Includes ------------------------------------------------------------------*/ |
---|
| 23 | #include "app_netxduo.h" |
---|
| 24 | |
---|
| 25 | /* Private includes ----------------------------------------------------------*/ |
---|
| 26 | /* USER CODE BEGIN Includes */ |
---|
| 27 | |
---|
| 28 | /* USER CODE END Includes */ |
---|
| 29 | |
---|
| 30 | /* Private typedef -----------------------------------------------------------*/ |
---|
| 31 | /* USER CODE BEGIN PTD */ |
---|
| 32 | |
---|
| 33 | /* USER CODE END PTD */ |
---|
| 34 | |
---|
| 35 | /* Private define ------------------------------------------------------------*/ |
---|
| 36 | /* USER CODE BEGIN PD */ |
---|
| 37 | |
---|
| 38 | #define IP_HELPER_THREAD_STACK_SIZE (512U) |
---|
| 39 | #define NX_PACKET_POOL_SIZE (1024U) |
---|
| 40 | |
---|
| 41 | /* USER CODE END PD */ |
---|
| 42 | |
---|
| 43 | /* Private macro -------------------------------------------------------------*/ |
---|
| 44 | /* USER CODE BEGIN PM */ |
---|
| 45 | |
---|
| 46 | /* USER CODE END PM */ |
---|
| 47 | |
---|
| 48 | /* Private variables ---------------------------------------------------------*/ |
---|
| 49 | /* USER CODE BEGIN PV */ |
---|
| 50 | |
---|
| 51 | NX_IP ip; |
---|
| 52 | static CHAR ipName[] = "Eth"; |
---|
| 53 | static CHAR ip_helper_thread_stack[IP_HELPER_THREAD_STACK_SIZE] __attribute__((section(".DTCM_RAM"))); |
---|
| 54 | static CHAR nx_packet_pool_memory[NX_PACKET_POOL_SIZE] __attribute__((section(".DTCM_RAM"), aligned(4))); |
---|
| 55 | static NX_PACKET_POOL pool; |
---|
| 56 | |
---|
| 57 | /* USER CODE END PV */ |
---|
| 58 | |
---|
| 59 | /* Private function prototypes -----------------------------------------------*/ |
---|
| 60 | /* USER CODE BEGIN PFP */ |
---|
| 61 | |
---|
| 62 | VOID ip_network_driver(NX_IP_DRIVER *ipDrv); |
---|
| 63 | |
---|
| 64 | /* USER CODE END PFP */ |
---|
| 65 | |
---|
| 66 | /** |
---|
| 67 | * @brief Application NetXDuo Initialization. |
---|
| 68 | * @param memory_ptr: memory pointer |
---|
| 69 | * @retval int |
---|
| 70 | */ |
---|
| 71 | UINT MX_NetXDuo_Init(VOID *memory_ptr) |
---|
| 72 | { |
---|
| 73 | UINT ret = NX_SUCCESS; |
---|
| 74 | |
---|
| 75 | TX_BYTE_POOL *byte_pool = (TX_BYTE_POOL*)memory_ptr; |
---|
| 76 | |
---|
| 77 | /* USER CODE BEGIN MX_NetXDuo_MEM_POOL */ |
---|
| 78 | (void)byte_pool; |
---|
| 79 | /* USER CODE END MX_NetXDuo_MEM_POOL */ |
---|
| 80 | |
---|
| 81 | /* USER CODE BEGIN 0 */ |
---|
| 82 | |
---|
| 83 | nx_system_initialize(); |
---|
| 84 | |
---|
| 85 | UINT r = nx_packet_pool_create(&pool, "NX packet pool", 512, nx_packet_pool_memory, NX_PACKET_POOL_SIZE); |
---|
| 86 | //printf("Result = %u\n", r); |
---|
| 87 | |
---|
| 88 | r = nx_ip_create(&ip, ipName, IP_ADDRESS(192, 168, 1, 177), 0xFFFFFFFF, &pool, ip_network_driver, ip_helper_thread_stack, IP_HELPER_THREAD_STACK_SIZE, 1); |
---|
| 89 | //printf("Result = %u\n", r); |
---|
| 90 | |
---|
| 91 | /* USER CODE END 0 */ |
---|
| 92 | |
---|
| 93 | /* USER CODE BEGIN MX_NetXDuo_Init */ |
---|
| 94 | |
---|
| 95 | /* USER CODE END MX_NetXDuo_Init */ |
---|
| 96 | |
---|
| 97 | return ret; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | /* USER CODE BEGIN 1 */ |
---|
| 101 | |
---|
| 102 | VOID ip_network_driver(NX_IP_DRIVER *ipDrv) |
---|
| 103 | { |
---|
| 104 | printf("Network Driver is working!\n"); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | /* USER CODE END 1 */ |
---|