You've already forked Http_Cyclone
mirror of
https://github.com/AdaCore/Http_Cyclone.git
synced 2026-02-12 13:07:39 -08:00
Initial commit
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
obj/
|
||||
*.o
|
||||
*.bin
|
||||
*.elf
|
||||
*.lst
|
||||
*.map
|
||||
1
.vscode/.cortex-debug.peripherals.state.json
vendored
Normal file
1
.vscode/.cortex-debug.peripherals.state.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[]
|
||||
1
.vscode/.cortex-debug.registers.state.json
vendored
Normal file
1
.vscode/.cortex-debug.registers.state.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[]
|
||||
35
.vscode/launch.json
vendored
Normal file
35
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "STM Debug",
|
||||
"type": "cortex-debug",
|
||||
"request": "launch",
|
||||
"servertype": "openocd",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"device": "STM32F769II",
|
||||
// "interface": "swd",
|
||||
"executable": "./ftp_client_demo.elf",
|
||||
"configFiles": [
|
||||
"board/stm32f7discovery.cfg"
|
||||
],
|
||||
"swoConfig": {
|
||||
"enabled": false,
|
||||
"source": "probe",
|
||||
"swoFrequency": 0,
|
||||
"cpuFrequency": 0,
|
||||
"decoders": [
|
||||
{
|
||||
"port": 0,
|
||||
"type": "console",
|
||||
"label": "SWO output",
|
||||
"encoding": "ascii"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
27
.vscode/settings.json
vendored
Normal file
27
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"freertos.h": "c",
|
||||
"portable.h": "c",
|
||||
"portmacro.h": "c"
|
||||
},
|
||||
"cortex-debug.JLinkGDBServerPath": "/home/cluzel/.JLink/JLinkGDBServer",
|
||||
"C_Cpp.default.includePath": [
|
||||
"${default}",
|
||||
"${workspaceFolder}/src",
|
||||
"${workspaceFolder}/src/third_party/cmsis/include",
|
||||
"${workspaceFolder}/src/third_party/st/devices/stm32f7xx",
|
||||
"${workspaceFolder}/src/third_party/st/drivers/stm32f7xx_hal_driver/inc",
|
||||
"${workspaceFolder}/src/third_party/st/boards/stm32f769i_discovery",
|
||||
"${workspaceFolder}/src/third_party/freertos/include",
|
||||
"${workspaceFolder}/src/third_party/freertos/portable/gcc/arm_cm7/r0p1",
|
||||
"${workspaceFolder}/src/common",
|
||||
"${workspaceFolder}/src/cyclone_tcp",
|
||||
],
|
||||
"C_Cpp.default.defines": [
|
||||
"${default}",
|
||||
"STM32F769xx",
|
||||
"USE_HAL_DRIVER",
|
||||
"USE_STM32F769I_DISCO",
|
||||
"__error_t_defined"
|
||||
]
|
||||
}
|
||||
399
Makefile
Normal file
399
Makefile
Normal file
@@ -0,0 +1,399 @@
|
||||
RESULT ?= http_client_demo
|
||||
|
||||
DEFINES = \
|
||||
-DSTM32F769xx \
|
||||
-DUSE_HAL_DRIVER \
|
||||
-DUSE_STM32F769I_DISCO \
|
||||
-D_WINSOCK_H \
|
||||
-D__error_t_defined
|
||||
|
||||
INCLUDES = \
|
||||
-I./src \
|
||||
-I./src/third_party/cmsis/include \
|
||||
-I./src/third_party/st/devices/stm32f7xx \
|
||||
-I./src/third_party/st/drivers/stm32f7xx_hal_driver/inc \
|
||||
-I./src/third_party/st/boards/stm32f769i_discovery \
|
||||
-I./src/third_party/freertos/include \
|
||||
-I./src/third_party/freertos/portable/gcc/arm_cm7/r0p1 \
|
||||
-I./src/common \
|
||||
-I./src/cyclone_tcp \
|
||||
-I./src/cyclone_ssl \
|
||||
-I./src/cyclone_crypto
|
||||
|
||||
ASM_SOURCES = \
|
||||
./src/startup_stm32f769xx.S
|
||||
|
||||
C_SOURCES = \
|
||||
./src/system_stm32f7xx.c \
|
||||
./src/stm32f7xx_it.c \
|
||||
./src/syscalls.c \
|
||||
./src/main.c \
|
||||
./src/debug.c \
|
||||
./src/common/cpu_endian.c \
|
||||
./src/common/os_port_freertos.c \
|
||||
./src/common/date_time.c \
|
||||
./src/common/str.c \
|
||||
./src/cyclone_tcp/core/net.c \
|
||||
./src/cyclone_tcp/core/net_mem.c \
|
||||
./src/cyclone_tcp/core/net_misc.c \
|
||||
./src/cyclone_tcp/drivers/mac/stm32f7xx_eth_driver.c \
|
||||
./src/cyclone_tcp/drivers/phy/lan8742_driver.c \
|
||||
./src/cyclone_tcp/core/nic.c \
|
||||
./src/cyclone_tcp/core/ethernet.c \
|
||||
./src/cyclone_tcp/core/ethernet_misc.c \
|
||||
./src/cyclone_tcp/ipv4/arp.c \
|
||||
./src/cyclone_tcp/ipv4/ipv4.c \
|
||||
./src/cyclone_tcp/ipv4/ipv4_frag.c \
|
||||
./src/cyclone_tcp/ipv4/ipv4_misc.c \
|
||||
./src/cyclone_tcp/ipv4/icmp.c \
|
||||
./src/cyclone_tcp/ipv4/igmp.c \
|
||||
./src/cyclone_tcp/ipv6/ipv6.c \
|
||||
./src/cyclone_tcp/ipv6/ipv6_frag.c \
|
||||
./src/cyclone_tcp/ipv6/ipv6_misc.c \
|
||||
./src/cyclone_tcp/ipv6/ipv6_pmtu.c \
|
||||
./src/cyclone_tcp/ipv6/icmpv6.c \
|
||||
./src/cyclone_tcp/ipv6/mld.c \
|
||||
./src/cyclone_tcp/ipv6/ndp.c \
|
||||
./src/cyclone_tcp/ipv6/ndp_cache.c \
|
||||
./src/cyclone_tcp/ipv6/ndp_misc.c \
|
||||
./src/cyclone_tcp/ipv6/slaac.c \
|
||||
./src/cyclone_tcp/core/ip.c \
|
||||
./src/cyclone_tcp/core/tcp.c \
|
||||
./src/cyclone_tcp/core/tcp_fsm.c \
|
||||
./src/cyclone_tcp/core/tcp_misc.c \
|
||||
./src/cyclone_tcp/core/tcp_timer.c \
|
||||
./src/cyclone_tcp/core/udp.c \
|
||||
./src/cyclone_tcp/core/socket.c \
|
||||
./src/cyclone_tcp/core/bsd_socket.c \
|
||||
./src/cyclone_tcp/core/raw_socket.c \
|
||||
./src/cyclone_tcp/dns/dns_cache.c \
|
||||
./src/cyclone_tcp/dns/dns_client.c \
|
||||
./src/cyclone_tcp/dns/dns_common.c \
|
||||
./src/cyclone_tcp/dns/dns_debug.c \
|
||||
./src/cyclone_tcp/mdns/mdns_client.c \
|
||||
./src/cyclone_tcp/mdns/mdns_responder.c \
|
||||
./src/cyclone_tcp/mdns/mdns_common.c \
|
||||
./src/cyclone_tcp/netbios/nbns_client.c \
|
||||
./src/cyclone_tcp/netbios/nbns_responder.c \
|
||||
./src/cyclone_tcp/netbios/nbns_common.c \
|
||||
./src/cyclone_tcp/llmnr/llmnr_client.c \
|
||||
./src/cyclone_tcp/llmnr/llmnr_responder.c \
|
||||
./src/cyclone_tcp/llmnr/llmnr_common.c \
|
||||
./src/cyclone_tcp/dhcp/dhcp_client.c \
|
||||
./src/cyclone_tcp/dhcp/dhcp_common.c \
|
||||
./src/cyclone_tcp/dhcp/dhcp_debug.c \
|
||||
./src/cyclone_tcp/ftp/ftp_client.c \
|
||||
./src/cyclone_tcp/ftp/ftp_client_transport.c \
|
||||
./src/cyclone_tcp/ftp/ftp_client_misc.c \
|
||||
./src/third_party/freertos/portable/gcc/arm_cm7/r0p1/port.c \
|
||||
./src/third_party/freertos/croutine.c \
|
||||
./src/third_party/freertos/list.c \
|
||||
./src/third_party/freertos/queue.c \
|
||||
./src/third_party/freertos/tasks.c \
|
||||
./src/third_party/freertos/timers.c \
|
||||
./src/third_party/freertos/portable/memmang/heap_3.c \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery.c \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_audio.c \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_eeprom.c \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_lcd.c \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_qspi.c \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_sd.c \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_sdram.c \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_ts.c \
|
||||
./src/third_party/st/boards/components/ft6x06/ft6x06.c \
|
||||
./src/third_party/st/boards/components/otm8009a/otm8009a.c \
|
||||
./src/third_party/st/boards/components/wm8994/wm8994.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_adc.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_adc_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_can.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_cec.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_cortex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_crc.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_crc_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_cryp.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_cryp_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_dac.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_dac_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_dcmi.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_dcmi_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_dfsdm.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_dma.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_dma_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_dma2d.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_dsi.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_eth.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_flash.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_flash_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_gpio.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_hash.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_hash_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_hcd.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_i2c.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_i2c_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_i2s.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_irda.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_iwdg.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_jpeg.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_lptim.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_ltdc.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_ltdc_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_mdios.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_nand.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_nor.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_pcd.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_pcd_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_pwr.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_pwr_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_qspi.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_rcc.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_rcc_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_rng.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_rtc.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_rtc_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_sai.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_sai_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_sd.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_sdram.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_smartcard.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_smartcard_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_spdifrx.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_spi.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_sram.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_tim.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_tim_ex.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_uart.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_usart.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_hal_wwdg.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_ll_fmc.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_ll_sdmmc.c \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/src/stm32f7xx_ll_usb.c
|
||||
|
||||
HEADERS = \
|
||||
./src/os_port_config.h \
|
||||
./src/net_config.h \
|
||||
./src/FreeRTOSConfig.h \
|
||||
./src/stm32f7xx_hal_conf.h \
|
||||
./src/stm32f7xx_it.h \
|
||||
./src/common/cpu_endian.h \
|
||||
./src/common/os_port.h \
|
||||
./src/common/os_port_freertos.h \
|
||||
./src/common/date_time.h \
|
||||
./src/common/str.h \
|
||||
./src/common/error.h \
|
||||
./src/common/debug.h \
|
||||
./src/cyclone_tcp/core/net.h \
|
||||
./src/cyclone_tcp/core/net_mem.h \
|
||||
./src/cyclone_tcp/core/net_misc.h \
|
||||
./src/cyclone_tcp/drivers/mac/stm32f7xx_eth_driver.h \
|
||||
./src/cyclone_tcp/drivers/phy/lan8742_driver.h \
|
||||
./src/cyclone_tcp/core/nic.h \
|
||||
./src/cyclone_tcp/core/ethernet.h \
|
||||
./src/cyclone_tcp/core/ethernet_misc.h \
|
||||
./src/cyclone_tcp/ipv4/arp.h \
|
||||
./src/cyclone_tcp/ipv4/ipv4.h \
|
||||
./src/cyclone_tcp/ipv4/ipv4_frag.h \
|
||||
./src/cyclone_tcp/ipv4/ipv4_misc.h \
|
||||
./src/cyclone_tcp/ipv4/icmp.h \
|
||||
./src/cyclone_tcp/ipv4/igmp.h \
|
||||
./src/cyclone_tcp/ipv6/ipv6.h \
|
||||
./src/cyclone_tcp/ipv6/ipv6_frag.h \
|
||||
./src/cyclone_tcp/ipv6/ipv6_misc.h \
|
||||
./src/cyclone_tcp/ipv6/ipv6_pmtu.h \
|
||||
./src/cyclone_tcp/ipv6/icmpv6.h \
|
||||
./src/cyclone_tcp/ipv6/mld.h \
|
||||
./src/cyclone_tcp/ipv6/ndp.h \
|
||||
./src/cyclone_tcp/ipv6/ndp_cache.h \
|
||||
./src/cyclone_tcp/ipv6/ndp_misc.h \
|
||||
./src/cyclone_tcp/ipv6/slaac.h \
|
||||
./src/cyclone_tcp/core/ip.h \
|
||||
./src/cyclone_tcp/core/tcp.h \
|
||||
./src/cyclone_tcp/core/tcp_fsm.h \
|
||||
./src/cyclone_tcp/core/tcp_misc.h \
|
||||
./src/cyclone_tcp/core/tcp_timer.h \
|
||||
./src/cyclone_tcp/core/udp.h \
|
||||
./src/cyclone_tcp/core/socket.h \
|
||||
./src/cyclone_tcp/core/bsd_socket.h \
|
||||
./src/cyclone_tcp/core/raw_socket.h \
|
||||
./src/cyclone_tcp/dns/dns_cache.h \
|
||||
./src/cyclone_tcp/dns/dns_client.h \
|
||||
./src/cyclone_tcp/dns/dns_common.h \
|
||||
./src/cyclone_tcp/dns/dns_debug.h \
|
||||
./src/cyclone_tcp/mdns/mdns_client.h \
|
||||
./src/cyclone_tcp/mdns/mdns_responder.h \
|
||||
./src/cyclone_tcp/mdns/mdns_common.h \
|
||||
./src/cyclone_tcp/netbios/nbns_client.h \
|
||||
./src/cyclone_tcp/netbios/nbns_responder.h \
|
||||
./src/cyclone_tcp/netbios/nbns_common.h \
|
||||
./src/cyclone_tcp/llmnr/llmnr_client.h \
|
||||
./src/cyclone_tcp/llmnr/llmnr_responder.h \
|
||||
./src/cyclone_tcp/llmnr/llmnr_common.h \
|
||||
./src/cyclone_tcp/dhcp/dhcp_client.h \
|
||||
./src/cyclone_tcp/dhcp/dhcp_common.h \
|
||||
./src/cyclone_tcp/dhcp/dhcp_debug.h \
|
||||
./src/cyclone_tcp/ftp/ftp_client.h \
|
||||
./src/cyclone_tcp/ftp/ftp_client_transport.h \
|
||||
./src/cyclone_tcp/ftp/ftp_client_misc.h \
|
||||
./src/third_party/freertos/portable/gcc/arm_cm7/r0p1/portmacro.h \
|
||||
./src/third_party/freertos/include/croutine.h \
|
||||
./src/third_party/freertos/include/FreeRTOS.h \
|
||||
./src/third_party/freertos/include/list.h \
|
||||
./src/third_party/freertos/include/mpu_wrappers.h \
|
||||
./src/third_party/freertos/include/portable.h \
|
||||
./src/third_party/freertos/include/projdefs.h \
|
||||
./src/third_party/freertos/include/queue.h \
|
||||
./src/third_party/freertos/include/semphr.h \
|
||||
./src/third_party/freertos/include/stack_macros.h \
|
||||
./src/third_party/freertos/include/task.h \
|
||||
./src/third_party/freertos/include/timers.h \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery.h \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_audio.h \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_eeprom.h \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_lcd.h \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_qspi.h \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_sd.h \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_sdram.h \
|
||||
./src/third_party/st/boards/stm32f769i_discovery/stm32f769i_discovery_ts.h \
|
||||
./src/third_party/st/boards/components/adv7533/adv7533.h \
|
||||
./src/third_party/st/boards/components/ft6x06/ft6x06.h \
|
||||
./src/third_party/st/boards/components/mx25l512/mx25l512.h \
|
||||
./src/third_party/st/boards/components/otm8009a/otm8009a.h \
|
||||
./src/third_party/st/boards/components/wm8994/wm8994.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_adc.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_adc_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_can.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_cec.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_cortex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_crc.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_crc_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_cryp.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_cryp_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_dac.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_dac_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_dcmi.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_dcmi_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_def.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_dfsdm.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_dma.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_dma_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_dma2d.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_dsi.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_eth.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_flash.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_flash_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_gpio.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_gpio_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_hash.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_hash_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_hcd.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_i2c.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_i2c_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_i2s.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_irda.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_irda_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_iwdg.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_jpeg.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_lptim.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_ltdc.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_ltdc_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_mdios.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_nand.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_nor.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_pcd.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_pcd_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_pwr.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_pwr_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_qspi.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_rcc.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_rcc_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_rng.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_rtc.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_rtc_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_sai.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_sai_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_sd.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_sdram.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_smartcard.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_smartcard_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_spdifrx.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_spi.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_sram.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_tim.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_tim_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_uart.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_uart_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_usart.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_usart_ex.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_hal_wwdg.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_ll_fmc.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_ll_sdmmc.h \
|
||||
./src/third_party/st/drivers/stm32f7xx_hal_driver/inc/stm32f7xx_ll_usb.h
|
||||
|
||||
ASM_OBJECTS = $(patsubst %.S, %.o, $(ASM_SOURCES))
|
||||
|
||||
C_OBJECTS = $(patsubst %.c, %.o, $(C_SOURCES))
|
||||
|
||||
OBJ_DIR = obj
|
||||
|
||||
LINKER_SCRIPT = src/stm32f769_flash.ld
|
||||
|
||||
CFLAGS += -fno-common -Wall -Os -g3
|
||||
CFLAGS += -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard
|
||||
CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections
|
||||
CFLAGS += $(DEFINES)
|
||||
CFLAGS += $(INCLUDES)
|
||||
|
||||
CROSS_COMPILE ?= arm-none-eabi-
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
OBJDUMP = $(CROSS_COMPILE)objdump
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
SIZE = $(CROSS_COMPILE)size
|
||||
|
||||
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
|
||||
all: build size
|
||||
|
||||
install: build size program
|
||||
|
||||
build: $(RESULT).elf $(RESULT).lst $(RESULT).bin $(RESULT).hex
|
||||
|
||||
$(RESULT).elf: $(ASM_OBJECTS) $(C_OBJECTS) $(HEADERS) $(LINKER_SCRIPT) $(THIS_MAKEFILE)
|
||||
$(CC) -Wl,-M=$(RESULT).map -Wl,-T$(LINKER_SCRIPT) $(CFLAGS) $(addprefix $(OBJ_DIR)/, $(notdir $(ASM_OBJECTS))) $(addprefix $(OBJ_DIR)/, $(notdir $(C_OBJECTS))) -o $@
|
||||
|
||||
$(ASM_OBJECTS): | $(OBJ_DIR)
|
||||
|
||||
$(C_OBJECTS): | $(OBJ_DIR)
|
||||
|
||||
$(OBJ_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
%.o: %.c $(HEADERS) $(THIS_MAKEFILE)
|
||||
$(CC) $(CFLAGS) -c $< -o $(addprefix $(OBJ_DIR)/, $(notdir $@))
|
||||
|
||||
%.o: %.S $(HEADERS) $(THIS_MAKEFILE)
|
||||
$(CC) $(CFLAGS) -c $< -o $(addprefix $(OBJ_DIR)/, $(notdir $@))
|
||||
|
||||
%.lst: %.elf
|
||||
$(OBJDUMP) -x -S $(RESULT).elf > $@
|
||||
|
||||
%.bin: %.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
%.hex: %.elf
|
||||
$(OBJCOPY) -O ihex $< $@
|
||||
|
||||
size: $(RESULT).elf
|
||||
$(SIZE) $(RESULT).elf
|
||||
|
||||
flash:
|
||||
openocd -f board/stm32f7discovery.cfg -c "init; reset halt; flash write_image erase $(RESULT).bin 0x08000000; reset run; shutdown"
|
||||
|
||||
clean:
|
||||
rm -f $(RESULT).elf
|
||||
rm -f $(RESULT).bin
|
||||
rm -f $(RESULT).map
|
||||
rm -f $(RESULT).hex
|
||||
rm -f $(RESULT).lst
|
||||
rm -f $(OBJ_DIR)/*.o
|
||||
15
README.md
Normal file
15
README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
HTTP Client
|
||||
===========
|
||||
|
||||
This HTTP Client is based on Oryx-Embedded Cyclone TCP library
|
||||
(https://oryx-embedded.com).
|
||||
It is made to compile on STM32F769I-dicovery plateform.
|
||||
|
||||
Compilation
|
||||
-----------
|
||||
|
||||
Use `make` to compile the project, and `make flash` to install in
|
||||
on the STM32 card.
|
||||
|
||||
You can see the debug messages by opening a terminal on the card
|
||||
with `minicom -D /dev/ttyACM0`.
|
||||
131
src/FreeRTOSConfig.h
Normal file
131
src/FreeRTOSConfig.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* If you are: *
|
||||
* *
|
||||
* + New to FreeRTOS, *
|
||||
* + Wanting to learn FreeRTOS or multitasking in general quickly *
|
||||
* + Looking for basic training, *
|
||||
* + Wanting to improve your FreeRTOS skills and productivity *
|
||||
* *
|
||||
* then take a look at the FreeRTOS eBook *
|
||||
* *
|
||||
* "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
* A pdf reference manual is also available. Both are usually delivered *
|
||||
* to your inbox within 20 minutes to two hours when purchased between 8am *
|
||||
* and 8pm GMT (although please allow up to 24 hours in case of *
|
||||
* exceptional circumstances). Thank you for your support! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||
***NOTE*** The exception to the GPL is included to allow you to distribute
|
||||
a combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details. You should have received a copy of the GNU General Public
|
||||
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||
by writing to Richard Barry, contact details for whom are available on the
|
||||
FreeRTOS WEB site.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
//Keil MDK-ARM, IAR EWARM or GCC compiler?
|
||||
#if (defined(__CC_ARM) || defined(__ICCARM__) || defined(__GNUC__))
|
||||
|
||||
#include <stdint.h>
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||
#define configMAX_PRIORITIES ( 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 400 )
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_APPLICATION_TASK_TAG 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||
#define configGENERATE_RUN_TIME_STATS 0
|
||||
//#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS init_us_timer
|
||||
//#define portGET_RUN_TIME_COUNTER_VALUE get_us_time
|
||||
|
||||
/* Co-routine definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. */
|
||||
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 1
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
|
||||
/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255
|
||||
(lowest) to 0 (1?) (highest). */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY 255
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */
|
||||
|
||||
/* This is the value being used as per the ST library which permits 16
|
||||
priority values, 0 to 15. This must correspond to the
|
||||
configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest
|
||||
NVIC value of 255. */
|
||||
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15
|
||||
|
||||
/* Redefine functions names to match the standard peripheral library */
|
||||
//#define xPortSysTickHandler SysTick_Handler
|
||||
#define xPortPendSVHandler PendSV_Handler
|
||||
#define vPortSVCHandler SVC_Handler
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
|
||||
169
src/common/compiler_port.h
Normal file
169
src/common/compiler_port.h
Normal file
@@ -0,0 +1,169 @@
|
||||
/**
|
||||
* @file compiler_port.h
|
||||
* @brief Compiler specific definitions
|
||||
*
|
||||
* @section License
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @author Oryx Embedded SARL (www.oryx-embedded.com)
|
||||
* @version 1.9.7b
|
||||
**/
|
||||
|
||||
#ifndef _COMPILER_PORT_H
|
||||
#define _COMPILER_PORT_H
|
||||
|
||||
//Dependencies
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//Types
|
||||
typedef char char_t;
|
||||
typedef signed int int_t;
|
||||
typedef unsigned int uint_t;
|
||||
typedef uint32_t systime_t;
|
||||
|
||||
#if !defined(R_TYPEDEFS_H) && !defined(USE_CHIBIOS_2)
|
||||
typedef int bool_t;
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#define PRIuSIZE "zu"
|
||||
#define PRIXSIZE "zX"
|
||||
#define PRIuTIME "lu"
|
||||
#elif defined(_WIN32)
|
||||
#define PRIuSIZE "Iu"
|
||||
#define PRIXSIZE "IX"
|
||||
#define PRIuTIME "lu"
|
||||
#elif defined(__XC32)
|
||||
#define PRIuSIZE "u"
|
||||
#define PRIXSIZE "X"
|
||||
#define PRIuTIME "u"
|
||||
#elif defined(__CWCC__)
|
||||
#define PRIu8 "u"
|
||||
#define PRIu16 "u"
|
||||
#define PRIu32 "u"
|
||||
#define PRIx8 "x"
|
||||
#define PRIx16 "x"
|
||||
#define PRIx32 "x"
|
||||
#define PRIX8 "X"
|
||||
#define PRIX16 "X"
|
||||
#define PRIX32 "X"
|
||||
#define PRIuSIZE "u"
|
||||
#define PRIXSIZE "X"
|
||||
#define PRIuTIME "u"
|
||||
#else
|
||||
#define PRIuSIZE "u"
|
||||
#define PRIXSIZE "X"
|
||||
#define PRIuTIME "lu"
|
||||
#endif
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
#undef PRIu8
|
||||
#define PRIu8 "u"
|
||||
#undef PRIu16
|
||||
#define PRIu16 "u"
|
||||
#endif
|
||||
|
||||
//ARM compiler V6?
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
char *strtok_r(char *s, const char *delim, char **last);
|
||||
//CodeWarrior compiler?
|
||||
#elif defined(__CWCC__)
|
||||
typedef uint32_t time_t;
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
char *strtok_r(char *s, const char *delim, char **last);
|
||||
//TI ARM compiler?
|
||||
#elif defined(__TI_ARM__)
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
char *strtok_r(char *s, const char *delim, char **last);
|
||||
//Microchip XC32 compiler?
|
||||
#elif defined(__XC32)
|
||||
#define sprintf _sprintf
|
||||
int sprintf(char * str, const char * format, ...);
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
char *strtok_r(char *s, const char *delim, char **last);
|
||||
#endif
|
||||
|
||||
//ARM compiler V6?
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#undef __start_packed
|
||||
#define __start_packed
|
||||
#undef __end_packed
|
||||
#define __end_packed __attribute__((packed))
|
||||
#define __weak __attribute__((weak))
|
||||
//ARM compiler?
|
||||
#elif defined(__CC_ARM)
|
||||
#pragma anon_unions
|
||||
#undef __start_packed
|
||||
#define __start_packed __packed
|
||||
#undef __end_packed
|
||||
#define __end_packed
|
||||
//IAR compiler?
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#undef __start_packed
|
||||
#define __start_packed __packed
|
||||
#undef __end_packed
|
||||
#define __end_packed
|
||||
//GCC compiler?
|
||||
#elif defined(__GNUC__)
|
||||
#undef __start_packed
|
||||
#define __start_packed
|
||||
#undef __end_packed
|
||||
#define __end_packed __attribute__((__packed__))
|
||||
#define __weak __attribute__((weak))
|
||||
//CodeWarrior compiler?
|
||||
#elif defined(__CWCC__)
|
||||
#undef __start_packed
|
||||
#define __start_packed
|
||||
#undef __end_packed
|
||||
#define __end_packed
|
||||
#define __weak
|
||||
//TI ARM compiler?
|
||||
#elif defined(__TI_ARM__)
|
||||
#undef __start_packed
|
||||
#define __start_packed
|
||||
#undef __end_packed
|
||||
#define __end_packed __attribute__((__packed__))
|
||||
#define __weak
|
||||
//Win32 compiler?
|
||||
#elif defined(_WIN32)
|
||||
#undef interface
|
||||
#undef __start_packed
|
||||
#define __start_packed
|
||||
#undef __end_packed
|
||||
#define __end_packed
|
||||
#define __weak
|
||||
#endif
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
151
src/common/cpu_endian.c
Normal file
151
src/common/cpu_endian.c
Normal file
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* @file cpu_endian.c
|
||||
* @brief Byte order conversion
|
||||
*
|
||||
* @section License
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @author Oryx Embedded SARL (www.oryx-embedded.com)
|
||||
* @version 1.9.7b
|
||||
**/
|
||||
|
||||
//Dependencies
|
||||
#include "cpu_endian.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reverse the byte order of a 16-bit word
|
||||
* @param[in] value 16-bit value
|
||||
* @return 16-bit value with byte order swapped
|
||||
**/
|
||||
|
||||
uint16_t swapInt16(uint16_t value)
|
||||
{
|
||||
return SWAPINT16(value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reverse the byte order of a 32-bit word
|
||||
* @param[in] value 32-bit value
|
||||
* @return 32-bit value with byte order swapped
|
||||
**/
|
||||
|
||||
uint32_t swapInt32(uint32_t value)
|
||||
{
|
||||
return SWAPINT32(value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reverse the byte order of a 64-bit word
|
||||
* @param[in] value 64-bit value
|
||||
* @return 64-bit value with byte order swapped
|
||||
**/
|
||||
|
||||
uint64_t swapInt64(uint64_t value)
|
||||
{
|
||||
return SWAPINT64(value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reverse bit order in a 4-bit word
|
||||
* @param[in] value 4-bit value
|
||||
* @return 4-bit value with bit order reversed
|
||||
**/
|
||||
|
||||
uint8_t reverseInt4(uint8_t value)
|
||||
{
|
||||
value = ((value & 0x0C) >> 2) | ((value & 0x03) << 2);
|
||||
value = ((value & 0x0A) >> 1) | ((value & 0x05) << 1);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reverse bit order in a byte
|
||||
* @param[in] value 8-bit value
|
||||
* @return 8-bit value with bit order reversed
|
||||
**/
|
||||
|
||||
uint8_t reverseInt8(uint8_t value)
|
||||
{
|
||||
value = ((value & 0xF0) >> 4) | ((value & 0x0F) << 4);
|
||||
value = ((value & 0xCC) >> 2) | ((value & 0x33) << 2);
|
||||
value = ((value & 0xAA) >> 1) | ((value & 0x55) << 1);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reverse bit order in a 16-bit word
|
||||
* @param[in] value 16-bit value
|
||||
* @return 16-bit value with bit order reversed
|
||||
**/
|
||||
|
||||
uint16_t reverseInt16(uint16_t value)
|
||||
{
|
||||
value = ((value & 0xFF00) >> 8) | ((value & 0x00FF) << 8);
|
||||
value = ((value & 0xF0F0) >> 4) | ((value & 0x0F0F) << 4);
|
||||
value = ((value & 0xCCCC) >> 2) | ((value & 0x3333) << 2);
|
||||
value = ((value & 0xAAAA) >> 1) | ((value & 0x5555) << 1);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reverse bit order in a 32-bit word
|
||||
* @param[in] value 32-bit value
|
||||
* @return 32-bit value with bit order reversed
|
||||
**/
|
||||
|
||||
uint32_t reverseInt32(uint32_t value)
|
||||
{
|
||||
value = ((value & 0xFFFF0000UL) >> 16) | ((value & 0x0000FFFFUL) << 16);
|
||||
value = ((value & 0xFF00FF00UL) >> 8) | ((value & 0x00FF00FFUL) << 8);
|
||||
value = ((value & 0xF0F0F0F0UL) >> 4) | ((value & 0x0F0F0F0FUL) << 4);
|
||||
value = ((value & 0xCCCCCCCCUL) >> 2) | ((value & 0x33333333UL) << 2);
|
||||
value = ((value & 0xAAAAAAAAUL) >> 1) | ((value & 0x55555555UL) << 1);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reverse bit order in a 64-bit word
|
||||
* @param[in] value 64-bit value
|
||||
* @return 64-bit value with bit order reversed
|
||||
**/
|
||||
|
||||
uint64_t reverseInt64(uint64_t value)
|
||||
{
|
||||
value = ((value & 0xFFFFFFFF00000000ULL) >> 32) | ((value & 0x00000000FFFFFFFFULL) << 32);
|
||||
value = ((value & 0xFFFF0000FFFF0000ULL) >> 16) | ((value & 0x0000FFFF0000FFFFULL) << 16);
|
||||
value = ((value & 0xFF00FF00FF00FF00ULL) >> 8) | ((value & 0x00FF00FF00FF00FFULL) << 8);
|
||||
value = ((value & 0xF0F0F0F0F0F0F0F0ULL) >> 4) | ((value & 0x0F0F0F0F0F0F0F0FULL) << 4);
|
||||
value = ((value & 0xCCCCCCCCCCCCCCCCULL) >> 2) | ((value & 0x3333333333333333ULL) << 2);
|
||||
value = ((value & 0xAAAAAAAAAAAAAAAAULL) >> 1) | ((value & 0x5555555555555555ULL) << 1);
|
||||
|
||||
return value;
|
||||
}
|
||||
457
src/common/cpu_endian.h
Normal file
457
src/common/cpu_endian.h
Normal file
@@ -0,0 +1,457 @@
|
||||
/**
|
||||
* @file cpu_endian.h
|
||||
* @brief Byte order conversion
|
||||
*
|
||||
* @section License
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @author Oryx Embedded SARL (www.oryx-embedded.com)
|
||||
* @version 1.9.7b
|
||||
**/
|
||||
|
||||
#ifndef _CPU_ENDIAN_H
|
||||
#define _CPU_ENDIAN_H
|
||||
|
||||
//Dependencies
|
||||
#include "os_port.h"
|
||||
|
||||
//Undefine conflicting definitions
|
||||
#ifdef HTONS
|
||||
#undef HTONS
|
||||
#endif
|
||||
|
||||
#ifdef HTONL
|
||||
#undef HTONL
|
||||
#endif
|
||||
|
||||
#ifdef htons
|
||||
#undef htons
|
||||
#endif
|
||||
|
||||
#ifdef htonl
|
||||
#undef htonl
|
||||
#endif
|
||||
|
||||
#ifdef NTOHS
|
||||
#undef NTOHS
|
||||
#endif
|
||||
|
||||
#ifdef NTOHL
|
||||
#undef NTOHL
|
||||
#endif
|
||||
|
||||
#ifdef ntohs
|
||||
#undef ntohs
|
||||
#endif
|
||||
|
||||
#ifdef ntohl
|
||||
#undef ntohl
|
||||
#endif
|
||||
|
||||
#ifdef HTOLE16
|
||||
#undef HTOLE16
|
||||
#endif
|
||||
|
||||
#ifdef HTOLE32
|
||||
#undef HTOLE32
|
||||
#endif
|
||||
|
||||
#ifdef HTOLE64
|
||||
#undef HTOLE64
|
||||
#endif
|
||||
|
||||
#ifdef htole16
|
||||
#undef htole16
|
||||
#endif
|
||||
|
||||
#ifdef htole32
|
||||
#undef htole32
|
||||
#endif
|
||||
|
||||
#ifdef htole64
|
||||
#undef htole64
|
||||
#endif
|
||||
|
||||
#ifdef LETOH16
|
||||
#undef LETOH16
|
||||
#endif
|
||||
|
||||
#ifdef LETOH32
|
||||
#undef LETOH32
|
||||
#endif
|
||||
|
||||
#ifdef LETOH64
|
||||
#undef LETOH64
|
||||
#endif
|
||||
|
||||
#ifdef letoh16
|
||||
#undef letoh16
|
||||
#endif
|
||||
|
||||
#ifdef letoh32
|
||||
#undef letoh32
|
||||
#endif
|
||||
|
||||
#ifdef letoh64
|
||||
#undef letoh64
|
||||
#endif
|
||||
|
||||
#ifdef HTOBE16
|
||||
#undef HTOBE16
|
||||
#endif
|
||||
|
||||
#ifdef HTOBE32
|
||||
#undef HTOBE32
|
||||
#endif
|
||||
|
||||
#ifdef HTOBE64
|
||||
#undef HTOBE64
|
||||
#endif
|
||||
|
||||
#ifdef htobe16
|
||||
#undef htobe16
|
||||
#endif
|
||||
|
||||
#ifdef htobe32
|
||||
#undef htobe32
|
||||
#endif
|
||||
|
||||
#ifdef htobe64
|
||||
#undef htobe64
|
||||
#endif
|
||||
|
||||
#ifdef BETOH16
|
||||
#undef BETOH16
|
||||
#endif
|
||||
|
||||
#ifdef BETOH32
|
||||
#undef BETOH32
|
||||
#endif
|
||||
|
||||
#ifdef BETOH64
|
||||
#undef BETOH64
|
||||
#endif
|
||||
|
||||
#ifdef betoh16
|
||||
#undef betoh16
|
||||
#endif
|
||||
|
||||
#ifdef betoh32
|
||||
#undef betoh32
|
||||
#endif
|
||||
|
||||
#ifdef betoh64
|
||||
#undef betoh64
|
||||
#endif
|
||||
|
||||
//Load unaligned 16-bit integer (little-endian encoding)
|
||||
#define LOAD16LE(p) ( \
|
||||
((uint16_t)(((uint8_t *)(p))[0]) << 0) | \
|
||||
((uint16_t)(((uint8_t *)(p))[1]) << 8))
|
||||
|
||||
//Load unaligned 16-bit integer (big-endian encoding)
|
||||
#define LOAD16BE(p) ( \
|
||||
((uint16_t)(((uint8_t *)(p))[0]) << 8) | \
|
||||
((uint16_t)(((uint8_t *)(p))[1]) << 0))
|
||||
|
||||
//Load unaligned 24-bit integer (little-endian encoding)
|
||||
#define LOAD24LE(p) ( \
|
||||
((uint32_t)(((uint8_t *)(p))[0]) << 0)| \
|
||||
((uint32_t)(((uint8_t *)(p))[1]) << 8) | \
|
||||
((uint32_t)(((uint8_t *)(p))[2]) << 16))
|
||||
|
||||
//Load unaligned 24-bit integer (big-endian encoding)
|
||||
#define LOAD24BE(p) ( \
|
||||
((uint32_t)(((uint8_t *)(p))[0]) << 16) | \
|
||||
((uint32_t)(((uint8_t *)(p))[1]) << 8) | \
|
||||
((uint32_t)(((uint8_t *)(p))[2]) << 0))
|
||||
|
||||
//Load unaligned 32-bit integer (little-endian encoding)
|
||||
#define LOAD32LE(p) ( \
|
||||
((uint32_t)(((uint8_t *)(p))[0]) << 0) | \
|
||||
((uint32_t)(((uint8_t *)(p))[1]) << 8) | \
|
||||
((uint32_t)(((uint8_t *)(p))[2]) << 16) | \
|
||||
((uint32_t)(((uint8_t *)(p))[3]) << 24))
|
||||
|
||||
//Load unaligned 32-bit integer (big-endian encoding)
|
||||
#define LOAD32BE(p) ( \
|
||||
((uint32_t)(((uint8_t *)(p))[0]) << 24) | \
|
||||
((uint32_t)(((uint8_t *)(p))[1]) << 16) | \
|
||||
((uint32_t)(((uint8_t *)(p))[2]) << 8) | \
|
||||
((uint32_t)(((uint8_t *)(p))[3]) << 0))
|
||||
|
||||
//Load unaligned 48-bit integer (little-endian encoding)
|
||||
#define LOAD48LE(p) ( \
|
||||
((uint64_t)(((uint8_t *)(p))[0]) << 0) | \
|
||||
((uint64_t)(((uint8_t *)(p))[1]) << 8) | \
|
||||
((uint64_t)(((uint8_t *)(p))[2]) << 16) | \
|
||||
((uint64_t)(((uint8_t *)(p))[3]) << 24) | \
|
||||
((uint64_t)(((uint8_t *)(p))[4]) << 32) | \
|
||||
((uint64_t)(((uint8_t *)(p))[5]) << 40)
|
||||
|
||||
//Load unaligned 48-bit integer (big-endian encoding)
|
||||
#define LOAD48BE(p) ( \
|
||||
((uint64_t)(((uint8_t *)(p))[0]) << 40) | \
|
||||
((uint64_t)(((uint8_t *)(p))[1]) << 32) | \
|
||||
((uint64_t)(((uint8_t *)(p))[2]) << 24) | \
|
||||
((uint64_t)(((uint8_t *)(p))[3]) << 16) | \
|
||||
((uint64_t)(((uint8_t *)(p))[4]) << 8) | \
|
||||
((uint64_t)(((uint8_t *)(p))[5]) << 0))
|
||||
|
||||
//Load unaligned 64-bit integer (little-endian encoding)
|
||||
#define LOAD64LE(p) ( \
|
||||
((uint64_t)(((uint8_t *)(p))[0]) << 0) | \
|
||||
((uint64_t)(((uint8_t *)(p))[1]) << 8) | \
|
||||
((uint64_t)(((uint8_t *)(p))[2]) << 16) | \
|
||||
((uint64_t)(((uint8_t *)(p))[3]) << 24) | \
|
||||
((uint64_t)(((uint8_t *)(p))[4]) << 32) | \
|
||||
((uint64_t)(((uint8_t *)(p))[5]) << 40) | \
|
||||
((uint64_t)(((uint8_t *)(p))[6]) << 48) | \
|
||||
((uint64_t)(((uint8_t *)(p))[7]) << 56))
|
||||
|
||||
//Load unaligned 64-bit integer (big-endian encoding)
|
||||
#define LOAD64BE(p) ( \
|
||||
((uint64_t)(((uint8_t *)(p))[0]) << 56) | \
|
||||
((uint64_t)(((uint8_t *)(p))[1]) << 48) | \
|
||||
((uint64_t)(((uint8_t *)(p))[2]) << 40) | \
|
||||
((uint64_t)(((uint8_t *)(p))[3]) << 32) | \
|
||||
((uint64_t)(((uint8_t *)(p))[4]) << 24) | \
|
||||
((uint64_t)(((uint8_t *)(p))[5]) << 16) | \
|
||||
((uint64_t)(((uint8_t *)(p))[6]) << 8) | \
|
||||
((uint64_t)(((uint8_t *)(p))[7]) << 0))
|
||||
|
||||
//Store unaligned 16-bit integer (little-endian encoding)
|
||||
#define STORE16LE(a, p) \
|
||||
((uint8_t *)(p))[0] = ((uint16_t)(a) >> 0) & 0xFFU, \
|
||||
((uint8_t *)(p))[1] = ((uint16_t)(a) >> 8) & 0xFFU
|
||||
|
||||
//Store unaligned 32-bit integer (big-endian encoding)
|
||||
#define STORE16BE(a, p) \
|
||||
((uint8_t *)(p))[0] = ((uint16_t)(a) >> 8) & 0xFFU, \
|
||||
((uint8_t *)(p))[1] = ((uint16_t)(a) >> 0) & 0xFFU
|
||||
|
||||
//Store unaligned 24-bit integer (little-endian encoding)
|
||||
#define STORE24LE(a, p) \
|
||||
((uint8_t *)(p))[0] = ((uint32_t)(a) >> 0) & 0xFFU, \
|
||||
((uint8_t *)(p))[1] = ((uint32_t)(a) >> 8) & 0xFFU, \
|
||||
((uint8_t *)(p))[2] = ((uint32_t)(a) >> 16) & 0xFFU
|
||||
|
||||
//Store unaligned 24-bit integer (big-endian encoding)
|
||||
#define STORE24BE(a, p) \
|
||||
((uint8_t *)(p))[0] = ((uint32_t)(a) >> 16) & 0xFFU, \
|
||||
((uint8_t *)(p))[1] = ((uint32_t)(a) >> 8) & 0xFFU, \
|
||||
((uint8_t *)(p))[2] = ((uint32_t)(a) >> 0) & 0xFFU
|
||||
|
||||
//Store unaligned 32-bit integer (little-endian encoding)
|
||||
#define STORE32LE(a, p) \
|
||||
((uint8_t *)(p))[0] = ((uint32_t)(a) >> 0) & 0xFFU, \
|
||||
((uint8_t *)(p))[1] = ((uint32_t)(a) >> 8) & 0xFFU, \
|
||||
((uint8_t *)(p))[2] = ((uint32_t)(a) >> 16) & 0xFFU, \
|
||||
((uint8_t *)(p))[3] = ((uint32_t)(a) >> 24) & 0xFFU
|
||||
|
||||
//Store unaligned 32-bit integer (big-endian encoding)
|
||||
#define STORE32BE(a, p) \
|
||||
((uint8_t *)(p))[0] = ((uint32_t)(a) >> 24) & 0xFFU, \
|
||||
((uint8_t *)(p))[1] = ((uint32_t)(a) >> 16) & 0xFFU, \
|
||||
((uint8_t *)(p))[2] = ((uint32_t)(a) >> 8) & 0xFFU, \
|
||||
((uint8_t *)(p))[3] = ((uint32_t)(a) >> 0) & 0xFFU
|
||||
|
||||
//Store unaligned 48-bit integer (little-endian encoding)
|
||||
#define STORE48LE(a, p) \
|
||||
((uint8_t *)(p))[0] = ((uint64_t)(a) >> 0) & 0xFFU, \
|
||||
((uint8_t *)(p))[1] = ((uint64_t)(a) >> 8) & 0xFFU, \
|
||||
((uint8_t *)(p))[2] = ((uint64_t)(a) >> 16) & 0xFFU, \
|
||||
((uint8_t *)(p))[3] = ((uint64_t)(a) >> 24) & 0xFFU, \
|
||||
((uint8_t *)(p))[4] = ((uint64_t)(a) >> 32) & 0xFFU, \
|
||||
((uint8_t *)(p))[5] = ((uint64_t)(a) >> 40) & 0xFFU,
|
||||
|
||||
//Store unaligned 48-bit integer (big-endian encoding)
|
||||
#define STORE48BE(a, p) \
|
||||
((uint8_t *)(p))[0] = ((uint64_t)(a) >> 40) & 0xFFU, \
|
||||
((uint8_t *)(p))[1] = ((uint64_t)(a) >> 32) & 0xFFU, \
|
||||
((uint8_t *)(p))[2] = ((uint64_t)(a) >> 24) & 0xFFU, \
|
||||
((uint8_t *)(p))[3] = ((uint64_t)(a) >> 16) & 0xFFU, \
|
||||
((uint8_t *)(p))[4] = ((uint64_t)(a) >> 8) & 0xFFU, \
|
||||
((uint8_t *)(p))[5] = ((uint64_t)(a) >> 0) & 0xFFU
|
||||
|
||||
//Store unaligned 64-bit integer (little-endian encoding)
|
||||
#define STORE64LE(a, p) \
|
||||
((uint8_t *)(p))[0] = ((uint64_t)(a) >> 0) & 0xFFU, \
|
||||
((uint8_t *)(p))[1] = ((uint64_t)(a) >> 8) & 0xFFU, \
|
||||
((uint8_t *)(p))[2] = ((uint64_t)(a) >> 16) & 0xFFU, \
|
||||
((uint8_t *)(p))[3] = ((uint64_t)(a) >> 24) & 0xFFU, \
|
||||
((uint8_t *)(p))[4] = ((uint64_t)(a) >> 32) & 0xFFU, \
|
||||
((uint8_t *)(p))[5] = ((uint64_t)(a) >> 40) & 0xFFU, \
|
||||
((uint8_t *)(p))[6] = ((uint64_t)(a) >> 48) & 0xFFU, \
|
||||
((uint8_t *)(p))[7] = ((uint64_t)(a) >> 56) & 0xFFU
|
||||
|
||||
//Store unaligned 64-bit integer (big-endian encoding)
|
||||
#define STORE64BE(a, p) \
|
||||
((uint8_t *)(p))[0] = ((uint64_t)(a) >> 56) & 0xFFU, \
|
||||
((uint8_t *)(p))[1] = ((uint64_t)(a) >> 48) & 0xFFU, \
|
||||
((uint8_t *)(p))[2] = ((uint64_t)(a) >> 40) & 0xFFU, \
|
||||
((uint8_t *)(p))[3] = ((uint64_t)(a) >> 32) & 0xFFU, \
|
||||
((uint8_t *)(p))[4] = ((uint64_t)(a) >> 24) & 0xFFU, \
|
||||
((uint8_t *)(p))[5] = ((uint64_t)(a) >> 16) & 0xFFU, \
|
||||
((uint8_t *)(p))[6] = ((uint64_t)(a) >> 8) & 0xFFU, \
|
||||
((uint8_t *)(p))[7] = ((uint64_t)(a) >> 0) & 0xFFU
|
||||
|
||||
//Swap a 16-bit integer
|
||||
#define SWAPINT16(x) ( \
|
||||
(((uint16_t)(x) & 0x00FFU) << 8) | \
|
||||
(((uint16_t)(x) & 0xFF00U) >> 8))
|
||||
|
||||
//Swap a 32-bit integer
|
||||
#define SWAPINT32(x) ( \
|
||||
(((uint32_t)(x) & 0x000000FFUL) << 24) | \
|
||||
(((uint32_t)(x) & 0x0000FF00UL) << 8) | \
|
||||
(((uint32_t)(x) & 0x00FF0000UL) >> 8) | \
|
||||
(((uint32_t)(x) & 0xFF000000UL) >> 24))
|
||||
|
||||
//Swap a 64-bit integer
|
||||
#define SWAPINT64(x) ( \
|
||||
(((uint64_t)(x) & 0x00000000000000FFULL) << 56) | \
|
||||
(((uint64_t)(x) & 0x000000000000FF00ULL) << 40) | \
|
||||
(((uint64_t)(x) & 0x0000000000FF0000ULL) << 24) | \
|
||||
(((uint64_t)(x) & 0x00000000FF000000ULL) << 8) | \
|
||||
(((uint64_t)(x) & 0x000000FF00000000ULL) >> 8) | \
|
||||
(((uint64_t)(x) & 0x0000FF0000000000ULL) >> 24) | \
|
||||
(((uint64_t)(x) & 0x00FF000000000000ULL) >> 40) | \
|
||||
(((uint64_t)(x) & 0xFF00000000000000ULL) >> 56))
|
||||
|
||||
//Big-endian machine?
|
||||
#ifdef _CPU_BIG_ENDIAN
|
||||
|
||||
//Host byte order to network byte order
|
||||
#define HTONS(value) (value)
|
||||
#define HTONL(value) (value)
|
||||
#define htons(value) ((uint16_t) (value))
|
||||
#define htonl(value) ((uint32_t) (value))
|
||||
|
||||
//Network byte order to host byte order
|
||||
#define NTOHS(value) (value)
|
||||
#define NTOHL(value) (value)
|
||||
#define ntohs(value) ((uint16_t) (value))
|
||||
#define ntohl(value) ((uint32_t) (value))
|
||||
|
||||
//Host byte order to little-endian byte order
|
||||
#define HTOLE16(value) SWAPINT16(value)
|
||||
#define HTOLE32(value) SWAPINT32(value)
|
||||
#define HTOLE64(value) SWAPINT64(value)
|
||||
#define htole16(value) swapInt16((uint16_t) (value))
|
||||
#define htole32(value) swapInt32((uint32_t) (value))
|
||||
#define htole64(value) swapInt64((uint64_t) (value))
|
||||
|
||||
//Little-endian byte order to host byte order
|
||||
#define LETOH16(value) SWAPINT16(value)
|
||||
#define LETOH32(value) SWAPINT32(value)
|
||||
#define LETOH64(value) SWAPINT64(value)
|
||||
#define letoh16(value) swapInt16((uint16_t) (value))
|
||||
#define letoh32(value) swapInt32((uint32_t) (value))
|
||||
#define letoh64(value) swapInt64((uint64_t) (value))
|
||||
|
||||
//Host byte order to big-endian byte order
|
||||
#define HTOBE16(value) (value)
|
||||
#define HTOBE32(value) (value)
|
||||
#define HTOBE64(value) (value)
|
||||
#define htobe16(value) ((uint16_t) (value))
|
||||
#define htobe32(value) ((uint32_t) (value))
|
||||
#define htobe64(value) ((uint64_t) (value))
|
||||
|
||||
//Big-endian byte order to host byte order
|
||||
#define BETOH16(value) (value)
|
||||
#define BETOH32(value) (value)
|
||||
#define BETOH64(value) (value)
|
||||
#define betoh16(value) ((uint16_t) (value))
|
||||
#define betoh32(value) ((uint32_t) (value))
|
||||
#define betoh64(value) ((uint64_t) (value))
|
||||
|
||||
//Little-endian machine?
|
||||
#else
|
||||
|
||||
//Host byte order to network byte order
|
||||
#define HTONS(value) SWAPINT16(value)
|
||||
#define HTONL(value) SWAPINT32(value)
|
||||
#define htons(value) swapInt16((uint16_t) (value))
|
||||
#define htonl(value) swapInt32((uint32_t) (value))
|
||||
|
||||
//Network byte order to host byte order
|
||||
#define NTOHS(value) SWAPINT16(value)
|
||||
#define NTOHL(value) SWAPINT32(value)
|
||||
#define ntohs(value) swapInt16((uint16_t) (value))
|
||||
#define ntohl(value) swapInt32((uint32_t) (value))
|
||||
|
||||
//Host byte order to little-endian byte order
|
||||
#define HTOLE16(value) (value)
|
||||
#define HTOLE32(value) (value)
|
||||
#define HTOLE64(value) (value)
|
||||
#define htole16(value) ((uint16_t) (value))
|
||||
#define htole32(value) ((uint32_t) (value))
|
||||
#define htole64(value) ((uint64_t) (value))
|
||||
|
||||
//Little-endian byte order to host byte order
|
||||
#define LETOH16(value) (value)
|
||||
#define LETOH32(value) (value)
|
||||
#define LETOH64(value) (value)
|
||||
#define letoh16(value) ((uint16_t) (value))
|
||||
#define letoh32(value) ((uint32_t) (value))
|
||||
#define letoh64(value) ((uint64_t) (value))
|
||||
|
||||
//Host byte order to big-endian byte order
|
||||
#define HTOBE16(value) SWAPINT16(value)
|
||||
#define HTOBE32(value) SWAPINT32(value)
|
||||
#define HTOBE64(value) SWAPINT64(value)
|
||||
#define htobe16(value) swapInt16((uint16_t) (value))
|
||||
#define htobe32(value) swapInt32((uint32_t) (value))
|
||||
#define htobe64(value) swapInt64((uint64_t) (value))
|
||||
|
||||
//Big-endian byte order to host byte order
|
||||
#define BETOH16(value) SWAPINT16(value)
|
||||
#define BETOH32(value) SWAPINT32(value)
|
||||
#define BETOH64(value) SWAPINT64(value)
|
||||
#define betoh16(value) swapInt16((uint16_t) (value))
|
||||
#define betoh32(value) swapInt32((uint32_t) (value))
|
||||
#define betoh64(value) swapInt64((uint64_t) (value))
|
||||
|
||||
#endif
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//Byte order conversion functions
|
||||
uint16_t swapInt16(uint16_t value);
|
||||
uint32_t swapInt32(uint32_t value);
|
||||
uint64_t swapInt64(uint64_t value);
|
||||
|
||||
//Bit reversal functions
|
||||
uint8_t reverseInt4(uint8_t value);
|
||||
uint8_t reverseInt8(uint8_t value);
|
||||
uint16_t reverseInt16(uint16_t value);
|
||||
uint32_t reverseInt32(uint32_t value);
|
||||
uint64_t reverseInt64(uint64_t value);
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
374
src/common/date_time.c
Normal file
374
src/common/date_time.c
Normal file
@@ -0,0 +1,374 @@
|
||||
/**
|
||||
* @file date_time.c
|
||||
* @brief Date and time management
|
||||
*
|
||||
* @section License
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @author Oryx Embedded SARL (www.oryx-embedded.com)
|
||||
* @version 1.9.7b
|
||||
**/
|
||||
|
||||
//Dependencies
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "date_time.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
//Days
|
||||
static const char days[8][10] =
|
||||
{
|
||||
"",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
"Sunday"
|
||||
};
|
||||
|
||||
//Months
|
||||
static const char months[13][10] =
|
||||
{
|
||||
"",
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December"
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Format system time
|
||||
* @param[in] time System time
|
||||
* @param[out] str NULL-terminated string representing the specified time
|
||||
* @return Pointer to the formatted string
|
||||
**/
|
||||
|
||||
const char_t *formatSystemTime(systime_t time, char_t *str)
|
||||
{
|
||||
uint16_t hours;
|
||||
uint8_t minutes;
|
||||
uint8_t seconds;
|
||||
uint16_t milliseconds;
|
||||
static char_t buffer[24];
|
||||
|
||||
//Retrieve milliseconds
|
||||
milliseconds = time % 1000;
|
||||
time /= 1000;
|
||||
//Retrieve seconds
|
||||
seconds = time % 60;
|
||||
time /= 60;
|
||||
//Retrieve minutes
|
||||
minutes = time % 60;
|
||||
time /= 60;
|
||||
//Retrieve hours
|
||||
hours = time;
|
||||
|
||||
//The str parameter is optional
|
||||
if(!str)
|
||||
str = buffer;
|
||||
|
||||
//Format system time
|
||||
if(hours > 0)
|
||||
{
|
||||
osSprintf(str, "%" PRIu16 "h %02" PRIu8 "min %02" PRIu8 "s %03" PRIu16 "ms",
|
||||
hours, minutes, seconds, milliseconds);
|
||||
}
|
||||
else if(minutes > 0)
|
||||
{
|
||||
osSprintf(str, "%" PRIu8 "min %02" PRIu8 "s %03" PRIu16 "ms",
|
||||
minutes, seconds, milliseconds);
|
||||
}
|
||||
else if(seconds > 0)
|
||||
{
|
||||
osSprintf(str, "%" PRIu8 "s %03" PRIu16 "ms", seconds, milliseconds);
|
||||
}
|
||||
else
|
||||
{
|
||||
osSprintf(str, "%" PRIu16 "ms", milliseconds);
|
||||
}
|
||||
|
||||
//Return a pointer to the formatted string
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Format date
|
||||
* @param[in] date Pointer to a structure representing the date
|
||||
* @param[out] str NULL-terminated string representing the specified date
|
||||
* @return Pointer to the formatted string
|
||||
**/
|
||||
|
||||
const char_t *formatDate(const DateTime *date, char_t *str)
|
||||
{
|
||||
static char_t buffer[40];
|
||||
|
||||
//The str parameter is optional
|
||||
if(!str)
|
||||
str = buffer;
|
||||
|
||||
//Format date
|
||||
if(date->dayOfWeek)
|
||||
{
|
||||
osSprintf(str, "%s, %s %" PRIu8 ", %" PRIu16 " %02" PRIu8 ":%02" PRIu8 ":%02" PRIu8,
|
||||
days[MIN(date->dayOfWeek, 7)], months[MIN(date->month, 12)], date->day,
|
||||
date->year, date->hours, date->minutes, date->seconds);
|
||||
}
|
||||
else
|
||||
{
|
||||
osSprintf(str, "%s %" PRIu8 ", %" PRIu16 " %02" PRIu8 ":%02" PRIu8 ":%02" PRIu8,
|
||||
months[MIN(date->month, 12)], date->day, date->year,
|
||||
date->hours, date->minutes, date->seconds);
|
||||
}
|
||||
|
||||
//Return a pointer to the formatted string
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get current date and time
|
||||
* @param[out] date Pointer to a structure representing the date and time
|
||||
**/
|
||||
|
||||
void getCurrentDate(DateTime *date)
|
||||
{
|
||||
//Retrieve current time
|
||||
time_t time = getCurrentUnixTime();
|
||||
|
||||
//Convert Unix timestamp to date
|
||||
convertUnixTimeToDate(time, date);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get current time
|
||||
* @return Unix timestamp
|
||||
**/
|
||||
|
||||
time_t getCurrentUnixTime(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
//Retrieve current time
|
||||
return time(NULL);
|
||||
#else
|
||||
//Not implemented
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convert Unix timestamp to date
|
||||
* @param[in] t Unix timestamp
|
||||
* @param[out] date Pointer to a structure representing the date and time
|
||||
**/
|
||||
|
||||
void convertUnixTimeToDate(time_t t, DateTime *date)
|
||||
{
|
||||
uint32_t a;
|
||||
uint32_t b;
|
||||
uint32_t c;
|
||||
uint32_t d;
|
||||
uint32_t e;
|
||||
uint32_t f;
|
||||
|
||||
//Negative Unix time values are not supported
|
||||
if(t < 1)
|
||||
t = 0;
|
||||
|
||||
//Clear milliseconds
|
||||
date->milliseconds = 0;
|
||||
|
||||
//Retrieve hours, minutes and seconds
|
||||
date->seconds = t % 60;
|
||||
t /= 60;
|
||||
date->minutes = t % 60;
|
||||
t /= 60;
|
||||
date->hours = t % 24;
|
||||
t /= 24;
|
||||
|
||||
//Convert Unix time to date
|
||||
a = (uint32_t) ((4 * t + 102032) / 146097 + 15);
|
||||
b = (uint32_t) (t + 2442113 + a - (a / 4));
|
||||
c = (20 * b - 2442) / 7305;
|
||||
d = b - 365 * c - (c / 4);
|
||||
e = d * 1000 / 30601;
|
||||
f = d - e * 30 - e * 601 / 1000;
|
||||
|
||||
//January and February are counted as months 13 and 14 of the previous year
|
||||
if(e <= 13)
|
||||
{
|
||||
c -= 4716;
|
||||
e -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
c -= 4715;
|
||||
e -= 13;
|
||||
}
|
||||
|
||||
//Retrieve year, month and day
|
||||
date->year = c;
|
||||
date->month = e;
|
||||
date->day = f;
|
||||
|
||||
//Calculate day of week
|
||||
date->dayOfWeek = computeDayOfWeek(c, e, f);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convert date to Unix timestamp
|
||||
* @param[in] date Pointer to a structure representing the date and time
|
||||
* @return Unix timestamp
|
||||
**/
|
||||
|
||||
time_t convertDateToUnixTime(const DateTime *date)
|
||||
{
|
||||
uint_t y;
|
||||
uint_t m;
|
||||
uint_t d;
|
||||
uint32_t t;
|
||||
|
||||
//Year
|
||||
y = date->year;
|
||||
//Month of year
|
||||
m = date->month;
|
||||
//Day of month
|
||||
d = date->day;
|
||||
|
||||
//January and February are counted as months 13 and 14 of the previous year
|
||||
if(m <= 2)
|
||||
{
|
||||
m += 12;
|
||||
y -= 1;
|
||||
}
|
||||
|
||||
//Convert years to days
|
||||
t = (365 * y) + (y / 4) - (y / 100) + (y / 400);
|
||||
//Convert months to days
|
||||
t += (30 * m) + (3 * (m + 1) / 5) + d;
|
||||
//Unix time starts on January 1st, 1970
|
||||
t -= 719561;
|
||||
//Convert days to seconds
|
||||
t *= 86400;
|
||||
//Add hours, minutes and seconds
|
||||
t += (3600 * date->hours) + (60 * date->minutes) + date->seconds;
|
||||
|
||||
//Return Unix time
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Compare dates
|
||||
* @param[in] date1 Pointer to the first date
|
||||
* @param[in] date2 Pointer to the second date
|
||||
* @return Comparison result
|
||||
**/
|
||||
|
||||
int_t compareDateTime(const DateTime *date1, const DateTime *date2)
|
||||
{
|
||||
int_t res;
|
||||
|
||||
//Perform comparison
|
||||
if(date1->year < date2->year)
|
||||
res = -1;
|
||||
else if(date1->year > date2->year)
|
||||
res = 1;
|
||||
else if(date1->month < date2->month)
|
||||
res = -1;
|
||||
else if(date1->month > date2->month)
|
||||
res = 1;
|
||||
else if(date1->day < date2->day)
|
||||
res = -1;
|
||||
else if(date1->day > date2->day)
|
||||
res = 1;
|
||||
else if(date1->hours < date2->hours)
|
||||
res = -1;
|
||||
else if(date1->hours > date2->hours)
|
||||
res = 1;
|
||||
else if(date1->minutes < date2->minutes)
|
||||
res = -1;
|
||||
else if(date1->minutes > date2->minutes)
|
||||
res = 1;
|
||||
else if(date1->seconds < date2->seconds)
|
||||
res = -1;
|
||||
else if(date1->seconds > date2->seconds)
|
||||
res = 1;
|
||||
else if(date1->milliseconds < date2->milliseconds)
|
||||
res = -1;
|
||||
else if(date1->milliseconds > date2->milliseconds)
|
||||
res = 1;
|
||||
else
|
||||
res = 0;
|
||||
|
||||
//Return comparison result
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calculate day of week
|
||||
* @param[in] y Year
|
||||
* @param[in] m Month of year (in range 1 to 12)
|
||||
* @param[in] d Day of month (in range 1 to 31)
|
||||
* @return Day of week (in range 1 to 7)
|
||||
**/
|
||||
|
||||
uint8_t computeDayOfWeek(uint16_t y, uint8_t m, uint8_t d)
|
||||
{
|
||||
uint_t h;
|
||||
uint_t j;
|
||||
uint_t k;
|
||||
|
||||
//January and February are counted as months 13 and 14 of the previous year
|
||||
if(m <= 2)
|
||||
{
|
||||
m += 12;
|
||||
y -= 1;
|
||||
}
|
||||
|
||||
//J is the century
|
||||
j = y / 100;
|
||||
//K the year of the century
|
||||
k = y % 100;
|
||||
|
||||
//Compute H using Zeller's congruence
|
||||
h = d + (26 * (m + 1) / 10) + k + (k / 4) + (5 * j) + (j / 4);
|
||||
|
||||
//Return the day of the week
|
||||
return ((h + 5) % 7) + 1;
|
||||
}
|
||||
78
src/common/date_time.h
Normal file
78
src/common/date_time.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @file date_time.h
|
||||
* @brief Date and time management
|
||||
*
|
||||
* @section License
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @author Oryx Embedded SARL (www.oryx-embedded.com)
|
||||
* @version 1.9.7b
|
||||
**/
|
||||
|
||||
#ifndef _DATE_TIME_H
|
||||
#define _DATE_TIME_H
|
||||
|
||||
//Dependencies
|
||||
#include <time.h>
|
||||
#include "os_port.h"
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Date and time representation
|
||||
**/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t dayOfWeek;
|
||||
uint8_t hours;
|
||||
uint8_t minutes;
|
||||
uint8_t seconds;
|
||||
uint16_t milliseconds;
|
||||
} DateTime;
|
||||
|
||||
|
||||
//Date and time management
|
||||
const char_t *formatSystemTime(systime_t time, char_t *str);
|
||||
const char_t *formatDate(const DateTime *date, char_t *str);
|
||||
|
||||
void getCurrentDate(DateTime *date);
|
||||
time_t getCurrentUnixTime(void);
|
||||
|
||||
void convertUnixTimeToDate(time_t t, DateTime *date);
|
||||
time_t convertDateToUnixTime(const DateTime *date);
|
||||
|
||||
int_t compareDateTime(const DateTime *date1, const DateTime *date2);
|
||||
|
||||
uint8_t computeDayOfWeek(uint16_t y, uint8_t m, uint8_t d);
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
64
src/common/debug.c
Normal file
64
src/common/debug.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @file debug.c
|
||||
* @brief Debugging facilities
|
||||
*
|
||||
* @section License
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @author Oryx Embedded SARL (www.oryx-embedded.com)
|
||||
* @version 1.9.7b
|
||||
**/
|
||||
|
||||
//Dependencies
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Display the contents of an array
|
||||
* @param[in] stream Pointer to a FILE object that identifies an output stream
|
||||
* @param[in] prepend String to prepend to the left of each line
|
||||
* @param[in] data Pointer to the data array
|
||||
* @param[in] length Number of bytes to display
|
||||
**/
|
||||
|
||||
void debugDisplayArray(FILE *stream,
|
||||
const char_t *prepend, const void *data, size_t length)
|
||||
{
|
||||
uint_t i;
|
||||
|
||||
//Dump the contents of the array
|
||||
for(i = 0; i < length; i++)
|
||||
{
|
||||
//Beginning of a new line?
|
||||
if((i % 16) == 0)
|
||||
{
|
||||
TRACE_PRINTF("%s", prepend);
|
||||
}
|
||||
|
||||
//Display current data byte
|
||||
TRACE_PRINTF("%02" PRIX8 " ", *((const uint8_t *) data + i));
|
||||
|
||||
//End of current line?
|
||||
if((i % 16) == 15 || i == (length - 1))
|
||||
{
|
||||
TRACE_PRINTF("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
136
src/common/debug.h
Normal file
136
src/common/debug.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* @file debug.h
|
||||
* @brief Debugging facilities
|
||||
*
|
||||
* @section License
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @author Oryx Embedded SARL (www.oryx-embedded.com)
|
||||
* @version 1.9.7b
|
||||
**/
|
||||
|
||||
#ifndef _DEBUG_H
|
||||
#define _DEBUG_H
|
||||
|
||||
//Dependencies
|
||||
#include <stdio.h>
|
||||
#include "os_port.h"
|
||||
|
||||
//Trace level definitions
|
||||
#define TRACE_LEVEL_OFF 0
|
||||
#define TRACE_LEVEL_FATAL 1
|
||||
#define TRACE_LEVEL_ERROR 2
|
||||
#define TRACE_LEVEL_WARNING 3
|
||||
#define TRACE_LEVEL_INFO 4
|
||||
#define TRACE_LEVEL_DEBUG 5
|
||||
|
||||
//Default trace level
|
||||
#ifndef TRACE_LEVEL
|
||||
#define TRACE_LEVEL TRACE_LEVEL_DEBUG
|
||||
#endif
|
||||
|
||||
//Trace output redirection
|
||||
#ifndef TRACE_PRINTF
|
||||
#define TRACE_PRINTF(...) osSuspendAllTasks(), fprintf(stderr, __VA_ARGS__), osResumeAllTasks()
|
||||
#endif
|
||||
|
||||
#ifndef TRACE_ARRAY
|
||||
#define TRACE_ARRAY(p, a, n) osSuspendAllTasks(), debugDisplayArray(stderr, p, a, n), osResumeAllTasks()
|
||||
#endif
|
||||
|
||||
#ifndef TRACE_MPI
|
||||
#define TRACE_MPI(p, a) osSuspendAllTasks(), mpiDump(stderr, p, a), osResumeAllTasks()
|
||||
#endif
|
||||
|
||||
//Debugging macros
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_FATAL)
|
||||
#define TRACE_FATAL(...) TRACE_PRINTF(__VA_ARGS__)
|
||||
#define TRACE_FATAL_ARRAY(p, a, n) TRACE_ARRAY(p, a, n)
|
||||
#define TRACE_FATAL_MPI(p, a) TRACE_MPI(p, a)
|
||||
#else
|
||||
#define TRACE_FATAL(...)
|
||||
#define TRACE_FATAL_ARRAY(p, a, n)
|
||||
#define TRACE_FATAL_MPI(p, a)
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_ERROR)
|
||||
#define TRACE_ERROR(...) TRACE_PRINTF(__VA_ARGS__)
|
||||
#define TRACE_ERROR_ARRAY(p, a, n) TRACE_ARRAY(p, a, n)
|
||||
#define TRACE_ERROR_MPI(p, a) TRACE_MPI(p, a)
|
||||
#else
|
||||
#define TRACE_ERROR(...)
|
||||
#define TRACE_ERROR_ARRAY(p, a, n)
|
||||
#define TRACE_ERROR_MPI(p, a)
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_WARNING)
|
||||
#define TRACE_WARNING(...) TRACE_PRINTF(__VA_ARGS__)
|
||||
#define TRACE_WARNING_ARRAY(p, a, n) TRACE_ARRAY(p, a, n)
|
||||
#define TRACE_WARNING_MPI(p, a) TRACE_MPI(p, a)
|
||||
#else
|
||||
#define TRACE_WARNING(...)
|
||||
#define TRACE_WARNING_ARRAY(p, a, n)
|
||||
#define TRACE_WARNING_MPI(p, a)
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
|
||||
#define TRACE_INFO(...) TRACE_PRINTF(__VA_ARGS__)
|
||||
#define TRACE_INFO_ARRAY(p, a, n) TRACE_ARRAY(p, a, n)
|
||||
#define TRACE_INFO_NET_BUFFER(p, b, o, n)
|
||||
#define TRACE_INFO_MPI(p, a) TRACE_MPI(p, a)
|
||||
#else
|
||||
#define TRACE_INFO(...)
|
||||
#define TRACE_INFO_ARRAY(p, a, n)
|
||||
#define TRACE_INFO_NET_BUFFER(p, b, o, n)
|
||||
#define TRACE_INFO_MPI(p, a)
|
||||
#endif
|
||||
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
|
||||
#define TRACE_DEBUG(...) TRACE_PRINTF(__VA_ARGS__)
|
||||
#define TRACE_DEBUG_ARRAY(p, a, n) TRACE_ARRAY(p, a, n)
|
||||
#define TRACE_DEBUG_NET_BUFFER(p, b, o, n)
|
||||
#define TRACE_DEBUG_MPI(p, a) TRACE_MPI(p, a)
|
||||
#else
|
||||
#define TRACE_DEBUG(...)
|
||||
#define TRACE_DEBUG_ARRAY(p, a, n)
|
||||
#define TRACE_DEBUG_NET_BUFFER(p, b, o, n)
|
||||
#define TRACE_DEBUG_MPI(p, a)
|
||||
#endif
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//Debug related functions
|
||||
void debugInit(uint32_t baudrate);
|
||||
|
||||
void debugDisplayArray(FILE *stream,
|
||||
const char_t *prepend, const void *data, size_t length);
|
||||
|
||||
//Deprecated definitions
|
||||
#define TRACE_LEVEL_NO_TRACE TRACE_LEVEL_OFF
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
289
src/common/error.h
Normal file
289
src/common/error.h
Normal file
@@ -0,0 +1,289 @@
|
||||
/**
|
||||
* @file error.h
|
||||
* @brief Error codes description
|
||||
*
|
||||
* @section License
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @author Oryx Embedded SARL (www.oryx-embedded.com)
|
||||
* @version 1.9.7b
|
||||
**/
|
||||
|
||||
#ifndef _ERROR_H
|
||||
#define _ERROR_H
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Error codes
|
||||
**/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NO_ERROR = 0, ///<Success
|
||||
ERROR_FAILURE = 1, ///<Generic error code
|
||||
|
||||
ERROR_INVALID_PARAMETER, ///<Invalid parameter
|
||||
ERROR_PARAMETER_OUT_OF_RANGE, ///<Specified parameter is out of range
|
||||
|
||||
ERROR_BAD_CRC,
|
||||
ERROR_BAD_BLOCK,
|
||||
ERROR_INVALID_RECIPIENT, ///<Invalid recipient
|
||||
ERROR_INVALID_INTERFACE, ///<Invalid interface
|
||||
ERROR_INVALID_ENDPOINT, ///<Invalid endpoint
|
||||
ERROR_INVALID_ALT_SETTING, ///<Alternate setting does not exist
|
||||
ERROR_UNSUPPORTED_REQUEST, ///<Unsupported request
|
||||
ERROR_UNSUPPORTED_CONFIGURATION, ///<Unsupported configuration
|
||||
ERROR_UNSUPPORTED_FEATURE, ///<Unsupported feature
|
||||
ERROR_ENDPOINT_BUSY, ///<Endpoint already in use
|
||||
ERROR_USB_RESET,
|
||||
ERROR_ABORTED,
|
||||
|
||||
ERROR_OUT_OF_MEMORY = 100,
|
||||
ERROR_OUT_OF_RESOURCES,
|
||||
ERROR_INVALID_REQUEST,
|
||||
ERROR_NOT_IMPLEMENTED,
|
||||
ERROR_VERSION_NOT_SUPPORTED,
|
||||
ERROR_INVALID_SYNTAX,
|
||||
ERROR_AUTHENTICATION_FAILED,
|
||||
ERROR_UNEXPECTED_RESPONSE,
|
||||
ERROR_INVALID_RESPONSE,
|
||||
ERROR_UNEXPECTED_VALUE,
|
||||
|
||||
ERROR_OPEN_FAILED = 200,
|
||||
ERROR_CONNECTION_FAILED,
|
||||
ERROR_CONNECTION_REFUSED,
|
||||
ERROR_CONNECTION_CLOSING,
|
||||
ERROR_CONNECTION_RESET,
|
||||
ERROR_NOT_CONNECTED,
|
||||
ERROR_ALREADY_CLOSED,
|
||||
ERROR_ALREADY_CONNECTED,
|
||||
ERROR_INVALID_SOCKET,
|
||||
ERROR_PROTOCOL_UNREACHABLE,
|
||||
ERROR_PORT_UNREACHABLE,
|
||||
ERROR_INVALID_FRAME,
|
||||
ERROR_INVALID_HEADER,
|
||||
ERROR_WRONG_CHECKSUM,
|
||||
ERROR_WRONG_IDENTIFIER,
|
||||
ERROR_WRONG_CLIENT_ID,
|
||||
ERROR_WRONG_SERVER_ID,
|
||||
ERROR_WRONG_COOKIE,
|
||||
ERROR_NO_RESPONSE,
|
||||
ERROR_RECEIVE_QUEUE_FULL,
|
||||
ERROR_TIMEOUT,
|
||||
ERROR_WOULD_BLOCK,
|
||||
ERROR_INVALID_NAME,
|
||||
ERROR_INVALID_OPTION,
|
||||
ERROR_UNEXPECTED_STATE,
|
||||
ERROR_INVALID_COMMAND,
|
||||
ERROR_INVALID_PROTOCOL,
|
||||
ERROR_INVALID_STATUS,
|
||||
ERROR_INVALID_ADDRESS,
|
||||
ERROR_INVALID_MESSAGE,
|
||||
ERROR_INVALID_KEY,
|
||||
ERROR_INVALID_KEY_LENGTH,
|
||||
ERROR_INVALID_EPOCH,
|
||||
ERROR_INVALID_SEQUENCE_NUMBER,
|
||||
ERROR_INVALID_CHARACTER,
|
||||
ERROR_INVALID_LENGTH,
|
||||
ERROR_INVALID_PADDING,
|
||||
ERROR_INVALID_MAC,
|
||||
ERROR_INVALID_TAG,
|
||||
ERROR_INVALID_TYPE,
|
||||
ERROR_INVALID_VALUE,
|
||||
ERROR_INVALID_CLASS,
|
||||
ERROR_INVALID_VERSION,
|
||||
ERROR_INVALID_PIN_CODE,
|
||||
ERROR_WRONG_LENGTH,
|
||||
ERROR_WRONG_TYPE,
|
||||
ERROR_WRONG_ENCODING,
|
||||
ERROR_WRONG_VALUE,
|
||||
ERROR_INCONSISTENT_VALUE,
|
||||
ERROR_UNSUPPORTED_TYPE,
|
||||
ERROR_UNSUPPORTED_ALGO,
|
||||
ERROR_UNSUPPORTED_CIPHER_SUITE,
|
||||
ERROR_UNSUPPORTED_CIPHER_MODE,
|
||||
ERROR_UNSUPPORTED_CIPHER_ALGO,
|
||||
ERROR_UNSUPPORTED_HASH_ALGO,
|
||||
ERROR_UNSUPPORTED_KEY_EXCH_METHOD,
|
||||
ERROR_UNSUPPORTED_SIGNATURE_ALGO,
|
||||
ERROR_UNSUPPORTED_ELLIPTIC_CURVE,
|
||||
ERROR_INVALID_SIGNATURE_ALGO,
|
||||
ERROR_CERTIFICATE_REQUIRED,
|
||||
ERROR_MESSAGE_TOO_LONG,
|
||||
ERROR_OUT_OF_RANGE,
|
||||
ERROR_MESSAGE_DISCARDED,
|
||||
|
||||
ERROR_INVALID_PACKET,
|
||||
ERROR_BUFFER_EMPTY,
|
||||
ERROR_BUFFER_OVERFLOW,
|
||||
ERROR_BUFFER_UNDERFLOW,
|
||||
|
||||
ERROR_INVALID_RESOURCE,
|
||||
ERROR_INVALID_PATH,
|
||||
ERROR_NOT_FOUND,
|
||||
ERROR_ACCESS_DENIED,
|
||||
ERROR_NOT_WRITABLE,
|
||||
ERROR_AUTH_REQUIRED,
|
||||
|
||||
ERROR_TRANSMITTER_BUSY,
|
||||
ERROR_NO_RUNNING,
|
||||
|
||||
ERROR_INVALID_FILE = 300,
|
||||
ERROR_FILE_NOT_FOUND,
|
||||
ERROR_FILE_OPENING_FAILED,
|
||||
ERROR_FILE_READING_FAILED,
|
||||
ERROR_END_OF_FILE,
|
||||
ERROR_UNEXPECTED_END_OF_FILE,
|
||||
ERROR_UNKNOWN_FILE_FORMAT,
|
||||
|
||||
ERROR_INVALID_DIRECTORY,
|
||||
ERROR_DIRECTORY_NOT_FOUND,
|
||||
|
||||
ERROR_FILE_SYSTEM_NOT_SUPPORTED = 400,
|
||||
ERROR_UNKNOWN_FILE_SYSTEM,
|
||||
ERROR_INVALID_FILE_SYSTEM,
|
||||
ERROR_INVALID_BOOT_SECTOR_SIGNATURE,
|
||||
ERROR_INVALID_SECTOR_SIZE,
|
||||
ERROR_INVALID_CLUSTER_SIZE,
|
||||
ERROR_INVALID_FILE_RECORD_SIZE,
|
||||
ERROR_INVALID_INDEX_BUFFER_SIZE,
|
||||
ERROR_INVALID_VOLUME_DESCRIPTOR_SIGNATURE,
|
||||
ERROR_INVALID_VOLUME_DESCRIPTOR,
|
||||
ERROR_INVALID_FILE_RECORD,
|
||||
ERROR_INVALID_INDEX_BUFFER,
|
||||
ERROR_INVALID_DATA_RUNS,
|
||||
ERROR_WRONG_TAG_IDENTIFIER,
|
||||
ERROR_WRONG_TAG_CHECKSUM,
|
||||
ERROR_WRONG_MAGIC_NUMBER,
|
||||
ERROR_WRONG_SEQUENCE_NUMBER,
|
||||
ERROR_DESCRIPTOR_NOT_FOUND,
|
||||
ERROR_ATTRIBUTE_NOT_FOUND,
|
||||
ERROR_RESIDENT_ATTRIBUTE,
|
||||
ERROR_NOT_RESIDENT_ATTRIBUTE,
|
||||
ERROR_INVALID_SUPER_BLOCK,
|
||||
ERROR_INVALID_SUPER_BLOCK_SIGNATURE,
|
||||
ERROR_INVALID_BLOCK_SIZE,
|
||||
ERROR_UNSUPPORTED_REVISION_LEVEL,
|
||||
ERROR_INVALID_INODE_SIZE,
|
||||
ERROR_INODE_NOT_FOUND,
|
||||
|
||||
ERROR_UNEXPECTED_MESSAGE = 500,
|
||||
|
||||
ERROR_URL_TOO_LONG,
|
||||
ERROR_QUERY_STRING_TOO_LONG,
|
||||
|
||||
ERROR_NO_ADDRESS,
|
||||
ERROR_NO_BINDING,
|
||||
ERROR_NOT_ON_LINK,
|
||||
ERROR_USE_MULTICAST,
|
||||
ERROR_NAK_RECEIVED,
|
||||
ERROR_EXCEPTION_RECEIVED,
|
||||
|
||||
ERROR_NO_CARRIER,
|
||||
|
||||
ERROR_INVALID_LEVEL,
|
||||
ERROR_WRONG_STATE,
|
||||
ERROR_END_OF_STREAM,
|
||||
ERROR_LINK_DOWN,
|
||||
ERROR_INVALID_OPTION_LENGTH,
|
||||
ERROR_IN_PROGRESS,
|
||||
|
||||
ERROR_NO_ACK,
|
||||
ERROR_INVALID_METADATA,
|
||||
ERROR_NOT_CONFIGURED,
|
||||
ERROR_NAME_RESOLUTION_FAILED,
|
||||
ERROR_NO_ROUTE,
|
||||
|
||||
ERROR_WRITE_FAILED,
|
||||
ERROR_READ_FAILED,
|
||||
ERROR_UPLOAD_FAILED,
|
||||
ERROR_READ_ONLY_ACCESS,
|
||||
|
||||
ERROR_INVALID_SIGNATURE,
|
||||
ERROR_INVALID_TICKET,
|
||||
|
||||
ERROR_BAD_RECORD_MAC,
|
||||
ERROR_RECORD_OVERFLOW,
|
||||
ERROR_HANDSHAKE_FAILED,
|
||||
ERROR_NO_CERTIFICATE,
|
||||
ERROR_BAD_CERTIFICATE,
|
||||
ERROR_UNSUPPORTED_CERTIFICATE,
|
||||
ERROR_CERTIFICATE_EXPIRED,
|
||||
ERROR_CERTIFICATE_REVOKED,
|
||||
ERROR_UNKNOWN_CA,
|
||||
ERROR_DECODING_FAILED,
|
||||
ERROR_DECRYPTION_FAILED,
|
||||
ERROR_ILLEGAL_PARAMETER,
|
||||
ERROR_MISSING_EXTENSION,
|
||||
ERROR_UNSUPPORTED_EXTENSION,
|
||||
ERROR_INAPPROPRIATE_FALLBACK,
|
||||
ERROR_NO_APPLICATION_PROTOCOL,
|
||||
|
||||
ERROR_MORE_DATA_REQUIRED,
|
||||
ERROR_TLS_NOT_SUPPORTED,
|
||||
ERROR_PRNG_NOT_READY,
|
||||
ERROR_SERVICE_CLOSING,
|
||||
ERROR_INVALID_TIMESTAMP,
|
||||
ERROR_NO_DNS_SERVER,
|
||||
|
||||
ERROR_OBJECT_NOT_FOUND,
|
||||
ERROR_INSTANCE_NOT_FOUND,
|
||||
ERROR_ADDRESS_NOT_FOUND,
|
||||
|
||||
ERROR_UNKNOWN_IDENTITY,
|
||||
ERROR_UNKNOWN_ENGINE_ID,
|
||||
ERROR_UNKNOWN_USER_NAME,
|
||||
ERROR_UNKNOWN_CONTEXT,
|
||||
ERROR_UNAVAILABLE_CONTEXT,
|
||||
ERROR_UNSUPPORTED_SECURITY_LEVEL,
|
||||
ERROR_NOT_IN_TIME_WINDOW,
|
||||
ERROR_AUTHORIZATION_FAILED,
|
||||
|
||||
ERROR_INVALID_FUNCTION_CODE,
|
||||
ERROR_DEVICE_BUSY,
|
||||
|
||||
ERROR_REQUEST_REJECTED,
|
||||
|
||||
ERROR_INVALID_CHANNEL,
|
||||
ERROR_UNKNOWN_SERVICE,
|
||||
ERROR_UNKNOWN_REQUEST,
|
||||
ERROR_FLOW_CONTROL,
|
||||
|
||||
ERROR_INVALID_PASSWORD,
|
||||
ERROR_INVALID_HANDLE,
|
||||
ERROR_BAD_NONCE,
|
||||
ERROR_UNEXPECTED_STATUS,
|
||||
ERROR_RESPONSE_TOO_LARGE,
|
||||
|
||||
ERROR_NO_MATCH,
|
||||
ERROR_PARTIAL_MATCH
|
||||
} error_t;
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
126
src/common/fs_port.h
Normal file
126
src/common/fs_port.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @file fs_port.h
|
||||
* @brief File system abstraction layer
|
||||
*
|
||||
* @section License
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @author Oryx Embedded SARL (www.oryx-embedded.com)
|
||||
* @version 1.9.7b
|
||||
**/
|
||||
|
||||
#ifndef _FS_PORT_H
|
||||
#define _FS_PORT_H
|
||||
|
||||
//Dependencies
|
||||
#include "fs_port_config.h"
|
||||
#include "os_port.h"
|
||||
#include "date_time.h"
|
||||
#include "error.h"
|
||||
|
||||
//Maximum filename length
|
||||
#ifndef FS_MAX_NAME_LEN
|
||||
#define FS_MAX_NAME_LEN 127
|
||||
#elif (FS_MAX_NAME_LEN < 11)
|
||||
#error FS_MAX_NAME_LEN parameter is not valid
|
||||
#endif
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief File attributes
|
||||
**/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FS_FILE_ATTR_READ_ONLY = 0x01,
|
||||
FS_FILE_ATTR_HIDDEN = 0x02,
|
||||
FS_FILE_ATTR_SYSTEM = 0x04,
|
||||
FS_FILE_ATTR_VOLUME_NAME = 0x08,
|
||||
FS_FILE_ATTR_DIRECTORY = 0x10,
|
||||
FS_FILE_ATTR_ARCHIVE = 0x20
|
||||
} FsFileAttributes;
|
||||
|
||||
|
||||
/**
|
||||
* @brief File access mode
|
||||
**/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FS_FILE_MODE_READ = 1,
|
||||
FS_FILE_MODE_WRITE = 2,
|
||||
FS_FILE_MODE_CREATE = 4,
|
||||
FS_FILE_MODE_TRUNC = 8
|
||||
} FsFileMode;
|
||||
|
||||
|
||||
/**
|
||||
* @brief File seek origin
|
||||
**/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FS_SEEK_SET = 0,
|
||||
FS_SEEK_CUR = 1,
|
||||
FS_SEEK_END = 2
|
||||
} FsSeekOrigin;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Directory entry
|
||||
**/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t attributes;
|
||||
uint32_t size;
|
||||
DateTime modified;
|
||||
char_t name[FS_MAX_NAME_LEN + 1];
|
||||
} FsDirEntry;
|
||||
|
||||
|
||||
//FatFs port?
|
||||
#if defined(USE_FATFS)
|
||||
#include "fs_port_fatfs.h"
|
||||
//SPIFFS port?
|
||||
#elif defined(USE_SPIFFS)
|
||||
#include "fs_port_spiffs.h"
|
||||
//Windows port?
|
||||
#elif defined(_WIN32)
|
||||
#include "fs_port_posix.h"
|
||||
//POSIX port?
|
||||
#elif defined(__linux__) || defined(__FreeBSD__)
|
||||
#include "fs_port_posix.h"
|
||||
//Custom port?
|
||||
#elif defined(USE_CUSTOM_FS)
|
||||
#include "fs_port_custom.h"
|
||||
#endif
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
872
src/common/fs_port_fatfs.c
Normal file
872
src/common/fs_port_fatfs.c
Normal file
File diff suppressed because it is too large
Load Diff
97
src/common/fs_port_fatfs.h
Normal file
97
src/common/fs_port_fatfs.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @file fs_port_fatfs.h
|
||||
* @brief File system abstraction layer (FatFs)
|
||||
*
|
||||
* @section License
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @author Oryx Embedded SARL (www.oryx-embedded.com)
|
||||
* @version 1.9.7b
|
||||
**/
|
||||
|
||||
#ifndef _FS_PORT_FATFS_H
|
||||
#define _FS_PORT_FATFS_H
|
||||
|
||||
//Dependencies
|
||||
#include "os_port.h"
|
||||
#include "ff.h"
|
||||
|
||||
//Number of files that can be opened simultaneously
|
||||
#ifndef FS_MAX_FILES
|
||||
#define FS_MAX_FILES 8
|
||||
#elif (FS_MAX_FILES < 1)
|
||||
#error FS_MAX_FILES parameter is not valid
|
||||
#endif
|
||||
|
||||
//Number of directories that can be opened simultaneously
|
||||
#ifndef FS_MAX_DIRS
|
||||
#define FS_MAX_DIRS 8
|
||||
#elif (FS_MAX_DIRS < 1)
|
||||
#error FS_MAX_DIRS parameter is not valid
|
||||
#endif
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief File descriptor
|
||||
**/
|
||||
|
||||
typedef void FsFile;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Directory descriptor
|
||||
**/
|
||||
|
||||
typedef void FsDir;
|
||||
|
||||
|
||||
//File system abstraction layer
|
||||
error_t fsInit(void);
|
||||
|
||||
bool_t fsFileExists(const char_t *path);
|
||||
error_t fsGetFileSize(const char_t *path, uint32_t *size);
|
||||
error_t fsRenameFile(const char_t *oldPath, const char_t *newPath);
|
||||
error_t fsDeleteFile(const char_t *path);
|
||||
|
||||
FsFile *fsOpenFile(const char_t *path, uint_t mode);
|
||||
error_t fsSeekFile(FsFile *file, int_t offset, uint_t origin);
|
||||
error_t fsWriteFile(FsFile *file, void *data, size_t length);
|
||||
error_t fsReadFile(FsFile *file, void *data, size_t size, size_t *length);
|
||||
void fsCloseFile(FsFile *file);
|
||||
|
||||
bool_t fsDirExists(const char_t *path);
|
||||
error_t fsCreateDir(const char_t *path);
|
||||
error_t fsRemoveDir(const char_t *path);
|
||||
|
||||
FsDir *fsOpenDir(const char_t *path);
|
||||
error_t fsReadDir(FsDir *dir, FsDirEntry *dirEntry);
|
||||
void fsCloseDir(FsDir *dir);
|
||||
|
||||
//C++ guard
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
645
src/common/fs_port_posix.c
Normal file
645
src/common/fs_port_posix.c
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user