diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index b8b8e1c6..45686790 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -41,6 +41,12 @@ jobs: - "examples/mbed-legacy-examples/mbed-serial" - "examples/spl-blink" - "examples/stm32cube-hal-blink" + - "examples/stm32cube-hal-eeprom-emulation" + - "examples/stm32cube-hal-extmem-boot" + - "examples/stm32cube-hal-iap" + - "examples/stm32cube-hal-lcd" + - "examples/stm32cube-hal-usb-device-dfu" + - "examples/stm32cube-hal-wifi-client" - "examples/stm32cube-ll-blink" - "examples/zephyr-blink" - "examples/zephyr-cpp-synchronization" diff --git a/boards/1bitsy_stm32f415rgt.json b/boards/1bitsy_stm32f415rgt.json index 3369ee67..e67c2ca2 100644 --- a/boards/1bitsy_stm32f415rgt.json +++ b/boards/1bitsy_stm32f415rgt.json @@ -29,6 +29,7 @@ "protocol": "blackmagic", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/afroflight_f103cb.json b/boards/afroflight_f103cb.json index cf864d5f..4a59e4eb 100644 --- a/boards/afroflight_f103cb.json +++ b/boards/afroflight_f103cb.json @@ -26,6 +26,7 @@ "protocol": "serial", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "dfu", diff --git a/boards/armed_v1.json b/boards/armed_v1.json index 75412874..d09d3136 100644 --- a/boards/armed_v1.json +++ b/boards/armed_v1.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/armstrap_eagle1024.json b/boards/armstrap_eagle1024.json index 37ff15b4..ed96cea6 100644 --- a/boards/armstrap_eagle1024.json +++ b/boards/armstrap_eagle1024.json @@ -32,6 +32,7 @@ "protocol": "blackmagic", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/armstrap_eagle2048.json b/boards/armstrap_eagle2048.json index 32089920..5e1eecff 100644 --- a/boards/armstrap_eagle2048.json +++ b/boards/armstrap_eagle2048.json @@ -32,6 +32,7 @@ "protocol": "blackmagic", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/armstrap_eagle512.json b/boards/armstrap_eagle512.json index ab9b6894..fca39bf4 100644 --- a/boards/armstrap_eagle512.json +++ b/boards/armstrap_eagle512.json @@ -32,6 +32,7 @@ "protocol": "blackmagic", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/b96b_argonkey.json b/boards/b96b_argonkey.json index 2a7ef9e1..329cebf0 100644 --- a/boards/b96b_argonkey.json +++ b/boards/b96b_argonkey.json @@ -30,6 +30,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/b96b_f446ve.json b/boards/b96b_f446ve.json index 125038d5..d363f22e 100644 --- a/boards/b96b_f446ve.json +++ b/boards/b96b_f446ve.json @@ -21,6 +21,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F446x.svd" }, "frameworks": [ @@ -37,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/b96b_neonkey.json b/boards/b96b_neonkey.json index 790c3120..2e279a4b 100644 --- a/boards/b96b_neonkey.json +++ b/boards/b96b_neonkey.json @@ -30,6 +30,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/black_f407ve.json b/boards/black_f407ve.json index 0f10e08b..3133dc2e 100644 --- a/boards/black_f407ve.json +++ b/boards/black_f407ve.json @@ -33,6 +33,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/black_f407vg.json b/boards/black_f407vg.json index 2b47eea2..e28b3cf9 100644 --- a/boards/black_f407vg.json +++ b/boards/black_f407vg.json @@ -32,6 +32,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/black_f407ze.json b/boards/black_f407ze.json index 2a193f18..8b173145 100644 --- a/boards/black_f407ze.json +++ b/boards/black_f407ze.json @@ -32,6 +32,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/black_f407zg.json b/boards/black_f407zg.json index f6b7d681..d17329ed 100644 --- a/boards/black_f407zg.json +++ b/boards/black_f407zg.json @@ -36,6 +36,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/blackpill_f103c8.json b/boards/blackpill_f103c8.json index 4753030e..dbd68552 100644 --- a/boards/blackpill_f103c8.json +++ b/boards/blackpill_f103c8.json @@ -47,6 +47,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/blackpill_f103c8_128.json b/boards/blackpill_f103c8_128.json index 72d56e88..500ab993 100644 --- a/boards/blackpill_f103c8_128.json +++ b/boards/blackpill_f103c8_128.json @@ -47,6 +47,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/blackpill_f401cc.json b/boards/blackpill_f401cc.json index 766dcdf1..75cac469 100644 --- a/boards/blackpill_f401cc.json +++ b/boards/blackpill_f401cc.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/blackpill_f401ce.json b/boards/blackpill_f401ce.json index e2b36f0e..5dca4ba7 100644 --- a/boards/blackpill_f401ce.json +++ b/boards/blackpill_f401ce.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/blackpill_f411ce.json b/boards/blackpill_f411ce.json index ead687ae..976704c4 100644 --- a/boards/blackpill_f411ce.json +++ b/boards/blackpill_f411ce.json @@ -30,6 +30,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/blue_f407ve_mini.json b/boards/blue_f407ve_mini.json index f40aa49c..87cc69bf 100644 --- a/boards/blue_f407ve_mini.json +++ b/boards/blue_f407ve_mini.json @@ -32,6 +32,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/bluepill_f103c6.json b/boards/bluepill_f103c6.json index f5e78d5c..a45c8bd6 100644 --- a/boards/bluepill_f103c6.json +++ b/boards/bluepill_f103c6.json @@ -43,6 +43,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/bluepill_f103c8.json b/boards/bluepill_f103c8.json index ae872598..de121f2b 100644 --- a/boards/bluepill_f103c8.json +++ b/boards/bluepill_f103c8.json @@ -48,6 +48,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed", diff --git a/boards/bluepill_f103c8_128k.json b/boards/bluepill_f103c8_128k.json index d8703fcc..2132de92 100644 --- a/boards/bluepill_f103c8_128k.json +++ b/boards/bluepill_f103c8_128k.json @@ -47,6 +47,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "dfu" diff --git a/boards/cloud_jam.json b/boards/cloud_jam.json index ef239fd3..f789fce9 100644 --- a/boards/cloud_jam.json +++ b/boards/cloud_jam.json @@ -17,6 +17,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F401xE.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/cloud_jam_l4.json b/boards/cloud_jam_l4.json index d0520ebb..f59540d3 100644 --- a/boards/cloud_jam_l4.json +++ b/boards/cloud_jam_l4.json @@ -15,6 +15,7 @@ "stlink" ], "openocd_board": "st_nucleo_l4", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x6.svd" }, "frameworks": [ @@ -30,6 +31,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/coreboard_f401rc.json b/boards/coreboard_f401rc.json index 7c81d251..d8ae9403 100644 --- a/boards/coreboard_f401rc.json +++ b/boards/coreboard_f401rc.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "hid", diff --git a/boards/demo_f030f4.json b/boards/demo_f030f4.json index 90b39551..cf90d3a3 100644 --- a/boards/demo_f030f4.json +++ b/boards/demo_f030f4.json @@ -25,6 +25,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/disco_f030r8.json b/boards/disco_f030r8.json index 27cc8f68..1619401d 100644 --- a/boards/disco_f030r8.json +++ b/boards/disco_f030r8.json @@ -16,6 +16,7 @@ "stlink" ], "openocd_board": "stm32f0discovery", + "openocd_target": "stm32f0x", "svd_path": "STM32F030.svd" }, "frameworks": [ @@ -32,6 +33,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/disco_f051r8.json b/boards/disco_f051r8.json index 6e5df63b..884430c4 100644 --- a/boards/disco_f051r8.json +++ b/boards/disco_f051r8.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "stm32f0discovery", + "openocd_target": "stm32f0x", "svd_path": "STM32F0xx.svd" }, "frameworks": [ @@ -34,6 +35,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/disco_f072rb.json b/boards/disco_f072rb.json index 01d7a0c3..56d4ebf3 100644 --- a/boards/disco_f072rb.json +++ b/boards/disco_f072rb.json @@ -40,6 +40,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/disco_f100rb.json b/boards/disco_f100rb.json index 85ef6ae2..34443876 100644 --- a/boards/disco_f100rb.json +++ b/boards/disco_f100rb.json @@ -32,6 +32,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/disco_f303vc.json b/boards/disco_f303vc.json index 208deead..fc7d9d2b 100644 --- a/boards/disco_f303vc.json +++ b/boards/disco_f303vc.json @@ -20,6 +20,7 @@ "stlink" ], "openocd_board": "stm32f3discovery", + "openocd_target": "stm32f3x", "svd_path": "STM32F30x.svd" }, "frameworks": [ @@ -37,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_f334c8.json b/boards/disco_f334c8.json index acbbdace..92a64f83 100644 --- a/boards/disco_f334c8.json +++ b/boards/disco_f334c8.json @@ -15,6 +15,7 @@ "stlink" ], "openocd_board": "stm32f334discovery", + "openocd_target": "stm32f3x", "svd_path": "STM32F334x.svd" }, "frameworks": [ @@ -30,6 +31,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_f401vc.json b/boards/disco_f401vc.json index aa1e12d6..8bde9042 100644 --- a/boards/disco_f401vc.json +++ b/boards/disco_f401vc.json @@ -15,6 +15,7 @@ "stlink" ], "openocd_board": "stm32f4discovery", + "openocd_target": "stm32f4x", "svd_path": "STM32F401x.svd" }, "frameworks": [ @@ -30,6 +31,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/disco_f407vg.json b/boards/disco_f407vg.json index 44d67463..0f3c7807 100644 --- a/boards/disco_f407vg.json +++ b/boards/disco_f407vg.json @@ -2,7 +2,7 @@ "build": { "core": "stm32", "cpu": "cortex-m4", - "extra_flags": "-DSTM32F4 -DSTM32F407xx -DSTM32F40_41xxx -DARDUINO_STM32DiscoveryF407 -DBOARD_discovery_f4", + "extra_flags": "-DSTM32F4 -DSTM32F407xx -DSTM32F40_41xxx", "f_cpu": "168000000L", "mcu": "stm32f407vgt6", "variant": "DISCO_F407VG", @@ -20,6 +20,7 @@ "stlink" ], "openocd_board": "stm32f4discovery", + "openocd_target": "stm32f4x", "svd_path": "STM32F40x.svd" }, "frameworks": [ @@ -38,6 +39,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_f411ve.json b/boards/disco_f411ve.json index 0645c27a..5c6098d2 100644 --- a/boards/disco_f411ve.json +++ b/boards/disco_f411ve.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "stm32f4discovery", + "openocd_target": "stm32f4x", "svd_path": "STM32F411xx.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/disco_f412zg.json b/boards/disco_f412zg.json index 02e1f627..f0cf5a8c 100644 --- a/boards/disco_f412zg.json +++ b/boards/disco_f412zg.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F41x.svd" }, "frameworks": [ @@ -34,6 +35,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_f413zh.json b/boards/disco_f413zh.json index ec6ddccc..8dfe7b68 100644 --- a/boards/disco_f413zh.json +++ b/boards/disco_f413zh.json @@ -20,6 +20,7 @@ "stlink" ], "openocd_board": "stm32f4discovery", + "openocd_target": "stm32f4x", "svd_path": "STM32F41x.svd" }, "frameworks": [ @@ -36,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_f429zi.json b/boards/disco_f429zi.json index 7e325950..019de232 100644 --- a/boards/disco_f429zi.json +++ b/boards/disco_f429zi.json @@ -21,6 +21,7 @@ "stlink" ], "openocd_board": "stm32f429discovery", + "openocd_target": "stm32f4x", "svd_path": "STM32F429x.svd" }, "frameworks": [ @@ -37,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_f469ni.json b/boards/disco_f469ni.json index 25c24ed0..797cd9ff 100644 --- a/boards/disco_f469ni.json +++ b/boards/disco_f469ni.json @@ -21,6 +21,7 @@ "stlink" ], "openocd_board": "stm32f469discovery", + "openocd_target": "stm32f4x", "svd_path": "STM32F46_79x.svd" }, "frameworks": [ @@ -37,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_f723ie.json b/boards/disco_f723ie.json index ce0a7e59..c137b131 100644 --- a/boards/disco_f723ie.json +++ b/boards/disco_f723ie.json @@ -4,7 +4,7 @@ "extra_flags": "-DSTM32F723xx", "f_cpu": "216000000L", "mcu": "stm32f723iek6", - "product_line": "DSTM32F723xx", + "product_line": "STM32F723xx", "zephyr": { "variant": "stm32f723e_disco" } @@ -22,6 +22,7 @@ "stlink" ], "openocd_board": "stm32f7discovery", + "openocd_target": "stm32f7x", "svd_path": "STM32F7x3.svd" }, "frameworks": [ @@ -37,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/disco_f746ng.json b/boards/disco_f746ng.json index d8e56cad..70371752 100644 --- a/boards/disco_f746ng.json +++ b/boards/disco_f746ng.json @@ -23,6 +23,7 @@ "stlink" ], "openocd_board": "stm32f7discovery", + "openocd_target": "stm32f7x", "svd_path": "STM32F7x6.svd" }, "frameworks": [ @@ -40,6 +41,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_f750n8.json b/boards/disco_f750n8.json index d94c8b86..2b564329 100644 --- a/boards/disco_f750n8.json +++ b/boards/disco_f750n8.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "stm32f7discovery", + "openocd_target": "stm32f7x", "svd_path": "STM32F7x.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/disco_f769ni.json b/boards/disco_f769ni.json index 4aba8d1a..264ea1c6 100644 --- a/boards/disco_f769ni.json +++ b/boards/disco_f769ni.json @@ -22,6 +22,7 @@ "stlink" ], "openocd_board": "stm32f7discovery", + "openocd_target": "stm32f7x", "svd_path": "STM32F7x9.svd" }, "frameworks": [ @@ -38,6 +39,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_g031j6.json b/boards/disco_g031j6.json index 9b599809..c891c84d 100644 --- a/boards/disco_g031j6.json +++ b/boards/disco_g031j6.json @@ -13,12 +13,14 @@ }, "debug": { "jlink_device": "STM32G031J6", + "openocd_target": "stm32g0x", "svd_path": "STM32G031.svd" }, "frameworks": [ "arduino", "cmsis", - "libopencm3" + "libopencm3", + "stm32cube" ], "name": "ST STM32G0316-DISCO", "upload": { @@ -27,6 +29,7 @@ "protocol": "mbed", "protocols": [ "blackmagic", + "cmsis-dap", "dfu", "jlink", "serial", diff --git a/boards/disco_h747xi.json b/boards/disco_h747xi.json index 5dd6865d..40694720 100644 --- a/boards/disco_h747xi.json +++ b/boards/disco_h747xi.json @@ -22,6 +22,7 @@ "stlink" ], "openocd_board": "st_nucleo_h743zi", + "openocd_target": "stm32h7x", "svd_path": "STM32H7x7.svd" }, "frameworks": [ @@ -38,6 +39,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_l053c8.json b/boards/disco_l053c8.json index 8a8762a5..62990bff 100644 --- a/boards/disco_l053c8.json +++ b/boards/disco_l053c8.json @@ -15,6 +15,7 @@ "stlink" ], "openocd_board": "stm32l0discovery", + "openocd_target": "stm32l0", "svd_path": "STM32L053x.svd" }, "frameworks": [ @@ -30,6 +31,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_l072cz_lrwan1.json b/boards/disco_l072cz_lrwan1.json index cc9d53b3..d8f638a0 100644 --- a/boards/disco_l072cz_lrwan1.json +++ b/boards/disco_l072cz_lrwan1.json @@ -22,6 +22,7 @@ "stlink" ], "openocd_board": "stm32l0discovery", + "openocd_target": "stm32l0", "svd_path": "STM32L07x.svd" }, "frameworks": [ @@ -39,6 +40,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_l100rc.json b/boards/disco_l100rc.json index 4a8d4dba..2527e050 100644 --- a/boards/disco_l100rc.json +++ b/boards/disco_l100rc.json @@ -16,6 +16,7 @@ "stlink" ], "openocd_board": "st_nucleo_l1", + "openocd_target": "stm32l1", "svd_path": "STM32L1xx.svd" }, "frameworks": [ diff --git a/boards/disco_l152rb.json b/boards/disco_l152rb.json index a3d58c59..0d164ea3 100644 --- a/boards/disco_l152rb.json +++ b/boards/disco_l152rb.json @@ -17,6 +17,7 @@ "stlink" ], "openocd_board": "st_nucleo_l1", + "openocd_target": "stm32l1", "svd_path": "STM32L1xx.svd" }, "frameworks": [ @@ -32,6 +33,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/disco_l475vg_iot01a.json b/boards/disco_l475vg_iot01a.json index d739801b..41d6c79c 100644 --- a/boards/disco_l475vg_iot01a.json +++ b/boards/disco_l475vg_iot01a.json @@ -27,6 +27,7 @@ "stlink" ], "openocd_board": "stm32l4discovery", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x5.svd" }, "frameworks": [ @@ -44,6 +45,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_l476vg.json b/boards/disco_l476vg.json index 3bcb066b..b23921ee 100644 --- a/boards/disco_l476vg.json +++ b/boards/disco_l476vg.json @@ -21,6 +21,7 @@ "stlink" ], "openocd_board": "stm32l4discovery", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x6.svd" }, "frameworks": [ @@ -37,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/disco_l496ag.json b/boards/disco_l496ag.json index 2ba99b73..187f9aea 100644 --- a/boards/disco_l496ag.json +++ b/boards/disco_l496ag.json @@ -21,6 +21,7 @@ "stlink" ], "openocd_board": "stm32l4discovery", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x6.svd" }, "frameworks": [ @@ -37,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/diymore_f407vgt.json b/boards/diymore_f407vgt.json index 3154c5d0..a073c104 100644 --- a/boards/diymore_f407vgt.json +++ b/boards/diymore_f407vgt.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/electrosmith_daisy.json b/boards/electrosmith_daisy.json index 17257757..1038ce47 100644 --- a/boards/electrosmith_daisy.json +++ b/boards/electrosmith_daisy.json @@ -27,6 +27,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/elmo_f411re.json b/boards/elmo_f411re.json index d88e5780..f890ef10 100644 --- a/boards/elmo_f411re.json +++ b/boards/elmo_f411re.json @@ -12,6 +12,7 @@ ], "jlink_device": "STM32F411RE", "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F411xx.svd" }, "frameworks": [ @@ -27,6 +28,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/eval_f072vb.json b/boards/eval_f072vb.json index ac6aee16..6f85f9b8 100644 --- a/boards/eval_f072vb.json +++ b/boards/eval_f072vb.json @@ -30,6 +30,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/eval_f107vc.json b/boards/eval_f107vc.json index f9c881bf..86dab99f 100644 --- a/boards/eval_f107vc.json +++ b/boards/eval_f107vc.json @@ -27,6 +27,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/eval_f373vc.json b/boards/eval_f373vc.json index 055a7d2f..eba37a75 100644 --- a/boards/eval_f373vc.json +++ b/boards/eval_f373vc.json @@ -30,6 +30,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/eval_l073z.json b/boards/eval_l073z.json index 51651ad2..6c054864 100644 --- a/boards/eval_l073z.json +++ b/boards/eval_l073z.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/fk407m1.json b/boards/fk407m1.json index 9a5b04ba..d8780343 100644 --- a/boards/fk407m1.json +++ b/boards/fk407m1.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/fysetc_s6.json b/boards/fysetc_s6.json index 090e2c2d..e0d742a1 100644 --- a/boards/fysetc_s6.json +++ b/boards/fysetc_s6.json @@ -32,6 +32,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103C8.json b/boards/genericSTM32F103C8.json index 9a4157b9..6731b7d3 100644 --- a/boards/genericSTM32F103C8.json +++ b/boards/genericSTM32F103C8.json @@ -38,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103CB.json b/boards/genericSTM32F103CB.json index f00dc406..802845c7 100644 --- a/boards/genericSTM32F103CB.json +++ b/boards/genericSTM32F103CB.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103R8.json b/boards/genericSTM32F103R8.json index 477ba92b..f4191692 100644 --- a/boards/genericSTM32F103R8.json +++ b/boards/genericSTM32F103R8.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103RB.json b/boards/genericSTM32F103RB.json index 364a9c94..e58e3f16 100644 --- a/boards/genericSTM32F103RB.json +++ b/boards/genericSTM32F103RB.json @@ -38,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103RC.json b/boards/genericSTM32F103RC.json index 241c3c85..00b11d99 100644 --- a/boards/genericSTM32F103RC.json +++ b/boards/genericSTM32F103RC.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103RE.json b/boards/genericSTM32F103RE.json index c9c0ccfd..352f40e5 100644 --- a/boards/genericSTM32F103RE.json +++ b/boards/genericSTM32F103RE.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103T8.json b/boards/genericSTM32F103T8.json index 20107e05..8dfe90b7 100644 --- a/boards/genericSTM32F103T8.json +++ b/boards/genericSTM32F103T8.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103TB.json b/boards/genericSTM32F103TB.json index 7f78ff8f..1670c4cc 100644 --- a/boards/genericSTM32F103TB.json +++ b/boards/genericSTM32F103TB.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103VB.json b/boards/genericSTM32F103VB.json index 8567e4df..96f000ad 100644 --- a/boards/genericSTM32F103VB.json +++ b/boards/genericSTM32F103VB.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103VC.json b/boards/genericSTM32F103VC.json index 64312a96..738d662f 100644 --- a/boards/genericSTM32F103VC.json +++ b/boards/genericSTM32F103VC.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103VD.json b/boards/genericSTM32F103VD.json index 527e5699..5bc18d76 100644 --- a/boards/genericSTM32F103VD.json +++ b/boards/genericSTM32F103VD.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103VE.json b/boards/genericSTM32F103VE.json index c4de0fc4..ac8a9ba7 100644 --- a/boards/genericSTM32F103VE.json +++ b/boards/genericSTM32F103VE.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103ZC.json b/boards/genericSTM32F103ZC.json index d131b674..f60688d9 100644 --- a/boards/genericSTM32F103ZC.json +++ b/boards/genericSTM32F103ZC.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103ZD.json b/boards/genericSTM32F103ZD.json index e4bf37f8..df8e1e2c 100644 --- a/boards/genericSTM32F103ZD.json +++ b/boards/genericSTM32F103ZD.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F103ZE.json b/boards/genericSTM32F103ZE.json index 06bde69c..67068f9f 100644 --- a/boards/genericSTM32F103ZE.json +++ b/boards/genericSTM32F103ZE.json @@ -37,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/genericSTM32F303CB.json b/boards/genericSTM32F303CB.json index 7d7da45a..b27da219 100644 --- a/boards/genericSTM32F303CB.json +++ b/boards/genericSTM32F303CB.json @@ -27,6 +27,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/hy_tinystm103tb.json b/boards/hy_tinystm103tb.json index 1ce5e9e3..144375f3 100644 --- a/boards/hy_tinystm103tb.json +++ b/boards/hy_tinystm103tb.json @@ -37,6 +37,7 @@ "protocol": "dfu", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/malyanm200_f070cb.json b/boards/malyanm200_f070cb.json index 4c6fb7cc..2c92a84e 100644 --- a/boards/malyanm200_f070cb.json +++ b/boards/malyanm200_f070cb.json @@ -28,6 +28,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/malyanm200_f103cb.json b/boards/malyanm200_f103cb.json index 8341f561..1c0df076 100644 --- a/boards/malyanm200_f103cb.json +++ b/boards/malyanm200_f103cb.json @@ -40,6 +40,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/maple.json b/boards/maple.json index 82f20690..2e5698d9 100644 --- a/boards/maple.json +++ b/boards/maple.json @@ -37,6 +37,7 @@ "protocol": "dfu", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "dfu" diff --git a/boards/maple_mini_b20.json b/boards/maple_mini_b20.json index f024575e..cddea1e7 100644 --- a/boards/maple_mini_b20.json +++ b/boards/maple_mini_b20.json @@ -37,6 +37,7 @@ "protocol": "dfu", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "dfu" diff --git a/boards/maple_mini_origin.json b/boards/maple_mini_origin.json index 4f19669c..ffc182a6 100644 --- a/boards/maple_mini_origin.json +++ b/boards/maple_mini_origin.json @@ -40,6 +40,7 @@ "protocol": "dfu", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "dfu", diff --git a/boards/maple_ret6.json b/boards/maple_ret6.json index d26efa82..1b87feba 100644 --- a/boards/maple_ret6.json +++ b/boards/maple_ret6.json @@ -37,6 +37,7 @@ "protocol": "dfu", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "dfu" diff --git a/boards/mbed_connect_odin.json b/boards/mbed_connect_odin.json index df8f37fa..c2982859 100644 --- a/boards/mbed_connect_odin.json +++ b/boards/mbed_connect_odin.json @@ -2,7 +2,8 @@ "build": { "cpu": "cortex-m4", "f_cpu": "168000000L", - "mcu": "stm32f439ziy6" + "mcu": "stm32f439ziy6", + "product_line": "STM32F439xx" }, "connectivity": [ "bluetooth", @@ -30,9 +31,9 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", - "blackmagic", - "cmsis-dap" + "blackmagic" ] }, "url": "https://os.mbed.com/platforms/mbed-Connect-Cloud/", diff --git a/boards/microduino32_flash.json b/boards/microduino32_flash.json index eeb76e19..64908bb0 100644 --- a/boards/microduino32_flash.json +++ b/boards/microduino32_flash.json @@ -38,6 +38,7 @@ "protocol": "dfu", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "dfu" diff --git a/boards/mkr_sharky.json b/boards/mkr_sharky.json index eb8dcb39..56d8f248 100644 --- a/boards/mkr_sharky.json +++ b/boards/mkr_sharky.json @@ -12,6 +12,7 @@ ], "debug": { "jlink_device": "STM32WB55xx", + "openocd_target": "stm32wbx.cfg", "svd_path": "STM32WBxx.svd" }, "frameworks": [ @@ -24,6 +25,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "blackmagic", "mbed", "serial", diff --git a/boards/mote_l152rc.json b/boards/mote_l152rc.json index 2d0a6a1f..32bde526 100644 --- a/boards/mote_l152rc.json +++ b/boards/mote_l152rc.json @@ -9,6 +9,7 @@ "debug": { "jlink_device": "STM32L152RC", "openocd_board": "st_nucleo_l1", + "openocd_target": "stm32l1", "svd_path": "STM32L1xx.svd" }, "frameworks": [ @@ -24,6 +25,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/mtb_ublox_odin_w2.json b/boards/mtb_ublox_odin_w2.json index 31ddd590..ac644087 100644 --- a/boards/mtb_ublox_odin_w2.json +++ b/boards/mtb_ublox_odin_w2.json @@ -2,7 +2,8 @@ "build": { "cpu": "cortex-m4", "f_cpu": "168000000L", - "mcu": "stm32f439ziy6" + "mcu": "stm32f439ziy6", + "product_line": "STM32F439xx" }, "connectivity": [ "bluetooth", @@ -29,6 +30,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/mts_dragonfly_f411re.json b/boards/mts_dragonfly_f411re.json index a0e6275f..73c8b215 100644 --- a/boards/mts_dragonfly_f411re.json +++ b/boards/mts_dragonfly_f411re.json @@ -2,7 +2,8 @@ "build": { "cpu": "cortex-m4", "f_cpu": "100000000L", - "mcu": "stm32f411ret6" + "mcu": "stm32f411ret6", + "product_line": "STM32F411xE" }, "connectivity": [ "cellular" @@ -24,6 +25,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/mts_mdot_f405rg.json b/boards/mts_mdot_f405rg.json index 2765f202..16b249af 100644 --- a/boards/mts_mdot_f405rg.json +++ b/boards/mts_mdot_f405rg.json @@ -2,7 +2,8 @@ "build": { "cpu": "cortex-m4", "f_cpu": "100000000L", - "mcu": "stm32f411ret6" + "mcu": "stm32f411ret6", + "product_line": "STM32F411xE" }, "debug": { "jlink_device": "STM32F411RE", @@ -21,6 +22,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/mts_mdot_f411re.json b/boards/mts_mdot_f411re.json index fc2858b4..48a966a6 100644 --- a/boards/mts_mdot_f411re.json +++ b/boards/mts_mdot_f411re.json @@ -3,7 +3,8 @@ "cpu": "cortex-m4", "extra_flags": "-DSTM32F411xE", "f_cpu": "100000000L", - "mcu": "stm32f411ret6" + "mcu": "stm32f411ret6", + "product_line": "STM32F411xE" }, "debug": { "jlink_device": "STM32F411RE", @@ -22,6 +23,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/mxchip_az3166.json b/boards/mxchip_az3166.json index fcd47198..e99a3380 100644 --- a/boards/mxchip_az3166.json +++ b/boards/mxchip_az3166.json @@ -40,6 +40,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/nucleo_f030r8.json b/boards/nucleo_f030r8.json index afcced0d..151680b1 100644 --- a/boards/nucleo_f030r8.json +++ b/boards/nucleo_f030r8.json @@ -16,6 +16,7 @@ "stlink" ], "openocd_board": "st_nucleo_f0", + "openocd_target": "stm32f0x", "svd_path": "STM32F030.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f031k6.json b/boards/nucleo_f031k6.json index 33ef4f48..13d674d7 100644 --- a/boards/nucleo_f031k6.json +++ b/boards/nucleo_f031k6.json @@ -17,6 +17,7 @@ "stlink" ], "openocd_board": "st_nucleo_f0", + "openocd_target": "stm32f0x", "svd_path": "STM32F031x.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f042k6.json b/boards/nucleo_f042k6.json index 1be08643..41daf633 100644 --- a/boards/nucleo_f042k6.json +++ b/boards/nucleo_f042k6.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "st_nucleo_f0", + "openocd_target": "stm32f0x", "svd_path": "STM32F042x.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f070rb.json b/boards/nucleo_f070rb.json index d826bc97..5953e84b 100644 --- a/boards/nucleo_f070rb.json +++ b/boards/nucleo_f070rb.json @@ -15,6 +15,7 @@ "stlink" ], "openocd_board": "st_nucleo_f0", + "openocd_target": "stm32f0x", "svd_path": "STM32F0xx.svd" }, "frameworks": [ @@ -31,6 +32,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f072rb.json b/boards/nucleo_f072rb.json index 628593d0..89e1f421 100644 --- a/boards/nucleo_f072rb.json +++ b/boards/nucleo_f072rb.json @@ -20,6 +20,7 @@ "stlink" ], "openocd_board": "st_nucleo_f0", + "openocd_target": "stm32f0x", "svd_path": "STM32F072x.svd" }, "frameworks": [ @@ -36,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f091rc.json b/boards/nucleo_f091rc.json index 12685b7c..2bb0f26b 100644 --- a/boards/nucleo_f091rc.json +++ b/boards/nucleo_f091rc.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_f0", + "openocd_target": "stm32f0x", "svd_path": "STM32F091x.svd" }, "frameworks": [ @@ -36,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f103rb.json b/boards/nucleo_f103rb.json index 545abd4c..8b4653f2 100644 --- a/boards/nucleo_f103rb.json +++ b/boards/nucleo_f103rb.json @@ -17,6 +17,7 @@ "stlink" ], "openocd_board": "st_nucleo_f103rb", + "openocd_target": "stm32f1x", "svd_path": "STM32F103xx.svd" }, "frameworks": [ @@ -34,6 +35,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f207zg.json b/boards/nucleo_f207zg.json index b3ab74b9..27439e2c 100644 --- a/boards/nucleo_f207zg.json +++ b/boards/nucleo_f207zg.json @@ -38,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f302r8.json b/boards/nucleo_f302r8.json index 1d788908..31dd005c 100644 --- a/boards/nucleo_f302r8.json +++ b/boards/nucleo_f302r8.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_f3", + "openocd_target": "stm32f3x", "svd_path": "STM32F302x.svd" }, "frameworks": [ @@ -36,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f303k8.json b/boards/nucleo_f303k8.json index 32517ad8..2258d2ed 100644 --- a/boards/nucleo_f303k8.json +++ b/boards/nucleo_f303k8.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_f3", + "openocd_target": "stm32f3x", "svd_path": "STM32F30x.svd" }, "frameworks": [ @@ -35,6 +36,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f303re.json b/boards/nucleo_f303re.json index 8981568a..55629a15 100644 --- a/boards/nucleo_f303re.json +++ b/boards/nucleo_f303re.json @@ -16,6 +16,7 @@ "stlink" ], "openocd_board": "st_nucleo_f3", + "openocd_target": "stm32f3x", "svd_path": "STM32F303xE.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f303ze.json b/boards/nucleo_f303ze.json index eb9800e6..fcc1a45f 100644 --- a/boards/nucleo_f303ze.json +++ b/boards/nucleo_f303ze.json @@ -15,6 +15,7 @@ "stlink" ], "openocd_board": "st_nucleo_f3", + "openocd_target": "stm32f3x", "svd_path": "STM32F303xE.svd" }, "frameworks": [ @@ -30,6 +31,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f334r8.json b/boards/nucleo_f334r8.json index 81ffe166..3c9ea0d8 100644 --- a/boards/nucleo_f334r8.json +++ b/boards/nucleo_f334r8.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "st_nucleo_f3", + "openocd_target": "stm32f3x", "svd_path": "STM32F334x.svd" }, "frameworks": [ @@ -34,6 +35,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f401re.json b/boards/nucleo_f401re.json index 8ae04d8d..4f3caa60 100644 --- a/boards/nucleo_f401re.json +++ b/boards/nucleo_f401re.json @@ -17,6 +17,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F401xE.svd" }, "frameworks": [ @@ -35,6 +36,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f410rb.json b/boards/nucleo_f410rb.json index 35ed3633..207f04d7 100644 --- a/boards/nucleo_f410rb.json +++ b/boards/nucleo_f410rb.json @@ -15,6 +15,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F41x.svd" }, "frameworks": [ @@ -30,6 +31,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f411re.json b/boards/nucleo_f411re.json index 53e5bb5f..40569728 100644 --- a/boards/nucleo_f411re.json +++ b/boards/nucleo_f411re.json @@ -16,6 +16,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F411xx.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f412zg.json b/boards/nucleo_f412zg.json index 2793c570..b7493853 100644 --- a/boards/nucleo_f412zg.json +++ b/boards/nucleo_f412zg.json @@ -15,6 +15,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F41x.svd" }, "frameworks": [ @@ -31,6 +32,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f413zh.json b/boards/nucleo_f413zh.json index 936f731e..8cf77670 100644 --- a/boards/nucleo_f413zh.json +++ b/boards/nucleo_f413zh.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F41x.svd" }, "frameworks": [ @@ -34,6 +35,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f429zi.json b/boards/nucleo_f429zi.json index dee10427..c0a76a7d 100644 --- a/boards/nucleo_f429zi.json +++ b/boards/nucleo_f429zi.json @@ -20,6 +20,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F429x.svd" }, "frameworks": [ @@ -37,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f439zi.json b/boards/nucleo_f439zi.json index a8d3f964..6ce4fb30 100644 --- a/boards/nucleo_f439zi.json +++ b/boards/nucleo_f439zi.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F439x.svd" }, "frameworks": [ @@ -34,6 +35,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f446re.json b/boards/nucleo_f446re.json index dcea8a8b..decbb52e 100644 --- a/boards/nucleo_f446re.json +++ b/boards/nucleo_f446re.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F446x.svd" }, "frameworks": [ @@ -36,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f446ze.json b/boards/nucleo_f446ze.json index c1d90202..0d872ebb 100644 --- a/boards/nucleo_f446ze.json +++ b/boards/nucleo_f446ze.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F446x.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f722ze.json b/boards/nucleo_f722ze.json index ac919926..f453e776 100644 --- a/boards/nucleo_f722ze.json +++ b/boards/nucleo_f722ze.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "st_nucleo_f7", + "openocd_target": "stm32f7x", "svd_path": "STM32F7x2.svd" }, "frameworks": [ @@ -32,6 +33,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f746zg.json b/boards/nucleo_f746zg.json index 6979584f..b82b59ad 100644 --- a/boards/nucleo_f746zg.json +++ b/boards/nucleo_f746zg.json @@ -21,6 +21,7 @@ "stlink" ], "openocd_board": "st_nucleo_f7", + "openocd_target": "stm32f7x", "svd_path": "STM32F7x6.svd" }, "frameworks": [ @@ -38,6 +39,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f756zg.json b/boards/nucleo_f756zg.json index 8a901710..6657e0ff 100644 --- a/boards/nucleo_f756zg.json +++ b/boards/nucleo_f756zg.json @@ -21,6 +21,7 @@ "stlink" ], "openocd_board": "st_nucleo_f7", + "openocd_target": "stm32f7x", "svd_path": "STM32F7x6.svd" }, "frameworks": [ @@ -38,6 +39,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_f767zi.json b/boards/nucleo_f767zi.json index 3568ee24..7d4b2547 100644 --- a/boards/nucleo_f767zi.json +++ b/boards/nucleo_f767zi.json @@ -20,6 +20,7 @@ "stlink" ], "openocd_board": "st_nucleo_f7", + "openocd_target": "stm32f7x", "svd_path": "STM32F7x7.svd" }, "frameworks": [ @@ -37,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_g071rb.json b/boards/nucleo_g071rb.json index 9c23f3e5..a7a671ee 100644 --- a/boards/nucleo_g071rb.json +++ b/boards/nucleo_g071rb.json @@ -13,12 +13,14 @@ }, "debug": { "jlink_device": "STM32G071RB", + "openocd_target": "stm32g0x", "svd_path": "STM32G071.svd" }, "frameworks": [ "arduino", "cmsis", "libopencm3", + "stm32cube", "zephyr" ], "name": "Nucleo G071RB", @@ -28,6 +30,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "blackmagic", "mbed" ] diff --git a/boards/nucleo_g431kb.json b/boards/nucleo_g431kb.json index 7a161098..b80628b1 100644 --- a/boards/nucleo_g431kb.json +++ b/boards/nucleo_g431kb.json @@ -13,12 +13,14 @@ ], "debug": { "jlink_device": "STM32G431KB", + "openocd_target": "stm32g4x", "svd_path": "STM32G431xx.svd" }, "frameworks": [ "arduino", "cmsis", - "libopencm3" + "libopencm3", + "stm32cube" ], "name": "Nucleo G431KB", "upload": { @@ -27,6 +29,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "blackmagic", "mbed" ] diff --git a/boards/nucleo_g431rb.json b/boards/nucleo_g431rb.json index a6399ba1..ff440567 100644 --- a/boards/nucleo_g431rb.json +++ b/boards/nucleo_g431rb.json @@ -13,12 +13,14 @@ ], "debug": { "jlink_device": "STM32G431RB", + "openocd_target": "stm32g4x", "svd_path": "STM32G431xx.svd" }, "frameworks": [ "arduino", "cmsis", "libopencm3", + "stm32cube", "zephyr" ], "name": "Nucleo G431RB", @@ -28,6 +30,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "blackmagic", "mbed" ] diff --git a/boards/nucleo_g474re.json b/boards/nucleo_g474re.json index 67f2dedf..cce58ef4 100644 --- a/boards/nucleo_g474re.json +++ b/boards/nucleo_g474re.json @@ -13,6 +13,7 @@ ], "debug": { "jlink_device": "STM32G474RE", + "openocd_target": "stm32g4x", "svd_path": "STM32G474xx.svd" }, "frameworks": [ @@ -20,6 +21,7 @@ "cmsis", "mbed", "libopencm3", + "stm32cube", "zephyr" ], "name": "Nucleo G474RE", @@ -29,6 +31,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "blackmagic", "mbed" ] diff --git a/boards/nucleo_h743zi.json b/boards/nucleo_h743zi.json index 55f3ac1a..2cb9abe1 100644 --- a/boards/nucleo_h743zi.json +++ b/boards/nucleo_h743zi.json @@ -21,6 +21,7 @@ "stlink" ], "openocd_board": "st_nucleo_h743zi", + "openocd_target": "stm32h7x", "svd_path": "STM32H7x3.svd" }, "frameworks": [ @@ -37,6 +38,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_h745zi_q.json b/boards/nucleo_h745zi_q.json new file mode 100644 index 00000000..0e9f2ecb --- /dev/null +++ b/boards/nucleo_h745zi_q.json @@ -0,0 +1,49 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m7", + "extra_flags": "-DSTM32H7xx -DSTM32H745xx", + "f_cpu": "480000000L", + "mcu": "stm32h745zit6", + "product_line": "STM32H745xx", + "zephyr": { + "variant": "nucleo_h745zi_q_m7" + } + }, + "connectivity": [ + "can", + "ethernet" + ], + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32H745ZI", + "onboard_tools": [ + "stlink" + ], + "openocd_board": "st_nucleo_h745zi", + "openocd_target": "stm32h7x", + "svd_path": "STM32H7x5.svd" + }, + "frameworks": [ + "cmsis", + "stm32cube", + "zephyr" + ], + "name": "ST Nucleo H745ZI-Q", + "upload": { + "maximum_ram_size": 524288, + "maximum_size": 1048576, + "protocol": "stlink", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "blackmagic", + "mbed" + ] + }, + "url": "https://www.st.com/en/evaluation-tools/nucleo-h745zi-q.html", + "vendor": "ST" +} diff --git a/boards/nucleo_l011k4.json b/boards/nucleo_l011k4.json index 2e0cb0cb..f3ffbdb6 100644 --- a/boards/nucleo_l011k4.json +++ b/boards/nucleo_l011k4.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/nucleo_l031k6.json b/boards/nucleo_l031k6.json index b8743fda..d1b71e68 100644 --- a/boards/nucleo_l031k6.json +++ b/boards/nucleo_l031k6.json @@ -32,6 +32,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l053r8.json b/boards/nucleo_l053r8.json index 774cc45d..989e61b6 100644 --- a/boards/nucleo_l053r8.json +++ b/boards/nucleo_l053r8.json @@ -36,6 +36,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l073rz.json b/boards/nucleo_l073rz.json index 82cb55d8..4b449599 100644 --- a/boards/nucleo_l073rz.json +++ b/boards/nucleo_l073rz.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_l073rz", + "openocd_target": "stm32l0", "svd_path": "STM32L07x.svd" }, "frameworks": [ @@ -36,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l152re.json b/boards/nucleo_l152re.json index a8acf3c6..05aa75fc 100644 --- a/boards/nucleo_l152re.json +++ b/boards/nucleo_l152re.json @@ -16,6 +16,7 @@ "stlink" ], "openocd_board": "st_nucleo_l1", + "openocd_target": "stm32l1", "svd_path": "STM32L15xxE.svd" }, "frameworks": [ @@ -32,6 +33,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l412kb.json b/boards/nucleo_l412kb.json index be763a8e..e7e3369d 100644 --- a/boards/nucleo_l412kb.json +++ b/boards/nucleo_l412kb.json @@ -16,6 +16,7 @@ "stlink" ], "openocd_board": "st_nucleo_l4", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x2.svd" }, "frameworks": [ @@ -30,6 +31,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/nucleo_l432kc.json b/boards/nucleo_l432kc.json index a0c960d4..b80561a4 100644 --- a/boards/nucleo_l432kc.json +++ b/boards/nucleo_l432kc.json @@ -33,6 +33,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l433rc_p.json b/boards/nucleo_l433rc_p.json index 9ae897cf..2b5939a0 100644 --- a/boards/nucleo_l433rc_p.json +++ b/boards/nucleo_l433rc_p.json @@ -17,6 +17,7 @@ "stlink" ], "openocd_board": "st_nucleo_l4", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x3.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l452re.json b/boards/nucleo_l452re.json index 642aa279..385e6292 100644 --- a/boards/nucleo_l452re.json +++ b/boards/nucleo_l452re.json @@ -35,6 +35,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l476rg.json b/boards/nucleo_l476rg.json index 971e6e5b..200d4e4a 100644 --- a/boards/nucleo_l476rg.json +++ b/boards/nucleo_l476rg.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_l4", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x6.svd" }, "frameworks": [ @@ -36,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l486rg.json b/boards/nucleo_l486rg.json index 79253c59..8b9ca5ea 100644 --- a/boards/nucleo_l486rg.json +++ b/boards/nucleo_l486rg.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "st_nucleo_l4", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x6.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l496zg.json b/boards/nucleo_l496zg.json index 5ba972c4..d39cd4c7 100644 --- a/boards/nucleo_l496zg.json +++ b/boards/nucleo_l496zg.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_l4", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x6.svd" }, "frameworks": [ @@ -36,6 +37,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l496zg_p.json b/boards/nucleo_l496zg_p.json index ab5fbbd2..5fcdc4af 100644 --- a/boards/nucleo_l496zg_p.json +++ b/boards/nucleo_l496zg_p.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_l4", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x6.svd" }, "frameworks": [ @@ -35,6 +36,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_l4r5zi.json b/boards/nucleo_l4r5zi.json index d51f13f3..1b56648c 100644 --- a/boards/nucleo_l4r5zi.json +++ b/boards/nucleo_l4r5zi.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_l4", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x5.svd" }, "frameworks": [ @@ -35,6 +36,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/nucleo_wb55rg_p.json b/boards/nucleo_wb55rg_p.json index f915e74a..a859be4b 100644 --- a/boards/nucleo_wb55rg_p.json +++ b/boards/nucleo_wb55rg_p.json @@ -30,6 +30,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/olimex_e407.json b/boards/olimex_e407.json index d147bbe7..b395eb41 100644 --- a/boards/olimex_e407.json +++ b/boards/olimex_e407.json @@ -36,6 +36,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/olimex_f103.json b/boards/olimex_f103.json index 0f59fa1a..8f915ec2 100644 --- a/boards/olimex_f103.json +++ b/boards/olimex_f103.json @@ -30,6 +30,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/olimex_h407.json b/boards/olimex_h407.json index 295fe7c4..2aed499c 100644 --- a/boards/olimex_h407.json +++ b/boards/olimex_h407.json @@ -36,6 +36,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/olimex_p405.json b/boards/olimex_p405.json index 83e0ba66..3a42bccd 100644 --- a/boards/olimex_p405.json +++ b/boards/olimex_p405.json @@ -30,6 +30,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/olimexino.json b/boards/olimexino.json index 2dd362dd..c783c029 100644 --- a/boards/olimexino.json +++ b/boards/olimexino.json @@ -31,6 +31,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/piconomix_px_her0.json b/boards/piconomix_px_her0.json index 78956bb3..3e1b9158 100644 --- a/boards/piconomix_px_her0.json +++ b/boards/piconomix_px_her0.json @@ -12,7 +12,7 @@ }, "debug": { "jlink_device": "STM32L072RB", - "openocd_target": "stm32l0x", + "openocd_target": "stm32l0", "svd_path": "STM32L07x.svd" }, "frameworks": [ diff --git a/boards/pybstick26_lite.json b/boards/pybstick26_lite.json index bfda540f..3c164f38 100644 --- a/boards/pybstick26_lite.json +++ b/boards/pybstick26_lite.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/pybstick26_pro.json b/boards/pybstick26_pro.json index a7103bf8..12d247c5 100644 --- a/boards/pybstick26_pro.json +++ b/boards/pybstick26_pro.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "dfu", diff --git a/boards/pybstick26_std.json b/boards/pybstick26_std.json index 67953279..31e14427 100644 --- a/boards/pybstick26_std.json +++ b/boards/pybstick26_std.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/rak811_tracker.json b/boards/rak811_tracker.json index 64874b34..898957a4 100644 --- a/boards/rak811_tracker.json +++ b/boards/rak811_tracker.json @@ -25,6 +25,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/rak811_tracker_32.json b/boards/rak811_tracker_32.json index b044eed3..0cc89848 100644 --- a/boards/rak811_tracker_32.json +++ b/boards/rak811_tracker_32.json @@ -25,6 +25,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/remram_v1.json b/boards/remram_v1.json index 96187bd4..2ca3f84e 100644 --- a/boards/remram_v1.json +++ b/boards/remram_v1.json @@ -34,6 +34,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/rhf76_052.json b/boards/rhf76_052.json index df2369ef..51448337 100644 --- a/boards/rhf76_052.json +++ b/boards/rhf76_052.json @@ -16,7 +16,7 @@ ], "debug": { "jlink_device": "STM32L051C8", - "openocd_target": "stm32l0x", + "openocd_target": "stm32l0", "svd_path": "STM32L051x.svd" }, "frameworks": [ @@ -32,6 +32,7 @@ "protocol": "serial", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "dfu", diff --git a/boards/rhombio_l476dmw1k.json b/boards/rhombio_l476dmw1k.json index 1b97a574..0a213174 100644 --- a/boards/rhombio_l476dmw1k.json +++ b/boards/rhombio_l476dmw1k.json @@ -33,9 +33,9 @@ "protocol": "cmsis-dap", "protocols": [ "jlink", + "cmsis-dap", "stlink", - "blackmagic", - "cmsis-dap" + "blackmagic" ] }, "url": "https://os.mbed.com/platforms/RHOMBIO-L476DMW1K/", diff --git a/boards/robotdyn_blackpill_f303cc.json b/boards/robotdyn_blackpill_f303cc.json index 005964a4..b84aa72f 100644 --- a/boards/robotdyn_blackpill_f303cc.json +++ b/boards/robotdyn_blackpill_f303cc.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/rumba32_f446ve.json b/boards/rumba32_f446ve.json index 6158fbe7..58cf689f 100644 --- a/boards/rumba32_f446ve.json +++ b/boards/rumba32_f446ve.json @@ -28,6 +28,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/sakuraio_evb_01.json b/boards/sakuraio_evb_01.json index 9d403278..162c346a 100644 --- a/boards/sakuraio_evb_01.json +++ b/boards/sakuraio_evb_01.json @@ -30,10 +30,10 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "stlink", "mbed", - "blackmagic", - "cmsis-dap" + "blackmagic" ] }, "url": "https://os.mbed.com/platforms/SAKURAIO_EVB_01/", diff --git a/boards/seeedArchMax.json b/boards/seeedArchMax.json index dccbbe2b..c289be3c 100644 --- a/boards/seeedArchMax.json +++ b/boards/seeedArchMax.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F40x.svd" }, "frameworks": [ @@ -33,6 +34,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/silica_sensor_node.json b/boards/silica_sensor_node.json index c0190014..47ee0844 100644 --- a/boards/silica_sensor_node.json +++ b/boards/silica_sensor_node.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_l4", + "openocd_target": "stm32l4x", "svd_path": "STM32L4x6.svd" }, "frameworks": [ @@ -34,6 +35,7 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "mbed" diff --git a/boards/sparky_v1.json b/boards/sparky_v1.json index 9f0e57c6..5b5384e4 100644 --- a/boards/sparky_v1.json +++ b/boards/sparky_v1.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/st3dp001_eval.json b/boards/st3dp001_eval.json index e0ea67da..f8629935 100644 --- a/boards/st3dp001_eval.json +++ b/boards/st3dp001_eval.json @@ -17,6 +17,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F401xG.svd" }, "frameworks": [ @@ -31,6 +32,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/steval_fcu001v1.json b/boards/steval_fcu001v1.json index 37801fa4..f2b24513 100644 --- a/boards/steval_fcu001v1.json +++ b/boards/steval_fcu001v1.json @@ -24,6 +24,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/steval_mksboxv1.json b/boards/steval_mksboxv1.json index b9849b4f..1ec0a82d 100644 --- a/boards/steval_mksboxv1.json +++ b/boards/steval_mksboxv1.json @@ -32,6 +32,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "dfu" diff --git a/boards/thunder_pack.json b/boards/thunder_pack.json index f5319a81..6bf68af4 100644 --- a/boards/thunder_pack.json +++ b/boards/thunder_pack.json @@ -12,7 +12,7 @@ }, "debug": { "jlink_device": "STM32L072KZ", - "openocd_target": "stm32l0x", + "openocd_target": "stm32l0", "svd_path": "STM32L07x.svd" }, "frameworks": [ diff --git a/boards/thunder_pack_f411.json b/boards/thunder_pack_f411.json index 8ee48191..dd51f5ae 100644 --- a/boards/thunder_pack_f411.json +++ b/boards/thunder_pack_f411.json @@ -29,6 +29,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/ublox_c030_n211.json b/boards/ublox_c030_n211.json index cb2991e4..27c3fdf1 100644 --- a/boards/ublox_c030_n211.json +++ b/boards/ublox_c030_n211.json @@ -25,10 +25,10 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", - "mbed", - "cmsis-dap" + "mbed" ] }, "url": "https://os.mbed.com/platforms/ublox-C030-N211/", diff --git a/boards/ublox_c030_r410m.json b/boards/ublox_c030_r410m.json index f1f6cc17..cce2ea5c 100644 --- a/boards/ublox_c030_r410m.json +++ b/boards/ublox_c030_r410m.json @@ -18,6 +18,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F437x.svd" }, "frameworks": [ diff --git a/boards/ublox_c030_u201.json b/boards/ublox_c030_u201.json index 3372e01e..3285e534 100644 --- a/boards/ublox_c030_u201.json +++ b/boards/ublox_c030_u201.json @@ -24,10 +24,10 @@ "protocol": "mbed", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", - "mbed", - "cmsis-dap" + "mbed" ] }, "url": "https://os.mbed.com/platforms/ublox-C030-N211/", diff --git a/boards/ublox_evk_odin_w2.json b/boards/ublox_evk_odin_w2.json index adbe29d1..717ac737 100644 --- a/boards/ublox_evk_odin_w2.json +++ b/boards/ublox_evk_odin_w2.json @@ -26,6 +26,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/vake_v1.json b/boards/vake_v1.json index ade8d1f2..6b8e3a78 100644 --- a/boards/vake_v1.json +++ b/boards/vake_v1.json @@ -28,6 +28,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial" diff --git a/boards/vccgnd_f103zet6.json b/boards/vccgnd_f103zet6.json index f28b22e6..efb122b6 100644 --- a/boards/vccgnd_f103zet6.json +++ b/boards/vccgnd_f103zet6.json @@ -26,6 +26,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic", "serial", diff --git a/boards/waveshare_open103z.json b/boards/waveshare_open103z.json index e56a3d7e..5982d371 100644 --- a/boards/waveshare_open103z.json +++ b/boards/waveshare_open103z.json @@ -26,6 +26,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/boards/wio_3g.json b/boards/wio_3g.json index 160a5bff..8172a411 100644 --- a/boards/wio_3g.json +++ b/boards/wio_3g.json @@ -19,6 +19,7 @@ "stlink" ], "openocd_board": "st_nucleo_f4", + "openocd_target": "stm32f4x", "svd_path": "STM32F439x.svd" }, "frameworks": [ diff --git a/boards/xdot_l151cc.json b/boards/xdot_l151cc.json index 1393f08e..2237c450 100644 --- a/boards/xdot_l151cc.json +++ b/boards/xdot_l151cc.json @@ -9,6 +9,7 @@ "debug": { "jlink_device": "STM32L151CC", "openocd_board": "st_nucleo_l1", + "openocd_target": "stm32l1", "svd_path": "STM32L15xC.svd" }, "frameworks": [ @@ -24,6 +25,7 @@ "protocol": "stlink", "protocols": [ "jlink", + "cmsis-dap", "stlink", "blackmagic" ] diff --git a/builder/frameworks/stm32cube.py b/builder/frameworks/stm32cube.py index 33eb42ef..212163f5 100644 --- a/builder/frameworks/stm32cube.py +++ b/builder/frameworks/stm32cube.py @@ -22,42 +22,29 @@ http://www.st.com/en/embedded-software/stm32cube-embedded-software.html?querycriteria=productId=LN1897 """ -from glob import glob -from os import listdir -from os.path import basename, isdir, isfile, join -from shutil import copy -from string import Template +import glob +import os +import shutil +import string import sys from SCons.Script import DefaultEnvironment -from platformio import fs from platformio.builder.tools.piolib import PlatformIOLibBuilder env = DefaultEnvironment() platform = env.PioPlatform() board = env.BoardConfig() -FRAMEWORK_DIR = platform.get_package_dir("framework-stm32cube") -assert isdir(FRAMEWORK_DIR) +MCU = board.get("build.mcu", "") +MCU_FAMILY = MCU[0:7] -FRAMEWORK_CORE = board.get("build.mcu")[5:7].lower() -MCU_FAMILY = board.get("build.mcu")[0:7] +PRODUCT_LINE = board.get("build.product_line", "") +assert PRODUCT_LINE, "Missing MCU or Product Line field" -STARTUP_FILE_EXCEPTIONS = { - "stm32f030f4": "startup_stm32f030x6.s", - "stm32f103c8": "startup_stm32f103xb.s", - "stm32f103r8": "startup_stm32f103xb.s", - "stm32f103rc": "startup_stm32f103xb.s", - "stm32f103t8": "startup_stm32f103xb.s", - "stm32f103vc": "startup_stm32f103xe.s", - "stm32f103vd": "startup_stm32f103xe.s", - "stm32f103ve": "startup_stm32f103xe.s", - "stm32f103zc": "startup_stm32f103xe.s", - "stm32f103zd": "startup_stm32f103xe.s", - "stm32f303cb": "startup_stm32f303xc.s", - "stm32f407ve": "startup_stm32f407xx.s" -} +FRAMEWORK_DIR = platform.get_package_dir("framework-stm32cube%s" % MCU[5:7]) +LDSCRIPTS_DIR = platform.get_package_dir("tool-ldscripts-ststm32") +assert all(os.path.isdir(d) for d in (FRAMEWORK_DIR, LDSCRIPTS_DIR)) class CustomLibBuilder(PlatformIOLibBuilder): @@ -76,89 +63,123 @@ def src_dir(self): return self.path -def get_startup_file(mcu): - if len(mcu) > 12: - mcu = mcu[:-2] +def generate_ldscript(default_ldscript_path): + ram = board.get("upload.maximum_ram_size", 0) + flash = board.get("upload.maximum_size", 0) + template_file = os.path.join(LDSCRIPTS_DIR, "tpl", "linker.tpl") + content = "" + with open(template_file) as fp: + data = string.Template(fp.read()) + content = data.substitute( + stack=hex(0x20000000 + ram), # 0x20000000 - start address for RAM + ram=str(int(ram / 1024)) + "K", + flash=str(int(flash / 1024)) + "K", + ) + + with open(default_ldscript_path, "w") as fp: + fp.write(content) - search_path = join( - FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", "CMSIS", "Device", - "ST", mcu[0:7].upper() + "xx", "Source", "Templates", "gcc" - ) - search_path = join( - search_path, - "startup_" + mcu[0:9] + "[" + mcu[9] + "|x]" + - "[" + mcu[10] + "|x]" + ".[sS]" +def get_linker_script(board_mcu): + ldscript_match = glob.glob( + os.path.join( + LDSCRIPTS_DIR, board_mcu[0:7], board_mcu[0:11].upper() + "*_FLASH.ld" + ) ) - if mcu in STARTUP_FILE_EXCEPTIONS: - return STARTUP_FILE_EXCEPTIONS[mcu] + if ldscript_match and os.path.isfile(ldscript_match[0]): + return ldscript_match[0] - startup_file = glob(search_path) + default_ldscript = os.path.join( + LDSCRIPTS_DIR, board_mcu[0:7], board_mcu[0:11].upper() + "_DEFAULT.ld" + ) - if not startup_file: - sys.stderr.write( - """Error: There is no default startup file for %s MCU! - Please add initialization code to your project manually!""" % mcu) - env.Exit(1) - return basename(startup_file[0]) + print( + "Warning! Cannot find a linker script for the required board! " + "An auto-generated script will be used to link firmware!" + ) + if not os.path.isfile(default_ldscript): + generate_ldscript(default_ldscript) -def get_linker_script(mcu): - ldscript = join(FRAMEWORK_DIR, "platformio", - "ldscripts", mcu[0:11].upper() + "_FLASH.ld") + return default_ldscript - if isfile(ldscript): - return ldscript - default_ldscript = join(FRAMEWORK_DIR, "platformio", - "ldscripts", mcu[0:11].upper() + "_DEFAULT.ld") +def prepare_startup_file(src_path): + startup_file = os.path.join(src_path, "gcc", "startup_%s.S" % PRODUCT_LINE.lower()) + # Change file extension to uppercase + if not os.path.isfile(startup_file) and os.path.isfile(startup_file[:-2] + ".s"): + os.rename(startup_file[:-2] + ".s", startup_file) + if not os.path.isfile(startup_file): + print( + "Warning! Cannot find the default startup file for `%s`. " + "Ignore this warning if the startup code is part of your project." % MCU + ) - print("Warning! Cannot find a linker script for the required board! " - "Firmware will be linked with a default linker script!") - if isfile(default_ldscript): - return default_ldscript +def generate_hal_config_file(): + config_path = os.path.join( + FRAMEWORK_DIR, + "Drivers", + MCU_FAMILY.upper() + "xx_HAL_Driver", + "Inc", + ) - ram = board.get("upload.maximum_ram_size", 0) - flash = board.get("upload.maximum_size", 0) - template_file = join(FRAMEWORK_DIR, "platformio", - "ldscripts", "tpl", "linker.tpl") - content = "" - with open(template_file) as fp: - data = Template(fp.read()) - content = data.substitute( - stack=hex(0x20000000 + ram), # 0x20000000 - start address for RAM - ram=str(int(ram/1024)) + "K", - flash=str(int(flash/1024)) + "K" + if os.path.isfile(os.path.join(config_path, MCU_FAMILY + "xx_hal_conf.h")): + return + + if not os.path.isfile( + os.path.join(config_path, MCU_FAMILY + "xx_hal_conf_template.h") + ): + sys.stderr.write( + "Error: Cannot find peripheral template file to configure framework!\n" ) + env.Exit(1) - with open(default_ldscript, "w") as fp: - fp.write(content) + shutil.copy( + os.path.join(config_path, MCU_FAMILY + "xx_hal_conf_template.h"), + os.path.join(config_path, MCU_FAMILY + "xx_hal_conf.h"), + ) - return default_ldscript +def build_custom_lib(lib_path, lib_manifest=None): + if board.get("build.stm32cube.disable_embedded_libs", "no") == "yes": + return + if lib_path: + lib_manifest = lib_manifest or {"name": os.path.basename(lib_path)} + env.Append( + EXTRA_LIB_BUILDERS=[ + PlatformIOLibBuilder(env, lib_path, lib_manifest.copy()) + ] + ) -def generate_hal_config_file(mcu): - config_path = join(FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", - MCU_FAMILY.upper() + "xx_HAL_Driver", "Inc") - if isfile(join(config_path, MCU_FAMILY + "xx_hal_conf.h")): - return +def build_usb_libs(usb_libs_root): + # Note: config files for USB peripheral is located in project dirs + manifest = { + "build": { + "flags": ["-I $PROJECT_SRC_DIR", "-I $PROJECT_INCLUDE_DIR"], + "includeDir": "Inc", + "srcDir": "Src", + "srcFilter": ["+<*>", "-"], + } + } - if not isfile(join(config_path, MCU_FAMILY + "xx_hal_conf_template.h")): - sys.stderr.write( - "Error: Cannot find template file to configure framework!\n") - env.Exit(1) + usb_core_dir = os.path.join(usb_libs_root, "Core") + if os.path.isdir(usb_core_dir): + manifest["name"] = os.path.basename(usb_libs_root) + "-Core" + build_custom_lib(usb_core_dir, manifest) - copy(join(config_path, MCU_FAMILY + "xx_hal_conf_template.h"), - join(config_path, MCU_FAMILY + "xx_hal_conf.h")) + usb_class_dir = os.path.join(usb_libs_root, "Class") + if os.path.isdir(usb_class_dir): + for device_class in os.listdir(usb_class_dir): + if device_class.lower() == "template": + continue + manifest["name"] = "%s-%s" % (os.path.basename(usb_libs_root), device_class) + build_custom_lib(os.path.join(usb_class_dir, device_class), manifest) -env.Replace( - AS="$CC", - ASCOM="$ASPPCOM" -) +env.Replace(AS="$CC", ASCOM="$ASPPCOM") env.Append( ASFLAGS=["-x", "assembler-with-cpp"], @@ -170,7 +191,7 @@ def generate_hal_config_file(mcu): "-Wall", "-mthumb", "-mcpu=%s" % board.get("build.cpu"), - "-nostdlib" + "-nostdlib", ], CPPDEFINES=[ @@ -178,6 +199,33 @@ def generate_hal_config_file(mcu): ("F_CPU", "$BOARD_F_CPU") ], + CPPPATH=[ + "$PROJECT_SRC_DIR", + "$PROJECT_INCLUDE_DIR", + os.path.join(FRAMEWORK_DIR, "Drivers", "CMSIS", "Include"), + os.path.join( + FRAMEWORK_DIR, + "Drivers", + "CMSIS", + "Device", + "ST", + MCU_FAMILY.upper() + "xx", + "Include", + ), + os.path.join( + FRAMEWORK_DIR, + "Drivers", + MCU_FAMILY.upper() + "xx_HAL_Driver", + "Inc", + ), + os.path.join( + FRAMEWORK_DIR, + "Drivers", + MCU_FAMILY.upper() + "xx_HAL_Driver", + "Src", + ), + ], + CXXFLAGS=[ "-fno-rtti", "-fno-exceptions" @@ -189,98 +237,133 @@ def generate_hal_config_file(mcu): "-mthumb", "-mcpu=%s" % board.get("build.cpu"), "--specs=nano.specs", - "--specs=nosys.specs" + "--specs=nosys.specs", + ], + + LIBPATH=[ + os.path.join(FRAMEWORK_DIR, "Drivers", "CMSIS", "Lib", "GCC"), + os.path.join(FRAMEWORK_DIR, "platformio", "ldscripts"), ], - LIBS=["c", "gcc", "m", "stdc++", "nosys"] + LIBS=["c", "gcc", "m", "stdc++", "nosys"], ) # copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode) env.Append(ASFLAGS=env.get("CCFLAGS", [])[:]) -cpp_flags = env.Flatten(env.get("CPPDEFINES", [])) +if not board.get("build.ldscript", ""): + env.Replace(LDSCRIPT_PATH=get_linker_script(board.get("build.mcu", ""))) -if "F103xC" in cpp_flags: - env.Append(CPPDEFINES=["STM32F103xE"]) -elif "F103x8" in cpp_flags: - env.Append(CPPDEFINES=["STM32F103xB"]) +# +# Process BSP components +# +bsp_dir = os.path.join(FRAMEWORK_DIR, "Drivers", "BSP") +components_dir = os.path.join(bsp_dir, "Components") +for component in os.listdir(components_dir): + build_custom_lib(os.path.join(components_dir, component)) -env.Append( - CPPPATH=[ - join(FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", "CMSIS", "Include"), - join(FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", "CMSIS", "Device", - "ST", MCU_FAMILY.upper() + "xx", "Include"), - - join(FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", - MCU_FAMILY.upper() + "xx_HAL_Driver", "Inc"), - join(FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", - "BSP", "Components", "Common") - ], - - LIBPATH=[ - join(FRAMEWORK_DIR, FRAMEWORK_CORE, - "Drivers", "CMSIS", "Lib", "GCC"), - join(FRAMEWORK_DIR, "platformio", "ldscripts") - ] -) +if os.path.isdir(os.path.join(bsp_dir, "Adafruit_Shield")): + build_custom_lib(os.path.join(bsp_dir, "Adafruit_Shield")) -if not board.get("build.ldscript", ""): - env.Replace( - LDSCRIPT_PATH=get_linker_script(board.get("build.mcu"))) +# +# Process Utilities +# -variants_remap = fs.load_json( - join(FRAMEWORK_DIR, "platformio", "variants_remap.json")) -board_type = env.subst("$BOARD") -variant = variants_remap[ - board_type] if board_type in variants_remap else board_type.upper() +utils_dir = os.path.join(FRAMEWORK_DIR, "Utilities") +for util in os.listdir(utils_dir): + util_dir = os.path.join(utils_dir, util) + # Some of utilities is not meant to be built + if not any(f.endswith((".c", ".h")) for f in os.listdir(util_dir)): + continue + build_custom_lib( + os.path.join(utils_dir, util), + { + "name": "Util-%s" % util, + "dependencies": [{"name": "FrameworkVariantBSP"}], + "build": {"flags": ["-I $PROJECT_SRC_DIR", "-I $PROJECT_INCLUDE_DIR"], "libLDFMode": "deep"}, + }, + ) # -# Generate framework specific files +# USB libraries from ST # -generate_hal_config_file(board.get("build.mcu")) +middleware_dir = os.path.join(FRAMEWORK_DIR, "Middlewares", "ST") +for usb_lib in ("STM32_USB_Device_Library", "STM32_USB_Host_Library"): + build_usb_libs(os.path.join(middleware_dir, usb_lib)) # -# Process BSP components +# Target: Build HAL Library # -components_dir = join( - FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", "BSP", "Components") -for component in listdir(components_dir): - env.Append(EXTRA_LIB_BUILDERS=[ - CustomLibBuilder( - env, join(components_dir, component), - {"name": "BSP-%s" % component} - ) - ]) +libs = [] +# +# BSP libraries +# + +if "build.stm32cube.variant" in board: + bsp_variant_dir = os.path.join( + FRAMEWORK_DIR, "Drivers", "BSP", board.get("build.stm32cube.variant") + ) + if os.path.isdir(bsp_variant_dir): + build_custom_lib(os.path.join(bsp_variant_dir), {"name": "FrameworkVariantBSP"}) # -# Target: Build HAL Library +# HAL libraries # -libs = [] +# Generate a default stm32xxx_hal_conf.h +if board.get("build.stm32cube.custom_config_header", "no") == "no": + generate_hal_config_file() + +libs.append( + env.BuildLibrary( + os.path.join("$BUILD_DIR", "FrameworkHALDriver"), + os.path.join( + FRAMEWORK_DIR, + "Drivers", + MCU_FAMILY.upper() + "xx_HAL_Driver", + ), + src_filter="+<*> - -", + ) +) -bsp_dir = join(FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", "BSP", variant) -if isdir(bsp_dir): - libs.append(env.BuildLibrary(join("$BUILD_DIR", "FrameworkBSP"), bsp_dir)) - env.Append(CPPPATH=[bsp_dir]) - -libs.append(env.BuildLibrary( - join("$BUILD_DIR", "FrameworkHALDriver"), - join(FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", - MCU_FAMILY.upper() + "xx_HAL_Driver"), - src_filter="+<*> - -" -)) - -libs.append(env.BuildLibrary( - join("$BUILD_DIR", "FrameworkCMSISDevice"), - join(FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", "CMSIS", "Device", "ST", - MCU_FAMILY.upper() + "xx", "Source", "Templates"), - src_filter="-<*> +<*.c> +" % get_startup_file( - board.get("build.mcu")) -)) +# +# CMSIS library +# +if board.get("build.stm32cube.custom_system_setup", "no") == "no": + sources_path = os.path.join( + FRAMEWORK_DIR, + "Drivers", + "CMSIS", + "Device", + "ST", + MCU_FAMILY.upper() + "xx", + "Source", + "Templates", + ) + + prepare_startup_file(sources_path) + libs.append( + env.BuildLibrary( + os.path.join("$BUILD_DIR", "FrameworkCMSISDevice"), + sources_path, + src_filter=[ + "-<*>", + "+<%s>" + % board.get( + "build.stm32cube.system_file", "system_%sxx.c" % MCU_FAMILY + ), + "+" + % board.get( + "build.stm32cube.startup_file", + "startup_%s.S" % PRODUCT_LINE.lower(), + ), + ], + ) + ) env.Append(LIBS=libs) diff --git a/examples/stm32cube-hal-blink-clangd/.clangd b/examples/stm32cube-hal-blink-clangd/.clangd new file mode 100644 index 00000000..75aa76d0 --- /dev/null +++ b/examples/stm32cube-hal-blink-clangd/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + Add: [-D DEFINE_FROM_CLANGD_FILE] \ No newline at end of file diff --git a/examples/stm32cube-hal-blink-clangd/.gitignore b/examples/stm32cube-hal-blink-clangd/.gitignore new file mode 100644 index 00000000..03f4a3c1 --- /dev/null +++ b/examples/stm32cube-hal-blink-clangd/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/examples/stm32cube-hal-blink-clangd/.travis.yml b/examples/stm32cube-hal-blink-clangd/.travis.yml new file mode 100644 index 00000000..7c486f18 --- /dev/null +++ b/examples/stm32cube-hal-blink-clangd/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/stm32cube-hal-blink-clangd/README.rst b/examples/stm32cube-hal-blink-clangd/README.rst new file mode 100644 index 00000000..7c5eaa8c --- /dev/null +++ b/examples/stm32cube-hal-blink-clangd/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/stm32cube-hal-blink + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e nucleo_f401re + + # Upload firmware for the specific environment + > platformio run -e nucleo_f401re --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/stm32cube-hal-blink-clangd/compile_commands.json b/examples/stm32cube-hal-blink-clangd/compile_commands.json new file mode 100644 index 00000000..9f13c6b9 --- /dev/null +++ b/examples/stm32cube-hal-blink-clangd/compile_commands.json @@ -0,0 +1,447 @@ +[ + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkBSP/stm32f4xx_nucleo.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_adc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_adc_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_can.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_cec.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cec.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cec.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_cortex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_crc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_crc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_crc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_cryp.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cryp.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cryp.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_cryp_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cryp_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cryp_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_dac.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dac.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dac.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_dac_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dac_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dac_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_dcmi.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dcmi.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dcmi.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_dcmi_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dcmi_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dcmi_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_dfsdm.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dfsdm.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dfsdm.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_dma.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_dma2d.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_dma_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_dsi.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dsi.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dsi.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_eth.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_eth.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_eth.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_flash.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_flash_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_flash_ramfunc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_fmpi2c.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_fmpi2c.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_fmpi2c.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_fmpi2c_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_fmpi2c_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_fmpi2c_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_gpio.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_hash.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hash.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hash.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_hash_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hash_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hash_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_hcd.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hcd.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hcd.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_i2c.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_i2c_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_i2s.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_i2s_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_irda.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_irda.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_irda.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_iwdg.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_iwdg.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_iwdg.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_lptim.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_lptim.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_lptim.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_ltdc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_ltdc_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_mmc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_mmc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_mmc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_nand.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_nand.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_nand.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_nor.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_nor.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_nor.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_pccard.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pccard.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pccard.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_pcd.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_pcd_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_pwr.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_pwr_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_qspi.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_qspi.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_qspi.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_rcc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_rcc_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_rng.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rng.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rng.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_rtc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_rtc_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_sai.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sai.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sai.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_sai_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sai_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sai_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_sd.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_sdram.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sdram.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sdram.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_smartcard.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_smartcard.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_smartcard.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_spdifrx.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spdifrx.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spdifrx.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_spi.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_sram.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_tim.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_tim_ex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_uart.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_usart.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_usart.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_usart.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_hal_wwdg.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_wwdg.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_wwdg.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_adc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_crc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_crc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_crc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_dac.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dac.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dac.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_dma.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_dma2d.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma2d.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma2d.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_exti.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_exti.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_exti.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_fmc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_fsmc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fsmc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fsmc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_gpio.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_i2c.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_i2c.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_i2c.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_lptim.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_lptim.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_lptim.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_pwr.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_pwr.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_pwr.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_rcc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rcc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rcc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_rng.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rng.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rng.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_rtc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rtc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rtc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_sdmmc.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_spi.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_spi.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_spi.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_tim.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_tim.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_tim.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_usart.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usart.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usart.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_usb.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkHALDriver/Src/stm32f4xx_ll_utils.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_utils.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_utils.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -x assembler-with-cpp -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo -c -o .pio/build/nucleo_f401re/FrameworkCMSISDevice/gcc/startup_stm32f401xe.o C:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f401xe.s", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f401xe.s" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/FrameworkCMSISDevice/system_stm32f4xx.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo C:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "C:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c" + }, + { + "command": "C:/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe -o .pio/build/nucleo_f401re/src/main.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -DDEFINES_FROM_COMPILE_COMMANDS -DPLATFORMIO=50004 -DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx -DF4 -DUSE_HAL_DRIVER -DF_CPU=84000000L -Iinclude -Isrc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/STM32F4xx_HAL_Driver/Inc -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/Components/Common -IC:/.platformio/packages/framework-stm32cube/f4/Drivers/BSP/STM32F4xx-Nucleo src/main.c", + "directory": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd", + "file": "E:/Projects/pio-platforms/platform-ststm32/examples/stm32cube-hal-blink-clangd/src/main.c" + } +] \ No newline at end of file diff --git a/examples/stm32cube-hal-blink-clangd/include/README b/examples/stm32cube-hal-blink-clangd/include/README new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/examples/stm32cube-hal-blink-clangd/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/stm32cube-hal-blink-clangd/lib/README b/examples/stm32cube-hal-blink-clangd/lib/README new file mode 100644 index 00000000..6debab1e --- /dev/null +++ b/examples/stm32cube-hal-blink-clangd/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/stm32cube-hal-blink-clangd/platformio.ini b/examples/stm32cube-hal-blink-clangd/platformio.ini new file mode 100644 index 00000000..91976b73 --- /dev/null +++ b/examples/stm32cube-hal-blink-clangd/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:nucleo_f401re] +platform = ststm32 +framework = stm32cube +board = nucleo_f401re +build_flags = -DF4 diff --git a/examples/stm32cube-hal-blink-clangd/src/main.c b/examples/stm32cube-hal-blink-clangd/src/main.c new file mode 100644 index 00000000..20027fdc --- /dev/null +++ b/examples/stm32cube-hal-blink-clangd/src/main.c @@ -0,0 +1,90 @@ +#if F0 +#include "stm32f0xx_hal.h" +#elif F1 +#include "stm32f1xx_hal.h" +#elif F2 +#include "stm32f2xx_hal.h" +#elif F3 +#include "stm32f3xx_hal.h" +#elif F4 +#include "stm32f4xx_hal.h" +#elif F7 +#include "stm32f7xx_hal.h" +#elif L0 +#include "stm32l0xx_hal.h" +#elif L1 +#include "stm32l1xx_hal.h" +#elif L4 +#include "stm32l4xx_hal.h" +#else +#error "Unsupported STM32 Family" +#endif + +#define LED_PIN GPIO_PIN_5 +#define LED_GPIO_PORT GPIOA +#define LED_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() + +int main(void) +{ + HAL_Init(); + LED_GPIO_CLK_ENABLE(); + + + GPIO_InitTypeDef GPIO_InitStruct; + + GPIO_InitStruct.Pin = LED_PIN; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + HAL_GPIO_Init(LED_GPIO_PORT, &GPIO_InitStruct); + + while (1) + { + HAL_GPIO_TogglePin(LED_GPIO_PORT, LED_PIN); + + HAL_Delay(1000); + } +} + +void SysTick_Handler(void) +{ + HAL_IncTick(); +} + +void NMI_Handler(void) +{ +} + +void HardFault_Handler(void) +{ + while (1) {} +} + + +void MemManage_Handler(void) +{ + while (1) {} +} + +void BusFault_Handler(void) +{ + while (1) {} +} + +void UsageFault_Handler(void) +{ + while (1) {} +} + +void SVC_Handler(void) +{ +} + + +void DebugMon_Handler(void) +{ +} + +void PendSV_Handler(void) +{ +} diff --git a/examples/stm32cube-hal-blink-clangd/test/README b/examples/stm32cube-hal-blink-clangd/test/README new file mode 100644 index 00000000..df5066e6 --- /dev/null +++ b/examples/stm32cube-hal-blink-clangd/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/stm32cube-hal-eeprom-emulation/.gitignore b/examples/stm32cube-hal-eeprom-emulation/.gitignore new file mode 100644 index 00000000..03f4a3c1 --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/examples/stm32cube-hal-eeprom-emulation/.travis.yml b/examples/stm32cube-hal-eeprom-emulation/.travis.yml new file mode 100644 index 00000000..7c486f18 --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/stm32cube-hal-eeprom-emulation/README.rst b/examples/stm32cube-hal-eeprom-emulation/README.rst new file mode 100644 index 00000000..59eedb45 --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/README.rst @@ -0,0 +1,32 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/stm32cube-hal-eeprom-emulation + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/stm32cube-hal-eeprom-emulation/include/README b/examples/stm32cube-hal-eeprom-emulation/include/README new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/stm32cube-hal-eeprom-emulation/lib/README b/examples/stm32cube-hal-eeprom-emulation/lib/README new file mode 100644 index 00000000..6debab1e --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/stm32cube-hal-eeprom-emulation/platformio.ini b/examples/stm32cube-hal-eeprom-emulation/platformio.ini new file mode 100644 index 00000000..1da62775 --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/platformio.ini @@ -0,0 +1,16 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:nucleo_f103rb] +platform = ststm32 +framework = stm32cube +board = nucleo_f103rb +build_flags = -Wl,-Map=system_stm32f1xx.txt +board_build.stm32cube.custom_system_setup = yes +; board_build.stm32cube.custom_config_header = yes \ No newline at end of file diff --git a/examples/stm32cube-hal-eeprom-emulation/src/eeprom.c b/examples/stm32cube-hal-eeprom-emulation/src/eeprom.c new file mode 100644 index 00000000..ac142d03 --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/src/eeprom.c @@ -0,0 +1,712 @@ +/** + ****************************************************************************** + * @file EEPROM_Emulation/src/eeprom.c + * @author MCD Application Team + * @brief This file provides all the EEPROM emulation firmware functions. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup EEPROM_Emulation + * @{ + */ + +/* Includes ------------------------------------------------------------------*/ +#include "eeprom.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ + +/* Global variable used to store variable value in read sequence */ +uint16_t DataVar = 0; + +/* Virtual address defined by the user: 0xFFFF value is prohibited */ +extern uint16_t VirtAddVarTab[NB_OF_VAR]; + +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ +static HAL_StatusTypeDef EE_Format(void); +static uint16_t EE_FindValidPage(uint8_t Operation); +static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data); +static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data); +static uint16_t EE_VerifyPageFullyErased(uint32_t Address); + +/** + * @brief Restore the pages to a known good state in case of page's status + * corruption after a power loss. + * @param None. + * @retval - Flash error code: on write Flash error + * - FLASH_COMPLETE: on success + */ +uint16_t EE_Init(void) +{ + uint16_t pagestatus0 = 6, pagestatus1 = 6; + uint16_t varidx = 0; + uint16_t eepromstatus = 0, readstatus = 0; + int16_t x = -1; + HAL_StatusTypeDef flashstatus; + uint32_t page_error = 0; + FLASH_EraseInitTypeDef s_eraseinit; + + + /* Get Page0 status */ + pagestatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS); + /* Get Page1 status */ + pagestatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS); + + /* Fill EraseInit structure*/ + s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; + s_eraseinit.PageAddress = PAGE0_ID; + s_eraseinit.NbPages = 1; + + /* Check for invalid header states and repair if necessary */ + switch (pagestatus0) + { + case ERASED: + if (pagestatus1 == VALID_PAGE) /* Page0 erased, Page1 valid */ + { + /* Erase Page0 */ + if(!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) + { + flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error); + /* If erase operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + } + else if (pagestatus1 == RECEIVE_DATA) /* Page0 erased, Page1 receive */ + { + /* Erase Page0 */ + if(!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) + { + flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error); + /* If erase operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + /* Mark Page1 as valid */ + flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE1_BASE_ADDRESS, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + else /* First EEPROM access (Page0&1 are erased) or invalid state -> format EEPROM */ + { + /* Erase both Page0 and Page1 and set Page0 as valid page */ + flashstatus = EE_Format(); + /* If erase/program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + break; + + case RECEIVE_DATA: + if (pagestatus1 == VALID_PAGE) /* Page0 receive, Page1 valid */ + { + /* Transfer data from Page1 to Page0 */ + for (varidx = 0; varidx < NB_OF_VAR; varidx++) + { + if (( *(__IO uint16_t*)(PAGE0_BASE_ADDRESS + 6)) == VirtAddVarTab[varidx]) + { + x = varidx; + } + if (varidx != x) + { + /* Read the last variables' updates */ + readstatus = EE_ReadVariable(VirtAddVarTab[varidx], &DataVar); + /* In case variable corresponding to the virtual address was found */ + if (readstatus != 0x1) + { + /* Transfer the variable to the Page0 */ + eepromstatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[varidx], DataVar); + /* If program operation was failed, a Flash error code is returned */ + if (eepromstatus != HAL_OK) + { + return eepromstatus; + } + } + } + } + /* Mark Page0 as valid */ + flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; + s_eraseinit.PageAddress = PAGE1_ID; + s_eraseinit.NbPages = 1; + /* Erase Page1 */ + if(!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) + { + flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error); + /* If erase operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + } + else if (pagestatus1 == ERASED) /* Page0 receive, Page1 erased */ + { + s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; + s_eraseinit.PageAddress = PAGE1_ID; + s_eraseinit.NbPages = 1; + /* Erase Page1 */ + if(!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) + { + flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error); + /* If erase operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + /* Mark Page0 as valid */ + flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + else /* Invalid state -> format eeprom */ + { + /* Erase both Page0 and Page1 and set Page0 as valid page */ + flashstatus = EE_Format(); + /* If erase/program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + break; + + case VALID_PAGE: + if (pagestatus1 == VALID_PAGE) /* Invalid state -> format eeprom */ + { + /* Erase both Page0 and Page1 and set Page0 as valid page */ + flashstatus = EE_Format(); + /* If erase/program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + else if (pagestatus1 == ERASED) /* Page0 valid, Page1 erased */ + { + s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; + s_eraseinit.PageAddress = PAGE1_ID; + s_eraseinit.NbPages = 1; + /* Erase Page1 */ + if(!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) + { + flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error); + /* If erase operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + } + else /* Page0 valid, Page1 receive */ + { + /* Transfer data from Page0 to Page1 */ + for (varidx = 0; varidx < NB_OF_VAR; varidx++) + { + if ((*(__IO uint16_t*)(PAGE1_BASE_ADDRESS + 6)) == VirtAddVarTab[varidx]) + { + x = varidx; + } + if (varidx != x) + { + /* Read the last variables' updates */ + readstatus = EE_ReadVariable(VirtAddVarTab[varidx], &DataVar); + /* In case variable corresponding to the virtual address was found */ + if (readstatus != 0x1) + { + /* Transfer the variable to the Page1 */ + eepromstatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[varidx], DataVar); + /* If program operation was failed, a Flash error code is returned */ + if (eepromstatus != HAL_OK) + { + return eepromstatus; + } + } + } + } + /* Mark Page1 as valid */ + flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE1_BASE_ADDRESS, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; + s_eraseinit.PageAddress = PAGE0_ID; + s_eraseinit.NbPages = 1; + /* Erase Page0 */ + if(!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) + { + flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error); + /* If erase operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + } + break; + + default: /* Any other state -> format eeprom */ + /* Erase both Page0 and Page1 and set Page0 as valid page */ + flashstatus = EE_Format(); + /* If erase/program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + break; + } + + return HAL_OK; +} + +/** + * @brief Verify if specified page is fully erased. + * @param Address: page address + * This parameter can be one of the following values: + * @arg PAGE0_BASE_ADDRESS: Page0 base address + * @arg PAGE1_BASE_ADDRESS: Page1 base address + * @retval page fully erased status: + * - 0: if Page not erased + * - 1: if Page erased + */ +uint16_t EE_VerifyPageFullyErased(uint32_t Address) +{ + uint32_t readstatus = 1; + uint16_t addressvalue = 0x5555; + + /* Check each active page address starting from end */ + while (Address <= PAGE0_END_ADDRESS) + { + /* Get the current location content to be compared with virtual address */ + addressvalue = (*(__IO uint16_t*)Address); + + /* Compare the read address with the virtual address */ + if (addressvalue != ERASED) + { + + /* In case variable value is read, reset readstatus flag */ + readstatus = 0; + + break; + } + /* Next address location */ + Address = Address + 4; + } + + /* Return readstatus value: (0: Page not erased, 1: Page erased) */ + return readstatus; +} + +/** + * @brief Returns the last stored variable data, if found, which correspond to + * the passed virtual address + * @param VirtAddress: Variable virtual address + * @param Data: Global variable contains the read variable value + * @retval Success or error status: + * - 0: if variable was found + * - 1: if the variable was not found + * - NO_VALID_PAGE: if no valid page was found. + */ +uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data) +{ + uint16_t validpage = PAGE0; + uint16_t addressvalue = 0x5555, readstatus = 1; + uint32_t address = EEPROM_START_ADDRESS, PageStartAddress = EEPROM_START_ADDRESS; + + /* Get active Page for read operation */ + validpage = EE_FindValidPage(READ_FROM_VALID_PAGE); + + /* Check if there is no valid page */ + if (validpage == NO_VALID_PAGE) + { + return NO_VALID_PAGE; + } + + /* Get the valid Page start Address */ + PageStartAddress = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(validpage * PAGE_SIZE)); + + /* Get the valid Page end Address */ + address = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + validpage) * PAGE_SIZE)); + + /* Check each active page address starting from end */ + while (address > (PageStartAddress + 2)) + { + /* Get the current location content to be compared with virtual address */ + addressvalue = (*(__IO uint16_t*)address); + + /* Compare the read address with the virtual address */ + if (addressvalue == VirtAddress) + { + /* Get content of Address-2 which is variable value */ + *Data = (*(__IO uint16_t*)(address - 2)); + + /* In case variable value is read, reset readstatus flag */ + readstatus = 0; + + break; + } + else + { + /* Next address location */ + address = address - 4; + } + } + + /* Return readstatus value: (0: variable exist, 1: variable doesn't exist) */ + return readstatus; +} + +/** + * @brief Writes/upadtes variable data in EEPROM. + * @param VirtAddress: Variable virtual address + * @param Data: 16 bit data to be written + * @retval Success or error status: + * - FLASH_COMPLETE: on success + * - PAGE_FULL: if valid page is full + * - NO_VALID_PAGE: if no valid page was found + * - Flash error code: on write Flash error + */ +uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data) +{ + uint16_t Status = 0; + + /* Write the variable virtual address and value in the EEPROM */ + Status = EE_VerifyPageFullWriteVariable(VirtAddress, Data); + + /* In case the EEPROM active page is full */ + if (Status == PAGE_FULL) + { + /* Perform Page transfer */ + Status = EE_PageTransfer(VirtAddress, Data); + } + + /* Return last operation status */ + return Status; +} + +/** + * @brief Erases PAGE and PAGE1 and writes VALID_PAGE header to PAGE + * @param None + * @retval Status of the last operation (Flash write or erase) done during + * EEPROM formating + */ +static HAL_StatusTypeDef EE_Format(void) +{ + HAL_StatusTypeDef flashstatus = HAL_OK; + uint32_t page_error = 0; + FLASH_EraseInitTypeDef s_eraseinit; + + s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; + s_eraseinit.PageAddress = PAGE0_ID; + s_eraseinit.NbPages = 1; + /* Erase Page0 */ + if(!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) + { + flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error); + /* If erase operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + /* Set Page0 as valid page: Write VALID_PAGE at Page0 base address */ + flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + + s_eraseinit.PageAddress = PAGE1_ID; + /* Erase Page1 */ + if(!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) + { + flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error); + /* If erase operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + } + + return HAL_OK; +} + +/** + * @brief Find valid Page for write or read operation + * @param Operation: operation to achieve on the valid page. + * This parameter can be one of the following values: + * @arg READ_FROM_VALID_PAGE: read operation from valid page + * @arg WRITE_IN_VALID_PAGE: write operation from valid page + * @retval Valid page number (PAGE or PAGE1) or NO_VALID_PAGE in case + * of no valid page was found + */ +static uint16_t EE_FindValidPage(uint8_t Operation) +{ + uint16_t pagestatus0 = 6, pagestatus1 = 6; + + /* Get Page0 actual status */ + pagestatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS); + + /* Get Page1 actual status */ + pagestatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS); + + /* Write or read operation */ + switch (Operation) + { + case WRITE_IN_VALID_PAGE: /* ---- Write operation ---- */ + if (pagestatus1 == VALID_PAGE) + { + /* Page0 receiving data */ + if (pagestatus0 == RECEIVE_DATA) + { + return PAGE0; /* Page0 valid */ + } + else + { + return PAGE1; /* Page1 valid */ + } + } + else if (pagestatus0 == VALID_PAGE) + { + /* Page1 receiving data */ + if (pagestatus1 == RECEIVE_DATA) + { + return PAGE1; /* Page1 valid */ + } + else + { + return PAGE0; /* Page0 valid */ + } + } + else + { + return NO_VALID_PAGE; /* No valid Page */ + } + + case READ_FROM_VALID_PAGE: /* ---- Read operation ---- */ + if (pagestatus0 == VALID_PAGE) + { + return PAGE0; /* Page0 valid */ + } + else if (pagestatus1 == VALID_PAGE) + { + return PAGE1; /* Page1 valid */ + } + else + { + return NO_VALID_PAGE ; /* No valid Page */ + } + + default: + return PAGE0; /* Page0 valid */ + } +} + +/** + * @brief Verify if active page is full and Writes variable in EEPROM. + * @param VirtAddress: 16 bit virtual address of the variable + * @param Data: 16 bit data to be written as variable value + * @retval Success or error status: + * - FLASH_COMPLETE: on success + * - PAGE_FULL: if valid page is full + * - NO_VALID_PAGE: if no valid page was found + * - Flash error code: on write Flash error + */ +static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data) +{ + HAL_StatusTypeDef flashstatus = HAL_OK; + uint16_t validpage = PAGE0; + uint32_t address = EEPROM_START_ADDRESS, pageendaddress = EEPROM_START_ADDRESS+PAGE_SIZE; + + /* Get valid Page for write operation */ + validpage = EE_FindValidPage(WRITE_IN_VALID_PAGE); + + /* Check if there is no valid page */ + if (validpage == NO_VALID_PAGE) + { + return NO_VALID_PAGE; + } + + /* Get the valid Page start address */ + address = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(validpage * PAGE_SIZE)); + + /* Get the valid Page end address */ + pageendaddress = (uint32_t)((EEPROM_START_ADDRESS - 1) + (uint32_t)((validpage + 1) * PAGE_SIZE)); + + /* Check each active page address starting from begining */ + while (address < pageendaddress) + { + /* Verify if address and address+2 contents are 0xFFFFFFFF */ + if ((*(__IO uint32_t*)address) == 0xFFFFFFFF) + { + /* Set variable data */ + flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, address, Data); + /* If program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + /* Set variable virtual address */ + flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, address + 2, VirtAddress); + /* Return program operation status */ + return flashstatus; + } + else + { + /* Next address location */ + address = address + 4; + } + } + + /* Return PAGE_FULL in case the valid page is full */ + return PAGE_FULL; +} + +/** + * @brief Transfers last updated variables data from the full Page to + * an empty one. + * @param VirtAddress: 16 bit virtual address of the variable + * @param Data: 16 bit data to be written as variable value + * @retval Success or error status: + * - FLASH_COMPLETE: on success + * - PAGE_FULL: if valid page is full + * - NO_VALID_PAGE: if no valid page was found + * - Flash error code: on write Flash error + */ +static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data) +{ + HAL_StatusTypeDef flashstatus = HAL_OK; + uint32_t newpageaddress = EEPROM_START_ADDRESS; + uint32_t oldpageid = 0; + uint16_t validpage = PAGE0, varidx = 0; + uint16_t eepromstatus = 0, readstatus = 0; + uint32_t page_error = 0; + FLASH_EraseInitTypeDef s_eraseinit; + + /* Get active Page for read operation */ + validpage = EE_FindValidPage(READ_FROM_VALID_PAGE); + + if (validpage == PAGE1) /* Page1 valid */ + { + /* New page address where variable will be moved to */ + newpageaddress = PAGE0_BASE_ADDRESS; + + /* Old page ID where variable will be taken from */ + oldpageid = PAGE1_ID; + } + else if (validpage == PAGE0) /* Page0 valid */ + { + /* New page address where variable will be moved to */ + newpageaddress = PAGE1_BASE_ADDRESS; + + /* Old page ID where variable will be taken from */ + oldpageid = PAGE0_ID; + } + else + { + return NO_VALID_PAGE; /* No valid Page */ + } + + /* Set the new Page status to RECEIVE_DATA status */ + flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, newpageaddress, RECEIVE_DATA); + /* If program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + + /* Write the variable passed as parameter in the new active page */ + eepromstatus = EE_VerifyPageFullWriteVariable(VirtAddress, Data); + /* If program operation was failed, a Flash error code is returned */ + if (eepromstatus != HAL_OK) + { + return eepromstatus; + } + + /* Transfer process: transfer variables from old to the new active page */ + for (varidx = 0; varidx < NB_OF_VAR; varidx++) + { + if (VirtAddVarTab[varidx] != VirtAddress) /* Check each variable except the one passed as parameter */ + { + /* Read the other last variable updates */ + readstatus = EE_ReadVariable(VirtAddVarTab[varidx], &DataVar); + /* In case variable corresponding to the virtual address was found */ + if (readstatus != 0x1) + { + /* Transfer the variable to the new active page */ + eepromstatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[varidx], DataVar); + /* If program operation was failed, a Flash error code is returned */ + if (eepromstatus != HAL_OK) + { + return eepromstatus; + } + } + } + } + + s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES; + s_eraseinit.PageAddress = oldpageid; + s_eraseinit.NbPages = 1; + + /* Erase the old Page: Set old Page status to ERASED status */ + flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error); + /* If erase operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + + /* Set new Page status to VALID_PAGE status */ + flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, newpageaddress, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (flashstatus != HAL_OK) + { + return flashstatus; + } + + + + /* Return last operation flash status */ + return flashstatus; +} + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-eeprom-emulation/src/eeprom.h b/examples/stm32cube-hal-eeprom-emulation/src/eeprom.h new file mode 100644 index 00000000..875813ab --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/src/eeprom.h @@ -0,0 +1,205 @@ +/** + ****************************************************************************** + * @file EEPROM_Emulation/inc/eeprom.h + * @author MCD Application Team + * @brief This file contains all the functions prototypes for the EEPROM + * emulation firmware library. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __EEPROM_H +#define __EEPROM_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f1xx_hal.h" + +/* Exported constants --------------------------------------------------------*/ +/* Base address of the Flash sectors */ +#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 1 Kbytes */ +#define ADDR_FLASH_PAGE_1 ((uint32_t)0x08000400) /* Base @ of Page 1, 1 Kbytes */ +#define ADDR_FLASH_PAGE_2 ((uint32_t)0x08000800) /* Base @ of Page 2, 1 Kbytes */ +#define ADDR_FLASH_PAGE_3 ((uint32_t)0x08000C00) /* Base @ of Page 3, 1 Kbytes */ +#define ADDR_FLASH_PAGE_4 ((uint32_t)0x08001000) /* Base @ of Page 4, 1 Kbytes */ +#define ADDR_FLASH_PAGE_5 ((uint32_t)0x08001400) /* Base @ of Page 5, 1 Kbytes */ +#define ADDR_FLASH_PAGE_6 ((uint32_t)0x08001800) /* Base @ of Page 6, 1 Kbytes */ +#define ADDR_FLASH_PAGE_7 ((uint32_t)0x08001C00) /* Base @ of Page 7, 1 Kbytes */ +#define ADDR_FLASH_PAGE_8 ((uint32_t)0x08002000) /* Base @ of Page 8, 1 Kbytes */ +#define ADDR_FLASH_PAGE_9 ((uint32_t)0x08002400) /* Base @ of Page 9, 1 Kbytes */ +#define ADDR_FLASH_PAGE_10 ((uint32_t)0x08002800) /* Base @ of Page 10, 1 Kbytes */ +#define ADDR_FLASH_PAGE_11 ((uint32_t)0x08002C00) /* Base @ of Page 11, 1 Kbytes */ +#define ADDR_FLASH_PAGE_12 ((uint32_t)0x08003000) /* Base @ of Page 12, 1 Kbytes */ +#define ADDR_FLASH_PAGE_13 ((uint32_t)0x08003400) /* Base @ of Page 13, 1 Kbytes */ +#define ADDR_FLASH_PAGE_14 ((uint32_t)0x08003800) /* Base @ of Page 14, 1 Kbytes */ +#define ADDR_FLASH_PAGE_15 ((uint32_t)0x08003C00) /* Base @ of Page 15, 1 Kbytes */ +#define ADDR_FLASH_PAGE_16 ((uint32_t)0x08004000) /* Base @ of Page 16, 1 Kbytes */ +#define ADDR_FLASH_PAGE_17 ((uint32_t)0x08004400) /* Base @ of Page 17, 1 Kbytes */ +#define ADDR_FLASH_PAGE_18 ((uint32_t)0x08004800) /* Base @ of Page 18, 1 Kbytes */ +#define ADDR_FLASH_PAGE_19 ((uint32_t)0x08004C00) /* Base @ of Page 19, 1 Kbytes */ +#define ADDR_FLASH_PAGE_20 ((uint32_t)0x08005000) /* Base @ of Page 20, 1 Kbytes */ +#define ADDR_FLASH_PAGE_21 ((uint32_t)0x08005400) /* Base @ of Page 21, 1 Kbytes */ +#define ADDR_FLASH_PAGE_22 ((uint32_t)0x08005800) /* Base @ of Page 22, 1 Kbytes */ +#define ADDR_FLASH_PAGE_23 ((uint32_t)0x08005C00) /* Base @ of Page 23, 1 Kbytes */ +#define ADDR_FLASH_PAGE_24 ((uint32_t)0x08006000) /* Base @ of Page 24, 1 Kbytes */ +#define ADDR_FLASH_PAGE_25 ((uint32_t)0x08006400) /* Base @ of Page 25, 1 Kbytes */ +#define ADDR_FLASH_PAGE_26 ((uint32_t)0x08006800) /* Base @ of Page 26, 1 Kbytes */ +#define ADDR_FLASH_PAGE_27 ((uint32_t)0x08006C00) /* Base @ of Page 27, 1 Kbytes */ +#define ADDR_FLASH_PAGE_28 ((uint32_t)0x08007000) /* Base @ of Page 28, 1 Kbytes */ +#define ADDR_FLASH_PAGE_29 ((uint32_t)0x08007400) /* Base @ of Page 29, 1 Kbytes */ +#define ADDR_FLASH_PAGE_30 ((uint32_t)0x08007800) /* Base @ of Page 30, 1 Kbytes */ +#define ADDR_FLASH_PAGE_31 ((uint32_t)0x08007C00) /* Base @ of Page 31, 1 Kbytes */ +#define ADDR_FLASH_PAGE_32 ((uint32_t)0x08008000) /* Base @ of Page 32, 1 Kbytes */ +#define ADDR_FLASH_PAGE_33 ((uint32_t)0x08008400) /* Base @ of Page 33, 1 Kbytes */ +#define ADDR_FLASH_PAGE_34 ((uint32_t)0x08008800) /* Base @ of Page 34, 1 Kbytes */ +#define ADDR_FLASH_PAGE_35 ((uint32_t)0x08008C00) /* Base @ of Page 35, 1 Kbytes */ +#define ADDR_FLASH_PAGE_36 ((uint32_t)0x08009000) /* Base @ of Page 36, 1 Kbytes */ +#define ADDR_FLASH_PAGE_37 ((uint32_t)0x08009400) /* Base @ of Page 37, 1 Kbytes */ +#define ADDR_FLASH_PAGE_38 ((uint32_t)0x08009800) /* Base @ of Page 38, 1 Kbytes */ +#define ADDR_FLASH_PAGE_39 ((uint32_t)0x08009C00) /* Base @ of Page 39, 1 Kbytes */ +#define ADDR_FLASH_PAGE_40 ((uint32_t)0x0800A000) /* Base @ of Page 40, 1 Kbytes */ +#define ADDR_FLASH_PAGE_41 ((uint32_t)0x0800A400) /* Base @ of Page 41, 1 Kbytes */ +#define ADDR_FLASH_PAGE_42 ((uint32_t)0x0800A800) /* Base @ of Page 42, 1 Kbytes */ +#define ADDR_FLASH_PAGE_43 ((uint32_t)0x0800AC00) /* Base @ of Page 43, 1 Kbytes */ +#define ADDR_FLASH_PAGE_44 ((uint32_t)0x0800B000) /* Base @ of Page 44, 1 Kbytes */ +#define ADDR_FLASH_PAGE_45 ((uint32_t)0x0800B400) /* Base @ of Page 45, 1 Kbytes */ +#define ADDR_FLASH_PAGE_46 ((uint32_t)0x0800B800) /* Base @ of Page 46, 1 Kbytes */ +#define ADDR_FLASH_PAGE_47 ((uint32_t)0x0800BC00) /* Base @ of Page 47, 1 Kbytes */ +#define ADDR_FLASH_PAGE_48 ((uint32_t)0x0800C000) /* Base @ of Page 48, 1 Kbytes */ +#define ADDR_FLASH_PAGE_49 ((uint32_t)0x0800C400) /* Base @ of Page 49, 1 Kbytes */ +#define ADDR_FLASH_PAGE_50 ((uint32_t)0x0800C800) /* Base @ of Page 50, 1 Kbytes */ +#define ADDR_FLASH_PAGE_51 ((uint32_t)0x0800CC00) /* Base @ of Page 51, 1 Kbytes */ +#define ADDR_FLASH_PAGE_52 ((uint32_t)0x0800D000) /* Base @ of Page 52, 1 Kbytes */ +#define ADDR_FLASH_PAGE_53 ((uint32_t)0x0800D400) /* Base @ of Page 53, 1 Kbytes */ +#define ADDR_FLASH_PAGE_54 ((uint32_t)0x0800D800) /* Base @ of Page 54, 1 Kbytes */ +#define ADDR_FLASH_PAGE_55 ((uint32_t)0x0800DC00) /* Base @ of Page 55, 1 Kbytes */ +#define ADDR_FLASH_PAGE_56 ((uint32_t)0x0800E000) /* Base @ of Page 56, 1 Kbytes */ +#define ADDR_FLASH_PAGE_57 ((uint32_t)0x0800E400) /* Base @ of Page 57, 1 Kbytes */ +#define ADDR_FLASH_PAGE_58 ((uint32_t)0x0800E800) /* Base @ of Page 58, 1 Kbytes */ +#define ADDR_FLASH_PAGE_59 ((uint32_t)0x0800EC00) /* Base @ of Page 59, 1 Kbytes */ +#define ADDR_FLASH_PAGE_60 ((uint32_t)0x0800F000) /* Base @ of Page 60, 1 Kbytes */ +#define ADDR_FLASH_PAGE_61 ((uint32_t)0x0800F400) /* Base @ of Page 61, 1 Kbytes */ +#define ADDR_FLASH_PAGE_62 ((uint32_t)0x0800F800) /* Base @ of Page 62, 1 Kbytes */ +#define ADDR_FLASH_PAGE_63 ((uint32_t)0x0800FC00) /* Base @ of Page 63, 1 Kbytes */ +#define ADDR_FLASH_PAGE_64 ((uint32_t)0x08010000) /* Base @ of Page 64, 1 Kbytes */ +#define ADDR_FLASH_PAGE_65 ((uint32_t)0x08010400) /* Base @ of Page 65, 1 Kbytes */ +#define ADDR_FLASH_PAGE_66 ((uint32_t)0x08010800) /* Base @ of Page 66, 1 Kbytes */ +#define ADDR_FLASH_PAGE_67 ((uint32_t)0x08010C00) /* Base @ of Page 67, 1 Kbytes */ +#define ADDR_FLASH_PAGE_68 ((uint32_t)0x08011000) /* Base @ of Page 68, 1 Kbytes */ +#define ADDR_FLASH_PAGE_69 ((uint32_t)0x08011400) /* Base @ of Page 69, 1 Kbytes */ +#define ADDR_FLASH_PAGE_70 ((uint32_t)0x08011800) /* Base @ of Page 70, 1 Kbytes */ +#define ADDR_FLASH_PAGE_71 ((uint32_t)0x08011C00) /* Base @ of Page 71, 1 Kbytes */ +#define ADDR_FLASH_PAGE_72 ((uint32_t)0x08012000) /* Base @ of Page 72, 1 Kbytes */ +#define ADDR_FLASH_PAGE_73 ((uint32_t)0x08012400) /* Base @ of Page 73, 1 Kbytes */ +#define ADDR_FLASH_PAGE_74 ((uint32_t)0x08012800) /* Base @ of Page 74, 1 Kbytes */ +#define ADDR_FLASH_PAGE_75 ((uint32_t)0x08012C00) /* Base @ of Page 75, 1 Kbytes */ +#define ADDR_FLASH_PAGE_76 ((uint32_t)0x08013000) /* Base @ of Page 76, 1 Kbytes */ +#define ADDR_FLASH_PAGE_77 ((uint32_t)0x08013400) /* Base @ of Page 77, 1 Kbytes */ +#define ADDR_FLASH_PAGE_78 ((uint32_t)0x08013800) /* Base @ of Page 78, 1 Kbytes */ +#define ADDR_FLASH_PAGE_79 ((uint32_t)0x08013C00) /* Base @ of Page 79, 1 Kbytes */ +#define ADDR_FLASH_PAGE_80 ((uint32_t)0x08014000) /* Base @ of Page 80, 1 Kbytes */ +#define ADDR_FLASH_PAGE_81 ((uint32_t)0x08014400) /* Base @ of Page 81, 1 Kbytes */ +#define ADDR_FLASH_PAGE_82 ((uint32_t)0x08014800) /* Base @ of Page 82, 1 Kbytes */ +#define ADDR_FLASH_PAGE_83 ((uint32_t)0x08014C00) /* Base @ of Page 83, 1 Kbytes */ +#define ADDR_FLASH_PAGE_84 ((uint32_t)0x08015000) /* Base @ of Page 84, 1 Kbytes */ +#define ADDR_FLASH_PAGE_85 ((uint32_t)0x08015400) /* Base @ of Page 85, 1 Kbytes */ +#define ADDR_FLASH_PAGE_86 ((uint32_t)0x08015800) /* Base @ of Page 86, 1 Kbytes */ +#define ADDR_FLASH_PAGE_87 ((uint32_t)0x08015C00) /* Base @ of Page 87, 1 Kbytes */ +#define ADDR_FLASH_PAGE_88 ((uint32_t)0x08016000) /* Base @ of Page 88, 1 Kbytes */ +#define ADDR_FLASH_PAGE_89 ((uint32_t)0x08016400) /* Base @ of Page 89, 1 Kbytes */ +#define ADDR_FLASH_PAGE_90 ((uint32_t)0x08016800) /* Base @ of Page 90, 1 Kbytes */ +#define ADDR_FLASH_PAGE_91 ((uint32_t)0x08016C00) /* Base @ of Page 91, 1 Kbytes */ +#define ADDR_FLASH_PAGE_92 ((uint32_t)0x08017000) /* Base @ of Page 92, 1 Kbytes */ +#define ADDR_FLASH_PAGE_93 ((uint32_t)0x08017400) /* Base @ of Page 93, 1 Kbytes */ +#define ADDR_FLASH_PAGE_94 ((uint32_t)0x08017800) /* Base @ of Page 94, 1 Kbytes */ +#define ADDR_FLASH_PAGE_95 ((uint32_t)0x08017C00) /* Base @ of Page 95, 1 Kbytes */ +#define ADDR_FLASH_PAGE_96 ((uint32_t)0x08018000) /* Base @ of Page 96, 1 Kbytes */ +#define ADDR_FLASH_PAGE_97 ((uint32_t)0x08018400) /* Base @ of Page 97, 1 Kbytes */ +#define ADDR_FLASH_PAGE_98 ((uint32_t)0x08018800) /* Base @ of Page 98, 1 Kbytes */ +#define ADDR_FLASH_PAGE_99 ((uint32_t)0x08018C00) /* Base @ of Page 99, 1 Kbytes */ +#define ADDR_FLASH_PAGE_100 ((uint32_t)0x08019000) /* Base @ of Page 100, 1 Kbytes */ +#define ADDR_FLASH_PAGE_101 ((uint32_t)0x08019400) /* Base @ of Page 101, 1 Kbytes */ +#define ADDR_FLASH_PAGE_102 ((uint32_t)0x08019800) /* Base @ of Page 102, 1 Kbytes */ +#define ADDR_FLASH_PAGE_103 ((uint32_t)0x08019C00) /* Base @ of Page 103, 1 Kbytes */ +#define ADDR_FLASH_PAGE_104 ((uint32_t)0x0801A000) /* Base @ of Page 104, 1 Kbytes */ +#define ADDR_FLASH_PAGE_105 ((uint32_t)0x0801A400) /* Base @ of Page 105, 1 Kbytes */ +#define ADDR_FLASH_PAGE_106 ((uint32_t)0x0801A800) /* Base @ of Page 106, 1 Kbytes */ +#define ADDR_FLASH_PAGE_107 ((uint32_t)0x0801AC00) /* Base @ of Page 107, 1 Kbytes */ +#define ADDR_FLASH_PAGE_108 ((uint32_t)0x0801B000) /* Base @ of Page 108, 1 Kbytes */ +#define ADDR_FLASH_PAGE_109 ((uint32_t)0x0801B400) /* Base @ of Page 109, 1 Kbytes */ +#define ADDR_FLASH_PAGE_110 ((uint32_t)0x0801B800) /* Base @ of Page 110, 1 Kbytes */ +#define ADDR_FLASH_PAGE_111 ((uint32_t)0x0801BC00) /* Base @ of Page 111, 1 Kbytes */ +#define ADDR_FLASH_PAGE_112 ((uint32_t)0x0801C000) /* Base @ of Page 112, 1 Kbytes */ +#define ADDR_FLASH_PAGE_113 ((uint32_t)0x0801C400) /* Base @ of Page 113, 1 Kbytes */ +#define ADDR_FLASH_PAGE_114 ((uint32_t)0x0801C800) /* Base @ of Page 114, 1 Kbytes */ +#define ADDR_FLASH_PAGE_115 ((uint32_t)0x0801CC00) /* Base @ of Page 115, 1 Kbytes */ +#define ADDR_FLASH_PAGE_116 ((uint32_t)0x0801D000) /* Base @ of Page 116, 1 Kbytes */ +#define ADDR_FLASH_PAGE_117 ((uint32_t)0x0801D400) /* Base @ of Page 117, 1 Kbytes */ +#define ADDR_FLASH_PAGE_118 ((uint32_t)0x0801D800) /* Base @ of Page 118, 1 Kbytes */ +#define ADDR_FLASH_PAGE_119 ((uint32_t)0x0801DC00) /* Base @ of Page 119, 1 Kbytes */ +#define ADDR_FLASH_PAGE_120 ((uint32_t)0x0801E000) /* Base @ of Page 120, 1 Kbytes */ +#define ADDR_FLASH_PAGE_121 ((uint32_t)0x0801E400) /* Base @ of Page 121, 1 Kbytes */ +#define ADDR_FLASH_PAGE_122 ((uint32_t)0x0801E800) /* Base @ of Page 122, 1 Kbytes */ +#define ADDR_FLASH_PAGE_123 ((uint32_t)0x0801EC00) /* Base @ of Page 123, 1 Kbytes */ +#define ADDR_FLASH_PAGE_124 ((uint32_t)0x0801F000) /* Base @ of Page 124, 1 Kbytes */ +#define ADDR_FLASH_PAGE_125 ((uint32_t)0x0801F400) /* Base @ of Page 125, 1 Kbytes */ +#define ADDR_FLASH_PAGE_126 ((uint32_t)0x0801F800) /* Base @ of Page 126, 1 Kbytes */ +#define ADDR_FLASH_PAGE_127 ((uint32_t)0x0801FC00) /* Base @ of Page 127, 1 Kbytes */ + +/* Define the size of the sectors to be used */ +#define PAGE_SIZE (uint32_t)FLASH_PAGE_SIZE /* Page size */ + +/* EEPROM start address in Flash */ +#define EEPROM_START_ADDRESS ((uint32_t)ADDR_FLASH_PAGE_32) /* EEPROM emulation start address */ + +/* Pages 0 and 1 base and end addresses */ +#define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000)) +#define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1))) +#define PAGE0_ID ADDR_FLASH_PAGE_32 + +#define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x10000)) +#define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x10000 + PAGE_SIZE - 1)) +#define PAGE1_ID ADDR_FLASH_PAGE_96 + +/* Used Flash pages for EEPROM emulation */ +#define PAGE0 ((uint16_t)0x0000) +#define PAGE1 ((uint16_t)0x0040) + +/* No valid page define */ +#define NO_VALID_PAGE ((uint16_t)0x00AB) + +/* Page status definitions */ +#define ERASED ((uint16_t)0xFFFF) /* Page is empty */ +#define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */ +#define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */ + +/* Valid pages in read and write defines */ +#define READ_FROM_VALID_PAGE ((uint8_t)0x00) +#define WRITE_IN_VALID_PAGE ((uint8_t)0x01) + +/* Page full define */ +#define PAGE_FULL ((uint8_t)0x80) + +/* Variables' number */ +#define NB_OF_VAR ((uint8_t)0x03) + +/* Exported types ------------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +uint16_t EE_Init(void); +uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data); +uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data); + +#endif /* __EEPROM_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-eeprom-emulation/src/main.c b/examples/stm32cube-hal-eeprom-emulation/src/main.c new file mode 100644 index 00000000..0c7f4bde --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/src/main.c @@ -0,0 +1,194 @@ +/** + ****************************************************************************** + * @file EEPROM_Emulation/Src/main.c + * @author MCD Application Team + * @brief Main program body + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "eeprom.h" +#include "stm32f1xx_hal_pwr.h" + +/** @addtogroup STM32F1xx_HAL_Applications + * @{ + */ + +/** @addtogroup EEPROM_Emulation + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ + +/* Virtual address defined by the user: 0xFFFF value is prohibited */ +uint16_t VirtAddVarTab[NB_OF_VAR] = {0x5555, 0x6666, 0x7777}; +uint16_t VarDataTab[NB_OF_VAR] = {0, 0, 0}; +uint16_t VarValue = 0; + +/* Private function prototypes -----------------------------------------------*/ +static void SystemClock_Config(void); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Main program. + * @param None + * @retval None + */ +int main(void) +{ + /* STM32F103xB HAL library initialization: + - Configure the Flash prefetch + - Systick timer is configured by default as source of time base, but user + can eventually implement his proper time base source (a general purpose + timer for example or other time source), keeping in mind that Time base + duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and + handled in milliseconds basis. + - Set NVIC Group Priority to 4 + - Low Level Initialization + */ + HAL_Init(); + + /* Configure the system clock to 64 MHz */ + SystemClock_Config(); + + /* Unlock the Flash Program Erase controller */ + HAL_FLASH_Unlock(); + + /* EEPROM Init */ + EE_Init(); + +/* --- Store successively many values of the three variables in the EEPROM ---*/ + /* Store 0x1000 values of Variable1 in EEPROM */ + for (VarValue = 1; VarValue <= 0x1000; VarValue++) + { + EE_WriteVariable(VirtAddVarTab[0], VarValue); + } + + /* read the last stored variables data*/ + EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]); + + + /* Store 0x2000 values of Variable2 in EEPROM */ + for (VarValue = 1; VarValue <= 0x2000; VarValue++) + { + EE_WriteVariable(VirtAddVarTab[1], VarValue); + } + + /* read the last stored variables data*/ + EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]); + EE_ReadVariable(VirtAddVarTab[1], &VarDataTab[1]); + + + /* Store 0x3000 values of Variable3 in EEPROM */ + for (VarValue = 1; VarValue <= 0x3000; VarValue++) + { + EE_WriteVariable(VirtAddVarTab[2], VarValue); + } + + /* read the last stored variables data*/ + EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]); + EE_ReadVariable(VirtAddVarTab[1], &VarDataTab[1]); + EE_ReadVariable(VirtAddVarTab[2], &VarDataTab[2]); + + while (1) + { + }; +} + +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSI) + * SYSCLK(Hz) = 64000000 + * HCLK(Hz) = 64000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 2 + * APB2 Prescaler = 1 + * PLLMUL = 16 + * Flash Latency(WS) = 2 + * @param None + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef clkinitstruct = {0}; + RCC_OscInitTypeDef oscinitstruct = {0}; + + /* Configure PLL ------------------------------------------------------*/ + /* PLL configuration: PLLCLK = (HSI / 2) * PLLMUL = (8 / 2) * 16 = 64 MHz */ + /* PREDIV1 configuration: PREDIV1CLK = PLLCLK / HSEPredivValue = 64 / 1 = 64 MHz */ + /* Enable HSI and activate PLL with HSi_DIV2 as source */ + oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; + oscinitstruct.HSEState = RCC_HSE_OFF; + oscinitstruct.LSEState = RCC_LSE_OFF; + oscinitstruct.HSIState = RCC_HSI_ON; + oscinitstruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; + oscinitstruct.PLL.PLLState = RCC_PLL_ON; + oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2; + oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL16; + if (HAL_RCC_OscConfig(&oscinitstruct)!= HAL_OK) + { + /* Initialization Error */ + while(1); + } + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; + clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; + if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2)!= HAL_OK) + { + /* Initialization Error */ + while(1); + } +} + +#ifdef USE_FULL_ASSERT + +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + + /* Infinite loop */ + while (1) + { + } +} +#endif + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-eeprom-emulation/src/stm32f1xx_hal_conf.h b/examples/stm32cube-hal-eeprom-emulation/src/stm32f1xx_hal_conf.h new file mode 100644 index 00000000..3c74be01 --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/src/stm32f1xx_hal_conf.h @@ -0,0 +1,397 @@ +/** + ****************************************************************************** + * @file stm32f1xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F1xx_HAL_CONF_H +#define __STM32F1xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +/* #define HAL_ADC_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +#define HAL_CORTEX_MODULE_ENABLED +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +#define HAL_DMA_MODULE_ENABLED +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_I2C_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_PCD_MODULE_ENABLED */ +/* #define HAL_PWR_MODULE_ENABLED */ +#define HAL_RCC_MODULE_ENABLED +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_SPI_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_TIM_MODULE_ENABLED */ +/* #define HAL_UART_MODULE_ENABLED */ +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#if defined(USE_STM3210C_EVAL) + #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ +#else + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ + +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ + +#define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848 PHY Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ +#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ +#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ + +#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ +#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ + +#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ +#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ + +#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ +#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ + +#define USE_SPI_CRC 1U + + + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f1xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f1xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f1xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f1xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f1xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f1xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "Legacy/stm32f1xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f1xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f1xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f1xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f1xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f1xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f1xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f1xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f1xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f1xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f1xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f1xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f1xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f1xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f1xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f1xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f1xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f1xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f1xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f1xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f1xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f1xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f1xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f1xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f1xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f1xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F1xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-eeprom-emulation/src/stm32f1xx_it.c b/examples/stm32cube-hal-eeprom-emulation/src/stm32f1xx_it.c new file mode 100644 index 00000000..33199cc8 --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/src/stm32f1xx_it.c @@ -0,0 +1,166 @@ +/** + ****************************************************************************** + * @file EEPROM_Emulation/Src/stm32f1xx_it.c + * @author MCD Application Team + * @brief Main Interrupt Service Routines. + * This file provides template for all exceptions handler and + * peripherals interrupt service routine. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f1xx_it.h" + +/** @addtogroup STM32F1xx_HAL_Applications + * @{ + */ + +/** @addtogroup EEPROM_Emulation + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/******************************************************************************/ +/* Cortex-M3 Processor Exceptions Handlers */ +/******************************************************************************/ + +/** + * @brief This function handles NMI exception. + * @param None + * @retval None + */ +void NMI_Handler(void) +{ +} + +/** + * @brief This function handles Hard Fault exception. + * @param None + * @retval None + */ +void HardFault_Handler(void) +{ + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Memory Manage exception. + * @param None + * @retval None + */ +void MemManage_Handler(void) +{ + /* Go to infinite loop when Memory Manage exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Bus Fault exception. + * @param None + * @retval None + */ +void BusFault_Handler(void) +{ + /* Go to infinite loop when Bus Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Usage Fault exception. + * @param None + * @retval None + */ +void UsageFault_Handler(void) +{ + /* Go to infinite loop when Usage Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles SVCall exception. + * @param None + * @retval None + */ +void SVC_Handler(void) +{ +} + +/** + * @brief This function handles Debug Monitor exception. + * @param None + * @retval None + */ +void DebugMon_Handler(void) +{ +} + +/** + * @brief This function handles PendSVC exception. + * @param None + * @retval None + */ +void PendSV_Handler(void) +{ +} + +/** + * @brief This function handles SysTick Handler. + * @param None + * @retval None + */ +void SysTick_Handler(void) +{ + HAL_IncTick(); +} + +/******************************************************************************/ +/* STM32F1xx Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file (startup_stm32f1xx.s). */ +/******************************************************************************/ +/** + * @brief This function handles PPP interrupt request. + * @param None + * @retval None + */ +/*void PPP_IRQHandler(void) +{ +}*/ + + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-eeprom-emulation/src/stm32f1xx_it.h b/examples/stm32cube-hal-eeprom-emulation/src/stm32f1xx_it.h new file mode 100644 index 00000000..dcddb8cd --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/src/stm32f1xx_it.h @@ -0,0 +1,52 @@ +/** + ****************************************************************************** + * @file EEPROM_Emulation/Inc/stm32f1xx_it.h + * @author MCD Application Team + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F1xx_IT_H +#define __STM32F1xx_IT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f1xx_hal.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F1xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-eeprom-emulation/src/system_stm32f1xx.c b/examples/stm32cube-hal-eeprom-emulation/src/system_stm32f1xx.c new file mode 100644 index 00000000..4f107c85 --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/src/system_stm32f1xx.c @@ -0,0 +1,428 @@ +/** + ****************************************************************************** + * @file system_stm32f1xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. + * + * 1. This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier + * factors, AHB/APBx prescalers and Flash settings). + * This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32f1xx_xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * 2. After each device reset the HSI (8 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to + * configure the system clock before to branch to main program. + * + * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on + * the product used), refer to "HSE_VALUE". + * When HSE is used as system clock source, directly or through PLL, and you + * are using different crystal you have to adapt the HSE value to your own + * configuration. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f1xx_system + * @{ + */ + +/** @addtogroup STM32F1xx_System_Private_Includes + * @{ + */ + +#include "stm32f1xx.h" + +/** + * @} + */ + +/** @addtogroup STM32F1xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F1xx_System_Private_Defines + * @{ + */ + +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. + This value can be provided and adapted by the user application. */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. + This value can be provided and adapted by the user application. */ +#endif /* HSI_VALUE */ + +/*!< Uncomment the following line if you need to use external SRAM */ +#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) +/* #define DATA_IN_ExtSRAM */ +#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ + +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ + + +/** + * @} + */ + +/** @addtogroup STM32F1xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F1xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ +uint32_t SystemCoreClock = 16000000; +const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; +const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; +/** + * @} + */ + +/** @addtogroup STM32F1xx_System_Private_FunctionPrototypes + * @{ + */ + +#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) +#ifdef DATA_IN_ExtSRAM + static void SystemInit_ExtMemCtl(void); +#endif /* DATA_IN_ExtSRAM */ +#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ + +/** + * @} + */ + +/** @addtogroup STM32F1xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the Embedded Flash Interface, the PLL and update the + * SystemCoreClock variable. + * @note This function should be used only after reset. + * @param None + * @retval None + */ +void SystemInit (void) +{ + /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ + /* Set HSION bit */ + RCC->CR |= (uint32_t)0x00000001; + + /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ +#if !defined(STM32F105xC) && !defined(STM32F107xC) + RCC->CFGR &= (uint32_t)0xF8FF0000; +#else + RCC->CFGR &= (uint32_t)0xF0FF0000; +#endif /* STM32F105xC */ + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFFF; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ + RCC->CFGR &= (uint32_t)0xFF80FFFF; + +#if defined(STM32F105xC) || defined(STM32F107xC) + /* Reset PLL2ON and PLL3ON bits */ + RCC->CR &= (uint32_t)0xEBFFFFFF; + + /* Disable all interrupts and clear pending bits */ + RCC->CIR = 0x00FF0000; + + /* Reset CFGR2 register */ + RCC->CFGR2 = 0x00000000; +#elif defined(STM32F100xB) || defined(STM32F100xE) + /* Disable all interrupts and clear pending bits */ + RCC->CIR = 0x009F0000; + + /* Reset CFGR2 register */ + RCC->CFGR2 = 0x00000000; +#else + /* Disable all interrupts and clear pending bits */ + RCC->CIR = 0x009F0000; +#endif /* STM32F105xC */ + +#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) + #ifdef DATA_IN_ExtSRAM + SystemInit_ExtMemCtl(); + #endif /* DATA_IN_ExtSRAM */ +#endif + +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ +#endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) + * or HSI_VALUE(*) multiplied by the PLL factors. + * + * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value + * 8 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value + * 8 MHz or 25 MHz, depending on the product used), user has to ensure + * that HSE_VALUE is same as the real frequency of the crystal used. + * Otherwise, this function may have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * @param None + * @retval None + */ +void SystemCoreClockUpdate (void) +{ + uint32_t tmp = 0, pllmull = 0, pllsource = 0; + +#if defined(STM32F105xC) || defined(STM32F107xC) + uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; +#endif /* STM32F105xC */ + +#if defined(STM32F100xB) || defined(STM32F100xE) + uint32_t prediv1factor = 0; +#endif /* STM32F100xB or STM32F100xE */ + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & RCC_CFGR_SWS; + + switch (tmp) + { + case 0x00: /* HSI used as system clock */ + SystemCoreClock = HSI_VALUE; + break; + case 0x04: /* HSE used as system clock */ + SystemCoreClock = HSE_VALUE; + break; + case 0x08: /* PLL used as system clock */ + + /* Get PLL clock source and multiplication factor ----------------------*/ + pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; + pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; + +#if !defined(STM32F105xC) && !defined(STM32F107xC) + pllmull = ( pllmull >> 18) + 2; + + if (pllsource == 0x00) + { + /* HSI oscillator clock divided by 2 selected as PLL clock entry */ + SystemCoreClock = (HSI_VALUE >> 1) * pllmull; + } + else + { + #if defined(STM32F100xB) || defined(STM32F100xE) + prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; + /* HSE oscillator clock selected as PREDIV1 clock entry */ + SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; + #else + /* HSE selected as PLL clock entry */ + if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) + {/* HSE oscillator clock divided by 2 */ + SystemCoreClock = (HSE_VALUE >> 1) * pllmull; + } + else + { + SystemCoreClock = HSE_VALUE * pllmull; + } + #endif + } +#else + pllmull = pllmull >> 18; + + if (pllmull != 0x0D) + { + pllmull += 2; + } + else + { /* PLL multiplication factor = PLL input clock * 6.5 */ + pllmull = 13 / 2; + } + + if (pllsource == 0x00) + { + /* HSI oscillator clock divided by 2 selected as PLL clock entry */ + SystemCoreClock = (HSI_VALUE >> 1) * pllmull; + } + else + {/* PREDIV1 selected as PLL clock entry */ + + /* Get PREDIV1 clock source and division factor */ + prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; + prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; + + if (prediv1source == 0) + { + /* HSE oscillator clock selected as PREDIV1 clock entry */ + SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; + } + else + {/* PLL2 clock selected as PREDIV1 clock entry */ + + /* Get PREDIV2 division factor and PLL2 multiplication factor */ + prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; + pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; + SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; + } + } +#endif /* STM32F105xC */ + break; + + default: + SystemCoreClock = HSI_VALUE; + break; + } + + /* Compute HCLK clock frequency ----------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK clock frequency */ + SystemCoreClock >>= tmp; +} + +#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) +/** + * @brief Setup the external memory controller. Called in startup_stm32f1xx.s + * before jump to __main + * @param None + * @retval None + */ +#ifdef DATA_IN_ExtSRAM +/** + * @brief Setup the external memory controller. + * Called in startup_stm32f1xx_xx.s/.c before jump to main. + * This function configures the external SRAM mounted on STM3210E-EVAL + * board (STM32 High density devices). This SRAM will be used as program + * data memory (including heap and stack). + * @param None + * @retval None + */ +void SystemInit_ExtMemCtl(void) +{ + __IO uint32_t tmpreg; + /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is + required, then adjust the Register Addresses */ + + /* Enable FSMC clock */ + RCC->AHBENR = 0x00000114; + + /* Delay after an RCC peripheral clock enabling */ + tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN); + + /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ + RCC->APB2ENR = 0x000001E0; + + /* Delay after an RCC peripheral clock enabling */ + tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN); + + (void)(tmpreg); + +/* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ +/*---------------- SRAM Address lines configuration -------------------------*/ +/*---------------- NOE and NWE configuration --------------------------------*/ +/*---------------- NE3 configuration ----------------------------------------*/ +/*---------------- NBL0, NBL1 configuration ---------------------------------*/ + + GPIOD->CRL = 0x44BB44BB; + GPIOD->CRH = 0xBBBBBBBB; + + GPIOE->CRL = 0xB44444BB; + GPIOE->CRH = 0xBBBBBBBB; + + GPIOF->CRL = 0x44BBBBBB; + GPIOF->CRH = 0xBBBB4444; + + GPIOG->CRL = 0x44BBBBBB; + GPIOG->CRH = 0x44444B44; + +/*---------------- FSMC Configuration ---------------------------------------*/ +/*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ + + FSMC_Bank1->BTCR[4] = 0x00001091; + FSMC_Bank1->BTCR[5] = 0x00110212; +} +#endif /* DATA_IN_ExtSRAM */ +#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-eeprom-emulation/test/README b/examples/stm32cube-hal-eeprom-emulation/test/README new file mode 100644 index 00000000..df5066e6 --- /dev/null +++ b/examples/stm32cube-hal-eeprom-emulation/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/stm32cube-hal-extmem-boot/.gitignore b/examples/stm32cube-hal-extmem-boot/.gitignore new file mode 100644 index 00000000..03f4a3c1 --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/examples/stm32cube-hal-extmem-boot/.travis.yml b/examples/stm32cube-hal-extmem-boot/.travis.yml new file mode 100644 index 00000000..7c486f18 --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/stm32cube-hal-extmem-boot/README.rst b/examples/stm32cube-hal-extmem-boot/README.rst new file mode 100644 index 00000000..bb158330 --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/README.rst @@ -0,0 +1,32 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/stm32cube-hal-extmem-boot + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/stm32cube-hal-extmem-boot/include/README b/examples/stm32cube-hal-extmem-boot/include/README new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/stm32cube-hal-extmem-boot/lib/README b/examples/stm32cube-hal-extmem-boot/lib/README new file mode 100644 index 00000000..6debab1e --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/stm32cube-hal-extmem-boot/platformio.ini b/examples/stm32cube-hal-extmem-boot/platformio.ini new file mode 100644 index 00000000..d146b98d --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/platformio.ini @@ -0,0 +1,17 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:disco_f723ie] +platform = ststm32 +framework = stm32cube +board = disco_f723ie +board_build.stm32cube.variant = STM32F723E-Discovery +; board_build.ldscript = STM32F746NGHx_FLASH.ld +; lib_ignore = + ; Util-Fonts diff --git a/examples/stm32cube-hal-extmem-boot/src/fmc.c b/examples/stm32cube-hal-extmem-boot/src/fmc.c new file mode 100644 index 00000000..f1a1ca0d --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/fmc.c @@ -0,0 +1,177 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Src/fmc.c + * @author MCD Application Team + * @brief This file includes the fmc-memories supported + * STM32F723E-Discovery evaluation boards. + @verbatim + PartNumber supported by the file: + ----------------------- + - IS61WV51216BLL-10M : PSRAM external memory mounted on STM32F723E Discovery board. + + @endverbatim + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f7xx_hal.h" +#include "memory.h" +#include "memory_msp.h" + +/** @addtogroup FMC + * @{ + */ + +/** @defgroup FMC + * @{ + */ + +/** @defgroup FMC_Private_Types_Definitions FMC Private Types Definitions + * @{ + */ +/** + * @} + */ + +/** @defgroup FMC_Private_Defines FMC Private Defines + * @{ + */ +/** + * @} + */ + +/** @defgroup FMC_Private_Macros FMC Private Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup FMC_Private_Variables FMC Private Variables + * @{ + */ +/** + * @} + */ + +/** @defgroup FMC_Private_Functions FMC Private Functions + * @{ + */ + +#if (DATA_AREA == USE_EXTERNAL_PSRAM) || (CODE_AREA == USE_EXTERNAL_PSRAM) +/** @defgroup PSRAM_Constants PSRAM Defines + * @{ + */ +/* #define PSRAM_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_8*/ +#define PSRAM_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_16 + +#define PSRAM_BURSTACCESS FMC_BURST_ACCESS_MODE_DISABLE +/* #define PSRAM_BURSTACCESS FMC_BURST_ACCESS_MODE_ENABLE*/ + +#define PSRAM_WRITEBURST FMC_WRITE_BURST_DISABLE +/* #define PSRAM_WRITEBURST FMC_WRITE_BURST_ENABLE */ + +#define PSRAM_CONTINUOUSCLOCK FMC_CONTINUOUS_CLOCK_SYNC_ONLY +/* #define PSRAM_CONTINUOUSCLOCK FMC_CONTINUOUS_CLOCK_SYNC_ASYNC */ +/** + * @} + */ +/** + * @brief Initializes the PSRAM device. + * @retval PSRAM status + */ +uint32_t PSRAM_Startup(void) +{ + static FMC_NORSRAM_TimingTypeDef Timing; + SRAM_HandleTypeDef psramHandle; + + /* PSRAM device configuration */ + psramHandle.Instance = FMC_NORSRAM_DEVICE; + psramHandle.Extended = FMC_NORSRAM_EXTENDED_DEVICE; + + /* PSRAM device configuration */ + /* Timing configuration derived from system clock (up to 216Mhz) + for 108Mhz as PSRAM clock frequency */ + Timing.AddressSetupTime = 9; + Timing.AddressHoldTime = 2; + Timing.DataSetupTime = 6; + Timing.BusTurnAroundDuration = 1; + Timing.CLKDivision = 2; + Timing.DataLatency = 2; + Timing.AccessMode = FMC_ACCESS_MODE_A; + + psramHandle.Init.NSBank = FMC_NORSRAM_BANK1; + psramHandle.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; + psramHandle.Init.MemoryType = FMC_MEMORY_TYPE_SRAM; + psramHandle.Init.MemoryDataWidth = PSRAM_MEMORY_WIDTH; + psramHandle.Init.BurstAccessMode = PSRAM_BURSTACCESS; + psramHandle.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW; + psramHandle.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; + psramHandle.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE; + psramHandle.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE; + psramHandle.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; + psramHandle.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE; + psramHandle.Init.WriteBurst = PSRAM_WRITEBURST; + psramHandle.Init.WriteFifo = FMC_WRITE_FIFO_DISABLE; + psramHandle.Init.PageSize = FMC_PAGE_SIZE_NONE; + psramHandle.Init.ContinuousClock = PSRAM_CONTINUOUSCLOCK; + + /* PSRAM controller initialization */ + PSRAM_MspInit(); + if (HAL_SRAM_Init(&psramHandle, &Timing, &Timing) != HAL_OK) + { + return MEMORY_ERROR; + } + return MEMORY_OK; +} +#endif /*(DATA_AREA == USE_EXTERNAL_PSRAM) || (CODE_AREA == USE_EXTERNAL_PSRAM)*/ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/main.c b/examples/stm32cube-hal-extmem-boot/src/main.c new file mode 100644 index 00000000..fcca5888 --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/main.c @@ -0,0 +1,271 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Src/main.c + * @author MCD Application Team + * @brief This file provides main program functions + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "memory.h" + +/** @addtogroup STM32F7xx_HAL_Applications + * @{ + */ + +/** @addtogroup ExtMem_Boot + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +typedef void (*pFunction)(void); +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +pFunction JumpToApplication; + + +/* Private function prototypes -----------------------------------------------*/ +static void SystemClock_Config(void); +static void Error_Handler(void); +static void CPU_CACHE_Enable(void); +static void CPU_CACHE_Disable(void); +static uint32_t Memory_Startup(void); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Main program + * @param None + * @retval None + */ +int main(void) +{ + /* Enable the CPU Cache */ + CPU_CACHE_Enable(); + + /* STM32F7xx HAL library initialization: + - Configure the Flash ART accelerator on ITCM interface + - Configure the Systick to generate an interrupt each 1 msec + - Set NVIC Group Priority to 4 + - Global MSP (MCU Support Package) initialization + */ + HAL_Init(); + + /* Configure the system clock to 200 MHz */ + /* Configure the Systick to generate an interrupt each 1 msec */ + SystemClock_Config(); + + /*##-1- Configure Required Memory #########################################*/ + if(Memory_Startup() != MEMORY_OK) + { + Error_Handler(); + } + + /* Disable CPU L1 cache before jumping to the QSPI code execution */ + CPU_CACHE_Disable(); + /* Disable Systick interrupt */ + SysTick->CTRL = 0; + + /* Initialize user application's Stack Pointer & Jump to user application */ + JumpToApplication = (pFunction) (*(__IO uint32_t*) (APPLICATION_ADDRESS + 4)); + __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS); + JumpToApplication(); + + /* We should never get here as execution is now on user application */ + while(1) + { + } +} + +/** + * @brief Initialize and configure Volatile and Non-Volatile memory. + * @param None + * @retval None + */ +uint32_t Memory_Startup(void) +{ + uint32_t status = HAL_OK; + + /* Volatile Memory Configuration */ +#if (DATA_AREA == USE_EXTERNAL_PSRAM) || (CODE_AREA == USE_EXTERNAL_PSRAM) + status |= PSRAM_Startup(); +#endif + + /* Non-Volatile Memory Configuration */ +#if (CODE_AREA == USE_QSPI) + status |= QSPI_Startup(QSPI_MODE); +#endif + + return status; +} + +/** + * @brief This function is executed in case of error occurrence. + * @param None + * @retval None + */ +static void Error_Handler(void) +{ + while(1) + { + } +} + +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 200000000 + * HCLK(Hz) = 200000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 4 + * APB2 Prescaler = 2 + * HSE Frequency(Hz) = 25000000 + * PLL_M = 25 + * PLL_N = 400 + * PLL_P = 2 + * PLL_Q = 8 + * VDD(V) = 3.3 + * Main regulator output voltage = Scale1 mode + * Flash Latency(WS) = 6 + * @param None + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + HAL_StatusTypeDef ret = HAL_OK; + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 25; + RCC_OscInitStruct.PLL.PLLN = 400; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 8; + ret = HAL_RCC_OscConfig(&RCC_OscInitStruct); + if(ret != HAL_OK) + { + while(1) { ; } + } + + /* Activate the OverDrive to reach the 200 MHz Frequency */ + ret = HAL_PWREx_EnableOverDrive(); + if(ret != HAL_OK) + { + while(1) { ; } + } + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + + ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6); + if(ret != HAL_OK) + { + while(1) { ; } + } +} + +/** + * @brief CPU L1-Cache enable. + * @param None + * @retval None + */ +static void CPU_CACHE_Enable(void) +{ + /* Enable I-Cache */ + SCB_EnableICache(); + + /* Enable D-Cache */ + SCB_EnableDCache(); +} + +/** + * @brief CPU L1-Cache disable. + * @param None + * @retval None + */ +static void CPU_CACHE_Disable(void) +{ + /* Disable I-Cache */ + SCB_DisableICache(); + + /* Disable D-Cache */ + SCB_DisableDCache(); +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t* file, uint32_t line) +{ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + + /* Infinite loop */ + while (1) + { + } +} +#endif + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/main.h b/examples/stm32cube-hal-extmem-boot/src/main.h new file mode 100644 index 00000000..08b61e24 --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/main.h @@ -0,0 +1,61 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Inc/main.h + * @author MCD Application Team + * @brief Header for main.c module + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f7xx_hal.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ + +#endif /* __MAIN_H */ + +/* Exported functions ------------------------------------------------------- */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/memory.h b/examples/stm32cube-hal-extmem-boot/src/memory.h new file mode 100644 index 00000000..51e6bd8b --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/memory.h @@ -0,0 +1,175 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Inc/memory.h + * @author MCD Application Team + * @brief This file contains the common defines and functions prototypes for + * all external memory configuration helper. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/** @addtogroup MEMORY + * @{ + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MEMORY_H +#define __MEMORY_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32f7xx_hal.h" + +/** @addtogroup MEMORY + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ + +/** @defgroup MEMORY_Exported_Types Memory Exported Types + * @{ + */ +/* Error codes */ +#define MEMORY_OK ((uint32_t)0x00) +#define MEMORY_ERROR ((uint32_t)0x01) + + +/* QSPI Init Mode */ +#define QSPI_MODE ((uint32_t)0x00) /* Init in quad-spi mode for XiP mode */ +#define SPI_NOR_MODE ((uint32_t)0x01) /* Emulate an spi-nor using QSPI with one line for BootROM scenario */ +/** + * @} + */ + +#define USE_EXTERNAL_PSRAM 3 +#define USE_INTERNAL_SRAM 4 +#define USE_QSPI 5 + +/* + @verbatim + ============================================================================== + ##### How to use this Config ##### + ============================================================================== + [..] + The configuration bellow allows simple selection switch between configuration + + The configuration is composed mainly by two area: + (#) CODE_AREA: Used to specify external memory used for code execution + (##) XiP Mode: + (+++) USE_QSPI : QSPI Flash is used for code execution + + (#) DATA_AREA: Used to specify volatile memory used for data holding + (##) USE_EXTERNAL_PSRAM : External PSRAM is used for code execution + (##) USE_INTERNAL_SRAM : Internal SRAM is used for code execution + + Bellow an automatic update APPLICATION_ADDRESS to default value based on + user configuration, which can be tailored as required + + Finally a set of check allows to avoid unsupported combined configuration. + + @endverbatim +*/ +#define DATA_AREA USE_INTERNAL_SRAM +#define CODE_AREA USE_QSPI + +/*************************************************/ +/* */ +/* Configure Application Startup Address */ +/* */ +/*************************************************/ +#if (CODE_AREA == USE_QSPI) + #define APPLICATION_ADDRESS QSPI_BASE + +#else + #error "APPLICATION_ADDRESS not defined" + +#endif + +/****************************************************/ +/* */ +/* Check to avoid unsupported configuration */ +/* */ +/****************************************************/ +#if ((DATA_AREA != USE_EXTERNAL_PSRAM) && \ + (DATA_AREA != USE_INTERNAL_SRAM)) + #error "Wrong type used for DATA_AREA" +#endif + +#if (CODE_AREA != USE_QSPI) + #error "Wrong type used for CODE_AREA" +#endif + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup Memory_Exported_Functions Non-Volatile memory + * @{ + */ +uint32_t QSPI_Startup(uint32_t Mode); +/** + * @} + */ + + +/** @addtogroup Memory_Exported_Functions Volatile memory + * @{ + */ +uint32_t PSRAM_Startup(void); +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MEMORY_H */ +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/memory_msp.c b/examples/stm32cube-hal-extmem-boot/src/memory_msp.c new file mode 100644 index 00000000..f451487a --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/memory_msp.c @@ -0,0 +1,187 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Src/memory_msp.c + * @author MCD Application Team + * @brief External memory code execution MSP module. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f7xx_hal.h" +#include "memory.h" +#include "memory_msp.h" + +/** @addtogroup MEMORY + * @{ + */ + +/** @defgroup MEMORY + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** @defgroup MEMORY_MSP_Private_Functions + * @{ + */ + +#if (CODE_AREA == USE_QSPI) || (CODE_AREA == USE_SPI_NOR) +/** + * @brief QSPI MSP Initialization + * This function configures the hardware resources used in this example: + * - Peripheral's clock enable + * - Peripheral's GPIO Configuration + * - NVIC configuration for QSPI interrupt + * @retval None + */ +void QSPI_MspInit(void) +{ + GPIO_InitTypeDef gpio_init_structure; + + /*##-1- Enable peripherals and GPIO Clocks #################################*/ + /* Enable the QuadSPI memory interface clock */ + __HAL_RCC_QSPI_CLK_ENABLE(); + /* Reset the QuadSPI memory interface */ + __HAL_RCC_QSPI_FORCE_RESET(); + __HAL_RCC_QSPI_RELEASE_RESET(); + /* Enable GPIO clocks */ + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + + /*##-2- Configure peripheral GPIO ##########################################*/ + /* QSPI CS GPIO pin configuration */ + gpio_init_structure.Pin = GPIO_PIN_6; + gpio_init_structure.Alternate = GPIO_AF10_QUADSPI; + gpio_init_structure.Mode = GPIO_MODE_AF_PP; + gpio_init_structure.Pull = GPIO_PULLUP; + gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH; + HAL_GPIO_Init(GPIOB, &gpio_init_structure); + + /* QSPI CLK GPIO pin configuration */ + gpio_init_structure.Pin = GPIO_PIN_2; + gpio_init_structure.Alternate = GPIO_AF9_QUADSPI; + gpio_init_structure.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &gpio_init_structure); + + /* QSPI D0 GPIO pin configuration */ + gpio_init_structure.Pin = GPIO_PIN_9; + HAL_GPIO_Init(GPIOC, &gpio_init_structure); +#if (CODE_AREA == USE_QSPI) + /* QSPI D1 GPIO pin configuration */ + gpio_init_structure.Pin = GPIO_PIN_10; + HAL_GPIO_Init(GPIOC, &gpio_init_structure); + /* QSPI D2 GPIO pin configuration */ + gpio_init_structure.Pin = GPIO_PIN_2; + HAL_GPIO_Init(GPIOE, &gpio_init_structure); + /* QSPI D3 GPIO pin configuration */ + gpio_init_structure.Pin = GPIO_PIN_13; + HAL_GPIO_Init(GPIOD, &gpio_init_structure); +#endif +} +#endif + +#if (DATA_AREA == USE_EXTERNAL_PSRAM) || (CODE_AREA == USE_EXTERNAL_PSRAM) +/** + * @brief Initializes PSRAM MSP. + * @retval None + */ +void PSRAM_MspInit(void) +{ + GPIO_InitTypeDef gpio_init_structure; + + /* Enable FMC clock */ + __HAL_RCC_FMC_CLK_ENABLE(); + + /* Enable GPIOs clock */ + __HAL_RCC_GPIOF_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOE_CLK_ENABLE(); + + /* Common GPIO configuration */ + gpio_init_structure.Mode = GPIO_MODE_AF_PP; + gpio_init_structure.Pull = GPIO_PULLUP; + gpio_init_structure.Speed = GPIO_SPEED_HIGH; + gpio_init_structure.Alternate = GPIO_AF12_FMC; + + /* GPIOD configuration: GPIO_PIN_7 is FMC_NE1 , GPIO_PIN_11 ans GPIO_PIN_12 are PSRAM_A16 and PSRAM_A17 */ + gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_7 | GPIO_PIN_8 |\ + GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_15; + HAL_GPIO_Init(GPIOD, &gpio_init_structure); + + /* GPIOE configuration */ + gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ + GPIO_PIN_12 |GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; + HAL_GPIO_Init(GPIOE, &gpio_init_structure); + + /* GPIOF configuration */ + gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 |\ + GPIO_PIN_5 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; + HAL_GPIO_Init(GPIOF, &gpio_init_structure); + + /* GPIOG configuration */ + gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 |\ + GPIO_PIN_5; + HAL_GPIO_Init(GPIOG, &gpio_init_structure); + +} +#endif /*(DATA_AREA == USE_EXTERNAL_PSRAM) || (CODE_AREA == USE_EXTERNAL_PSRAM)*/ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/memory_msp.h b/examples/stm32cube-hal-extmem-boot/src/memory_msp.h new file mode 100644 index 00000000..279ce67a --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/memory_msp.h @@ -0,0 +1,80 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Inc/memory_msp.h + * @author MCD Application Team + * @brief This file contains Header for msp function needed for external + memory initialization. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MEMORY_PRIVATE_H +#define __MEMORY_PRIVATE_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f7xx_hal.h" + +/** @addtogroup MEMORY_DEFS + * @{ + */ + +/* Exported constants --------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +void PSRAM_MspInit(void); +void QSPI_MspInit(void); + +/* Exported macro ------------------------------------------------------------*/ + + +#ifdef __cplusplus +} +#endif + +#endif /* __MEMORY_PRIVATE_H */ +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/qspi.c b/examples/stm32cube-hal-extmem-boot/src/qspi.c new file mode 100644 index 00000000..610618ed --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/qspi.c @@ -0,0 +1,629 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Src/qspi.c + * @author MCD Application Team + * @brief This file includes a driver for QSPI flashes support mounted on + * STM32F723E-Discovery evaluation boards. + @verbatim + PartNumber supported by the file: + ----------------------- + - MX25L512 : QSPI Flash memory mounted on STM32F723E Discovery board. + @endverbatim + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f7xx_hal.h" +#include "memory.h" +#include "memory_msp.h" +#include "mx25l512.h" + +/** @addtogroup QSPI + * @{ + */ + +/** @defgroup QSPI + * @{ + */ + + +/* Private variables ---------------------------------------------------------*/ + +/** @defgroup QSPI_Private_Variables QSPI Private Variables + * @{ + */ +QSPI_HandleTypeDef QSPIHandle; +QSPI_CommandTypeDef sCommand; +QSPI_AutoPollingTypeDef sConfig; +/** + * @} + */ + +/* Private Macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** @defgroup QSPI_Private_Functions QSPI Private Functions + * @{ + */ +static uint32_t QSPI_ResetMemory(QSPI_HandleTypeDef *hqspi); +static uint32_t QSPI_EnterFourBytesAddress(QSPI_HandleTypeDef *hqspi); +static uint32_t QSPI_DummyCyclesCfg(QSPI_HandleTypeDef *hqspi); +static uint32_t QSPI_EnterMemory_QPI(QSPI_HandleTypeDef *hqspi); +static uint32_t QSPI_OutDrvStrengthCfg(QSPI_HandleTypeDef *hqspi); +static uint32_t QSPI_WriteEnable(QSPI_HandleTypeDef *hqspi); +static uint32_t QSPI_AutoPollingMemReady(QSPI_HandleTypeDef *hqspi, uint32_t Timeout); +static uint32_t QSPI_EnableMemoryMappedMode(QSPI_HandleTypeDef *hqspi); + +/** + * @} + */ + +/** @defgroup QSPI_Exported_Functions QSPI Exported Functions + * @{ + */ + +/** + * @brief Initializes and configure the QSPI interface. + * @retval QSPI memory status + */ +uint32_t QSPI_Startup(uint32_t Mode) +{ + QSPIHandle.Instance = QUADSPI; + + /* Call the DeInit function to reset the driver */ + if (HAL_QSPI_DeInit(&QSPIHandle) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* System level initialization */ + QSPI_MspInit(); + + /* sCommand initialize common parameter */ + sCommand.AddressMode = QSPI_ADDRESS_NONE; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + sCommand.DataMode = QSPI_DATA_NONE; + sCommand.DummyCycles = 0; + sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; + sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + sCommand.AddressSize = QSPI_ADDRESS_32_BITS; + + /* sConfig initialize common parameter */ + sConfig.MatchMode = QSPI_MATCH_MODE_AND; + sConfig.StatusBytesSize = 1; + sConfig.Interval = 0x10; + sConfig.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; + + /* QSPI initialization */ + /* QSPI freq = SYSCLK /(1 + ClockPrescaler) = 200 MHz/(1+1) = 100 Mhz */ + QSPIHandle.Init.ClockPrescaler = 1; /* QSPI freq = 200 MHz/(1+1) = 100 Mhz */ + QSPIHandle.Init.FifoThreshold = 16; + QSPIHandle.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE; + QSPIHandle.Init.FlashSize = POSITION_VAL(MX25L512_FLASH_SIZE) - 1; + QSPIHandle.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_4_CYCLE; /* Min 30ns for nonRead */ + QSPIHandle.Init.ClockMode = QSPI_CLOCK_MODE_0; + QSPIHandle.Init.FlashID = QSPI_FLASH_ID_1; + QSPIHandle.Init.DualFlash = QSPI_DUALFLASH_DISABLE; + + if (HAL_QSPI_Init(&QSPIHandle) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* QSPI memory reset */ + if (QSPI_ResetMemory(&QSPIHandle)) + { + return MEMORY_ERROR; + } + + /* Put QSPI memory in QPI mode */ + if( QSPI_EnterMemory_QPI( &QSPIHandle )!=MEMORY_OK ) + { + return MEMORY_ERROR; + } + + /* Set the QSPI memory in 4-bytes address mode */ + if (QSPI_EnterFourBytesAddress(&QSPIHandle) != MEMORY_OK) + { + return MEMORY_ERROR; + } + + /* Configuration of the dummy cycles on QSPI memory side */ + if (QSPI_DummyCyclesCfg(&QSPIHandle) != MEMORY_OK) + { + return MEMORY_ERROR; + } + + /* Configuration of the Output driver strength on memory side */ + if( QSPI_OutDrvStrengthCfg( &QSPIHandle ) != MEMORY_OK ) + { + return MEMORY_ERROR; + } + + /* Enable MemoryMapped mode */ + if( QSPI_EnableMemoryMappedMode( &QSPIHandle ) != MEMORY_OK ) + { + return MEMORY_ERROR; + } + + return MEMORY_OK; +} + + +/** + * @} + */ + +/** @addtogroup QSPI_Private_Functions + * @{ + */ + + +/** + * @brief Configure the QSPI in memory-mapped mode + * @retval QSPI memory status + */ +static uint32_t QSPI_EnableMemoryMappedMode(QSPI_HandleTypeDef *hqspi) +{ + QSPI_MemoryMappedTypeDef s_mem_mapped_cfg; + + /* Configure the command for the read instruction */ + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.Instruction = QSPI_READ_4_BYTE_ADDR_CMD; + sCommand.AddressMode = QSPI_ADDRESS_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.DummyCycles = MX25L512_DUMMY_CYCLES_READ_QUAD_IO; + + /* Configure the memory mapped mode */ + s_mem_mapped_cfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE; + s_mem_mapped_cfg.TimeOutPeriod = 0; + + if (HAL_QSPI_MemoryMapped(hqspi, &sCommand, &s_mem_mapped_cfg) != HAL_OK) + { + return MEMORY_ERROR; + } + + return MEMORY_OK; +} + +/** + * @brief This function reset the QSPI memory. + * @param hqspi: QSPI handle + * @retval None + */ +static uint32_t QSPI_ResetMemory(QSPI_HandleTypeDef *hqspi) +{ + uint8_t reg; + + /* Send command RESET command in QPI mode (QUAD I/Os) */ + /* Initialize the reset enable command */ + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.Instruction = RESET_ENABLE_CMD; + sCommand.DataMode = QSPI_DATA_NONE; + + /* Send the command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + /* Send the reset memory command */ + sCommand.Instruction = RESET_MEMORY_CMD; + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Send command RESET command in SPI mode */ + /* Initialize the reset enable command */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = RESET_ENABLE_CMD; + /* Send the command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Send the reset memory command */ + sCommand.Instruction = RESET_MEMORY_CMD; + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* After reset CMD, 1000ms requested if QSPI memory SWReset occured during full chip erase operation */ + HAL_Delay( 1000 ); + + /* Configure automatic polling mode to wait the memory is ready */ + if (QSPI_AutoPollingMemReady(hqspi, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != MEMORY_OK) + { + return MEMORY_ERROR; + } + + /* Initialize the reading of status register */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = READ_STATUS_REG_CMD; + sCommand.DataMode = QSPI_DATA_1_LINE; + sCommand.NbData = 1; + + /* Configure the command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Reception of the data */ + if (HAL_QSPI_Receive(hqspi, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Enable write operations, command in 1 bit */ + /* Enable write operations */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = WRITE_ENABLE_CMD; + sCommand.DataMode = QSPI_DATA_NONE; + + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Configure automatic polling mode to wait for write enabling */ + sConfig.Match = MX25L512_SR_WREN; + sConfig.Mask = MX25L512_SR_WREN; + + sCommand.Instruction = READ_STATUS_REG_CMD; + sCommand.DataMode = QSPI_DATA_1_LINE; + + if (HAL_QSPI_AutoPolling(hqspi, &sCommand, &sConfig, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Update the configuration register with new dummy cycles */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = WRITE_STATUS_CFG_REG_CMD; + sCommand.NbData = 1; + + /* Enable the Quad IO on the QSPI memory (Non-volatile bit) */ + reg |= MX25L512_SR_QUADEN; + + /* Configure the command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Transmission of the data */ + if (HAL_QSPI_Transmit(hqspi, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* 40ms Write Status/Configuration Register Cycle Time */ + HAL_Delay( 40 ); + + return MEMORY_OK; +} + +/** + * @brief This function set the QSPI memory in 4-byte address mode + * @param hqspi: QSPI handle + * @retval None + */ +static uint32_t QSPI_EnterFourBytesAddress(QSPI_HandleTypeDef *hqspi) +{ + /* Initialize the command */ + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.Instruction = ENTER_4_BYTE_ADDR_MODE_CMD; + sCommand.DataMode = QSPI_DATA_NONE; + + /* Enable write operations */ + if (QSPI_WriteEnable(hqspi) != MEMORY_OK) + { + return MEMORY_ERROR; + } + + /* Send the command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Configure automatic polling mode to wait the memory is ready */ + if (QSPI_AutoPollingMemReady(hqspi, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != MEMORY_OK) + { + return MEMORY_ERROR; + } + + return MEMORY_OK; +} + +/** + * @brief This function configure the dummy cycles on memory side. + * @param hqspi: QSPI handle + * @retval None + */ +static uint32_t QSPI_DummyCyclesCfg(QSPI_HandleTypeDef *hqspi) +{ + uint8_t reg[2]; + + /* Initialize the reading of status register */ + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + + sCommand.NbData = 1; + sCommand.Instruction = READ_STATUS_REG_CMD; + + /* Configure the command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Reception of the data */ + if (HAL_QSPI_Receive(hqspi, &(reg[0]), HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Initialize the reading of configuration register */ + sCommand.Instruction = READ_CFG_REG_CMD; + sCommand.NbData = 1; + + /* Configure the command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Reception of the data */ + if (HAL_QSPI_Receive(hqspi, &(reg[1]), HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Enable write operations */ + if (QSPI_WriteEnable(hqspi) != MEMORY_OK) + { + return MEMORY_ERROR; + } + + /* Update the configuration register with new dummy cycles */ + sCommand.Instruction = WRITE_STATUS_CFG_REG_CMD; + sCommand.NbData = 2; + + /* MX25L512_DUMMY_CYCLES_READ_QUAD = 3 for 10 cycles in QPI mode */ + MODIFY_REG( reg[1], MX25L512_CR_NB_DUMMY, (MX25L512_DUMMY_CYCLES_READ_QUAD << POSITION_VAL(MX25L512_CR_NB_DUMMY))); + + /* Configure the write volatile configuration register command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Transmission of the data */ + if (HAL_QSPI_Transmit(hqspi, &(reg[0]), HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* 40ms Write Status/Configuration Register Cycle Time */ + HAL_Delay( 40 ); + + return MEMORY_OK; +} + +/** + * @brief This function put QSPI memory in QPI mode (quad I/O). + * @param hqspi: QSPI handle + * @retval None + */ +static uint32_t QSPI_EnterMemory_QPI( QSPI_HandleTypeDef *hqspi ) +{ + /* Initialize the QPI enable command */ + /* QSPI memory is supported to be in SPI mode, so CMD on 1 LINE */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = ENTER_QUAD_CMD; + sCommand.DataMode = QSPI_DATA_NONE; + + /* Send the command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Configure automatic polling mode to wait the QUADEN bit=1 and WIP bit=0 */ + sConfig.Match = MX25L512_SR_QUADEN; + sConfig.Mask = MX25L512_SR_QUADEN|MX25L512_SR_WIP; + + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.Instruction = READ_STATUS_REG_CMD; + sCommand.DataMode = QSPI_DATA_4_LINES; + + if (HAL_QSPI_AutoPolling(hqspi, &sCommand, &sConfig, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + return MEMORY_OK; +} + +/** + * @brief This function configure the Output driver strength on memory side. + * @param hqspi: QSPI handle + * @retval None + */ +static uint32_t QSPI_OutDrvStrengthCfg( QSPI_HandleTypeDef *hqspi ) +{ + uint8_t reg[2]; + + /* Initialize the reading of status register */ + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + + sCommand.Instruction = READ_STATUS_REG_CMD; + sCommand.NbData = 1; + + /* Configure the command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Reception of the data */ + if (HAL_QSPI_Receive(hqspi, &(reg[0]), HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Initialize the reading of configuration register */ + sCommand.Instruction = READ_CFG_REG_CMD; + sCommand.NbData = 1; + + /* Configure the command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Reception of the data */ + if (HAL_QSPI_Receive(hqspi, &(reg[1]), HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Enable write operations */ + if (QSPI_WriteEnable(&QSPIHandle) != MEMORY_OK) + { + return MEMORY_ERROR; + } + + /* Update the configuration register with new output driver strength */ + sCommand.Instruction = WRITE_STATUS_CFG_REG_CMD; + sCommand.NbData = 2; + + /* Set Output Strength of the QSPI memory 15 ohms */ + MODIFY_REG( reg[1], MX25L512_CR_ODS, (MX25L512_CR_ODS_15 << POSITION_VAL(MX25L512_CR_ODS))); + + /* Configure the write volatile configuration register command */ + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Transmission of the data */ + if (HAL_QSPI_Transmit(hqspi, &(reg[0]), HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + return MEMORY_OK; +} + +/** + * @brief This function send a Write Enable and wait it is effective. + * @param hqspi: QSPI handle + * @retval None + */ +static uint32_t QSPI_WriteEnable(QSPI_HandleTypeDef *hqspi) +{ + /* Enable write operations */ + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.Instruction = WRITE_ENABLE_CMD; + sCommand.DataMode = QSPI_DATA_NONE; + + if (HAL_QSPI_Command(hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + /* Configure automatic polling mode to wait for write enabling */ + sConfig.Match = MX25L512_SR_WREN; + sConfig.Mask = MX25L512_SR_WREN; + + sCommand.Instruction = READ_STATUS_REG_CMD; + sCommand.DataMode = QSPI_DATA_4_LINES; + + if (HAL_QSPI_AutoPolling(hqspi, &sCommand, &sConfig, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) + { + return MEMORY_ERROR; + } + + return MEMORY_OK; +} + +/** + * @brief This function read the SR of the memory and wait the EOP. + * @param hqspi: QSPI handle + * @param Timeout + * @retval None + */ +static uint32_t QSPI_AutoPollingMemReady(QSPI_HandleTypeDef *hqspi, uint32_t Timeout) +{ + /* Configure automatic polling mode to wait for memory ready */ + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.Instruction = READ_STATUS_REG_CMD; + sCommand.DataMode = QSPI_DATA_4_LINES; + + sConfig.Match = 0; + sConfig.Mask = MX25L512_SR_WIP; + + if (HAL_QSPI_AutoPolling(hqspi, &sCommand, &sConfig, Timeout) != HAL_OK) + { + return MEMORY_ERROR; + } + + return MEMORY_OK; +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_hal_conf.h b/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_hal_conf.h new file mode 100644 index 00000000..df263d69 --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_hal_conf.h @@ -0,0 +1,458 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Inc/stm32f7xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F7xx_HAL_CONF_H +#define __STM32F7xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +/* #define HAL_ADC_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_DCMI_MODULE_ENABLED */ +#define HAL_DMA_MODULE_ENABLED +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +#define HAL_FLASH_MODULE_ENABLED +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +/* #define HAL_I2C_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +#define HAL_SD_MODULE_ENABLED +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_SPI_MODULE_ENABLED */ +/* #define HAL_TIM_MODULE_ENABLED */ +/* #define HAL_UART_MODULE_ENABLED */ +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_CORTEX_MODULE_ENABLED +/* #define HAL_PCD_MODULE_ENABLED */ +/* #define HAL_HCD_MODULE_ENABLED */ + + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)32000) +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0x0F) /*!< tick interrupt priority */ +#define USE_RTOS 0 +#define PREFETCH_ENABLE 1 +#define INSTRUCTION_CACHE_ENABLE 1 +#define DATA_CACHE_ENABLE 1 + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1 */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2 +#define MAC_ADDR1 0 +#define MAC_ADDR2 0 +#define MAC_ADDR3 0 +#define MAC_ADDR4 0 +#define MAC_ADDR5 0 + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848 PHY Address*/ +#define DP83848_PHY_ADDRESS 0x01 +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FF) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF) + +#define PHY_READ_TO ((uint32_t)0x0000FFFF) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFF) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x10) /*!< PHY status register Offset */ +#define PHY_MICR ((uint16_t)0x11) /*!< MII Interrupt Control Register */ +#define PHY_MISR ((uint16_t)0x12) /*!< MII Interrupt Status and Misc. Control Register */ + +#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ +#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ + +#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ +#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ + +#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ +#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 1U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f7xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f7xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F7xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_hal_msp.c b/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_hal_msp.c new file mode 100644 index 00000000..443dd3f0 --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_hal_msp.c @@ -0,0 +1,80 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Src/stm32f7xx_hal_msp.c + * @author MCD Application Team + * @brief HAL MSP module. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/** @addtogroup STM32F7xx_HAL_Applications + * @{ + */ + +/** @defgroup LOADER + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** @defgroup HAL_MSP_Private_Functions + * @{ + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_it.c b/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_it.c new file mode 100644 index 00000000..6dbd8c6f --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_it.c @@ -0,0 +1,160 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Src/stm32f7xx_it.c + * @author MCD Application Team + * @brief Main Interrupt Service Routines. + * This file provides template for all exceptions handler and + * peripherals interrupt service routine. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32f7xx_it.h" + +/** @addtogroup STM32F7xx_HAL_Applications + * @{ + */ + +/** @addtogroup LOADER + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/******************************************************************************/ +/* Cortex-M7 Processor Exceptions Handlers */ +/******************************************************************************/ + +/** + * @brief This function handles NMI exception. + * @param None + * @retval None + */ +void NMI_Handler(void) +{ +} + +/** + * @brief This function handles Hard Fault exception. + * @param None + * @retval None + */ +void HardFault_Handler(void) +{ + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Memory Manage exception. + * @param None + * @retval None + */ +void MemManage_Handler(void) +{ + /* Go to infinite loop when Memory Manage exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Bus Fault exception. + * @param None + * @retval None + */ +void BusFault_Handler(void) +{ + /* Go to infinite loop when Bus Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Usage Fault exception. + * @param None + * @retval None + */ +void UsageFault_Handler(void) +{ + /* Go to infinite loop when Usage Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles SVCall exception. + * @param None + * @retval None + */ +void SVC_Handler(void) +{ +} + +/** + * @brief This function handles Debug Monitor exception. + * @param None + * @retval None + */ +void DebugMon_Handler(void) +{ +} + +/** + * @brief This function handles PendSVC exception. + * @param None + * @retval None + */ +void PendSV_Handler(void) +{ +} + +/** + * @brief This function handles SysTick Handler. + * @param None + * @retval None + */ +void SysTick_Handler(void) +{ + HAL_IncTick(); +} + +/******************************************************************************/ +/* STM32F7xx Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file (startup_stm32f7xx.s). */ +/******************************************************************************/ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_it.h b/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_it.h new file mode 100644 index 00000000..25d1362a --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/stm32f7xx_it.h @@ -0,0 +1,53 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Inc/stm32f7xx_it.h + * @author MCD Application Team + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F7xx_IT_H +#define __STM32F7xx_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); +void SysTick_Handler(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F7xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/src/system_stm32f7xx.c b/examples/stm32cube-hal-extmem-boot/src/system_stm32f7xx.c new file mode 100644 index 00000000..b6910382 --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/src/system_stm32f7xx.c @@ -0,0 +1,182 @@ +/** + ****************************************************************************** + * @file ExtMem_CodeExecution/ExtMem_Boot/Src/system_stm32f7xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M7 Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32f7xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f7xx_system + * @{ + */ + +/** @addtogroup STM32F7xx_System_Private_Includes + * @{ + */ + +#include "stm32f7xx.h" + +/** + * @} + */ + +/** @addtogroup STM32F7xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F7xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32F7xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F7xx_System_Private_Variables + * @{ + */ + + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = 16000000; + const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; + const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; + +/** + * @} + */ + +/** @addtogroup STM32F7xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the Embedded Flash Interface, the PLL and update the + * SystemFrequency variable. + * @param None + * @retval None + */ +void SystemInit(void) +{ + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set HSION bit */ + RCC->CR |= (uint32_t)0x00000001; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFFF; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x24003010; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Disable all interrupts */ + RCC->CIR = 0x00000000; + + /* Configure the Vector Table location add offset address ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-extmem-boot/test/README b/examples/stm32cube-hal-extmem-boot/test/README new file mode 100644 index 00000000..df5066e6 --- /dev/null +++ b/examples/stm32cube-hal-extmem-boot/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/stm32cube-hal-iap/.gitignore b/examples/stm32cube-hal-iap/.gitignore new file mode 100644 index 00000000..03f4a3c1 --- /dev/null +++ b/examples/stm32cube-hal-iap/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/examples/stm32cube-hal-iap/.travis.yml b/examples/stm32cube-hal-iap/.travis.yml new file mode 100644 index 00000000..7c486f18 --- /dev/null +++ b/examples/stm32cube-hal-iap/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/stm32cube-hal-iap/README.rst b/examples/stm32cube-hal-iap/README.rst new file mode 100644 index 00000000..c2eae2cd --- /dev/null +++ b/examples/stm32cube-hal-iap/README.rst @@ -0,0 +1,32 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/stm32cube-hal-iap + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/stm32cube-hal-iap/include/README b/examples/stm32cube-hal-iap/include/README new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/examples/stm32cube-hal-iap/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/stm32cube-hal-iap/lib/README b/examples/stm32cube-hal-iap/lib/README new file mode 100644 index 00000000..6debab1e --- /dev/null +++ b/examples/stm32cube-hal-iap/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/stm32cube-hal-iap/platformio.ini b/examples/stm32cube-hal-iap/platformio.ini new file mode 100644 index 00000000..96ad8b6c --- /dev/null +++ b/examples/stm32cube-hal-iap/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:eval_f373vc] +platform = ststm32 +framework = stm32cube +board = eval_f373vc +board_build.stm32cube.variant = STM32373C_EVAL diff --git a/examples/stm32cube-hal-iap/src/common.c b/examples/stm32cube-hal-iap/src/common.c new file mode 100644 index 00000000..b24062c9 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/common.c @@ -0,0 +1,167 @@ +/** + ****************************************************************************** + * @file IAP_Main/Src/common.c + * @author MCD Application Team + * @brief This file provides all the common functions. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/** @addtogroup STM32F3xx_IAP_Main + * @{ + */ + +/* Includes ------------------------------------------------------------------*/ +#include "common.h" +#include "main.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Convert an Integer to a string + * @param p_str: The string output pointer + * @param intnum: The integer to be converted + * @retval None + */ +void Int2Str(uint8_t *p_str, uint32_t intnum) +{ + uint32_t i, divider = 1000000000, pos = 0, status = 0; + + for (i = 0; i < 10; i++) + { + p_str[pos++] = (intnum / divider) + 48; + + intnum = intnum % divider; + divider /= 10; + if ((p_str[pos-1] == '0') & (status == 0)) + { + pos = 0; + } + else + { + status++; + } + } +} + +/** + * @brief Convert a string to an integer + * @param p_inputstr: The string to be converted + * @param p_intnum: The integer value + * @retval 1: Correct + * 0: Error + */ +uint32_t Str2Int(uint8_t *p_inputstr, uint32_t *p_intnum) +{ + uint32_t i = 0, res = 0; + uint32_t val = 0; + + if ((p_inputstr[0] == '0') && ((p_inputstr[1] == 'x') || (p_inputstr[1] == 'X'))) + { + i = 2; + while ( ( i < 11 ) && ( p_inputstr[i] != '\0' ) ) + { + if (ISVALIDHEX(p_inputstr[i])) + { + val = (val << 4) + CONVERTHEX(p_inputstr[i]); + } + else + { + /* Return 0, Invalid input */ + res = 0; + break; + } + i++; + } + + /* valid result */ + if (p_inputstr[i] == '\0') + { + *p_intnum = val; + res = 1; + } + } + else /* max 10-digit decimal input */ + { + while ( ( i < 11 ) && ( res != 1 ) ) + { + if (p_inputstr[i] == '\0') + { + *p_intnum = val; + /* return 1 */ + res = 1; + } + else if (((p_inputstr[i] == 'k') || (p_inputstr[i] == 'K')) && (i > 0)) + { + val = val << 10; + *p_intnum = val; + res = 1; + } + else if (((p_inputstr[i] == 'm') || (p_inputstr[i] == 'M')) && (i > 0)) + { + val = val << 20; + *p_intnum = val; + res = 1; + } + else if (ISVALIDDEC(p_inputstr[i])) + { + val = val * 10 + CONVERTDEC(p_inputstr[i]); + } + else + { + /* return 0, Invalid input */ + res = 0; + break; + } + i++; + } + } + + return res; +} + +/** + * @brief Print a string on the HyperTerminal + * @param p_string: The string to be printed + * @retval None + */ +void Serial_PutString(uint8_t *p_string) +{ + uint16_t length = 0; + + while (p_string[length] != '\0') + { + length++; + } + HAL_UART_Transmit(&UartHandle, p_string, length, TX_TIMEOUT); +} + +/** + * @brief Transmit a byte to the HyperTerminal + * @param param The byte to be sent + * @retval HAL_StatusTypeDef HAL_OK if OK + */ +HAL_StatusTypeDef Serial_PutByte( uint8_t param ) +{ + return HAL_UART_Transmit(&UartHandle, ¶m, 1, TX_TIMEOUT); +} +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/common.h b/examples/stm32cube-hal-iap/src/common.h new file mode 100644 index 00000000..335c8a93 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/common.h @@ -0,0 +1,53 @@ +/** + ****************************************************************************** + * @file IAP_Main/Inc/common.h + * @author MCD Application Team + * @brief This file provides all the headers of the common functions. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __COMMON_H +#define __COMMON_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f3xx.h" +#include "stm32373c_eval.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Constants used by Serial Command Line Mode */ +#define TX_TIMEOUT ((uint32_t)100) +#define RX_TIMEOUT HAL_MAX_DELAY + +/* Exported macro ------------------------------------------------------------*/ +#define IS_CAP_LETTER(c) (((c) >= 'A') && ((c) <= 'F')) +#define IS_LC_LETTER(c) (((c) >= 'a') && ((c) <= 'f')) +#define IS_09(c) (((c) >= '0') && ((c) <= '9')) +#define ISVALIDHEX(c) (IS_CAP_LETTER(c) || IS_LC_LETTER(c) || IS_09(c)) +#define ISVALIDDEC(c) IS_09(c) +#define CONVERTDEC(c) (c - '0') + +#define CONVERTHEX_ALPHA(c) (IS_CAP_LETTER(c) ? ((c) - 'A'+10) : ((c) - 'a'+10)) +#define CONVERTHEX(c) (IS_09(c) ? ((c) - '0') : CONVERTHEX_ALPHA(c)) + +/* Exported functions ------------------------------------------------------- */ +void Int2Str(uint8_t *p_str, uint32_t intnum); +uint32_t Str2Int(uint8_t *inputstr, uint32_t *intnum); +void Serial_PutString(uint8_t *p_string); +HAL_StatusTypeDef Serial_PutByte(uint8_t param); + +#endif /* __COMMON_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/flash_if.c b/examples/stm32cube-hal-iap/src/flash_if.c new file mode 100644 index 00000000..8652f95a --- /dev/null +++ b/examples/stm32cube-hal-iap/src/flash_if.c @@ -0,0 +1,221 @@ +/** + ****************************************************************************** + * @file IAP_Main/Src/flash_if.c + * @author MCD Application Team + * @brief This file provides all the memory related operation functions. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/** @addtogroup STM32F3xx_IAP + * @{ + */ + +/* Includes ------------------------------------------------------------------*/ +#include "flash_if.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Unlocks Flash for write access + * @param None + * @retval None + */ +void FLASH_If_Init(void) +{ + /* Unlock the Program memory */ + HAL_FLASH_Unlock(); + + /* Clear all FLASH flags */ + __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPERR); + /* Unlock the Program memory */ + HAL_FLASH_Lock(); +} + +/** + * @brief This function does an erase of all user flash area + * @param start: start of user flash area + * @retval FLASHIF_OK : user flash area successfully erased + * FLASHIF_ERASEKO : error occurred + */ +uint32_t FLASH_If_Erase(uint32_t start) +{ + uint32_t NbrOfPages = 0; + uint32_t PageError = 0; + FLASH_EraseInitTypeDef pEraseInit; + HAL_StatusTypeDef status = HAL_OK; + + /* Unlock the Flash to enable the flash control register access *************/ + HAL_FLASH_Unlock(); + + /* Get the sector where start the user flash area */ + NbrOfPages = (USER_FLASH_END_ADDRESS - start)/FLASH_PAGE_SIZE; + + pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES; + pEraseInit.PageAddress = start; + pEraseInit.NbPages = NbrOfPages; + status = HAL_FLASHEx_Erase(&pEraseInit, &PageError); + + /* Lock the Flash to disable the flash control register access (recommended + to protect the FLASH memory against possible unwanted operation) *********/ + HAL_FLASH_Lock(); + + if (status != HAL_OK) + { + /* Error occurred while page erase */ + return FLASHIF_ERASEKO; + } + + return FLASHIF_OK; +} + +/* Public functions ---------------------------------------------------------*/ +/** + * @brief This function writes a data buffer in flash (data are 32-bit aligned). + * @note After writing data buffer, the flash content is checked. + * @param destination: start address for target location + * @param p_source: pointer on buffer with data to write + * @param length: length of data buffer (unit is 32-bit word) + * @retval uint32_t 0: Data successfully written to Flash memory + * 1: Error occurred while writing data in Flash memory + * 2: Written Data in flash memory is different from expected one + */ +uint32_t FLASH_If_Write(uint32_t destination, uint32_t *p_source, uint32_t length) +{ + uint32_t i = 0; + + /* Unlock the Flash to enable the flash control register access *************/ + HAL_FLASH_Unlock(); + + for (i = 0; (i < length) && (destination <= (USER_FLASH_END_ADDRESS-4)); i++) + { + /* Device voltage range supposed to be [2.7V to 3.6V], the operation will + be done by word */ + if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, destination, *(uint32_t*)(p_source+i)) == HAL_OK) + { + /* Check the written value */ + if (*(uint32_t*)destination != *(uint32_t*)(p_source+i)) + { + /* Flash content doesn't match SRAM content */ + return(FLASHIF_WRITINGCTRL_ERROR); + } + /* Increment FLASH destination address */ + destination += 4; + } + else + { + /* Error occurred while writing data in Flash memory */ + return (FLASHIF_WRITING_ERROR); + } + } + + /* Lock the Flash to disable the flash control register access (recommended + to protect the FLASH memory against possible unwanted operation) *********/ + HAL_FLASH_Lock(); + + return (FLASHIF_OK); +} + +/** + * @brief Returns the write protection status of application flash area. + * @param None + * @retval If a sector in application area is write-protected returned value is a combinaison + of the possible values : FLASHIF_PROTECTION_WRPENABLED, FLASHIF_PROTECTION_PCROPENABLED, ... + * If no sector is write-protected FLASHIF_PROTECTION_NONE is returned. + */ +uint32_t FLASH_If_GetWriteProtectionStatus(void) +{ + uint32_t ProtectedPAGE = FLASHIF_PROTECTION_NONE; + FLASH_OBProgramInitTypeDef OptionsBytesStruct; + + /* Unlock the Flash to enable the flash control register access *************/ + HAL_FLASH_Unlock(); + + /* Check if there are write protected sectors inside the user flash area ****/ + HAL_FLASHEx_OBGetConfig(&OptionsBytesStruct); + + /* Lock the Flash to disable the flash control register access (recommended + to protect the FLASH memory against possible unwanted operation) *********/ + HAL_FLASH_Lock(); + + /* Get pages already write protected ****************************************/ + ProtectedPAGE = ~(OptionsBytesStruct.WRPPage) & FLASH_PAGE_TO_BE_PROTECTED; + + /* Check if desired pages are already write protected ***********************/ + if(ProtectedPAGE != 0) + { + /* Some sectors inside the user flash area are write protected */ + return FLASHIF_PROTECTION_WRPENABLED; + } + else + { + /* No write protected sectors inside the user flash area */ + return FLASHIF_PROTECTION_NONE; + } +} + +/** + * @brief Configure the write protection status of user flash area. + * @param protectionstate : FLASHIF_WRP_DISABLE or FLASHIF_WRP_ENABLE the protection + * @retval uint32_t FLASHIF_OK if change is applied. + */ +uint32_t FLASH_If_WriteProtectionConfig(uint32_t protectionstate) +{ + uint32_t ProtectedPAGE = 0x0; + FLASH_OBProgramInitTypeDef config_new, config_old; + HAL_StatusTypeDef result = HAL_OK; + + + /* Get pages write protection status ****************************************/ + HAL_FLASHEx_OBGetConfig(&config_old); + + /* The parameter says whether we turn the protection on or off */ + config_new.WRPState = (protectionstate == FLASHIF_WRP_ENABLE ? OB_WRPSTATE_ENABLE : OB_WRPSTATE_DISABLE); + + /* We want to modify only the Write protection */ + config_new.OptionType = OPTIONBYTE_WRP; + + /* No read protection, keep BOR and reset settings */ + config_new.RDPLevel = OB_RDP_LEVEL_0; + config_new.USERConfig = config_old.USERConfig; + /* Get pages already write protected ****************************************/ + ProtectedPAGE = config_old.WRPPage | FLASH_PAGE_TO_BE_PROTECTED; + + /* Unlock the Flash to enable the flash control register access *************/ + HAL_FLASH_Unlock(); + + /* Unlock the Options Bytes *************************************************/ + HAL_FLASH_OB_Unlock(); + + /* Erase all the option Bytes ***********************************************/ + result = HAL_FLASHEx_OBErase(); + + if (result == HAL_OK) + { + config_new.WRPPage = ProtectedPAGE; + result = HAL_FLASHEx_OBProgram(&config_new); + } + + return (result == HAL_OK ? FLASHIF_OK: FLASHIF_PROTECTION_ERRROR); +} +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/flash_if.h b/examples/stm32cube-hal-iap/src/flash_if.h new file mode 100644 index 00000000..cd5a3b60 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/flash_if.h @@ -0,0 +1,87 @@ +/** + ****************************************************************************** + * @file IAP_Main/Inc/flash_if.h + * @author MCD Application Team + * @brief This file provides all the headers of the flash_if functions. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __FLASH_IF_H +#define __FLASH_IF_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f3xx_hal.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + + +/* Error code */ +enum +{ + FLASHIF_OK = 0, + FLASHIF_ERASEKO, + FLASHIF_WRITINGCTRL_ERROR, + FLASHIF_WRITING_ERROR, + FLASHIF_PROTECTION_ERRROR +}; + +/* protection type */ +enum{ + FLASHIF_PROTECTION_NONE = 0, + FLASHIF_PROTECTION_PCROPENABLED = 0x1, + FLASHIF_PROTECTION_WRPENABLED = 0x2, + FLASHIF_PROTECTION_RDPENABLED = 0x4, +}; + +/* protection update */ +enum { + FLASHIF_WRP_ENABLE, + FLASHIF_WRP_DISABLE +}; + +/* Define the address from where user application will be loaded. + Note: this area is reserved for the IAP code */ +#define FLASH_PAGE_STEP FLASH_PAGE_SIZE /* Size of page : 2 Kbytes */ +#define APPLICATION_ADDRESS (uint32_t)0x08004000 /* Start user code address: ADDR_FLASH_PAGE_8 */ + +/* Notable Flash addresses */ +#define FLASH_START ((uint32_t)0x08000000) +#define USER_FLASH_END_ADDRESS 0x08040000 + +/* Define the user application size */ +#define USER_FLASH_SIZE ((uint32_t)0x00003000) /* Small default template application */ + +/* Define bitmap representing user flash area that could be write protected (check restricted to pages 8-39). */ +#define FLASH_PAGE_TO_BE_PROTECTED (OB_WRP_PAGES8TO9 | OB_WRP_PAGES10TO11 | OB_WRP_PAGES12TO13 | OB_WRP_PAGES14TO15 | \ + OB_WRP_PAGES16TO17 | OB_WRP_PAGES18TO19 | OB_WRP_PAGES20TO21 | OB_WRP_PAGES22TO23 | \ + OB_WRP_PAGES24TO25 | OB_WRP_PAGES26TO27 | OB_WRP_PAGES28TO29 | OB_WRP_PAGES30TO31 | \ + OB_WRP_PAGES32TO33 | OB_WRP_PAGES34TO35 | OB_WRP_PAGES36TO37 | OB_WRP_PAGES38TO39 ) + + +/* Exported macro ------------------------------------------------------------*/ +/* ABSoulute value */ +#define ABS_RETURN(x,y) (((x) < (y)) ? (y) : (x)) + +/* Exported functions ------------------------------------------------------- */ +void FLASH_If_Init(void); +uint32_t FLASH_If_Erase(uint32_t StartSector); +uint32_t FLASH_If_GetWriteProtectionStatus(void); +uint32_t FLASH_If_Write(uint32_t destination, uint32_t *p_source, uint32_t length); +uint32_t FLASH_If_WriteProtectionConfig(uint32_t protectionstate); + +#endif /* __FLASH_IF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/main.c b/examples/stm32cube-hal-iap/src/main.c new file mode 100644 index 00000000..c53bedc3 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/main.c @@ -0,0 +1,195 @@ +/** + ****************************************************************************** + * @file IAP_Main/Src/main.c + * @author MCD Application Team + * @brief Main program body + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "menu.h" + +/** @addtogroup STM32F3xx_IAP_Main + * @{ + */ + +/* Exported variables --------------------------------------------------------*/ +/* UART handler declaration */ +UART_HandleTypeDef UartHandle; + + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +extern pFunction JumpToApplication; +extern uint32_t JumpAddress; + +/* Private function prototypes -----------------------------------------------*/ +static void IAP_Init(void); +void SystemClock_Config(void); + +/** + * @brief Main program + * @param None + * @retval None + */ +int main(void) +{ + /* STM32F3xx HAL library initialization: + - Configure the Flash prefetch + - Systick timer is configured by default as source of time base, but user + can eventually implement his proper time base source (a general purpose + timer for example or other time source), keeping in mind that Time base + duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and + handled in milliseconds basis. + - Set NVIC Group Priority to 4 + - Low Level Initialization + */ + HAL_Init(); + + /* Configure the system clock to 72 MHz */ + SystemClock_Config(); + + /* Initialize Key push-button mounted on STM32373C-EVAL RevB board */ + BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO); + + /* Test if Key push-button on STM32373C-EVAL RevB Board is pressed */ + if (BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET) + { + /* Initialise Flash */ + FLASH_If_Init(); + /* Execute the IAP driver in order to reprogram the Flash */ + IAP_Init(); + /* Display main menu */ + Main_Menu (); + } + /* Keep the user application running */ + else + { + /* Test if user code is programmed starting from address "APPLICATION_ADDRESS" */ + if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000) + { + /* Jump to user application */ + JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4); + JumpToApplication = (pFunction) JumpAddress; + /* Initialize user application's Stack Pointer */ + __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS); + JumpToApplication(); + } + } + + while (1) + {} +} + +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 72000000 + * HCLK(Hz) = 72000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 2 + * APB2 Prescaler = 1 + * HSE Frequency(Hz) = 8000000 + * HSE PREDIV = 1 + * PLLMUL = RCC_PLL_MUL9 (9) + * Flash Latency(WS) = 2 + * @param None + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct)!= HAL_OK) + { + /* Initialization Error */ + while(1); + } + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2)!= HAL_OK) + { + /* Initialization Error */ + while(1); + } +} +/** + * @brief Initialize the IAP: Configure USART. + * @param None + * @retval None + */ +void IAP_Init(void) +{ + /* USART resources configuration (Clock, GPIO pins and USART registers) ----*/ + /* USART configured as follow: + - BaudRate = 115200 baud + - Word Length = 8 Bits + - One Stop Bit + - No parity + - Hardware flow control disabled (RTS and CTS signals) + - Receive and transmit enabled + */ + UartHandle.Init.BaudRate = 115200; + UartHandle.Init.WordLength = UART_WORDLENGTH_8B; + UartHandle.Init.StopBits = UART_STOPBITS_1; + UartHandle.Init.Parity = UART_PARITY_NONE; + UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; + UartHandle.Init.Mode = UART_MODE_RX | UART_MODE_TX; + + BSP_COM_Init(COM1, &UartHandle); + +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + + /* Infinite loop */ + while (1) + {} +} +#endif + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/main.h b/examples/stm32cube-hal-iap/src/main.h new file mode 100644 index 00000000..091c7554 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/main.h @@ -0,0 +1,38 @@ +/** + ****************************************************************************** + * @file IAP_Main/Inc/main.h + * @author MCD Application Team + * @brief Header for main.c module + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f3xx_hal.h" +#include "stm32373c_eval.h" + +/* Exported variables --------------------------------------------------------*/ +extern UART_HandleTypeDef UartHandle; + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/menu.c b/examples/stm32cube-hal-iap/src/menu.c new file mode 100644 index 00000000..461516ec --- /dev/null +++ b/examples/stm32cube-hal-iap/src/menu.c @@ -0,0 +1,229 @@ +/** + ****************************************************************************** + * @file IAP_Main/Src/menu.c + * @author MCD Application Team + * @brief This file provides the software which contains the main menu routine. + * The main menu gives the options of: + * - downloading a new binary file, + * - uploading internal flash memory, + * - executing the binary file already loaded + * - configuring the write protection of the Flash sectors where the + * user loads his binary file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/** @addtogroup STM32F3xx_IAP + * @{ + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "common.h" +#include "flash_if.h" +#include "menu.h" +#include "ymodem.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +pFunction JumpToApplication; +uint32_t JumpAddress; +uint32_t FlashProtection = 0; +uint8_t aFileName[FILE_NAME_LENGTH]; + +/* Private function prototypes -----------------------------------------------*/ +void SerialDownload(void); +void SerialUpload(void); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Download a file via serial port + * @param None + * @retval None + */ +void SerialDownload(void) +{ + uint8_t number[11] = {0}; + uint32_t size = 0; + COM_StatusTypeDef result; + + Serial_PutString((uint8_t *)"Waiting for the file to be sent ... (press 'a' to abort)\n\r"); + result = Ymodem_Receive( &size ); + if (result == COM_OK) + { + Serial_PutString((uint8_t *)"\n\n\r Programming Completed Successfully!\n\r--------------------------------\r\n Name: "); + Serial_PutString(aFileName); + Int2Str(number, size); + Serial_PutString((uint8_t *)"\n\r Size: "); + Serial_PutString(number); + Serial_PutString((uint8_t *)" Bytes\r\n"); + Serial_PutString((uint8_t *)"-------------------\n"); + } + else if (result == COM_LIMIT) + { + Serial_PutString((uint8_t *)"\n\n\rThe image size is higher than the allowed space memory!\n\r"); + } + else if (result == COM_DATA) + { + Serial_PutString((uint8_t *)"\n\n\rVerification failed!\n\r"); + } + else if (result == COM_ABORT) + { + Serial_PutString((uint8_t *)"\r\n\nAborted by user.\n\r"); + } + else + { + Serial_PutString((uint8_t *)"\n\rFailed to receive the file!\n\r"); + } +} + +/** + * @brief Upload a file via serial port. + * @param None + * @retval None + */ +void SerialUpload(void) +{ + uint8_t status = 0; + + Serial_PutString((uint8_t *)"\n\n\rSelect Receive File\n\r"); + + HAL_UART_Receive(&UartHandle, &status, 1, RX_TIMEOUT); + if ( status == CRC16) + { + /* Transmit the flash image through ymodem protocol */ + status = Ymodem_Transmit((uint8_t*)APPLICATION_ADDRESS, (const uint8_t*)"UploadedFlashImage.bin", USER_FLASH_SIZE); + + if (status != 0) + { + Serial_PutString((uint8_t *)"\n\rError Occurred while Transmitting File\n\r"); + } + else + { + Serial_PutString((uint8_t *)"\n\rFile uploaded successfully \n\r"); + } + } +} + +/** + * @brief Display the Main Menu on HyperTerminal + * @param None + * @retval None + */ +void Main_Menu(void) +{ + uint8_t key = 0; + + Serial_PutString((uint8_t *)"\r\n======================================================================"); + Serial_PutString((uint8_t *)"\r\n= (C) COPYRIGHT 2016 STMicroelectronics ="); + Serial_PutString((uint8_t *)"\r\n= ="); + Serial_PutString((uint8_t *)"\r\n= STM32F3xx In-Application Programming Application (Version 1.0.0) ="); + Serial_PutString((uint8_t *)"\r\n= ="); + Serial_PutString((uint8_t *)"\r\n= By MCD Application Team ="); + Serial_PutString((uint8_t *)"\r\n======================================================================"); + Serial_PutString((uint8_t *)"\r\n\r\n"); + + /* Test if any sector of Flash memory where user application will be loaded is write protected */ + FlashProtection = FLASH_If_GetWriteProtectionStatus(); + + while (1) + { + + Serial_PutString((uint8_t *)"\r\n=================== Main Menu ============================\r\n\n"); + Serial_PutString((uint8_t *)" Download image to the internal Flash ----------------- 1\r\n\n"); + Serial_PutString((uint8_t *)" Upload image from the internal Flash ----------------- 2\r\n\n"); + Serial_PutString((uint8_t *)" Execute the loaded application ----------------------- 3\r\n\n"); + + + if(FlashProtection != FLASHIF_PROTECTION_NONE) + { + Serial_PutString((uint8_t *)" Disable the write protection ------------------------- 4\r\n\n"); + } + else + { + Serial_PutString((uint8_t *)" Enable the write protection -------------------------- 4\r\n\n"); + } + Serial_PutString((uint8_t *)"==========================================================\r\n\n"); + + /* Clean the input path */ + __HAL_UART_FLUSH_DRREGISTER(&UartHandle); + + /* Receive key */ + HAL_UART_Receive(&UartHandle, &key, 1, RX_TIMEOUT); + + switch (key) + { + case '1' : + /* Download user application in the Flash */ + SerialDownload(); + break; + case '2' : + /* Upload user application from the Flash */ + SerialUpload(); + break; + case '3' : + Serial_PutString((uint8_t *)"Start program execution......\r\n\n"); + /* execute the new program */ + JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4); + /* Jump to user application */ + JumpToApplication = (pFunction) JumpAddress; + /* Initialize user application's Stack Pointer */ + __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS); + JumpToApplication(); + break; + case '4' : + if (FlashProtection != FLASHIF_PROTECTION_NONE) + { + /* Disable the write protection */ + if (FLASH_If_WriteProtectionConfig(FLASHIF_WRP_DISABLE) == FLASHIF_OK) + { + Serial_PutString((uint8_t *)"Write Protection disabled...\r\n"); + Serial_PutString((uint8_t *)"System will now restart...\r\n"); + /* Launch the option byte loading */ + HAL_FLASH_OB_Launch(); + } + else + { + Serial_PutString((uint8_t *)"Error: Flash write un-protection failed...\r\n"); + } + } + else + { + if (FLASH_If_WriteProtectionConfig(FLASHIF_WRP_ENABLE) == FLASHIF_OK) + { + Serial_PutString((uint8_t *)"Write Protection enabled...\r\n"); + Serial_PutString((uint8_t *)"System will now restart...\r\n"); + /* Launch the option byte loading */ + HAL_FLASH_OB_Launch(); + } + else + { + Serial_PutString((uint8_t *)"Error: Flash write protection failed...\r\n"); + } + } + break; + default: + Serial_PutString((uint8_t *)"Invalid Number ! ==> The number should be either 1, 2, 3 or 4\r"); + break; + } + } +} + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/menu.h b/examples/stm32cube-hal-iap/src/menu.h new file mode 100644 index 00000000..2672de60 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/menu.h @@ -0,0 +1,42 @@ +/** + ****************************************************************************** + * @file IAP_Main/Inc/menu.h + * @author MCD Application Team + * @brief This file provides all the headers of the menu functions. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MENU_H +#define __MENU_H + +/* Includes ------------------------------------------------------------------*/ +#include "flash_if.h" +#include "ymodem.h" + +/* Imported variables --------------------------------------------------------*/ +extern uint8_t aFileName[FILE_NAME_LENGTH]; + +/* Private variables ---------------------------------------------------------*/ +typedef void (*pFunction)(void); + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +void Main_Menu(void); + +#endif /* __MENU_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/stm32f3xx_hal_conf.h b/examples/stm32cube-hal-iap/src/stm32f3xx_hal_conf.h new file mode 100644 index 00000000..0a9d1659 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/stm32f3xx_hal_conf.h @@ -0,0 +1,357 @@ +/** + ****************************************************************************** + * @file stm32f3xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F3xx_HAL_CONF_H +#define __STM32F3xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +/* #define HAL_ADC_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_COMP_MODULE_ENABLED */ +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +/* #define HAL_DAC_MODULE_ENABLED */ +#define HAL_DMA_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +/* #define HAL_HRTIM_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_OPAMP_MODULE_ENABLED */ +/* #define HAL_PCD_MODULE_ENABLED */ +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SDADC_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_SPI_MODULE_ENABLED */ +/* #define HAL_TIM_MODULE_ENABLED */ +/* #define HAL_TSC_MODULE_ENABLED */ +#define HAL_UART_MODULE_ENABLED +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +/** + * @brief In the following line adjust the External High Speed oscillator (HSE) Startup + * Timeout value + */ +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE (8000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief In the following line adjust the Internal High Speed oscillator (HSI) Startup + * Timeout value + */ +#if !defined (HSI_STARTUP_TIMEOUT) + #define HSI_STARTUP_TIMEOUT (5000U) /*!< Time out for HSI start up */ +#endif /* HSI_STARTUP_TIMEOUT */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE (40000U) +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +/** + * @brief Time out for LSE start up value in ms. + */ +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + * - External clock generated through external PLL component on EVAL 303 (based on MCO or crystal) + * - External clock not generated on EVAL 373 + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE (8000000U) /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE (3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)(1U<<__NVIC_PRIO_BITS) - 1U) /*!< tick interrupt priority (lowest by default) */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 0U +#define DATA_CACHE_ENABLE 0U +#define USE_SPI_CRC 1U + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SDADC_REGISTER_CALLBACKS 0U /* SDADC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* OPAMP register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_TSC_REGISTER_CALLBACKS 0U /* TSC register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/*#define USE_FULL_ASSERT 1*/ + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f3xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f3xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f3xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f3xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f3xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f3xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f3xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f3xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f3xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32f3xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f3xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f3xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f3xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f3xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f3xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f3xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f3xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_HRTIM_MODULE_ENABLED + #include "stm32f3xx_hal_hrtim.h" +#endif /* HAL_HRTIM_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f3xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f3xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f3xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f3xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED + #include "stm32f3xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f3xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f3xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f3xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SDADC_MODULE_ENABLED + #include "stm32f3xx_hal_sdadc.h" +#endif /* HAL_SDADC_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f3xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32f3xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f3xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f3xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_TSC_MODULE_ENABLED + #include "stm32f3xx_hal_tsc.h" +#endif /* HAL_TSC_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f3xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f3xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f3xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F3xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/stm32f3xx_it.c b/examples/stm32cube-hal-iap/src/stm32f3xx_it.c new file mode 100644 index 00000000..ed4457d7 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/stm32f3xx_it.c @@ -0,0 +1,151 @@ +/** + ****************************************************************************** + * @file IAP_Main/Src/stm32f3xx_it.c + * @author MCD Application Team + * @brief Main Interrupt Service Routines. + * This file provides template for all exceptions handler and + * peripherals interrupt service routine. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32f3xx_it.h" + +/** @addtogroup STM32F3xx_IAP_Main + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/******************************************************************************/ +/* Cortex-M4 Processor Exceptions Handlers */ +/******************************************************************************/ + +/** + * @brief This function handles NMI exception. + * @param None + * @retval None + */ +void NMI_Handler(void) +{ +} + +/** + * @brief This function handles Hard Fault exception. + * @param None + * @retval None + */ +void HardFault_Handler(void) +{ + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Memory Manage exception. + * @param None + * @retval None + */ +void MemManage_Handler(void) +{ + /* Go to infinite loop when Memory Manage exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Bus Fault exception. + * @param None + * @retval None + */ +void BusFault_Handler(void) +{ + /* Go to infinite loop when Bus Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Usage Fault exception. + * @param None + * @retval None + */ +void UsageFault_Handler(void) +{ + /* Go to infinite loop when Usage Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles SVCall exception. + * @param None + * @retval None + */ +void SVC_Handler(void) +{ +} + +/** + * @brief This function handles Debug Monitor exception. + * @param None + * @retval None + */ +void DebugMon_Handler(void) +{ +} + +/** + * @brief This function handles PendSVC exception. + * @param None + * @retval None + */ +void PendSV_Handler(void) +{ +} + +/** + * @brief This function handles SysTick Handler. + * @param None + * @retval None + */ +void SysTick_Handler(void) +{ + HAL_IncTick(); +} + +/******************************************************************************/ +/* STM32F3xx Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file (startup_stm32f3xx.s). */ +/******************************************************************************/ + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/stm32f3xx_it.h b/examples/stm32cube-hal-iap/src/stm32f3xx_it.h new file mode 100644 index 00000000..4b07cb8e --- /dev/null +++ b/examples/stm32cube-hal-iap/src/stm32f3xx_it.h @@ -0,0 +1,50 @@ +/** + ****************************************************************************** + * @file IAP_Main/Inc/stm32f3xx_it.h + * @author MCD Application Team + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F3xx_IT_H +#define __STM32F3xx_IT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F3xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/system_stm32f3xx.c b/examples/stm32cube-hal-iap/src/system_stm32f3xx.c new file mode 100644 index 00000000..558f3830 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/system_stm32f3xx.c @@ -0,0 +1,298 @@ +/** + ****************************************************************************** + * @file system_stm32f3xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. + * + * 1. This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32f3xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * 2. After each device reset the HSI (8 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32f3xx.s" file, to + * configure the system clock before to branch to main program. + * + * 3. This file configures the system clock as follows: + *============================================================================= + * Supported STM32F3xx device + *----------------------------------------------------------------------------- + * System Clock source | HSI + *----------------------------------------------------------------------------- + * SYSCLK(Hz) | 8000000 + *----------------------------------------------------------------------------- + * HCLK(Hz) | 8000000 + *----------------------------------------------------------------------------- + * AHB Prescaler | 1 + *----------------------------------------------------------------------------- + * APB2 Prescaler | 1 + *----------------------------------------------------------------------------- + * APB1 Prescaler | 1 + *----------------------------------------------------------------------------- + * USB Clock | DISABLE + *----------------------------------------------------------------------------- + *============================================================================= + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f3xx_system + * @{ + */ + +/** @addtogroup STM32F3xx_System_Private_Includes + * @{ + */ + +#include "stm32f3xx.h" + +/** + * @} + */ + +/** @addtogroup STM32F3xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F3xx_System_Private_Defines + * @{ + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. + This value can be provided and adapted by the user application. */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. + This value can be provided and adapted by the user application. */ +#endif /* HSI_VALUE */ + +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/** + * @} + */ + +/** @addtogroup STM32F3xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F3xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock there is no need to + call the 2 first functions listed above, since SystemCoreClock variable is + updated automatically. + */ +uint32_t SystemCoreClock = 8000000; + +const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; +const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; + +/** + * @} + */ + +/** @addtogroup STM32F3xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F3xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the FPU setting, vector table location and the PLL configuration is reset. + * @param None + * @retval None + */ +void SystemInit(void) +{ + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ + #endif + + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set HSION bit */ + RCC->CR |= 0x00000001U; + + /* Reset CFGR register */ + RCC->CFGR &= 0xF87FC00CU; + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= 0xFEF6FFFFU; + + /* Reset HSEBYP bit */ + RCC->CR &= 0xFFFBFFFFU; + + /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE bits */ + RCC->CFGR &= 0xFF80FFFFU; + + /* Reset PREDIV1[3:0] bits */ + RCC->CFGR2 &= 0xFFFFFFF0U; + + /* Reset USARTSW[1:0], I2CSW and TIMs bits */ + RCC->CFGR3 &= 0xFF00FCCCU; + + /* Disable all interrupts */ + RCC->CIR = 0x00000000U; + +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (*) HSI_VALUE is a constant defined in stm32f3xx_hal.h file (default value + * 8 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSE_VALUE is a constant defined in stm32f3xx_hal.h file (default value + * 8 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate (void) +{ + uint32_t tmp = 0, pllmull = 0, pllsource = 0, predivfactor = 0; + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & RCC_CFGR_SWS; + + switch (tmp) + { + case RCC_CFGR_SWS_HSI: /* HSI used as system clock */ + SystemCoreClock = HSI_VALUE; + break; + case RCC_CFGR_SWS_HSE: /* HSE used as system clock */ + SystemCoreClock = HSE_VALUE; + break; + case RCC_CFGR_SWS_PLL: /* PLL used as system clock */ + /* Get PLL clock source and multiplication factor ----------------------*/ + pllmull = RCC->CFGR & RCC_CFGR_PLLMUL; + pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; + pllmull = ( pllmull >> 18) + 2; + +#if defined (STM32F302xE) || defined (STM32F303xE) || defined (STM32F398xx) + predivfactor = (RCC->CFGR2 & RCC_CFGR2_PREDIV) + 1; + if (pllsource == RCC_CFGR_PLLSRC_HSE_PREDIV) + { + /* HSE oscillator clock selected as PREDIV1 clock entry */ + SystemCoreClock = (HSE_VALUE / predivfactor) * pllmull; + } + else + { + /* HSI oscillator clock selected as PREDIV1 clock entry */ + SystemCoreClock = (HSI_VALUE / predivfactor) * pllmull; + } +#else + if (pllsource == RCC_CFGR_PLLSRC_HSI_DIV2) + { + /* HSI oscillator clock divided by 2 selected as PLL clock entry */ + SystemCoreClock = (HSI_VALUE >> 1) * pllmull; + } + else + { + predivfactor = (RCC->CFGR2 & RCC_CFGR2_PREDIV) + 1; + /* HSE oscillator clock selected as PREDIV1 clock entry */ + SystemCoreClock = (HSE_VALUE / predivfactor) * pllmull; + } +#endif /* STM32F302xE || STM32F303xE || STM32F398xx */ + break; + default: /* HSI used as system clock */ + SystemCoreClock = HSI_VALUE; + break; + } + /* Compute HCLK clock frequency ----------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK clock frequency */ + SystemCoreClock >>= tmp; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/examples/stm32cube-hal-iap/src/ymodem.c b/examples/stm32cube-hal-iap/src/ymodem.c new file mode 100644 index 00000000..413c2de4 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/ymodem.c @@ -0,0 +1,652 @@ +/** + ****************************************************************************** + * @file IAP_Main/Src/ymodem.c + * @author MCD Application Team + * @brief This file provides all the software functions related to the ymodem + * protocol. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/** @addtogroup STM32F3xx_IAP + * @{ + */ + +/* Includes ------------------------------------------------------------------*/ +#include "flash_if.h" +#include "common.h" +#include "ymodem.h" +#include "string.h" +#include "main.h" +#include "menu.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +#define CRC16_F /* activate the CRC16 integrity */ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* @note ATTENTION - please keep this variable 32bit alligned */ +uint8_t aPacketData[PACKET_1K_SIZE + PACKET_DATA_INDEX + PACKET_TRAILER_SIZE]; + +/* Private function prototypes -----------------------------------------------*/ +static void PrepareIntialPacket(uint8_t *p_data, const uint8_t *p_file_name, uint32_t length); +static void PreparePacket(uint8_t *p_source, uint8_t *p_packet, uint8_t pkt_nr, uint32_t size_blk); +static HAL_StatusTypeDef ReceivePacket(uint8_t *p_data, uint32_t *p_length, uint32_t timeout); +uint16_t UpdateCRC16(uint16_t crc_in, uint8_t byte); +uint16_t Cal_CRC16(const uint8_t* p_data, uint32_t size); +uint8_t CalcChecksum(const uint8_t *p_data, uint32_t size); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Receive a packet from sender + * @param data + * @param length + * 0: end of transmission + * 2: abort by sender + * >0: packet length + * @param timeout + * @retval HAL_OK: normally return + * HAL_BUSY: abort by user + */ +static HAL_StatusTypeDef ReceivePacket(uint8_t *p_data, uint32_t *p_length, uint32_t timeout) +{ + uint32_t crc; + uint32_t packet_size = 0; + HAL_StatusTypeDef status; + uint8_t char1; + + *p_length = 0; + status = HAL_UART_Receive(&UartHandle, &char1, 1, timeout); + + if (status == HAL_OK) + { + switch (char1) + { + case SOH: + packet_size = PACKET_SIZE; + break; + case STX: + packet_size = PACKET_1K_SIZE; + break; + case EOT: + break; + case CA: + if ((HAL_UART_Receive(&UartHandle, &char1, 1, timeout) == HAL_OK) && (char1 == CA)) + { + packet_size = 2; + } + else + { + status = HAL_ERROR; + } + break; + case ABORT1: + case ABORT2: + status = HAL_BUSY; + break; + default: + status = HAL_ERROR; + break; + } + *p_data = char1; + + if (packet_size >= PACKET_SIZE ) + { + status = HAL_UART_Receive(&UartHandle, &p_data[PACKET_NUMBER_INDEX], packet_size + PACKET_OVERHEAD_SIZE, timeout); + + /* Simple packet sanity check */ + if (status == HAL_OK ) + { + if (p_data[PACKET_NUMBER_INDEX] != ((p_data[PACKET_CNUMBER_INDEX]) ^ NEGATIVE_BYTE)) + { + packet_size = 0; + status = HAL_ERROR; + } + else + { + /* Check packet CRC */ + crc = p_data[ packet_size + PACKET_DATA_INDEX ] << 8; + crc += p_data[ packet_size + PACKET_DATA_INDEX + 1 ]; + if (Cal_CRC16(&p_data[PACKET_DATA_INDEX], packet_size) != crc ) + { + packet_size = 0; + status = HAL_ERROR; + } + } + } + else + { + packet_size = 0; + } + } + } + *p_length = packet_size; + return status; +} + +/** + * @brief Prepare the first block + * @param p_data: output buffer + * @param p_file_name: name of the file to be sent + * @param length: length of the file to be sent in bytes + * @retval None + */ +static void PrepareIntialPacket(uint8_t *p_data, const uint8_t *p_file_name, uint32_t length) +{ + uint32_t i, j = 0; + uint8_t astring[10]; + + /* first 3 bytes are constant */ + p_data[PACKET_START_INDEX] = SOH; + p_data[PACKET_NUMBER_INDEX] = 0x00; + p_data[PACKET_CNUMBER_INDEX] = 0xff; + + /* Filename written */ + for (i = 0; (p_file_name[i] != '\0') && (i < FILE_NAME_LENGTH); i++) + { + p_data[i + PACKET_DATA_INDEX] = p_file_name[i]; + } + + p_data[i + PACKET_DATA_INDEX] = 0x00; + + /* file size written */ + Int2Str (astring, length); + i = i + PACKET_DATA_INDEX + 1; + while (astring[j] != '\0') + { + p_data[i++] = astring[j++]; + } + + /* padding with zeros */ + for (j = i; j < PACKET_SIZE + PACKET_DATA_INDEX; j++) + { + p_data[j] = 0; + } +} + +/** + * @brief Prepare the data packet + * @param p_source: pointer to the data to be sent + * @param p_packet: pointer to the output buffer + * @param pkt_nr: number of the packet + * @param size_blk: length of the block to be sent in bytes + * @retval None + */ +static void PreparePacket(uint8_t *p_source, uint8_t *p_packet, uint8_t pkt_nr, uint32_t size_blk) +{ + uint8_t *p_record; + uint32_t i, size, packet_size; + + /* Make first three packet */ + packet_size = size_blk >= PACKET_1K_SIZE ? PACKET_1K_SIZE : PACKET_SIZE; + size = size_blk < packet_size ? size_blk : packet_size; + if (packet_size == PACKET_1K_SIZE) + { + p_packet[PACKET_START_INDEX] = STX; + } + else + { + p_packet[PACKET_START_INDEX] = SOH; + } + p_packet[PACKET_NUMBER_INDEX] = pkt_nr; + p_packet[PACKET_CNUMBER_INDEX] = (~pkt_nr); + p_record = p_source; + + /* Filename packet has valid data */ + for (i = PACKET_DATA_INDEX; i < size + PACKET_DATA_INDEX;i++) + { + p_packet[i] = *p_record++; + } + if ( size <= packet_size) + { + for (i = size + PACKET_DATA_INDEX; i < packet_size + PACKET_DATA_INDEX; i++) + { + p_packet[i] = 0x1A; /* EOF (0x1A) or 0x00 */ + } + } +} + +/** + * @brief Update CRC16 for input byte + * @param crc_in input value + * @param input byte + * @retval None + */ +uint16_t UpdateCRC16(uint16_t crc_in, uint8_t byte) +{ + uint32_t crc = crc_in; + uint32_t in = byte | 0x100; + + do + { + crc <<= 1; + in <<= 1; + if(in & 0x100) + ++crc; + if(crc & 0x10000) + crc ^= 0x1021; + } + + while(!(in & 0x10000)); + + return crc & 0xffffu; +} + +/** + * @brief Cal CRC16 for YModem Packet + * @param data + * @param length + * @retval None + */ +uint16_t Cal_CRC16(const uint8_t* p_data, uint32_t size) +{ + uint32_t crc = 0; + const uint8_t* dataEnd = p_data+size; + + while(p_data < dataEnd) + crc = UpdateCRC16(crc, *p_data++); + + crc = UpdateCRC16(crc, 0); + crc = UpdateCRC16(crc, 0); + + return crc&0xffffu; +} + +/** + * @brief Calculate Check sum for YModem Packet + * @param p_data Pointer to input data + * @param size length of input data + * @retval uint8_t checksum value + */ +uint8_t CalcChecksum(const uint8_t *p_data, uint32_t size) +{ + uint32_t sum = 0; + const uint8_t *p_data_end = p_data + size; + + while (p_data < p_data_end ) + { + sum += *p_data++; + } + + return (sum & 0xffu); +} + +/* Public functions ---------------------------------------------------------*/ +/** + * @brief Receive a file using the ymodem protocol with CRC16. + * @param p_size The size of the file. + * @retval COM_StatusTypeDef result of reception/programming + */ +COM_StatusTypeDef Ymodem_Receive ( uint32_t *p_size ) +{ + uint32_t i, packet_length, session_done = 0, file_done, errors = 0, session_begin = 0; + uint32_t flashdestination, ramsource, filesize; + uint8_t *file_ptr; + uint8_t file_size[FILE_SIZE_LENGTH], tmp, packets_received; + COM_StatusTypeDef result = COM_OK; + + /* Initialize flashdestination variable */ + flashdestination = APPLICATION_ADDRESS; + + while ((session_done == 0) && (result == COM_OK)) + { + packets_received = 0; + file_done = 0; + while ((file_done == 0) && (result == COM_OK)) + { + switch (ReceivePacket(aPacketData, &packet_length, DOWNLOAD_TIMEOUT)) + { + case HAL_OK: + errors = 0; + switch (packet_length) + { + case 2: + /* Abort by sender */ + Serial_PutByte(ACK); + result = COM_ABORT; + break; + case 0: + /* End of transmission */ + Serial_PutByte(ACK); + file_done = 1; + break; + default: + /* Normal packet */ + if (aPacketData[PACKET_NUMBER_INDEX] != packets_received) + { + Serial_PutByte(NAK); + } + else + { + if (packets_received == 0) + { + /* File name packet */ + if (aPacketData[PACKET_DATA_INDEX] != 0) + { + /* File name extraction */ + i = 0; + file_ptr = aPacketData + PACKET_DATA_INDEX; + while ( (*file_ptr != 0) && (i < FILE_NAME_LENGTH)) + { + aFileName[i++] = *file_ptr++; + } + + /* File size extraction */ + aFileName[i++] = '\0'; + i = 0; + file_ptr ++; + while ( (*file_ptr != ' ') && (i < FILE_SIZE_LENGTH)) + { + file_size[i++] = *file_ptr++; + } + file_size[i++] = '\0'; + Str2Int(file_size, &filesize); + + /* Test the size of the image to be sent */ + /* Image size is greater than Flash size */ + if (*p_size > (USER_FLASH_SIZE + 1)) + { + /* End session */ + tmp = CA; + HAL_UART_Transmit(&UartHandle, &tmp, 1, NAK_TIMEOUT); + HAL_UART_Transmit(&UartHandle, &tmp, 1, NAK_TIMEOUT); + result = COM_LIMIT; + } + /* erase user application area */ + FLASH_If_Erase(APPLICATION_ADDRESS); + *p_size = filesize; + + Serial_PutByte(ACK); + Serial_PutByte(CRC16); + } + /* File header packet is empty, end session */ + else + { + Serial_PutByte(ACK); + file_done = 1; + session_done = 1; + break; + } + } + else /* Data packet */ + { + ramsource = (uint32_t) & aPacketData[PACKET_DATA_INDEX]; + + /* Write received data in Flash */ + if (FLASH_If_Write(flashdestination, (uint32_t*) ramsource, packet_length/4) == FLASHIF_OK) + { + flashdestination += packet_length; + Serial_PutByte(ACK); + } + else /* An error occurred while writing to Flash memory */ + { + /* End session */ + Serial_PutByte(CA); + Serial_PutByte(CA); + result = COM_DATA; + } + } + packets_received ++; + session_begin = 1; + } + break; + } + break; + case HAL_BUSY: /* Abort actually */ + Serial_PutByte(CA); + Serial_PutByte(CA); + result = COM_ABORT; + break; + default: + if (session_begin > 0) + { + errors ++; + } + if (errors > MAX_ERRORS) + { + /* Abort communication */ + Serial_PutByte(CA); + Serial_PutByte(CA); + } + else + { + Serial_PutByte(CRC16); /* Ask for a packet */ + } + break; + } + } + } + return result; +} + +/** + * @brief Transmit a file using the ymodem protocol + * @param p_buf: Address of the first byte + * @param p_file_name: Name of the file sent + * @param file_size: Size of the transmission + * @retval COM_StatusTypeDef result of the communication + */ +COM_StatusTypeDef Ymodem_Transmit (uint8_t *p_buf, const uint8_t *p_file_name, uint32_t file_size) +{ + uint32_t errors = 0, ack_recpt = 0, size = 0, pkt_size; + uint8_t *p_buf_int; + COM_StatusTypeDef result = COM_OK; + uint32_t blk_number = 1; + uint8_t a_rx_ctrl[2]; + uint8_t i; +#ifdef CRC16_F + uint32_t temp_crc; +#else /* CRC16_F */ + uint8_t temp_chksum; +#endif /* CRC16_F */ + + /* Prepare first block - header */ + PrepareIntialPacket(aPacketData, p_file_name, file_size); + + while (( !ack_recpt ) && ( result == COM_OK )) + { + /* Send Packet */ + HAL_UART_Transmit(&UartHandle, &aPacketData[PACKET_START_INDEX], PACKET_SIZE + PACKET_HEADER_SIZE, NAK_TIMEOUT); + + /* Send CRC or Check Sum based on CRC16_F */ +#ifdef CRC16_F + temp_crc = Cal_CRC16(&aPacketData[PACKET_DATA_INDEX], PACKET_SIZE); + Serial_PutByte(temp_crc >> 8); + Serial_PutByte(temp_crc & 0xFF); +#else /* CRC16_F */ + temp_chksum = CalcChecksum (&aPacketData[PACKET_DATA_INDEX], PACKET_SIZE); + Serial_PutByte(temp_chksum); +#endif /* CRC16_F */ + + /* Wait for Ack and 'C' */ + if (HAL_UART_Receive(&UartHandle, &a_rx_ctrl[0], 1, NAK_TIMEOUT) == HAL_OK) + { + if (a_rx_ctrl[0] == ACK) + { + ack_recpt = 1; + } + else if (a_rx_ctrl[0] == CA) + { + if ((HAL_UART_Receive(&UartHandle, &a_rx_ctrl[0], 1, NAK_TIMEOUT) == HAL_OK) && (a_rx_ctrl[0] == CA)) + { + HAL_Delay( 2 ); + __HAL_UART_FLUSH_DRREGISTER(&UartHandle); + result = COM_ABORT; + } + } + } + else + { + errors++; + } + if (errors >= MAX_ERRORS) + { + result = COM_ERROR; + } + } + + p_buf_int = p_buf; + size = file_size; + + /* Here 1024 bytes length is used to send the packets */ + while ((size) && (result == COM_OK )) + { + /* Prepare next packet */ + PreparePacket(p_buf_int, aPacketData, blk_number, size); + ack_recpt = 0; + a_rx_ctrl[0] = 0; + errors = 0; + + /* Resend packet if NAK for few times else end of communication */ + while (( !ack_recpt ) && ( result == COM_OK )) + { + /* Send next packet */ + if (size >= PACKET_1K_SIZE) + { + pkt_size = PACKET_1K_SIZE; + } + else + { + pkt_size = PACKET_SIZE; + } + + HAL_UART_Transmit(&UartHandle, &aPacketData[PACKET_START_INDEX], pkt_size + PACKET_HEADER_SIZE, NAK_TIMEOUT); + + /* Send CRC or Check Sum based on CRC16_F */ +#ifdef CRC16_F + temp_crc = Cal_CRC16(&aPacketData[PACKET_DATA_INDEX], pkt_size); + Serial_PutByte(temp_crc >> 8); + Serial_PutByte(temp_crc & 0xFF); +#else /* CRC16_F */ + temp_chksum = CalcChecksum (&aPacketData[PACKET_DATA_INDEX], pkt_size); + Serial_PutByte(temp_chksum); +#endif /* CRC16_F */ + + /* Wait for Ack */ + if ((HAL_UART_Receive(&UartHandle, &a_rx_ctrl[0], 1, NAK_TIMEOUT) == HAL_OK) && (a_rx_ctrl[0] == ACK)) + { + ack_recpt = 1; + if (size > pkt_size) + { + p_buf_int += pkt_size; + size -= pkt_size; + if (blk_number == (USER_FLASH_SIZE / PACKET_1K_SIZE)) + { + result = COM_LIMIT; /* boundary error */ + } + else + { + blk_number++; + } + } + else + { + p_buf_int += pkt_size; + size = 0; + } + } + else + { + errors++; + } + + /* Resend packet if NAK for a count of 10 else end of communication */ + if (errors >= MAX_ERRORS) + { + result = COM_ERROR; + } + } + } + + /* Sending End Of Transmission char */ + ack_recpt = 0; + a_rx_ctrl[0] = 0x00; + errors = 0; + while (( !ack_recpt ) && ( result == COM_OK )) + { + Serial_PutByte(EOT); + + /* Wait for Ack */ + if (HAL_UART_Receive(&UartHandle, &a_rx_ctrl[0], 1, NAK_TIMEOUT) == HAL_OK) + { + if (a_rx_ctrl[0] == ACK) + { + ack_recpt = 1; + } + else if (a_rx_ctrl[0] == CA) + { + if ((HAL_UART_Receive(&UartHandle, &a_rx_ctrl[0], 1, NAK_TIMEOUT) == HAL_OK) && (a_rx_ctrl[0] == CA)) + { + HAL_Delay( 2 ); + __HAL_UART_FLUSH_DRREGISTER(&UartHandle); + result = COM_ABORT; + } + } + } + else + { + errors++; + } + + if (errors >= MAX_ERRORS) + { + result = COM_ERROR; + } + } + + /* Empty packet sent - some terminal emulators need this to close session */ + if ( result == COM_OK ) + { + /* Preparing an empty packet */ + aPacketData[PACKET_START_INDEX] = SOH; + aPacketData[PACKET_NUMBER_INDEX] = 0; + aPacketData[PACKET_CNUMBER_INDEX] = 0xFF; + for (i = PACKET_DATA_INDEX; i < (PACKET_SIZE + PACKET_DATA_INDEX); i++) + { + aPacketData [i] = 0x00; + } + + /* Send Packet */ + HAL_UART_Transmit(&UartHandle, &aPacketData[PACKET_START_INDEX], PACKET_SIZE + PACKET_HEADER_SIZE, NAK_TIMEOUT); + + /* Send CRC or Check Sum based on CRC16_F */ +#ifdef CRC16_F + temp_crc = Cal_CRC16(&aPacketData[PACKET_DATA_INDEX], PACKET_SIZE); + Serial_PutByte(temp_crc >> 8); + Serial_PutByte(temp_crc & 0xFF); +#else /* CRC16_F */ + temp_chksum = CalcChecksum (&aPacketData[PACKET_DATA_INDEX], PACKET_SIZE); + Serial_PutByte(temp_chksum); +#endif /* CRC16_F */ + + /* Wait for Ack and 'C' */ + if (HAL_UART_Receive(&UartHandle, &a_rx_ctrl[0], 1, NAK_TIMEOUT) == HAL_OK) + { + if (a_rx_ctrl[0] == CA) + { + HAL_Delay( 2 ); + __HAL_UART_FLUSH_DRREGISTER(&UartHandle); + result = COM_ABORT; + } + } + } + + return result; /* file transmitted successfully */ +} + +/** + * @} + */ + +/*******************(C)COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-iap/src/ymodem.h b/examples/stm32cube-hal-iap/src/ymodem.h new file mode 100644 index 00000000..3d8a9906 --- /dev/null +++ b/examples/stm32cube-hal-iap/src/ymodem.h @@ -0,0 +1,88 @@ +/** + ****************************************************************************** + * @file IAP_Main/Inc/ymodem.h + * @author MCD Application Team + * @brief This file provides all the software function headers of the ymodem.c + * file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2016 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __YMODEM_H_ +#define __YMODEM_H_ + +/* Includes ------------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ + +/** + * @brief Comm status structures definition + */ +typedef enum +{ + COM_OK = 0x00, + COM_ERROR = 0x01, + COM_ABORT = 0x02, + COM_TIMEOUT = 0x03, + COM_DATA = 0x04, + COM_LIMIT = 0x05 +} COM_StatusTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------*/ +/* Packet structure defines */ +#define PACKET_HEADER_SIZE ((uint32_t)3) +#define PACKET_DATA_INDEX ((uint32_t)4) +#define PACKET_START_INDEX ((uint32_t)1) +#define PACKET_NUMBER_INDEX ((uint32_t)2) +#define PACKET_CNUMBER_INDEX ((uint32_t)3) +#define PACKET_TRAILER_SIZE ((uint32_t)2) +#define PACKET_OVERHEAD_SIZE (PACKET_HEADER_SIZE + PACKET_TRAILER_SIZE - 1) +#define PACKET_SIZE ((uint32_t)128) +#define PACKET_1K_SIZE ((uint32_t)1024) + +/* /-------- Packet in IAP memory ------------------------------------------\ + * | 0 | 1 | 2 | 3 | 4 | ... | n+4 | n+5 | n+6 | + * |------------------------------------------------------------------------| + * | unused | start | number | !num | data[0] | ... | data[n] | crc0 | crc1 | + * \------------------------------------------------------------------------/ + * the first byte is left unused for memory alignment reasons */ + +#define FILE_NAME_LENGTH ((uint32_t)64) +#define FILE_SIZE_LENGTH ((uint32_t)16) + +#define SOH ((uint8_t)0x01) /* start of 128-byte data packet */ +#define STX ((uint8_t)0x02) /* start of 1024-byte data packet */ +#define EOT ((uint8_t)0x04) /* end of transmission */ +#define ACK ((uint8_t)0x06) /* acknowledge */ +#define NAK ((uint8_t)0x15) /* negative acknowledge */ +#define CA ((uint32_t)0x18) /* two of these in succession aborts transfer */ +#define CRC16 ((uint8_t)0x43) /* 'C' == 0x43, request 16-bit CRC */ +#define NEGATIVE_BYTE ((uint8_t)0xFF) + +#define ABORT1 ((uint8_t)0x41) /* 'A' == 0x41, abort by user */ +#define ABORT2 ((uint8_t)0x61) /* 'a' == 0x61, abort by user */ + +#define NAK_TIMEOUT ((uint32_t)0x100000) +#define DOWNLOAD_TIMEOUT ((uint32_t)1000) /* One second retry delay */ +#define MAX_ERRORS ((uint32_t)5) + +/* Exported functions ------------------------------------------------------- */ +COM_StatusTypeDef Ymodem_Receive(uint32_t *p_size); +COM_StatusTypeDef Ymodem_Transmit(uint8_t *p_buf, const uint8_t *p_file_name, uint32_t file_size); + +#endif /* __YMODEM_H_ */ + +/*******************(C)COPYRIGHT STMicroelectronics ********END OF FILE********/ diff --git a/examples/stm32cube-hal-iap/test/README b/examples/stm32cube-hal-iap/test/README new file mode 100644 index 00000000..df5066e6 --- /dev/null +++ b/examples/stm32cube-hal-iap/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/stm32cube-hal-lcd/.gitignore b/examples/stm32cube-hal-lcd/.gitignore new file mode 100644 index 00000000..03f4a3c1 --- /dev/null +++ b/examples/stm32cube-hal-lcd/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/examples/stm32cube-hal-lcd/.travis.yml b/examples/stm32cube-hal-lcd/.travis.yml new file mode 100644 index 00000000..7c486f18 --- /dev/null +++ b/examples/stm32cube-hal-lcd/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/stm32cube-hal-lcd/README.rst b/examples/stm32cube-hal-lcd/README.rst new file mode 100644 index 00000000..1ee6f370 --- /dev/null +++ b/examples/stm32cube-hal-lcd/README.rst @@ -0,0 +1,32 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/stm32cube-hal-lcd + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/stm32cube-hal-lcd/include/README b/examples/stm32cube-hal-lcd/include/README new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/examples/stm32cube-hal-lcd/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/stm32cube-hal-lcd/lib/README b/examples/stm32cube-hal-lcd/lib/README new file mode 100644 index 00000000..6debab1e --- /dev/null +++ b/examples/stm32cube-hal-lcd/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/stm32cube-hal-lcd/platformio.ini b/examples/stm32cube-hal-lcd/platformio.ini new file mode 100644 index 00000000..22800c0a --- /dev/null +++ b/examples/stm32cube-hal-lcd/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:eval_l073z] +platform = ststm32 +framework = stm32cube +board = eval_l073z +board_build.stm32cube.variant = STM32L073Z_EVAL diff --git a/examples/stm32cube-hal-lcd/src/main.c b/examples/stm32cube-hal-lcd/src/main.c new file mode 100644 index 00000000..ec29e8b1 --- /dev/null +++ b/examples/stm32cube-hal-lcd/src/main.c @@ -0,0 +1,423 @@ +/** + ****************************************************************************** + * @file LCD/LCD_Display_Text/Src/main.c + * @author MCD Application Team + * @brief This example describes how to configure and use GPIOs through + * the STM32L0xx HAL API. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2016 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/** @addtogroup STM32L0xx_HAL_Examples + * @{ + */ + +/** @addtogroup LCD_Blink_Frequency + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +extern LCD_HandleTypeDef LCDHandle; +BatteryLevel_TypeDef BatteryLevel_Tab; +uint16_t TextValue[7]; +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +static void Convert_Into_Char(uint32_t number, uint16_t *p_tab); +void Print_Smiley_LCD(void); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Main program + * @param None + * @retval None + */ +int main(void) +{ + /* This sample code shows how to use STM32L0xx LCD HAL API to configures the LCD Blink + mode and Blink frequency.*/ + + /* STM32L0xx HAL library initialization: + - Configure the Flash prefetch + - Systick timer is configured by default as source of time base, but user + can eventually implement his proper time base source (a general purpose + timer for example or other time source), keeping in mind that Time base + duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and + handled in milliseconds basis. + - Low Level Initialization + */ + HAL_Init(); + + /* Configure the system clock to 32 MHz */ + SystemClock_Config(); + + /* Configure the Wkup/Tamper push-button */ + BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_EXTI); + + /* Configure the Joystick */ + BSP_JOY_Init(JOY_MODE_EXTI); + + /* Initialize LED3 */ + BSP_LED_Init(LED3); + /* Initialize LED1 */ + BSP_LED_Init(LED1); + /* Initialize LED2 */ + BSP_LED_Init(LED2); + /* Initialize LED4 */ + BSP_LED_Init(LED4); + + /* LCD GLASS Initialization */ + BSP_LCD_GLASS_Init(); + + /*----------------------------*/ + BSP_LCD_GLASS_Clear(); + BSP_LCD_GLASS_BarLevelConfig(BATTERYLEVEL_OFF); + + /* Display string on LCD glass*/ + BSP_LCD_GLASS_DisplayString((uint8_t*)"STM32L0\n\r"); + + BSP_LED_On(LED1); + + HAL_Delay(1000); + + BSP_LCD_GLASS_Clear(); + + BSP_LED_Off(LED1); + /*----------------------------*/ + BSP_LCD_GLASS_Clear(); + BSP_LCD_GLASS_BarLevelConfig(BATTERYLEVEL_OFF); + + /* Configure all LCD segments and Coms to blink at frequency LCDCLK/128 */ + __HAL_LCD_BLINK_CONFIG(&LCDHandle, LCD_BLINKMODE_ALLSEG_ALLCOM, LCD_BLINKFREQUENCY_DIV128); + + /* Display the "BK0128" message on the LCD GLASS */ + BSP_LCD_GLASS_DisplayString((uint8_t*)"BLK 128"); + + BSP_LED_On(LED2); + + HAL_Delay(2000); + + __HAL_LCD_BLINK_CONFIG(&LCDHandle, LCD_BLINKMODE_OFF, LCD_BLINKFREQUENCY_DIV128); + + BSP_LED_Off(LED2); + + /*----------------------------*/ + BSP_LCD_GLASS_Clear(); + + /* Scroll sentence on LCD glass*/ + BSP_LCD_GLASS_ScrollSentence((uint8_t*)"SCROLLING SENTENCE ", 1, SCROLL_SPEED); + HAL_Delay(2000); + + /*----------------------------*/ + + BSP_LCD_GLASS_Clear(); + + BSP_LED_On(LED2); + + HAL_Delay(1000); + + BSP_LCD_GLASS_BarLevelConfig(BATTERYLEVEL_OFF); HAL_Delay(400); + BSP_LCD_GLASS_BarLevelConfig(BATTERYLEVEL_1_4); HAL_Delay(400); + BSP_LCD_GLASS_BarLevelConfig(BATTERYLEVEL_1_2); HAL_Delay(400); + BSP_LCD_GLASS_BarLevelConfig(BATTERYLEVEL_3_4); HAL_Delay(400); + BSP_LCD_GLASS_BarLevelConfig(BATTERYLEVEL_FULL); HAL_Delay(400); + + BSP_LED_Off(LED2); + /*----------------------------*/ + + /*Display Voltage 3500 uA on LCD glass*/ + Convert_Into_Char(3500, TextValue); + + /* Test the significant digit for displays 3 or 4 digits*/ + if (TextValue[0] != '0') + { + TextValue[1] |= DOT; /* To add decimal point */ + } + else + { + /* To shift for suppress '0' before decimal */ + TextValue[0] = TextValue[1] ; + TextValue[0] |= DOUBLE_DOT; /*DOT ;*/ + TextValue[1] = TextValue[2] ; + TextValue[2] = TextValue[3] ; + TextValue[3] = TextValue[4] ;/*' ';*/ + } + /*add units:uA*/ + TextValue[4] = ' '; + TextValue[5] = 'U'; /*'µ';*/ + TextValue[6] = 'A'; + + BSP_LCD_GLASS_DisplayStrDeci(TextValue); + HAL_Delay(2000); + + BSP_LCD_GLASS_DisplayLogo(ENABLE); /*ST logo*/ + HAL_Delay(1000); + + BSP_LCD_GLASS_ArrowConfig(ARROWDIRECTION_OFF); HAL_Delay(200); + BSP_LCD_GLASS_ArrowConfig(ARROWDIRECTION_DOWN); HAL_Delay(200); + BSP_LCD_GLASS_ArrowConfig(ARROWDIRECTION_LEFT); HAL_Delay(200); + BSP_LCD_GLASS_ArrowConfig(ARROWDIRECTION_UP); HAL_Delay(200); + BSP_LCD_GLASS_ArrowConfig(ARROWDIRECTION_RIGHT); HAL_Delay(200); + HAL_Delay(1000); + + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_5, PIXELCOLUMN_10);/*UL:10*19*/ + HAL_Delay(1000); + + BSP_LCD_GLASS_TemperatureConfig(TEMPERATURELEVEL_OFF); HAL_Delay(100); + BSP_LCD_GLASS_TemperatureConfig(TEMPERATURELEVEL_1); HAL_Delay(100); + BSP_LCD_GLASS_TemperatureConfig(TEMPERATURELEVEL_2); HAL_Delay(100); + BSP_LCD_GLASS_TemperatureConfig(TEMPERATURELEVEL_3); HAL_Delay(100); + BSP_LCD_GLASS_TemperatureConfig(TEMPERATURELEVEL_4); HAL_Delay(100); + BSP_LCD_GLASS_TemperatureConfig(TEMPERATURELEVEL_5); HAL_Delay(100); + BSP_LCD_GLASS_TemperatureConfig(TEMPERATURELEVEL_6); HAL_Delay(100); + HAL_Delay(1000); + + BSP_LCD_GLASS_ValueUnitConfig(VALUEUNIT_OFF); HAL_Delay(100); + BSP_LCD_GLASS_ValueUnitConfig(VALUEUNIT_MILLIAMPERE); HAL_Delay(100); + BSP_LCD_GLASS_ValueUnitConfig(VALUEUNIT_MICROAMPERE); HAL_Delay(100); + BSP_LCD_GLASS_ValueUnitConfig(VALUEUNIT_NANOAMPERE); HAL_Delay(100); + HAL_Delay(1000); + + BSP_LCD_GLASS_SignCmd(SIGN_NEGATIVE, ENABLE); HAL_Delay(100); + BSP_LCD_GLASS_SignCmd(SIGN_NEGATIVE, DISABLE); HAL_Delay(100); + BSP_LCD_GLASS_SignCmd(SIGN_NEGATIVE, ENABLE); HAL_Delay(100); + BSP_LCD_GLASS_SignCmd(SIGN_POSITIVE, ENABLE); HAL_Delay(100); + HAL_Delay(1000); + + BSP_LCD_GLASS_ClearMatrixPixel(PIXELROW_5, PIXELCOLUMN_10);/*UL:10*19*/ + HAL_Delay(1000); + + Print_Smiley_LCD(); + + + BSP_LED_On(LED1); + + HAL_Delay(1000); + + BSP_LED_Off(LED1); + + BSP_LCD_GLASS_Clear(); + HAL_Delay(100); + BSP_LCD_GLASS_BarLevelConfig(BATTERYLEVEL_OFF); + /*----------------------------*/ + HAL_Delay(100); + + /*Display " END " on LCD glass*/ + BSP_LCD_GLASS_DisplayString((uint8_t*)"THE END\n\r"); + /*----------------------------*/ + + /* Infinite loop */ + while (1) + { + HAL_Delay(100); + BSP_LED_Toggle(LED4); + } +} + +/** + * @brief Set Matrix Pixel on. + * @param PixelRow: Specify Matrix Row. + * @param PixelColumn: Specify Matrix Column. + * @retval None + */ +void Print_Smiley_LCD(void) +{ + /*clear all->loop on 10*19*/ + BSP_LCD_GLASS_ClearMatrixPixel(PIXELROW_5, PIXELCOLUMN_10); + + /*draw smiley on LCD*/ + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_2, PIXELCOLUMN_9); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_2, PIXELCOLUMN_10); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_2, PIXELCOLUMN_11); + + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_3, PIXELCOLUMN_8); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_3, PIXELCOLUMN_12); + + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_4, PIXELCOLUMN_7); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_5, PIXELCOLUMN_7); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_6, PIXELCOLUMN_7); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_7, PIXELCOLUMN_7); + + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_4, PIXELCOLUMN_13); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_5, PIXELCOLUMN_13); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_6, PIXELCOLUMN_13); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_7, PIXELCOLUMN_13); + + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_8, PIXELCOLUMN_8); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_8, PIXELCOLUMN_12); + + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_9, PIXELCOLUMN_9); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_9, PIXELCOLUMN_10); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_9, PIXELCOLUMN_11); + + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_4, PIXELCOLUMN_9); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_4, PIXELCOLUMN_11); + + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_6, PIXELCOLUMN_9); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_6, PIXELCOLUMN_11); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_7, PIXELCOLUMN_9); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_7, PIXELCOLUMN_10); + BSP_LCD_GLASS_WriteMatrixPixel(PIXELROW_7, PIXELCOLUMN_11); + +} + + +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 32000000 + * HCLK(Hz) = 32000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 1 + * APB2 Prescaler = 1 + * Flash Latency(WS) = 1 + * Main regulator output voltage = Scale1 mode + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct ={0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /* Enable HSE Oscillator */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL8; + RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV2; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct)!= HAL_OK) + { + /* Initialization Error */ + while(1); + } + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1)!= HAL_OK) + { + /* Initialization Error */ + while(1); + } +} + + +/** + * @brief EXTI line detection callbacks. + * @param GPIO_Pin: Specifies the pins connected EXTI line + * @retval None + */ + void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) + { + if(GPIO_Pin == TAMPER_BUTTON_PIN) + { + while (BSP_PB_GetState(BUTTON_TAMPER) == GPIO_PIN_SET) + { + __HAL_GPIO_EXTI_CLEAR_IT(TAMPER_BUTTON_PIN); + } + } + + } + + + /** + * @brief converts a 32bit unsigned int into ASCII + * @caller several callers for display values + * @param Number digit to displays + * p_tab values in array in ASCII + * @retval None + */ +static void Convert_Into_Char(uint32_t number, uint16_t *p_tab) +{ + uint16_t units=0, tens=0, hundreds=0, thousands=0, misc=0; + + units = (((number%10000)%1000)%100)%10; + tens = ((((number-units)/10)%1000)%100)%10; + hundreds = (((number-tens-units)/100))%100%10; + thousands = ((number-hundreds-tens-units)/1000)%10; + misc = ((number-thousands-hundreds-tens-units)/10000); + + *(p_tab+4) = units + 0x30; + *(p_tab+3) = tens + 0x30; + *(p_tab+2) = hundreds + 0x30; + *(p_tab+1) = thousands + 0x30; + *(p_tab) = misc + 0x30; + +} + +#ifdef USE_FULL_ASSERT + +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + + /* Infinite loop */ + while (1) + { + } +} +#endif + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-lcd/src/main.h b/examples/stm32cube-hal-lcd/src/main.h new file mode 100644 index 00000000..dfe5ba22 --- /dev/null +++ b/examples/stm32cube-hal-lcd/src/main.h @@ -0,0 +1,58 @@ +/** + ****************************************************************************** + * @file LCD/LCD_Display_Text/Inc/main.h + * @author MCD Application Team + * @brief Header for main.c module + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2016 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include "stm32l0xx_hal.h" +#include "stm32l073z_eval.h" +#include "stm32l073z_eval_io.h" +#include "stm32l073z_eval_glass_lcd.h" +#include "stm32l073z_eval_tsensor.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +void TSENSOR_demo (void); +uint8_t CheckForUserInput(void); + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-lcd/src/stm32l0xx_hal_conf.h b/examples/stm32cube-hal-lcd/src/stm32l0xx_hal_conf.h new file mode 100644 index 00000000..edbd255e --- /dev/null +++ b/examples/stm32cube-hal-lcd/src/stm32l0xx_hal_conf.h @@ -0,0 +1,322 @@ +/** + ****************************************************************************** + * @file stm32l0xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2016 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32L0xx_HAL_CONF_H +#define __STM32L0xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +/* #define HAL_ADC_MODULE_ENABLED */ +/* #define HAL_COMP_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +#define HAL_DMA_MODULE_ENABLED +/* #define HAL_FIREWALL_MODULE_ENABLED */ +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +#define HAL_LCD_MODULE_ENABLED +/* #define HAL_LPTIM_MODULE_ENABLED */ +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SPI_MODULE_ENABLED */ +/* #define HAL_TIM_MODULE_ENABLED */ +/* #define HAL_TSC_MODULE_ENABLED */ +/* #define HAL_UART_MODULE_ENABLED */ +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_CORTEX_MODULE_ENABLED +/* #define HAL_PCD_MODULE_ENABLED */ + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal Multiple Speed oscillator (MSI) default value. + * This value is the default MSI range value after Reset. + */ +#if !defined (MSI_VALUE) + #define MSI_VALUE ((uint32_t)2097152U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* MSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal High Speed oscillator for USB (HSI48) value. + */ +#if !defined (HSI48_VALUE) +#define HSI48_VALUE ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB in Hz. + The real value may vary depending on the variations + in voltage and temperature. */ +#endif /* HSI48_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)37000U) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +/** + * @brief Time out for LSE start up value in ms. + */ +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY (((uint32_t)1U<<__NVIC_PRIO_BITS) - 1U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define PREREAD_ENABLE 0U +#define BUFFER_CACHE_DISABLE 0U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1 */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ + +#define USE_SPI_CRC 1U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32l0xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32l0xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32l0xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32l0xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32l0xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32l0xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32l0xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32l0xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32l0xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FIREWALL_MODULE_ENABLED + #include "stm32l0xx_hal_firewall.h" +#endif /* HAL_FIREWALL_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32l0xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32l0xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32l0xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32l0xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LCD_MODULE_ENABLED + #include "stm32l0xx_hal_lcd.h" +#endif /* HAL_LCD_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32l0xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32l0xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32l0xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32l0xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32l0xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32l0xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_TSC_MODULE_ENABLED + #include "stm32l0xx_hal_tsc.h" +#endif /* HAL_TSC_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32l0xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32l0xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32l0xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32l0xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32l0xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32l0xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32l0xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32L0xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/examples/stm32cube-hal-lcd/src/stm32l0xx_hal_msp.c b/examples/stm32cube-hal-lcd/src/stm32l0xx_hal_msp.c new file mode 100644 index 00000000..ccf533d5 --- /dev/null +++ b/examples/stm32cube-hal-lcd/src/stm32l0xx_hal_msp.c @@ -0,0 +1,173 @@ +/** + ****************************************************************************** + * @file LCD/LCD_Display_Text/Src/stm32l0xx_hal_msp.c + * @author MCD Application Team + * @brief HAL MSP module. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2016 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/** @addtogroup STM32L0xx_HAL_Examples + * @{ + */ + +/** @defgroup HAL_MSP + * @brief HAL MSP module. + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** @defgroup HAL_MSP_Private_Functions + * @{ + */ + +/** + * @brief LCD MSP Init. + * @param hlcd: LCD handle + * @retval None + */ + void HAL_LCD_MspInit(LCD_HandleTypeDef *hlcd) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + + /*##-1- Enable PWR peripheral Clock #######################################*/ + __HAL_RCC_PWR_CLK_ENABLE(); + + /*##-2- Allow Access and Reset the Backup Domaine ##########################*/ + /* Allow Access to Backup Domaine */ + HAL_PWR_EnableBkUpAccess(); + + /* Reset the Backup Domaine */ + __HAL_RCC_BACKUPRESET_FORCE(); + __HAL_RCC_BACKUPRESET_RELEASE(); + + /*##-3- Configue LSE as RTC clock soucre ###################################*/ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; + RCC_OscInitStruct.LSEState = RCC_LSE_ON; + if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + /* Turn LED3 on */ + while(1); + } + __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE); + + + /*##-4- Enable LCD GPIO Clocks #############################################*/ + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOE_CLK_ENABLE(); + + /*##-5- Configure peripheral GPIO ##########################################*/ + /* Configure Output for LCD */ + /* Port A */ + GPIO_InitStruct.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6 | \ + GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | \ + GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF1_LCD; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + + /* Configure Output for LCD */ + /* Port B */ + GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4 | \ + GPIO_PIN_5 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | \ + GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | \ + GPIO_PIN_15; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + + /* Configure Output for LCD */ + /* Port C*/ + GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ + GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \ + GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \ + GPIO_PIN_12; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* Configure Output for LCD */ + /* Port D*/ + GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | \ + GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | \ + GPIO_PIN_15; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /* Configure Output for LCD */ + /* Port E*/ + GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + /*##-6- Enable LCD peripheral Clock ########################################*/ + __HAL_RCC_LCD_CLK_ENABLE(); +} + +/** + * @brief LCD MSP De-Initialization + * This function freeze the hardware resources used in this example: + * - Disable the Peripheral's clock + * @param hlcd: LCD handle pointer + * @retval None + */ +void HAL_LCD_MspDeInit(LCD_HandleTypeDef *hlcd) +{ + /* Enable LCD reset state */ + __HAL_RCC_LCD_FORCE_RESET(); + + /* Release LCD from reset state */ + __HAL_RCC_LCD_RELEASE_RESET(); +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-lcd/src/stm32l0xx_it.c b/examples/stm32cube-hal-lcd/src/stm32l0xx_it.c new file mode 100644 index 00000000..6f3223e9 --- /dev/null +++ b/examples/stm32cube-hal-lcd/src/stm32l0xx_it.c @@ -0,0 +1,158 @@ +/** + ****************************************************************************** + * @file LCD/LCD_Display_Text/Src/stm32l0xx_it.c + * @author MCD Application Team + * @brief Main Interrupt Service Routines. + * This file provides template for all exceptions handler and + * peripherals interrupt service routine. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2016 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32l0xx_it.h" + +/** @addtogroup STM32L0xx_HAL_Examples + * @{ + */ + +/** @addtogroup LCD_Blink_Frequency + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ + +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/******************************************************************************/ +/* Cortex-M0+ Processor Exceptions Handlers */ +/******************************************************************************/ + +/** + * @brief This function handles NMI exception. + * @param None + * @retval None + */ +void NMI_Handler(void) +{ +} + +/** + * @brief This function handles Hard Fault exception. + * @param None + * @retval None + */ +void HardFault_Handler(void) +{ + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles SVCall exception. + * @param None + * @retval None + */ +void SVC_Handler(void) +{ +} + +/** + * @brief This function handles PendSVC exception. + * @param None + * @retval None + */ +void PendSV_Handler(void) +{ +} + +/** + * @brief This function handles SysTick Handler. + * @param None + * @retval None + */ +void SysTick_Handler(void) +{ + HAL_IncTick(); +} + +/******************************************************************************/ +/* STM32L0xx Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file (startup_stm32l0xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles External lines 4 to 15 interrupt request. + * @param None + * @retval None + */ +void EXTI4_15_IRQHandler(void) +{ + /*printf("\r\n **EXTI4_15_IRQHandler** \n");*/ + HAL_GPIO_EXTI_IRQHandler(TAMPER_BUTTON_PIN); + + +} +/** + * @brief This function handles External lines 0 to 1 interrupt request. + * @param None + * @retval None + */ +void EXTI0_1_IRQHandler(void) +{ + /*printf("\r\n **EXTI0_1_IRQHandler** \n");*/ + +} +/** + * @brief This function handles External lines 2 to 3 interrupt request. + * @param None + * @retval None + */ +void EXTI2_3_IRQHandler(void) +{ + /*printf("\r\n **EXTI2_3_IRQHandler** \n");*/ +} +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-lcd/src/stm32l0xx_it.h b/examples/stm32cube-hal-lcd/src/stm32l0xx_it.h new file mode 100644 index 00000000..8ced4de1 --- /dev/null +++ b/examples/stm32cube-hal-lcd/src/stm32l0xx_it.h @@ -0,0 +1,65 @@ +/** + ****************************************************************************** + * @file LCD/LCD_Display_Text/Inc/stm32l0xx_it.h + * @author MCD Application Team + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2016 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32L0xx_IT_H +#define __STM32L0xx_IT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +void NMI_Handler(void); +void HardFault_Handler(void); +void SVC_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); +void EXTI4_15_IRQHandler(void); + +void EXTI0_1_IRQHandler(void); +void EXTI2_3_IRQHandler(void); +#ifdef __cplusplus +} +#endif + +#endif /* __STM32L0xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-lcd/src/system_stm32l0xx.c b/examples/stm32cube-hal-lcd/src/system_stm32l0xx.c new file mode 100644 index 00000000..dc4ec030 --- /dev/null +++ b/examples/stm32cube-hal-lcd/src/system_stm32l0xx.c @@ -0,0 +1,295 @@ +/** + ****************************************************************************** + * @file system_stm32l0xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32l0xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2016 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32l0xx_system + * @{ + */ + +/** @addtogroup STM32L0xx_System_Private_Includes + * @{ + */ + +#include "stm32l0xx.h" + +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (MSI_VALUE) + #define MSI_VALUE ((uint32_t)2097152U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* MSI_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + + +/** + * @} + */ + +/** @addtogroup STM32L0xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32L0xx_System_Private_Defines + * @{ + */ +/************************* Miscellaneous Configuration ************************/ + +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00U /*!< Vector Table base offset field. + This value must be a multiple of 0x100. */ +/******************************************************************************/ +/** + * @} + */ + +/** @addtogroup STM32L0xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32L0xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = 2097152U; /* 32.768 kHz * 2^6 */ + const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; + const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; + const uint8_t PLLMulTable[9] = {3U, 4U, 6U, 8U, 12U, 16U, 24U, 32U, 48U}; + +/** + * @} + */ + +/** @addtogroup STM32L0xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32L0xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * @param None + * @retval None + */ +void SystemInit (void) +{ +/*!< Set MSION bit */ + RCC->CR |= (uint32_t)0x00000100U; + + /*!< Reset SW[1:0], HPRE[3:0], PPRE1[2:0], PPRE2[2:0], MCOSEL[2:0] and MCOPRE[2:0] bits */ + RCC->CFGR &= (uint32_t) 0x88FF400CU; + + /*!< Reset HSION, HSIDIVEN, HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFF6U; + + /*!< Reset HSI48ON bit */ + RCC->CRRCR &= (uint32_t)0xFFFFFFFEU; + + /*!< Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFFU; + + /*!< Reset PLLSRC, PLLMUL[3:0] and PLLDIV[1:0] bits */ + RCC->CFGR &= (uint32_t)0xFF02FFFFU; + + /*!< Disable all interrupts */ + RCC->CIER = 0x00000000U; + + /* Configure the Vector Table location add offset address ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif +} + +/** + * @brief Update SystemCoreClock according to Clock Register Values + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is MSI, SystemCoreClock will contain the MSI + * value as defined by the MSI range. + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (*) HSI_VALUE is a constant defined in stm32l0xx_hal.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSE_VALUE is a constant defined in stm32l0xx_hal.h file (default value + * 8 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * @param None + * @retval None + */ +void SystemCoreClockUpdate (void) +{ + uint32_t tmp = 0U, pllmul = 0U, plldiv = 0U, pllsource = 0U, msirange = 0U; + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & RCC_CFGR_SWS; + + switch (tmp) + { + case 0x00U: /* MSI used as system clock */ + msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE) >> RCC_ICSCR_MSIRANGE_Pos; + SystemCoreClock = (32768U * (1U << (msirange + 1U))); + break; + case 0x04U: /* HSI used as system clock */ + if ((RCC->CR & RCC_CR_HSIDIVF) != 0U) + { + SystemCoreClock = HSI_VALUE / 4U; + } + else + { + SystemCoreClock = HSI_VALUE; + } + break; + case 0x08U: /* HSE used as system clock */ + SystemCoreClock = HSE_VALUE; + break; + default: /* PLL used as system clock */ + /* Get PLL clock source and multiplication factor ----------------------*/ + pllmul = RCC->CFGR & RCC_CFGR_PLLMUL; + plldiv = RCC->CFGR & RCC_CFGR_PLLDIV; + pllmul = PLLMulTable[(pllmul >> RCC_CFGR_PLLMUL_Pos)]; + plldiv = (plldiv >> RCC_CFGR_PLLDIV_Pos) + 1U; + + pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; + + if (pllsource == 0x00U) + { + /* HSI oscillator clock selected as PLL clock entry */ + if ((RCC->CR & RCC_CR_HSIDIVF) != 0U) + { + SystemCoreClock = (((HSI_VALUE / 4U) * pllmul) / plldiv); + } + else + { + SystemCoreClock = (((HSI_VALUE) * pllmul) / plldiv); + } + } + else + { + /* HSE selected as PLL clock entry */ + SystemCoreClock = (((HSE_VALUE) * pllmul) / plldiv); + } + break; + } + /* Compute HCLK clock frequency --------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos)]; + /* HCLK clock frequency */ + SystemCoreClock >>= tmp; +} + + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-lcd/test/README b/examples/stm32cube-hal-lcd/test/README new file mode 100644 index 00000000..df5066e6 --- /dev/null +++ b/examples/stm32cube-hal-lcd/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/stm32cube-hal-usb-device-dfu/.gitignore b/examples/stm32cube-hal-usb-device-dfu/.gitignore new file mode 100644 index 00000000..03f4a3c1 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/examples/stm32cube-hal-usb-device-dfu/.travis.yml b/examples/stm32cube-hal-usb-device-dfu/.travis.yml new file mode 100644 index 00000000..7c486f18 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/stm32cube-hal-usb-device-dfu/README.rst b/examples/stm32cube-hal-usb-device-dfu/README.rst new file mode 100644 index 00000000..98530ba9 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/README.rst @@ -0,0 +1,32 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/stm32cube-hal-usb-device-dfu + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/stm32cube-hal-usb-device-dfu/include/README b/examples/stm32cube-hal-usb-device-dfu/include/README new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/stm32cube-hal-usb-device-dfu/lib/README b/examples/stm32cube-hal-usb-device-dfu/lib/README new file mode 100644 index 00000000..6debab1e --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/stm32cube-hal-usb-device-dfu/platformio.ini b/examples/stm32cube-hal-usb-device-dfu/platformio.ini new file mode 100644 index 00000000..2e16185e --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:nucleo_f207zg] +platform = ststm32 +framework = stm32cube +board = nucleo_f207zg +board_build.stm32cube.variant = STM32F2xx_Nucleo_144 \ No newline at end of file diff --git a/examples/stm32cube-hal-usb-device-dfu/src/main.c b/examples/stm32cube-hal-usb-device-dfu/src/main.c new file mode 100644 index 00000000..2511e873 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/main.c @@ -0,0 +1,173 @@ +/** + ****************************************************************************** + * @file USB_Device/DFU_Standalone/Src/main.c + * @author MCD Application Team + * @brief USB device DFU demo main file + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +USBD_HandleTypeDef USBD_Device; +pFunction JumpToApplication; +uint32_t JumpAddress; + +/* Private function prototypes -----------------------------------------------*/ +static void SystemClock_Config(void); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Main program + * @param None + * @retval None + */ +int main(void) +{ + /* STM32F207xx HAL library initialization */ + HAL_Init(); + + /* Configure the System clock to have a frequency of 120 MHz */ + SystemClock_Config(); + + /* Configure User Button */ + BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO); + + /* Check if the User Button is pressed */ + if(BSP_PB_GetState(BUTTON_USER) == 0x00) + { + /* Test if user code is programmed starting from USBD_DFU_APP_DEFAULT_ADD address */ + if(((*(__IO uint32_t*)USBD_DFU_APP_DEFAULT_ADD) & 0x2FFE0000 ) == 0x20000000) + { + /* Jump to user application */ + JumpAddress = *(__IO uint32_t*) (USBD_DFU_APP_DEFAULT_ADD + 4); + JumpToApplication = (pFunction) JumpAddress; + + /* Initialize user application's Stack Pointer */ + __set_MSP((*(__IO uint32_t*) USBD_DFU_APP_DEFAULT_ADD )); + JumpToApplication(); + } + } + + /* Otherwise enters DFU mode to allow user programming his application */ + /* Init Device Library */ + USBD_Init(&USBD_Device, &DFU_Desc, 0); + + /* Add Supported Class */ + USBD_RegisterClass(&USBD_Device, USBD_DFU_CLASS); + + /* Add DFU Media interface */ + USBD_DFU_RegisterMedia(&USBD_Device, &USBD_DFU_Flash_fops); + + /* Start Device Process */ + USBD_Start(&USBD_Device); + + /* Run Application (Interrupt mode) */ + while (1) + { + } +} + +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 120000000 + * HCLK(Hz) = 120000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 4 + * APB2 Prescaler = 2 + * HSE Frequency(Hz) = 8000000 + * PLL_M = 8 + * PLL_N = 240 + * PLL_P = 2 + * PLL_Q = 5 + * VDD(V) = 3.3 + * Flash Latency(WS) = 3 + * @param None + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 240; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 5; + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3); +} + +/** + * @brief This function provides accurate delay (in milliseconds) based + * on SysTick counter flag. + * @note This function is declared as __weak to be overwritten in case of other + * implementations in user file. + * @param Delay: specifies the delay time length, in milliseconds. + * @retval None + */ + +void HAL_Delay(__IO uint32_t Delay) +{ + while(Delay) + { + if (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) + { + Delay--; + } + } +} + + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t* file, uint32_t line) +{ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + + /* Infinite loop */ + while (1) + { + } +} +#endif + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/main.h b/examples/stm32cube-hal-usb-device-dfu/src/main.h new file mode 100644 index 00000000..3b73b38b --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/main.h @@ -0,0 +1,39 @@ +/** + ****************************************************************************** + * @file USB_Device/DFU_Standalone/Inc/main.h + * @author MCD Application Team + * @brief Header for main.c module + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f2xx_hal.h" +#include "usbd_core.h" +#include "usbd_desc.h" +#include "stm32f2xx_nucleo_144.h" +#include "usbd_dfu.h" +#include "usbd_dfu_flash.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/stm32f2xx_hal_conf.h b/examples/stm32cube-hal-usb-device-dfu/src/stm32f2xx_hal_conf.h new file mode 100644 index 00000000..8b892580 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/stm32f2xx_hal_conf.h @@ -0,0 +1,407 @@ +/** + ****************************************************************************** + * @file stm32f2xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F2xx_HAL_CONF_H +#define __STM32F2xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_PCCARD_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED + + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration for NUCLEO 144 board ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB 5U /* 5 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 5U /* 5 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* LAN8742A PHY Address*/ +#define LAN8742A_PHY_ADDRESS 0x00U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */ + + +#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */ +#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 1U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f2xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f2xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f2xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f2xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f2xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f2xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f2xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f2xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f2xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f2xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f2xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f2xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f2xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f2xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f2xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f2xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f2xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f2xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f2xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f2xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f2xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f2xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f2xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f2xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f2xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f2xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f2xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f2xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f2xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f2xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f2xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f2xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f2xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f2xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F2xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/stm32f2xx_it.c b/examples/stm32cube-hal-usb-device-dfu/src/stm32f2xx_it.c new file mode 100644 index 00000000..2637edf3 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/stm32f2xx_it.c @@ -0,0 +1,159 @@ +/** + ****************************************************************************** + * @file USB_Device/DFU_Standalone/Src/stm32f2xx_it.c + * @author MCD Application Team + * @brief Main Interrupt Service Routines. + * This file provides template for all exceptions handler and + * peripherals interrupt service routine. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f2xx_hal.h" +#include "main.h" +#include "stm32f2xx_it.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +extern PCD_HandleTypeDef hpcd; + +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/******************************************************************************/ +/* Cortex-M3 Processor Exceptions Handlers */ +/******************************************************************************/ +/** + * @brief This function handles NMI exception. + * @param None + * @retval None + */ +void NMI_Handler(void) +{ +} + +/** + * @brief This function handles Hard Fault exception. + * @param None + * @retval None + */ +void HardFault_Handler(void) +{ + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Memory Manage exception. + * @param None + * @retval None + */ +void MemManage_Handler(void) +{ + /* Go to infinite loop when Memory Manage exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Bus Fault exception. + * @param None + * @retval None + */ +void BusFault_Handler(void) +{ + /* Go to infinite loop when Bus Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Usage Fault exception. + * @param None + * @retval None + */ +void UsageFault_Handler(void) +{ + /* Go to infinite loop when Usage Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles SVCall exception. + * @param None + * @retval None + */ +void SVC_Handler(void) +{ +} + +/** + * @brief This function handles Debug Monitor exception. + * @param None + * @retval None + */ +void DebugMon_Handler(void) +{ +} + +/** + * @brief This function handles PendSVC exception. + * @param None + * @retval None + */ +void PendSV_Handler(void) +{ +} + +/** + * @brief SysTick_Handler + * This function handles SysTick exception. + * @param None + * @retval None + */ +void SysTick_Handler(void) +{ + HAL_IncTick(); +} + +/******************************************************************************/ +/* STM32F2xx Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file (startup_stm32f2xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles USB-On-The-Go HS/FS global interrupt request. + * @param None + * @retval None + */ +#ifdef USE_USB_FS +void OTG_FS_IRQHandler(void) +#else +void OTG_HS_IRQHandler(void) +#endif +{ + HAL_PCD_IRQHandler(&hpcd); +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/stm32f2xx_it.h b/examples/stm32cube-hal-usb-device-dfu/src/stm32f2xx_it.h new file mode 100644 index 00000000..db6aa693 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/stm32f2xx_it.h @@ -0,0 +1,56 @@ +/** + ****************************************************************************** + * @file USB_Device/DFU_Standalone/Inc/stm32f2xx_it.h + * @author MCD Application Team + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F2xx_IT_H +#define __STM32F2xx_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); + +#ifdef USE_USB_FS +void OTG_FS_IRQHandler(void); +#else +void OTG_HS_IRQHandler(void); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F2xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/system_stm32f2xx.c b/examples/stm32cube-hal-usb-device-dfu/src/system_stm32f2xx.c new file mode 100644 index 00000000..46fe2889 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/system_stm32f2xx.c @@ -0,0 +1,251 @@ +/** + ****************************************************************************** + * @file system_stm32f2xx.c + * @author MCD Application Team + * @brief - CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. + * - This file is dedicated only for STM32F207 NUCLEO 144 boards. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32f2xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f2xx_system + * @{ + */ + +/** @addtogroup STM32F2xx_System_Private_Includes + * @{ + */ + +#include "stm32f2xx.h" + +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @} + */ + +/** @addtogroup STM32F2xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F2xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32F2xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F2xx_System_Private_Variables + * @{ + */ + + /* This varaible can be updated in Three ways : + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = 16000000; +const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; + const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; + +/** + * @} + */ + + +/** @addtogroup STM32F2xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the Embedded Flash Interface, the PLL and update the + * SystemFrequency variable. + * @param None + * @retval None + */ +void SystemInit(void) +{ + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set HSION bit */ + RCC->CR |= (uint32_t)0x00000001; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFFF; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x24003010; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Disable all interrupts */ + RCC->CIR = 0x00000000; + + /* Configure the Vector Table location add offset address ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (*) HSI_VALUE is a constant defined in stm32f2xx_hal_conf.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSE_VALUE is a constant defined in stm32f2xx_hal_conf.h file (its value + * depends on the application requirements), user has to ensure that HSE_VALUE + * is same as the real frequency of the crystal used. Otherwise, this function + * may have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & RCC_CFGR_SWS; + + switch (tmp) + { + case 0x00: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + case 0x04: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + case 0x08: /* PLL used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N + SYSCLK = PLL_VCO / PLL_P + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; + pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; + + if (pllsource != 0) + { + /* HSE used as PLL clock source */ + pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + else + { + /* HSI used as PLL clock source */ + pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + + pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; + SystemCoreClock = pllvco/pllp; + break; + default: + SystemCoreClock = HSI_VALUE; + break; + } + /* Compute HCLK frequency --------------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK frequency */ + SystemCoreClock >>= tmp; +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/usbd_conf.c b/examples/stm32cube-hal-usb-device-dfu/src/usbd_conf.c new file mode 100644 index 00000000..a79aa209 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/usbd_conf.c @@ -0,0 +1,474 @@ +/** + ****************************************************************************** + * @file USB_Device/DFU_Standalone/Src/usbd_conf.c + * @author MCD Application Team + * @brief This file implements the USB Device library callbacks and MSP + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2015 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +PCD_HandleTypeDef hpcd; + +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/******************************************************************************* + PCD BSP Routines +*******************************************************************************/ + +/** + * @brief Initializes the PCD MSP. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + /* Configure USB FS GPIOs */ + __HAL_RCC_GPIOA_CLK_ENABLE(); + + /* Configure DM DP Pins */ + GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Configure VBUS Pin */ + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Configure ID pin */ + GPIO_InitStruct.Pin = GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Enable USB FS Clock */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + + /* Set USBFS Interrupt priority */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + + /* Enable USBFS Interrupt */ + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); +} + +/** + * @brief De-Initializes the PCD MSP. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd) +{ + /* Disable USB FS Clock */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + __HAL_RCC_SYSCFG_CLK_DISABLE(); +} + +/******************************************************************************* + LL Driver Callbacks (PCD -> USB Device Library) +*******************************************************************************/ + +/** + * @brief SetupStage callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_LL_SetupStage(hpcd->pData, (uint8_t *)hpcd->Setup); +} + +/** + * @brief DataOut Stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint Number + * @retval None + */ +void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +{ + USBD_LL_DataOutStage(hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); +} + +/** + * @brief DataIn Stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint Number + * @retval None + */ +void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +{ + USBD_LL_DataInStage(hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); +} + +/** + * @brief SOF callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_LL_SOF(hpcd->pData); +} + +/** + * @brief Reset callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_SpeedTypeDef speed = USBD_SPEED_FULL; + + /* Set USB Current Speed */ + switch(hpcd->Init.speed) + { + case PCD_SPEED_HIGH: + speed = USBD_SPEED_HIGH; + break; + + case PCD_SPEED_FULL: + speed = USBD_SPEED_FULL; + break; + + default: + speed = USBD_SPEED_FULL; + break; + } + + /* Reset Device */ + USBD_LL_Reset(hpcd->pData); + + USBD_LL_SetSpeed(hpcd->pData, speed); +} + +/** + * @brief Suspend callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_LL_Suspend(hpcd->pData); +} + +/** + * @brief Resume callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_LL_Resume(hpcd->pData); +} + +/** + * @brief ISOOUTIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint Number + * @retval None + */ +void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +{ + USBD_LL_IsoOUTIncomplete(hpcd->pData, epnum); +} + +/** + * @brief ISOINIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint Number + * @retval None + */ +void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +{ + USBD_LL_IsoINIncomplete(hpcd->pData, epnum); +} + +/** + * @brief ConnectCallback callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_LL_DevConnected(hpcd->pData); +} + +/** + * @brief Disconnect callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_LL_DevDisconnected(hpcd->pData); +} + +/******************************************************************************* + LL Driver Interface (USB Device Library --> PCD) +*******************************************************************************/ + +/** + * @brief Initializes the Low Level portion of the Device driver. + * @param pdev: Device handle + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) +{ + /* Set LL Driver parameters */ + hpcd.Instance = USB_OTG_FS; + hpcd.Init.dev_endpoints = 4; + hpcd.Init.use_dedicated_ep1 = 0; + hpcd.Init.dma_enable = 0; + hpcd.Init.low_power_enable = 0; + hpcd.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd.Init.Sof_enable = 0; + hpcd.Init.speed = PCD_SPEED_FULL; + hpcd.Init.vbus_sensing_enable = 1; + + /* Link The driver to the stack */ + hpcd.pData = pdev; + pdev->pData = &hpcd; + + /* Initialize LL Driver */ + HAL_PCD_Init(&hpcd); + + HAL_PCDEx_SetRxFiFo(&hpcd, 0xA0); + HAL_PCDEx_SetTxFiFo(&hpcd, 0, 0xA0); + + return USBD_OK; +} + +/** + * @brief De-Initializes the Low Level portion of the Device driver. + * @param pdev: Device handle + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) +{ + HAL_PCD_DeInit(pdev->pData); + return USBD_OK; +} + +/** + * @brief Starts the Low Level portion of the Device driver. + * @param pdev: Device handle + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) +{ + HAL_PCD_Start(pdev->pData); + return USBD_OK; +} + +/** + * @brief Stops the Low Level portion of the Device driver. + * @param pdev: Device handle + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) +{ + HAL_PCD_Stop(pdev->pData); + return USBD_OK; +} + +/** + * @brief Opens an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint Number + * @param ep_type: Endpoint Type + * @param ep_mps: Endpoint Max Packet Size + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, + uint8_t ep_addr, + uint8_t ep_type, + uint16_t ep_mps) +{ + HAL_PCD_EP_Open(pdev->pData, + ep_addr, + ep_mps, + ep_type); + + return USBD_OK; +} + +/** + * @brief Closes an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint Number + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_PCD_EP_Close(pdev->pData, ep_addr); + return USBD_OK; +} + +/** + * @brief Flushes an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint Number + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_PCD_EP_Flush(pdev->pData, ep_addr); + return USBD_OK; +} + +/** + * @brief Sets a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint Number + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_PCD_EP_SetStall(pdev->pData, ep_addr); + return USBD_OK; +} + +/** + * @brief Clears a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint Number + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); + return USBD_OK; +} + +/** + * @brief Returns Stall condition. + * @param pdev: Device handle + * @param ep_addr: Endpoint Number + * @retval Stall (1: Yes, 0: No) + */ +uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + PCD_HandleTypeDef *hpcd = pdev->pData; + + if((ep_addr & 0x80) == 0x80) + { + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + } + else + { + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + } +} + +/** + * @brief Assigns a USB address to the device. + * @param pdev: Device handle + * @param ep_addr: Endpoint Number + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) +{ + HAL_PCD_SetAddress(pdev->pData, dev_addr); + return USBD_OK; +} + +/** + * @brief Transmits data over an endpoint. + * @param pdev: Device handle + * @param ep_addr: Endpoint Number + * @param pbuf: Pointer to data to be sent + * @param size: Data size + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, + uint8_t ep_addr, + uint8_t *pbuf, + uint16_t size) +{ + HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); + return USBD_OK; +} + +/** + * @brief Prepares an endpoint for reception. + * @param pdev: Device handle + * @param ep_addr: Endpoint Number + * @param pbuf: Pointer to data to be received + * @param size: Data size + * @retval USBD Status + */ +USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, + uint8_t ep_addr, + uint8_t *pbuf, + uint16_t size) +{ + HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); + return USBD_OK; +} + +/** + * @brief Returns the last transferred packet size. + * @param pdev: Device handle + * @param ep_addr: Endpoint Number + * @retval Received Data Size + */ +uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + return HAL_PCD_EP_GetRxCount(pdev->pData, ep_addr); +} + +/** + * @brief Delays routine for the USB Device Library. + * @param Delay: Delay in ms + * @retval None + */ +void USBD_LL_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/** + * @brief static single allocation. + * @param size: size of allocated memory + * @retval None + */ +void *USBD_static_malloc(uint32_t size) +{ + static uint32_t mem[MAX_STATIC_ALLOC_SIZE]; + return mem; +} + +/** + * @brief Dummy memory free + * @param *p pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/usbd_conf.h b/examples/stm32cube-hal-usb-device-dfu/src/usbd_conf.h new file mode 100644 index 00000000..5e1b3356 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/usbd_conf.h @@ -0,0 +1,89 @@ +/** + ****************************************************************************** + * @file USB_Device/DFU_Standalone/Inc/usbd_conf.h + * @author MCD Application Team + * @brief General low level driver configuration + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2015 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CONF_H +#define __USBD_CONF_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f2xx_hal.h" +#include +#include +#include + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Common Config */ +/* Maximum number of supported media : Flash */ +#define USBD_MAX_NUM_INTERFACES 1 +#define USBD_MAX_NUM_CONFIGURATION 1 +#define USBD_MAX_STR_DESC_SIZ 0x100 +#define USBD_SUPPORT_USER_STRING_DESC 1 +#define USBD_SELF_POWERED 1 +#define USBD_DEBUG_LEVEL 0 + +/* DFU Class Config */ +#define USBD_DFU_MAX_ITF_NUM 1 +#define USBD_DFU_XFER_SIZE 1024 /* Max DFU Packet Size = 1024 bytes */ +#define USBD_DFU_APP_DEFAULT_ADD 0x08008000 /* The first 3 sectors (48 KB) are reserved for DFU code */ +#define USBD_DFU_MAX_NB_OF_SECTORS 12 /* Max number of sectors: 12 sectors in Bank1 */ + +/* Exported macro ------------------------------------------------------------*/ +/* Memory management macros */ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); + +#define MAX_STATIC_ALLOC_SIZE 262 /*MSC Class Driver Structure size*/ + +#define USBD_malloc (uint32_t *)USBD_static_malloc +#define USBD_free USBD_static_free +#define USBD_memset /* Not used */ +#define USBD_memcpy /* Not used */ +#define USBD_Delay HAL_Delay + +/* DEBUG macros */ +#if (USBD_DEBUG_LEVEL > 0) +#define USBD_UsrLog(...) printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_UsrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 1) + +#define USBD_ErrLog(...) printf("ERROR: ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_ErrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 2) +#define USBD_DbgLog(...) printf("DEBUG : ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_DbgLog(...) +#endif + +/* Exported functions ------------------------------------------------------- */ + +#endif /* __USBD_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/usbd_desc.c b/examples/stm32cube-hal-usb-device-dfu/src/usbd_desc.c new file mode 100644 index 00000000..16ecf6f2 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/usbd_desc.c @@ -0,0 +1,272 @@ +/** + ****************************************************************************** + * @file USB_Device/DFU_Standalone/Src/usbd_desc.c + * @author MCD Application Team + * @brief This file provides the USBD descriptors and string formatting method. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2015 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_conf.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +#define USBD_VID 0x0483 +#define USBD_PID 0xDF11 +#define USBD_LANGID_STRING 0x409 +#define USBD_MANUFACTURER_STRING "STMicroelectronics" +#define USBD_PRODUCT_HS_STRING "DFU in HS Mode" +#define USBD_PRODUCT_FS_STRING "DFU in FS Mode" +#define USBD_CONFIGURATION_HS_STRING "DFU Config" +#define USBD_INTERFACE_HS_STRING "DFU Interface" +#define USBD_CONFIGURATION_FS_STRING "DFU Config" +#define USBD_INTERFACE_FS_STRING "DFU Interface" + +/* Private macro -------------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +uint8_t *USBD_DFU_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t *USBD_DFU_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t *USBD_DFU_ManufacturerStrDescriptor (USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t *USBD_DFU_ProductStrDescriptor (USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t *USBD_DFU_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t *USBD_DFU_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t *USBD_DFU_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + +/* Private variables ---------------------------------------------------------*/ +USBD_DescriptorsTypeDef DFU_Desc = { + USBD_DFU_DeviceDescriptor, + USBD_DFU_LangIDStrDescriptor, + USBD_DFU_ManufacturerStrDescriptor, + USBD_DFU_ProductStrDescriptor, + USBD_DFU_SerialStrDescriptor, + USBD_DFU_ConfigStrDescriptor, + USBD_DFU_InterfaceStrDescriptor, +}; + +/* USB Standard Device Descriptor */ +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { + 0x12, /* bLength */ + USB_DESC_TYPE_DEVICE, /* bDescriptorType */ + 0x00, /* bcdUSB */ + 0x02, + 0x00, /* bDeviceClass */ + 0x00, /* bDeviceSubClass */ + 0x00, /* bDeviceProtocol */ + USB_MAX_EP0_SIZE, /* bMaxPacketSize */ + LOBYTE(USBD_VID), /* idVendor */ + HIBYTE(USBD_VID), /* idVendor */ + LOBYTE(USBD_PID), /* idVendor */ + HIBYTE(USBD_PID), /* idVendor */ + 0x00, /* bcdDevice rel. 2.00 */ + 0x02, + USBD_IDX_MFC_STR, /* Index of manufacturer string */ + USBD_IDX_PRODUCT_STR, /* Index of product string */ + USBD_IDX_SERIAL_STR, /* Index of serial number string */ + USBD_MAX_NUM_CONFIGURATION /* bNumConfigurations */ +}; /* USB_DeviceDescriptor */ + +/* USB Standard Device Descriptor */ +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { + USB_LEN_LANGID_STR_DESC, + USB_DESC_TYPE_STRING, + LOBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING), +}; + + +#if defined ( __ICCARM__ ) /* !< IAR Compiler */ +#pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { + USB_SIZ_STRING_SERIAL, + USB_DESC_TYPE_STRING, +}; + +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; + +/* Private functions ---------------------------------------------------------*/ +static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len); +static void Get_SerialNum(void); + +/** + * @brief Returns the device descriptor. + * @param speed: Current device speed + * @param length: Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t *USBD_DFU_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + *length = sizeof(USBD_DeviceDesc); + return (uint8_t*)USBD_DeviceDesc; +} + +/** + * @brief Returns the LangID string descriptor. + * @param speed: Current device speed + * @param length: Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t *USBD_DFU_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + *length = sizeof(USBD_LangIDDesc); + return (uint8_t*)USBD_LangIDDesc; +} + +/** + * @brief Returns the product string descriptor. + * @param speed: Current device speed + * @param length: Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t *USBD_DFU_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_PRODUCT_HS_STRING, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_PRODUCT_FS_STRING, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Returns the manufacturer string descriptor. + * @param speed: Current device speed + * @param length: Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t *USBD_DFU_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** + * @brief Returns the serial number string descriptor. + * @param speed: Current device speed + * @param length: Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t *USBD_DFU_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + *length = USB_SIZ_STRING_SERIAL; + + /* Update the serial number string descriptor with the data from the unique ID*/ + Get_SerialNum(); + + return (uint8_t*)USBD_StringSerial; +} + +/** + * @brief Returns the configuration string descriptor. + * @param speed: Current device speed + * @param length: Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t *USBD_DFU_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_HS_STRING, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Returns the interface string descriptor. + * @param speed: Current device speed + * @param length: Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t *USBD_DFU_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_INTERFACE_HS_STRING, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Create the serial number string descriptor + * @param None + * @retval None + */ +static void Get_SerialNum(void) +{ + uint32_t deviceserial0, deviceserial1, deviceserial2; + + deviceserial0 = *(uint32_t*)DEVICE_ID1; + deviceserial1 = *(uint32_t*)DEVICE_ID2; + deviceserial2 = *(uint32_t*)DEVICE_ID3; + + deviceserial0 += deviceserial2; + + if (deviceserial0 != 0) + { + IntToUnicode (deviceserial0, (uint8_t*)&USBD_StringSerial[2] ,8); + IntToUnicode (deviceserial1, (uint8_t*)&USBD_StringSerial[18] ,4); + } +} + +/** + * @brief Convert Hex 32Bits value into char + * @param value: value to convert + * @param pbuf: pointer to the buffer + * @param len: buffer length + * @retval None + */ +static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len) +{ + uint8_t idx = 0; + + for( idx = 0; idx < len; idx ++) + { + if( ((value >> 28)) < 0xA ) + { + pbuf[ 2* idx] = (value >> 28) + '0'; + } + else + { + pbuf[2* idx] = (value >> 28) + 'A' - 10; + } + + value = value << 4; + + pbuf[ 2* idx + 1] = 0; + } +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/usbd_desc.h b/examples/stm32cube-hal-usb-device-dfu/src/usbd_desc.h new file mode 100644 index 00000000..c1c0fa78 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/usbd_desc.h @@ -0,0 +1,40 @@ +/** + ****************************************************************************** + * @file USB_Device/DFU_Standalone/Inc/usbd_desc.h + * @author MCD Application Team + * @brief Header for usbd_desc.c module + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2015 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_DESC_H +#define __USBD_DESC_H + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_def.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +#define DEVICE_ID1 (0x1FFF7A10) +#define DEVICE_ID2 (0x1FFF7A14) +#define DEVICE_ID3 (0x1FFF7A18) + +#define USB_SIZ_STRING_SERIAL 0x1A +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +extern USBD_DescriptorsTypeDef DFU_Desc; + +#endif /* __USBD_DESC_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/usbd_dfu_flash.c b/examples/stm32cube-hal-usb-device-dfu/src/usbd_dfu_flash.c new file mode 100644 index 00000000..bc6082df --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/usbd_dfu_flash.c @@ -0,0 +1,262 @@ +/** + ****************************************************************************** + * @file USB_Device/DFU_Standalone/Src/usbd_dfu_flash.c + * @author MCD Application Team + * @brief Memory management layer + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2015 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_dfu_flash.h" +#include "stm32f2xx_hal_conf.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +#define FLASH_DESC_STR "@Internal Flash /0x08000000/02*016Ka,02*016Kg,01*064Kg,07*128Kg,04*016Kg,01*064Kg,07*128Kg" + +#define FLASH_ERASE_TIME (uint16_t)50 +#define FLASH_PROGRAM_TIME (uint16_t)50 + +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +static uint32_t GetSector(uint32_t Address); +static uint32_t GetBank(uint32_t Addr); + +/* Extern function prototypes ------------------------------------------------*/ +uint16_t Flash_If_Init(void); +uint16_t Flash_If_Erase(uint32_t Add); +uint16_t Flash_If_Write(uint8_t *src, uint8_t *dest, uint32_t Len); +uint8_t *Flash_If_Read(uint8_t *src, uint8_t *dest, uint32_t Len); +uint16_t Flash_If_DeInit(void); +uint16_t Flash_If_GetStatus(uint32_t Add, uint8_t Cmd, uint8_t *buffer); + +USBD_DFU_MediaTypeDef USBD_DFU_Flash_fops= { + (uint8_t *)FLASH_DESC_STR, + Flash_If_Init, + Flash_If_DeInit, + Flash_If_Erase, + Flash_If_Write, + Flash_If_Read, + Flash_If_GetStatus, +}; + +/* Private functions ---------------------------------------------------------*/ +/** + * @brief Initializes Memory. + * @param None + * @retval 0 if operation is successful, MAL_FAIL else. + */ +uint16_t Flash_If_Init(void) +{ + /* Unlock the internal flash */ + HAL_FLASH_Unlock(); + return 0; +} + +/** + * @brief De-Initializes Memory. + * @param None + * @retval 0 if operation is successful, MAL_FAIL else. + */ +uint16_t Flash_If_DeInit(void) +{ + /* Lock the internal flash */ + HAL_FLASH_Lock(); + return 0; +} + +/** + * @brief Erases sector. + * @param Add: Address of sector to be erased. + * @retval 0 if operation is successful, MAL_FAIL else. + */ +uint16_t Flash_If_Erase(uint32_t Add) +{ + uint32_t startsector = 0, sectorerror = 0; + + /* Variable contains Flash operation status */ + HAL_StatusTypeDef status; + FLASH_EraseInitTypeDef eraseinitstruct; + + /* Get the number of sector */ + startsector = GetSector(Add); + eraseinitstruct.TypeErase = FLASH_TYPEERASE_SECTORS; + eraseinitstruct.Banks = GetBank(Add); + eraseinitstruct.Sector = startsector; + eraseinitstruct.NbSectors = 1; + eraseinitstruct.VoltageRange = FLASH_VOLTAGE_RANGE_3; + status = HAL_FLASHEx_Erase(&eraseinitstruct, §orerror); + + if (status != HAL_OK) + { + return 1; + } + return 0; +} + +/** + * @brief Writes Data into Memory. + * @param src: Pointer to the source buffer. Address to be written to. + * @param dest: Pointer to the destination buffer. + * @param Len: Number of data to be written (in bytes). + * @retval 0 if operation is successful, MAL_FAIL else. + */ +uint16_t Flash_If_Write(uint8_t *src, uint8_t *dest, uint32_t Len) +{ + uint32_t i = 0; + + for(i = 0; i < Len; i+=4) + { + /* Device voltage range supposed to be [2.7V to 3.6V], the operation will + be done by byte */ + if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, (uint32_t)(dest+i), *(uint32_t*)(src+i)) == HAL_OK) + { + /* Check the written value */ + if(*(uint32_t *)(src + i) != *(uint32_t*)(dest+i)) + { + /* Flash content doesn't match SRAM content */ + return 2; + } + } + else + { + /* Error occurred while writing data in Flash memory */ + return 1; + } + } + return 0; +} + +/** + * @brief Reads Data into Memory. + * @param src: Pointer to the source buffer. Address to be written to. + * @param dest: Pointer to the destination buffer. + * @param Len: Number of data to be read (in bytes). + * @retval Pointer to the physical address where data should be read. + */ +uint8_t *Flash_If_Read(uint8_t *src, uint8_t *dest, uint32_t Len) +{ + uint32_t i = 0; + uint8_t *psrc = src; + + for(i = 0; i < Len; i++) + { + dest[i] = *psrc++; + } + /* Return a valid address to avoid HardFault */ + return (uint8_t*)(dest); +} + +/** + * @brief Gets Memory Status. + * @param Add: Address to be read from. + * @param Cmd: Number of data to be read (in bytes). + * @retval 0 if operation is successful + */ +uint16_t Flash_If_GetStatus(uint32_t Add, uint8_t Cmd, uint8_t *buffer) +{ + switch(Cmd) + { + case DFU_MEDIA_PROGRAM: + buffer[1] = (uint8_t)FLASH_PROGRAM_TIME; + buffer[2] = (uint8_t)(FLASH_PROGRAM_TIME << 8); + buffer[3] = 0; + break; + + case DFU_MEDIA_ERASE: + default: + buffer[1] = (uint8_t)FLASH_ERASE_TIME; + buffer[2] = (uint8_t)(FLASH_ERASE_TIME << 8); + buffer[3] = 0; + break; + } + return 0; +} + +/** + * @brief Gets the sector of a given address + * @param Address Address of the FLASH Memory + * @retval The sector of a given address + */ +static uint32_t GetSector(uint32_t Address) +{ + uint32_t sector = 0; + + if((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0)) + { + sector = FLASH_SECTOR_0; + } + else if((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1)) + { + sector = FLASH_SECTOR_1; + } + else if((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2)) + { + sector = FLASH_SECTOR_2; + } + else if((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3)) + { + sector = FLASH_SECTOR_3; + } + else if((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4)) + { + sector = FLASH_SECTOR_4; + } + else if((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5)) + { + sector = FLASH_SECTOR_5; + } + else if((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6)) + { + sector = FLASH_SECTOR_6; + } + else if((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7)) + { + sector = FLASH_SECTOR_7; + } + else if((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8)) + { + sector = FLASH_SECTOR_8; + } + else if((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9)) + { + sector = FLASH_SECTOR_9; + } + else if((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10)) + { + sector = FLASH_SECTOR_10; + } + else + { + sector = FLASH_SECTOR_11; + } + return sector; +} + +/** + * @brief Gets the bank of a given address + * @param Addr: Address of the FLASH Memory + * @retval The bank of a given address + */ +static uint32_t GetBank(uint32_t Addr) +{ + uint32_t bank = 0; + + /* Sector in bank 1 */ + bank = FLASH_BANK_1; + return bank; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/src/usbd_dfu_flash.h b/examples/stm32cube-hal-usb-device-dfu/src/usbd_dfu_flash.h new file mode 100644 index 00000000..d58bc447 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/src/usbd_dfu_flash.h @@ -0,0 +1,64 @@ +/** + ****************************************************************************** + * @file USB_Device/DFU_Standalone/Inc/usbd_dfu_flash.h + * @author MCD Application Team + * @brief Header for usbd_dfu_flash.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2015 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_DFU_FLASH_H_ +#define __USBD_DFU_FLASH_H_ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_dfu.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Base address of the Flash sectors */ +/* Bank 1 */ +#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */ +#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */ +#define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */ +#define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbytes */ +#define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbytes */ +#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbytes */ +/* Bank 2 */ +#define ADDR_FLASH_SECTOR_12 ((uint32_t)0x08100000) /* Base @ of Sector 12, 16 Kbytes */ +#define ADDR_FLASH_SECTOR_13 ((uint32_t)0x08104000) /* Base @ of Sector 13, 16 Kbytes */ +#define ADDR_FLASH_SECTOR_14 ((uint32_t)0x08108000) /* Base @ of Sector 14, 16 Kbytes */ +#define ADDR_FLASH_SECTOR_15 ((uint32_t)0x0810C000) /* Base @ of Sector 15, 16 Kbytes */ +#define ADDR_FLASH_SECTOR_16 ((uint32_t)0x08110000) /* Base @ of Sector 16, 64 Kbytes */ +#define ADDR_FLASH_SECTOR_17 ((uint32_t)0x08120000) /* Base @ of Sector 17, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_18 ((uint32_t)0x08140000) /* Base @ of Sector 18, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_19 ((uint32_t)0x08160000) /* Base @ of Sector 19, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_20 ((uint32_t)0x08180000) /* Base @ of Sector 20, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_21 ((uint32_t)0x081A0000) /* Base @ of Sector 21, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_22 ((uint32_t)0x081C0000) /* Base @ of Sector 22, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_23 ((uint32_t)0x081E0000) /* Base @ of Sector 23, 128 Kbytes */ + +/* Exported macro ------------------------------------------------------------*/ +extern USBD_DFU_MediaTypeDef USBD_DFU_Flash_fops; + +/* Exported functions ------------------------------------------------------- */ + +#endif /* __USBD_DFU_FLASH_H_ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-device-dfu/test/README b/examples/stm32cube-hal-usb-device-dfu/test/README new file mode 100644 index 00000000..df5066e6 --- /dev/null +++ b/examples/stm32cube-hal-usb-device-dfu/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/stm32cube-hal-usb-host-hid/.gitignore b/examples/stm32cube-hal-usb-host-hid/.gitignore new file mode 100644 index 00000000..03f4a3c1 --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/examples/stm32cube-hal-usb-host-hid/.travis.yml b/examples/stm32cube-hal-usb-host-hid/.travis.yml new file mode 100644 index 00000000..7c486f18 --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/stm32cube-hal-usb-host-hid/README.rst b/examples/stm32cube-hal-usb-host-hid/README.rst new file mode 100644 index 00000000..bb158330 --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/README.rst @@ -0,0 +1,32 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/stm32cube-hal-extmem-boot + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/stm32cube-hal-usb-host-hid/include/README b/examples/stm32cube-hal-usb-host-hid/include/README new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/stm32cube-hal-usb-host-hid/lib/README b/examples/stm32cube-hal-usb-host-hid/lib/README new file mode 100644 index 00000000..6debab1e --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/stm32cube-hal-usb-host-hid/platformio.ini b/examples/stm32cube-hal-usb-host-hid/platformio.ini new file mode 100644 index 00000000..40d4126d --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/platformio.ini @@ -0,0 +1,15 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:nucleo_l4r5zi] +platform = ststm32 +framework = stm32cube +board = nucleo_l4r5zi +board_build.stm32cube.variant = STM32L4xx_Nucleo_144 +board_build.stm32cube.disable_embedded_libs = yes \ No newline at end of file diff --git a/examples/stm32cube-hal-usb-host-hid/src/keyboard.c b/examples/stm32cube-hal-usb-host-hid/src/keyboard.c new file mode 100644 index 00000000..c2d5a6fb --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/keyboard.c @@ -0,0 +1,197 @@ +/** + ****************************************************************************** + * @file USB_Host/HID_Standalone/Src/keyboard.c + * @author MCD Application Team + * @brief This file implements the HID keyboard functions + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license SLA0044, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * http://www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ + +/* +#define KYBRD_FIRST_COLUMN (uint16_t)7 +#define KYBRD_LAST_COLUMN (uint16_t)479 +#define KYBRD_FIRST_LINE (uint8_t) 70 +#define SMALL_FONT_COLUMN_WIDTH 8 +#define SMALL_FONT_LINE_WIDTH 15 +#define KYBRD_LAST_LINE (uint16_t)200 +*/ + +#define KYBRD_FIRST_COLUMN 7 +#define KYBRD_LAST_COLUMN 121 +#define KYBRD_FIRST_LINE 50 +#define SMALL_FONT_COLUMN_WIDTH 6 +#define SMALL_FONT_LINE_WIDTH 10 +#define KYBRD_LAST_LINE 81 +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +extern HID_DEMO_StateMachine hid_demo; +extern uint8_t *DEMO_KEYBOARD_menu[]; +extern uint8_t prev_select; +extern uint32_t hid_demo_ready; +uint8_t KeybrdCharXpos = 0; +uint16_t KeybrdCharYpos = 0; + +/* Private function prototypes -----------------------------------------------*/ +static void USR_KEYBRD_Init(void); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Manages Keyboard Menu Process. + * @param None + * @retval None + */ +void HID_KeyboardMenuProcess(void) +{ + switch(hid_demo.keyboard_state) + { + case HID_KEYBOARD_IDLE: + hid_demo.keyboard_state = HID_KEYBOARD_START; + HID_SelectItem(DEMO_KEYBOARD_menu, 0); + hid_demo.select = 0; + prev_select = 0; + break; + + case HID_KEYBOARD_WAIT: + if(hid_demo.select != prev_select) + { + prev_select = hid_demo.select ; + HID_SelectItem(DEMO_KEYBOARD_menu, hid_demo.select & 0x7F); + /* Handle select item */ + if(hid_demo.select & 0x80) + { + hid_demo.select &= 0x7F; + switch(hid_demo.select) + { + case 0: + hid_demo.keyboard_state = HID_KEYBOARD_START; + break; + + case 1: /* Return */ + LCD_LOG_ClearTextZone(); + hid_demo.state = HID_DEMO_REENUMERATE; + hid_demo.select = 0; + break; + + default: + break; + } + } + } + break; + + case HID_KEYBOARD_START: + USR_KEYBRD_Init(); + hid_demo.keyboard_state = HID_KEYBOARD_WAIT; + break; + + default: + break; + } +} + +/** + * @brief Init Keyboard window. + * @param None + * @retval None + */ +static void USR_KEYBRD_Init(void) +{ + LCD_LOG_ClearTextZone(); + BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); + + BSP_LCD_DisplayStringAtLine(4, (uint8_t *)"Use Keyboard to tape"); + BSP_LCD_DisplayStringAtLine(5, (uint8_t *)"characters:"); + BSP_LCD_SetTextColor(LCD_COLOR_WHITE); + + KeybrdCharXpos = KYBRD_FIRST_LINE; + KeybrdCharYpos = KYBRD_FIRST_COLUMN; +} + +/** + * @brief Processes Keyboard data. + * @param data: Keyboard data to be displayed + * @retval None + */ +void USR_KEYBRD_ProcessData(uint8_t data) +{ + if(data == '\n') + { + KeybrdCharYpos = KYBRD_FIRST_COLUMN; + + /* Increment char X position */ + KeybrdCharXpos += SMALL_FONT_LINE_WIDTH; + + if(KeybrdCharXpos > KYBRD_LAST_LINE) + { + LCD_LOG_ClearTextZone(); + KeybrdCharXpos = KYBRD_FIRST_LINE; + KeybrdCharYpos = KYBRD_FIRST_COLUMN; + } + } + else if(data == '\r') + { + /* Manage deletion of character and upadte cursor location */ + if( KeybrdCharYpos == KYBRD_FIRST_COLUMN) + { + /* First character of first line to be deleted */ + if(KeybrdCharXpos == KYBRD_FIRST_LINE) + { + KeybrdCharYpos = KYBRD_FIRST_COLUMN; + } + else + { + KeybrdCharXpos -= SMALL_FONT_LINE_WIDTH; + KeybrdCharYpos = (KYBRD_LAST_COLUMN - SMALL_FONT_COLUMN_WIDTH); + } + } + else + { + KeybrdCharYpos -= SMALL_FONT_COLUMN_WIDTH; + } + BSP_LCD_DisplayChar(KeybrdCharYpos, KeybrdCharXpos, ' '); + } + else + { + /* Update the cursor position on LCD */ + BSP_LCD_DisplayChar(KeybrdCharYpos, KeybrdCharXpos, data); + + /* Increment char Y position */ + KeybrdCharYpos += SMALL_FONT_COLUMN_WIDTH; + + /* Check if the Y position has reached the last column */ + if(KeybrdCharYpos == KYBRD_LAST_COLUMN) + { + KeybrdCharYpos = KYBRD_FIRST_COLUMN; + + /* Increment char X position */ + KeybrdCharXpos += SMALL_FONT_LINE_WIDTH; + } + + if(KeybrdCharXpos > KYBRD_LAST_LINE) + { + LCD_LOG_ClearTextZone(); + KeybrdCharXpos = KYBRD_FIRST_LINE; + /* Start New Display of the cursor position on LCD */ + BSP_LCD_DisplayChar(KeybrdCharYpos,KeybrdCharXpos, data); + } + } +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/lcd_log_conf.h b/examples/stm32cube-hal-usb-host-hid/src/lcd_log_conf.h new file mode 100644 index 00000000..9f2ea48a --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/lcd_log_conf.h @@ -0,0 +1,132 @@ +/** + ****************************************************************************** + * @file lcd_log_conf.h + * @author MCD Application Team + * @brief lcd_log configuration template file. + * This file should be copied to the application folder and modified + * as follows: + * - Rename it to 'lcd_log_conf.h'. + * - Update the name of the LCD driver's header file, depending on + * the EVAL board you are using, see line40 below (be default this + * file will generate compile error unless you do this modification). + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license SLA0044, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * http://www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ + +#ifndef __LCD_LOG_CONF_H__ +#define __LCD_LOG_CONF_H__ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32l4xx_nucleo_144.h" +#include "stm32_adafruit_lcd.h" +#include + + +/** @addtogroup LCD_LOG + * @{ + */ + +/** @defgroup LCD_LOG + * @brief This file is the + * @{ + */ + + +/** @defgroup LCD_LOG_CONF_Exported_Defines + * @{ + */ + +/* Define the LCD default text color */ +#define LCD_LOG_DEFAULT_COLOR LCD_COLOR_WHITE + +/* Comment the line below to disable the scroll back and forward features */ +#define LCD_SCROLL_ENABLED 1 + + +/* Define the Fonts */ +#define LCD_LOG_HEADER_FONT Font8 +#define LCD_LOG_FOOTER_FONT Font8 +#define LCD_LOG_TEXT_FONT Font8 + +/* Define the LCD LOG Color */ +#define LCD_LOG_BACKGROUND_COLOR LCD_COLOR_BLACK +#define LCD_LOG_TEXT_COLOR LCD_COLOR_WHITE + +#define LCD_LOG_SOLID_BACKGROUND_COLOR LCD_COLOR_BLUE +#define LCD_LOG_SOLID_TEXT_COLOR LCD_COLOR_WHITE + +/* Define the cache depth */ +#define CACHE_SIZE 100 +#define YWINDOW_SIZE 8 + +#if (YWINDOW_SIZE > 14) + #error "Wrong YWINDOW SIZE" +#endif + +/* Redirect the printf to the LCD */ +#ifdef __GNUC__ +/* With GCC, small printf (option LD Linker->Libraries->Small printf + set to 'Yes') calls __io_putchar() */ +#define LCD_LOG_PUTCHAR int __io_putchar(int ch) +#else +#define LCD_LOG_PUTCHAR int fputc(int ch, FILE *f) +#endif /* __GNUC__ */ + +/** @defgroup LCD_LOG_CONF_Exported_TypesDefinitions + * @{ + */ + +/** + * @} + */ + + +/** @defgroup LCD_LOG_Exported_Macros + * @{ + */ + + +/** + * @} + */ + +/** @defgroup LCD_LOG_CONF_Exported_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup LCD_LOG_CONF_Exported_FunctionsPrototype + * @{ + */ + +/** + * @} + */ + + +#endif //__LCD_LOG_CONF_H__ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/main.c b/examples/stm32cube-hal-usb-host-hid/src/main.c new file mode 100644 index 00000000..0164f5fd --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/main.c @@ -0,0 +1,341 @@ +/** + ****************************************************************************** + * @file USB_Host/HID_Standalone/Src/main.c + * @author MCD Application Team + * @brief USB host HID Mouse and Keyboard demo main file + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license SLA0044, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * http://www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/* Private typedef -----------------------------------------------------------*/ +typedef enum +{ + SHIELD_NOT_DETECTED = 0, + SHIELD_DETECTED +}ShieldStatus; +/* Private define ------------------------------------------------------------*/ +#define ADC_MULTIMODE_SUPPORT 1 +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +USBH_HandleTypeDef hUSBHost; +HID_ApplicationTypeDef Appli_state = APPLICATION_IDLE; + + + +/* Private function prototypes -----------------------------------------------*/ +static void SystemClock_Config(void); +static ShieldStatus TFT_ShieldDetect(void); +static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id); +static void HID_InitApplication(void); +static void Error_Handler(void); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Main program + * @param None + * @retval None + */ +int main(void) +{ + /* STM32L4xx HAL library initialization: + - Configure the Flash prefetch + - Systick timer is configured by default as source of time base, but user + can eventually implement his proper time base source (a general purpose + timer for example or other time source), keeping in mind that Time base + duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and + handled in milliseconds basis. + - Set NVIC Group Priority to 4 + - Low Level Initialization + */ + + /* Initialize the HAL Library */ + HAL_Init(); + + /* Configure the system clock to 80 MHz */ + SystemClock_Config(); + + /* Enable Power Clock*/ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* Check the availability of adafruit 1.8" TFT shield on top of STM32NUCLEO + board. This is done by reading the state of IO PF.03 pin (mapped to + JoyStick available on adafruit 1.8" TFT shield). If the state of PF.03 + is high then the adafruit 1.8" TFT shield is available. */ + if(TFT_ShieldDetect() != SHIELD_DETECTED) + { + Error_Handler(); + } + + /* Enable USB power on Pwrctrl CR2 register */ + HAL_PWREx_EnableVddUSB(); + + /* Init HID Application */ + HID_InitApplication(); + + /* Init Host Library */ + USBH_Init(&hUSBHost, USBH_UserProcess, 0); + + /* Add Supported Class */ + USBH_RegisterClass(&hUSBHost, USBH_HID_CLASS); + + /* Start Host Process */ + USBH_Start(&hUSBHost); + + /* Run Application (Blocking mode) */ + while (1) + { + /* USB Host Background task */ + USBH_Process(&hUSBHost); + + /* HID Menu Process */ + HID_MenuProcess(); + /* HID Joystick */ + HID_Joysticky(); + } +} + + + + +/** + * @brief HID application Init + * @param None + * @retval None + */ +static void HID_InitApplication(void) +{ + /* Initialize the LCD */ + BSP_LCD_Init(); + + /* Configure Joystick in EXTI mode */ + BSP_JOY_Init(); + + /* Configure KEY Button */ + BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI); + + /* Configure the LEDs */ + BSP_LED_Init(LED1); + BSP_LED_Init(LED2); + BSP_LED_Init(LED3); + + /* Init the LCD Log module */ + LCD_LOG_Init(); + + LCD_LOG_SetHeader((uint8_t *)" USB OTG FS HID Host"); + + LCD_UsrLog("USB Host library started.\n"); + + /* Start HID Interface */ + HID_MenuInit(); +} + +/** + * @brief User Process + * @param phost: Host Handle + * @param id: Host Library user message ID + * @retval None + */ +static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id) +{ + switch(id) + { + case HOST_USER_SELECT_CONFIGURATION: + break; + + case HOST_USER_DISCONNECTION: + Appli_state = APPLICATION_DISCONNECT; + break; + + case HOST_USER_CLASS_ACTIVE: + Appli_state = APPLICATION_READY; + break; + + case HOST_USER_CONNECTION: + Appli_state = APPLICATION_START; + break; + + default: + break; + } +} + +/** + * @brief Toggles LEDs to show user input state. + * @param None + * @retval None + */ +void Toggle_Leds(void) +{ + static uint32_t ticks; + + if(ticks++ == 100) + { + BSP_LED_Toggle(LED1); + BSP_LED_Toggle(LED2); + BSP_LED_Toggle(LED3); + ticks = 0; + } +} + +/** + * @brief Check the availability of adafruit 1.8" TFT shield on top of STM32NUCLEO + * board. This is done by reading the state of IO PF.03 pin (mapped to + * JoyStick available on adafruit 1.8" TFT shield). If the state of PF.03 + * is high then the adafruit 1.8" TFT shield is available. + * @param None + * @retval SHIELD_DETECTED: 1.8" TFT shield is available + * SHIELD_NOT_DETECTED: 1.8" TFT shield is not available + */ +static ShieldStatus TFT_ShieldDetect(void) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + /* Enable GPIO clock */ + NUCLEO_ADCx_GPIO_CLK_ENABLE(); + + GPIO_InitStruct.Pin = NUCLEO_ADCx_GPIO_PIN ; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + HAL_GPIO_Init(NUCLEO_ADCx_GPIO_PORT , &GPIO_InitStruct); + + if(HAL_GPIO_ReadPin(NUCLEO_ADCx_GPIO_PORT, NUCLEO_ADCx_GPIO_PIN) != 0) + { + return SHIELD_DETECTED; + } + else + { + return SHIELD_NOT_DETECTED; + } +} + + +/** + * @brief System Clock Configuration + * The system Clock is configured as follows : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 120000000 + * HCLK(Hz) = 120000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 1 + * APB2 Prescaler = 1 + * HSE Frequency(Hz) = 8000000 + * PLL_M = 2 + * PLL_N = 60 + * PLL_Q = 1 + * PLL_R = 1 + * PLL_P = 1 + * USB Clock source = PLLSAI1 + * PLLSAI1 source = PLL (HSE) + * PLLSAI1 out Frequency(Hz) = 48000000 + * PLLSAI1_M = 4 + * PLLSAI1_N = 96 + * PLLSAI1_Q = 4 + * PLLSAI1_P = 1 + * Flash Latency(WS) = 4 + * @param None + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /* Enable voltage range 1 boost mode for frequency above 80 Mhz */ + __HAL_RCC_PWR_CLK_ENABLE(); + HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST); + __HAL_RCC_PWR_CLK_DISABLE(); + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 4; + RCC_OscInitStruct.PLL.PLLN = 60; + RCC_OscInitStruct.PLL.PLLR = 2; + RCC_OscInitStruct.PLL.PLLP = 2; + RCC_OscInitStruct.PLL.PLLQ = 2; + + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + while(1) {}; + } + + /* Select PLLSAI output as USB clock source */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1; + PeriphClkInitStruct.PLLSAI1.PLLSAI1M = 4; + PeriphClkInitStruct.PLLSAI1.PLLSAI1N = 96; + PeriphClkInitStruct.PLLSAI1.PLLSAI1Q = 4; + PeriphClkInitStruct.PLLSAI1.PLLSAI1P = 1; + PeriphClkInitStruct.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSE; + PeriphClkInitStruct.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + while(1) {}; + } + + /* To avoid undershoot due to maximum frequency, select PLL as system clock source */ + /* with AHB prescaler divider 2 as first step */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) + { + while(1) {}; + } +} + +/** + * @brief This function is executed in case of error occurrence. + * @param None + * @retval None + */ +static void Error_Handler(void) +{ + /* Turn LED3 on */ + BSP_LED_On(LED3); + + while (1) + { + } +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + + /* Infinite loop */ + while (1) + { + } +} +#endif + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/main.h b/examples/stm32cube-hal-usb-host-hid/src/main.h new file mode 100644 index 00000000..522aeacd --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/main.h @@ -0,0 +1,101 @@ +/** + ****************************************************************************** + * @file USB_Host/HID_Standalone/Inc/main.h + * @author MCD Application Team + * @brief Header for main.c module + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license SLA0044, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * http://www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +/* Includes ------------------------------------------------------------------*/ +#include "stdio.h" +#include "usbh_core.h" +#include "stm32l4xx_nucleo_144.h" +#include "stm32_adafruit_lcd.h" +#include "lcd_log.h" +#include "usbh_hid.h" +#include "usbh_hid_parser.h" + + +/* Exported types ------------------------------------------------------------*/ +typedef enum { + HID_DEMO_IDLE = 0, + HID_DEMO_WAIT, + HID_DEMO_START, + HID_DEMO_MOUSE, + HID_DEMO_KEYBOARD, + HID_DEMO_REENUMERATE, +}HID_Demo_State; + +typedef enum { + HID_MOUSE_IDLE = 0, + HID_MOUSE_WAIT, + HID_MOUSE_START, +}HID_mouse_State; + +typedef enum { + HID_KEYBOARD_IDLE = 0, + HID_KEYBOARD_WAIT, + HID_KEYBOARD_START, +}HID_keyboard_State; + +typedef struct _DemoStateMachine { + __IO HID_Demo_State state; + __IO HID_mouse_State mouse_state; + __IO HID_keyboard_State keyboard_state; + __IO JOYState_TypeDef joy_state; + __IO uint8_t select; + __IO uint8_t lock; +}HID_DEMO_StateMachine; + +typedef enum { + APPLICATION_IDLE = 0, + APPLICATION_DISCONNECT, + APPLICATION_START, + APPLICATION_READY, + APPLICATION_RUNNING, +}HID_ApplicationTypeDef; + +extern USBH_HandleTypeDef hUSBHost; +extern HID_ApplicationTypeDef Appli_state; +extern HID_MOUSE_Info_TypeDef mouse_info; +extern uint8_t *DEMO_MOUSE_menu[]; +extern HID_DEMO_StateMachine hid_demo; +extern uint8_t prev_select; + +/* Exported constants --------------------------------------------------------*/ + +/* Enable one of the following defines to select which clock will be used for USB */ +/* #define USB_USE_LSE_MSI_CLOCK */ /* Use MSI clock automatically trimmed by LSE as USB clock */ +#define USB_USE_HSE_CLOCK /* Use HSE as clock source for USB */ + +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +void Toggle_Leds(void); +void HID_SelectItem(uint8_t **menu, uint8_t item); +void HID_MenuInit(void); +void HID_MenuProcess(void); +void HID_MouseMenuProcess(void); +void HID_Joysticky(void); +void HID_KeyboardMenuProcess(void); +void HID_MOUSE_ButtonReleased(uint8_t button_idx); +void HID_MOUSE_ButtonPressed(uint8_t button_idx); +void USR_MOUSE_ProcessData(HID_MOUSE_Info_TypeDef *data); +void USR_KEYBRD_ProcessData(uint8_t data); +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/menu.c b/examples/stm32cube-hal-usb-host-hid/src/menu.c new file mode 100644 index 00000000..b51e84aa --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/menu.c @@ -0,0 +1,334 @@ +/** + ****************************************************************************** + * @file USB_Host/HID_Standalone/Src/menu.c + * @author MCD Application Team + * @brief This file implements Menu Functions + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license SLA0044, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * http://www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +HID_DEMO_StateMachine hid_demo; +uint8_t prev_select = 0; + +uint8_t *DEMO_KEYBOARD_menu[] = +{ + (uint8_t *)" 1 - Start Keyboard / Clear ", + (uint8_t *)" 2 - Return ", +}; + +uint8_t *DEMO_MOUSE_menu[] = +{ + (uint8_t *)" 1 - Start Mouse / Re-Initialize ", + (uint8_t *)" 2 - Return ", +}; + +uint8_t *DEMO_HID_menu[] = +{ + (uint8_t *)" 1 - Start HID ", + (uint8_t *)" 2 - Re-Enumerate ", +}; + +/* Private function prototypes -----------------------------------------------*/ +static void HID_DEMO_ProbeKey(JOYState_TypeDef state); +static void USBH_MouseDemo(USBH_HandleTypeDef *phost); +static void USBH_KeybdDemo(USBH_HandleTypeDef *phost); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Demo state machine. + * @param None + * @retval None + */ +void HID_MenuInit(void) +{ + /* Start HID Interface */ + USBH_UsrLog("Starting HID Demo"); + + BSP_LCD_SetTextColor(LCD_COLOR_GREEN); + BSP_LCD_DisplayStringAtLine(14, (uint8_t *)"Use [Joystick Left/Right]"); + BSP_LCD_DisplayStringAtLine(15, (uint8_t *)"to scroll up/down"); + BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"Use [Joystick Up/Down]"); + BSP_LCD_DisplayStringAtLine(17, (uint8_t *)"to scroll HID menu"); + hid_demo.state = HID_DEMO_IDLE; + HID_MenuProcess(); +} + +/** + * @brief Manages HID Menu Process. + * @param None + * @retval None + */ +void HID_MenuProcess(void) +{ + switch(hid_demo.state) + { + case HID_DEMO_IDLE: + HID_SelectItem(DEMO_HID_menu, 0); + hid_demo.state = HID_DEMO_WAIT; + hid_demo.select = 0; + break; + + case HID_DEMO_WAIT: + if(hid_demo.select != prev_select) + { + prev_select = hid_demo.select; + + HID_SelectItem(DEMO_HID_menu, hid_demo.select & 0x7F); + /* Handle select item */ + if(hid_demo.select & 0x80) + { + hid_demo.select &= 0x7F; + switch(hid_demo.select) + { + case 0: + hid_demo.state = HID_DEMO_START; + break; + + case 1: + hid_demo.state = HID_DEMO_REENUMERATE; + break; + + default: + break; + } + } + } + break; + + case HID_DEMO_START: + if(Appli_state == APPLICATION_READY) + { + if(USBH_HID_GetDeviceType(&hUSBHost) == HID_KEYBOARD) + { + hid_demo.keyboard_state = HID_KEYBOARD_IDLE; + hid_demo.state = HID_DEMO_KEYBOARD; + } + else if(USBH_HID_GetDeviceType(&hUSBHost) == HID_MOUSE) + { + hid_demo.mouse_state = HID_MOUSE_IDLE; + hid_demo.state = HID_DEMO_MOUSE; + } + } + else + { + LCD_ErrLog("No supported HID device!\n"); + hid_demo.state = HID_DEMO_WAIT; + } + break; + + case HID_DEMO_REENUMERATE: + /* Force HID Device to re-enumerate */ + USBH_ReEnumerate(&hUSBHost); + hid_demo.state = HID_DEMO_WAIT; + break; + + case HID_DEMO_MOUSE: + if(Appli_state == APPLICATION_READY) + { + HID_MouseMenuProcess(); + USBH_MouseDemo(&hUSBHost); + } + break; + + case HID_DEMO_KEYBOARD: + if(Appli_state == APPLICATION_READY) + { + HID_KeyboardMenuProcess(); + USBH_KeybdDemo(&hUSBHost); + } + break; + + default: + break; + } + + if(Appli_state == APPLICATION_DISCONNECT) + { + Appli_state = APPLICATION_IDLE; + LCD_LOG_ClearTextZone(); + LCD_ErrLog("HID device disconnected!\n"); + hid_demo.state = HID_DEMO_IDLE; + hid_demo.select = 0; + } +} + +/** + * @brief Manages the menu on the screen. + * @param menu: Menu table + * @param item: Selected item to be highlighted + * @retval None + */ +void HID_SelectItem(uint8_t **menu, uint8_t item) +{ + BSP_LCD_SetTextColor(LCD_COLOR_WHITE); + + switch(item) + { + case 0: + BSP_LCD_SetBackColor(LCD_COLOR_MAGENTA); + BSP_LCD_DisplayStringAtLine(18, menu [0]); + BSP_LCD_SetBackColor(LCD_COLOR_BLUE); + BSP_LCD_DisplayStringAtLine(19, menu [1]); + break; + + case 1: + BSP_LCD_SetBackColor(LCD_COLOR_BLUE); + BSP_LCD_DisplayStringAtLine(18, menu [0]); + BSP_LCD_SetBackColor(LCD_COLOR_MAGENTA); + BSP_LCD_DisplayStringAtLine(19, menu [1]); + BSP_LCD_SetBackColor(LCD_COLOR_BLUE); + break; + } + BSP_LCD_SetBackColor(LCD_COLOR_BLACK); + +} + +/** + * @brief Probes the HID joystick state. + * @param state: Joystick state + * @retval None + */ +static void HID_DEMO_ProbeKey(JOYState_TypeDef state) +{ + /* Handle Menu inputs */ + if(hid_demo.joy_state != state) + { + if((state == JOY_UP) && (hid_demo.select > 0)) + { + hid_demo.select--; + } + else if((state == JOY_DOWN) && (hid_demo.select < 2)) + { + hid_demo.select++; + } + else if(state == JOY_SEL) + { + hid_demo.select |= 0x80; + } + } + hid_demo.joy_state = state; +} + +/** + * @brief EXTI line detection callbacks. + * @param GPIO_Pin: Specifies the pins connected EXTI line + * @retval None + */ +void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) +{ + return; +} + +/** + * @brief Get the joystick state. + * @param None + * @retval None + */ +void HID_Joysticky(void) +{ + static JOYState_TypeDef JoyState = JOY_NONE; + + /* Get the Joystick State */ + JoyState = BSP_JOY_GetState(); + + HID_DEMO_ProbeKey(JoyState); + + switch(JoyState) + { + case JOY_LEFT: + LCD_LOG_ScrollBack(); + break; + + case JOY_RIGHT: + LCD_LOG_ScrollForward(); + break; + + default: + break; + } +} + +/** + * @brief Main routine for Mouse application + * @param phost: Host handle + * @retval None + */ +static void USBH_MouseDemo(USBH_HandleTypeDef *phost) +{ + HID_MOUSE_Info_TypeDef *m_pinfo; + + m_pinfo = USBH_HID_GetMouseInfo(phost); + if(m_pinfo != NULL) + { + /* Handle Mouse data position */ + USR_MOUSE_ProcessData(&mouse_info); + + if(m_pinfo->buttons[0]) + { + HID_MOUSE_ButtonPressed(0); + } + else + { + HID_MOUSE_ButtonReleased(0); + } + + if(m_pinfo->buttons[1]) + { + HID_MOUSE_ButtonPressed(2); + } + else + { + HID_MOUSE_ButtonReleased(2); + } + + if(m_pinfo->buttons[2]) + { + HID_MOUSE_ButtonPressed(1); + } + else + { + HID_MOUSE_ButtonReleased(1); + } + } +} + +/** + * @brief Main routine for Keyboard application + * @param phost: Host handle + * @retval None + */ +static void USBH_KeybdDemo(USBH_HandleTypeDef *phost) +{ + HID_KEYBD_Info_TypeDef *k_pinfo; + char c; + k_pinfo = USBH_HID_GetKeybdInfo(phost); + + if(k_pinfo != NULL) + { + c = USBH_HID_GetASCIICode(k_pinfo); + if(c != 0) + { + USR_KEYBRD_ProcessData(c); + } + } +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/mouse.c b/examples/stm32cube-hal-usb-host-hid/src/mouse.c new file mode 100644 index 00000000..abb9c265 --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/mouse.c @@ -0,0 +1,299 @@ +/** + ****************************************************************************** + * @file USB_Host/HID_Standalone/Src/mouse.c + * @author MCD Application Team + * @brief This file implements Functions for mouse menu + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license SLA0044, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * http://www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/* Private typedef -----------------------------------------------------------*/ +extern USBH_HandleTypeDef hUSBHost; + +/* Private define ------------------------------------------------------------*/ + +/* Left Button Report data */ +#define HID_MOUSE_BUTTON1 0x01 +/* Right Button Report data */ +#define HID_MOUSE_BUTTON2 0x02 +/* Middle Button Report data */ +#define HID_MOUSE_BUTTON3 0x04 + +/* Mouse directions */ +#define MOUSE_TOP_DIR 0x80 +#define MOUSE_BOTTOM_DIR 0x00 +#define MOUSE_LEFT_DIR 0x80 +#define MOUSE_RIGHT_DIR 0x00 +/* +#define MOUSE_WINDOW_X 50 +#define MOUSE_WINDOW_Y 70 +#define MOUSE_WINDOW_X_MAX 181 +#define MOUSE_WINDOW_Y_MIN 101 +#define MOUSE_WINDOW_HEIGHT 80 +#define MOUSE_WINDOW_WIDTH 200 + +#define HID_MOUSE_BUTTON_HEIGHT 15 +#define HID_MOUSE_BUTTON_WIDTH 25 +#define HID_MOUSE_BUTTON1_XCHORD 50 +#define HID_MOUSE_BUTTON2_XCHORD 135 +#define HID_MOUSE_BUTTON3_XCHORD 225 +#define HID_MOUSE_BUTTON_YCHORD 170 +*/ + +#define MOUSE_WINDOW_X 7 +#define MOUSE_WINDOW_Y 52 +#define MOUSE_WINDOW_X_MAX 10 +#define MOUSE_WINDOW_Y_MIN 50 +#define MOUSE_WINDOW_HEIGHT 40 +#define MOUSE_WINDOW_WIDTH 110 + +#define HID_MOUSE_BUTTON_HEIGHT 10 +#define HID_MOUSE_BUTTON_WIDTH 30 +#define HID_MOUSE_BUTTON1_XCHORD 8 +#define HID_MOUSE_BUTTON2_XCHORD 48 +#define HID_MOUSE_BUTTON3_XCHORD 88 +#define HID_MOUSE_BUTTON_YCHORD 100 + +#define MOUSE_LEFT_MOVE 1 +#define MOUSE_RIGHT_MOVE 2 +#define MOUSE_UP_MOVE 3 +#define MOUSE_DOWN_MOVE 4 + +#define HID_MOUSE_HEIGHTLSB 2 +#define HID_MOUSE_WIDTHLSB 2 +#define HID_MOUSE_RES_X 4 +#define HID_MOUSE_RES_Y 4 + +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +static void USR_MOUSE_Init(void); +static void HID_MOUSE_UpdatePosition(int8_t x, int8_t y); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Manages Mouse Menu Process. + * @param None + * @retval None + */ +void HID_MouseMenuProcess(void) +{ + switch(hid_demo.mouse_state) + { + case HID_MOUSE_IDLE: + hid_demo.mouse_state = HID_MOUSE_START; + HID_SelectItem(DEMO_MOUSE_menu, 0); + hid_demo.select = 0; + prev_select = 0; + break; + + case HID_MOUSE_WAIT: + if(hid_demo.select != prev_select) + { + prev_select = hid_demo.select ; + HID_SelectItem(DEMO_MOUSE_menu, hid_demo.select & 0x7F); + + /* Handle select item */ + if(hid_demo.select & 0x80) + { + hid_demo.select &= 0x7F; + switch(hid_demo.select) + { + case 0: + hid_demo.mouse_state = HID_MOUSE_START; + break; + + case 1: /* Return */ + LCD_LOG_ClearTextZone(); + BSP_LCD_ClearStringLine(12); + BSP_LCD_ClearStringLine(13); + hid_demo.state = HID_DEMO_REENUMERATE; + hid_demo.select = 0; + break; + + default: + break; + } + } + } + break; + + case HID_MOUSE_START: + USR_MOUSE_Init(); + hid_demo.mouse_state = HID_MOUSE_WAIT; + HID_MOUSE_UpdatePosition(0,0); + break; + + default: + break; + } +} + +/** + * @brief Init Mouse window. + * @param None + * @retval None + */ +static void USR_MOUSE_Init(void) +{ + LCD_LOG_ClearTextZone(); + BSP_LCD_ClearStringLine(12); + BSP_LCD_ClearStringLine(13); + BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); + BSP_LCD_DisplayStringAtLine(4, (uint8_t *)"USB HID Host Mouse Demo... "); + BSP_LCD_SetTextColor(LCD_LOG_DEFAULT_COLOR); + + /* Display Mouse Window */ + BSP_LCD_DrawRect(MOUSE_WINDOW_X, MOUSE_WINDOW_Y, MOUSE_WINDOW_WIDTH, MOUSE_WINDOW_HEIGHT); + + HID_MOUSE_ButtonReleased(0); + HID_MOUSE_ButtonReleased(1); + HID_MOUSE_ButtonReleased(2); + + BSP_LCD_SetTextColor(LCD_COLOR_GREEN); + BSP_LCD_SetBackColor(LCD_COLOR_BLACK); + + HID_MOUSE_UpdatePosition(0,0); +} + +/** + * @brief Processes Mouse data. + * @param data: Mouse data to be displayed + * @retval None + */ +void USR_MOUSE_ProcessData(HID_MOUSE_Info_TypeDef *data) +{ + if((data->x != 0) && (data->y != 0)) + { + HID_MOUSE_UpdatePosition(data->x , data->y); + } +} + +/** + * @brief Handles mouse scroll to update the mouse position on display window. + * @param x: USB HID Mouse X co-ordinate + * @param y: USB HID Mouse Y co-ordinate + * @retval None + */ +static void HID_MOUSE_UpdatePosition(int8_t x, int8_t y) +{ + static int16_t x_loc = 0, y_loc = 0; + static int16_t prev_x = 5, prev_y = 1; + + if((x != 0) || (y != 0)) + { + x_loc += x/2; + y_loc += y/10; + + if(y_loc > MOUSE_WINDOW_HEIGHT - 12) + { + y_loc = MOUSE_WINDOW_HEIGHT - 12; + } + if(x_loc > MOUSE_WINDOW_WIDTH - 10) + { + x_loc = MOUSE_WINDOW_WIDTH - 10; + } + + if(y_loc < 2) + { + y_loc = 2; + } + if(x_loc < 2) + { + x_loc = 2; + } + BSP_LCD_SetBackColor(LCD_COLOR_BLACK); + BSP_LCD_SetTextColor(LCD_COLOR_BLACK); + BSP_LCD_DisplayChar(MOUSE_WINDOW_X + prev_x, MOUSE_WINDOW_Y + prev_y, 'x'); + + BSP_LCD_SetTextColor(LCD_COLOR_GREEN); + BSP_LCD_DisplayChar(MOUSE_WINDOW_X + x_loc, MOUSE_WINDOW_Y + y_loc, 'x'); + + prev_x = x_loc; + prev_y = y_loc; + } +} + +/** + * @brief Handles mouse button press. + * @param button_idx: Mouse button pressed + * @retval None + */ +void HID_MOUSE_ButtonPressed(uint8_t button_idx) +{ + /* Set the color for button press status */ + BSP_LCD_SetTextColor(LCD_COLOR_BLUE); + BSP_LCD_SetBackColor(LCD_COLOR_BLUE); + + /* Change the color of button pressed to indicate button press */ + switch(button_idx) + { + /* Left Button Pressed */ + case 0: + BSP_LCD_FillRect(HID_MOUSE_BUTTON1_XCHORD, HID_MOUSE_BUTTON_YCHORD,\ + HID_MOUSE_BUTTON_WIDTH, HID_MOUSE_BUTTON_HEIGHT ); + break; + + /* Right Button Pressed */ + case 1: + BSP_LCD_FillRect(HID_MOUSE_BUTTON2_XCHORD,HID_MOUSE_BUTTON_YCHORD,\ + HID_MOUSE_BUTTON_WIDTH,HID_MOUSE_BUTTON_HEIGHT); + break; + + /* Middle button Pressed */ + case 2: + BSP_LCD_FillRect(HID_MOUSE_BUTTON3_XCHORD,HID_MOUSE_BUTTON_YCHORD,\ + HID_MOUSE_BUTTON_WIDTH,HID_MOUSE_BUTTON_HEIGHT); + break; + } +} + +/** + * @brief Handles mouse button release. + * @param button_idx: Mouse button released + * @retval None + */ +void HID_MOUSE_ButtonReleased(uint8_t button_idx) +{ + /* Set the color for release status */ + BSP_LCD_SetTextColor(LCD_COLOR_WHITE); + BSP_LCD_SetBackColor(LCD_COLOR_BLACK); + + /* Change the color of button released to default button color */ + switch(button_idx) + { + /* Left Button Released */ + case 0: + BSP_LCD_FillRect(HID_MOUSE_BUTTON1_XCHORD, HID_MOUSE_BUTTON_YCHORD,\ + HID_MOUSE_BUTTON_WIDTH, HID_MOUSE_BUTTON_HEIGHT); + break; + + /* Right Button Released */ + case 1: + BSP_LCD_FillRect(HID_MOUSE_BUTTON2_XCHORD, HID_MOUSE_BUTTON_YCHORD,\ + HID_MOUSE_BUTTON_WIDTH, HID_MOUSE_BUTTON_HEIGHT); + break; + + /* Middle Button Released */ + case 2: + BSP_LCD_FillRect(HID_MOUSE_BUTTON3_XCHORD, HID_MOUSE_BUTTON_YCHORD,\ + HID_MOUSE_BUTTON_WIDTH, HID_MOUSE_BUTTON_HEIGHT); + break; + } +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/stm32l4xx_hal_conf.h b/examples/stm32cube-hal-usb-host-hid/src/stm32l4xx_hal_conf.h new file mode 100644 index 00000000..143a21ef --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/stm32l4xx_hal_conf.h @@ -0,0 +1,402 @@ +/** + ****************************************************************************** + * @file stm32l4xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32L4xx_HAL_CONF_H +#define __STM32L4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +/* #define HAL_COMP_MODULE_ENABLED */ +#define HAL_CORTEX_MODULE_ENABLED +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +#define HAL_DMA_MODULE_ENABLED +/* #define HAL_FIREWALL_MODULE_ENABLED */ +#define HAL_FLASH_MODULE_ENABLED +/* #define HAL_NAND_MODULE_ENABLED */ +#define HAL_NOR_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +#define HAL_LCD_MODULE_ENABLED +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_OPAMP_MODULE_ENABLED */ +/* #define HAL_PCD_MODULE_ENABLED */ +#define HAL_PWR_MODULE_ENABLED +/* #define HAL_QSPI_MODULE_ENABLED */ +#define HAL_RCC_MODULE_ENABLED +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +/* #define HAL_SWPMI_MODULE_ENABLED */ +/* #define HAL_TIM_MODULE_ENABLED */ +/* #define HAL_TSC_MODULE_ENABLED */ +#define HAL_UART_MODULE_ENABLED +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ + + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal Multiple Speed oscillator (MSI) default value. + * This value is the default MSI range value after Reset. + */ +#if !defined (MSI_VALUE) + #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* MSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI48) value for USB FS, SDMMC and RNG. + * This internal oscillator is mainly dedicated to provide a high precision clock to + * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry. + * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency + * which is subject to manufacturing process variations. + */ +#if !defined (HSI48_VALUE) + #define HSI48_VALUE 48000000U /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz. + The real value my vary depending on manufacturing process variations.*/ +#endif /* HSI48_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for SAI1 peripheral + * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source + * frequency. + */ +#if !defined (EXTERNAL_SAI1_CLOCK_VALUE) + #define EXTERNAL_SAI1_CLOCK_VALUE 48000U /*!< Value of the SAI1 External clock source in Hz*/ +#endif /* EXTERNAL_SAI1_CLOCK_VALUE */ + +/** + * @brief External clock source for SAI2 peripheral + * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source + * frequency. + */ +#if !defined (EXTERNAL_SAI2_CLOCK_VALUE) + #define EXTERNAL_SAI2_CLOCK_VALUE 48000U /*!< Value of the SAI2 External clock source in Hz*/ +#endif /* EXTERNAL_SAI2_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 0U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ + +#define USE_SPI_CRC 1U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32l4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32l4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32l4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32l4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32l4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32l4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32l4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "Legacy/stm32l4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32l4xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32l4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32l4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32l4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32l4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32l4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32l4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_FIREWALL_MODULE_ENABLED + #include "stm32l4xx_hal_firewall.h" +#endif /* HAL_FIREWALL_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32l4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32l4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32l4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32l4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32l4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32l4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32l4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LCD_MODULE_ENABLED + #include "stm32l4xx_hal_lcd.h" +#endif /* HAL_LCD_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32l4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32l4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED +#include "stm32l4xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32l4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32l4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32l4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32l4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32l4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32l4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32l4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32l4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SWPMI_MODULE_ENABLED + #include "stm32l4xx_hal_swpmi.h" +#endif /* HAL_SWPMI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32l4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_TSC_MODULE_ENABLED + #include "stm32l4xx_hal_tsc.h" +#endif /* HAL_TSC_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32l4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32l4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32l4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32l4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32l4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32l4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32l4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_GFXMMU_MODULE_ENABLED + #include "stm32l4xx_hal_gfxmmu.h" +#endif /* HAL_GFXMMU_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32L4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/stm32l4xx_it.c b/examples/stm32cube-hal-usb-host-hid/src/stm32l4xx_it.c new file mode 100644 index 00000000..d1b5fbb5 --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/stm32l4xx_it.c @@ -0,0 +1,170 @@ +/** + ****************************************************************************** + * @file USB_Host/HID_Standalone/Src/stm32l4xx_it.c + * @author MCD Application Team + * @brief Main Interrupt Service Routines. + * This file provides template for all exceptions handler and + * peripherals interrupt service routine. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license SLA0044, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * http://www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32l4xx_it.h" +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +extern HCD_HandleTypeDef hhcd; +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/******************************************************************************/ +/* Cortex-M4 Processor Exceptions Handlers */ +/******************************************************************************/ + +/** + * @brief This function handles NMI exception. + * @param None + * @retval None + */ +void NMI_Handler(void) +{ +} + +/** + * @brief This function handles Hard Fault exception. + * @param None + * @retval None + */ +void HardFault_Handler(void) +{ + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Memory Manage exception. + * @param None + * @retval None + */ +void MemManage_Handler(void) +{ + /* Go to infinite loop when Memory Manage exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Bus Fault exception. + * @param None + * @retval None + */ +void BusFault_Handler(void) +{ + /* Go to infinite loop when Bus Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Usage Fault exception. + * @param None + * @retval None + */ +void UsageFault_Handler(void) +{ + /* Go to infinite loop when Usage Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles SVCall exception. + * @param None + * @retval None + */ +void SVC_Handler(void) +{ +} + +/** + * @brief This function handles Debug Monitor exception. + * @param None + * @retval None + */ +void DebugMon_Handler(void) +{ +} + +/** + * @brief This function handles PendSVC exception. + * @param None + * @retval None + */ +void PendSV_Handler(void) +{ +} + +/** + * @brief This function handles SysTick Handler. + * @param None + * @retval None + */ +void SysTick_Handler(void) +{ + HAL_IncTick(); +} + +/******************************************************************************/ +/* STM32L4xx Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file (startup_stm32l4xx.s). */ +/******************************************************************************/ + + +/** + * @brief This function handles USB-On-The-Go FS global interrupt request. + * @param None + * @retval None + */ +void OTG_FS_IRQHandler(void) +{ + HAL_HCD_IRQHandler(&hhcd); +} + +/** + * @brief This function handles External lines 15 to 10 interrupt request. + * @param None + * @retval None + */ +void EXTI15_10_IRQHandler(void) +{ + HAL_GPIO_EXTI_IRQHandler(USER_BUTTON_PIN); +} + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/stm32l4xx_it.h b/examples/stm32cube-hal-usb-host-hid/src/stm32l4xx_it.h new file mode 100644 index 00000000..8ec61f4d --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/stm32l4xx_it.h @@ -0,0 +1,52 @@ +/** + ****************************************************************************** + * @file stm32l4xx_it.h + * @author MCD Application Team + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license SLA0044, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * http://www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32L4xx_IT_H +#define __STM32L4xx_IT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); +void OTG_FS_IRQHandler(void); +void EXTI15_10_IRQHandler(void); +#ifdef __cplusplus +} +#endif + +#endif /* __STM32L4xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/system_stm32l4xx.c b/examples/stm32cube-hal-usb-host-hid/src/system_stm32l4xx.c new file mode 100644 index 00000000..f4189475 --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/system_stm32l4xx.c @@ -0,0 +1,344 @@ +/** + ****************************************************************************** + * @file system_stm32l4xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32l4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * After each device reset the MSI (4 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32l4xx.s" file, to + * configure the system clock before to branch to main program. + * + * This file configures the system clock as follows: + *============================================================================= + *----------------------------------------------------------------------------- + * System Clock source | MSI + *----------------------------------------------------------------------------- + * SYSCLK(Hz) | 4000000 + *----------------------------------------------------------------------------- + * HCLK(Hz) | 4000000 + *----------------------------------------------------------------------------- + * AHB Prescaler | 1 + *----------------------------------------------------------------------------- + * APB1 Prescaler | 1 + *----------------------------------------------------------------------------- + * APB2 Prescaler | 1 + *----------------------------------------------------------------------------- + * PLL_M | 1 + *----------------------------------------------------------------------------- + * PLL_N | 8 + *----------------------------------------------------------------------------- + * PLL_P | 7 + *----------------------------------------------------------------------------- + * PLL_Q | 2 + *----------------------------------------------------------------------------- + * PLL_R | 2 + *----------------------------------------------------------------------------- + * PLLSAI1_P | NA + *----------------------------------------------------------------------------- + * PLLSAI1_Q | NA + *----------------------------------------------------------------------------- + * PLLSAI1_R | NA + *----------------------------------------------------------------------------- + * PLLSAI2_P | NA + *----------------------------------------------------------------------------- + * PLLSAI2_Q | NA + *----------------------------------------------------------------------------- + * PLLSAI2_R | NA + *----------------------------------------------------------------------------- + * Require 48MHz for USB OTG FS, | Disabled + * SDIO and RNG clock | + *----------------------------------------------------------------------------- + *============================================================================= + ****************************************************************************** + * @attention + * + * Copyright (c) 2009-2018 ARM Limited - STMicroelectronics. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32l4xx_system + * @{ + */ + +/** @addtogroup STM32L4xx_System_Private_Includes + * @{ + */ + +#include "stm32l4xx.h" + +#if !defined (HSE_VALUE) + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (MSI_VALUE) + #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* MSI_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/******************************************************************************/ +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_Variables + * @{ + */ + /* The SystemCoreClock variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = 4000000U; + + const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; + const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; + const uint32_t MSIRangeTable[12] = {100000U, 200000U, 400000U, 800000U, 1000000U, 2000000U, \ + 4000000U, 8000000U, 16000000U, 24000000U, 32000000U, 48000000U}; +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * @param None + * @retval None + */ + +void SystemInit(void) +{ + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set MSION bit */ + RCC->CR |= RCC_CR_MSION; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000U; + + /* Reset HSEON, CSSON , HSION, and PLLON bits */ + RCC->CR &= 0xEAF6FFFFU; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x00001000U; + + /* Reset HSEBYP bit */ + RCC->CR &= 0xFFFBFFFFU; + + /* Disable all interrupts */ + RCC->CIER = 0x00000000U; + + /* Configure the Vector Table location add offset address ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is MSI, SystemCoreClock will contain the MSI_VALUE(*) + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) + * or HSI_VALUE(*) or MSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (*) MSI_VALUE is a constant defined in stm32l4xx_hal.h file (default value + * 4 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSI_VALUE is a constant defined in stm32l4xx_hal.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***) HSE_VALUE is a constant defined in stm32l4xx_hal.h file (default value + * 8 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + uint32_t tmp = 0U, msirange = 0U, pllvco = 0U, pllr = 2U, pllsource = 0U, pllm = 2U; + + /* Get MSI Range frequency--------------------------------------------------*/ + if((RCC->CR & RCC_CR_MSIRGSEL) == RESET) + { /* MSISRANGE from RCC_CSR applies */ + msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U; + } + else + { /* MSIRANGE from RCC_CR applies */ + msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U; + } + /*MSI frequency range in HZ*/ + msirange = MSIRangeTable[msirange]; + + /* Get SYSCLK source -------------------------------------------------------*/ + switch (RCC->CFGR & RCC_CFGR_SWS) + { + case 0x00: /* MSI used as system clock source */ + SystemCoreClock = msirange; + break; + + case 0x04: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + + case 0x08: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + + case 0x0C: /* PLL used as system clock source */ + /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); + pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U ; + + switch (pllsource) + { + case 0x02: /* HSI used as PLL clock source */ + pllvco = (HSI_VALUE / pllm); + break; + + case 0x03: /* HSE used as PLL clock source */ + pllvco = (HSE_VALUE / pllm); + break; + + default: /* MSI used as PLL clock source */ + pllvco = (msirange / pllm); + break; + } + pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); + pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; + SystemCoreClock = pllvco/pllr; + break; + + default: + SystemCoreClock = msirange; + break; + } + /* Compute HCLK clock frequency --------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; + /* HCLK clock frequency */ + SystemCoreClock >>= tmp; +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/usbh_conf.c b/examples/stm32cube-hal-usb-host-hid/src/usbh_conf.c new file mode 100644 index 00000000..5761ca5a --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/usbh_conf.c @@ -0,0 +1,482 @@ +/** + ****************************************************************************** + * @file USB_Host/HID_Standalone/Src/usbh_conf.c + * @author MCD Application Team + * @brief USB Host configuration file. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2017 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32l4xx_hal.h" +#include "usbh_core.h" + +#define USBOTG_PPWR_GPIO_PIN GPIO_PIN_6 +#define USBOTG_PPWR_GPIO_PORT GPIOG +#define USBOTG_PPWR_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() + +HCD_HandleTypeDef hhcd; + +/******************************************************************************* + HCD BSP Routines +*******************************************************************************/ +/** + * @brief Initializes the HCD MSP. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + /* Configure USB FS GPIOs */ + __HAL_RCC_GPIOA_CLK_ENABLE(); + + /* Configure USBOTG_PPWR GPIO */ + USBOTG_PPWR_GPIO_CLK_ENABLE(); + + __HAL_RCC_PWR_CLK_ENABLE(); + HAL_PWREx_EnableVddIO2(); + __HAL_RCC_PWR_CLK_DISABLE(); + + GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = USBOTG_PPWR_GPIO_PIN; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(USBOTG_PPWR_GPIO_PORT, &GPIO_InitStruct); + + /* Enable USB FS Clocks */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + + /* Set USBFS Interrupt to the lowest priority */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + + /* Enable USBFS Interrupt */ + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); +} + +/** + * @brief DeInitializes the HCD MSP. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd) +{ + /* Disable USB FS Clocks */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); +} + +/******************************************************************************* + LL Driver Callbacks (HCD -> USB Host Library) +*******************************************************************************/ + +/** + * @brief SOF callback. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd) +{ + USBH_LL_IncTimer (hhcd->pData); +} + +/** + * @brief Connect callback. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd) +{ + uint32_t i = 0; + + USBH_LL_Connect(hhcd->pData); + + for (i = 0; i< 200000; i ++) + { + __asm ("nop"); + } +} + +/** + * @brief Disconnect callback. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) +{ + USBH_LL_Disconnect(hhcd->pData); +} + +/** + * @brief Port Port Enabled callback. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_PortEnabled_Callback(HCD_HandleTypeDef *hhcd) +{ + USBH_LL_PortEnabled(hhcd->pData); +} + +/** + * @brief Port Port Disabled callback. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_PortDisabled_Callback(HCD_HandleTypeDef *hhcd) +{ + USBH_LL_PortDisabled(hhcd->pData); +} + +/** + * @brief Notify URB state change callback. + * @param hhcd: HCD handle + * @param chnum: Channel number + * @param urb_state: URB State + * @retval None + */ +void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, + HCD_URBStateTypeDef urb_state) +{ + /* To be used with OS to sync URB state with the global state machine */ +} + +/******************************************************************************* + LL Driver Interface (USB Host Library --> HCD) +*******************************************************************************/ +/** + * @brief USBH_LL_Init + * Initialize the Low Level portion of the Host driver. + * @param phost: Host handle + * @retval USBH Status + */ +USBH_StatusTypeDef USBH_LL_Init (USBH_HandleTypeDef *phost) +{ + /* Set the LL Driver parameters */ + hhcd.Instance = USB_OTG_FS; + hhcd.Init.Host_channels = 11; + hhcd.Init.dma_enable = 0; + hhcd.Init.low_power_enable = 0; + hhcd.Init.phy_itface = HCD_PHY_EMBEDDED; + hhcd.Init.Sof_enable = 0; + hhcd.Init.speed = HCD_SPEED_FULL; + /* Link the driver to the stack */ + hhcd.pData = phost; + phost->pData = &hhcd; + /* Initialize the LL Driver */ + HAL_HCD_Init(&hhcd); + + USBH_LL_SetTimer(phost, HAL_HCD_GetCurrentFrame(&hhcd)); + + return USBH_OK; +} + +/** + * @brief USBH_LL_DeInit + * De-Initialize the Low Level portion of the Host driver. + * @param phost: Host handle + * @retval USBH Status + */ +USBH_StatusTypeDef USBH_LL_DeInit (USBH_HandleTypeDef *phost) +{ + HAL_HCD_DeInit(phost->pData); + return USBH_OK; +} + +/** + * @brief USBH_LL_Start + * Start the Low Level portion of the Host driver. + * @param phost: Host handle + * @retval USBH Status + */ +USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost) +{ + HAL_HCD_Start(phost->pData); + return USBH_OK; +} + +/** + * @brief USBH_LL_Stop + * Stop the Low Level portion of the Host driver. + * @param phost: Host handle + * @retval USBH Status + */ +USBH_StatusTypeDef USBH_LL_Stop (USBH_HandleTypeDef *phost) +{ + HAL_HCD_Stop(phost->pData); + return USBH_OK; +} + +/** + * @brief USBH_LL_GetSpeed + * Return the USB Host Speed from the Low Level Driver. + * @param phost: Host handle + * @retval USBH Speeds + */ +USBH_SpeedTypeDef USBH_LL_GetSpeed (USBH_HandleTypeDef *phost) +{ + USBH_SpeedTypeDef speed = USBH_SPEED_FULL; + + switch (HAL_HCD_GetCurrentSpeed(phost->pData)) + { + case 1: + speed = USBH_SPEED_FULL; + break; + + case 2: + speed = USBH_SPEED_LOW; + break; + + default: + speed = USBH_SPEED_FULL; + break; + } + return speed; +} + +/** + * @brief USBH_LL_ResetPort + * Reset the Host Port of the Low Level Driver. + * @param phost: Host handle + * @retval USBH Status + */ +USBH_StatusTypeDef USBH_LL_ResetPort (USBH_HandleTypeDef *phost) +{ + HAL_HCD_ResetPort(phost->pData); + return USBH_OK; +} + +/** + * @brief USBH_LL_GetLastXferSize + * Return the last transferred packet size. + * @param phost: Host handle + * @param pipe: Pipe index + * @retval Packet Size + */ +uint32_t USBH_LL_GetLastXferSize (USBH_HandleTypeDef *phost, uint8_t pipe) +{ + return HAL_HCD_HC_GetXferCount(phost->pData, pipe); +} + +/** + * @brief USBH_LL_OpenPipe + * Open a pipe of the Low Level Driver. + * @param phost: Host handle + * @param pipe: Pipe index + * @param epnum: Endpoint Number + * @param dev_address: Device USB address + * @param speed: Device Speed + * @param ep_type: Endpoint Type + * @param mps: Endpoint Max Packet Size + * @retval USBH Status + */ +USBH_StatusTypeDef USBH_LL_OpenPipe (USBH_HandleTypeDef *phost, + uint8_t pipe, + uint8_t epnum, + uint8_t dev_address, + uint8_t speed, + uint8_t ep_type, + uint16_t mps) +{ + HAL_HCD_HC_Init(phost->pData, + pipe, + epnum, + dev_address, + speed, + ep_type, + mps); + return USBH_OK; +} + +/** + * @brief USBH_LL_ClosePipe + * Close a pipe of the Low Level Driver. + * @param phost: Host handle + * @param pipe: Pipe index + * @retval USBH Status + */ +USBH_StatusTypeDef USBH_LL_ClosePipe (USBH_HandleTypeDef *phost, uint8_t pipe) +{ + HAL_HCD_HC_Halt(phost->pData, pipe); + return USBH_OK; +} + +/** + * @brief USBH_LL_SubmitURB + * Submit a new URB to the low level driver. + * @param phost: Host handle + * @param pipe: Pipe index + * This parameter can be a value from 1 to 15 + * @param direction : Channel number + * This parameter can be one of the these values: + * 0 : Output + * 1 : Input + * @param ep_type : Endpoint Type + * This parameter can be one of the these values: + * @arg EP_TYPE_CTRL: Control type + * @arg EP_TYPE_ISOC: Isochronous type + * @arg EP_TYPE_BULK: Bulk type + * @arg EP_TYPE_INTR: Interrupt type + * @param token : Endpoint Type + * This parameter can be one of the these values: + * @arg 0: PID_SETUP + * @arg 1: PID_DATA + * @param pbuff : pointer to URB data + * @param length : Length of URB data + * @param do_ping : activate do ping protocol (for high speed only) + * This parameter can be one of the these values: + * 0 : do ping inactive + * 1 : do ping active + * @retval Status + */ + +USBH_StatusTypeDef USBH_LL_SubmitURB (USBH_HandleTypeDef *phost, + uint8_t pipe, + uint8_t direction , + uint8_t ep_type, + uint8_t token, + uint8_t* pbuff, + uint16_t length, + uint8_t do_ping ) +{ + HAL_HCD_HC_SubmitRequest(phost->pData, + pipe, + direction, + ep_type, + token, + pbuff, + length, + do_ping); + return USBH_OK; +} + +/** + * @brief USBH_LL_GetURBState + * Get a URB state from the low level driver. + * @param phost: Host handle + * @param pipe: Pipe index + * This parameter can be a value from 1 to 15 + * @retval URB state + * This parameter can be one of the these values: + * @arg URB_IDLE + * @arg URB_DONE + * @arg URB_NOTREADY + * @arg URB_NYET + * @arg URB_ERROR + * @arg URB_STALL + */ +USBH_URBStateTypeDef USBH_LL_GetURBState (USBH_HandleTypeDef *phost, uint8_t pipe) +{ + return (USBH_URBStateTypeDef)HAL_HCD_HC_GetURBState (phost->pData, pipe); +} + +/** + * @brief USBH_LL_DriverVBUS + * Drive VBUS. + * @param phost: Host handle + * @param state : VBUS state + * This parameter can be one of the these values: + * 0 : VBUS Active + * 1 : VBUS Inactive + * @retval Status + */ + +USBH_StatusTypeDef USBH_LL_DriverVBUS (USBH_HandleTypeDef *phost, uint8_t state) +{ + if(state == 0) + { + /* Configure Low Charge pump */ + HAL_GPIO_WritePin(USBOTG_PPWR_GPIO_PORT, USBOTG_PPWR_GPIO_PIN, GPIO_PIN_RESET); + } + else + { + /* Drive High Charge pump */ + HAL_GPIO_WritePin(USBOTG_PPWR_GPIO_PORT, USBOTG_PPWR_GPIO_PIN, GPIO_PIN_SET); + } + + HAL_Delay(200); + return USBH_OK; +} + +/** + * @brief USBH_LL_SetToggle + * Set toggle for a pipe. + * @param phost: Host handle + * @param pipe: Pipe index + * @param toggle: toggle (0/1) + * @retval Status + */ +USBH_StatusTypeDef USBH_LL_SetToggle (USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t toggle) +{ + if(hhcd.hc[pipe].ep_is_in) + { + hhcd.hc[pipe].toggle_in = toggle; + } + else + { + hhcd.hc[pipe].toggle_out = toggle; + } + return USBH_OK; +} + +/** + * @brief USBH_LL_GetToggle + * Return the current toggle of a pipe. + * @param phost: Host handle + * @param pipe: Pipe index + * @retval toggle (0/1) + */ +uint8_t USBH_LL_GetToggle (USBH_HandleTypeDef *phost, uint8_t pipe) +{ + uint8_t toggle = 0; + + if(hhcd.hc[pipe].ep_is_in) + { + toggle = hhcd.hc[pipe].toggle_in; + } + else + { + toggle = hhcd.hc[pipe].toggle_out; + } + return toggle; +} + +/** + * @brief USBH_Delay + * Delay routine for the USB Host Library + * @param Delay: Delay in ms + * @retval None + */ +void USBH_Delay (uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/src/usbh_conf.h b/examples/stm32cube-hal-usb-host-hid/src/usbh_conf.h new file mode 100644 index 00000000..331157c7 --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/src/usbh_conf.h @@ -0,0 +1,85 @@ +/** + ****************************************************************************** + * @file USB_Host/HID_Standalone/Inc/usbh_conf.h + * @author MCD Application Team + * @brief General low level driver configuration + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license SLA0044, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * http://www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBH_CONF_H +#define __USBH_CONF_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32l4xx_hal.h" +#include +#include +#include + +/* Exported types ------------------------------------------------------------*/ +#define USBH_MAX_NUM_ENDPOINTS 2 +#define USBH_MAX_NUM_INTERFACES 2 +#define USBH_MAX_NUM_CONFIGURATION 1 +#define USBH_MAX_NUM_SUPPORTED_CLASS 1 +#define USBH_KEEP_CFG_DESCRIPTOR 0 +#define USBH_MAX_SIZE_CONFIGURATION 0x200 +#define USBH_MAX_DATA_BUFFER 0x200 +#define USBH_DEBUG_LEVEL 2 +#define USBH_USE_OS 0 + +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* CMSIS OS macros */ +#if (USBH_USE_OS == 1) + #include "cmsis_os.h" + #define USBH_PROCESS_PRIO osPriorityNormal +#endif + +/* Memory management macros */ +#define USBH_malloc malloc +#define USBH_free free +#define USBH_memset memset +#define USBH_memcpy memcpy + +/* DEBUG macros */ +#if (USBH_DEBUG_LEVEL > 0) +#define USBH_UsrLog(...) printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBH_UsrLog(...) +#endif + + +#if (USBH_DEBUG_LEVEL > 1) + +#define USBH_ErrLog(...) printf("ERROR: ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBH_ErrLog(...) +#endif + +#if (USBH_DEBUG_LEVEL > 2) +#define USBH_DbgLog(...) printf("DEBUG : ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBH_DbgLog(...) +#endif + +/* Exported functions ------------------------------------------------------- */ + +#endif /* __USB_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-usb-host-hid/test/README b/examples/stm32cube-hal-usb-host-hid/test/README new file mode 100644 index 00000000..df5066e6 --- /dev/null +++ b/examples/stm32cube-hal-usb-host-hid/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/stm32cube-hal-wifi-client/.gitignore b/examples/stm32cube-hal-wifi-client/.gitignore new file mode 100644 index 00000000..03f4a3c1 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/examples/stm32cube-hal-wifi-client/.travis.yml b/examples/stm32cube-hal-wifi-client/.travis.yml new file mode 100644 index 00000000..7c486f18 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/stm32cube-hal-wifi-client/README.rst b/examples/stm32cube-hal-wifi-client/README.rst new file mode 100644 index 00000000..856c2efb --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/README.rst @@ -0,0 +1,32 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/stm32cube-hal-wifi-client + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/stm32cube-hal-wifi-client/include/README b/examples/stm32cube-hal-wifi-client/include/README new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/stm32cube-hal-wifi-client/lib/README b/examples/stm32cube-hal-wifi-client/lib/README new file mode 100644 index 00000000..6debab1e --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/stm32cube-hal-wifi-client/platformio.ini b/examples/stm32cube-hal-wifi-client/platformio.ini new file mode 100644 index 00000000..38845c5b --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/platformio.ini @@ -0,0 +1,16 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:disco_f413zh] +platform = ststm32 +framework = stm32cube +board = disco_f413zh +board_build.stm32cube.variant = STM32F413H-Discovery +lib_ignore = + Util-Fonts diff --git a/examples/stm32cube-hal-wifi-client/src/es_wifi.c b/examples/stm32cube-hal-wifi-client/src/es_wifi.c new file mode 100644 index 00000000..744c5cc7 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/es_wifi.c @@ -0,0 +1,1488 @@ +/** + ****************************************************************************** + * @file es-wifi.c + * @author MCD Application Team + * @brief This file provides a set of functions to manage the es-wifi module. + ****************************************************************************** + * @attention + * + *

© Copyright © 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "es_wifi.h" + +#define AT_OK_STRING "\r\nOK\r\n> " +#define AT_ERROR_STRING "\r\nERROR" + + + +#define CHARISHEXNUM(x) (((x) >= '0' && (x) <= '9') || \ + ((x) >= 'a' && (x) <= 'f') || \ + ((x) >= 'A' && (x) <= 'F')) + +#define CHARISNUM(x) ((x) >= '0' && (x) <= '9') +#define CHAR2NUM(x) ((x) - '0') +/* Private function prototypes -----------------------------------------------*/ +static uint8_t Hex2Num(char a); +static uint32_t ParseHexNumber(char* ptr, uint8_t* cnt); +static uint32_t ParseHexNumber(char* ptr, uint8_t* cnt); +static void ParseMAC(char* ptr, uint8_t* arr); +static void ParseIP(char* ptr, uint8_t* arr); +static ES_WIFI_SecurityType_t ParseSecurity(char* ptr); +#if (ES_WIFI_USE_UART == 1) +static void AT_ParseUARTConfig(char *pdata, ES_WIFI_UARTConfig_t *pConfig); +#endif +static void AT_ParseSystemConfig(char *pdata, ES_WIFI_SystemConfig_t *pConfig); +static void AT_ParseConnSettings(char *pdata, ES_WIFI_Network_t *NetSettings); +static ES_WIFI_Status_t AT_ExecuteCommand(ES_WIFIObject_t *Obj, uint8_t* cmd, uint8_t *pdata); + +/* Private functions ---------------------------------------------------------*/ +/** + * @brief Convert char in Hex format to integer. + * @param a: character to convert + * @retval integer value. + */ +static uint8_t Hex2Num(char a) +{ + if (a >= '0' && a <= '9') { /* Char is num */ + return a - '0'; + } else if (a >= 'a' && a <= 'f') { /* Char is lowercase character A - Z (hex) */ + return (a - 'a') + 10; + } else if (a >= 'A' && a <= 'F') { /* Char is uppercase character A - Z (hex) */ + return (a - 'A') + 10; + } + + return 0; +} + +/** + * @brief Extract a hex number from a string. + * @param ptr: pointer to string + * @param cnt: pointer to the number of parsed digit + * @retval Hex value. + */ +static uint32_t ParseHexNumber(char* ptr, uint8_t* cnt) +{ + uint32_t sum = 0; + uint8_t i = 0; + + while (CHARISHEXNUM(*ptr)) { /* Parse number */ + sum <<= 4; + sum += Hex2Num(*ptr); + ptr++; + i++; + } + + if (cnt != NULL) { /* Save number of characters used for number */ + *cnt = i; + } + return sum; /* Return number */ +} + +/** + * @brief Parses and returns number from string. + * @param ptr: pointer to string + * @param cnt: pointer to the number of parsed digit + * @retval integer value. + */ +static int32_t ParseNumber(char* ptr, uint8_t* cnt) +{ + uint8_t minus = 0, i = 0; + int32_t sum = 0; + + if (*ptr == '-') { /* Check for minus character */ + minus = 1; + ptr++; + i++; + } + while (CHARISNUM(*ptr)) { /* Parse number */ + sum = 10 * sum + CHAR2NUM(*ptr); + ptr++; + i++; + } + if (cnt != NULL) { /* Save number of characters used for number */ + *cnt = i; + } + if (minus) { /* Minus detected */ + return 0 - sum; + } + return sum; /* Return number */ +} + +/** + * @brief Parses and returns MAC address. + * @param ptr: pointer to string + * @param arr: pointer to MAC array + * @retval None. + */ +static void ParseMAC(char* ptr, uint8_t* arr) +{ + uint8_t hexnum = 0, hexcnt; + + while(* ptr) { + hexcnt = 1; + if(*ptr != ':') + { + arr[hexnum++] = ParseHexNumber(ptr, &hexcnt); + } + ptr = ptr + hexcnt; + } +} + +/** + * @brief Parses and returns IP address. + * @param ptr: pointer to string + * @param arr: pointer to IP array + * @retval None. + */ +static void ParseIP(char* ptr, uint8_t* arr) +{ + uint8_t hexnum = 0, hexcnt; + + while(* ptr) { + hexcnt = 1; + if(*ptr != '.') + { + arr[hexnum++] = ParseNumber(ptr, &hexcnt); + } + ptr = ptr + hexcnt; + } +} + +/** + * @brief Parses Security type. + * @param ptr: pointer to string + * @retval Encryption type. + */ +static ES_WIFI_SecurityType_t ParseSecurity(char* ptr) +{ + if(strstr(ptr,"Open")) return ES_WIFI_SEC_OPEN; + else if(strstr(ptr,"WEP")) return ES_WIFI_SEC_WEP; + else if(strstr(ptr,"WPA")) return ES_WIFI_SEC_WPA; + else if(strstr(ptr,"WPA2")) return ES_WIFI_SEC_WPA2; + else if(strstr(ptr,"WPA WPA2")) return ES_WIFI_SEC_WPA_WPA2; + else if(strstr(ptr,"WPA2 TKIP")) return ES_WIFI_SEC_WPA2_TKIP; + else return ES_WIFI_SEC_UNKNOWN; +} + +/** + * @brief Parses ES module informations and save them in the handle. + * @param Obj: pointer to module handle + * @param ptr: pointer to string + * @retval None. + */ +static void AT_ParseInfo(ES_WIFIObject_t *Obj,uint8_t *pdata) +{ + char *ptr; + uint8_t num = 0; + + ptr = strtok((char *)pdata + 2, ","); + + while (ptr != NULL){ + switch (num++) { + case 0: + strncpy((char *)Obj->Product_ID, ptr, ES_WIFI_PRODUCT_ID_SIZE); + break; + + case 1: + strncpy((char *)Obj->FW_Rev, ptr, ES_WIFI_FW_REV_SIZE ); + break; + + case 2: + strncpy((char *)Obj->API_Rev, ptr, ES_WIFI_API_REV_SIZE); + break; + + case 3: + strncpy((char *)Obj->Stack_Rev, ptr, ES_WIFI_STACK_REV_SIZE); + break; + + case 4: + strncpy((char *)Obj->RTOS_Rev, ptr, ES_WIFI_RTOS_REV_SIZE); + break; + + case 5: + Obj->CPU_Clock = ParseNumber(ptr, NULL); + break; + + case 6: + ptr = strtok(ptr, "\r"); + strncpy((char *)Obj->Product_Name, ptr, ES_WIFI_PRODUCT_NAME_SIZE); + break; + + default: break; + } + ptr = strtok(NULL, ","); + } +} + +/** + * @brief Parses Access point configuration. + * @param APs: Access points structure + * @param ptr: pointer to string + * @retval None. + */ +static void AT_ParseAP(char *pdata, ES_WIFI_APs_t *APs) +{ + uint8_t num = 0; + char *ptr; + APs->nbr = 0; + + ptr = strtok(pdata + 2, ","); + + while ((ptr != NULL) && (APs->nbr < ES_WIFI_MAX_DETECTED_AP)) { + switch (num++) { + case 0: /* Ignore index */ + case 4: /* Ignore Max Rate */ + case 5: /* Ignore Network Type */ + case 7: /* Ignore Radio Band */ + break; + + case 1: + ptr[strlen(ptr) - 1] = 0; + strncpy((char *)APs->AP[APs->nbr].SSID, ptr+ 1, ES_WIFI_MAX_SSID_NAME_SIZE + 1); + break; + + case 2: + ParseMAC(ptr, APs->AP[APs->nbr].MAC); + break; + + case 3: + APs->AP[APs->nbr].RSSI = ParseNumber(ptr, NULL); + break; + + case 6: + APs->AP[APs->nbr].Security = ParseSecurity(ptr); + break; + + case 8: + APs->AP[APs->nbr].Channel = ParseNumber(ptr, NULL); + APs->nbr++; + num = 1; + break; + + default: + break; + } + ptr = strtok(NULL, ","); + } +} + +#if (ES_WIFI_USE_UART == 1) +/** + * @brief Parses UART configuration. + * @param APs: UART Config structure + * @param ptr: pointer to string + * @retval None. + */ +static void AT_ParseUARTConfig(char *pdata, ES_WIFI_UARTConfig_t *pConfig) +{ + uint8_t num = 0; + char *ptr; + + ptr = strtok(pdata + 2, ","); + + while (ptr != NULL) { + switch (num++) { + case 0: + pConfig->Port = ParseNumber(ptr, NULL); + break; + + case 1: + pConfig->BaudRate = ParseNumber(ptr, NULL); + break; + + case 2: + pConfig->DataWidth = ParseNumber(ptr, NULL); + break; + + case 3: + pConfig->Parity = ParseNumber(ptr, NULL); + break; + + case 4: + pConfig->StopBits = ParseNumber(ptr, NULL); + break; + + case 5: + pConfig->Mode = ParseNumber(ptr, NULL); + break; + + default: + break; + } + ptr = strtok(NULL, ","); + } +} +#endif + +/** + * @brief Parses System configuration. + * @param APs: System Config structure + * @param ptr: pointer to string + * @retval None. + */ +static void AT_ParseSystemConfig(char *pdata, ES_WIFI_SystemConfig_t *pConfig) +{ + uint8_t num = 0; + char *ptr; + + ptr = strtok(pdata + 2, ","); + + while (ptr != NULL) { + switch (num++) { + case 0: + pConfig->Configuration = ParseNumber(ptr, NULL); + break; + + case 1: + pConfig->WPSPin = ParseNumber(ptr, NULL); + break; + + case 2: + pConfig->VID = ParseNumber(ptr, NULL); + break; + + case 3: + pConfig->PID = ParseNumber(ptr, NULL); + break; + + case 4: + ParseMAC(ptr, pConfig->MAC); + break; + + case 5: + ParseIP(ptr, pConfig->AP_IPAddress); + break; + + case 6: + pConfig->PS_Mode = ParseNumber(ptr, NULL); + break; + + case 7: + pConfig->RadioMode = ParseNumber(ptr, NULL); + break; + + case 8: + pConfig->CurrentBeacon = ParseNumber(ptr, NULL); + break; + + case 9: + pConfig->PrevBeacon = ParseNumber(ptr, NULL); + break; + + case 10: + pConfig->ProductName = ParseNumber(ptr, NULL); + break; + + default: + break; + } + ptr = strtok(NULL, ","); + } +} + + +/** + * @brief Parses WIFI connection settings. + * @param NetSettings: settings + * @param pdata: pointer to data + * @retval None. + */ +static void AT_ParseConnSettings(char *pdata, ES_WIFI_Network_t *NetSettings) +{ + uint8_t num = 0; + char *ptr; + + ptr = strtok(pdata + 2, ","); + + while (ptr != NULL) { + switch (num++) { + case 0: + strncpy((char *)NetSettings->SSID, ptr, ES_WIFI_MAX_SSID_NAME_SIZE + 1); + break; + + case 1: + strncpy((char *)NetSettings->pswd, ptr, ES_WIFI_MAX_PSWD_NAME_SIZE + 1); + break; + + case 2: + NetSettings->Security = (ES_WIFI_SecurityType_t)ParseNumber(ptr, NULL); + break; + + case 3: + NetSettings->DHCP_IsEnabled = ParseNumber(ptr, NULL); + break; + + case 4: + NetSettings->IP_Ver = (ES_WIFI_IPVer_t)ParseNumber(ptr, NULL); + break; + + case 5: + ParseIP(ptr, NetSettings->IP_Addr); + break; + + case 6: + ParseIP(ptr, NetSettings->IP_Mask); + break; + + case 7: + ParseIP(ptr, NetSettings->Gateway_Addr); + break; + + case 8: + ParseIP(ptr, NetSettings->DNS1); + break; + + case 9: + ParseIP(ptr, NetSettings->DNS2); + break; + + case 10: + NetSettings->JoinRetries = ParseNumber(ptr, NULL); + break; + + case 11: + NetSettings->AutoConnect = ParseNumber(ptr, NULL); + break; + + default: + break; + } + ptr = strtok(NULL, ","); + } +} + +/** + * @brief Execute AT command. + * @param Obj: pointer to module handle + * @param cmd: pointer to command string + * @param pdata: pointer to returned data + * @retval Operation Status. + */ +static ES_WIFI_Status_t AT_ExecuteCommand(ES_WIFIObject_t *Obj, uint8_t* cmd, uint8_t *pdata) +{ + if(Obj->fops.IO_Send(cmd, strlen((char*)cmd), Obj->Timeout) > 0) + { + int16_t n=Obj->fops.IO_Receive(pdata, 0, Obj->Timeout); + if(n > 0) + { + *(pdata+n)=0; + if(strstr((char *)pdata, AT_OK_STRING)) + { + return ES_WIFI_STATUS_OK; + } + else if(strstr((char *)pdata, AT_ERROR_STRING)) + { + return ES_WIFI_STATUS_ERROR; + } + } + } + return ES_WIFI_STATUS_IO_ERROR; +} + +/** + * @brief Execute AT command with data. + * @param Obj: pointer to module handle + * @param cmd: pointer to command string + * @param pcmd_data: pointer to binary data + * @param len: binary data length + * @param pdata: pointer to returned data + * @retval Operation Status. + */ +static ES_WIFI_Status_t AT_RequestSendData(ES_WIFIObject_t *Obj, uint8_t* cmd, uint8_t *pcmd_data, uint16_t len, uint8_t *pdata) +{ + /* Can send only even number of byte on first send */ + uint16_t n=strlen((char*)cmd); + if (n &1 ) return ES_WIFI_STATUS_ERROR; + if(Obj->fops.IO_Send(cmd, n, Obj->Timeout) == n) + { + int16_t n=Obj->fops.IO_Send(pcmd_data, len, Obj->Timeout); + if(n == len) + { + n = Obj->fops.IO_Receive(pdata, 0, Obj->Timeout); + if(n > 0) + { + *(pdata+n)=0; + if(strstr((char *)pdata, AT_OK_STRING)) + { + return ES_WIFI_STATUS_OK; + } + else if(strstr((char *)pdata, AT_ERROR_STRING)) + { + return ES_WIFI_STATUS_ERROR; + } + } + } + else + { + return ES_WIFI_STATUS_ERROR; + } + } + return ES_WIFI_STATUS_IO_ERROR; +} + +/** + * @brief Parses Received data. + * @param ptr: pointer to raw data + * @param pdata: payload + * @retval Data length. + */ +static ES_WIFI_Status_t AT_RequestReceiveData(ES_WIFIObject_t *Obj, uint8_t* cmd, char *pdata, uint16_t Reqlen, uint16_t *ReadData) +{ + uint16_t len; + + if(Obj->fops.IO_Send(cmd, strlen((char*)cmd), Obj->Timeout) > 0) + { + if(Obj->fops.IO_Receive((uint8_t *)pdata, 2, Obj->Timeout) == 2) /* Read Prompt */ + { + len = Obj->fops.IO_Receive((uint8_t *)pdata, Reqlen + strlen(AT_OK_STRING) , Obj->Timeout); + + if(strstr((char *)pdata + len -strlen(AT_OK_STRING), AT_OK_STRING)) + { + *ReadData = len - strlen(AT_OK_STRING); + return ES_WIFI_STATUS_OK; + } + } + else + { + return ES_WIFI_STATUS_IO_ERROR; + } + } + return ES_WIFI_STATUS_IO_ERROR; +} + +/** + * @brief Initialize WIFI module. + * @param Obj: pointer to module handle + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_Init(ES_WIFIObject_t *Obj) +{ + ES_WIFI_Status_t ret = ES_WIFI_STATUS_ERROR; + + Obj->Timeout = ES_WIFI_TIMEOUT; + + if (Obj->fops.IO_Init() == 0) + { + ret = AT_ExecuteCommand(Obj,(uint8_t*)"I?\r\n", Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + AT_ParseInfo (Obj, Obj->CmdData); + } + } + return ret; +} + +/** + * @brief Return ProductID. + * @param Obj: pointer to module handle + * @param productID: pointer productID + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetProductID(ES_WIFIObject_t *Obj, uint8_t *productID) +{ + strncpy((char *)productID, (char *)Obj->Product_ID, ES_WIFI_PRODUCT_ID_SIZE); + return ES_WIFI_STATUS_OK; +} + +/** + * @brief Return Firmware Revision. + * @param Obj: pointer to module handle + * @param productID: pointer Revision + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetFWRevID(ES_WIFIObject_t *Obj, uint8_t *FWRev) +{ + strncpy((char *)FWRev, (char *)Obj->FW_Rev, ES_WIFI_FW_REV_SIZE); + return ES_WIFI_STATUS_OK; +} + +/** + * @brief Return product Name. + * @param Obj: pointer to module handle + * @param productID: pointer product Name + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetProductName(ES_WIFIObject_t *Obj, uint8_t *productName) +{ + strncpy((char *)productName, (char *)Obj->Product_Name, ES_WIFI_PRODUCT_NAME_SIZE); + return ES_WIFI_STATUS_OK; +} + +/** + * @brief Return API revision. + * @param Obj: pointer to module handle + * @param productID: pointer API revision. + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetAPIRev(ES_WIFIObject_t *Obj, uint8_t *APIRev) +{ + strncpy((char *)APIRev, (char *)Obj->API_Rev, ES_WIFI_API_REV_SIZE); + return ES_WIFI_STATUS_OK; +} + +/** + * @brief Return Stack Revision. + * @param Obj: pointer to module handle + * @param productID: pointer Stack Revision + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetStackRev(ES_WIFIObject_t *Obj, uint8_t *StackRev) +{ + strncpy((char *)StackRev, (char *)Obj->Stack_Rev, ES_WIFI_STACK_REV_SIZE); + return ES_WIFI_STATUS_OK; +} + +/** + * @brief Return RTOS Revision + * @param Obj: pointer to module handle + * @param productID: pointer RTOS Revision + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetRTOSRev(ES_WIFIObject_t *Obj, uint8_t *RTOSRev) +{ + strncpy((char *)RTOSRev, (char *)Obj->RTOS_Rev, ES_WIFI_RTOS_REV_SIZE); + return ES_WIFI_STATUS_OK; +} + + +/** + * @brief Initialize WIFI module. + * @param Obj: pointer to module handle + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_RegisterBusIO(ES_WIFIObject_t *Obj, IO_Init_Func IO_Init, + IO_DeInit_Func IO_DeInit, + IO_Delay_Func IO_Delay, + IO_Send_Func IO_Send, + IO_Receive_Func IO_Receive) +{ + if(!Obj || !IO_Init || !IO_DeInit || !IO_Send || !IO_Receive) + { + return ES_WIFI_STATUS_ERROR; + } + + Obj->fops.IO_Init = IO_Init; + Obj->fops.IO_Send = IO_Send; + Obj->fops.IO_Receive = IO_Receive; + Obj->fops.IO_Delay = IO_Delay; + + return ES_WIFI_STATUS_OK; +} + +/** + * @brief Change default Timeout. + * @param Obj: pointer to module handle + * @param Timeout: Timeout in mS + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_SetTimeout(ES_WIFIObject_t *Obj, uint32_t Timeout) +{ + Obj->Timeout = Timeout; + return ES_WIFI_STATUS_OK; +} + +/** + * @brief List all detected APs. + * @param Obj: pointer to module handle + * @param APs: pointer Access points structure + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_ListAccessPoints(ES_WIFIObject_t *Obj, ES_WIFI_APs_t *APs) +{ + + ES_WIFI_Status_t ret; + + ret = AT_ExecuteCommand(Obj,(uint8_t*)"F0\r", Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + AT_ParseAP((char *)Obj->CmdData, APs); + } + return ret; +} + +/** + * @brief Join an Access point. + * @param Obj: pointer to module handle + * @param Ssid: the access point id. + * @param Password: the Access point password. + * @param SecType: Security type. + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_Connect(ES_WIFIObject_t *Obj, const char* SSID, + const char* Password, + ES_WIFI_SecurityType_t SecType) +{ + ES_WIFI_Status_t ret; + + sprintf((char*)Obj->CmdData,"C1=%s\r", SSID); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"C2=%s\r", Password); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + Obj->Security = SecType; + sprintf((char*)Obj->CmdData,"C3=%d\r", (uint8_t)SecType); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"C0\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + Obj->NetSettings.IsConnected = 1; + } + } + } + } + return ret; +} + +/** + * @brief Check whether the module is connected to an access point. + * @retval Operation Status. + */ +uint8_t ES_WIFI_IsConnected(ES_WIFIObject_t *Obj) +{ + return Obj->NetSettings.IsConnected; +} +/** + * @brief Disconnect from a network. + * @param Obj: pointer to module handle + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_Disconnect(ES_WIFIObject_t *Obj) +{ + sprintf((char*)Obj->CmdData,"CD\r"); + return AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); +} +/** + * @brief Return network settings. + * @param Obj: pointer to module handle + * @param Pointer to network setting structure. + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetNetworkSettings(ES_WIFIObject_t *Obj) +{ + ES_WIFI_Status_t ret; + + sprintf((char*)Obj->CmdData,"C?\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + AT_ParseConnSettings((char *)Obj->CmdData, &Obj->NetSettings); + } + return ret; +} + +/** + * @brief retrn the MAC address of the es module. + * @param Obj: pointer to module handle + * @param mac: pointer to the MAC address array. + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetMACAddress(ES_WIFIObject_t *Obj, uint8_t *mac) +{ + ES_WIFI_Status_t ret ; + char *ptr; + + sprintf((char*)Obj->CmdData,"Z5\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + ptr = strtok((char *)(Obj->CmdData + 2), "\r\n"); + ParseMAC(ptr, mac) ; + } + return ret; +} + +/** + * @brief retrn the IP address of the es module. + * @param Obj: pointer to module handle + * @param mac: pointer to the IP address array. + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetIPAddress(ES_WIFIObject_t *Obj, uint8_t *ipaddr) +{ + memcpy(ipaddr, Obj->NetSettings.IP_Addr, 4); + return ES_WIFI_STATUS_OK; +} + +/** + * @brief Set the MAC address of the es module. + * @param Obj: pointer to module handle + * @param mac: pointer to the MAC address array. + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_SetMACAddress(ES_WIFIObject_t *Obj, uint8_t *mac) +{ + ES_WIFI_Status_t ret ; + + sprintf((char*)Obj->CmdData,"Z4=%X:%X:%X:%X:%X:%X\r",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5] ); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"Z1\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + } + return ret; +} + +/** + * @brief Reset To factory defaults. + * @param Obj: pointer to module handle + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_ResetToFactoryDefault(ES_WIFIObject_t *Obj) +{ + ES_WIFI_Status_t ret ; + + sprintf((char*)Obj->CmdData,"Z0\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + return ret; +} + +/** + * @brief Reset the module. + * @param Obj: pointer to module handle + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_ResetModule(ES_WIFIObject_t *Obj) +{ + ES_WIFI_Status_t ret ; + + sprintf((char*)Obj->CmdData,"ZR\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + return ret; +} + +/** + * @brief Set Product Name. + * @param Obj: pointer to module handle + * @param ProductName : pointer to product name string + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_SetProductName(ES_WIFIObject_t *Obj, uint8_t *ProductName) +{ + ES_WIFI_Status_t ret ; + + sprintf((char*)Obj->CmdData,"ZN=%s\r",ProductName); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"Z1\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + } + return ret; +} + +#if (ES_WIFI_USE_FIRMWAREUPDATE == 1) +/** + * @brief OTA Firmware Upgrade. + * @param Obj: pointer to module handle + * @param Upgrade link path + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_OTA_Upgrade(ES_WIFIObject_t *Obj, uint8_t *link) +{ + ES_WIFI_Status_t ret ; + + sprintf((char*)Obj->CmdData,"Z0=%d\r%s",strlen((char *)link), (char *)link); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + return ret; +} +#endif +#if (ES_WIFI_USE_UART == 1) +/** + * @brief Set UART Baud Rate. + * @param Obj: pointer to module handle + * @param UART BAud rate + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_SetUARTBaudRate(ES_WIFIObject_t *Obj, uint16_t BaudRate) +{ + ES_WIFI_Status_t ret ; + + sprintf((char*)Obj->CmdData,"U2=%d\r", BaudRate); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"U0\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + } + return ret; +} + +/** + * @brief Get UART Configuration. + * @param Obj: pointer to module handle + * @param pointer to UART config structure + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetUARTConfig(ES_WIFIObject_t *Obj, ES_WIFI_UARTConfig_t *pconf) +{ + ES_WIFI_Status_t ret ; + + sprintf((char*)Obj->CmdData,"U?\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + AT_ParseUARTConfig((char *)Obj->CmdData, pconf); + } + return ret; +} +#endif + +/** + * @brief Get System Configuration. + * @param Obj: pointer to module handle + * @param pointer to System config structure + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_GetSystemConfig(ES_WIFIObject_t *Obj, ES_WIFI_SystemConfig_t *pconf) +{ + ES_WIFI_Status_t ret ; + + sprintf((char*)Obj->CmdData,"Z?\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + AT_ParseSystemConfig((char *)Obj->CmdData, pconf); + } + return ret; +} + +#if (ES_WIFI_USE_PING == 1) +/** + * @brief Ping an IP address. + * @param Obj: pointer to module handle + * @param Ping: ping structure. + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_Ping(ES_WIFIObject_t *Obj, uint8_t *address, uint16_t count, uint16_t interval_ms) +{ + ES_WIFI_Status_t ret; + + sprintf((char*)Obj->CmdData,"T1=%d.%d.%d.%d\r", address[0],address[1], + address[2],address[3]); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + + sprintf((char*)Obj->CmdData,"T2=%d\r", count); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"T3=%d\r", interval_ms); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"T0=\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + } + } + } + + return ret; +} +#endif +/** + * @brief DNS Lookup to get IP address . + * @param Obj: pointer to module handle + * @param url: Domain Name. + * @param ipaddress: IP address. + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_DNS_LookUp(ES_WIFIObject_t *Obj, const char *url, uint8_t *ipaddress) +{ + ES_WIFI_Status_t ret; + char *ptr; + + sprintf((char*)Obj->CmdData,"D0=%s\r", url); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + ptr = strtok((char *)Obj->CmdData + 2, "\r"); + ParseIP(ptr, ipaddress); + } + return ret; +} + + +/** + * @brief Configure and Start a Client connection. + * @param Obj: pointer to module handle + * @param conn: pointer to the connection structure + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_StartClientConnection(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn) +{ + ES_WIFI_Status_t ret; + + sprintf((char*)Obj->CmdData,"P0=%d\r", conn->Number); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P1=%d\r", conn->Type); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + if ((conn->Type == ES_WIFI_UDP_CONNECTION) && (conn->LocalPort > 0)) + { + sprintf((char*)Obj->CmdData,"P2=%d\r", conn->RemotePort); + if(AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData) == ES_WIFI_STATUS_ERROR) + { + return ES_WIFI_STATUS_ERROR; + } + } + sprintf((char*)Obj->CmdData,"P4=%d\r", conn->RemotePort); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P3=%d.%d.%d.%d\r", conn->RemoteIP[0],conn->RemoteIP[1], + conn->RemoteIP[2],conn->RemoteIP[3]); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P6=1\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + } + } + } + } + return ret; +} + +/** + * @brief Stop Client connection. + * @param Obj: pointer to module handle + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_StopClientConnection(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn) +{ + ES_WIFI_Status_t ret; + + sprintf((char*)Obj->CmdData,"P0=%d\r", conn->Number); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P6=0\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + } + return ret; +} + +#if (ES_WIFI_USE_AWS == 1) +/** + * @brief Configure and Start a AWS Client connection. + * @param Obj: pointer to module handle + * @param conn: pointer to the connection structure + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_StartAWSClientConnection(ES_WIFIObject_t *Obj, ES_WIFI_AWS_Conn_t *conn) +{ + + ES_WIFI_Status_t ret; + + sprintf((char*)Obj->CmdData,"P0=%d\r", conn->Number); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P1=%d\r", conn->Type); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P4=%d\r", conn->RemotePort); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"PM=0,%s\r", conn->PublishTopic); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"PM=1,%s\r", conn->SubscribeTopic); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + + sprintf((char*)Obj->CmdData,"PM=2,%d\r", conn->MQTTMode); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"PM=5,%s\r", conn->ClientID); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"PM\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P6=1\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + } + } + } + } + } + } + } + } + } + return ret; +} +#endif +/** + * @brief Configure and Start a Server. + * @param Obj: pointer to module handle + * @param conn: pointer to the connection structure + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_StartServerSingleConn(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn) +{ + ES_WIFI_Status_t ret = ES_WIFI_STATUS_ERROR; + char *ptr; + + sprintf((char*)Obj->CmdData,"PK=1,3000\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P0=%d\r", conn->Number); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P1=%d\r", conn->Type); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P2=%d\r", conn->LocalPort); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P5=1\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { +#if (ES_WIFI_USE_UART == 1) + if(Obj->fops.IO_Receive(Obj->CmdData, 0, Obj->Timeout) > 0) + { + if(strstr((char *)Obj->CmdData, "Accepted")) + { + ptr = strtok((char *)Obj->CmdData + 2, " "); + ptr = strtok(NULL, " "); + ptr = strtok(NULL, " "); + ptr = strtok(NULL, ":"); + ParseIP((char *)ptr, conn->RemoteIP); + ret = ES_WIFI_STATUS_OK; + } + } +#else + do + { + sprintf((char*)Obj->CmdData,"MR\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + if((strstr((char *)Obj->CmdData, "[SOMA]")) && (strstr((char *)Obj->CmdData, "[EOMA]"))) + { + if(strstr((char *)Obj->CmdData, "Accepted")) + { + ptr = strtok((char *)Obj->CmdData + 2, " "); + ptr = strtok(NULL, " "); + ptr = strtok(NULL, " "); + ptr = strtok(NULL, ":"); + ParseIP((char *)ptr, conn->RemoteIP); + ret = ES_WIFI_STATUS_OK; + break; + } + } + } + else + { + ret = ES_WIFI_STATUS_ERROR; + break; + } + Obj->fops.IO_Delay(1000); + } while (1); +#endif + } + } + } + } + } + return ret; +} + +/** + * @brief Stop a Server. + * @param Obj: pointer to module handle + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_StopServerSingleConn(ES_WIFIObject_t *Obj) +{ + sprintf((char*)Obj->CmdData,"P5=0\r"); + return AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); +} + + +/** + * @brief Configure and Start a Server. + * @param Obj: pointer to module handle + * @param conn: pointer to the connection structure + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_StartServerMultiConn(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn) +{ + ES_WIFI_Status_t ret = ES_WIFI_STATUS_ERROR; + char *ptr; + + sprintf((char*)Obj->CmdData,"PK=1,3000\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P0=%d\r", conn->Number); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P1=%d\r", conn->Type); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P2=%d\r", conn->LocalPort); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P8=6\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P5=1\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { +#if (ES_WIFI_USE_UART == 1) + if(Obj->fops.IO_Receive(Obj->CmdData, 0, Obj->Timeout) > 0) + { + if(strstr((char *)Obj->CmdData, "Accepted")) + { + ptr = strtok((char *)Obj->CmdData + 2, " "); + ptr = strtok(NULL, " "); + ptr = strtok(NULL, " "); + ptr = strtok(NULL, ":"); + ParseIP((char *)ptr, conn->RemoteIP); + ret = ES_WIFI_STATUS_OK; + } + } +#else + do + { + sprintf((char*)Obj->CmdData,"MR\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + if((strstr((char *)Obj->CmdData, "[SOMA]")) && (strstr((char *)Obj->CmdData, "[EOMA]"))) + { + if(strstr((char *)Obj->CmdData, "Accepted")) + { + ptr = strtok((char *)Obj->CmdData + 2, " "); + ptr = strtok(NULL, " "); + ptr = strtok(NULL, " "); + ptr = strtok(NULL, ":"); + ParseIP((char *)ptr, conn->RemoteIP); + ret = ES_WIFI_STATUS_OK; + break; + } + } + } + else + { + ret = ES_WIFI_STATUS_ERROR; + break; + } + Obj->fops.IO_Delay(1000); + } while (1); +#endif + } + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"P7=1\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + } + } + } + } + } + } + return ret; +} + +/** + * @brief Stop a Server. + * @param Obj: pointer to module handle + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_StopServerMultiConn(ES_WIFIObject_t *Obj) +{ + ES_WIFI_Status_t ret = ES_WIFI_STATUS_ERROR; + + /* close the socket handle for the current request. */ + sprintf((char*)Obj->CmdData,"P7=2\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + /*Get the next request out of the queue */ + sprintf((char*)Obj->CmdData,"P7=3\r"); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + if(ret == ES_WIFI_STATUS_OK) + { + if(Obj->fops.IO_Receive(Obj->CmdData, 0, Obj->Timeout) > 0) + { + if(strstr((char *)Obj->CmdData, "Accepted")) + { + ret = ES_WIFI_STATUS_OK; + } + } + } + } + } + return ret; +} +/** + * @brief Send an amount data over WIFI. + * @param Obj: pointer to module handle + * @param Socket: number of the socket + * @param pdata: pointer to data + * @param len : length of the data to be sent + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_SendData(ES_WIFIObject_t *Obj, uint8_t Socket, uint8_t *pdata, uint16_t Reqlen , uint16_t *SentLen , uint32_t Timeout) +{ + ES_WIFI_Status_t ret = ES_WIFI_STATUS_ERROR; + + if(Reqlen >= ES_WIFI_PAYLOAD_SIZE ) Reqlen= ES_WIFI_PAYLOAD_SIZE; + + *SentLen = Reqlen; + sprintf((char*)Obj->CmdData,"P0=%d\r", Socket); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"S2=%lu\r",Timeout); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char *)Obj->CmdData,"S3=%04d\r",Reqlen); + ret = AT_RequestSendData(Obj, Obj->CmdData, pdata, Reqlen, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + if(strstr((char *)Obj->CmdData,"-1\r\n")) + { + ret = ES_WIFI_STATUS_ERROR; + } + } + } + } + + if (ret == ES_WIFI_STATUS_ERROR) *SentLen = 0; + return ret; +} + +/** + * @brief Receive an amount data over WIFI. + * @param Obj: pointer to module handle + * @param Socket: number of the socket + * @param pdata: pointer to data + * @param len : pointer to the length of the data to be received + * @retval Operation Status. + */ +ES_WIFI_Status_t ES_WIFI_ReceiveData(ES_WIFIObject_t *Obj, uint8_t Socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *Receivedlen, uint32_t Timeout) +{ + ES_WIFI_Status_t ret = ES_WIFI_STATUS_ERROR; + + if(Reqlen <= ES_WIFI_PAYLOAD_SIZE ) + { + sprintf((char*)Obj->CmdData,"P0=%d\r", Socket); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"R1=%d\r", Reqlen); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"R2=%lu\r", Timeout); + ret = AT_ExecuteCommand(Obj, Obj->CmdData, Obj->CmdData); + if(ret == ES_WIFI_STATUS_OK) + { + sprintf((char*)Obj->CmdData,"R0=\r"); + ret = AT_RequestReceiveData(Obj, Obj->CmdData, (char *)pdata, Reqlen, Receivedlen); + } + } + else + { + *Receivedlen = 0; + } + } + } + return ret; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/es_wifi.h b/examples/stm32cube-hal-wifi-client/src/es_wifi.h new file mode 100644 index 00000000..e267c46a --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/es_wifi.h @@ -0,0 +1,305 @@ +/** + ****************************************************************************** + * @file es-wifi.h + * @author MCD Application Team + * @brief header file for the es-wifi module. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __ES_WIFI_H +#define __ES_WIFI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stdint.h" +#include "string.h" +#include "stdio.h" +#include "es_wifi_conf.h" + +/* Exported Constants --------------------------------------------------------*/ +#define ES_WIFI_PAYLOAD_SIZE 1200 +/* Exported macro-------------------------------------------------------------*/ +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +typedef int8_t (*IO_Init_Func)( void); +typedef int8_t (*IO_DeInit_Func)( void); +typedef void (*IO_Delay_Func)(uint32_t); +typedef int16_t (*IO_Send_Func)( uint8_t *, uint16_t len, uint32_t); +typedef int16_t (*IO_Receive_Func)(uint8_t *, uint16_t len, uint32_t); + +/* Exported typedef ----------------------------------------------------------*/ +typedef enum { + ES_WIFI_STATUS_OK = 0, + ES_WIFI_STATUS_REQ_DATA_STAGE = 1, + ES_WIFI_STATUS_ERROR = 2, + ES_WIFI_STATUS_TIMEOUT = 3, + ES_WIFI_STATUS_IO_ERROR = 4, +}ES_WIFI_Status_t; + +typedef enum { + ES_WIFI_MODE_SINGLE = 0, + ES_WIFI_MODE_MULTI = 1, +}ES_WIFI_ConnMode_t; + +typedef enum { + ES_WIFI_TCP_CONNECTION = 0, + ES_WIFI_UDP_CONNECTION = 1, + ES_WIFI_UDP_LITE_CONNECTION = 2, + ES_WIFI_TCP_SSL_CONNECTION = 3, + ES_WIFI_MQTT_CONNECTION = 4, +}ES_WIFI_ConnType_t; + +/* Security settings for wifi network */ +typedef enum { + ES_WIFI_SEC_OPEN = 0x00, /*!< Wifi is open */ + ES_WIFI_SEC_WEP = 0x01, /*!< Wired Equivalent Privacy option for wifi security. \note This mode can't be used when setting up ES_WIFI wifi */ + ES_WIFI_SEC_WPA = 0x02, /*!< Wi-Fi Protected Access */ + ES_WIFI_SEC_WPA2 = 0x03, /*!< Wi-Fi Protected Access 2 */ + ES_WIFI_SEC_WPA_WPA2= 0x04, /*!< Wi-Fi Protected Access with both modes */ + ES_WIFI_SEC_WPA2_TKIP= 0x05, /*!< Wi-Fi Protected Access with both modes */ + ES_WIFI_SEC_UNKNOWN = 0xFF, /*!< Wi-Fi Unknown Security mode */ +} ES_WIFI_SecurityType_t; + +typedef enum { + ES_WIFI_IPV4 = 0x00, + ES_WIFI_IPV6 = 0x01, +} ES_WIFI_IPVer_t; + +typedef enum { + ES_WIFI_AP_NONE = 0x00, + ES_WIFI_AP_ASSIGNED = 0x01, + ES_WIFI_AP_JOINED = 0x02, + ES_WIFI_AP_ERROR = 0xFF, +} ES_WIFI_APState_t; + + +typedef struct +{ + uint32_t Port; + uint32_t BaudRate; + uint32_t DataWidth; + uint32_t Parity; + uint32_t StopBits; + uint32_t Mode; + +}ES_WIFI_UARTConfig_t; + + +typedef struct +{ + uint32_t Configuration; + uint32_t WPSPin; + uint32_t VID; + uint32_t PID; + uint8_t MAC[6]; + uint8_t AP_IPAddress[4]; + uint32_t PS_Mode; + uint32_t RadioMode; + uint32_t CurrentBeacon; + uint32_t PrevBeacon; + uint32_t ProductName; + +}ES_WIFI_SystemConfig_t; + +typedef struct { + uint8_t* Address; /*!< Pointer to domain or IP to ping */ + uint32_t Time; /*!< Time in milliseconds needed for pinging */ + uint8_t Success; /*!< Status indicates if ping was successful */ +}ES_WIFI_Ping_t; + +typedef struct { + uint8_t SSID[ES_WIFI_MAX_SSID_NAME_SIZE + 1]; /*!< Service Set Identifier value.Wi-Fi spot name */ + ES_WIFI_SecurityType_t Security; /*!< Security of Wi-Fi spot. */ + int16_t RSSI; /*!< Signal strength of Wi-Fi spot */ + uint8_t MAC[6]; /*!< MAC address of spot */ + uint8_t Channel; /*!< Wi-Fi channel */ +} ES_WIFI_AP_t; + +/* Access point configuration */ +typedef struct { + uint8_t SSID[ES_WIFI_MAX_SSID_NAME_SIZE + 1]; /*!< Network public name for ESP AP mode */ + uint8_t Pass[ES_WIFI_MAX_PSWD_NAME_SIZE + 1]; /*!< Network password for ESP AP mode */ + ES_WIFI_SecurityType_t Security; /*!< Security of Wi-Fi spot. This parameter can be a value of \ref ESP8266_Ecn_t enumeration */ + uint8_t Channel; /*!< Channel Wi-Fi is operating at */ + uint8_t MaxConnections; /*!< Max number of stations that are allowed to connect to ESP AP, between 1 and 4 */ + uint8_t Hidden; /*!< Set to 1 if network is hidden (not broadcast) or zero if noz */ +} ES_WIFI_APConfig_t; + + +typedef struct { + uint8_t SSID[ES_WIFI_MAX_SSID_NAME_SIZE + 1]; /*!< Network public name for ESP AP mode */ + uint8_t IP_Addr[4]; /*!< IP Address */ + uint8_t MAC_Addr[6]; /*!< MAC address */ +} ES_WIFI_APSettings_t; + +typedef struct { + ES_WIFI_AP_t AP[ES_WIFI_MAX_DETECTED_AP]; + uint8_t nbr; + +}ES_WIFI_APs_t; + +typedef struct { + uint8_t SSID[ES_WIFI_MAX_SSID_NAME_SIZE + 1]; + uint8_t pswd[ES_WIFI_MAX_PSWD_NAME_SIZE + 1]; + ES_WIFI_SecurityType_t Security; + uint8_t DHCP_IsEnabled; + uint8_t JoinRetries; + uint8_t IsConnected; + uint8_t AutoConnect; + ES_WIFI_IPVer_t IP_Ver; + uint8_t IP_Addr[4]; + uint8_t IP_Mask[4]; + uint8_t Gateway_Addr[4]; + uint8_t DNS1[4]; + uint8_t DNS2[4]; +} ES_WIFI_Network_t; + +#if (ES_WIFI_USE_AWS == 1) +typedef struct { + ES_WIFI_ConnType_t Type; + uint8_t Number; + uint16_t RemotePort; + uint8_t RemoteIP[4]; + uint8_t *PublishTopic; + uint8_t *SubscribeTopic; + uint8_t *ClientID; + uint8_t MQTTMode; +} ES_WIFI_AWS_Conn_t; +#endif + +typedef struct { + ES_WIFI_ConnType_t Type; + uint8_t Number; + uint16_t RemotePort; + uint16_t LocalPort; + uint8_t RemoteIP[4]; + char* Name; +} ES_WIFI_Conn_t; + +typedef struct { + IO_Init_Func IO_Init; + IO_DeInit_Func IO_DeInit; + IO_Delay_Func IO_Delay; + IO_Send_Func IO_Send; + IO_Receive_Func IO_Receive; +} ES_WIFI_IO_t; + +typedef struct { + uint8_t Product_ID[ES_WIFI_PRODUCT_ID_SIZE]; + uint8_t FW_Rev[ES_WIFI_FW_REV_SIZE]; + uint8_t API_Rev[ES_WIFI_API_REV_SIZE]; + uint8_t Stack_Rev[ES_WIFI_STACK_REV_SIZE]; + uint8_t RTOS_Rev[ES_WIFI_RTOS_REV_SIZE]; + uint8_t Product_Name[ES_WIFI_PRODUCT_NAME_SIZE]; + uint32_t CPU_Clock; + ES_WIFI_SecurityType_t Security; + ES_WIFI_Network_t NetSettings; + ES_WIFI_APSettings_t APSettings; + ES_WIFI_IO_t fops; + uint8_t CmdData[ES_WIFI_DATA_SIZE]; + uint32_t Timeout; + uint32_t BufferSize; +}ES_WIFIObject_t; + + +/* Exported functions --------------------------------------------------------*/ +ES_WIFI_Status_t ES_WIFI_Init(ES_WIFIObject_t *Obj); +ES_WIFI_Status_t ES_WIFI_SetTimeout(ES_WIFIObject_t *Obj, uint32_t Timeout); +ES_WIFI_Status_t ES_WIFI_ListAccessPoints(ES_WIFIObject_t *Obj, ES_WIFI_APs_t *APs); +ES_WIFI_Status_t ES_WIFI_Connect(ES_WIFIObject_t *Obj, const char* SSID, const char* Password, + ES_WIFI_SecurityType_t SecType); +ES_WIFI_Status_t ES_WIFI_Disconnect(ES_WIFIObject_t *Obj); +uint8_t ES_WIFI_IsConnected(ES_WIFIObject_t *Obj); +ES_WIFI_Status_t ES_WIFI_GetNetworkSettings(ES_WIFIObject_t *Obj); +ES_WIFI_Status_t ES_WIFI_GetMACAddress(ES_WIFIObject_t *Obj, uint8_t *mac); +ES_WIFI_Status_t ES_WIFI_GetIPAddress(ES_WIFIObject_t *Obj, uint8_t *ipaddr); +ES_WIFI_Status_t ES_WIFI_GetProductID(ES_WIFIObject_t *Obj, uint8_t *productID); +ES_WIFI_Status_t ES_WIFI_GetFWRevID(ES_WIFIObject_t *Obj, uint8_t *FWRev); +ES_WIFI_Status_t ES_WIFI_GetRTOSRev(ES_WIFIObject_t *Obj, uint8_t *RTOSRev); +ES_WIFI_Status_t ES_WIFI_GetProductName(ES_WIFIObject_t *Obj, uint8_t *productName); +ES_WIFI_Status_t ES_WIFI_GetAPIRev(ES_WIFIObject_t *Obj, uint8_t *APIRev); +ES_WIFI_Status_t ES_WIFI_GetStackRev(ES_WIFIObject_t *Obj, uint8_t *StackRev); + + +ES_WIFI_Status_t ES_WIFI_SetMACAddress(ES_WIFIObject_t *Obj, uint8_t *mac); +ES_WIFI_Status_t ES_WIFI_ResetToFactoryDefault(ES_WIFIObject_t *Obj); +ES_WIFI_Status_t ES_WIFI_ResetModule(ES_WIFIObject_t *Obj); +ES_WIFI_Status_t ES_WIFI_SetProductName(ES_WIFIObject_t *Obj, uint8_t *ProductName); +#if (ES_WIFI_USE_PING == 1) +ES_WIFI_Status_t ES_WIFI_Ping(ES_WIFIObject_t *Obj, uint8_t *address, uint16_t count, uint16_t interval_ms); +#endif +ES_WIFI_Status_t ES_WIFI_DNS_LookUp(ES_WIFIObject_t *Obj, const char *url, uint8_t *ipaddress); +ES_WIFI_Status_t ES_WIFI_StartClientConnection(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn); +ES_WIFI_Status_t ES_WIFI_StopClientConnection(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn); +#if (ES_WIFI_USE_AWS == 1) +ES_WIFI_Status_t ES_WIFI_StartAWSClientConnection(ES_WIFIObject_t *Obj, ES_WIFI_AWS_Conn_t *conn); +#endif +ES_WIFI_Status_t ES_WIFI_StartServerSingleConn(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn); +ES_WIFI_Status_t ES_WIFI_StopServerSingleConn(ES_WIFIObject_t *Obj); +ES_WIFI_Status_t ES_WIFI_StartServerMultiConn(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn); +ES_WIFI_Status_t ES_WIFI_StopServerMultiConn(ES_WIFIObject_t *Obj); +ES_WIFI_Status_t ES_WIFI_SendData(ES_WIFIObject_t *Obj, uint8_t Socket, uint8_t *pdata, uint16_t Reqlen , uint16_t *SentLen, uint32_t timeout); +ES_WIFI_Status_t ES_WIFI_ReceiveData(ES_WIFIObject_t *Obj, uint8_t Socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *Receivedlen, uint32_t timeout); + +#if (ES_WIFI_USE_FIRMWAREUPDATE == 1) +ES_WIFI_Status_t ES_WIFI_OTA_Upgrade(ES_WIFIObject_t *Obj, uint8_t *link); +#endif + +#if (ES_WIFI_USE_UART == 1) +ES_WIFI_Status_t ES_WIFI_SetUARTBaudRate(ES_WIFIObject_t *Obj, uint16_t BaudRate); +ES_WIFI_Status_t ES_WIFI_GetUARTConfig(ES_WIFIObject_t *Obj, ES_WIFI_UARTConfig_t *pconf); +#endif + +ES_WIFI_Status_t ES_WIFI_GetSystemConfig(ES_WIFIObject_t *Obj, ES_WIFI_SystemConfig_t *pconf); + +ES_WIFI_Status_t ES_WIFI_RegisterBusIO(ES_WIFIObject_t *Obj, IO_Init_Func IO_Init, + IO_DeInit_Func IO_DeInit, + IO_Delay_Func IO_Delay, + IO_Send_Func IO_Send, + IO_Receive_Func IO_Receive); +#ifdef __cplusplus +} +#endif +#endif /*__ES_WIFI_H*/ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/es_wifi_conf.h b/examples/stm32cube-hal-wifi-client/src/es_wifi_conf.h new file mode 100644 index 00000000..6a4328e3 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/es_wifi_conf.h @@ -0,0 +1,85 @@ +/** + ****************************************************************************** + * @file Wifi/WiFi_Client_Server/Inc/es_wifi_conf.h + * @author MCD Application Team + * @brief es-wifi configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +#ifndef __ES_WIFI_CONF_H +#define __ES_WIFI_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ + +/* Exported constants --------------------------------------------------------*/ +#define ES_WIFI_MAX_SSID_NAME_SIZE 32 +#define ES_WIFI_MAX_PSWD_NAME_SIZE 32 +#define ES_WIFI_PRODUCT_ID_SIZE 32 +#define ES_WIFI_PRODUCT_NAME_SIZE 32 +#define ES_WIFI_FW_REV_SIZE 16 +#define ES_WIFI_API_REV_SIZE 16 +#define ES_WIFI_STACK_REV_SIZE 16 +#define ES_WIFI_RTOS_REV_SIZE 16 + +#define ES_WIFI_DATA_SIZE 1600 +#define ES_WIFI_MAX_DETECTED_AP 10 + +#define ES_WIFI_TIMEOUT 0xFFFF + +#define ES_WIFI_USE_PING 1 +#define ES_WIFI_USE_AWS 0 +#define ES_WIFI_USE_FIRMWAREUPDATE 0 +#define ES_WIFI_USE_WPS 0 + +#define ES_WIFI_USE_SPI 1 +#define ES_WIFI_USE_UART (!ES_WIFI_USE_SPI) + + + +#ifdef __cplusplus +} +#endif +#endif /* __ES_WIFI_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/es_wifi_conf_template.h b/examples/stm32cube-hal-wifi-client/src/es_wifi_conf_template.h new file mode 100644 index 00000000..392c656e --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/es_wifi_conf_template.h @@ -0,0 +1,85 @@ +/** + ****************************************************************************** + * @file es_wifi_conf_template.h + * @author MCD Application Team + * @brief es-wifi configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +#ifndef __ES_WIFI_CONF_H +#define __ES_WIFI_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ + +/* Exported constants --------------------------------------------------------*/ +#define ES_WIFI_MAX_SSID_NAME_SIZE 32 +#define ES_WIFI_MAX_PSWD_NAME_SIZE 32 +#define ES_WIFI_PRODUCT_ID_SIZE 32 +#define ES_WIFI_PRODUCT_NAME_SIZE 32 +#define ES_WIFI_FW_REV_SIZE 16 +#define ES_WIFI_API_REV_SIZE 16 +#define ES_WIFI_STACK_REV_SIZE 16 +#define ES_WIFI_RTOS_REV_SIZE 16 + +#define ES_WIFI_DATA_SIZE 1600 +#define ES_WIFI_MAX_DETECTED_AP 10 + +#define ES_WIFI_TIMEOUT 0xFFFF + +#define ES_WIFI_USE_PING 1 +#define ES_WIFI_USE_AWS 0 +#define ES_WIFI_USE_FIRMWAREUPDATE 0 +#define ES_WIFI_USE_WPS 0 + +#define ES_WIFI_USE_SPI 0 +#define ES_WIFI_USE_UART (!ES_WIFI_USE_SPI) + + + +#ifdef __cplusplus +} +#endif +#endif /* __ES_WIFI_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/es_wifi_io.c b/examples/stm32cube-hal-wifi-client/src/es_wifi_io.c new file mode 100644 index 00000000..fee875ec --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/es_wifi_io.c @@ -0,0 +1,294 @@ +/** + ****************************************************************************** + * @file es_wifi_io.c + * @author MCD Application Team + * @brief This file implments the IO operations to deal with the es-wifi + * module. It mainly Inits and Deinits the SPI interface. Send and + * receive data over it. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "es_wifi_io.h" +#include + +/* Private define ------------------------------------------------------------*/ +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +/* Private typedef -----------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +SPI_HandleTypeDef hspi; + +/* Private function prototypes -----------------------------------------------*/ + +/* Private functions ---------------------------------------------------------*/ +/******************************************************************************* + COM Driver Interface (SPI) +*******************************************************************************/ +/** + * @brief Initialize SPI MSP + * @param hspi: SPI handle + * @retval None + */ +void SPI_WIFI_MspInit(SPI_HandleTypeDef* hspi) +{ + + GPIO_InitTypeDef GPIO_Init; + + __HAL_RCC_SPI3_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + + /* configure Wake up pin */ + HAL_GPIO_WritePin( GPIOB, GPIO_PIN_15, GPIO_PIN_RESET ); + GPIO_Init.Pin = GPIO_PIN_15; + GPIO_Init.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_Init.Pull = GPIO_NOPULL; + GPIO_Init.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init( GPIOB, &GPIO_Init ); + + /* configure Data ready pin */ + GPIO_Init.Pin = GPIO_PIN_12; + GPIO_Init.Mode = GPIO_MODE_IT_RISING; + GPIO_Init.Pull = GPIO_NOPULL; + GPIO_Init.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init( GPIOG, &GPIO_Init ); + + /* configure Reset pin */ + GPIO_Init.Pin = GPIO_PIN_1; + GPIO_Init.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_Init.Pull = GPIO_NOPULL; + GPIO_Init.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_Init.Alternate = 0; + HAL_GPIO_Init( GPIOH, &GPIO_Init ); + + /* configure SPI NSS pin pin */ + HAL_GPIO_WritePin( GPIOG, GPIO_PIN_11, GPIO_PIN_SET ); + GPIO_Init.Pin = GPIO_PIN_11; + GPIO_Init.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_Init.Pull = GPIO_NOPULL; + GPIO_Init.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init( GPIOG, &GPIO_Init ); + + /* configure SPI CLK pin */ + GPIO_Init.Pin = GPIO_PIN_12; + GPIO_Init.Mode = GPIO_MODE_AF_PP; + GPIO_Init.Pull = GPIO_NOPULL; + GPIO_Init.Speed = GPIO_SPEED_FREQ_MEDIUM; + GPIO_Init.Alternate = GPIO_AF7_SPI3; + HAL_GPIO_Init( GPIOB, &GPIO_Init ); + + /* configure SPI MOSI pin */ + GPIO_Init.Pin = GPIO_PIN_5; + GPIO_Init.Mode = GPIO_MODE_AF_PP; + GPIO_Init.Pull = GPIO_NOPULL; + GPIO_Init.Speed = GPIO_SPEED_FREQ_MEDIUM; + GPIO_Init.Alternate = GPIO_AF6_SPI3; + HAL_GPIO_Init( GPIOB, &GPIO_Init ); + + /* configure SPI MISO pin */ + GPIO_Init.Pin = GPIO_PIN_4; + GPIO_Init.Mode = GPIO_MODE_AF_PP; + GPIO_Init.Pull = GPIO_PULLUP; + GPIO_Init.Speed = GPIO_SPEED_FREQ_MEDIUM; + GPIO_Init.Alternate = GPIO_AF6_SPI3; + HAL_GPIO_Init( GPIOB, &GPIO_Init ); +} + +/** + * @brief Initialize the SPI3 + * @param None + * @retval None + */ +int8_t SPI_WIFI_Init(void) +{ + uint32_t tickstart = HAL_GetTick(); + uint8_t Prompt[6]; + uint8_t count = 0; + HAL_StatusTypeDef Status; + + hspi.Instance = SPI3; + SPI_WIFI_MspInit(&hspi); + + hspi.Init.Mode = SPI_MODE_MASTER; + hspi.Init.Direction = SPI_DIRECTION_2LINES; + hspi.Init.DataSize = SPI_DATASIZE_16BIT; + hspi.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi.Init.NSS = SPI_NSS_SOFT; + hspi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4; /* 50/4= 12.5MHz (Inventek WIFI module supportes up to 20MHz)*/ + hspi.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi.Init.TIMode = SPI_TIMODE_DISABLE; + hspi.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi.Init.CRCPolynomial = 0; + + HAL_SPI_Init( &hspi ); + + WIFI_RESET_MODULE(); + + WIFI_ENABLE_NSS(); + + while (WIFI_IS_CMDDATA_READY()) + { + Status = HAL_SPI_Receive(&hspi , &Prompt[count], 1, 0xFFFF); + count += 2; + if(((HAL_GetTick() - tickstart ) > 0xFFFF) || (Status != HAL_OK)) + { + WIFI_DISABLE_NSS(); + return -1; + } + } + + if((Prompt[0] != 0x15) ||(Prompt[1] != 0x15) ||(Prompt[2] != '\r')|| + (Prompt[3] != '\n') ||(Prompt[4] != '>') ||(Prompt[5] != ' ')) + { + WIFI_DISABLE_NSS(); + return -1; + } + + WIFI_DISABLE_NSS(); + return 0; +} + +/** + * @brief Initialize the UART1 + * @param None + * @retval None + */ +int8_t SPI_WIFI_DeInit(void) +{ + HAL_SPI_DeInit( &hspi ); + return 0; +} + +/** + * @brief Receive wifi Data from SPI + * @param Pdata : pointer to data + * @retval Length of received data (payload) + */ +int16_t SPI_WIFI_ReceiveData(uint8_t *pData, uint16_t len, uint32_t timeout) +{ + uint32_t tickstart = HAL_GetTick(); + int16_t length = 0; + + WIFI_DISABLE_NSS(); + + while (!WIFI_IS_CMDDATA_READY()) + { + if((HAL_GetTick() - tickstart ) > timeout) + { + return -1; + } + } + + WIFI_ENABLE_NSS(); + + while (WIFI_IS_CMDDATA_READY()) + { + if((length < len) || (!len)) + { + HAL_SPI_Receive(&hspi, pData, 1, timeout) ; + length += 2; + pData += 2; + + if((HAL_GetTick() - tickstart ) > timeout) + { + WIFI_DISABLE_NSS(); + return -1; + } + } + else + { + break; + } + } + + if(*(--pData) == 0x15) + { + length--; + } + + WIFI_DISABLE_NSS(); + return length; +} + +/** + * @brief Send wifi Data thru SPI + * @param Pdata : pointer to data + * @retval Length of sent data + */ +int16_t SPI_WIFI_SendData( uint8_t *pdata, uint16_t len, uint32_t timeout) +{ + uint32_t tickstart = HAL_GetTick(); + + while (!WIFI_IS_CMDDATA_READY()) + { + if((HAL_GetTick() - tickstart ) > timeout) + { + return -1; + } + } + + WIFI_ENABLE_NSS(); + + if(len & 0x1) + { + pdata[len] = '\n'; + } + if( HAL_SPI_Transmit(&hspi, (uint8_t *)pdata , (len+1)/2, timeout) != HAL_OK) + { + return -1; + } + pdata[len] = 0; + return len; +} + +/** + * @brief Delay + * @param Delay in ms + * @retval None + */ +void SPI_WIFI_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/es_wifi_io.h b/examples/stm32cube-hal-wifi-client/src/es_wifi_io.h new file mode 100644 index 00000000..71822b63 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/es_wifi_io.h @@ -0,0 +1,84 @@ +/** + ****************************************************************************** + * @file es_wifi_io.h + * @author MCD Application Team + * @brief This file contains the functions prototypes for es_wifi IO operations. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +#ifndef __WIFI_IO__ +#define __WIFI_IO__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx.h" + +/* Exported constants --------------------------------------------------------*/ + +/* Exported macro ------------------------------------------------------------*/ +#define WIFI_RESET_MODULE() do{\ + HAL_GPIO_WritePin(GPIOH, GPIO_PIN_1, GPIO_PIN_RESET );\ + HAL_Delay(10);\ + HAL_GPIO_WritePin( GPIOH, GPIO_PIN_1, GPIO_PIN_SET );\ + HAL_Delay(500);\ + }while(0); + + +#define WIFI_ENABLE_NSS() do{ \ + HAL_GPIO_WritePin( GPIOG, GPIO_PIN_11, GPIO_PIN_RESET );\ + HAL_Delay(10);\ + }while(0); + +#define WIFI_DISABLE_NSS() do{ \ + HAL_GPIO_WritePin( GPIOG, GPIO_PIN_11, GPIO_PIN_SET );\ + HAL_Delay(10);\ + }while(0); + +#define WIFI_IS_CMDDATA_READY() (HAL_GPIO_ReadPin(GPIOG, GPIO_PIN_12) == GPIO_PIN_SET) + + + +/* Exported functions ------------------------------------------------------- */ +void SPI_WIFI_MspInit(SPI_HandleTypeDef* hspi); +int8_t SPI_WIFI_DeInit(void); +int8_t SPI_WIFI_Init(void); +int16_t SPI_WIFI_ReceiveData(uint8_t *pData, uint16_t len, uint32_t timeout); +int16_t SPI_WIFI_SendData( uint8_t *pData, uint16_t len, uint32_t timeout); +void SPI_WIFI_Delay(uint32_t Delay); + +#ifdef __cplusplus +} +#endif + +#endif /* __WIFI_IO__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/main.c b/examples/stm32cube-hal-wifi-client/src/main.c new file mode 100644 index 00000000..0d3fd7d0 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/main.c @@ -0,0 +1,348 @@ +/** + ****************************************************************************** + * @file Wifi/WiFi_Client_Server/src/main.c + * @author MCD Application Team + * @brief This file provides main program functions + ****************************************************************************** + * @attention + * + *

© Copyright © 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* Private defines -----------------------------------------------------------*/ +/* Update SSID and PASSWORD with own Access point settings */ +#define SSID "MySSID" +#define PASSWORD "MyPassword" + +#define LCD_USE + +#define CONNECTION_TRIAL_MAX 10 +/* Private variables ---------------------------------------------------------*/ +const uint8_t RemoteIP[] = {192,168,43, 246}; +uint8_t RxData [500]; + +uint8_t TxData[] = "STM32 : Hello!\n"; +uint16_t RxLen; +uint8_t MAC_Addr[6]; +uint8_t IP_Addr[4]; +/* Private function prototypes -----------------------------------------------*/ +static void SystemClock_Config(void); + +/* Private functions ---------------------------------------------------------*/ + +/** + * @brief Main program + * @param None + * @retval None + */ +int main(void) +{ + int32_t Socket = -1; + uint16_t Datalen; + uint16_t Trials = CONNECTION_TRIAL_MAX; +#if defined (LCD_USE) + uint8_t modulestr[20] = {0}; +#endif /* LCD_USE */ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* Configure the system clock */ + SystemClock_Config(); + /* Configure LED4 */ + BSP_LED_Init(LED4); +#if defined (LCD_USE) + BSP_LCD_InitEx(LCD_ORIENTATION_LANDSCAPE_ROT180); + BSP_LCD_DisplayOn(); + BSP_LCD_Clear(LCD_COLOR_WHITE); + + BSP_LCD_Clear(LCD_COLOR_WHITE); + BSP_LCD_SetBackColor(LCD_COLOR_BLUE); + + BSP_LCD_SetTextColor(LCD_COLOR_BLUE); + BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), (BSP_LCD_GetYSize() -200)); + + BSP_LCD_SetFont(&Font12); + BSP_LCD_SetTextColor(LCD_COLOR_WHITE); + BSP_LCD_DisplayStringAt(10, 10, (uint8_t *)"ES-WIFI Module in TCP", CENTER_MODE ); + BSP_LCD_DisplayStringAt(10, 23, (uint8_t *)"Client mode demonstration", CENTER_MODE ); + BSP_LCD_SetBackColor(LCD_COLOR_WHITE); + BSP_LCD_SetTextColor(LCD_COLOR_BLACK); + BSP_LCD_DisplayStringAtLine(4, (uint8_t *)"TCP Client Instructions:"); + BSP_LCD_DisplayStringAtLine(6, (uint8_t *)"1-Make sure your Phone connected "); + BSP_LCD_DisplayStringAtLine(7, (uint8_t *)"to the network that you configured"); + BSP_LCD_DisplayStringAtLine(8, (uint8_t *)"using Configuration AccessPoint."); + BSP_LCD_DisplayStringAtLine(10,(uint8_t *)"2-Create a server by using the "); + BSP_LCD_DisplayStringAtLine(11,(uint8_t *)"android application TCP Server"); + BSP_LCD_DisplayStringAtLine(12,(uint8_t *)"with port(8002)."); + BSP_LCD_DisplayStringAtLine(14,(uint8_t *)"3-Get the Network Name or IP Address"); + BSP_LCD_DisplayStringAtLine(15,(uint8_t *)"of your Android from the step 2."); + + HAL_Delay(2000); +#endif /* LCD_USE */ + /*Initialize WIFI module */ + if(WIFI_Init() == WIFI_STATUS_OK) + { +#if defined (LCD_USE) + BSP_LCD_Clear(LCD_COLOR_WHITE); + BSP_LCD_SetBackColor(LCD_COLOR_BLUE); + + BSP_LCD_SetTextColor(LCD_COLOR_BLUE); + BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), (BSP_LCD_GetYSize() -200)); + + BSP_LCD_SetFont(&Font12); + BSP_LCD_SetTextColor(LCD_COLOR_WHITE); + BSP_LCD_DisplayStringAt(10, 10, (uint8_t *)"ES-WIFI Module in TCP", CENTER_MODE ); + BSP_LCD_DisplayStringAt(10, 23, (uint8_t *)"Client mode demonstration", CENTER_MODE ); + + BSP_LCD_SetBackColor(LCD_COLOR_WHITE); + BSP_LCD_SetTextColor(LCD_COLOR_BLUE); + BSP_LCD_DisplayStringAtLine(7, (uint8_t *)"ES-WIFI Module Initialized."); +#endif /* LCD_USE */ + if(WIFI_GetMAC_Address(MAC_Addr) == WIFI_STATUS_OK) + { +#if defined (LCD_USE) + BSP_LCD_SetTextColor(LCD_COLOR_BLACK); + BSP_LCD_DisplayStringAtLine(9, (uint8_t *)"Es-wifi module MAC Address:"); + sprintf((char*)modulestr,"%X:%X:%X:%X:%X:%X.", MAC_Addr[0], + MAC_Addr[1], + MAC_Addr[2], + MAC_Addr[3], + MAC_Addr[4], + MAC_Addr[5]); + + BSP_LCD_DisplayStringAtLine(10, (uint8_t *) modulestr); +#endif /* LCD_USE */ + } + else + { +#if defined (LCD_USE) + BSP_LCD_SetTextColor(LCD_COLOR_RED); + BSP_LCD_DisplayStringAtLine(9, (uint8_t *)"ERROR : CANNOT get MAC address"); +#endif /* LCD_USE */ + BSP_LED_On(LED4); + } + + if( WIFI_Connect(SSID, PASSWORD, WIFI_ECN_WPA2_PSK) == WIFI_STATUS_OK) + { +#if defined (LCD_USE) + BSP_LCD_SetTextColor(LCD_COLOR_BLACK); + BSP_LCD_DisplayStringAtLine(11, (uint8_t *)"Es-wifi module connected"); +#endif /* LCD_USE */ + if(WIFI_GetIP_Address(IP_Addr) == WIFI_STATUS_OK) + { +#if defined (LCD_USE) + BSP_LCD_DisplayStringAtLine(12, (uint8_t *)"es-wifi module got IP Address :"); + sprintf((char*)modulestr,"%d.%d.%d.%d", IP_Addr[0], + IP_Addr[1], + IP_Addr[2], + IP_Addr[3]); + + BSP_LCD_DisplayStringAtLine(13, (uint8_t *) modulestr); + + BSP_LCD_DisplayStringAtLine(14, (uint8_t *)"Trying to connect to Server:"); + sprintf((char*)modulestr,"%d.%d.%d.%d:8002", RemoteIP[0], + RemoteIP[1], + RemoteIP[2], + RemoteIP[3]); + + BSP_LCD_DisplayStringAtLine(15, (uint8_t *) modulestr); + +#endif /* LCD_USE */ + while (Trials--) + { + if( WIFI_OpenClientConnection(0, WIFI_TCP_PROTOCOL, "TCP_CLIENT", (char *)RemoteIP, 8002, 0) == WIFI_STATUS_OK) + { +#if defined (LCD_USE) + BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"TCP Connection opened successfully."); +#endif /* LCD_USE */ + Socket = 0; + } + } + if(!Trials) + { +#if defined (LCD_USE) + BSP_LCD_SetTextColor(LCD_COLOR_RED); + BSP_LCD_DisplayStringAtLine(14, (uint8_t *)"ERROR : Cannot open Connection"); +#endif /* LCD_USE */ + BSP_LED_On(LED4); + } + } + else + { +#if defined (LCD_USE) + BSP_LCD_SetTextColor(LCD_COLOR_RED); + BSP_LCD_DisplayStringAtLine(12, (uint8_t *)"ERROR: es-wifi module CANNOT get IP address"); +#endif /* LCD_USE */ + BSP_LED_On(LED4); + } + } + else + { +#if defined (LCD_USE) + BSP_LCD_SetTextColor(LCD_COLOR_RED); + BSP_LCD_DisplayStringAtLine(11, (uint8_t *)"ERROR:es-wifi module NOT connected\n"); +#endif /* LCD_USE */ + BSP_LED_On(LED4); + } + } + else + { +#if defined (LCD_USE) + BSP_LCD_SetTextColor(LCD_COLOR_RED); + BSP_LCD_DisplayStringAtLine(7, (uint8_t *)"ERROR : WIFI Module cannot be initialized.\n"); +#endif /* LCD_USE */ + BSP_LED_On(LED4); + } + + while(1) + { + if(Socket != -1) + { + if(WIFI_ReceiveData(Socket, RxData, sizeof(RxData), &Datalen) == WIFI_STATUS_OK) + { + if(Datalen > 0) + { + if(WIFI_SendData(Socket, TxData, sizeof(TxData), &Datalen) != WIFI_STATUS_OK) + { +#if defined (LCD_USE) + BSP_LCD_SetTextColor(LCD_COLOR_RED); + BSP_LCD_DisplayStringAtLine(8, (uint8_t *)"ERROR : Failed to send Data."); +#endif /* LCD_USE */ + } + } + } + else + { +#if defined (LCD_USE) + BSP_LCD_SetTextColor(LCD_COLOR_RED); + BSP_LCD_DisplayStringAtLine(9, (uint8_t *)"ERROR : Failed to Receive Data."); +#endif /* LCD_USE */ + } + } + } +} + +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 100000000 + * HCLK(Hz) = 100000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 2 + * APB2 Prescaler = 1 + * HSE Frequency(Hz) = 8000000 + * PLL_M = 8 + * PLL_N = 200 + * PLL_P = 2 + * PLL_Q = 7 + * PLL_R = 2 + * VDD(V) = 3.3 + * Main regulator output voltage = Scale1 mode + * Flash Latency(WS) = 3 + * @param None + * @retval None + */ +static void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + + HAL_StatusTypeDef ret = HAL_OK; + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 200; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + RCC_OscInitStruct.PLL.PLLR = 2; + ret = HAL_RCC_OscConfig(&RCC_OscInitStruct); + + if(ret != HAL_OK) + { + while(1); + } + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3); + if(ret != HAL_OK) + { + while(1); + } +} + +#ifdef USE_FULL_ASSERT + +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t* file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + /* USER CODE END 6 */ + +} + +#endif + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/main.h b/examples/stm32cube-hal-wifi-client/src/main.h new file mode 100644 index 00000000..1c029a9d --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/main.h @@ -0,0 +1,62 @@ +/** + ****************************************************************************** + * @file Wifi/WiFi_Client_Server/Inc/main.h + * @author MCD Application Team + * @brief Header for main.c module + ****************************************************************************** + * @attention + * + *

© Copyright © 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +/* Includes ------------------------------------------------------------------*/ +#include "wifi.h" +#include "stm32f413h_discovery.h" +#include "stm32f413h_discovery_lcd.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/stm32f4xx_hal_conf.h b/examples/stm32cube-hal-wifi-client/src/stm32f4xx_hal_conf.h new file mode 100644 index 00000000..62da65c2 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/stm32f4xx_hal_conf.h @@ -0,0 +1,420 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf.h + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + +#define HAL_ADC_MODULE_ENABLED +//#define HAL_CAN_MODULE_ENABLED +//#define HAL_CAN_LEGACY_MODULE_ENABLED +//#define HAL_CRC_MODULE_ENABLED +//#define HAL_CRYP_MODULE_ENABLED +//#define HAL_DAC_MODULE_ENABLED +//#define HAL_DCMI_MODULE_ENABLED +//#define HAL_DMA2D_MODULE_ENABLED +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +//#define HAL_SDRAM_MODULE_ENABLED +//#define HAL_HASH_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_IWDG_MODULE_ENABLED +//#define HAL_LTDC_MODULE_ENABLED +//#define HAL_RNG_MODULE_ENABLED +//#define HAL_RTC_MODULE_ENABLED +//#define HAL_SAI_MODULE_ENABLED +//#define HAL_SD_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +//#define HAL_USART_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED +//#define HAL_PCD_MODULE_ENABLED +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_DSI_MODULE_ENABLED +//#define HAL_QSPI_MODULE_ENABLED +//#define HAL_QSPI_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE (32000U) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE (12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE (3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY (0xEU) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/stm32f4xx_it.c b/examples/stm32cube-hal-wifi-client/src/stm32f4xx_it.c new file mode 100644 index 00000000..ebf2bddd --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/stm32f4xx_it.c @@ -0,0 +1,176 @@ +/** + ****************************************************************************** + * @file Wifi/WiFi_Client_Server/Src/stm32f4xx_it.c + * @author MCD Application Team + * @brief Main Interrupt Service Routines. + * This file provides template for all exceptions handler and + * peripherals interrupt service routine. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32f4xx_it.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/******************************************************************************/ +/* Cortex-M4 Processor Exceptions Handlers */ +/******************************************************************************/ + +/** + * @brief This function handles NMI exception. + * @param None + * @retval None + */ +void NMI_Handler(void) +{ +} + +/** + * @brief This function handles Hard Fault exception. + * @param None + * @retval None + */ +void HardFault_Handler(void) +{ + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Memory Manage exception. + * @param None + * @retval None + */ +void MemManage_Handler(void) +{ + /* Go to infinite loop when Memory Manage exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Bus Fault exception. + * @param None + * @retval None + */ +void BusFault_Handler(void) +{ + /* Go to infinite loop when Bus Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Usage Fault exception. + * @param None + * @retval None + */ +void UsageFault_Handler(void) +{ + /* Go to infinite loop when Usage Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles SVCall exception. + * @param None + * @retval None + */ +void SVC_Handler(void) +{ +} + +/** + * @brief This function handles Debug Monitor exception. + * @param None + * @retval None + */ +void DebugMon_Handler(void) +{ +} + +/** + * @brief This function handles PendSVC exception. + * @param None + * @retval None + */ +void PendSV_Handler(void) +{ +} + +/** + * @brief This function handles SysTick Handler. + * @param None + * @retval None + */ +void SysTick_Handler(void) +{ + HAL_IncTick(); +} + +/******************************************************************************/ +/* STM32F4xx Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file. */ +/******************************************************************************/ +/** + * @brief This function handles PPP interrupt request. + * @param None + * @retval None + */ +/*void PPP_IRQHandler(void) +{ +}*/ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/stm32f4xx_it.h b/examples/stm32cube-hal-wifi-client/src/stm32f4xx_it.h new file mode 100644 index 00000000..5d45f857 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/stm32f4xx_it.h @@ -0,0 +1,77 @@ +/** + ****************************************************************************** + * @file Wifi/WiFi_Client_Server/inc/stm32f4xx_it..h + * @author MCD Application Team + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright © 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_IT_H +#define __STM32F4xx_IT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/system_stm32f4xx.c b/examples/stm32cube-hal-wifi-client/src/system_stm32f4xx.c new file mode 100644 index 00000000..564005a8 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/system_stm32f4xx.c @@ -0,0 +1,365 @@ +/** + ****************************************************************************** + * @file system_stm32f4xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32f4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f4xx_system + * @{ + */ + +/** @addtogroup STM32F4xx_System_Private_Includes + * @{ + */ + +#include "stm32f4xx.h" + +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to use external PSRAM as data memory */ +/*#define DATA_IN_ExtPSRAM*/ +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ +uint32_t SystemCoreClock = 16000000; + +const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; +const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes + * @{ + */ +#if defined (DATA_IN_ExtPSRAM) + static void SystemInit_ExtMemCtl(void); +#endif /* DATA_IN_ExtPSRAM */ +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the FPU setting, vector table location and External memory + * configuration. + * @param None + * @retval None + */ +void SystemInit(void) +{ + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set HSION bit */ + RCC->CR |= (uint32_t)0x00000001; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFFF; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x24003010; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Disable all interrupts */ + RCC->CIR = 0x00000000; + +#if defined (DATA_IN_ExtPSRAM) + SystemInit_ExtMemCtl(); +#endif /* DATA_IN_ExtPSRAM */ + + /* Configure the Vector Table location add offset address ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value + * depends on the application requirements), user has to ensure that HSE_VALUE + * is same as the real frequency of the crystal used. Otherwise, this function + * may have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & RCC_CFGR_SWS; + + switch (tmp) + { + case 0x00: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + case 0x04: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + case 0x08: /* PLL used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N + SYSCLK = PLL_VCO / PLL_P + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; + pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; + + if (pllsource != 0) + { + /* HSE used as PLL clock source */ + pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + else + { + /* HSI used as PLL clock source */ + pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + + pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; + SystemCoreClock = pllvco/pllp; + break; + default: + SystemCoreClock = HSI_VALUE; + break; + } + /* Compute HCLK frequency --------------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK frequency */ + SystemCoreClock >>= tmp; +} + +#if defined (DATA_IN_ExtPSRAM) +/** + * @brief Setup the external memory controller. + * Called in startup_stm32f4xx.s before jump to main. + * This function configures the external memories (PSRAM) + * This PSRAM will be used as program data memory (including heap and stack). + * @param None + * @retval None + */ +void SystemInit_ExtMemCtl(void) +{ + __IO uint32_t tmp = 0x00; + +/*-- GPIOs Configuration -----------------------------------------------------*/ + /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ + RCC->AHB1ENR |= 0x00000078; + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN); + + /* Connect PDx pins to FMC Alternate function */ + GPIOD->AFR[0] = 0xC0CC00CC; + GPIOD->AFR[1] = 0xCC0CCCCC; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xA2AA8A0A; + /* Configure PDx pins speed to 100 MHz */ + GPIOD->OSPEEDR = 0xF3FFCF0F; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x51554505; + + /* Connect PEx pins to FMC Alternate function */ + GPIOE->AFR[0] = 0xC00000CC; + GPIOE->AFR[1] = 0xCCCCCCCC; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xAAAA800A; + /* Configure PEx pins speed to 100 MHz */ + GPIOE->OSPEEDR = 0xFFFFC00F; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x55554005; + + /* Connect PFx pins to FMC Alternate function */ + GPIOF->AFR[0] = 0x00CCCCCC; + GPIOF->AFR[1] = 0xCCCC0000; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xAA000AAA; + /* Configure PFx pins speed to 100 MHz */ + GPIOF->OSPEEDR = 0xFF000FFF; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x55000555; + + /* Connect PGx pins to FMC Alternate function */ + GPIOG->AFR[0] = 0x00CCCCCC; + GPIOG->AFR[1] = 0x00000000; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0x00000AAA; + /* Configure PGx pins speed to 100 MHz */ + GPIOG->OSPEEDR = 0x00000FFF; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000555; + +/*-- FMC/FSMC Configuration --------------------------------------------------*/ + /* Enable the FMC/FSMC interface clock */ + RCC->AHB3ENR |= 0x00000001; + + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN); + /* Configure and enable Bank1_PSRAM1 */ + FSMC_Bank1->BTCR[0] = 0x00001091; + FSMC_Bank1->BTCR[1] = 0x00110413; + FSMC_Bank1E->BWTR[0] = 0x0FFFFFFF; + (void)(tmp); +} +#endif /* DATA_IN_ExtPSRAM*/ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/src/wifi.c b/examples/stm32cube-hal-wifi-client/src/wifi.c new file mode 100644 index 00000000..1762df4f --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/wifi.c @@ -0,0 +1,380 @@ +/** + ****************************************************************************** + * @file wifi.c + * @author MCD Application Team + * @brief WIFI interface file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "wifi.h" + +/* Private define ------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +ES_WIFIObject_t EsWifiObj; + +/* Private functions ---------------------------------------------------------*/ +/** + * @brief Initialiaze the LL part of the WIFI core + * @param None + * @retval Operation status + */ +WIFI_Status_t WIFI_Init(void) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(ES_WIFI_RegisterBusIO(&EsWifiObj, + SPI_WIFI_Init, + SPI_WIFI_DeInit, + SPI_WIFI_Delay, + SPI_WIFI_SendData, + SPI_WIFI_ReceiveData) == ES_WIFI_STATUS_OK) + { + + if(ES_WIFI_Init(&EsWifiObj) == ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + } + return ret; +} + +/** + * @brief List a defined number of vailable access points + * @param APs : pointer to APs structure + * @param AP_MaxNbr : Max APs number to be listed + * @retval Operation status + */ +WIFI_Status_t WIFI_ListAccessPoints(WIFI_APs_t *APs, uint8_t AP_MaxNbr) +{ + uint8_t APCount; + WIFI_Status_t ret = WIFI_STATUS_ERROR; + ES_WIFI_APs_t esWifiAPs; + + if(ES_WIFI_ListAccessPoints(&EsWifiObj, &esWifiAPs) == ES_WIFI_STATUS_OK) + { + if(esWifiAPs.nbr > 0) + { + APs->count = MIN(esWifiAPs.nbr, AP_MaxNbr); + for(APCount = 0; APCount < APs->count; APCount++) + { + APs->ap[APCount].Ecn = (WIFI_Ecn_t)esWifiAPs.AP[APCount].Security; + strncpy( (char *)APs->ap[APCount].SSID, (char *)esWifiAPs.AP[APCount].SSID, MIN (WIFI_MAX_SSID_NAME, WIFI_MAX_SSID_NAME)); + APs->ap[APCount].RSSI = esWifiAPs.AP[APCount].RSSI; + memcpy(APs->ap[APCount].MAC, esWifiAPs.AP[APCount].MAC, 6); + } + } + ret = WIFI_STATUS_OK; + } + return ret; +} + +/** + * @brief Join an Access Point + * @param SSID : SSID string + * @param Password : Password string + * @param ecn : Encryption type + * @param IP_Addr : Got IP Address + * @param IP_Mask : Network IP mask + * @param Gateway_Addr : Gateway IP address + * @param MAC : pointer to MAC Address + * @retval Operation status + */ +WIFI_Status_t WIFI_Connect( + const char* SSID, + const char* Password, + WIFI_Ecn_t ecn) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(ES_WIFI_Connect(&EsWifiObj, SSID, Password, (ES_WIFI_SecurityType_t) ecn) == ES_WIFI_STATUS_OK) + { + if(ES_WIFI_GetNetworkSettings(&EsWifiObj) == ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + + } + return ret; +} + +/** + * @brief This function retrieves the WiFi interface's MAC address. + * @retval Operation Status. + */ +WIFI_Status_t WIFI_GetMAC_Address(uint8_t *mac) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(ES_WIFI_GetMACAddress(&EsWifiObj, mac) == ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + return ret; +} + +/** + * @brief This function retrieves the WiFi interface's IP address. + * @retval Operation Status. + */ +WIFI_Status_t WIFI_GetIP_Address (uint8_t *ipaddr) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(EsWifiObj.NetSettings.IsConnected) + { + memcpy(ipaddr, EsWifiObj.NetSettings.IP_Addr, 4); + ret = WIFI_STATUS_OK; + } + return ret; +} + +/** + * @brief Disconnect from a network + * @param None + * @retval Operation status + */ +WIFI_Status_t WIFI_Disconnect(void) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + if( ES_WIFI_Disconnect(&EsWifiObj)== ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + + return ret; +} + +/** + * @brief Ping an IP address in the network + * @param ipaddr : array of the IP address + * @retval Operation status + */ +WIFI_Status_t WIFI_Ping(uint8_t* ipaddr, uint16_t count, uint16_t interval_ms) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(ES_WIFI_Ping(&EsWifiObj, ipaddr, count, interval_ms) == ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + return ret; +} + +/** + * @brief Configure and start a client connection + * @param type : Connection type TCP/UDP + * @param name : name of the connection + * @param location : Client address + * @param port : Remote port + * @param local_port : Local port + * @retval Operation status + */ +WIFI_Status_t WIFI_OpenClientConnection(uint32_t socket, WIFI_Protocol_t type, const char* name, char* location, uint16_t port, uint16_t local_port) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + ES_WIFI_Conn_t conn; + + conn.Number = socket; + conn.RemotePort = port; + conn.LocalPort = local_port; + conn.Type = (type == WIFI_TCP_PROTOCOL)? ES_WIFI_TCP_CONNECTION : ES_WIFI_UDP_CONNECTION; + conn.RemoteIP[0] = location[0]; + conn.RemoteIP[1] = location[1]; + conn.RemoteIP[2] = location[2]; + conn.RemoteIP[3] = location[3]; + if(ES_WIFI_StartClientConnection(&EsWifiObj, &conn)== ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + return ret; +} + +/** + * @brief Close client connection + * @param type : Connection type TCP/UDP + * @param name : name of the connection + * @param location : Client address + * @param port : Remote port + * @param local_port : Local port + * @retval Operation status + */ +WIFI_Status_t WIFI_CloseClientConnection(void) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + if(ES_WIFI_StopClientConnection(&EsWifiObj, 0)== ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + return ret; +} + +/** + * @brief Configure and start a Server + * @param type : Connection type TCP/UDP + * @param name : name of the connection + * @param port : Remote port + * @retval Operation status + */ +WIFI_Status_t WIFI_StartServer(uint32_t socket, WIFI_Protocol_t protocol, const char* name, uint16_t port) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + ES_WIFI_Conn_t conn; + conn.Number = socket; + conn.LocalPort = port; + conn.Type = (protocol == WIFI_TCP_PROTOCOL)? ES_WIFI_TCP_CONNECTION : ES_WIFI_UDP_CONNECTION; + if(ES_WIFI_StartServerSingleConn(&EsWifiObj, &conn)== ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + return ret; +} + +/** + * @brief Stop a server + * @retval Operation status + */ +WIFI_Status_t WIFI_StopServer(uint32_t socket) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(ES_WIFI_StopServerSingleConn(&EsWifiObj)== ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + return ret; +} +/** + * @brief Send Data on a socket + * @param pdata : pointer to data to be sent + * @param len : length of data to be sent + * @retval Operation status + */ +WIFI_Status_t WIFI_SendData(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *SentDatalen) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(ES_WIFI_SendData(&EsWifiObj, socket, pdata, Reqlen, SentDatalen, 10000) == ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + + return ret; +} + +/** + * @brief Receive Data from a socket + * @param pdata : pointer to Rx buffer + * @param *len : pointer to length of data + * @retval Operation status + */ +WIFI_Status_t WIFI_ReceiveData(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *RcvDatalen) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(ES_WIFI_ReceiveData(&EsWifiObj, socket, pdata, Reqlen, RcvDatalen, 10000) == ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + return ret; +} + +/** + * @brief Customize module data + * @param name : MFC name + * @param Mac : Mac Address + * @retval Operation status + */ +WIFI_Status_t WIFI_SetOEMProperties(const char *name, uint8_t *Mac) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(ES_WIFI_SetProductName(&EsWifiObj, (uint8_t *)name) == ES_WIFI_STATUS_OK) + { + if(ES_WIFI_SetMACAddress(&EsWifiObj, Mac) == ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + } + return ret; +} + +/** + * @brief Reset the WIFI module + * @retval Operation status + */ +WIFI_Status_t WIFI_ResetModule(void) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(ES_WIFI_ResetModule(&EsWifiObj) == ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + return ret; +} + +/** + * @brief Restore module default configuration + * @retval Operation status + */ +WIFI_Status_t WIFI_SetModuleDefault(void) +{ + WIFI_Status_t ret = WIFI_STATUS_ERROR; + + if(ES_WIFI_ResetToFactoryDefault(&EsWifiObj) == ES_WIFI_STATUS_OK) + { + ret = WIFI_STATUS_OK; + } + return ret; +} + + +/** + * @brief Update module firmware + * @param location : Binary Location IP address + * @retval Operation status + */ +WIFI_Status_t WIFI_ModuleFirmwareUpdate(const char *location) +{ + return WIFI_STATUS_NOT_SUPPORTED; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/examples/stm32cube-hal-wifi-client/src/wifi.h b/examples/stm32cube-hal-wifi-client/src/wifi.h new file mode 100644 index 00000000..98c0014b --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/src/wifi.h @@ -0,0 +1,180 @@ +/** + ****************************************************************************** + * @file wifi.h + * @author MCD Application Team + * @brief This file contains the diffrent wifi core resources definitions. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +#ifndef __WIFI_H_ +#define __WIFI_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "es_wifi.h" +#include "es_wifi_io.h" + +/* Exported constants --------------------------------------------------------*/ +#define WIFI_MAX_SSID_NAME 100 +#define WIFI_MAX_PSWD_NAME 100 +#define WIFI_MAX_APS 100 +#define WIFI_MAX_CONNECTIONS 4 +#define WIFI_MAX_MODULE_NAME 100 +#define WIFI_MAX_CONNECTED_STATIONS 2 +#define WIFI_MSG_JOINED 1 +#define WIFI_MSG_ASSIGNED 2 + + +/* Exported types ------------------------------------------------------------*/ +typedef enum { + WIFI_ECN_OPEN = 0x00, + WIFI_ECN_WEP = 0x01, + WIFI_ECN_WPA_PSK = 0x02, + WIFI_ECN_WPA2_PSK = 0x03, + WIFI_ECN_WPA_WPA2_PSK = 0x04, +}WIFI_Ecn_t; + +typedef enum { + WIFI_TCP_PROTOCOL = 0, + WIFI_UDP_PROTOCOL = 1, +}WIFI_Protocol_t; + +typedef enum { + WIFI_SERVER = 0, + WIFI_CLIENT = 1, +}WIFI_Type_t; + +typedef enum { + WIFI_STATUS_OK = 0, + WIFI_STATUS_ERROR = 1, + WIFI_STATUS_NOT_SUPPORTED = 2, + WIFI_STATUS_JOINED = 3, + WIFI_STATUS_ASSIGNED = 4, +}WIFI_Status_t; + +typedef struct { + WIFI_Ecn_t Ecn; /*!< Security of Wi-Fi spot. This parameter has a value of \ref WIFI_Ecn_t enumeration */ + char SSID[WIFI_MAX_SSID_NAME + 1]; /*!< Service Set Identifier value. Wi-Fi spot name */ + int16_t RSSI; /*!< Signal strength of Wi-Fi spot */ + uint8_t MAC[6]; /*!< MAC address of spot */ + uint8_t Channel; /*!< Wi-Fi channel */ + uint8_t Offset; /*!< Frequency offset from base 2.4GHz in kHz */ + uint8_t Calibration; /*!< Frequency offset calibration */ +}WIFI_AP_t; + +typedef struct { + WIFI_AP_t ap[WIFI_MAX_APS]; + uint8_t count; +} WIFI_APs_t; + + +typedef struct { + uint8_t Number; /*!< Connection number */ + uint16_t RemotePort; /*!< Remote PORT number */ + uint16_t LocalPort; + uint8_t RemoteIP[4]; /*!< IP address of device */ + WIFI_Protocol_t Protocol; /*!< Connection type. Parameter is valid only if connection is made as client */ + uint32_t TotalBytesReceived; /*!< Number of bytes received in entire connection lifecycle */ + uint32_t TotalBytesSent; /*!< Number of bytes sent in entire connection lifecycle */ + uint8_t Active; /*!< Status if connection is active */ + uint8_t Client; /*!< Set to 1 if connection was made as client */ +} WIFI_Socket_t; + + +typedef struct { + + uint8_t SSID[WIFI_MAX_SSID_NAME + 1]; + uint8_t PSWD[WIFI_MAX_PSWD_NAME + 1]; + uint8_t channel; + WIFI_Ecn_t Ecn; +} WIFI_APConfig_t; + +typedef struct { + uint8_t SSID[WIFI_MAX_SSID_NAME + 1]; /*!< Network public name for ESP AP mode */ + uint8_t IP_Addr[4]; /*!< IP Address */ + uint8_t MAC_Addr[6]; /*!< MAC address */ +} WIFI_APSettings_t; + +typedef struct { + uint8_t IsConnected; + uint8_t IP_Addr[4]; + uint8_t IP_Mask[4]; + uint8_t Gateway_Addr[4]; +} WIFI_Conn_t; + +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +WIFI_Status_t WIFI_Init(void); +WIFI_Status_t WIFI_ListAccessPoints(WIFI_APs_t *APs, uint8_t AP_MaxNbr); +WIFI_Status_t WIFI_Connect( + const char* SSID, + const char* Password, + WIFI_Ecn_t ecn); +WIFI_Status_t WIFI_GetIP_Address(uint8_t *ipaddr); +WIFI_Status_t WIFI_GetMAC_Address(uint8_t *mac); + +WIFI_Status_t WIFI_Disconnect(void); + +WIFI_Status_t WIFI_Ping(uint8_t* ipaddr, uint16_t count, uint16_t interval_ms); +WIFI_Status_t WIFI_OpenClientConnection(uint32_t socket, WIFI_Protocol_t type, const char* name, char* location, uint16_t port, uint16_t local_port); +WIFI_Status_t WIFI_CloseClientConnection(void); + +WIFI_Status_t WIFI_StartServer(uint32_t socket, WIFI_Protocol_t type, const char* name, uint16_t port); +WIFI_Status_t WIFI_StopServer(uint32_t socket); + +WIFI_Status_t WIFI_SendData(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *SentDatalen); +WIFI_Status_t WIFI_ReceiveData(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *RcvDatalen); +WIFI_Status_t WIFI_StartClient(void); +WIFI_Status_t WIFI_StopClient(void); + +WIFI_Status_t WIFI_SetOEMProperties(const char *name, uint8_t *Mac); +WIFI_Status_t WIFI_ResetModule(void); +WIFI_Status_t WIFI_SetModuleDefault(void); +WIFI_Status_t WIFI_ModuleFirmwareUpdate(const char *url); + +#ifdef __cplusplus +} +#endif + +#endif /* __WIFI_H_ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/stm32cube-hal-wifi-client/test/README b/examples/stm32cube-hal-wifi-client/test/README new file mode 100644 index 00000000..df5066e6 --- /dev/null +++ b/examples/stm32cube-hal-wifi-client/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/platform.json b/platform.json index 6052f054..f11711a3 100644 --- a/platform.json +++ b/platform.json @@ -18,7 +18,7 @@ "type": "git", "url": "https://github.com/platformio/platform-ststm32.git" }, - "version": "9.0.0", + "version": "10.0.0", "frameworks": { "mbed": { "package": "framework-mbed", @@ -188,7 +188,7 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~2.10000.0" + "version": "~3.10000.0" }, "framework-arduinostm32mxchip": { "type": "framework", @@ -202,11 +202,83 @@ "owner": "platformio", "version": "~2.10.0" }, - "framework-stm32cube": { + "framework-stm32cubef0": { "type": "framework", "optional": true, "owner": "platformio", - "version": "~2.0.181130" + "version": "~1.11.0" + }, + "framework-stm32cubef1": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.8.0" + }, + "framework-stm32cubef2": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.9.0" + }, + "framework-stm32cubef3": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.11.0" + }, + "framework-stm32cubef4": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.25.0" + }, + "framework-stm32cubef7": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.16.0" + }, + "framework-stm32cubeg0": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.3.0" + }, + "framework-stm32cubeg4": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.3.0" + }, + "framework-stm32cubeh7": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.8.0" + }, + "framework-stm32cubel0": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.11.0" + }, + "framework-stm32cubel1": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.10.0" + }, + "framework-stm32cubel4": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.16.0" + }, + "framework-stm32cubel5": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~1.3.0" }, "framework-zephyr": { "type": "framework", diff --git a/platform.py b/platform.py index 533ef906..60febf3b 100644 --- a/platform.py +++ b/platform.py @@ -27,6 +27,7 @@ def configure_default_packages(self, variables, targets): board_config = self.board_config(board) build_core = variables.get( "board_build.core", board_config.get("build.core", "arduino")) + build_mcu = variables.get("board_build.mcu", board_config.get("build.mcu", "")) frameworks = variables.get("pioframework", []) if "arduino" in frameworks: @@ -53,12 +54,16 @@ def configure_default_packages(self, variables, targets): self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.90201.0" if "cmsis" in frameworks: - assert board_config.get( - "build.mcu", ""), ("Missing MCU field for %s" % board) - device_package = "framework-cmsis-" + board_config.get("build.mcu")[0:7] + assert build_mcu, ("Missing MCU field for %s" % board) + device_package = "framework-cmsis-" + build_mcu[0:7] if device_package in self.packages: self.packages[device_package]["optional"] = False + if "stm32cube" in frameworks: + assert build_mcu, ("Missing MCU field for %s" % board) + device_package = "framework-stm32cube%s" % build_mcu[5:7] + self.frameworks["stm32cube"]["package"] = device_package + if any(f in frameworks for f in ("cmsis", "stm32cube")): self.packages["tool-ldscripts-ststm32"]["optional"] = False @@ -67,20 +72,20 @@ def configure_default_packages(self, variables, targets): self.packages["tool-dfuutil"]["optional"] = False if board == "mxchip_az3166": - self.frameworks['arduino'][ - 'package'] = "framework-arduinostm32mxchip" - self.frameworks['arduino'][ - 'script'] = "builder/frameworks/arduino/mxchip.py" - self.packages['toolchain-gccarmnoneeabi']['version'] = "~1.60301.0" + self.frameworks["arduino"][ + "package"] = "framework-arduinostm32mxchip" + self.frameworks["arduino"][ + "script"] = "builder/frameworks/arduino/mxchip.py" + self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.60301.0" if "zephyr" in variables.get("pioframework", []): for p in self.packages: if p.startswith("framework-zephyr-") or p in ( "tool-cmake", "tool-dtc", "tool-ninja"): self.packages[p]["optional"] = False - self.packages['toolchain-gccarmnoneeabi']['version'] = "~1.80201.0" + self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.80201.0" if "windows" not in get_systype(): - self.packages['tool-gperf']['optional'] = False + self.packages["tool-gperf"]["optional"] = False # configure J-LINK tool jlink_conds = [