-
Notifications
You must be signed in to change notification settings - Fork 26
/
CMakeLists.txt
113 lines (95 loc) · 4.17 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
cmake_minimum_required(VERSION 3.16)
project(stm32-enc28j60 C ASM)
set(SOURCES
src/enc28j60.c
src/ip_arp_udp_tcp.c
src/dhcp.c
src/dnslkup.c
src/websrv_help_functions.c
src/EtherShield.c
src/error_handler.c
)
set(HEADERS
inc/defines.h
inc/enc28j60.h
inc/ip_arp_udp_tcp.h
inc/net.h
inc/dhcp.h
inc/dnslkup.h
inc/websrv_help_functions.h
inc/EtherShield.h
inc/error_handler.h
)
set(ETHERNET_LED_GPIO "GPIOA" CACHE INTERNAL "GPIO for ethernet LED")
set(ETHERNET_LED_PIN "GPIO_PIN_2" CACHE INTERNAL "PIN for ethernet LED")
set(ETHERNET_CS_GPIO "GPIOA" CACHE INTERNAL "GPIO for SPI chip select")
set(ETHERNET_CS_PIN "GPIO_PIN_3" CACHE INTERNAL "PIN for SPI chip select")
set(ETHERNET_CS_DELAY "1" CACHE INTERNAL "chip-select delay for ethernet")
set(ETHERSHIELD_DEBUG "1" CACHE INTERNAL "enables debugging")
set(UDP_client "1" CACHE INTERNAL "enables UDP transport protocol")
set(NTP_client "1" CACHE INTERNAL "enables NTP client")
set(WOL_client "1" CACHE INTERNAL "enables WOL client")
set(DNS_client "1" CACHE INTERNAL "enables DNS client")
set(DHCP_client "1" CACHE INTERNAL "enables DHCP client")
set(DHCP_HOSTNAME "stm32-enc28j60" CACHE INTERNAL "DHCP host name")
set(PING_client "1" CACHE INTERNAL "enables ICMP ping client")
set(PINGPATTERN 0x42 CACHE INTERNAL "ping pattern value")
set(TCP_client "1" CACHE INTERNAL "enables TCP transport protocol")
set(WWW_client "1" CACHE INTERNAL "enables HTTP")
set(WWW_USER_AGENT "stm32-enc28j60/1.0" CACHE INTERNAL "HTTP User-Agent")
set(FROMDECODE_websrv_help "1" CACHE INTERNAL "")
set(URLENCODE_websrv_help "1" CACHE INTERNAL "")
string(LENGTH ${DHCP_HOSTNAME} DHCP_HOSTNAME_LEN)
if(DHCP_HOSTNAME_LEN GREATER 32)
message(SEND_ERROR "DHCP_HOSTNAME length > 32 limit")
endif()
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
## STM32_TOOLCHAIN_PATH, STM32_TARGET_TRIPLET, STM32_CUBE_F4_PATH must be present in environment variables
## check https://github.com/DVALight/stm32-cmake for more info
# change to your MCU family and model!
if(NOT MCU_FAMILY)
set(MCU_FAMILY "F4" CACHE INTERNAL "STM32 MCU family")
set(MCU_MODEL "F401VE" CACHE INTERNAL "STM32 MCU model")
endif()
list(APPEND HAL_COMP_LIST "STM32${MCU_FAMILY}" CORTEX RCC GPIO SPI)
list(APPEND CMSIS_COMP_LIST "STM32${MCU_FAMILY}")
if(NOT STM32_CMAKE_PACKAGES)
find_package(CMSIS COMPONENTS "${CMSIS_COMP_LIST}" REQUIRED)
find_package(HAL COMPONENTS "${HAL_COMP_LIST}" REQUIRED)
set(STM32_CMAKE_PACKAGES 1)
endif()
add_library(stm32-enc28j60 ${SOURCES} ${HEADERS})
target_include_directories(stm32-enc28j60 PUBLIC inc)
target_compile_definitions(stm32-enc28j60 PUBLIC
ETHERNET_LED_GPIO=${ETHERNET_LED_GPIO}
ETHERNET_LED_PIN=${ETHERNET_LED_PIN}
ETHERNET_CS_GPIO=${ETHERNET_CS_GPIO}
ETHERNET_CS_PIN=${ETHERNET_CS_PIN}
ETHERNET_CS_DELAY=${ETHERNET_CS_DELAY}
ETHERSHIELD_DEBUG=${ETHERSHIELD_DEBUG}
UDP_client=${UDP_client}
NTP_client=${NTP_client}
WOL_client=${WOL_client}
DNS_client=${DNS_client}
DHCP_client=${DHCP_client}
DHCP_HOSTNAME="${DHCP_HOSTNAME}"
DHCP_HOSTNAME_LEN=${DHCP_HOSTNAME_LEN}
PING_client=${PING_client}
PINGPATTERN=${PINGPATTERN}
TCP_client=${TCP_client}
WWW_client=${WWW_client}
WWW_USER_AGENT="${WWW_USER_AGENT}"
FROMDECODE_websrv_help=${FROMDECODE_websrv_help}
URLENCODE_websrv_help=${URLENCODE_websrv_help}
)
target_link_libraries(stm32-enc28j60
HAL::STM32::${MCU_FAMILY}::RCC
HAL::STM32::${MCU_FAMILY}::GPIO
HAL::STM32::${MCU_FAMILY}::CORTEX
CMSIS::STM32::${MCU_MODEL}
STM32::NoSys
)
#add_custom_command(TARGET stm32-enc28j60 POST_BUILD
# COMMAND ${CMAKE_OBJCOPY} -O ihex stm32-enc28j60.elf stm32-enc28j60.hex
#)
stm32_print_size_of_target(stm32-enc28j60)