diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index e3ecdd70b2..289c5740a3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,15 +1,15 @@ ### Description - ### Pull request type - +### Release Notes + + diff --git a/LICENSE b/LICENSE-apache-2.0.txt similarity index 100% rename from LICENSE rename to LICENSE-apache-2.0.txt diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000000..4522260636 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ +Unless specifically indicated otherwise in a file, files are licensed under the Apache 2.0 license, +as can be found in: LICENSE-apache-2.0.txt + +Folders containing files under different permissive license than Apache 2.0 are listed below. Each folder should contain its own README file with license specified for its files. The original license text is included in those source files. + +- [cmsis](./cmsis) - MIT, BSD-3-Clause +- [components/802.15.4_RF/mcr20a-rf-driver](./components/802.15.4_RF/mcr20a-rf-driver) - BSD-3-Clause +- [features/cryptocell/FEATURE_CRYPTOCELL310](./features/cryptocell/FEATURE_CRYPTOCELL310) - ARM Object Code and Header Files License +- [features/FEATURE_BOOTLOADER](./features/FEATURE_BOOTLOADER) - PBL +- [features/FEATURE_BLE/targets](./features/FEATURE_BLE/targets) - BSD-style, PBL, MIT-style +- [features/lorawan](./features/lorawan) - Revised BSD +- [features/lwipstack](./features/lwipstack) - BSD-style, MIT-style +- [features/nanostack/sal-stack-nanostack](./features/nanostack/sal-stack-nanostack) - BSD-3-Clause +- [features/storage](./features/storage) - BSD-style, MIT +- [features/netsocket/emac-drivers](./features/netsocket/emac-drivers) - BSD-style +- [features/frameworks/unity/unity](./features/frameworks/unity/unity) - MIT +- [features/unsupported](./features/unsupported) - MIT-style, BSD-style +- [rtos](./rtos) - MIT +- [drivers](./drivers) - MIT +- [TESTS/mbed_hal/trng/pithy](./TESTS/mbed_hal/trng/pithy) - BSD-3-Clause +- [tools/data/rpc](./tools/data/rpc) - MIT +- [targets](./targets) - PBL, BSD-style, MIT-style, Zlib-style, Public-domain diff --git a/README.md b/README.md index 59d8fcc7e3..bed98b0caf 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,11 @@ The [release notes](https://os.mbed.com/releases) detail the current release. Yo ## License and contributions -The software is provided under [Apache-2.0 license](LICENSE). Contributions to this project are accepted under the same license. Please see [contributing.md](CONTRIBUTING.md) for more info. +The software is provided under the [Apache-2.0 license](LICENSE-apache-2.0.txt). Contributions to this project are accepted under the same license. Please see [contributing.md](CONTRIBUTING.md) for more information. -This project contains code from other projects. The original license text is included in those source files. They must comply with our [license guide](https://os.mbed.com/docs/latest/reference/license.html) +This project contains code from other projects. The original license text is included in those source files. They must comply with our [license guide](https://os.mbed.com/docs/latest/reference/license.html). + +Folders containing files under different permissive license than Apache 2.0 are listed in the [LICENSE](LICENSE) file. ## Getting started for developers diff --git a/TESTS/mbed_drivers/flashiap/main.cpp b/TESTS/mbed_drivers/flashiap/main.cpp index 9cd3cd861b..28249eeaf2 100644 --- a/TESTS/mbed_drivers/flashiap/main.cpp +++ b/TESTS/mbed_drivers/flashiap/main.cpp @@ -29,6 +29,17 @@ #include "mbed.h" +// Debug available +#ifndef FLASHIAP_DEBUG +#define FLASHIAP_DEBUG 0 +#endif + +#if FLASHIAP_DEBUG +#define DEBUG_PRINTF(...) printf(__VA_ARGS__) +#else +#define DEBUG_PRINTF(...) +#endif + using namespace utest::v1; @@ -37,6 +48,21 @@ void flashiap_init_test() FlashIAP flash_device; uint32_t ret = flash_device.init(); TEST_ASSERT_EQUAL_INT32(0, ret); + + uint32_t flash_start = flash_device.get_flash_start(); + uint32_t flash_size = flash_device.get_flash_size(); + utest_printf("Flash address: 0x%08x, size: %d\n", flash_start, flash_size); + uint32_t address = flash_start; + int num = 0; + while (flash_size) { + uint32_t sector_size = flash_device.get_sector_size(address); + // Make sure all sectors sum up to the total flash size + TEST_ASSERT(flash_size >= sector_size); + DEBUG_PRINTF("\tsector %3d: address 0x%08x, size %8d\n", num++, address, sector_size); + flash_size -= sector_size; + address += sector_size; + } + ret = flash_device.deinit(); TEST_ASSERT_EQUAL_INT32(0, ret); } diff --git a/TESTS/mbedmicro-mbed/attributes/attributes.c b/TESTS/mbedmicro-mbed/attributes/attributes.c index 5329b8a3c5..df7ede99bb 100644 --- a/TESTS/mbedmicro-mbed/attributes/attributes.c +++ b/TESTS/mbedmicro-mbed/attributes/attributes.c @@ -1,3 +1,20 @@ +/* +* Copyright (c) 2016-2019 ARM Limited. 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 +* +* 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. +*/ #include "mbed_toolchain.h" #include diff --git a/TESTS/mbedmicro-mbed/attributes/weak.c b/TESTS/mbedmicro-mbed/attributes/weak.c index 7b2f862177..9a30fe77ce 100644 --- a/TESTS/mbedmicro-mbed/attributes/weak.c +++ b/TESTS/mbedmicro-mbed/attributes/weak.c @@ -1,3 +1,20 @@ +/* +* Copyright (c) 2016-2019 ARM Limited. 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 +* +* 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. +*/ #include "mbed_toolchain.h" int testWeak1() diff --git a/TESTS/mbedmicro-mbed/static_assert/test_c.c b/TESTS/mbedmicro-mbed/static_assert/test_c.c index b908a2e872..adcff7073a 100644 --- a/TESTS/mbedmicro-mbed/static_assert/test_c.c +++ b/TESTS/mbedmicro-mbed/static_assert/test_c.c @@ -1,3 +1,20 @@ +/* +* Copyright (c) 2015-2019 ARM Limited. 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 +* +* 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. +*/ #include "mbed_assert.h" #define THE_ANSWER 42 diff --git a/TESTS/mbedmicro-mbed/static_assert/test_cpp.cpp b/TESTS/mbedmicro-mbed/static_assert/test_cpp.cpp index 2bff2780cb..024e4970cf 100644 --- a/TESTS/mbedmicro-mbed/static_assert/test_cpp.cpp +++ b/TESTS/mbedmicro-mbed/static_assert/test_cpp.cpp @@ -1,3 +1,20 @@ +/* +* Copyright (c) 2016-2019 ARM Limited. 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 +* +* 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. +*/ #include "mbed_assert.h" #define THE_ANSWER 42 diff --git a/TESTS/netsocket/dns/asynchronous_dns_cancel.cpp b/TESTS/netsocket/dns/asynchronous_dns_cancel.cpp index 2c866cf6f7..e5594e16f4 100644 --- a/TESTS/netsocket/dns/asynchronous_dns_cancel.cpp +++ b/TESTS/netsocket/dns/asynchronous_dns_cancel.cpp @@ -42,6 +42,7 @@ void ASYNCHRONOUS_DNS_CANCEL() count++; } else { // No memory to initiate DNS query, callback will not be called + printf("Error: No memory to initiate DNS query for %s\n", dns_test_hosts[i]); data[i].result = NSAPI_ERROR_NO_MEMORY; data[i].value_set = true; } diff --git a/TESTS/netsocket/tcp/main.cpp b/TESTS/netsocket/tcp/main.cpp index 36f453532a..b49e9a9689 100644 --- a/TESTS/netsocket/tcp/main.cpp +++ b/TESTS/netsocket/tcp/main.cpp @@ -57,6 +57,15 @@ void drop_bad_packets(TCPSocket &sock, int orig_timeout) sock.set_timeout(orig_timeout); } +nsapi_version_t get_ip_version() +{ + SocketAddress test; + if (!test.set_ip_address(NetworkInterface::get_default_instance()->get_ip_address())) { + return NSAPI_UNSPEC; + } + return test.get_ip_version(); +} + static void _ifup() { NetworkInterface *net = NetworkInterface::get_default_instance(); diff --git a/TESTS/netsocket/tcp/tcp_tests.h b/TESTS/netsocket/tcp/tcp_tests.h index 8314a30da5..e03f8414ef 100644 --- a/TESTS/netsocket/tcp/tcp_tests.h +++ b/TESTS/netsocket/tcp/tcp_tests.h @@ -20,6 +20,7 @@ NetworkInterface *get_interface(); void drop_bad_packets(TCPSocket &sock, int orig_timeout); +nsapi_version_t get_ip_version(); void fill_tx_buffer_ascii(char *buff, size_t len); nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket &sock); nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket &sock); diff --git a/TESTS/netsocket/tcp/tcpsocket_bind_address_invalid.cpp b/TESTS/netsocket/tcp/tcpsocket_bind_address_invalid.cpp index 4e0c568ce7..933926ede4 100644 --- a/TESTS/netsocket/tcp/tcpsocket_bind_address_invalid.cpp +++ b/TESTS/netsocket/tcp/tcpsocket_bind_address_invalid.cpp @@ -39,7 +39,14 @@ void TCPSOCKET_BIND_ADDRESS_INVALID() return; } TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(NetworkInterface::get_default_instance())); - nsapi_error_t bind_result = sock->bind("190.2.3.4", 1024); + nsapi_error_t bind_result = NSAPI_ERROR_OK; + if (get_ip_version() == NSAPI_IPv4) { + bind_result = sock->bind("190.2.3.4", 1024); + } else if (get_ip_version() == NSAPI_IPv6) { + bind_result = sock->bind("fe80::ff01", 1024); + } else { + TEST_FAIL_MESSAGE("This stack is neither IPv4 nor IPv6"); + } if (bind_result == NSAPI_ERROR_UNSUPPORTED) { TEST_IGNORE_MESSAGE("bind() not supported"); } else { diff --git a/TESTS/netsocket/tcp/tcpsocket_bind_wrong_type.cpp b/TESTS/netsocket/tcp/tcpsocket_bind_wrong_type.cpp index be223b0f2c..6a388b5ca6 100644 --- a/TESTS/netsocket/tcp/tcpsocket_bind_wrong_type.cpp +++ b/TESTS/netsocket/tcp/tcpsocket_bind_wrong_type.cpp @@ -40,7 +40,14 @@ void TCPSOCKET_BIND_WRONG_TYPE() } TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(NetworkInterface::get_default_instance())); char addr_bytes[16] = {0xfe, 0x80, 0xff, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - SocketAddress sockAddr = SocketAddress(addr_bytes, NSAPI_IPv4, 80); + SocketAddress sockAddr; + if (get_ip_version() == NSAPI_IPv4) { + sockAddr = SocketAddress(addr_bytes, NSAPI_IPv4, 80); + } else if (get_ip_version() == NSAPI_IPv6) { + sockAddr = SocketAddress(addr_bytes, NSAPI_IPv6, 80); + } else { + TEST_FAIL_MESSAGE("This stack is neither IPv4 nor IPv6"); + } nsapi_error_t bind_result = sock->bind(sockAddr); if (bind_result == NSAPI_ERROR_UNSUPPORTED) { TEST_IGNORE_MESSAGE("bind() not supported"); diff --git a/TESTS/netsocket/tls/main.cpp b/TESTS/netsocket/tls/main.cpp index 0e7316a9e3..9ee0dfee56 100644 --- a/TESTS/netsocket/tls/main.cpp +++ b/TESTS/netsocket/tls/main.cpp @@ -195,9 +195,12 @@ Case cases[] = { Case("TLSSOCKET_SEND_REPEAT", TLSSOCKET_SEND_REPEAT), Case("TLSSOCKET_SEND_TIMEOUT", TLSSOCKET_SEND_TIMEOUT), Case("TLSSOCKET_NO_CERT", TLSSOCKET_NO_CERT), -#ifndef __IAR_SYSTEMS_ICC__ - Case("TLSSOCKET_SIMULTANEOUS", TLSSOCKET_SIMULTANEOUS) -#endif +// Temporarily removing this test, as TLS library consumes too much memory +// and we see frequent memory allocation failures on architectures with less +// RAM such as DISCO_L475VG_IOT1A and NUCLEO_F207ZG (both have 128 kB RAM) +// This test also fails for IAR, due to wrong heap configuration in the linker +// script - see https://github.com/ARMmbed/mbed-os/issues/8306 +// Case("TLSSOCKET_SIMULTANEOUS", TLSSOCKET_SIMULTANEOUS) }; Specification specification(greentea_setup, cases, greentea_teardown, greentea_continue_handlers); diff --git a/TESTS/netsocket/tls/tlssocket_echotest.cpp b/TESTS/netsocket/tls/tlssocket_echotest.cpp index b7b91b1ef4..56f8fa7fbd 100644 --- a/TESTS/netsocket/tls/tlssocket_echotest.cpp +++ b/TESTS/netsocket/tls/tlssocket_echotest.cpp @@ -63,8 +63,8 @@ void TLSSOCKET_ECHOTEST() if (tlssocket_connect_to_echo_srv(*sock) != NSAPI_ERROR_OK) { printf("Error from tlssocket_connect_to_echo_srv\n"); TEST_FAIL(); - return; delete sock; + return; } int recvd; diff --git a/TESTS/netsocket/tls/tlssocket_handshake_invalid.cpp b/TESTS/netsocket/tls/tlssocket_handshake_invalid.cpp index c5c1a187df..0417afb1c3 100644 --- a/TESTS/netsocket/tls/tlssocket_handshake_invalid.cpp +++ b/TESTS/netsocket/tls/tlssocket_handshake_invalid.cpp @@ -31,8 +31,8 @@ void TLSSOCKET_HANDSHAKE_INVALID() TLSSocket sock; TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(NetworkInterface::get_default_instance())); TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.set_root_ca_cert(tls_global::cert)); - TEST_ASSERT_EQUAL(NSAPI_ERROR_NO_CONNECTION, - sock.connect("google.com", MBED_CONF_APP_ECHO_SERVER_DISCARD_PORT_TLS)); + TEST_ASSERT_EQUAL(NSAPI_ERROR_AUTH_FAILURE, + sock.connect("google.com", 443)); // 443 is https port. TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close()); } diff --git a/TESTS/netsocket/udp/main.cpp b/TESTS/netsocket/udp/main.cpp index 9f9b7e950a..0057aed55f 100644 --- a/TESTS/netsocket/udp/main.cpp +++ b/TESTS/netsocket/udp/main.cpp @@ -33,10 +33,26 @@ using namespace utest::v1; +namespace { +Timer tc_bucket; // Timer to limit a test cases run time +} + #if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE mbed_stats_socket_t udp_stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT]; #endif +void drop_bad_packets(UDPSocket &sock, int orig_timeout) +{ + nsapi_error_t err; + sock.set_timeout(0); + while (true) { + err = sock.recv(NULL, 0); + if (err == NSAPI_ERROR_WOULD_BLOCK) { + break; + } + } + sock.set_timeout(orig_timeout); +} static void _ifup() { NetworkInterface *net = NetworkInterface::get_default_instance(); @@ -51,17 +67,14 @@ static void _ifdown() printf("MBED: ifdown\n"); } -void drop_bad_packets(UDPSocket &sock, int orig_timeout) + +nsapi_version_t get_ip_version() { - nsapi_error_t err; - sock.set_timeout(0); - while (true) { - err = sock.recvfrom(NULL, 0, 0); - if (err == NSAPI_ERROR_WOULD_BLOCK) { - break; - } + SocketAddress test; + if (!test.set_ip_address(NetworkInterface::get_default_instance()->get_ip_address())) { + return NSAPI_UNSPEC; } - sock.set_timeout(orig_timeout); + return test.get_ip_version(); } void fill_tx_buffer_ascii(char *buff, size_t len) @@ -71,6 +84,11 @@ void fill_tx_buffer_ascii(char *buff, size_t len) } } +int split2half_rmng_udp_test_time() +{ + return (udp_global::TESTS_TIMEOUT - tc_bucket.read()) / 2; +} + #if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE int fetch_stats() { @@ -81,20 +99,20 @@ int fetch_stats() // Test setup utest::v1::status_t greentea_setup(const size_t number_of_cases) { - GREENTEA_SETUP(480, "default_auto"); + GREENTEA_SETUP(udp_global::TESTS_TIMEOUT, "default_auto"); _ifup(); + tc_bucket.start(); return greentea_test_setup_handler(number_of_cases); } void greentea_teardown(const size_t passed, const size_t failed, const failure_t failure) { + tc_bucket.stop(); _ifdown(); return greentea_test_teardown_handler(passed, failed, failure); } Case cases[] = { - Case("UDPSOCKET_ECHOTEST", UDPSOCKET_ECHOTEST), - Case("UDPSOCKET_ECHOTEST_NONBLOCK", UDPSOCKET_ECHOTEST_NONBLOCK), Case("UDPSOCKET_OPEN_CLOSE_REPEAT", UDPSOCKET_OPEN_CLOSE_REPEAT), Case("UDPSOCKET_OPEN_LIMIT", UDPSOCKET_OPEN_LIMIT), Case("UDPSOCKET_RECV_TIMEOUT", UDPSOCKET_RECV_TIMEOUT), @@ -110,10 +128,11 @@ Case cases[] = { Case("UDPSOCKET_BIND_WRONG_TYPE", UDPSOCKET_BIND_WRONG_TYPE), Case("UDPSOCKET_BIND_UNOPENED", UDPSOCKET_BIND_UNOPENED), Case("UDPSOCKET_SENDTO_INVALID", UDPSOCKET_SENDTO_INVALID), - Case("UDPSOCKET_ECHOTEST", UDPSOCKET_ECHOTEST), - Case("UDPSOCKET_ECHOTEST_BURST", UDPSOCKET_ECHOTEST_BURST), + Case("UDPSOCKET_ECHOTEST_NONBLOCK", UDPSOCKET_ECHOTEST_NONBLOCK), Case("UDPSOCKET_ECHOTEST_BURST_NONBLOCK", UDPSOCKET_ECHOTEST_BURST_NONBLOCK), Case("UDPSOCKET_SENDTO_REPEAT", UDPSOCKET_SENDTO_REPEAT), + Case("UDPSOCKET_ECHOTEST", UDPSOCKET_ECHOTEST), + Case("UDPSOCKET_ECHOTEST_BURST", UDPSOCKET_ECHOTEST_BURST), }; Specification specification(greentea_setup, cases, greentea_teardown, greentea_continue_handlers); diff --git a/TESTS/netsocket/udp/udp_tests.h b/TESTS/netsocket/udp/udp_tests.h index b740ada298..a6222a786d 100644 --- a/TESTS/netsocket/udp/udp_tests.h +++ b/TESTS/netsocket/udp/udp_tests.h @@ -20,6 +20,7 @@ NetworkInterface *get_interface(); void drop_bad_packets(UDPSocket &sock, int orig_timeout); +nsapi_version_t get_ip_version(); void fill_tx_buffer_ascii(char *buff, size_t len); #if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE @@ -27,6 +28,15 @@ extern mbed_stats_socket_t udp_stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT]; int fetch_stats(void); #endif +/** + * Single testcase might take only half of the remaining execution time + */ +int split2half_rmng_udp_test_time(); // [s] + +namespace udp_global { +static const int TESTS_TIMEOUT = 480; +} + /* * Test cases */ diff --git a/TESTS/netsocket/udp/udpsocket_bind_address_invalid.cpp b/TESTS/netsocket/udp/udpsocket_bind_address_invalid.cpp index e0cee8a360..44b0717685 100644 --- a/TESTS/netsocket/udp/udpsocket_bind_address_invalid.cpp +++ b/TESTS/netsocket/udp/udpsocket_bind_address_invalid.cpp @@ -38,7 +38,16 @@ void UDPSOCKET_BIND_ADDRESS_INVALID() TEST_FAIL(); } TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(NetworkInterface::get_default_instance())); - nsapi_error_t bind_result = sock->bind("190.2.3.4", 1024); + + nsapi_error_t bind_result = NSAPI_ERROR_OK; + if (get_ip_version() == NSAPI_IPv4) { + bind_result = sock->bind("190.2.3.4", 1024); + } else if (get_ip_version() == NSAPI_IPv6) { + bind_result = sock->bind("fe80::ff01", 1024); + } else { + TEST_FAIL_MESSAGE("This stack is neither IPv4 nor IPv6"); + } + if (bind_result == NSAPI_ERROR_UNSUPPORTED) { TEST_IGNORE_MESSAGE("bind() not supported"); } else { diff --git a/TESTS/netsocket/udp/udpsocket_bind_wrong_type.cpp b/TESTS/netsocket/udp/udpsocket_bind_wrong_type.cpp index 5925af6254..f6a6e7928b 100644 --- a/TESTS/netsocket/udp/udpsocket_bind_wrong_type.cpp +++ b/TESTS/netsocket/udp/udpsocket_bind_wrong_type.cpp @@ -39,7 +39,14 @@ void UDPSOCKET_BIND_WRONG_TYPE() } TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(NetworkInterface::get_default_instance())); char addr_bytes[16] = {0xfe, 0x80, 0xff, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - SocketAddress sockAddr = SocketAddress(addr_bytes, NSAPI_IPv4, 80); + SocketAddress sockAddr; + if (get_ip_version() == NSAPI_IPv4) { + sockAddr = SocketAddress(addr_bytes, NSAPI_IPv4, 80); + } else if (get_ip_version() == NSAPI_IPv6) { + sockAddr = SocketAddress(addr_bytes, NSAPI_IPv6, 80); + } else { + TEST_FAIL_MESSAGE("This stack is neither IPv4 nor IPv6"); + } nsapi_error_t bind_result = sock->bind(sockAddr); if (bind_result == NSAPI_ERROR_UNSUPPORTED) { TEST_IGNORE_MESSAGE("bind() not supported"); diff --git a/TESTS/netsocket/udp/udpsocket_echotest.cpp b/TESTS/netsocket/udp/udpsocket_echotest.cpp index ffd3dc75e7..1457096fce 100644 --- a/TESTS/netsocket/udp/udpsocket_echotest.cpp +++ b/TESTS/netsocket/udp/udpsocket_echotest.cpp @@ -45,6 +45,8 @@ static const int pkt_sizes[PKTS] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, \ 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, \ 1100, 1200 }; +Timer tc_exec_time; +int time_allotted; } static void _sigio_handler(osThreadId id) @@ -106,6 +108,9 @@ void udpsocket_echotest_nonblock_receiver(void *receive_bytes) for (int retry_cnt = 0; retry_cnt <= RETRIES; retry_cnt++) { recvd = sock.recvfrom(NULL, rx_buffer, expt2recv); if (recvd == NSAPI_ERROR_WOULD_BLOCK) { + if (tc_exec_time.read() >= time_allotted) { + break; + } wait_ms(WAIT2RECV_TIMEOUT); --retry_cnt; continue; @@ -118,7 +123,7 @@ void udpsocket_echotest_nonblock_receiver(void *receive_bytes) } } - drop_bad_packets(sock, -1); // timeout equivalent to set_blocking(false) + drop_bad_packets(sock, 0); // timeout equivalent to set_blocking(false) tx_sem.release(); } @@ -132,6 +137,8 @@ void UDPSOCKET_ECHOTEST_NONBLOCK() TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state); } #endif + tc_exec_time.start(); + time_allotted = split2half_rmng_udp_test_time(); // [s] SocketAddress udp_addr; NetworkInterface::get_default_instance()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &udp_addr); @@ -166,7 +173,8 @@ void UDPSOCKET_ECHOTEST_NONBLOCK() packets_sent++; } if (sent == NSAPI_ERROR_WOULD_BLOCK) { - if (osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { + if (tc_exec_time.read() >= time_allotted || + osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { continue; } --retry_cnt; @@ -209,4 +217,5 @@ void UDPSOCKET_ECHOTEST_NONBLOCK() #endif } TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close()); + tc_exec_time.stop(); } diff --git a/TESTS/netsocket/udp/udpsocket_recv_timeout.cpp b/TESTS/netsocket/udp/udpsocket_recv_timeout.cpp index 3592d307ce..6db0e22b82 100644 --- a/TESTS/netsocket/udp/udpsocket_recv_timeout.cpp +++ b/TESTS/netsocket/udp/udpsocket_recv_timeout.cpp @@ -62,7 +62,7 @@ void UDPSOCKET_RECV_TIMEOUT() if (recvd == NSAPI_ERROR_WOULD_BLOCK) { osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT); printf("MBED: recvfrom() took: %dms\n", timer.read_ms()); - TEST_ASSERT_INT_WITHIN(50, 150, timer.read_ms()); + TEST_ASSERT_INT_WITHIN(51, 150, timer.read_ms()); continue; } else if (recvd < 0) { printf("[bt#%02d] network error %d\n", i, recvd); diff --git a/TESTS/network/emac/main.cpp b/TESTS/network/emac/main.cpp index 49ee3cf909..8da3492421 100644 --- a/TESTS/network/emac/main.cpp +++ b/TESTS/network/emac/main.cpp @@ -35,7 +35,8 @@ !defined(TARGET_MTB_ADV_WISE_1530) && \ !defined(TARGET_MTB_USI_WM_BN_BM_22) && \ !defined(TARGET_MTB_MXCHIP_EMW3166) && \ - !defined(TARGET_MTB_UBLOX_ODIN_W2) + !defined(TARGET_MTB_UBLOX_ODIN_W2) && \ + !defined(TARGET_UNO_91H) #error [NOT_SUPPORTED] Wifi tests are not valid for the target #endif #endif diff --git a/TESTS/network/interface/networkinterface_status.cpp b/TESTS/network/interface/networkinterface_status.cpp index 32d1a2bd8e..f19a31fa9b 100644 --- a/TESTS/network/interface/networkinterface_status.cpp +++ b/TESTS/network/interface/networkinterface_status.cpp @@ -137,8 +137,6 @@ void NETWORKINTERFACE_STATUS_NONBLOCK() void NETWORKINTERFACE_STATUS_GET() { - nsapi_connection_status_t status; - net = NetworkInterface::get_default_instance(); net->set_blocking(true); diff --git a/TESTS/network/wifi/main.cpp b/TESTS/network/wifi/main.cpp index aeb139137a..10d5c4c4df 100644 --- a/TESTS/network/wifi/main.cpp +++ b/TESTS/network/wifi/main.cpp @@ -52,7 +52,7 @@ using namespace utest::v1; utest::v1::status_t test_setup(const size_t number_of_cases) { - GREENTEA_SETUP(240, "default_auto"); + GREENTEA_SETUP(360, "default_auto"); return verbose_test_setup_handler(number_of_cases); } diff --git a/TESTS/network/wifi/wifi_tests.h b/TESTS/network/wifi/wifi_tests.h index b7d598b8b6..d5f8eea39e 100644 --- a/TESTS/network/wifi/wifi_tests.h +++ b/TESTS/network/wifi/wifi_tests.h @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2018-2019, Arm Limited and affiliates. + * 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 + * + * 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. + */ #ifndef WIFI_TESTS_H #define WIFI_TESTS_H diff --git a/UNITTESTS/CMakeLists.txt b/UNITTESTS/CMakeLists.txt index 7e93bf5c68..112aa373ea 100644 --- a/UNITTESTS/CMakeLists.txt +++ b/UNITTESTS/CMakeLists.txt @@ -59,7 +59,7 @@ target_include_directories(gmock_main SYSTEM BEFORE INTERFACE # TESTING #################### -enable_testing() +include(CTest) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/Testing" diff --git a/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp b/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp index 11a27e9d20..93ff3d29e0 100644 --- a/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp +++ b/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp @@ -181,6 +181,10 @@ TEST_F(Test_LoRaPHYAU915, link_ADR_request) uint8_t nb_rep_out = 0; uint8_t nb_bytes_parsed = 0; + uint8_t payload [] = {SRV_MAC_LINK_ADR_REQ, 1, 2, 3, 4}; + params.payload = payload; + params.payload_size = 5; + LoRaPHY_stub::uint8_value = 1; LoRaPHY_stub::ch_mask_value = 6; LoRaPHY_stub::adr_parse_count = 2; diff --git a/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp b/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp index abeefd52d6..20e8fc3be2 100644 --- a/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp +++ b/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp @@ -206,6 +206,10 @@ TEST_F(Test_LoRaPHYCN470, link_ADR_request) uint8_t nb_rep_out = 0; uint8_t nb_bytes_parsed = 0; + uint8_t payload [] = {SRV_MAC_LINK_ADR_REQ, 1, 2, 3, 4}; + params.payload = payload; + params.payload_size = 5; + LoRaPHY_stub::uint8_value = 1; LoRaPHY_stub::ch_mask_value = 6; LoRaPHY_stub::adr_parse_count = 2; diff --git a/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp b/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp index b3d921bac9..36e3a15e78 100644 --- a/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp +++ b/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp @@ -177,6 +177,7 @@ TEST_F(Test_LoRaPHYUS915, tx_config) TEST_F(Test_LoRaPHYUS915, link_ADR_request) { + uint8_t payload [] = {SRV_MAC_LINK_ADR_REQ, 1, 2, 3, 4}; adr_req_params_t params; memset(¶ms, 0, sizeof(params)); int8_t dr_out = 0; @@ -184,8 +185,14 @@ TEST_F(Test_LoRaPHYUS915, link_ADR_request) uint8_t nb_rep_out = 0; uint8_t nb_bytes_parsed = 0; - EXPECT_TRUE(0 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + params.payload = payload; + params.payload_size = 4; + uint8_t status = object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed); + + EXPECT_TRUE(0 == nb_bytes_parsed); + + params.payload_size = 5; LoRaPHY_stub::uint8_value = 1; LoRaPHY_stub::ch_mask_value = 6; LoRaPHY_stub::adr_parse_count = 2; diff --git a/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp b/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp index 15a2942001..e91f842055 100644 --- a/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp +++ b/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp @@ -494,6 +494,10 @@ TEST_F(Test_LoRaWANStack, handle_rx) ind.buffer = ind_buf; ind.buffer_size = 150; ind.type = MCPS_UNCONFIRMED; + ind.port = 15; + ind.is_data_recvd = true; + ind.fpending_status = false; + LoRaMac_stub::dev_class_value = CLASS_A; radio._ev->rx_done(NULL, 0, 0, 0); //data == NULL || LENGTH == 0 (2 cases) diff --git a/UNITTESTS/stubs/LoRaPHY_stub.cpp b/UNITTESTS/stubs/LoRaPHY_stub.cpp index 01b7312b7c..53dce9fe4f 100644 --- a/UNITTESTS/stubs/LoRaPHY_stub.cpp +++ b/UNITTESTS/stubs/LoRaPHY_stub.cpp @@ -151,9 +151,12 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle, } uint8_t LoRaPHY::parse_link_ADR_req(const uint8_t *payload, + uint8_t payload_size, link_adr_params_t *params) { params->ch_mask_ctrl = LoRaPHY_stub::ch_mask_value; + params->channel_mask = 0; + params->datarate = 0; if (LoRaPHY_stub::adr_parse_count) { return --LoRaPHY_stub::adr_parse_count; diff --git a/cmsis/mbed_cmsis_conf.h b/cmsis/mbed_cmsis_conf.h index d5ba37c8b2..2a79698992 100644 --- a/cmsis/mbed_cmsis_conf.h +++ b/cmsis/mbed_cmsis_conf.h @@ -1,23 +1,18 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2012 ARM Limited +/* + * Copyright (c) 2018-2019, Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * 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 * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * 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. */ #ifndef MBED_CMSIS_CONF_H #define MBED_CMSIS_CONF_H diff --git a/components/storage/blockdevice/COMPONENT_SPIF/TESTS/block_device/spif/main.cpp b/components/storage/blockdevice/COMPONENT_SPIF/TESTS/block_device/spif/main.cpp index c012c4a6e9..ad2b2636ed 100644 --- a/components/storage/blockdevice/COMPONENT_SPIF/TESTS/block_device/spif/main.cpp +++ b/components/storage/blockdevice/COMPONENT_SPIF/TESTS/block_device/spif/main.cpp @@ -47,6 +47,11 @@ void basic_erase_program_read_test(SPIFBlockDevice &block_device, bd_size_t bloc { int err = 0; _mutex->lock(); + + // Make sure block address per each test is unique + static unsigned block_seed = 1; + srand(block_seed++); + // Find a random block bd_addr_t block = (rand() * block_size) % block_device.size(); diff --git a/components/wifi/esp8266-driver/ESP8266Interface.cpp b/components/wifi/esp8266-driver/ESP8266Interface.cpp index eea53d71a4..f3e7d4b7de 100644 --- a/components/wifi/esp8266-driver/ESP8266Interface.cpp +++ b/components/wifi/esp8266-driver/ESP8266Interface.cpp @@ -58,6 +58,7 @@ ESP8266Interface::ESP8266Interface() _if_blocking(true), _if_connected(_cmutex), _initialized(false), + _connect_retval(NSAPI_ERROR_OK), _conn_stat(NSAPI_STATUS_DISCONNECTED), _conn_stat_cb(NULL), _global_event_queue(NULL), @@ -187,8 +188,12 @@ void ESP8266Interface::_connect_async() _cmutex.unlock(); return; } - - if (_esp.connect(ap_ssid, ap_pass) != NSAPI_ERROR_OK) { + _connect_retval = _esp.connect(ap_ssid, ap_pass); + if (_connect_retval == NSAPI_ERROR_OK || _connect_retval == NSAPI_ERROR_AUTH_FAILURE + || _connect_retval == NSAPI_ERROR_NO_SSID) { + _connect_event_id = 0; + _if_connected.notify_all(); + } else { // Postpone to give other stuff time to run _connect_event_id = _global_event_queue->call_in(ESP8266_CONNECT_TIMEOUT, callback(this, &ESP8266Interface::_connect_async)); @@ -196,9 +201,6 @@ void ESP8266Interface::_connect_async() MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \ "_connect_async(): unable to add event to queue"); } - } else { - _connect_event_id = 0; - _if_connected.notify_all(); } _cmutex.unlock(); } @@ -235,6 +237,7 @@ int ESP8266Interface::connect() _cmutex.lock(); + _connect_retval = NSAPI_ERROR_NO_CONNECTION; MBED_ASSERT(!_connect_event_id); _connect_event_id = _global_event_queue->call(callback(this, &ESP8266Interface::_connect_async)); @@ -243,13 +246,18 @@ int ESP8266Interface::connect() "connect(): unable to add event to queue"); } - while (_if_blocking && (_conn_status_to_error() != NSAPI_ERROR_IS_CONNECTED)) { + while (_if_blocking && (_conn_status_to_error() != NSAPI_ERROR_IS_CONNECTED) + && (_connect_retval == NSAPI_ERROR_NO_CONNECTION)) { _if_connected.wait(); } _cmutex.unlock(); - return NSAPI_ERROR_OK; + if (!_if_blocking) { + return NSAPI_ERROR_OK; + } else { + return _connect_retval; + } } int ESP8266Interface::set_credentials(const char *ssid, const char *pass, nsapi_security_t security) diff --git a/components/wifi/esp8266-driver/ESP8266Interface.h b/components/wifi/esp8266-driver/ESP8266Interface.h index f123cf27cd..93d455120f 100644 --- a/components/wifi/esp8266-driver/ESP8266Interface.h +++ b/components/wifi/esp8266-driver/ESP8266Interface.h @@ -368,6 +368,7 @@ private: bool _get_firmware_ok(); nsapi_error_t _init(void); void _hw_reset(); + nsapi_error_t _connect_retval; //sigio struct { diff --git a/features/FEATURE_BLE/ble/gap/AdvertisingDataSimpleBuilder.h b/features/FEATURE_BLE/ble/gap/AdvertisingDataSimpleBuilder.h index 9c529f4a09..0358672e5b 100644 --- a/features/FEATURE_BLE/ble/gap/AdvertisingDataSimpleBuilder.h +++ b/features/FEATURE_BLE/ble/gap/AdvertisingDataSimpleBuilder.h @@ -158,6 +158,7 @@ public: AdvertisingDataSimpleBuilder &setAdvertisingInterval(adv_interval_t interval) { MBED_ASSERT(_builder.setAdvertisingInterval(interval) == BLE_ERROR_NONE); + return *this; } /** diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioGattServer.cpp b/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioGattServer.cpp index 8a096aab26..e553256087 100644 --- a/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioGattServer.cpp +++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioGattServer.cpp @@ -294,7 +294,7 @@ ble_error_t GattServer::insert_characteristic_value_attribute( attribute_it->settings = ATTS_SET_READ_CBACK; } if (properties & WRITABLE_PROPERTIES) { - attribute_it->settings = ATTS_SET_WRITE_CBACK; + attribute_it->settings |= ATTS_SET_WRITE_CBACK; } if (value_attribute.getUUID().shortOrLong() == UUID::UUID_TYPE_LONG) { attribute_it->settings |= ATTS_SET_UUID_128; diff --git a/features/FEATURE_BLE/targets/TARGET_Cypress/TARGET_CYW43XXX/HCIDriver.cpp b/features/FEATURE_BLE/targets/TARGET_Cypress/TARGET_CYW43XXX/HCIDriver.cpp index 3b5bf8ef50..3288b568e0 100644 --- a/features/FEATURE_BLE/targets/TARGET_Cypress/TARGET_CYW43XXX/HCIDriver.cpp +++ b/features/FEATURE_BLE/targets/TARGET_Cypress/TARGET_CYW43XXX/HCIDriver.cpp @@ -75,11 +75,10 @@ public: virtual void do_initialize() { - - Cy_GPIO_Clr(BT_DEVICE_WAKE_PORT, BT_DEVICE_WAKE_PIN); + bt_device_wake = 0; wait_ms(500); - Cy_GPIO_Set(BT_POWER_PORT, BT_POWER_PIN); + bt_power = 1; wait_ms(500); } diff --git a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/btle/btle.cpp b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/btle/btle.cpp index a0ce8bbeb9..962ddef9b7 100644 --- a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/btle/btle.cpp +++ b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/btle/btle.cpp @@ -112,7 +112,6 @@ static uint32_t signalEvent() error_t btle_init(void) { - nrf_clock_lf_cfg_t clockConfiguration; ret_code_t err_code; // register softdevice handler vector @@ -122,6 +121,7 @@ error_t btle_init(void) err_code = nrf_sdh_enable_request(); ASSERT_STATUS(err_code); #else + nrf_clock_lf_cfg_t clockConfiguration; // Configure the LF clock according to values provided by btle_clock.h. // It is input from the chain of the yotta configuration system. clockConfiguration.source = LFCLK_CONF_SOURCE; diff --git a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/nRF5xPalSecurityManager.cpp b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/nRF5xPalSecurityManager.cpp index 01126720b4..78904d3312 100644 --- a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/nRF5xPalSecurityManager.cpp +++ b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/nRF5xPalSecurityManager.cpp @@ -107,15 +107,17 @@ nRF5xSecurityManager::~nRF5xSecurityManager() ble_error_t nRF5xSecurityManager::initialize() { #if defined(MBEDTLS_ECDH_C) - if (_crypto.generate_keys( + // Note: we do not use the object on the stack as the CryptoToolbox is quite large + // Please do not change or we risk a stack overflow. + CryptoToolbox* crypto = new CryptoToolbox(); + bool success = crypto->generate_keys( make_ArrayView(X), make_ArrayView(Y), make_ArrayView(secret) - )) { - return BLE_ERROR_NONE; - } + ); + delete crypto; - return BLE_ERROR_INTERNAL_STACK_FAILURE; + return success ? BLE_ERROR_NONE : BLE_ERROR_INTERNAL_STACK_FAILURE; #endif return BLE_ERROR_NONE; } @@ -943,12 +945,16 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt) static const size_t key_size = public_key_coord_t::size_; ble_gap_lesc_dhkey_t shared_secret; - _crypto.generate_shared_secret( + // Allocated on the heap to reduce stack pressure. + // Risk stack overflows if allocated on stack. + CryptoToolbox* crypto = new CryptoToolbox(); + crypto->generate_shared_secret( make_const_ArrayView(dhkey_request.p_pk_peer->pk), make_const_ArrayView(dhkey_request.p_pk_peer->pk + key_size), make_const_ArrayView(secret), shared_secret.key ); + delete crypto; sd_ble_gap_lesc_dhkey_reply(connection, &shared_secret); diff --git a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/nRF5xPalSecurityManager.h b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/nRF5xPalSecurityManager.h index 30ac7e20cc..b5a55d9dc0 100644 --- a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/nRF5xPalSecurityManager.h +++ b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/nRF5xPalSecurityManager.h @@ -360,7 +360,6 @@ private: pairing_control_block_t* _control_blocks; #if defined(MBEDTLS_ECDH_C) - CryptoToolbox _crypto; ble::public_key_coord_t X; ble::public_key_coord_t Y; ble::public_key_coord_t secret; diff --git a/features/cellular/framework/AT/AT_CellularStack.cpp b/features/cellular/framework/AT/AT_CellularStack.cpp index a43e2ebd89..ad4932c072 100644 --- a/features/cellular/framework/AT/AT_CellularStack.cpp +++ b/features/cellular/framework/AT/AT_CellularStack.cpp @@ -198,15 +198,21 @@ nsapi_error_t AT_CellularStack::socket_bind(nsapi_socket_t handle, const SocketA } if (addr) { - socket->localAddress.set_addr(addr.get_addr()); - } - - if (addr.get_port()) { - socket->localAddress.set_port(addr.get_port()); + return NSAPI_ERROR_UNSUPPORTED; } _at.lock(); + uint16_t port = addr.get_port(); + if (port != socket->localAddress.get_port()) { + if (port && (get_socket_index_by_port(port) == -1)) { + socket->localAddress.set_port(port); + } else { + _at.unlock(); + return NSAPI_ERROR_PARAMETER; + } + } + if (!socket->created) { create_socket_impl(socket); } @@ -340,3 +346,14 @@ void AT_CellularStack::socket_attach(nsapi_socket_t handle, void (*callback)(voi socket->_cb = callback; socket->_data = data; } + +int AT_CellularStack::get_socket_index_by_port(uint16_t port) +{ + int max_socket_count = get_max_socket_count(); + for (int i = 0; i < max_socket_count; i++) { + if (_socket[i]->localAddress.get_port() == port) { + return i; + } + } + return -1; +} diff --git a/features/cellular/framework/AT/AT_CellularStack.h b/features/cellular/framework/AT/AT_CellularStack.h index 2c25da1579..8ce5764665 100644 --- a/features/cellular/framework/AT/AT_CellularStack.h +++ b/features/cellular/framework/AT/AT_CellularStack.h @@ -184,6 +184,8 @@ protected: private: int find_socket_index(nsapi_socket_t handle); + int get_socket_index_by_port(uint16_t port); + // mutex for write/read to a _socket array, needed when multiple threads may open sockets simultaneously PlatformMutex _socket_mutex; }; diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp index 8d79fa6c74..59ec9487f4 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp @@ -62,6 +62,10 @@ nsapi_error_t QUECTEL_BG96_CellularStack::socket_connect(nsapi_socket_t handle, handle_open_socket_response(modem_connect_id, err); if ((_at.get_last_error() == NSAPI_ERROR_OK) && err) { + if (err == BG96_SOCKET_BIND_FAIL) { + socket->created = false; + return NSAPI_ERROR_PARAMETER; + } _at.cmd_start("AT+QICLOSE="); _at.write_int(modem_connect_id); _at.cmd_stop(); @@ -178,6 +182,10 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc handle_open_socket_response(modem_connect_id, err); if ((_at.get_last_error() == NSAPI_ERROR_OK) && err) { + if (err == BG96_SOCKET_BIND_FAIL) { + socket->created = false; + return NSAPI_ERROR_PARAMETER; + } _at.cmd_start("AT+QICLOSE="); _at.write_int(modem_connect_id); _at.cmd_stop_read_resp(); @@ -206,6 +214,10 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc handle_open_socket_response(modem_connect_id, err); if ((_at.get_last_error() == NSAPI_ERROR_OK) && err) { + if (err == BG96_SOCKET_BIND_FAIL) { + socket->created = false; + return NSAPI_ERROR_PARAMETER; + } _at.cmd_start("AT+QICLOSE="); _at.write_int(modem_connect_id); _at.cmd_stop_read_resp(); @@ -239,6 +251,14 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl(CellularSocket *socket, const SocketAddress &address, const void *data, nsapi_size_t size) { + if (size > BG96_MAX_SEND_SIZE) { + return NSAPI_ERROR_PARAMETER; + } + + if (!size && socket->proto == NSAPI_UDP) { + return NSAPI_ERROR_UNSUPPORTED; + } + int sent_len = 0; int sent_len_before = 0; int sent_len_after = 0; @@ -296,6 +316,11 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_recvfrom_impl(CellularS _at.cmd_start("AT+QIRD="); _at.write_int(socket->id); + if (socket->proto == NSAPI_TCP) { + // do not read more than max size + size = size > BG96_MAX_RECV_SIZE ? BG96_MAX_RECV_SIZE : size; + _at.write_int(size); + } _at.cmd_stop(); _at.resp_start("+QIRD:"); @@ -303,11 +328,15 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_recvfrom_impl(CellularS _at.read_string(ip_address, sizeof(ip_address)); port = _at.read_int(); if (recv_len > 0) { + // do not read more than buffer size + recv_len = recv_len > size ? size : recv_len; _at.read_bytes((uint8_t *)buffer, recv_len); } _at.resp_stop(); - if (!recv_len || (_at.get_last_error() != NSAPI_ERROR_OK)) { + // We block only if 0 recv length really means no data. + // If 0 is followed by ip address and port can be an UDP 0 length packet + if (!recv_len && port < 0) { return NSAPI_ERROR_WOULD_BLOCK; } diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h index 1b8e547530..e8eb670c1c 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h @@ -25,6 +25,9 @@ namespace mbed { #define BG96_SOCKET_MAX 12 #define BG96_CREATE_SOCKET_TIMEOUT 150000 //150 seconds #define BG96_CLOSE_SOCKET_TIMEOUT 20000 // TCP socket max timeout is >10sec +#define BG96_MAX_RECV_SIZE 1500 +#define BG96_MAX_SEND_SIZE 1460 +#define BG96_SOCKET_BIND_FAIL 556 class QUECTEL_BG96_CellularStack : public AT_CellularStack { public: diff --git a/features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26_CellularStack.cpp b/features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26_CellularStack.cpp index 20515438a2..0840edee8d 100644 --- a/features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26_CellularStack.cpp +++ b/features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26_CellularStack.cpp @@ -361,10 +361,10 @@ nsapi_size_or_error_t QUECTEL_M26_CellularStack::socket_sendto_impl(CellularSock const void *data, nsapi_size_t size) { int sent_len = (size > M26_SENT_BYTE_MAX) ? M26_SENT_BYTE_MAX : size; - int sent_acked = 0; int sent_nacked = 0; int sent_len_before = 0; int sent_len_after = 0; + int sent_acked; nsapi_error_t error; tr_debug("QUECTEL_M26_CellularStack:%s:%u:[%d-%d]", __FUNCTION__, __LINE__, sent_len, size); diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularNetwork.cpp b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularNetwork.cpp index 1491deee60..24b6a19c72 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularNetwork.cpp +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularNetwork.cpp @@ -38,6 +38,8 @@ AT_CellularNetwork::RegistrationMode UBLOX_AT_CellularNetwork::has_registration( nsapi_error_t UBLOX_AT_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat) { + nsapi_error_t ret = NSAPI_ERROR_OK; + switch (opRat) { #if defined(TARGET_UBLOX_C030_U201) || defined(TARGET_UBLOX_C027) case RAT_GSM: @@ -63,9 +65,9 @@ nsapi_error_t UBLOX_AT_CellularNetwork::set_access_technology_impl(RadioAccessTe #endif default: { _op_act = RAT_UNKNOWN; - return NSAPI_ERROR_UNSUPPORTED; + ret = NSAPI_ERROR_UNSUPPORTED; } } - return NSAPI_ERROR_OK; + return(ret); } diff --git a/features/frameworks/mbed-coap/.yotta_ignore b/features/frameworks/mbed-coap/.yotta_ignore deleted file mode 100644 index 6cd3f5174f..0000000000 --- a/features/frameworks/mbed-coap/.yotta_ignore +++ /dev/null @@ -1,5 +0,0 @@ -# need unity.h: -unittest/* -test/* -doxygen/* - diff --git a/features/frameworks/mbed-coap/CHANGELOG.md b/features/frameworks/mbed-coap/CHANGELOG.md index 7da355071f..4e0355bf70 100644 --- a/features/frameworks/mbed-coap/CHANGELOG.md +++ b/features/frameworks/mbed-coap/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## [v4.7.4](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.7.4) + +- Remove dependency to yotta tool +- Do not remove stored (GET) blockwise message when EMPTY ACK received + When non piggybacked response mode is used original GET request must not be removed from the stored message list. + Message is needed for building the next (GET) blockwise message. +- Move definitions to sn_config.h + +-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.7.3...v4.7.4) + ## [v4.7.3](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.7.3) - Do not store EMPTY response to blockwise list diff --git a/features/frameworks/mbed-coap/Makefile.test b/features/frameworks/mbed-coap/Makefile.test index 4cc7296c5f..78cf60fbbc 100644 --- a/features/frameworks/mbed-coap/Makefile.test +++ b/features/frameworks/mbed-coap/Makefile.test @@ -11,6 +11,28 @@ TESTDIRS := $(UNITTESTS:%=build-%) CLEANTESTDIRS := $(UNITTESTS:%=clean-%) COVERAGEFILE := ./lcov/coverage.info +TEST_MODULES = ./test_modules +TEST_MODULE_MBED_TRACE = $(TEST_MODULES)/mbed-trace +TEST_MODULE_NANOSTACK = $(TEST_MODULES)/nanostack-libservice +TEST_MODULE_RANDLIB = $(TEST_MODULES)/mbed-client-randlib + +.PHONY: clone +clone: + if [ ! -d $(TEST_MODULES) ]; \ + then mkdir $(TEST_MODULES); \ + fi; + + if [ ! -d $(TEST_MODULE_MBED_TRACE) ]; \ + then git clone --depth 1 git@github.com:ARMmbed/mbed-trace.git $(TEST_MODULE_MBED_TRACE); \ + fi; + + if [ ! -d $(TEST_MODULE_NANOSTACK) ]; \ + then git clone --depth 1 git@github.com:ARMmbed/nanostack-libservice.git $(TEST_MODULE_NANOSTACK); \ + fi; + + if [ ! -d $(TEST_MODULE_RANDLIB) ]; \ + then git clone --depth 1 git@github.com:ARMmbed/mbed-client-randlib.git $(TEST_MODULE_RANDLIB); \ + fi; .PHONY: test test: $(TESTDIRS) @rm -rf ./lcov @@ -27,7 +49,7 @@ test: $(TESTDIRS) @rm -f lcov/index.xml @find ./ -name '*.gcno' | xargs cp --backup=numbered -t ./coverage/ @find ./ -name '*.gcda' | xargs cp --backup=numbered -t ./coverage/ - @gcovr --object-directory ./coverage --exclude-unreachable-branches -e '.*/builds/.*' -e '.*/test/.*' -e '.*/yotta_modules/.*' -e '.*/stubs/.*' -e '.*/mbed-coap/.*' -x -o ./lcov/gcovr.xml + @gcovr --object-directory ./coverage --exclude-unreachable-branches -e '.*/builds/.*' -e '.*/test/.*' -e '.*/stubs/.*' -e '.*/mbed-coap/.*' -x -o ./lcov/gcovr.xml @lcov -d test/. -c -o $(COVERAGEFILE) @lcov -q -r $(COVERAGEFILE) "/usr*" -o $(COVERAGEFILE) @lcov -q -r $(COVERAGEFILE) "/test*" -o $(COVERAGEFILE) diff --git a/features/frameworks/mbed-coap/mbed-coap/sn_config.h b/features/frameworks/mbed-coap/mbed-coap/sn_config.h index 5794af5cbc..63652826ed 100644 --- a/features/frameworks/mbed-coap/mbed-coap/sn_config.h +++ b/features/frameworks/mbed-coap/mbed-coap/sn_config.h @@ -17,6 +17,10 @@ #ifndef SN_CONFIG_H #define SN_CONFIG_H +#ifdef MBED_CLIENT_USER_CONFIG_FILE +#include MBED_CLIENT_USER_CONFIG_FILE +#endif + /** * \brief Configuration options (set of defines and values) * @@ -30,9 +34,15 @@ * \brief For Message duplication detection * Init value for the maximum count of messages to be stored for duplication detection * Setting of this value to 0 will disable duplication check, also reduce use of ROM memory - * Default is set to 1. + * Default is set to 0. */ -#undef SN_COAP_DUPLICATION_MAX_MSGS_COUNT /* 1 */ +#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_DUPLICATION_MAX_MSGS_COUNT +#define SN_COAP_DUPLICATION_MAX_MSGS_COUNT MBED_CONF_MBED_CLIENT_SN_COAP_DUPLICATION_MAX_MSGS_COUNT +#endif + +#ifndef SN_COAP_DUPLICATION_MAX_MSGS_COUNT +#define SN_COAP_DUPLICATION_MAX_MSGS_COUNT 0 +#endif /** * \def SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE @@ -42,7 +52,13 @@ * also reduce use of ROM memory. * Note: This define is common for both received and sent Blockwise messages */ -#undef SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* 0 */ // < Must be 2^x and x is at least 4. Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024 +#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE +#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE MBED_CONF_MBED_CLIENT_SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE +#endif + +#ifndef SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE +#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE 0 /**< Must be 2^x and x is at least 4. Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024 */ +#endif /** * \def SN_COAP_DISABLE_RESENDINGS @@ -50,21 +66,33 @@ * when using CoAP with TCP transport for example. By default resendings are * enabled. Set to 1 to disable. */ -#undef SN_COAP_DISABLE_RESENDINGS /* 0 */ // < Default re-sending are not disabled. Set to 1 to disable re-sendings +#ifdef SN_COAP_DISABLE_RESENDINGS +#define ENABLE_RESENDINGS 0 /** Disable resendings **/ +#else +#define ENABLE_RESENDINGS 1 /**< Enable / Disable resending from library in building */ +#endif /** * \def SN_COAP_RESENDING_QUEUE_SIZE_MSGS * \brief Sets the number of messages stored * in the resending queue. Default is 2 */ -#undef SN_COAP_RESENDING_QUEUE_SIZE_MSGS /* 2 */ // < Default re-sending queue size - defines how many messages can be stored. Setting this to 0 disables feature +#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_MSGS +#define SN_COAP_RESENDING_QUEUE_SIZE_MSGS MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_MSGS +#endif + +#ifndef SN_COAP_RESENDING_QUEUE_SIZE_MSGS +#define SN_COAP_RESENDING_QUEUE_SIZE_MSGS 2 /**< Default re-sending queue size - defines how many messages can be stored. Setting this to 0 disables feature */ +#endif /** * \def DEFAULT_RESPONSE_TIMEOUT * \brief Sets the CoAP re-send interval in seconds. * By default is 10 seconds. */ -#undef DEFAULT_RESPONSE_TIMEOUT +#ifndef DEFAULT_RESPONSE_TIMEOUT +#define DEFAULT_RESPONSE_TIMEOUT 10 /**< Default re-sending timeout as seconds */ +#endif /** * \def SN_COAP_RESENDING_QUEUE_SIZE_BYTES @@ -72,7 +100,13 @@ * Setting this to 0 disables this feature. * By default, this feature is disabled. */ -#undef SN_COAP_RESENDING_QUEUE_SIZE_BYTES /* 0 */ // Default re-sending queue size - defines size of the re-sending buffer. Setting this to 0 disables feature +#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_BYTES +#define SN_COAP_RESENDING_QUEUE_SIZE_BYTES MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_BYTES +#endif + +#ifndef SN_COAP_RESENDING_QUEUE_SIZE_BYTES +#define SN_COAP_RESENDING_QUEUE_SIZE_BYTES 0 /**< Default re-sending queue size - defines size of the re-sending buffer. Setting this to 0 disables feature */ +#endif /** * \def SN_COAP_MAX_INCOMING_MESSAGE_SIZE @@ -83,7 +117,9 @@ * available storage capability. * By default, maximum size is UINT16_MAX, 65535 bytes. */ -#undef SN_COAP_MAX_INCOMING_MESSAGE_SIZE /* UINT16_MAX */ +#ifndef SN_COAP_MAX_INCOMING_MESSAGE_SIZE +#define SN_COAP_MAX_INCOMING_MESSAGE_SIZE UINT16_MAX +#endif /** * \def SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE @@ -98,21 +134,27 @@ * Note that value should be less than transport layer maximum fragment size. * Note that value has no effect if blockwise transfer is disabled. */ -#undef SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE /* 0 */ +#ifndef SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE +#define SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE 0 +#endif /** * \def SN_COAP_BLOCKWISE_ENABLED * \brief Enables the blockwise functionality in CoAP library also when blockwise payload * size is set to '0' in SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE. */ -#undef SN_COAP_BLOCKWISE_ENABLED /* 0 */ +#ifndef SN_COAP_BLOCKWISE_ENABLED +#define SN_COAP_BLOCKWISE_ENABLED 0 /**< Enable blockwise */ +#endif /** * \def SN_COAP_RESENDING_MAX_COUNT * \brief Defines how many times CoAP library tries to re-send the CoAP packet. * By default value is 3. */ -#undef SN_COAP_RESENDING_MAX_COUNT /* 3 */ +#ifndef SN_COAP_RESENDING_MAX_COUNT +#define SN_COAP_RESENDING_MAX_COUNT 3 +#endif /** * \def SN_COAP_MAX_ALLOWED_RESENDING_COUNT @@ -120,7 +162,9 @@ * 'sn_coap_protocol_set_retransmission_parameters()' API. * By default value is 6. */ -#undef SN_COAP_MAX_ALLOWED_RESENDING_COUNT /* 6 */ +#ifndef SN_COAP_MAX_ALLOWED_RESENDING_COUNT +#define SN_COAP_MAX_ALLOWED_RESENDING_COUNT 6 /**< Maximum allowed count of re-sending */ +#endif /** * \def SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT @@ -128,7 +172,9 @@ * 'sn_coap_protocol_set_retransmission_parameters()' API. * By default value is 40. */ -#undef SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT /* 40 */ +#ifndef SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT +#define SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT 40 /**< Maximum allowed re-sending timeout */ +#endif /** * \def SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS @@ -136,7 +182,9 @@ * 'sn_coap_protocol_set_retransmission_buffer()' API. * By default value is 6. */ -#undef SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS /* 6 */ +#ifndef SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS +#define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS 6 /**< Maximum allowed number of saved re-sending messages */ +#endif /** * \def SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES @@ -144,7 +192,9 @@ * 'sn_coap_protocol_set_retransmission_buffer()' API. * By default value is 512. */ -#undef SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES /* 512 */ +#ifndef SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES +#define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES 512 /**< Maximum allowed size of re-sending buffer */ +#endif /** * \def SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT @@ -152,14 +202,18 @@ * that can be set via 'sn_coap_protocol_set_duplicate_buffer_size' API. * By default value is 6. */ -#undef SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT +#ifndef SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT +#define SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT 6 +#endif /** * \def SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED * \brief Maximum time in seconds howe long message is kept for duplicate detection. * By default 60 seconds. */ -#undef SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED +#ifndef SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED +#define SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED 60 /** RESPONSE_TIMEOUT * RESPONSE_RANDOM_FACTOR * (2 ^ MAX_RETRANSMIT - 1) + the expected maximum round trip time **/ +#endif /** * \def SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED @@ -167,17 +221,25 @@ * Longer time will increase the memory consumption in lossy networks. * By default 60 seconds. */ -#undef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED +#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED +#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED MBED_CONF_MBED_CLIENT_SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED +#endif + +#ifndef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED +#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED 60 /**< Maximum time in seconds of data (messages and payload) to be stored for blockwising */ +#endif /** * \def SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE * \brief Maximum size of blockwise message that can be received. * By default 65535 bytes. */ -#undef SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE +#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_MAX_INCOMING_MESSAGE_SIZE +#define SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE MBED_CONF_MBED_CLIENT_SN_COAP_MAX_INCOMING_MESSAGE_SIZE +#endif -#ifdef MBED_CLIENT_USER_CONFIG_FILE -#include MBED_CLIENT_USER_CONFIG_FILE +#ifndef SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE +#define SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE UINT16_MAX #endif #endif // SN_CONFIG_H diff --git a/features/frameworks/mbed-coap/run_unit_tests.sh b/features/frameworks/mbed-coap/run_unit_tests.sh index 797ca2c6ce..de190fe139 100755 --- a/features/frameworks/mbed-coap/run_unit_tests.sh +++ b/features/frameworks/mbed-coap/run_unit_tests.sh @@ -17,7 +17,6 @@ echo echo "Build mbed-coap C unit tests" echo -yt target x86-linux-native -yt up +make -f Makefile.test clone make -f Makefile.test test #make -f Makefile.test test clean diff --git a/features/frameworks/mbed-coap/source/include/sn_coap_protocol_internal.h b/features/frameworks/mbed-coap/source/include/sn_coap_protocol_internal.h index 0eff138331..3654684517 100644 --- a/features/frameworks/mbed-coap/source/include/sn_coap_protocol_internal.h +++ b/features/frameworks/mbed-coap/source/include/sn_coap_protocol_internal.h @@ -34,118 +34,13 @@ extern "C" { struct sn_coap_hdr_; -/* * * * * * * * * * * */ -/* * * * DEFINES * * * */ -/* * * * * * * * * * * */ - -/* * For Message resending * */ -#ifdef SN_COAP_DISABLE_RESENDINGS -#define ENABLE_RESENDINGS 0 /* Disable resendings */ -#else -#define ENABLE_RESENDINGS 1 /**< Enable / Disable resending from library in building */ -#endif - -#define SN_COAP_RESENDING_MAX_COUNT 3 /**< Default number of re-sendings */ - -#ifdef YOTTA_CFG_COAP_RESENDING_QUEUE_SIZE_MSGS -#define SN_COAP_RESENDING_QUEUE_SIZE_MSGS YOTTA_CFG_COAP_RESENDING_QUEUE_SIZE_MSGS -#elif defined MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_MSGS -#define SN_COAP_RESENDING_QUEUE_SIZE_MSGS MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_MSGS -#endif - -#ifndef SN_COAP_RESENDING_QUEUE_SIZE_MSGS -#define SN_COAP_RESENDING_QUEUE_SIZE_MSGS 2 /**< Default re-sending queue size - defines how many messages can be stored. Setting this to 0 disables feature */ -#endif - -#ifdef YOTTA_CFG_COAP_RESENDING_QUEUE_SIZE_BYTES -#define SN_COAP_RESENDING_QUEUE_SIZE_BYTES YOTTA_CFG_COAP_RESENDING_QUEUE_SIZE_BYTES -#elif defined MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_BYTES -#define SN_COAP_RESENDING_QUEUE_SIZE_BYTES MBED_CONF_MBED_CLIENT_SN_COAP_RESENDING_QUEUE_SIZE_BYTES -#endif - -#ifndef SN_COAP_RESENDING_QUEUE_SIZE_BYTES -#define SN_COAP_RESENDING_QUEUE_SIZE_BYTES 0 /**< Default re-sending queue size - defines size of the re-sending buffer. Setting this to 0 disables feature */ -#endif - -#define DEFAULT_RESPONSE_TIMEOUT 10 /**< Default re-sending timeout as seconds */ - -/* These parameters sets maximum values application can set with API */ -#define SN_COAP_MAX_ALLOWED_RESENDING_COUNT 6 /**< Maximum allowed count of re-sending */ -#define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS 6 /**< Maximum allowed number of saved re-sending messages */ -#define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES 512 /**< Maximum allowed size of re-sending buffer */ -#define SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT 40 /**< Maximum allowed re-sending timeout */ - -#define RESPONSE_RANDOM_FACTOR 1.5 /**< Resending random factor, value is specified in IETF CoAP specification */ - -/* * For Message duplication detecting * */ - -/* Init value for the maximum count of messages to be stored for duplication detection */ -/* Setting of this value to 0 will disable duplication check, also reduce use of ROM memory */ -#ifdef YOTTA_CFG_COAP_DUPLICATION_MAX_MSGS_COUNT -#define SN_COAP_DUPLICATION_MAX_MSGS_COUNT YOTTA_CFG_COAP_DUPLICATION_MAX_MSGS_COUNT -#elif defined MBED_CONF_MBED_CLIENT_SN_COAP_DUPLICATION_MAX_MSGS_COUNT -#define SN_COAP_DUPLICATION_MAX_MSGS_COUNT MBED_CONF_MBED_CLIENT_SN_COAP_DUPLICATION_MAX_MSGS_COUNT -#endif - -// Keep the old flag to maintain backward compatibility -#ifndef SN_COAP_DUPLICATION_MAX_MSGS_COUNT -#define SN_COAP_DUPLICATION_MAX_MSGS_COUNT 0 -#endif - -/* Maximum allowed number of saved messages for duplicate searching */ -#define SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT 6 - -/* Maximum time in seconds of messages to be stored for duplication detection */ -#define SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED 60 /* RESPONSE_TIMEOUT * RESPONSE_RANDOM_FACTOR * (2 ^ MAX_RETRANSMIT - 1) + the expected maximum round trip time */ - -/* * For Message blockwising * */ - -/* Init value for the maximum payload size to be sent and received at one blockwise message */ -/* Setting of this value to 0 will disable this feature, and also reduce use of ROM memory */ -/* Note: This define is common for both received and sent Blockwise messages */ - -#ifdef YOTTA_CFG_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE -#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE YOTTA_CFG_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE -#elif defined MBED_CONF_MBED_CLIENT_SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE -#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE MBED_CONF_MBED_CLIENT_SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE -#endif - -#ifndef SN_COAP_BLOCKWISE_ENABLED -#define SN_COAP_BLOCKWISE_ENABLED 0 /**< Enable blockwise */ -#endif - -#ifndef SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE -#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE 0 /**< Must be 2^x and x is at least 4. Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024 */ -#endif - -#ifndef SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE -#define SN_COAP_MAX_NONBLOCKWISE_PAYLOAD_SIZE 0 -#endif - -#ifdef MBED_CONF_MBED_CLIENT_SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED -#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED MBED_CONF_MBED_CLIENT_SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED -#endif - -#ifndef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED -#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED 60 /**< Maximum time in seconds of data (messages and payload) to be stored for blockwising */ -#endif - -#ifdef YOTTA_CFG_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE -#define SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE YOTTA_CFG_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE -#elif defined MBED_CONF_MBED_CLIENT_SN_COAP_MAX_INCOMING_MESSAGE_SIZE -#define SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE MBED_CONF_MBED_CLIENT_SN_COAP_MAX_INCOMING_MESSAGE_SIZE -#endif - -#ifndef SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE -#define SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE UINT16_MAX -#endif +#define RESPONSE_RANDOM_FACTOR 1.5 /**< Resending random factor, value is specified in IETF CoAP specification */ /* * For Option handling * */ #define COAP_OPTION_MAX_AGE_DEFAULT 60 /**< Default value of Max-Age if option not present */ #define COAP_OPTION_URI_PORT_NONE (-1) /**< Internal value to represent no Uri-Port option */ #define COAP_OPTION_BLOCK_NONE (-1) /**< Internal value to represent no Block1/2 option */ - int8_t prepare_blockwise_message(struct coap_s *handle, struct sn_coap_hdr_ *coap_hdr_ptr); /* Structure which is stored to Linked list for message sending purposes */ diff --git a/features/frameworks/mbed-coap/source/sn_coap_protocol.c b/features/frameworks/mbed-coap/source/sn_coap_protocol.c index 0a87eb3f1a..773216bf29 100644 --- a/features/frameworks/mbed-coap/source/sn_coap_protocol.c +++ b/features/frameworks/mbed-coap/source/sn_coap_protocol.c @@ -738,7 +738,10 @@ sn_coap_hdr_s *sn_coap_protocol_parse(struct coap_s *handle, sn_nsdl_addr_s *src (returned_dst_coap_msg_ptr->options_list_ptr->block1 != COAP_OPTION_BLOCK_NONE || returned_dst_coap_msg_ptr->options_list_ptr->block2 != COAP_OPTION_BLOCK_NONE)) { returned_dst_coap_msg_ptr = sn_coap_handle_blockwise_message(handle, src_addr_ptr, returned_dst_coap_msg_ptr, param); - } else { + } else if (returned_dst_coap_msg_ptr->msg_code != COAP_MSG_CODE_EMPTY) { + // Do not clean stored blockwise message when empty ack is received. + // Stored message is mandatory when building a next (GET) blockwise message. + // This will happen when non piggybacked response mode is selected. /* Get ... */ coap_blockwise_msg_s *stored_blockwise_msg_temp_ptr = NULL; diff --git a/features/lorawan/lorastack/mac/LoRaMacCommand.cpp b/features/lorawan/lorastack/mac/LoRaMacCommand.cpp index b3447cde7f..d2ebf397ff 100644 --- a/features/lorawan/lorastack/mac/LoRaMacCommand.cpp +++ b/features/lorawan/lorastack/mac/LoRaMacCommand.cpp @@ -149,7 +149,7 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui int8_t link_adr_dr = DR_0; int8_t link_adr_txpower = TX_POWER_0; uint8_t link_adr_nbtrans = 0; - uint8_t link_adr_nb_bytes_pasred = 0; + uint8_t link_adr_nb_bytes_parsed = 0; // Fill parameter structure link_adr_req.payload = &payload[mac_index - 1]; @@ -165,7 +165,14 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui &link_adr_dr, &link_adr_txpower, &link_adr_nbtrans, - &link_adr_nb_bytes_pasred); + &link_adr_nb_bytes_parsed); + + // If nothing was consumed, we have a malformed packet at our hand + // we bin everything and return. link_adr_nb_bytes_parsed being 0 is + // a magic identifier letting us know that there are payload inconsistencies + if (link_adr_nb_bytes_parsed == 0) { + return LORAWAN_STATUS_UNSUPPORTED; + } if ((status & 0x07) == 0x07) { mac_sys_params.channel_data_rate = link_adr_dr; @@ -174,11 +181,11 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui } // Add the answers to the buffer - for (uint8_t i = 0; i < (link_adr_nb_bytes_pasred / 5); i++) { + for (uint8_t i = 0; i < (link_adr_nb_bytes_parsed / 5); i++) { ret_value = add_link_adr_ans(status); } // Update MAC index - mac_index += link_adr_nb_bytes_pasred - 1; + mac_index += link_adr_nb_bytes_parsed - 1; } break; case SRV_MAC_DUTY_CYCLE_REQ: diff --git a/features/lorawan/lorastack/phy/LoRaPHY.cpp b/features/lorawan/lorastack/phy/LoRaPHY.cpp index 1e6cc64169..dd3cba9217 100644 --- a/features/lorawan/lorastack/phy/LoRaPHY.cpp +++ b/features/lorawan/lorastack/phy/LoRaPHY.cpp @@ -309,11 +309,12 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle, } uint8_t LoRaPHY::parse_link_ADR_req(const uint8_t *payload, + uint8_t payload_size, link_adr_params_t *params) { uint8_t ret_index = 0; - if (payload[0] == SRV_MAC_LINK_ADR_REQ) { + if (payload_size >= 5) { // Parse datarate and tx power params->datarate = payload[1]; @@ -973,13 +974,17 @@ uint8_t LoRaPHY::link_ADR_request(adr_req_params_t *link_adr_req, verify_adr_params_t verify_params; - while (bytes_processed < link_adr_req->payload_size) { + while (bytes_processed < link_adr_req->payload_size && + link_adr_req->payload[bytes_processed] == SRV_MAC_LINK_ADR_REQ) { // Get ADR request parameters next_index = parse_link_ADR_req(&(link_adr_req->payload[bytes_processed]), + link_adr_req->payload_size - bytes_processed, &adr_settings); if (next_index == 0) { - break; // break loop, since no more request has been found + bytes_processed = 0; + // break loop, malformed packet + break; } // Update bytes processed @@ -1024,6 +1029,11 @@ uint8_t LoRaPHY::link_ADR_request(adr_req_params_t *link_adr_req, } } + if (bytes_processed == 0) { + *nb_bytes_processed = 0; + return status; + } + if (is_datarate_supported(adr_settings.datarate)) { verify_params.status = status; diff --git a/features/lorawan/lorastack/phy/LoRaPHY.h b/features/lorawan/lorastack/phy/LoRaPHY.h index d6be36b1dc..f68f646726 100644 --- a/features/lorawan/lorastack/phy/LoRaPHY.h +++ b/features/lorawan/lorastack/phy/LoRaPHY.h @@ -608,7 +608,8 @@ protected: /** * Parses the parameter of an LinkAdrRequest. */ - uint8_t parse_link_ADR_req(const uint8_t *payload, link_adr_params_t *adr_params); + uint8_t parse_link_ADR_req(const uint8_t *payload, uint8_t payload_size, + link_adr_params_t *adr_params); /** * Verifies and updates the datarate, the TX power and the number of repetitions diff --git a/features/lorawan/lorastack/phy/LoRaPHYAU915.cpp b/features/lorawan/lorastack/phy/LoRaPHYAU915.cpp index 46ea344860..b41091e8e8 100644 --- a/features/lorawan/lorastack/phy/LoRaPHYAU915.cpp +++ b/features/lorawan/lorastack/phy/LoRaPHYAU915.cpp @@ -435,12 +435,16 @@ uint8_t LoRaPHYAU915::link_ADR_request(adr_req_params_t *params, // Initialize local copy of channels mask copy_channel_mask(temp_channel_masks, channel_mask, AU915_CHANNEL_MASK_SIZE); - while (bytes_processed < params->payload_size) { + while (bytes_processed < params->payload_size && + params->payload[bytes_processed] == SRV_MAC_LINK_ADR_REQ) { next_index = parse_link_ADR_req(&(params->payload[bytes_processed]), + params->payload_size, &adr_settings); if (next_index == 0) { - break; // break loop, since no more request has been found + bytes_processed = 0; + // break loop, malformed packet + break; } // Update bytes processed @@ -471,6 +475,11 @@ uint8_t LoRaPHYAU915::link_ADR_request(adr_req_params_t *params, } } + if (bytes_processed == 0) { + *nb_bytes_parsed = 0; + return status; + } + // FCC 15.247 paragraph F mandates to hop on at least 2 125 kHz channels if ((adr_settings.datarate < DR_6) && (num_active_channels(temp_channel_masks, 0, 4) < 2)) { diff --git a/features/lorawan/lorastack/phy/LoRaPHYCN470.cpp b/features/lorawan/lorastack/phy/LoRaPHYCN470.cpp index 01614e34f5..da46aea6bf 100644 --- a/features/lorawan/lorastack/phy/LoRaPHYCN470.cpp +++ b/features/lorawan/lorastack/phy/LoRaPHYCN470.cpp @@ -460,13 +460,18 @@ uint8_t LoRaPHYCN470::link_ADR_request(adr_req_params_t *params, // Initialize local copy of channels mask copy_channel_mask(temp_channel_masks, channel_mask, CN470_CHANNEL_MASK_SIZE); - while (bytes_processed < params->payload_size) { + while (bytes_processed < params->payload_size && + params->payload[bytes_processed] == SRV_MAC_LINK_ADR_REQ) { // Get ADR request parameters - next_index = parse_link_ADR_req(&(params->payload[bytes_processed]), &adr_settings); + next_index = parse_link_ADR_req(&(params->payload[bytes_processed]), + params->payload_size, + &adr_settings); if (next_index == 0) { - break; // break loop, since no more request has been found + bytes_processed = 0; + // break loop, malformed packet + break; } // Update bytes processed @@ -501,6 +506,11 @@ uint8_t LoRaPHYCN470::link_ADR_request(adr_req_params_t *params, } } + if (bytes_processed == 0) { + *nb_bytes_parsed = 0; + return status; + } + verify_params.status = status; verify_params.adr_enabled = params->adr_enabled; verify_params.datarate = adr_settings.datarate; diff --git a/features/lorawan/lorastack/phy/LoRaPHYUS915.cpp b/features/lorawan/lorastack/phy/LoRaPHYUS915.cpp index abc496be13..d454fb24e4 100644 --- a/features/lorawan/lorastack/phy/LoRaPHYUS915.cpp +++ b/features/lorawan/lorastack/phy/LoRaPHYUS915.cpp @@ -460,12 +460,16 @@ uint8_t LoRaPHYUS915::link_ADR_request(adr_req_params_t *params, // Initialize local copy of channels mask copy_channel_mask(temp_channel_masks, channel_mask, US915_CHANNEL_MASK_SIZE); - while (bytes_processed < params->payload_size) { + while (bytes_processed < params->payload_size && + params->payload[bytes_processed] == SRV_MAC_LINK_ADR_REQ) { next_idx = parse_link_ADR_req(&(params->payload[bytes_processed]), + params->payload_size - bytes_processed, &adr_settings); if (next_idx == 0) { - break; // break loop, since no more request has been found + bytes_processed = 0; + // break loop, malformed packet + break; } // Update bytes processed @@ -501,6 +505,11 @@ uint8_t LoRaPHYUS915::link_ADR_request(adr_req_params_t *params, } } + if (bytes_processed == 0) { + *nb_bytes_parsed = 0; + return status; + } + // FCC 15.247 paragraph F mandates to hop on at least 2 125 kHz channels if ((adr_settings.datarate < DR_4) && (num_active_channels(temp_channel_masks, 0, 4) < 2)) { diff --git a/features/mbedtls/platform/src/mbed_trng.c b/features/mbedtls/platform/src/mbed_trng.cpp similarity index 87% rename from features/mbedtls/platform/src/mbed_trng.c rename to features/mbedtls/platform/src/mbed_trng.cpp index d4dd771c01..53c1c21097 100644 --- a/features/mbedtls/platform/src/mbed_trng.c +++ b/features/mbedtls/platform/src/mbed_trng.cpp @@ -17,12 +17,17 @@ #if DEVICE_TRNG #include "hal/trng_api.h" +#include "platform/PlatformMutex.h" +extern "C" int mbedtls_hardware_poll( void *data, unsigned char *output, size_t len, size_t *olen ) { + static PlatformMutex trng_mutex; trng_t trng_obj; + trng_mutex.lock(); trng_init(&trng_obj); int ret = trng_get_bytes(&trng_obj, output, len, olen); trng_free(&trng_obj); + trng_mutex.unlock(); return ret; } diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_fhss_timer.cpp b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_fhss_timer.cpp index ca9bc0a338..e5aa08f8f8 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_fhss_timer.cpp +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_fhss_timer.cpp @@ -1,15 +1,16 @@ /* - * Copyright (c) 2018 ARM Limited. All rights reserved. + * Copyright (c) 2018-2019, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_interrupt.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_interrupt.c index e09dd3e8bf..519e3995b9 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_interrupt.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_interrupt.c @@ -1,15 +1,16 @@ /* - * Copyright (c) 2016-2018 ARM Limited. All rights reserved. + * Copyright (c) 2016-2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_interrupt_private.h b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_interrupt_private.h index 586e2e9604..6bea5dcd07 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_interrupt_private.h +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_interrupt_private.h @@ -1,15 +1,16 @@ /* - * Copyright (c) 2016-2018 ARM Limited. All rights reserved. + * Copyright (c) 2016-2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_random.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_random.c index 2def6c4f16..7ba0aae6f8 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_random.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_random.c @@ -1,15 +1,16 @@ /* - * Copyright (c) 2015 ARM Limited. All rights reserved. + * Copyright (c) 2015, 2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_timer.cpp b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_timer.cpp index 7aeb13f334..c7952d1be9 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_timer.cpp +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_timer.cpp @@ -1,15 +1,16 @@ /* - * Copyright (c) 2016-2018 ARM Limited. All rights reserved. + * Copyright (c) 2016-2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/cs_nvm.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/cs_nvm.c index bdd77358f6..4b9eed9f93 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/cs_nvm.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/cs_nvm.c @@ -1,15 +1,16 @@ /* - * Copyright (c) 2016 ARM Limited. All rights reserved. + * Copyright (c) 2016, 2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/csnvmtest.cpp b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/csnvmtest.cpp index 4393ca4ad6..ee1e1881c5 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/csnvmtest.cpp +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/csnvmtest.cpp @@ -1,5 +1,18 @@ /* - * Copyright (c) 2016 ARM Limited. All rights reserved. + * Copyright (c) 2016, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #include "CppUTest/TestHarness.h" diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/main.cpp b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/main.cpp index cc82213e17..d6a8a5740c 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/main.cpp +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/main.cpp @@ -1,5 +1,18 @@ /* - * Copyright (c) 2015 ARM Limited. All rights reserved. + * Copyright (c) 2015, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #include "CppUTest/CommandLineTestRunner.h" diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/test_cs_nvm.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/test_cs_nvm.c index ced1cec5e8..915a82ea5e 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/test_cs_nvm.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/test_cs_nvm.c @@ -1,5 +1,18 @@ /* - * Copyright (c) 2016 ARM Limited. All rights reserved. + * Copyright (c) 2016, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #include diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/test_cs_nvm.h b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/test_cs_nvm.h index 36155af9f6..b14537ddd6 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/test_cs_nvm.h +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/test_cs_nvm.h @@ -1,5 +1,18 @@ /* - * Copyright (c) 2016 ARM Limited. All rights reserved. + * Copyright (c) 2016, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #ifndef TEST_NS_NVM_HELPER_H #define TEST_NS_NVM_HELPER_H diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/configuration_store_stub.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/configuration_store_stub.c index e00ead2cad..556c159b6c 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/configuration_store_stub.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/configuration_store_stub.c @@ -1,5 +1,18 @@ /* - * Copyright (c) 2016 ARM Limited. All rights reserved. + * Copyright (c) 2016, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #include diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/configuration_store_stub.h b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/configuration_store_stub.h index 02d53e4294..418b230143 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/configuration_store_stub.h +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/configuration_store_stub.h @@ -1,5 +1,18 @@ /* - * Copyright (c) 2016 ARM Limited. All rights reserved. + * Copyright (c) 2016, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #ifndef __CONFIGURATION_STORE_STUB_H__ #define __CONFIGURATION_STORE_STUB_H__ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/ns_trace_stub.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/ns_trace_stub.c index b4b4f442b6..d58eb4c4a5 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/ns_trace_stub.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/ns_trace_stub.c @@ -1,5 +1,18 @@ /* - * Copyright (c) 2014-2016 ARM Limited. All rights reserved. + * Copyright (c) 2014-2016, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #include diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/nsdynmemLIB_stub.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/nsdynmemLIB_stub.c index 0b10772efc..e870047d86 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/nsdynmemLIB_stub.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/nsdynmemLIB_stub.c @@ -1,5 +1,18 @@ /* - * Copyright (c) 2014-2016 ARM Limited. All rights reserved. + * Copyright (c) 2014-2016, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #include "nsdynmemLIB_stub.h" diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/nsdynmemLIB_stub.h b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/nsdynmemLIB_stub.h index 3a15519876..4ab78ec9dd 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/nsdynmemLIB_stub.h +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/nsdynmemLIB_stub.h @@ -1,5 +1,18 @@ /* - * Copyright (c) 2015-2016 ARM Limited. All rights reserved. + * Copyright (c) 2015-2016, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #ifndef __NSDYNMEMLIB_STUB_H__ #define __NSDYNMEMLIB_STUB_H__ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/timeout_stub.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/timeout_stub.c index be22af487a..4e18eb5010 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/timeout_stub.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/timeout_stub.c @@ -1,5 +1,18 @@ /* - * Copyright (c) 2016 ARM Limited. All rights reserved. + * Copyright (c) 2016, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #include "eventOS_event_timer.h" diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop.c index ec970bdd07..9b1655c127 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop.c @@ -1,15 +1,16 @@ /* - * Copyright (c) 2016-2018 ARM Limited. All rights reserved. + * Copyright (c) 2016-2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop.h b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop.h index 8dc55bd737..5e38ece428 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop.h +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop.h @@ -1,15 +1,16 @@ /* - * Copyright (c) 2016-2018 ARM Limited. All rights reserved. + * Copyright (c) 2016-2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mbed.cpp b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mbed.cpp index 6953cb660d..96e320884b 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mbed.cpp +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mbed.cpp @@ -1,15 +1,16 @@ /* - * Copyright (c) 2018 ARM Limited. All rights reserved. + * Copyright (c) 2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mutex.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mutex.c index b65c98617a..d6244d4757 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mutex.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mutex.c @@ -1,15 +1,16 @@ /* - * Copyright (c) 2018 ARM Limited. All rights reserved. + * Copyright (c) 2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mutex.h b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mutex.h index ce3ac9beb6..d8a56ca62a 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mutex.h +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mutex.h @@ -1,15 +1,16 @@ /* - * Copyright (c) 2018 ARM Limited. All rights reserved. + * Copyright (c) 2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_hal_init.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_hal_init.c index 566472a0dc..0a81c9ef17 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_hal_init.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_hal_init.c @@ -1,15 +1,16 @@ /* - * Copyright (c) 2016-2018 ARM Limited. All rights reserved. + * Copyright (c) 2016-2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_hal_init.h b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_hal_init.h index 10991ce4c7..a26b48cc25 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_hal_init.h +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_hal_init.h @@ -1,15 +1,16 @@ /* - * Copyright (c) 2016-2018 ARM Limited. All rights reserved. + * Copyright (c) 2016-2018, Arm Limited and affiliates. * 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. + * + * 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 + * 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. + * 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. */ diff --git a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/nvm/nvm_ram.c b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/nvm/nvm_ram.c index 51ad41160c..12a6974fa9 100644 --- a/features/nanostack/nanostack-hal-mbed-cmsis-rtos/nvm/nvm_ram.c +++ b/features/nanostack/nanostack-hal-mbed-cmsis-rtos/nvm/nvm_ram.c @@ -1,5 +1,18 @@ /* - * Copyright (c) 2016, ARM Limited, All Rights Reserved. + * Copyright (c) 2016, 2018, Arm Limited and affiliates. + * 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 + * + * 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. */ #ifdef MBED_CONF_NANOSTACK_HAL_NVM_CFSTORE diff --git a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/Thread/thread_extension.h b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/Thread/thread_extension.h index b6f64d1e90..2e9fd3d41f 100644 --- a/features/nanostack/sal-stack-nanostack/source/6LoWPAN/Thread/thread_extension.h +++ b/features/nanostack/sal-stack-nanostack/source/6LoWPAN/Thread/thread_extension.h @@ -85,7 +85,7 @@ uint8_t *thread_extension_discover_response_write(protocol_interface_info_entry_ #define thread_extension_version_check(version) (false) #define thread_extension_discover_response_read(nwk_info, discover_response_tlv, data_ptr, data_len) ((void) 0) #define thread_extension_discover_response_tlv_write(data, version, securityPolicy) ((void) 0) -#define thread_extension_service_init(cur) (0) +#define thread_extension_service_init(cur) ((void) 0) #define thread_extension_joining_enabled(interface_id) (false) #define thread_extension_discover_response_len(cur) (0) #define thread_extension_discover_response_write(cur, ptr) (ptr) diff --git a/features/nanostack/sal-stack-nanostack/source/Common_Protocols/icmpv6.c b/features/nanostack/sal-stack-nanostack/source/Common_Protocols/icmpv6.c index 2dd17b9143..3059e68265 100644 --- a/features/nanostack/sal-stack-nanostack/source/Common_Protocols/icmpv6.c +++ b/features/nanostack/sal-stack-nanostack/source/Common_Protocols/icmpv6.c @@ -1084,7 +1084,7 @@ buffer_t *icmpv6_up(buffer_t *buf) case ICMPV6_TYPE_INFO_ECHO_REPLY: ipv6_neighbour_reachability_confirmation(buf->src_sa.address, buf->interface->id); - /* fall through */ + /* fall through */ case ICMPV6_TYPE_ERROR_DESTINATION_UNREACH: #ifdef HAVE_RPL_ROOT @@ -1092,7 +1092,7 @@ buffer_t *icmpv6_up(buffer_t *buf) buf = rpl_control_source_route_error_handler(buf, cur); } #endif - /* no break */ + /* fall through */ default: if (buf) { diff --git a/features/netsocket/TLSSocketWrapper.cpp b/features/netsocket/TLSSocketWrapper.cpp index eb75479a84..5e65758784 100644 --- a/features/netsocket/TLSSocketWrapper.cpp +++ b/features/netsocket/TLSSocketWrapper.cpp @@ -287,7 +287,7 @@ nsapi_error_t TLSSocketWrapper::send(const void *data, nsapi_size_t size) ret = continue_handshake(); if (ret != NSAPI_ERROR_IS_CONNECTED) { if (ret == NSAPI_ERROR_ALREADY) { - ret = NSAPI_ERROR_NO_CONNECTION; + ret = NSAPI_ERROR_WOULD_BLOCK; } return ret; } @@ -341,7 +341,7 @@ nsapi_size_or_error_t TLSSocketWrapper::recv(void *data, nsapi_size_t size) ret = continue_handshake(); if (ret != NSAPI_ERROR_IS_CONNECTED) { if (ret == NSAPI_ERROR_ALREADY) { - ret = NSAPI_ERROR_NO_CONNECTION; + ret = NSAPI_ERROR_WOULD_BLOCK; } return ret; } diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/RdaWiFiInterface.cpp b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/RdaWiFiInterface.cpp new file mode 100644 index 0000000000..0df8bb6fee --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/RdaWiFiInterface.cpp @@ -0,0 +1,217 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#include "WiFiInterface.h" +#include "RdaWiFiInterface.h" +#include "rda5991h_wland.h" +#include "nsapi_types.h" +#include "wland_types.h" +#include "rda_sys_wrapper.h" + +nsapi_error_t RDAWiFiInterface::set_channel(uint8_t channel) +{ + int ret= 0; + init(); + + if (channel > 13) + return NSAPI_ERROR_PARAMETER; + + if (channel == 0) { + _channel = 0; + return NSAPI_ERROR_OK; + } + + ret = rda5981_set_channel(channel); + if (ret == 0) { + _channel = channel; + return NSAPI_ERROR_OK; + } else { + return NSAPI_ERROR_TIMEOUT; + } +} + +int8_t RDAWiFiInterface::get_rssi() +{ + return rda5981_get_rssi(); +} + +nsapi_error_t RDAWiFiInterface::init() +{ + if (!_interface) { + if (!_emac.power_up()) { + LWIP_DEBUGF(NETIF_DEBUG,"power up failed!\n"); + } + nsapi_error_t err = _stack.add_ethernet_interface(_emac, true, &_interface); + if (err != NSAPI_ERROR_OK) { + _interface = NULL; + return err; + } + _interface->attach(_connection_status_cb); + } + return NSAPI_ERROR_OK; +} + +nsapi_error_t RDAWiFiInterface::set_credentials(const char *ssid, const char *pass, + nsapi_security_t security) +{ + if (ssid == 0 || strlen(ssid) == 0) { + return NSAPI_ERROR_PARAMETER; + } + if (security != NSAPI_SECURITY_NONE && (pass == 0 || strlen(pass) == 0)) { + return NSAPI_ERROR_PARAMETER; + } + if (strlen(ssid) > 32 || strlen(pass) > 63) { + return NSAPI_ERROR_PARAMETER; + } + memcpy((void*)_ssid, (void*)ssid, strlen(ssid)); + _ssid[strlen(ssid)] = '\0'; + memcpy((void*)_pass, (void*)pass, strlen(pass)); + _pass[strlen(pass)] = '\0'; + _security = security; + return NSAPI_ERROR_OK; +} + +nsapi_error_t RDAWiFiInterface::connect(const char *ssid, const char *pass, + nsapi_security_t security, uint8_t channel) +{ + rda_msg msg; + bool find = false; + int i = 0; + rda5981_scan_result bss; + int ret = 0; + + if (ssid == NULL || ssid[0] == 0) { + return NSAPI_ERROR_PARAMETER; + } + + init(); + + if(rda5981_check_scan_result_name(ssid) != 0) { + for (i = 0; i< 5; i++) { + rda5981_scan(NULL, 0, 0); + if(rda5981_check_scan_result_name(ssid) == 0) { + find = true; + break; + } + } + } else { + find = true; + } + + if (find == false) { + LWIP_DEBUGF(NETIF_DEBUG,"can not find the ap.\r\n"); + return NSAPI_ERROR_CONNECTION_TIMEOUT; + } + bss.channel = 15; + rda5981_get_scan_result_name(&bss, ssid); + if ((channel !=0) && (bss.channel != channel)) { + LWIP_DEBUGF(NETIF_DEBUG, "invalid channel\r\n"); + return NSAPI_ERROR_CONNECTION_TIMEOUT; + } + + memcpy(gssid, ssid, strlen(ssid)); + if (pass[0] != 0) { + memcpy(gpass, pass, strlen(pass)); + } + memset(gbssid, 0, NSAPI_MAC_BYTES); + gssid[strlen(ssid)] = gpass[strlen(pass)] = '\0'; + + msg.type = WLAND_CONNECT; + rda_mail_put(wland_msgQ, (void*)&msg, osWaitForever); + ret = rda_sem_wait(wifi_auth_sem, 10000); + if (ret) { + return NSAPI_ERROR_CONNECTION_TIMEOUT; + } + + ret = _interface->bringup(_dhcp, + _ip_address[0] ? _ip_address : 0, + _netmask[0] ? _netmask : 0, + _gateway[0] ? _gateway : 0, + DEFAULT_STACK, + _blocking); + + return ret; +} + + +nsapi_error_t RDAWiFiInterface::connect() +{ + return connect(_ssid, _pass, _security, _channel); +} + +nsapi_error_t RDAWiFiInterface::disconnect() +{ + rda_msg msg; + + if(sta_state < 2) { + return NSAPI_ERROR_NO_CONNECTION; + } + msg.type = WLAND_DISCONNECT; + rda_mail_put(wland_msgQ, (void*)&msg, osWaitForever); + if (_interface) { + return _interface->bringdown(); + } + + return NSAPI_ERROR_NO_CONNECTION; +} + +nsapi_size_or_error_t RDAWiFiInterface::scan(WiFiAccessPoint *res, nsapi_size_t count) +{ + int bss_num = 0, i; + rda5981_scan_result *bss; + nsapi_wifi_ap_t ap; + + init(); + + rda5981_scan(NULL, 0, 0); + bss_num = rda5981_get_scan_num(); + if (count != 0) { + bss_num = (bss_num < count) ? bss_num : count; + } + if (res) { + bss = (rda5981_scan_result *)malloc(bss_num * sizeof(rda5981_scan_result)); + rda5981_get_scan_result(bss, bss_num); + for (i=0; i +#ifdef __cplusplus +extern "C" { +#endif + +extern const unsigned int RDA_FW_INFO_ADDR; +extern const unsigned int RDA_UPGRADE_ADDR; + +/* + * function: start to wirte a partition. this func will erase given flash region + * @addr: partition start address, must be 4k alignment + * @img_len: length of image getted from OTA server, must be 4k alignment + * return: 0:success, else:fail + */ +int rda5981_write_partition_start(unsigned int addr, unsigned int img_len); + +/* + * function: write image to flash, without erase. + * the write region must be inside of the area given by func rda5981_write_partition_start + * the write region must be in order, otherwise the end function will return crc error. + * the maximum length could be write once time is 0x1000 + * @offset: offset from image inital position, must be 1k alignment + * @buf: data to be written + * @len: buffer len, max #0x1000, must be 1k alignment + * return: 0:success, else:fail + */ +int rda5981_write_partition(unsigned int offset, const unsigned char *buf, unsigned int len); + +/* + * function: end of writing partition + * return: 0:crc32 check success, else:fail + */ +int rda5981_write_partition_end(void); + +#ifdef __cplusplus +} +#endif + +#endif /*_RDA5981_OTA_H_*/ diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/rda5981_sniffer.h b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/rda5981_sniffer.h new file mode 100644 index 0000000000..0f0f4658e3 --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/rda5981_sniffer.h @@ -0,0 +1,99 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#ifndef _RDA5981_SNIFFER_H_ +#define _RDA5981_SNIFFER_H_ + +#ifdef __cplusplus +extern "C" { +#endif +#include "wland_types.h" + +/* Enable filtering ACK frames (no support)*/ +//#define RDA_RX_FILTER_DROP_ACK BIT0 + +/* Enable filtering CTS frames (no support)*/ +//#define RDA_RX_FILTER_DROP_CTS BIT1 + +/* Enable filtering RTS frames (no support)*/ +//#define RDA_RX_FILTER_DROP_RTS BIT2 + +/* Enable filtering beacon frames */ +#define RDA_RX_FILTER_DROP_BEACON BIT3 + +/* Enable filtering ATIM frames (no support)*/ +//#define RDA_RX_FILTER_DROP_ATIM BIT4 + +/* Enable filtering CF_END frames (no support)*/ +//#define RDA_RX_FILTER_DROP_CF_END BIT5 + +/* Enable filtering QCF_POLL frames (no support)*/ +//#define RDA_RX_FILTER_DROP_QCF_POLL BIT6 + +/* Filter Management frames which are not directed to current STA */ +#define RDA_RX_FILTER_DROP_ND_MGMT BIT7 + +/* Filter BC/MC MGMT frames belonging to other BSS */ +#define RDA_RX_FILTER_DROP_BC_MC_MGMT_OTHER_BSS BIT8 + +/* Enable filtering of duplicate frames */ +#define RDA_RX_FILTER_DROP_DUPLICATE BIT9 + +/* Enable filtering of frames whose FCS has failed */ +#define RDA_RX_FILTER_DROP_FCS_FAILED BIT10 + +/* Enable filtering of De-authentication frame */ +#define RDA_RX_FILTER_DROP_DEAUTH BIT11 + +/* Filter BA frames which are not received as SIFS response (no support)*/ +//#define RDA_RX_FILTER_DROP_NSIFS_RESP_BA BIT12 + +/* Filter BA frames which are received as SIFS response (no support)*/ +//#define RDA_RX_FILTER_DROP_SIFS_RESP_BA BIT13 + +/* Filter frames which are received in secondary channel (20 MHz PPDU from Secondary channel) */ +#define RDA_RX_FILTER_DROP_SEC_CHANNEL BIT14 + +/* Filter BC/MC DATA frames belonging to other BSS */ +#define RDA_RX_FILTER_DROP_BC_MC_DATA_OTHER_BSS BIT15 + +/* Filter DATA frames not directed to this station */ +#define RDA_RX_FILTER_DROP_ND_DATA BIT16 + +/* Filter Control frames which are not directed to current STA (no support)*/ +//#define RDA_RX_FILTER_DROP_ND_CONTROL BIT17 + +/* Filter Beacon frames (in IBSS mode) which are not used for adoption because the timestamp field is lower than TSF timer */ +#define RDA_RX_FILTER_DROP_IBSS_BEACON BIT18 + +typedef int (*sniffer_handler_t)(unsigned short data_len, void *data); + +int rda5981_enable_sniffer(sniffer_handler_t handler); +int rda5981_disable_sniffer(void); +//don't use this in sniffer callback handler +int rda5981_disable_sniffer_nocallback(void); +///TODO: time is no use anymore +int rda5981_start_sniffer(unsigned char channel, unsigned char to_ds, + unsigned char from_ds, unsigned char mgm_frame, unsigned short time); +int rda5981_stop_sniffer(void); +int wland_sniffer_set_channel(unsigned char channel); +int rda5981_set_filter(unsigned char to_ds, unsigned char from_ds, unsigned int mgm_filter); +int rda5981_sniffer_enable_fcs(void);//for hiflying +#ifdef __cplusplus +} +#endif + +#endif /*_RDA5981_SNIFFER_H_*/ diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/rda5991h_wland.h b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/rda5991h_wland.h new file mode 100644 index 0000000000..25ec00acbc --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/rda5991h_wland.h @@ -0,0 +1,658 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#ifndef _RDA5991H_WLAND_H_ +#define _RDA5991H_WLAND_H_ + +#include "sys_arch.h" +#include "wland_types.h" + +/* Mbed interface mac address + * if MBED_MAC_ADD_x are zero, interface uid sets mac address, + * otherwise MAC_ADD_x are used. + */ + +extern unsigned char user_mac[6];//not save in flash, need fill before wifi init every time +extern unsigned char gssid[32+1]; +extern unsigned char gpass[64+1]; +extern unsigned char gchannel; +extern unsigned char gbssid[6]; + +extern unsigned char gssid_ap[32+1]; +extern unsigned char gpass_ap[64+1]; +extern unsigned char gchannel_ap; +extern void *wland_msgQ; +extern void *wifi_auth_sem; + +extern u8 sta_state; + +typedef enum { + WLAND_CONNECT, + WLAND_RECONNECT, + WLAND_DISCONNECT, + WLAND_DISCONNECT_ERROR, + WLAND_STARTAP, + WLAND_STOPAP, + WLAND_ADD_AP_GTK, + WLAND_AP_EAPOL_3_OF_4, + WLAND_ADD_AP_PTK, + WLAND_STAJOINED, + WLAND_STAEXITED, + WLAND_STADEAUTH, + WLAND_MAC_CONNECTED, + WLAND_MAC_AP_CONNECTED, + WLAND_ADD_GTK, + WLAND_ADD_PTK, + WLAND_CON_FINISH, + WLAND_AUTO_RATE, + WLAND_ARP_OFFLOAD, + WLAND_SM_START, + WLAND_SM_STOP, + WLAND_WPS_CONNECT, + WLAND_WPS_START, + WLAND_WPS_DISCONNECT, +}WLAND_MSG; + +typedef enum { + MAIN_CONNECT, + MAIN_RECONNECT, + MAIN_DISCONNECT, + MAIN_STOP_AP, +}MAIN_MSG; + +typedef struct { + unsigned int type; + unsigned int arg1; + unsigned int arg2; + unsigned int arg3; +}rda_msg; + + +enum { + D_NONE_LEVEL = 0, + D_ERROR_LEVEL = 1, + D_INFO_LEVEL = 2, + D_DEBUG_LEVEL = 3, +}; + +#define WLAND_DBG_DUMP 0 +#define WPA_DBG_DUMP 0 +#define HUT_DBG_DUMP 0 +#define WLAND_DBG_LEVEL D_NONE_LEVEL +#define WPA_DBG_LEBEL D_NONE_LEVEL +#define WLANDLIB_DBG_LEVEL D_NONE_LEVEL + +#define ETH_ALEN 6 + +//encrypt type +#define ENCRYPT_NONE (0) +#define ENCRYPT_WPA_TKIP BIT0 +#define ENCRYPT_WPA_CCMP BIT1 +#define ENCRYPT_WPA2_TKIP BIT2 +#define ENCRYPT_WPA2_CCMP BIT3 +#define ENCRYPT_WEP BIT4 + +/* r91h driver data structure */ +typedef struct { + struct netif *netif_sta; + struct netif *netif_ap; + sys_thread_t wland_thread; + sys_thread_t maclib_thread; + sys_mbox_t maclib_mbox; + sys_mbox_t wland_mbox; +} rda_enetdata_t; + +__STATIC_INLINE int mac_is_valid(char* mac) +{ + return (mac[0] | mac[1] | mac[2] | mac[3] | mac[4] | mac[5]); +} + + +#ifdef __cplusplus +extern "C" { +#endif + +extern void wland_txip_data(void *data, unsigned int len, int mode); +extern void *wland_get_databuf(void); +extern void wland_sta_init(void); +extern void wland_reg_func(void); +extern void r91h_phy_task(void *data); +extern void wland_task(void *arg); +extern void rda_get_macaddr(u8_t *macaddr, int mode); +extern void rda5981_send_rawdata(char* data, unsigned int len); +extern int rda5981_send_nulldata(int power_save); +extern void rda5981_set_country_code(unsigned char country_code);// 0~china(1-14) 1~NA(1-11) 2~EU(1-13) +extern int rda5981_set_retrans_policy(unsigned char count); +extern int rda5981_set_channel(unsigned char channel); +/* default is 0, receive multicast packet, disable please set 1*/ +extern int rda5981_filter_multicast(unsigned char enable); +/* default is 0, 0 ~ no hidden, 1 ~ hidden zero len, 2 ~ hidden zero contents */ +extern void rda5981_set_AP_hidden_type(unsigned char mode); +extern void rda5981_set_AP_link_num(unsigned char num); +extern char* rda5981_get_ver(void); +extern int rda5981_enter_CE_MODE(unsigned char enable); +/* + * mode 0 - not 11n 1 - 11n + * + * -----------------11n(mode 1)(Mbps)----------------- + * rate HT20 HT40 + * GI(800ns) GI(400ns) GI(800ns) GI(400ns) + * 0 6.5 7.2 13.5 15 + * 1 13 14.2 27 30 + * 2 19.5 21.7 40.5 45 + * 3 26 28.9 54 60 + * 4 39 43.3 81 90 + * 5 52 57.8 108 120 + * 6 58.5 65 121.5 135 + * 7 65 72 135 150 + * + * --------------not 11n(mode 0)(Mbps)----------------- + * rate data rate rate data rate + * 0 autorate 9 9 + * 1 1 12 12 + * 2 2 18 18 + * 5 5.5 24 24 + * 11 11 36 36 + * 6 6 48 48 + * + */ +extern int rda5981_set_data_rate(unsigned char mode, unsigned char rate); +extern void rda5981_set_mode(unsigned char bgn_enable); +extern void rda5981_set_auth_timeout(unsigned char timeout_enable); +typedef struct { + char BSSID[ETH_ALEN]; + char SSID[32+1]; + signed char RSSI; + unsigned char SSID_len; + unsigned char channel; + unsigned char secure_type;//refer #define ENCRYPT_XXX + unsigned char wmm; + unsigned char *ie;//user program couldn't free(ie); + unsigned short capability; + unsigned int ie_length; +} rda5981_scan_result; + +typedef struct { + unsigned char mac[ETH_ALEN]; + unsigned int ip; +} rda5981_apsta_info; + +//scan one or all channel(if channel is 0) once +int rda5981_scan(const char *SSID, const unsigned char SSID_len, const unsigned char channel); +//0 passive mode, 1 active mode, scan time(unit is second) +int rda5981_scan_v2(const char *SSID, const unsigned char SSID_len, const unsigned char channel, const unsigned char mode, \ + const unsigned char scan_time); +int rda5981_get_scan_num(); +int rda5981_get_scan_result(rda5981_scan_result *buf, const unsigned char len); +int rda5981_get_scan_result_index(rda5981_scan_result *buf, const unsigned char index); +int rda5981_get_scan_result_name(rda5981_scan_result *buf, const char *name); +int rda5981_get_scan_result_bssid(rda5981_scan_result *buf, const unsigned char *bssid); +int rda5981_check_scan_result_name(const char *name); +int rda5981_check_scan_result(const char *ssid, const char *bssid, const unsigned channel); +int rda5981_check_scan_result_name_bssid(const unsigned char *name, const unsigned char *bssid); +int rda5981_del_scan_all_result(void); +void rda5981_set_expired_time(unsigned int expired_time); +int rda5981_get_joined_AP(rda5981_scan_result *bss); +s8 rda5981_get_rssi(); +void rda5981_set_main_queue(void* queue); + +void rda5981_set_sta_listen_interval(unsigned char interval); +void rda5981_set_sta_link_loss_time(unsigned char time); +unsigned int rda5981_get_ap_join_info(rda5981_apsta_info *buf, const unsigned char len); +void rda5981_set_AP_white_list(unsigned char flag, unsigned char *mac); +int wland_set_joined_sta_ip(char *mac, unsigned int ip); + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_mac_addr(unsigned char *mac_addr); +int rda5981_flash_write_mac_addr(unsigned char *mac_addr); + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_erase_uart(void); +int rda5981_flash_read_uart(unsigned int *uart); +int rda5981_flash_write_uart(unsigned int *uart); + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_ip_addr(unsigned char *ip_addr, unsigned char *server_addr); +int rda5981_flash_write_ip_addr(unsigned char *ip_add, unsigned char *server_addr); + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_erase_dhcp_data(void); +int rda5981_flash_read_dhcp_data(unsigned int *enable, unsigned int *ip, unsigned int *msk, unsigned int *gw); +int rda5981_flash_write_dhcp_data(unsigned int enable, unsigned int ip, unsigned int msk, unsigned int gw); + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_ap_data(char *ssid, char *passwd, unsigned char *channel); +int rda5981_flash_write_ap_data(const char *ssid, const char *passwd, unsigned char channel); +int rda5981_flash_erase_ap_data(void); + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_ap_net_data(unsigned int *ip, unsigned int *msk, unsigned int *gw, + unsigned int *dhcps, unsigned int *dhcpe); +int rda5981_flash_write_ap_net_data(unsigned int ip, unsigned int msk, unsigned int gw, + unsigned int dhcps, unsigned int dhcpe); +int rda5981_flash_erase_ap_net_data(void); + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_sta_data(char *ssid, char *passwd); +int rda5981_flash_write_sta_data(const char *ssid, const char *passwd); +int rda5981_flash_erase_sta_data(void); + + +/* + * read 3rd parter data length from flash + * return user data length + */ +int rda5981_flash_read_3rdparter_data_length(void); + +/* + * read 3rd parter data from flash + * @buf, buf to store user data + * @buf_len, length of buf + * return user data length + */ +int rda5981_flash_read_3rdparter_data(unsigned char *buf, unsigned int buf_len); + +/* + * write 3rd parter data from flash + * @buf, data to write + * @buf_len, length of buf. + * return 0:ok, else:fail + */ +int rda5981_flash_write_3rdparter_data(const unsigned char *buf, unsigned int buf_len); + +/* + * erase 3rd parter data from flash + * return 0:ok, else:fail + */ +int rda5981_flash_erase_3rdparter_data(void); + +/* + * set flash size + * @size, 1MB:0x100000, 2MB:0x200000, 4MB:0x400000. default size: 1MB + * return 0:ok, else:fail + */ +int rda5981_set_flash_size(const unsigned int size); + +/* + * set userdata location on flash + * @sys_data_addr, data to save system parameter, user can not operate this area directly. + * size:4KB. default location:0x180fb000 + * @user_data_addr, data to save user data. user can save own data in this area + * by @rda5981_flash_read_3rdparter_data + * and @rda5981_flash_write_3rdparter_data + * default location:0x180fc000 + * @user_data_len, user data length, default:4KB + * return 0:ok, else:fail + */ +int rda5981_set_user_data_addr(const unsigned int sys_data_addr, + const unsigned int user_data_addr, const unsigned int user_data_len); + +/* + * function: erase flash + * @addr: mast be 4k alignment + * @len: must be 4k alignment. (package 64KB erase and 4KB erase for different condition automatically) + * return: 0:success, else:fail + */ +int rda5981_erase_flash(unsigned int addr, unsigned int len); + +/* + * function: write flash + * @addr: mast be 256 alignment + * @buf: data to be written, best be 4 alignment + * @len: buffer len, mast be 4 alignment + * return: 0:success, else:fail + */ +int rda5981_write_flash(unsigned int addr, char *buf, unsigned int len); + +/* + * function: read flash to @buf + * @addr: best be 4 alignment + * @buf: best be 4 alignment + * @len: buffer len + * return: 0:success, else:fail + */ +int rda5981_read_flash(unsigned int addr, char *buf, unsigned int len); + +/* + * function: read user data + * @data: data to read + * @len: length of data in byte + * @flag: user data flag + * return: 0:success, else:fail + */ +int rda5981_read_user_data(unsigned char *data, unsigned short len, unsigned int flag); + +/* + * function: write user data + * @data: data to write + * @len: length of data in byte + * @flag: user data flag + * return: 0:success, else:fail + */ +int rda5981_write_user_data(unsigned char *data, unsigned short len, unsigned int flag); + +/* + * function: erase user data + * @flag: user data flag + * return: 0:success, else:fail + */ +int rda5981_erase_user_data(unsigned int flag); + +/* + * function: update tx power from efuse data, for reg 11F and 120 + * return: 0:success, else:fail + */ +int update_tx_power_from_efuse(void); + +/* + * function: update xtal calibration from efuse data, for reg DA + * return: 0:success, else:fail + */ +int update_xtal_cal_from_efuse(void); + +/* + * function: update mac addr from flash data + * return: 0:success, else:fail + */ +int update_mac_addr_from_efuse(void); + +/* + * function: update tx power from flash data, Deprecated version + * return: 0:success, else:fail + */ +int update_tx_power_from_flash(void); + +/* + * function: update tx power from flash data, for reg 8A + * return: 0:success, else:fail + */ +int update_tx_power_rf_from_flash(void); + +/* + * function: update tx power from flash data, for reg 11F and 120 + * return: 0:success, else:fail + */ +int update_tx_power_phy_from_flash(void); + +/* + * function: update xtal calibration from flash data + * return: 0:success, else:fail + */ +int update_xtal_cal_from_flash(void); + +/* + * function: update mac addr from flash data + * return: 0:success, else:fail + */ +int update_mac_addr_from_flash(void); + +/* + * function: write rf reg + * @reg: rf reg data + * @value: rf reg value + * return: 0:success, else:fail + * eg: 0x00DA:xtal calibration + */ +int wland_rf_write(unsigned short reg, unsigned short value); + +/* + * function: write rf reg + * @reg: rf reg data + * @value: rf reg value + * @len : value length + * return: 0:success, else:fail + * eg: 0x008A:tx power rf + */ +int wland_rf_write_all_channels(unsigned short reg, unsigned short *value, unsigned short len); + +/* + * function: read rf reg + * @reg: rf reg data + * @value: rf reg value + * return: 0:success, else:fail + */ +int wland_rf_read(unsigned short reg, unsigned short *value); + +/* + * function: read rf reg + * @reg: rf reg data + * @value: rf reg value + * return: 0:success, else:fail + * eg: 0x008A:tx power rf + */ +int wland_rf_read_all_channels(unsigned short reg, unsigned short *value); + +/* + * function: write phy reg + * @reg: phy reg data + * @value: phy reg value + * return: 0:success, else:fail + */ +int wland_phy_write(unsigned int reg, unsigned int value); + +/* + * function: write phy reg + * @reg: phy reg data + * @value: phy reg value + * @len : value length + * return: 0:success, else:fail + */ +int wland_phy_write_all_channels(unsigned int reg, unsigned int *value, unsigned short len); + +/* + * function: read phy reg + * @reg: phy reg data + * @value: phy reg value + * return: 0:success, else:fail + */ +int wland_phy_read(unsigned int reg, unsigned int *value); + +/* + * function: read phy reg + * @reg: phy reg data + * @value: phy reg value + * return: 0:success, else:fail + */ +int wland_phy_read_all_channels(unsigned int reg, unsigned int *value); + +/* efuse API start */ +/* Efuse CAN ONLY WRITE ONCE! DO NOT CALL THESE API IF YOU DO KNOW WHAT THEY MEANS!!! */ + +/* + * function: read all efuse + * @value: buffer to store efuse data, 28 bytes + * return: 0:success, else:fail + */ +int wland_read_efuse(unsigned char *value); + +/* + * function: read tx power from efuse + * @tx_power: 2 bytes, first is mode g/n(range 0x25~0x54), second is mode b(range 0x15~0x54). + * return: 0:success, else:fail + */ +int wland_read_tx_power_from_efuse(unsigned char *tx_power); + +/* + * function: read tx power from efuse + * @tx_power: 2 bytes, first is mode g/n(range 0x25~0x54), second is mode b(range 0x15~0x54) + * @len: must be 2 + * return: 0:success, else:fail + */ +int wland_write_tx_power_to_efuse(unsigned char *tx_power, unsigned char len); + +/* + * function: read xtal cal from efuse + * @xtal_cal: 1 byte, maximum 0x7F + * return: 0:success, else:fail + */ +int wland_read_xtal_cal_from_efuse(unsigned char *cal_val); + +/* + * function: write xtal cal to efuse + * @xtal_cal: 1 byte, maximum 0x7F + * @len : must be 1 + * return: 0:success, else:fail + */ +int wland_write_xtal_cal_to_efuse(unsigned char *xtal_cal, unsigned char len); + +/* + * function: write mac to efuse + * @xtal_cal: 6 bytes + * return: 0:success, else:fail + */ +int wland_read_mac_addr_from_efuse(unsigned char *mac_addr); + +/* + * function: write mac to efuse + * @xtal_cal: 6 bytes + * @len : must be 6 + * return: 0:success, else:fail + */ +int wland_write_mac_addr_to_efuse(unsigned char*mac_addr, unsigned char len); +/* efuse API end */ + +/* + * function: start rf test + * @argc: number of argv + * @argv: args for test, 6 elements for tx test, 4 elements for rx test + * @is_tx: 1 for tx test, 0 for rx test + * return: 0:success, else:fail + */ +int wland_start_rf_test(unsigned int argc, unsigned int *argv, unsigned int is_tx); + +/* + * function: stop rx test + * return: 0:success, else:fail + */ +int wland_stop_rx_test(void); + +/* + * function: get rf test result + * @result buffer to store rx result + * return: 0:success, else:fail + */ +int wland_get_rx_result(char *result); + +/* + * function: restart rx test, use last rx test args + * return: 0:success, else:fail + */ +int wland_restart_rx_test(void); + +/* + * function: stop tx test + * return: 0:success, else:fail + */ +int wland_stop_tx_test(void); + +/* + * function: restart tx test, use last tx test args + * return: 0:success, else:fail + */ +int wland_restart_tx_test(void); + +#define RDA5981_FIRMWARE_INFO_ADDR 0x18003000 +/* + * function: reboot to assigned addr (onece). + * reboot to rf test mode, not for OTA + * @firmware_info_addr: firmware info addr, depend on your flash layout + * @reboot_addr: reboot addr, 0x18001000-0x1840000 + * return: 0:success, else:fail + */ +int rda5981_reboot_to_addr(unsigned int firmware_info_addr, unsigned int reboot_addr); + +/* + * function: read reg and corresponding value related to test mode stored in flash + * @reg: reg to read + * @value: buffer to store value + * @flag: user data flag + * return: 0:success, else:fail + */ +int rda5981_read_user_data_regs(unsigned char *reg, unsigned char *value, unsigned int flag); + +/* + * function: write reg and corresponding value related to test mode stored in flash + * @reg: reg to write + * @value: buffer that stores value + * @flag: user data flag + * return: 0:success, else:fail + */ +int rda5981_write_user_data_regs(unsigned char *reg, unsigned char *value, unsigned int flag); + +/* + * function: erase reg and corresponding value related to test mode stored in flash + * @reg: reg to erase + * @flag: user data flag + * return: 0:success, else:fail + */ +int rda5981_erase_user_data_regs(unsigned char *reg, unsigned int flag); + +/* + * function: get flash Manufacturer ID + * @mid: + * return: 0:success, else:fail + */ +int rda5981_flash_get_mid(unsigned char *mid); + +/* + * function: get flash Device ID + * @did: + * return: 0:success, else:fail + */ +int rda5981_flash_get_did(unsigned char *did); + +/* + * function: get flash ID + * @mid: + * return: 0:success, else:fail + */ +int rda5981_flash_get_jdid(unsigned short *jdid); + +/* + * function: read mac reg + * @reg: mac reg data + * @value: mac reg value + * return: 0:success, else:fail + */ +int wland_mac_reg_read(unsigned short reg, unsigned int *value); + +/* + * function: write mac reg + * @reg: mac reg data + * @value: mac reg value + * return: 0:success, else:fail + */ +int wland_mac_reg_write(unsigned short reg, unsigned int value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/rda_sys_wrapper.h b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/rda_sys_wrapper.h new file mode 100644 index 0000000000..25b80b5199 --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/rda_sys_wrapper.h @@ -0,0 +1,216 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#if 1 +#ifndef _RDA_SYS_WRAPPER_H_ +#define _RDA_SYS_WRAPPER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Alarm */ +/** + * @brief : get current time in units of micro second + * @param[in] : + * @param[out]: + * @return : return time value with uint32 type + */ +extern unsigned long rda_get_cur_time_ms(void); + +/** + * @brief : create an alarm with given function, return timer handle + * @param[in] : func(callback)/data(pass to func)/mode(once or periodic) + * @param[out]: + * @return : return timer handle, a pointer to the timer structure, non-zero is valid + */ +extern void * rda_alarm_create_v2(void *func, unsigned int data, unsigned int mode); +extern void * rda_alarm_create(void *func, unsigned int data); + +/** + * @brief : delete an alarm with given handle, then reset the handle + * @param[in] : *handle(pointer to the timer structure) + * @param[out]: **handle(address of the handle variable) + * @return : + */ +extern int rda_alarm_delete(void **handle); + +/** + * @brief : start an alarm, raise a function call after given timeout delay + * @param[in] : handle(pointer to the timer structure)/timeout(micro second) + * @param[out]: + * @return : + */ +extern int rda_alarm_start(void *handle, unsigned int timeout_ms); + +/** + * @brief : stop an alarm, will not raise a function call any more + * @param[in] : handle(pointer to the timer structure) + * @param[out]: + * @return : + */ +extern int rda_alarm_stop(void *handle); + + +/* Semaphore */ +/** + * @brief : create a semaphore + * @param[in] : name and initial valve of semaphore + * @param[out]: + * @return : return ERR or NO_ERR + */ +extern void* rda_sem_create(unsigned int count); + +/** + * @brief : wait a semaphore + * @param[in] : name of semaphore + * @param[out]: + * @return : return ERR or NO_ERR + */ +extern int rda_sem_wait(void *sem, unsigned int millisec); + +/** + * @brief : release a semaphore + * @param[in] : name of semaphore + * @param[out]: + * @return : return ERR or NO_ERR + */ +extern int rda_sem_release(void *sem); + +/** + * @brief : delete a semaphore + * @param[in] : name of semaphore + * @param[out]: + * @return : return ERR or NO_ERR + */ +extern int rda_sem_delete(void *sem); + + +/* Queue */ +/** + * @brief : create a message queue + * @param[in] : size of message queue + * @param[out]: + * @return : return message queue id or NULL if error + */ +extern void* rda_msgQ_create(unsigned int queuesz); + +/** + * @brief : put a message to queue + * @param[in] : message queue id, message value and wait time + * @param[out]: + * @return : return ERR or NO_ERR + */ +extern int rda_msg_put(void *msgQId, unsigned int msg, unsigned int millisec); + +/** + * @brief : get a message from queue + * @param[in] : message queue id, message value and wait time + * @param[out]: + * @return : return ERR or NO_ERR + */ +extern int rda_msg_get(void *msgQId, unsigned int *value, unsigned int millisec); + +/* Mail */ +/** + * @brief : create a mail + * @param[in] : mail count/size + * @param[out]: + * @return : return mail handle + */ +void* rda_mail_create(unsigned int msgcnt, unsigned int msgsize); + +/** + * @brief : get a msg from mail + * @param[in] : handler name of mail/mail/wait time + * @param[out]: + * @return : return ERR or NO_ERR + */ +int rda_mail_get(void *rdahandle, void *evt, unsigned int wait); + +/** + * @brief : put a msg to mail + * @param[in] : handler of mail/mail/wait time + * @param[out]: + * @return : return ERR or NO_ERR + */ + +int rda_mail_put(void *rdahandle, void *evt, unsigned int wait); + +/* Mutex */ +/** + * @brief : create a mutex + * @param[in] : + * @param[out]: + * @return : return ERR or NO_ERR + */ +extern void* rda_mutex_create(void); + +/** + * @brief : wait a mutex + * @param[in] : id of mutex and wait time + * @param[out]: + * @return : return ERR or NO_ERR + */ +extern int rda_mutex_wait(void *rdamutex, unsigned int millisec); + +/** + * @brief : release a mutex + * @param[in] : id of mutex + * @param[out]: + * @return : return ERR or NO_ERR + */ +extern int rda_mutex_realease(void *rdamutex); + +/** + * @brief : delete a mutex + * @param[in] : id of mutex + * @param[out]: + * @return : return ERR or NO_ERR + */ +extern int rda_mutex_delete(void *rdamutex); + +/* Thread */ +/** + * @brief : creat a thread + * @param[in] : thread name/thread function/thread fuction argument/stacksize/thread priority + * @param[out]: + * @return : return thread id + */ +void* rda_thread_new(const char *pcName, void (*thread)(void *arg), void *arg, int stacksize, int priority); + +/** + * @brief : delete a thread + * @param[in] : thread id + * @param[out]: + * @return : return ERR or NO_ERR + */ +int rda_thread_delete(void* id); + +/** + * @brief : get current thread id + * @param[in] : + * @param[out]: + * @return : return thread id + */ +void* rda_thread_get_id(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _RDA_SYS_WRAPPER_H_ */ +#endif diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_dbg.h b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_dbg.h new file mode 100644 index 0000000000..ce418c023b --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_dbg.h @@ -0,0 +1,60 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#ifndef _WLAND_DBG_H_ +#define _WLAND_DBG_H_ +#include +#include "rda5991h_wland.h" +#include "wland_types.h" + +extern int wland_dbg_dump; +extern int wland_dbg_level; + +#define RDA_WLAND_DBG + +#ifdef RDA_WLAND_DBG +#define WLAND_DBG(level, fmt, ...) do {\ + int dbg_level = D_##level##_LEVEL;\ + if((dbg_level <= wland_dbg_level)){\ + printf("%s,"fmt, __func__, ##__VA_ARGS__);\ + } \ + } while (0) + +//if frmae_len is zero, get len from frame header +static inline void wland_dump_frame(const char* msg, u8 *data, u32 frame_len) +{ + + u32 len,i; + + if(wland_dbg_dump == 1) { + if(frame_len != 0) { + len = frame_len; + } else { + len = data[0] | ((data[1]&0x0f) << 8); + } + printf("%s : ",msg); + for(i=0; i= 4) { + wait_busy_down_4(); + } else { + wait_busy_down_2(); + } +} + +static void spi_write_reset(void) +{ + if (rda_ccfg_hwver() >= 4) { + spi_write_reset_4(); + } else { + spi_write_reset_2(); + } +} + +static void spi_wip_reset(void) +{ + if (rda_ccfg_hwver() >= 4) { + spi_wip_reset_4(); + } else { + spi_wip_reset_2(); + } +} + +static inline void spi_flash_enable_cache(void) +{ + unsigned int func = spi_flash_cfg_cache_addr; + if (rda_ccfg_hwver() >= 4) { + func = spi_flash_cfg_cache_addr_4; + } + ((void(*)(void))func)(); +} + +static inline void spi_flash_disable_cache(void) +{ + unsigned int func = spi_flash_disable_cache_addr; + if (rda_ccfg_hwver() >= 4) { + func = spi_flash_disable_cache_addr_4; + } + ((void(*)(void))func)(); +} + +static inline void spi_flash_flush_cache(void) +{ + unsigned int func = spi_flash_flush_cache_addr; + if (rda_ccfg_hwver() >= 4) { + func = spi_flash_flush_cache_addr_4; + } + ((void(*)(void))func)(); +} + +static inline void rda5981_spi_flash_erase_4KB_sector(u32 addr) +{ + unsigned int func = spi_flash_erase_4KB_sector_addr; + if (rda_ccfg_hwver() >= 4) { + func = spi_flash_erase_4KB_sector_addr_4; + } + ((void(*)(u32))func)(addr); +} + +static inline void RDA5991H_ERASE_FLASH(void *addr, u32 len) +{ + unsigned int func = FLASH_ERASE_FUN_ADDR; + if (rda_ccfg_hwver() >= 4) { + func = FLASH_ERASE_FUN_ADDR_4; + } + ((void(*)(void *, u32))func)(addr, len); +} + +static inline void RDA5991H_WRITE_FLASH(u32 addr, u8 *data, u32 len) +{ + unsigned int func = FLASH_WRITE_FUN_ADDR; + if (rda_ccfg_hwver() >= 4) { + func = FLASH_WRITE_FUN_ADDR_4; + } + ((void(*)(u32, u8 *, u32))func)(addr, data, len); +} + +static inline void RDA5991H_READ_FLASH(u32 addr, u8 *buf, u32 len) +{ + unsigned int func = FLASH_READ_FUN_ADDR; + if (rda_ccfg_hwver() >= 4) { + func = FLASH_READ_FUN_ADDR_4; + } + ((void(*)(u32, u8 *, u32))func)(addr, buf, len); +} + +static inline void SPI_FLASH_READ_DATA_FOR_MBED(void *addr, void *buf, u32 len) +{ + unsigned int func = SPI_FLASH_READ_DATA_FOR_MBED_ADDR; + if (rda_ccfg_hwver() >= 4) { + func = SPI_FLASH_READ_DATA_FOR_MBED_ADDR_4; + } + ((void(*)(void *, void *, u32))func)(buf, addr, len); +} + +#endif /*_WLAND_FLASH_H_*/ + diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_flash_wp.h b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_flash_wp.h new file mode 100644 index 0000000000..40ee40ee59 --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_flash_wp.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#ifndef _WLAND_FLASH_WP_H_ +#define _WLAND_FLASH_WP_H_ + +#ifdef __cplusplus +extern "C" { +#endif +extern void flash_wrtie_protect_all(); +extern void flash_wrtie_protect_none(); +extern void flash_wrtie_protect(unsigned int offset); +extern void rda5981_flash_init(); +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_ota.h b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_ota.h new file mode 100644 index 0000000000..57b9052871 --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_ota.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#ifndef _WLAND_OTA_H_ +#define _WLAND_OTA_H_ +#include "wland_types.h" +#include "rda_ccfg_api.h" + +extern u32 flash_size; + +#define CRC32_TABLE_ADDR 0xbb5c +#define CRC32_ADDR 0x8dff//u32 crc32(const u8 *p, size_t len) + +#define CRC32_TABLE_ADDR_4 0xbbd8 +#define CRC32_ADDR_4 0x8e33//u32 crc32(const u8 *p, size_t len) + +static inline unsigned int bootrom_crc32(unsigned char *p, unsigned int len) +{ + unsigned int func = CRC32_ADDR; + if (rda_ccfg_hwver() >= 4) { + func = CRC32_ADDR_4; + } + return ((unsigned int(*)(unsigned char *, unsigned int))func)(p, len); +} + +#endif /*_WLAND_OTA_H_*/ diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_rf.h b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_rf.h new file mode 100644 index 0000000000..6a9ebebc98 --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_rf.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#ifndef _WLAND_RF_H_ +#define _WLAND_RF_H_ + +#include "wland_types.h" + +#define WLAND_TXP_NUM 2 +#define WLAND_CHANNEL_NUM 14 +#define WLAND_TX_POWER_PHY_GN_REG 0x11F +#define WLAND_TX_POWER_PHY_B_REG 0x120 +#define WLAND_TX_POWER_RF_REG 0x8A +#define WLAND_XTAL_CAL_REG 0xDA + +#define MAKE_WORD16(lsb, msb) (((u16)(msb) << 8) & 0xFF00) | (lsb) +#define MAKE_WORD32(lsw, msw) (((u32)(msw) << 16) & 0xFFFF0000) | (lsw) + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_types.h b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_types.h new file mode 100644 index 0000000000..3cb0e7e9e6 --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/inc/wland_types.h @@ -0,0 +1,86 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +/*****************************************************************************/ +/* */ +/* File Name : wland_types.h */ +/* */ +/* Description : This file contains all the data type definitions for */ +/* MAC implementation. */ +/* */ +/*****************************************************************************/ + +#ifndef WLAND_TYPES_H +#define WLAND_TYPES_H + +/*****************************************************************************/ +/* Constants Definitions */ +/*****************************************************************************/ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; +typedef signed long long s64; + +typedef unsigned int size_t; + +/** Indicates Bit Value of BITx */ +#ifndef BIT +#define BIT(x) (1ul << (x)) + +/*****************************************************************************/ +/* Constant Definitions */ +/*****************************************************************************/ + +#define BIT0 (1ul << 0) +#define BIT1 (1ul << 1) +#define BIT2 (1ul << 2) +#define BIT3 (1ul << 3) +#define BIT4 (1ul << 4) +#define BIT5 (1ul << 5) +#define BIT6 (1ul << 6) +#define BIT7 (1ul << 7) +#define BIT8 (1ul << 8) +#define BIT9 (1ul << 9) +#define BIT10 (1ul << 10) +#define BIT11 (1ul << 11) +#define BIT12 (1ul << 12) +#define BIT13 (1ul << 13) +#define BIT14 (1ul << 14) +#define BIT15 (1ul << 15) +#define BIT16 (1ul << 16) +#define BIT17 (1ul << 17) +#define BIT18 (1ul << 18) +#define BIT19 (1ul << 19) +#define BIT20 (1ul << 20) +#define BIT21 (1ul << 21) +#define BIT22 (1ul << 22) +#define BIT23 (1ul << 23) +#define BIT24 (1ul << 24) +#define BIT25 (1ul << 25) +#define BIT26 (1ul << 26) +#define BIT27 (1ul << 27) +#define BIT28 (1ul << 28) +#define BIT29 (1ul << 29) +#define BIT30 (1ul << 30) +#define BIT31 (1ul << 31) +#endif + +#endif /* WLAND_TYPES_H */ diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/LICENSE-permissive-binary-license-1.0.txt b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/LICENSE-permissive-binary-license-1.0.txt new file mode 100644 index 0000000000..24e25298db --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/LICENSE-permissive-binary-license-1.0.txt @@ -0,0 +1,49 @@ +Permissive Binary License + +Version 1.0, January 2019 + +Redistribution. Redistribution and use in binary form, without +modification, are permitted provided that the following conditions are +met: + +1) Redistributions must reproduce the above copyright notice and the + following disclaimer in the documentation and/or other materials + provided with the distribution. + +2) Unless to the extent explicitly permitted by law, no reverse + engineering, decompilation, or disassembly of this software is + permitted. + +3) Redistribution as part of a software development kit must include the + accompanying file named “DEPENDENCIES” and any dependencies listed in + that file. + +4) Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +Limited patent license. The copyright holders (and contributors) grant a +worldwide, non-exclusive, no-charge, royalty-free patent license to +make, have made, use, offer to sell, sell, import, and otherwise +transfer this software, where such license applies only to those patent +claims licensable by the copyright holders (and contributors) that are +necessarily infringed by this software. This patent license shall not +apply to any combinations that include this software. No hardware is +licensed hereunder. + +If you institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the software +itself infringes your patent(s), then your rights granted under this +license shall terminate as of the date such litigation is filed. + +DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS." 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 +HOLDERS 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. \ No newline at end of file diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/README.md b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/README.md new file mode 100644 index 0000000000..5df1aa37df --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/README.md @@ -0,0 +1,7 @@ +This directory tree contains binaries build from RDA SDK modified for Mbed OS and released under Permissive Binary License. + +libhal files in the subfolders are generated with toolchains: + +Arm Compiler 5 - version 5.06u6 +GNU Arm Embedded - version 6.3.1 +IAR EWARM - version 8.32.2.178 \ No newline at end of file diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/TOOLCHAIN_ARM_STD/libwifi_sta_ap.ar b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/TOOLCHAIN_ARM_STD/libwifi_sta_ap.ar new file mode 100644 index 0000000000..3c5307cd77 Binary files /dev/null and b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/TOOLCHAIN_ARM_STD/libwifi_sta_ap.ar differ diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/TOOLCHAIN_GCC_ARM/libwifi_sta_ap.a b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/TOOLCHAIN_GCC_ARM/libwifi_sta_ap.a new file mode 100644 index 0000000000..58685c8562 Binary files /dev/null and b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/TOOLCHAIN_GCC_ARM/libwifi_sta_ap.a differ diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/TOOLCHAIN_IAR/libwifi_sta_ap.a b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/TOOLCHAIN_IAR/libwifi_sta_ap.a new file mode 100644 index 0000000000..a55e385361 Binary files /dev/null and b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/lib/TOOLCHAIN_IAR/libwifi_sta_ap.a differ diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/maclib_task.c b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/maclib_task.c new file mode 100644 index 0000000000..bd31ff81d2 --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/maclib_task.c @@ -0,0 +1,275 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +/****************************************************************************** + * @file : maclib_task.c + * @brief : WiFi MACLib task source file + * @version: V1.0 + * @date : 6. May 2017 + * + * @note + * + ******************************************************************************/ +#include +#include +#include + +#include "mbed_interface.h" +#include "cmsis_os.h" +#include "csl_mbed.h" +#include "maclib_task.h" +#include "rda5991h_wland.h" + +#include "lwip/pbuf.h" +#include "lwip/sys.h" + +/** + * Macros + */ +#define MACLIB_TASK_DEBUG (0) + +/** + * Variables + */ +static int maclib_task_run = 0; +static sys_mbox_t maclib_mbox; +static int g_event_num = 0; +static int g_event_proc_done = 1; +static sys_sem_t g_maclib_sem_sleep; +static int g_maclib_sleep_flag = 0; + +extern maclib_func_t *maclib_func_p; + +extern void rda_critical_sec_start(void); +extern void rda_critical_sec_end(void); +extern void wland_set_sta_sleep(unsigned char is_sleep); + +#define MAX_MSG_POOL_NUM (64) +maclib_msg_t msg_str_pool[MAX_MSG_POOL_NUM]; +int msg_str_pool_inited = 0; + +void init_msg_str_pool(void) +{ + int idx; + for(idx = 0; idx < MAX_MSG_POOL_NUM; idx++) { + msg_str_pool[idx].is_free = 1; + } +} + +maclib_msg_t *alloc_msg_str(void) +{ + int idx; + maclib_msg_t *ret = NULL; + rda_critical_sec_start(); + if (0 == msg_str_pool_inited) { + init_msg_str_pool(); + msg_str_pool_inited = 1; + } + rda_critical_sec_end(); + for (idx = 0; idx < MAX_MSG_POOL_NUM; idx++) { + rda_critical_sec_start(); + ret = &msg_str_pool[idx]; + if (1 == ret->is_free) { + ret->is_free = 0; + rda_critical_sec_end(); + break; + } + rda_critical_sec_end(); + } + return ret; +} + +void free_msg_str(maclib_msg_t *p_msg) +{ + rda_critical_sec_start(); + p_msg->is_free = 1; + rda_critical_sec_end(); +} + +/** + * Functions + */ +/* maybe called in isr, should not use "printf", "malloc" */ +void mbed_event_handle_cb(unsigned int event) +{ + MACLIB_EVENT_HANDLE_T type = (MACLIB_EVENT_HANDLE_T)event; + if ((maclib_task_run == 0) && (MACLIB_EVENT_CLEANUP != type)) { + mbed_error_printf("evntHndlCb_nulldata\r\n"); + return; + } + switch(type) { + case MACLIB_EVENT_PEND: + rda_critical_sec_start(); + g_event_num++; + if((1 == g_event_num) && (1 == g_event_proc_done)) { + maclib_msg_t *msg; +#if MACLIB_TASK_DEBUG + mbed_error_printf("#1-1,%d(%08X)\r\n", g_event_num, __get_xPSR()); +#endif + msg = alloc_msg_str(); + if(NULL == msg) { + mbed_error_printf("malloc err\r\n"); + return; + } + msg->type = MACLIB_MSG_EVNT_HNDL; + msg->msg = NULL; + sys_mbox_trypost(&(maclib_mbox), msg); +#if MACLIB_TASK_DEBUG + mbed_error_printf("#1-2\r\n"); +#endif + } + rda_critical_sec_end(); + break; + case MACLIB_EVENT_PROCESS: +#if 1 + rda_critical_sec_start(); + g_event_num--; + if(0 > g_event_num) { + mbed_error_printf("event handle err\r\n"); + g_event_num = 0; + } + rda_critical_sec_end(); +#if MACLIB_TASK_DEBUG + mbed_error_printf("#3,%d\r\n",g_event_num); +#endif +#endif + break; + case MACLIB_EVENT_CLEANUP: +#if MACLIB_TASK_DEBUG + mbed_error_printf("event cleanup\r\n"); +#endif + rda_critical_sec_start(); + g_event_num = 0; + rda_critical_sec_end(); + break; + default: + break; + } +} + +void mbed_mltask_sleep_cb(void) +{ + g_maclib_sleep_flag = 1; + sys_arch_sem_wait(&g_maclib_sem_sleep, 0); +} + +void mbed_mltask_wakeup_cb(void) +{ + rda_critical_sec_start(); + if (1 == g_maclib_sleep_flag) { + g_maclib_sleep_flag = 0; + sys_sem_signal(&g_maclib_sem_sleep); + } + rda_critical_sec_end(); +} + +void maclib_check_status(void) +{ + rda_critical_sec_start(); + if (1 == g_maclib_sleep_flag) { + if(*((unsigned int *)0x40020580U) & (0x01UL << 2)) { + mbed_mltask_wakeup_cb(); + } + } + rda_critical_sec_end(); +} + +int maclib_is_sleep_allowed(void) +{ + return g_maclib_sleep_flag; +} + +void maclib_task(void *pvParameters) +{ + int ret; +#if 0 + sleep_entry_t maclib_sleep_entry = { + wland_set_sta_sleep, + maclib_is_sleep_allowed, + maclib_check_status + }; +#endif + sys_sem_new(&g_maclib_sem_sleep, 0); + //sleep_entry_register(&maclib_sleep_entry); + + ret = sys_mbox_new(&(maclib_mbox), 8); + if(0 != ret) { + LWIP_DEBUGF(NETIF_DEBUG,"msgbox init err!\r\n"); + goto mac_lib_err; + } +#if MACLIB_TASK_DEBUG + LWIP_DEBUGF(NETIF_DEBUG,"#mbox new\r\n"); +#endif + maclib_task_run = 1; + while(1) { + int mem_free = 1; + maclib_msg_t *msg = NULL; + unsigned int time = sys_arch_mbox_fetch(&(maclib_mbox), (void **)&msg, 0); + if ((SYS_ARCH_TIMEOUT == time) || (NULL == msg)) { + LWIP_DEBUGF(NETIF_DEBUG, "ml_task: invalid msg\r\n"); + continue; + } + switch(msg->type) { + case MACLIB_MSG_EVNT_HNDL: { + rda_critical_sec_start(); + g_event_proc_done = 0; + rda_critical_sec_end(); +#if MACLIB_TASK_DEBUG + mbed_error_printf("#get event %d\r\n", g_event_num); +#endif + maclib_func_p->ml_tasklet(); +#if MACLIB_TASK_DEBUG + mbed_error_printf("#5\r\n"); +#endif + rda_critical_sec_start(); +#if 0 + g_event_num--; + if(0 > g_event_num) { + mbed_error_printf("event handle err\r\n"); + } else +#endif + g_event_proc_done = 1; + if(0 < g_event_num) { +#if MACLIB_TASK_DEBUG + mbed_error_printf("#2-1\r\n"); +#endif + sys_mbox_trypost(&(maclib_mbox), msg); +#if MACLIB_TASK_DEBUG + mbed_error_printf("#2-2\r\n"); +#endif + mem_free = 0; + } + rda_critical_sec_end(); +#if MACLIB_TASK_DEBUG + mbed_error_printf("#pDone\r\n"); +#endif + break; + } + default: + break; + } + if (mem_free) { + free_msg_str(msg); +#if MACLIB_TASK_DEBUG + mbed_error_printf("#4\r\n"); +#endif + } + } + +mac_lib_err: + LWIP_DEBUGF(NETIF_DEBUG,"MACLib exit!\r\n"); + osDelay(osWaitForever); +} diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/rda5991h_wland.c b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/rda5991h_wland.c new file mode 100644 index 0000000000..4c6febce9d --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/rda5991h_wland.c @@ -0,0 +1,509 @@ +/* Copyright (c) 2019 ARM Limited + * 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 + * + * 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. + */ + +/****************************************************************************** + * @file rda5991h_wland.c + * @brief RDA5991H wlan driver for LWIP + * @version: V1.0 + * @date: 25. July 2016 + * + * @note + * Copyright (C) 2009 ARM Limited. All rights reserved. + * + * @par + * ARM Limited (ARM) is supplying this software for use with Cortex-M + * processor based microcontrollers. This file can be freely distributed + * within development tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +#include "lwip/opt.h" +#include "lwip/sys.h" +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/pbuf.h" +#include "lwip/stats.h" +#include "lwip/snmp.h" +#include "lwip/tcpip.h" +#include "netif/etharp.h" +#include "sys_arch.h" +#include "rda5991h_wland.h" +#include "cmsis.h" +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) +#include "entropy_poll.h" +#else +#include "trng_api.h" +#endif +#include "gpio_api.h" +#include "gpio_irq_api.h" +#include "maclib_task.h" +#include "rda_sys_wrapper.h" +#include +#include +#include +#include + +/* Global variables */ +rda_enetdata_t r91h_wifidata; + +int wland_dbg_dump = WLAND_DBG_DUMP; +int wland_dbg_level = WLAND_DBG_LEVEL; +int wpa_dbg_dump = WPA_DBG_DUMP; +int wpa_dbg_level = WPA_DBG_LEBEL; +int wlandlib_dbg_level = WLANDLIB_DBG_LEVEL; +int hut_dbg_dump = HUT_DBG_DUMP; + +//#define CONFIG_DISABLE_ALL_INT +#define CRI_SEC_START_PRI_LEVEL 0xF8 +#define CRI_SEC_END_PRI_LEVEL 0x00 +static unsigned int g_critical_sec_counter = 0U; +#if defined(CONFIG_DISABLE_ALL_INT) +static unsigned int g_critical_ctxt_saved = 0U; +#endif /* CONFIG_DISABLE_ALL_INT */ +void *packet_rx_queue; + +/* Function statements */ +void r91h_wifiif_input(struct netif *netif, u8_t *data, u32_t len, int idx); +void mbed_mac_address(char *mac); + +/** \brief Driver transmit and receive thread priorities + * + * Thread priorities for receive thread and TX cleanup thread. Alter + * to prioritize receive or transmit bandwidth. In a heavily loaded + * system or with LEIP_DEBUG enabled, the priorities might be better + * the same. */ +#define RX_PRIORITY (osPriorityNormal) +#define TX_PRIORITY (osPriorityNormal) +#define PHY_PRIORITY (osPriorityNormal) + +void rda_netif_down(int netif) +{ + if (netif == 0) { + netif_set_down(r91h_wifidata.netif_sta); + } else { + netif_set_down(r91h_wifidata.netif_ap); + } +} + +void rda_netif_link_down(int netif) +{ + rda_msg msg; + msg.type = 1; + msg.arg1 = 0; + rda_mail_put(packet_rx_queue, (void*)&msg, osWaitForever); +} + +void rda_netif_up(int netif) +{ + if (netif == 0) { + netif_set_up(r91h_wifidata.netif_sta); + } else { + netif_set_up(r91h_wifidata.netif_ap); + } +} + +void rda_netif_link_up(int netif) +{ + rda_msg msg; + msg.type = 1; + msg.arg1 = 1; + rda_mail_put(packet_rx_queue, (void*)&msg, osWaitForever); + return; +} + +void rda_netif_input(u8_t *data, u32_t len, int idx, int netif) +{ + if (netif == 0) { + r91h_wifiif_input(r91h_wifidata.netif_sta, data, len, idx++); + } else { + r91h_wifiif_input(r91h_wifidata.netif_ap, data, len, idx++); + } +} + +void rda_get_macaddr(u8_t *macaddr, int mode) +{ + mbed_mac_address((char *)macaddr); + if (mode == 1) { + if(macaddr[0] & 0x04) { + macaddr[0] &= 0xFB; + } else { + macaddr[0] |= 0x04; + } + } + return; +} + +void rda_critical_sec_start(void) +{ + if (__get_IPSR() == 0U) { + if (0U == g_critical_sec_counter) { +#if defined(CONFIG_DISABLE_ALL_INT) + g_critical_ctxt_saved = __disable_irq(); +#else /* CONFIG_DISABLE_ALL_INT */ + __set_BASEPRI(CRI_SEC_START_PRI_LEVEL); +#endif /* CONFIG_DISABLE_ALL_INT */ + } + g_critical_sec_counter++; + } +} + +void rda_critical_sec_end(void) +{ + if (__get_IPSR() == 0U) { + g_critical_sec_counter--; + if (0U == g_critical_sec_counter) { +#if defined(CONFIG_DISABLE_ALL_INT) + __set_PRIMASK(g_critical_ctxt_saved); +#else /* CONFIG_DISABLE_ALL_INT */ + __set_BASEPRI(CRI_SEC_END_PRI_LEVEL); +#endif /* CONFIG_DISABLE_ALL_INT */ + } + } +} + +void * rda_create_interrupt(unsigned int vec, unsigned int pri, void *isr) +{ + NVIC_SetPriority((IRQn_Type)vec, (uint32_t) pri); + NVIC_SetVector((IRQn_Type)vec, (uint32_t) isr); + + return NULL; +} + +void rda_delete_interrupt(unsigned int vec) +{ + NVIC_SetVector((IRQn_Type)vec, 0); +} + +void rda_enable_interrupt(unsigned int vec) +{ + NVIC_EnableIRQ((IRQn_Type)vec); +} + +void rda_disable_interrupt(unsigned int vec) +{ + NVIC_DisableIRQ((IRQn_Type)vec); +} + +/** \brief Allocates a pbuf and returns the data from the incoming packet. + * + * \param[in] netif the lwip network interface structure + * \param[in] idx index of packet to be read + * \return a pbuf filled with the received packet (including MAC header) + */ +static struct pbuf *r91h_low_level_input(struct netif *netif, u8_t *data, u32_t len, int idx) +{ + struct pbuf *p, *q; + u16_t index = 0; + + LWIP_DEBUGF(NETIF_DEBUG, ("low_level_input enter, rxlen:%d\n", len)); + + /* Obtain the size of the packet and put it into the "len" + variable. */ + if(!len) { + return NULL; + } + +#if ETH_PAD_SIZE + len += ETH_PAD_SIZE; /* allow room for Ethernet padding */ +#endif + + /* We allocate a pbuf chain of pbufs from the pool. */ + p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); + + if (p != NULL) { + +#if ETH_PAD_SIZE + pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ +#endif + + /* We iterate over the pbuf chain until we have read the entire + * packet into the pbuf. */ + for (q = p; q != NULL; q = q->next) { + /* Read enough bytes to fill this pbuf in the chain. The + * available data in the pbuf is given by the q->len + * variable. + * This does not necessarily have to be a memcpy, you can also preallocate + * pbufs for a DMA-enabled MAC and after receiving truncate it to the + * actually received size. In this case, ensure the tot_len member of the + * pbuf is the sum of the chained pbuf len members. + */ + /* load rx data from 96 to local mem_pool */ + MEMCPY(q->payload, &data[index], q->len); + index += q->len; + + if (index >= len) { + break; + } + } + +#if ETH_PAD_SIZE + pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ +#endif + + LINK_STATS_INC(link.recv); + } else { + /* Drop this packet */ + LWIP_DEBUGF(NETIF_DEBUG, ("low_level_input pbuf_alloc fail, rxlen:%d\n", len)); + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.drop); + + return NULL; + } + + return p; +} + +/** \brief Attempt to read a packet from the EMAC interface. + * + * \param[in] netif the lwip network interface structure + * \param[in] idx index of packet to be read + */ +void *data_sem = NULL; +void r91h_wifiif_input(struct netif *netif, u8_t *data, u32_t len, int idx) +{ + if(data_sem == NULL) + data_sem = rda_sem_create(0); + rda_msg msg; + msg.type = 0; + msg.arg1 = (int)data; + msg.arg2 = len; + msg.arg3 = (int)data_sem; + rda_mail_put(packet_rx_queue, (void*)&msg, osWaitForever); + rda_sem_wait(data_sem, osWaitForever); + return; +} + +/** \brief Low level init of the MAC and PHY. + * + * \param[in] netif Pointer to LWIP netif structure + */ + +static err_t low_level_init(struct netif *netif) +{ + static int init_flag = 0; + if (init_flag == 0) { + wland_reg_func(); + init_flag = 1; + } + return ERR_OK; +} + +/** + * This function is the ethernet packet send function. It calls + * etharp_output after checking link status. + * + * \param[in] netif the lwip network interface structure for this enetif + * \param[in] q Pointer to pbug to send + * \param[in] ipaddr IP address + * \return ERR_OK or error code + */ +err_t rda91h_etharp_output(struct netif *netif, struct pbuf *q, const ip_addr_t *ipaddr) +{ + /* Only send packet is link is up */ + if (netif->flags & NETIF_FLAG_LINK_UP) + return etharp_output(netif, q, ipaddr); + + return ERR_CONN; +} + +/** \brief Low level output of a packet. Never call this from an + * interrupt context, as it may block until TX descriptors + * become available. + * + * \param[in] netif the lwip network interface structure for this netif + * \param[in] p the MAC packet to send (e.g. IP packet including MAC addresses and type) + * \return ERR_OK if the packet could be sent or an err_t value if the packet couldn't be sent + */ +static err_t rda91h_low_level_output(struct netif *netif, struct pbuf *p) +{ + struct pbuf *q; + + /* rda5996 initiate transfer */ + u32_t actual_txlen = 0; + u8_t **data; + LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output enter, p:%08x\n", p)); + +#if ETH_PAD_SIZE + pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ +#endif + + data = (void*)wland_get_databuf(); + + if(data == NULL){ + LWIP_DEBUGF(NETIF_DEBUG, ("rda91h_low_level_output, no PKT buf\r\n")); + return ERR_BUF; + } + + for(q = p; q != NULL; q = q->next) + { + /* Send the data from the pbuf to the interface, one pbuf at a + time. The size of the data in each pbuf is kept in the ->len + variable. */ + MEMCPY(&((*data)[actual_txlen+2]), q->payload, q->len);//reserve wid header length + actual_txlen += q->len; + if(actual_txlen > 1514 || actual_txlen > p->tot_len) + { + LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output err, actual_txlen:%d, tot_len%d\n", + actual_txlen, p->tot_len)); + return ERR_BUF; + } + } + + /* Signal rda5996 that packet should be sent */ + if(actual_txlen == p->tot_len) + { + if(netif->name[0] == 's' && netif->name[1] == 't') { + wland_txip_data((void*)data, actual_txlen, 0); + } else if(netif->name[0] == 'a' && netif->name[1] == 'p') { + wland_txip_data((void*)data, actual_txlen, 1); + } + +#if ETH_PAD_SIZE + pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ +#endif + + LINK_STATS_INC(link.xmit); + + return ERR_OK; + } + + LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output pkt len mismatch, actual_txlen:%d, tot_len%d\n", + actual_txlen, p->tot_len)); + + + return ERR_BUF; +} + +/** + * Should be called at the beginning of the program to set up the + * network interface. + * + * This function should be passed as a parameter to netif_add(). + * + * @param[in] netif the lwip network interface structure for this netif + * @return ERR_OK if the loopif is initialized + * ERR_MEM if private data couldn't be allocated + * any other err_t on error + */ +err_t wifi_arch_enetif_init(struct netif *netif) +{ + err_t err; + static int thread_init_flag = 0; + LWIP_ASSERT("netif != NULL", (netif != NULL)); + + if (*((int *)netif->state) == 0) { + r91h_wifidata.netif_sta = netif; + netif->name[0] = 's'; + netif->name[1] = 't'; +#if LWIP_NETIF_HOSTNAME + /* Initialize interface hostname */ + if(netif->hostname == NULL) + netif->hostname = "lwipr91h_sta"; +#endif /* LWIP_NETIF_HOSTNAME */ + rda_get_macaddr((u8_t *)(netif->hwaddr), 0); + } else if(*((int *)netif->state) == 1) { + r91h_wifidata.netif_ap = netif; + netif->name[0] = 'a'; + netif->name[1] = 'p'; +#if LWIP_NETIF_HOSTNAME + /* Initialize interface hostname */ + if(netif->hostname == NULL) + netif->hostname = "lwipr91h_ap"; +#endif /* LWIP_NETIF_HOSTNAME */ + rda_get_macaddr((u8_t *)(netif->hwaddr), 1); + } + + netif->hwaddr_len = ETHARP_HWADDR_LEN; + + /* maximum transfer unit */ + netif->mtu = 1500; + + /* device capabilities */ + // TODOETH: check if the flags are correct below + netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP; + + /* Initialize the hardware */ + netif->state = &r91h_wifidata; + err = low_level_init(netif); + if (err != ERR_OK) + return err; + + netif->output = rda91h_etharp_output; + netif->linkoutput = rda91h_low_level_output; + if(thread_init_flag == 0){ + /* PHY monitoring task */ + sys_thread_new("maclib_thread", maclib_task, netif->state, DEFAULT_THREAD_STACKSIZE*8, PHY_PRIORITY); + sys_thread_new("wland_thread", wland_task, NULL, DEFAULT_THREAD_STACKSIZE*5, PHY_PRIORITY); + /* Allow the PHY task to detect the initial link state and set up the proper flags */ + osDelay(10); + thread_init_flag = 1; + } + return ERR_OK; +} + +unsigned char rda_mac_addr[6] = "\0"; +static int is_available_mac_addr(unsigned char *mac_addr) +{ + if (mac_addr[0]==0 && mac_addr[1]==0 && mac_addr[2]==0 && + mac_addr[3]==0 && mac_addr[4]==0 && mac_addr[5]==0) + return 0; + if (mac_addr[0]&0x1) + return 0; + return 1; +} +static void rda_get_macaddr_from_flash(unsigned char *macaddr) +{ + int ret; + if (!mac_is_valid((char *)rda_mac_addr)) { + ret = rda5981_flash_read_mac_addr(rda_mac_addr); + if ((ret!=0) || (is_available_mac_addr(rda_mac_addr)==0)) { +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) + unsigned int out_len; + ret = mbedtls_hardware_poll(NULL, rda_mac_addr, 6, &out_len); + if (6 != out_len) { + LWIP_DEBUGF(NETIF_DEBUG, ("out_len err:%d\n", out_len)); + } +#else + ret = rda_trng_get_bytes(rda_mac_addr, 6); +#endif + rda_mac_addr[0] &= 0xfe; /* clear multicast bit */ + rda_mac_addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ + rda5981_flash_write_mac_addr(rda_mac_addr); + } + } + memcpy(macaddr, rda_mac_addr, 6); +} +void mbed_mac_address(char *mac) +{ + mac[0] = 0xD6; + mac[1] = 0x71; + mac[2] = 0x36; + mac[3] = 0x60; + mac[4] = 0xD8; +#if !MBED_CONF_APP_ECHO_SERVER + mac[5] = 0xF4; +#else + mac[5] = 0xF3; +#endif + return; +} diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/rda_sys_wrapper.c b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/rda_sys_wrapper.c new file mode 100644 index 0000000000..35401ef3fe --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/rda_sys_wrapper.c @@ -0,0 +1,450 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#if 1 +#include "sys_arch.h" +#include "cmsis_os.h" +#include "cmsis_os2.h" +#include "lwip/sys.h" +#include "rtx_lib.h" + +#include +#include +#include "mbed_assert.h" +#define NO_ERR 0 +#define ERR -1 + +//#define RDA_SYS_DEBUG +#ifdef RDA_SYS_DEBUG +#define RDA_SYS_PRINT(fmt, ...) do {\ + printf(fmt, ##__VA_ARGS__);\ + } while (0) +#else +#define RDA_SYS_PRINT(fmt, ...) +#endif + + +/* Alarm */ +// Timer definitions +#define osTimerInvalid 0 +#define osTimerStopped 1 +#define osTimerRunning 2 +#if 0 +// Timer structures, same as os_timer_cb(rt_CMSIS.c) +typedef struct rda_ostmr_cb { + struct rda_ostmr_cb *next; // Pointer to next active Timer + uint8_t state; // Timer State + uint8_t type; // Timer Type (Periodic/One-shot) + uint16_t reserved; // Reserved + uint32_t tcnt; // Timer Delay Count + uint32_t icnt; // Timer Initial Count + void *arg; // Timer Function Argument + const osTimerDef_t *timer; // Pointer to Timer definition +} rda_ostmr_cb_t; +#endif +//#define USING_STDLIB + +#if !defined(USING_STDLIB) +typedef struct rda_tmr_node { + mbed_rtos_storage_timer_t _obj_mem; +} rda_tmr_node_t; + +typedef struct rda_tmr_ctrl { + unsigned char *buff; + unsigned char *state; + unsigned char max_node_num; + unsigned char node_size; + unsigned char node_cntr; + unsigned char last_freed_node_idx; +} rda_tmr_ctrl_t; + +#define MAX_ALARM_NUM (28) +#define WORD_ALIGN(n) (((n) + 0x03UL) & ~0x03UL) +#define MAX_ALARM_STAT_SIZE WORD_ALIGN(MAX_ALARM_NUM >> 3) +#define MAX_ALARM_MEM_SIZE (MAX_ALARM_NUM * WORD_ALIGN(sizeof(mbed_rtos_storage_timer_t)) + MAX_ALARM_STAT_SIZE) + +unsigned long g_alarm_buf[WORD_ALIGN(MAX_ALARM_MEM_SIZE) >> 2] = {0}; +rda_tmr_ctrl_t g_alarm_ctrl = { + (unsigned char *)g_alarm_buf + MAX_ALARM_STAT_SIZE, + (unsigned char *)g_alarm_buf, + MAX_ALARM_NUM, + WORD_ALIGN(sizeof(mbed_rtos_storage_timer_t)), + 0U, + 0U +}; + +__STATIC_INLINE unsigned char get_node_state(unsigned char *buf, unsigned char idx) +{ + unsigned char state, ofst; + ofst = (idx & 0x07U); + buf += (idx >> 3); + state = (*buf >> ofst) & 0x01U; + return state; +} + +__STATIC_INLINE void set_node_state(unsigned char *buf, unsigned char idx, unsigned char state) +{ + unsigned char ofst, tmp; + ofst = (idx & 0x07U); + buf += (idx >> 3); + tmp = *buf & (~(0x01U << ofst)); + *buf = tmp | (((state & 0x01U) << ofst)); +} + +static rda_tmr_node_t *get_tmr_node(void) +{ + rda_tmr_node_t *node = NULL; + unsigned char idx = g_alarm_ctrl.last_freed_node_idx; + if ((idx < g_alarm_ctrl.max_node_num) && (0U == get_node_state(g_alarm_ctrl.state, idx))) { + set_node_state(g_alarm_ctrl.state, idx, 1U); + node = (rda_tmr_node_t *)(g_alarm_ctrl.buff + idx * g_alarm_ctrl.node_size); + g_alarm_ctrl.node_cntr++; + } else { + for (idx = 0U; idx < g_alarm_ctrl.max_node_num; idx++) { + if(0U == get_node_state(g_alarm_ctrl.state, idx)) { + set_node_state(g_alarm_ctrl.state, idx, 1U); + node = (rda_tmr_node_t *)(g_alarm_ctrl.buff + idx * g_alarm_ctrl.node_size); + g_alarm_ctrl.node_cntr++; + break; + } + } + } + return node; +} + +static void put_tmr_node(rda_tmr_node_t *node) +{ + unsigned char *node_buf = (unsigned char *)node; + unsigned char idx = (node_buf - g_alarm_ctrl.buff) / g_alarm_ctrl.node_size; + if ((node_buf > g_alarm_ctrl.buff) && (idx < g_alarm_ctrl.max_node_num) && + (1U == get_node_state(g_alarm_ctrl.state, idx))) { + set_node_state(g_alarm_ctrl.state, idx, 0U); + g_alarm_ctrl.node_cntr--; + g_alarm_ctrl.last_freed_node_idx = idx; + } +} +#endif /* !USING_STDLIB */ + +/** + * @brief : get current time in units of micro second + * @param[in] : + * @param[out]: + * @return : return time value with uint32 type + */ +unsigned long rda_get_cur_time_ms(void) +{ + return sys_now(); +} + +/** + * @brief : create an alarm with given function, return timer handle + * @param[in] : func(callback)/data(pass to func)/mode(once or periodic) + * @param[out]: + * @return : return timer handle, a pointer to the timer structure, non-zero is valid + */ +void * rda_alarm_create_v2(void *func, unsigned int data, unsigned int mode) +{ + osTimerId_t handle; + mbed_rtos_storage_timer_t* _obj_mem = NULL; + MBED_ASSERT(func != NULL); + osTimerAttr_t attr = { 0 }; +#if defined(USING_STDLIB) + _obj_mem = (mbed_rtos_storage_timer_t*)malloc(sizeof(mbed_rtos_storage_timer_t)); +#else /* USING_STDLIB */ + _obj_mem = (mbed_rtos_storage_timer_t*)get_tmr_node(); +#endif /* USING_STDLIB */ + MBED_ASSERT(_obj_mem != NULL); + memset(_obj_mem, 0, sizeof(_obj_mem)); + attr.cb_mem = _obj_mem; + attr.cb_size = sizeof(mbed_rtos_storage_timer_t); + //printf("hehehehe fun %p\r\n", func); + handle = osTimerNew((osTimerFunc_t)func, mode, (void *)data, &attr); + //printf("time cb %p handle %p\r\n", _obj_mem, handle); + MBED_ASSERT(handle != NULL); + return handle; +} + +void * rda_alarm_create(void *func, unsigned int data) +{ + return rda_alarm_create_v2(func, data, osTimerOnce); +} + +/** + * @brief : delete an alarm with given handle, then reset the handle + * @param[in] : *handle(pointer to the timer structure) + * @param[out]: **handle(address of the handle variable) + * @return : + */ +int rda_alarm_delete(void **handle) +{ + if (NULL != *handle) { + osTimerId timer_id = (osTimerId)(*handle); + osStatus retval = osTimerDelete(timer_id); + if (osOK == retval) { +#if defined(USING_STDLIB) + free(timer_id); +#else /* USING_STDLIB */ + put_tmr_node((rda_tmr_node_t *)timer_id); +#endif /* USING_STDLIB */ + *handle = NULL; + } else { + RDA_SYS_PRINT("Delete alarm error: %d\r\n", retval); + return ERR; + } + return NO_ERR; + } + return ERR; +} + +/** + * @brief : start an alarm, raise a function call after given timeout delay + * @param[in] : handle(pointer to the timer structure)/timeout(micro second) + * @param[out]: + * @return : + */ +int rda_alarm_start(void *handle, unsigned int timeout_ms) +{ + if (NULL != handle) { + osTimerId timer_id = (osTimerId)handle; + osStatus retval = osTimerStart(timer_id, (uint32_t)timeout_ms); + if (osOK != retval) { + RDA_SYS_PRINT("Start alarm error: %d\r\n", retval); + return ERR; + } + return NO_ERR; + } + return ERR; +} + +/** + * @brief : stop an alarm, will not raise a function call any more + * @param[in] : handle(pointer to the timer structure) + * @param[out]: + * @return : + */ +int rda_alarm_stop(void *handle) +{ + if (NULL != handle) { + osTimerId timer_id = (osTimerId)handle; + osStatus retval = osTimerStop(timer_id); + if (osOK != retval) { + RDA_SYS_PRINT("Stop alarm error: %d\r\n", retval); + return ERR; + } + return NO_ERR; + } + return ERR; +} + + + +/* Semaphore */ +void* rda_sem_create(unsigned int count) +{ + osSemaphoreId_t sem; + mbed_rtos_storage_semaphore_t *_obj_mem = (mbed_rtos_storage_semaphore_t*)malloc(sizeof(mbed_rtos_storage_semaphore_t)); + osSemaphoreAttr_t attr = { 0 }; + attr.name = "rda_unnamed_sem"; + attr.cb_mem = _obj_mem; + attr.cb_size = sizeof(mbed_rtos_storage_semaphore_t); + sem = osSemaphoreNew(1, count, &attr); + MBED_ASSERT(sem != NULL); + + return (void*)sem; +} + +int rda_sem_wait(void* sem, unsigned int millisec) +{ + int res; + + res = osSemaphoreWait(sem, millisec); + if (res > 0) { + return NO_ERR; + } else { + RDA_SYS_PRINT("rda_sem_wait error %d\r\n", res); + return ERR; + } +} + +int rda_sem_release(void *sem) +{ + int res; + + res = osSemaphoreRelease(sem); + if (res == 0) { + return NO_ERR; + } else { + RDA_SYS_PRINT("rda_sem_release error %d\r\n", res); + return ERR; + } +} + +int rda_sem_delete(void *sem) +{ + int res; + + res = osSemaphoreDelete(sem); + free(sem); + if (res == 0) { + return NO_ERR; + } else { + RDA_SYS_PRINT("rda_sem_delete error %d\r\n", res); + return ERR; + } +} + +/* Mail */ +void* rda_mail_create(unsigned int msgcnt, unsigned int msgsize) +{ + unsigned int mq_size = msgcnt * (msgsize + sizeof(os_message_t)); + osMessageQueueId_t msgq; + mbed_rtos_storage_msg_queue_t *_obj_mem = (mbed_rtos_storage_msg_queue_t*)malloc(sizeof(mbed_rtos_storage_msg_queue_t)); + MBED_ASSERT(_obj_mem != NULL); + memset(_obj_mem, 0, sizeof(mbed_rtos_storage_msg_queue_t)); + void *_mq_mem = (void *)malloc(mq_size); + MBED_ASSERT(_mq_mem != NULL); + memset(_mq_mem, 0, mq_size); + osMessageQueueAttr_t attr = { 0 }; + attr.name = "rda_unnamed_message_queue"; + attr.cb_mem = _obj_mem; + attr.cb_size = sizeof(mbed_rtos_storage_msg_queue_t); + attr.mq_mem = _mq_mem; + attr.mq_size = mq_size; + msgq = osMessageQueueNew(msgcnt, msgsize, &attr); + MBED_ASSERT(msgq != NULL); + + return (void*)msgq; +} + +int rda_mail_get(void *msgq, void *msg, unsigned int wait) +{ + int ret; + ret = osMessageQueueGet(msgq, msg, 0, wait); + return ret; +} + +int rda_mail_put(void *msgq, void *msg, unsigned int wait) +{ + int ret; + ret = osMessageQueuePut(msgq, msg, 0, wait); + return ret; +} + +/* Mutex */ +void* rda_mutex_create(void) +{ + osMutexId_t rdamutex; + osMutexAttr_t attr = { 0 }; + mbed_rtos_storage_mutex_t *_obj_mem = (mbed_rtos_storage_mutex_t *)malloc(sizeof(mbed_rtos_storage_mutex_t)); + memset(_obj_mem, 0, sizeof(mbed_rtos_storage_mutex_t)); + attr.name = "rda_unnamed_mutex"; + attr.cb_mem = _obj_mem; + attr.cb_size = sizeof(mbed_rtos_storage_mutex_t); + attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust; + rdamutex = osMutexNew(&attr); + MBED_ASSERT(rdamutex != NULL); + return (void *)rdamutex; +} + +int rda_mutex_wait(void *rdamutex, unsigned int millisec) +{ + osMutexId_t mutex = (osMutexId_t)rdamutex; + osStatus res; + res = osMutexWait(mutex, millisec); + if (res == osOK) { + return NO_ERR; + } else { + return ERR; + } +} + +int rda_mutex_realease(void *rdamutex) +{ + osMutexId_t mutex = (osMutexId_t)rdamutex; + osStatus res; + res = osMutexRelease(mutex); + if(res == osOK) { + return NO_ERR; + } else { + return ERR; + } +} + +int rda_mutex_delete(void *rdamutex) +{ + osMutexId_t mutex = (osMutexId_t)rdamutex; + osStatus res; + res = osMutexDelete(mutex); + free(mutex); + if (res == osOK) { + return NO_ERR; + } else { + return ERR; + } +} + +/* Thread */ +void* rda_thread_new(const char *pcName, + void (*thread)(void *arg), + void *arg, int stacksize, int priority) +{ + osThreadId_t id; + osThreadAttr_t _attr = { 0 }; + mbed_rtos_storage_thread_t *_obj_mem = (mbed_rtos_storage_thread_t *)malloc(sizeof(mbed_rtos_storage_thread_t)); + MBED_ASSERT(_obj_mem != NULL); + memset(_obj_mem, 0, sizeof(mbed_rtos_storage_thread_t)); + _attr.priority = priority; + _attr.stack_size = stacksize; + _attr.name = pcName ? pcName : "rda_unnamed_thread"; + _attr.stack_mem = malloc(stacksize); + MBED_ASSERT(_attr.stack_mem != NULL); + _attr.cb_size = sizeof(mbed_rtos_storage_thread_t); + _attr.cb_mem = _obj_mem; + _attr.tz_module = 0; + + //Fill the stack with a magic word for maximum usage checking + for (uint32_t i = 0; i < (_attr.stack_size / sizeof(uint32_t)); i++) { + ((uint32_t *)_attr.stack_mem)[i] = 0xE25A2EA5; + } + id = osThreadNew(thread, arg, &_attr); + if (id == NULL){ + free(_attr.stack_mem); + free(_attr.cb_mem); + RDA_SYS_PRINT("sys_thread_new create error\n"); + return NULL; + } + return (void *)id; +} + +int rda_thread_delete(void* id) +{ + osStatus ret; + unsigned int *stk = ((osRtxThread_t *)id)->stack_mem; + ret = osThreadTerminate(id); + free(id); + free(stk); + if (ret != osOK) { + return ERR; + } + return NO_ERR; +} + +void* rda_thread_get_id(void) +{ + osThreadId id = osThreadGetId(); + return (void*)id; +} +#endif diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/wland_flash.c b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/wland_flash.c new file mode 100644 index 0000000000..a2c0cd8ffa --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/wland_flash.c @@ -0,0 +1,1481 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#include +#include +#include +#include "critical.h" +#include "wland_flash.h" +#include "wland_dbg.h" +#include "rda5981_flash.h" +#include "wland_flash_wp.h" + +#define MACDBG "%02x:%02x:%02x:%02x:%02x:%02x" +#define MAC2STRDBG(ea) (ea)[0], (ea)[1], (ea)[2], (ea)[3], (ea)[4], (ea)[5] + +u32 flash_size = FLASH_SIZE; +static u32 user_data_location = RDA5991H_USER_DATA_ADDR; +static u32 third_parter_data_location = RDA5991H_3RDPARTER_DATA_ADDR; +static u32 third_parter_data_len = RDA5991H_3RDPARTER_DATA_LEN; +int rda5981_read_flash(u32 addr, char *buf, u32 len) +{ + int ret = 0; + char *temp_buf = NULL, *temp_buf_aligned; + + addr &= (flash_size -1); + if (addr < RDA5991H_PARTITION_TABLE_END_ADDR-0x18000000) { + WLAND_DBG(ERROR, "couldn't read system data\n"); + return -1; + } + + if ((u32)buf % 4) { + temp_buf = malloc(len + 3); + if (temp_buf == NULL) { + ret = -1; + goto out; + } + if ((u32)temp_buf % 4) { + temp_buf_aligned = temp_buf + (4-(u32)temp_buf%4); + } else { + temp_buf_aligned = temp_buf; + } + } else { + temp_buf_aligned = buf; + } + + core_util_critical_section_enter(); + spi_flash_flush_cache(); + SPI_FLASH_READ_DATA_FOR_MBED((void *)addr, temp_buf_aligned, len); + core_util_critical_section_exit(); + + if (temp_buf_aligned != buf) { + memcpy(buf, temp_buf_aligned, len); + } + +out: + if (temp_buf) { + free(temp_buf); + } + + return ret; +} + +void rda5981_spi_flash_erase_64KB_block(u32 addr) +{ + if (rda_ccfg_hwver() < 4) { + spi_wip_reset_2(); + spi_write_reset_2(); + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, CMD_64KB_BLOCK_ERASE | (addr<<8)); + wait_busy_down_2(); + spi_wip_reset_2(); + } else { + spi_wip_reset_4(); + spi_write_reset_4(); + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, CMD_64KB_BLOCK_ERASE | (addr<<8)); + wait_busy_down_4(); + spi_wip_reset_4(); + } +} +void rda5981_spi_erase_partition(void *src, u32 counts) +{ + u32 a4k, a64k, a64kend, a4kend, atmp; + + if (counts > 0x00) { + a4k = ((u32)src ) & (~((0x01UL << 12) - 0x01UL)); + a64k = ((u32)src + (0x01UL << 16) - 0x01UL) & (~((0x01UL << 16) - 0x01UL)); + a64kend = ((u32)src + counts ) & (~((0x01UL << 16) - 0x01UL)); + a4kend = ((u32)src + counts + (0x01UL << 12) - 0x01UL) & (~((0x01UL << 12) - 0x01UL)); + + for (atmp = a4k; atmp < a4kend; atmp += (0x01UL << 12)) { + if (a64kend > a64k) { + if (atmp == a64k) { + for (; atmp < a64kend; atmp += (0x01UL << 16)) { + core_util_critical_section_enter(); + rda5981_spi_flash_erase_64KB_block(atmp); + core_util_critical_section_exit(); + } + if (atmp == a4kend) { + break; + } + } + } + core_util_critical_section_enter(); + rda5981_spi_flash_erase_4KB_sector(atmp); + core_util_critical_section_exit(); + } + } +} +//@len must be 4k aligment +int rda5981_erase_flash(u32 addr, u32 len) +{ + WLAND_DBG(INFO, "erase flash :%x:%x\n", addr, len); + + addr &= (flash_size - 1); + if (addr < RDA5991H_PARTITION_TABLE_END_ADDR-0x18000000) { + WLAND_DBG(ERROR, "couldn't erase system data\n"); + return -1; + } + + if (len & (SECTOR_SIZE-1)) { + len = ((len+SECTOR_SIZE) & (~(SECTOR_SIZE-1))); + } + flash_wrtie_protect(addr); + rda5981_spi_erase_partition((void*)addr, len); + flash_wrtie_protect_all(); + return 0; +} + +//@len must be 256 aligment +int rda5981_write_flash(u32 addr, char *buf, u32 len) +{ + int ret = 0; + u8 *temp_buf = NULL, *temp_buf_aligned; + u8 *check_buf = NULL; + + addr &= (flash_size -1); + if (addr < RDA5991H_PARTITION_TABLE_END_ADDR-0x18000000) { + WLAND_DBG(ERROR, "couldn't write system data\n"); + return -1; + } + + if ((u32)buf % 4) { + temp_buf = malloc(len + 3); + if (temp_buf == NULL) { + goto out; + } + if ((u32)temp_buf % 4) { + temp_buf_aligned = temp_buf + (4-(u32)temp_buf%4); + } else { + temp_buf_aligned = temp_buf; + } + memcpy(temp_buf_aligned, buf, len); + } else { + temp_buf_aligned = (u8*)buf; + } + flash_wrtie_protect(addr); + core_util_critical_section_enter(); + //RDA5991H_ERASE_FLASH(addr, len); + RDA5991H_WRITE_FLASH(addr, temp_buf_aligned, len); + core_util_critical_section_exit(); + flash_wrtie_protect_all(); + +#ifdef FLASH_READ_CHECK + if (ret == 0) { + check_buf = malloc(len); + rda5981_read_flash(addr, check_buf, len); + if (memcmp(buf, check_buf, len) == 0) { + ret = 0; + } else { + ret = -1; + } + } +#endif /*FLASH_READ_CHECK*/ + +out: + if (temp_buf) { + free(temp_buf); + } + if (check_buf) { + free(check_buf); + } + return ret; +} + +/* + * return 0:ok, else:error. + */ +rda5991h_user_data wland_user_data; +u8 read_flag = 0; +int rda5981_write_user_data(u8 *data, u16 len, u32 flag) +{ + WLAND_DBG(INFO, "Enter, flag:0x%x\r\n", flag); + + if (!read_flag) { + if (0 == rda5981_read_flash(user_data_location, + (char *)(&wland_user_data), sizeof(wland_user_data))) { + read_flag = 1; + } else { + return -1; + } + } + + if ((wland_user_data.flag & RDA5991H_USER_DATA_FLAG_UNINITIALIZED) || + strcmp((const char *)(wland_user_data.rda5981_flag), RDA5981_FLAG_FLAG)) { + memset(&wland_user_data, 0xff, sizeof(wland_user_data)); + wland_user_data.flag = flag; + strcpy((char *)(wland_user_data.rda5981_flag), RDA5981_FLAG_FLAG); + } + + wland_user_data.flag |= flag; + + switch (flag) { + case RDA5991H_USER_DATA_FLAG_STA: + memcpy(&wland_user_data.sta_data, data, + min(sizeof(wland_user_data.sta_data), len)); + break; + case RDA5991H_USER_DATA_FLAG_MAC: + memcpy(wland_user_data.mac_addr, data, + min(sizeof(wland_user_data.mac_addr), len)); + break; + case RDA5991H_USER_DATA_FLAG_PMK: + memcpy(wland_user_data.pmk, data, + min(sizeof(wland_user_data.pmk), len)); + break; + case RDA5991H_USER_DATA_FLAG_IP: + memcpy(wland_user_data.ip, data, + min(RDA5991H_USER_DATA_IP_LENGTH, len)); + break; + case RDA5991H_USER_DATA_FLAG_PARTER_DATA_LEN: + memcpy(&wland_user_data.parter_data_len, data, + min(sizeof(wland_user_data.parter_data_len), len)); + break; + case RDA5991H_USER_DATA_FLAG_TX_POWER: + memcpy(&wland_user_data.tx_power, data, + min(sizeof(wland_user_data.tx_power), len)); + break; + case RDA5991H_USER_DATA_FLAG_XTAL_CAL: + memcpy(&wland_user_data.xtal_cal, data, + min(sizeof(wland_user_data.xtal_cal), len)); + break; + case RDA5991H_USER_DATA_FLAG_TX_POWER_RF: + memcpy(&wland_user_data.tx_power_rf, data, + min(sizeof(wland_user_data.tx_power_rf), len)); + break; + case RDA5991H_USER_DATA_FLAG_TX_POWER_PHY_GN: + memcpy(&wland_user_data.tx_power_phy_gn, data, + min(sizeof(wland_user_data.tx_power_phy_gn), len)); + break; + case RDA5991H_USER_DATA_FLAG_TX_POWER_PHY_B: + memcpy(&wland_user_data.tx_power_phy_b, data, + min(sizeof(wland_user_data.tx_power_phy_b), len)); + break; + case RDA5991H_USER_DATA_FLAG_AP: + memcpy(&wland_user_data.ap_data, data, + min(sizeof(wland_user_data.ap_data), len)); + break; + case RDA5991H_USER_DATA_FLAG_APNET: + memcpy(&wland_user_data.ap_net_data, data, + min(sizeof(wland_user_data.ap_net_data), len)); + break; + case RDA5991H_USER_DATA_FLAG_DHCP: + memcpy(&wland_user_data.dhcp, data, + min(sizeof(wland_user_data.dhcp), len)); + break; + case RDA5991H_USER_DATA_FLAG_UART: + memcpy(&wland_user_data.uart, data, + min(sizeof(wland_user_data.uart), len)); + break; + case RDA5991H_USER_DATA_FLAG_RF: + memcpy(&wland_user_data.rf, data, + min(sizeof(wland_user_data.rf), len)); + break; + case RDA5991H_USER_DATA_FLAG_RF_CHANNELS: + memcpy(&wland_user_data.rf_channels, data, + min(sizeof(wland_user_data.rf_channels), len)); + break; + case RDA5991H_USER_DATA_FLAG_PHY: + memcpy(&wland_user_data.phy, data, + min(sizeof(wland_user_data.phy), len)); + break; + case RDA5991H_USER_DATA_FLAG_PHY_CHANNELS: + memcpy(&wland_user_data.phy_channels, data, + min(sizeof(wland_user_data.phy_channels), len)); + break; + case RDA5991H_USER_DATA_FLAG_TX_POWER_OFFSET: + memcpy(&wland_user_data.tp_offset, data, + min(sizeof(wland_user_data.tp_offset), len)); + break; + default: + return -1; + } + rda5981_erase_flash(user_data_location, sizeof(wland_user_data)); + return rda5981_write_flash(user_data_location, + (char *)(&wland_user_data), sizeof(wland_user_data)); +} + +/* + * return 0:ok, else:error. + */ +int rda5981_erase_user_data(u32 flag) +{ + if (!read_flag) { + read_flag = 1; + rda5981_read_flash(user_data_location, + (char *)(&wland_user_data), sizeof(wland_user_data)); + } + + if (wland_user_data.flag & RDA5991H_USER_DATA_FLAG_UNINITIALIZED) {//flash init is 0xffffffff + return -1; + } + + if ((wland_user_data.flag & flag) == 0) { + return 0; + } + + wland_user_data.flag &= (~flag); + + if (wland_user_data.flag == 0) { + wland_user_data.flag = RDA5991H_USER_DATA_FLAG_UNINITIALIZED; + } + if (flag & RDA5991H_USER_DATA_FLAG_STA) { + memset(&wland_user_data.sta_data, 0xff, + sizeof(wland_user_data.sta_data)); + } + if (flag & RDA5991H_USER_DATA_FLAG_MAC) { + memset(wland_user_data.mac_addr, 0xff, + sizeof(wland_user_data.mac_addr)); + } + if (flag & RDA5991H_USER_DATA_FLAG_PMK) { + memset(wland_user_data.pmk, 0xff, + sizeof(wland_user_data.pmk)); + } + if (flag & RDA5991H_USER_DATA_FLAG_IP) { + memset(wland_user_data.ip, 0xff, + RDA5991H_USER_DATA_IP_LENGTH); + } + if (flag & RDA5991H_USER_DATA_FLAG_PARTER_DATA_LEN) { + memset(&wland_user_data.parter_data_len, 0xff, + sizeof(wland_user_data.parter_data_len)); + } + if (flag & RDA5991H_USER_DATA_FLAG_TX_POWER) { + memset(&wland_user_data.tx_power, 0xff, + sizeof(wland_user_data.tx_power)); + } + if (flag & RDA5991H_USER_DATA_FLAG_XTAL_CAL) { + memset(&wland_user_data.xtal_cal, 0xff, + sizeof(wland_user_data.xtal_cal)); + } + if (flag & RDA5991H_USER_DATA_FLAG_TX_POWER_RF) { + memset(&wland_user_data.tx_power_rf, 0xff, + sizeof(wland_user_data.tx_power_rf)); + } + if (flag & RDA5991H_USER_DATA_FLAG_TX_POWER_PHY_GN) { + memset(&wland_user_data.tx_power_phy_gn, 0xff, + sizeof(wland_user_data.tx_power_phy_gn)); + } + if (flag & RDA5991H_USER_DATA_FLAG_TX_POWER_PHY_B) { + memset(&wland_user_data.tx_power_phy_b, 0xff, + sizeof(wland_user_data.tx_power_phy_b)); + } + if (flag & RDA5991H_USER_DATA_FLAG_AP) { + memset(&wland_user_data.ap_data, 0xff, + sizeof(wland_user_data.ap_data)); + } + if (flag & RDA5991H_USER_DATA_FLAG_APNET) { + memset(&wland_user_data.ap_net_data, 0xff, + sizeof(wland_user_data.ap_net_data)); + } + if (flag & RDA5991H_USER_DATA_FLAG_DHCP) { + memset(&wland_user_data.dhcp, 0xff, + sizeof(wland_user_data.dhcp)); + } + if (flag & RDA5991H_USER_DATA_FLAG_UART) { + memset(&wland_user_data.uart, 0xff, + sizeof(wland_user_data.uart)); + } + if (flag & RDA5991H_USER_DATA_FLAG_RF) { + memset(&wland_user_data.rf, 0xff, + sizeof(wland_user_data.rf)); + } + if (flag & RDA5991H_USER_DATA_FLAG_RF_CHANNELS) { + memset(&wland_user_data.rf_channels, 0xff, + sizeof(wland_user_data.rf_channels)); + } + if (flag & RDA5991H_USER_DATA_FLAG_PHY) { + memset(&wland_user_data.phy, 0xff, + sizeof(wland_user_data.phy)); + } + if (flag & RDA5991H_USER_DATA_FLAG_PHY_CHANNELS) { + memset(&wland_user_data.phy_channels, 0xff, + sizeof(wland_user_data.phy_channels)); + } + if (flag & RDA5991H_USER_DATA_FLAG_TX_POWER_OFFSET) { + memset(&wland_user_data.tp_offset, 0xff, + sizeof(wland_user_data.tp_offset)); + } + rda5981_erase_flash(user_data_location, sizeof(wland_user_data)); + return rda5981_write_flash(user_data_location, + (char *)(&wland_user_data), sizeof(wland_user_data)); +} + +/* + * return 0:ok, else:error. + */ +int rda5981_read_user_data(u8 *data, u16 len, u32 flag) +{ + //rda5991h_user_data wland_user_data; + WLAND_DBG(INFO, "Enter, flag:0x%x\r\n", flag); + + if (!read_flag) { + read_flag = 1; + rda5981_read_flash(user_data_location, + (char *)(&wland_user_data), sizeof(wland_user_data)); + } + + if (wland_user_data.flag & RDA5991H_USER_DATA_FLAG_UNINITIALIZED) {//flash init is 0xffffffff + return -1; + } + if (strcmp((const char *)(wland_user_data.rda5981_flag), RDA5981_FLAG_FLAG)) { + return -2; + } + if ((wland_user_data.flag & flag) == 0) { + return -3; + } + switch (flag) { + case RDA5991H_USER_DATA_FLAG_STA: + memcpy(data, &wland_user_data.sta_data, + min(sizeof(wland_user_data.sta_data), len)); + break; + case RDA5991H_USER_DATA_FLAG_MAC: + memcpy(data, wland_user_data.mac_addr, + min(sizeof(wland_user_data.mac_addr), len)); + break; + case RDA5991H_USER_DATA_FLAG_PMK: + memcpy(data, wland_user_data.pmk, + min(sizeof(wland_user_data.pmk), len)); + break; + case RDA5991H_USER_DATA_FLAG_IP: + memcpy(data, wland_user_data.ip, + min(RDA5991H_USER_DATA_IP_LENGTH, len)); + break; + case RDA5991H_USER_DATA_FLAG_PARTER_DATA_LEN: + memcpy(data, &wland_user_data.parter_data_len, + min(sizeof(wland_user_data.parter_data_len), len)); + break; + case RDA5991H_USER_DATA_FLAG_TX_POWER: + memcpy(data, &wland_user_data.tx_power, + min(sizeof(wland_user_data.tx_power), len)); + break; + case RDA5991H_USER_DATA_FLAG_XTAL_CAL: + memcpy(data, &wland_user_data.xtal_cal, + min(sizeof(wland_user_data.xtal_cal), len)); + break; + case RDA5991H_USER_DATA_FLAG_TX_POWER_RF: + memcpy(data, &wland_user_data.tx_power_rf, + min(sizeof(wland_user_data.tx_power_rf), len)); + break; + case RDA5991H_USER_DATA_FLAG_TX_POWER_PHY_GN: + memcpy(data, &wland_user_data.tx_power_phy_gn, + min(sizeof(wland_user_data.tx_power_phy_gn), len)); + break; + case RDA5991H_USER_DATA_FLAG_TX_POWER_PHY_B: + memcpy(data, &wland_user_data.tx_power_phy_b, + min(sizeof(wland_user_data.tx_power_phy_b), len)); + break; + case RDA5991H_USER_DATA_FLAG_AP: + memcpy(data, &wland_user_data.ap_data, + min(sizeof(wland_user_data.ap_data), len)); + break; + case RDA5991H_USER_DATA_FLAG_APNET: + memcpy(data, &wland_user_data.ap_net_data, + min(sizeof(wland_user_data.ap_net_data), len)); + break; + case RDA5991H_USER_DATA_FLAG_DHCP: + memcpy(data, &wland_user_data.dhcp, + min(sizeof(wland_user_data.dhcp), len)); + break; + case RDA5991H_USER_DATA_FLAG_UART: + memcpy(data, &wland_user_data.uart, + min(sizeof(wland_user_data.uart), len)); + break; + case RDA5991H_USER_DATA_FLAG_RF: + memcpy(data, &wland_user_data.rf, + min(sizeof(wland_user_data.rf), len)); + break; + case RDA5991H_USER_DATA_FLAG_RF_CHANNELS: + memcpy(data, &wland_user_data.rf_channels, + min(sizeof(wland_user_data.rf_channels), len)); + break; + case RDA5991H_USER_DATA_FLAG_PHY: + memcpy(data, &wland_user_data.phy, + min(sizeof(wland_user_data.phy), len)); + break; + case RDA5991H_USER_DATA_FLAG_PHY_CHANNELS: + memcpy(data, &wland_user_data.phy_channels, + min(sizeof(wland_user_data.phy_channels), len)); + break; + case RDA5991H_USER_DATA_FLAG_TX_POWER_OFFSET: + memcpy(data, &wland_user_data.tp_offset, + min(sizeof(wland_user_data.tp_offset), len)); + break; + default: + return -1; + } + return 0; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_mac_addr(u8 *mac_addr) +{ + int ret; + WLAND_DBG(DEBUG, "Enter\r\n"); + ret = rda5981_read_user_data(mac_addr, 6, RDA5991H_USER_DATA_FLAG_MAC); + if (ret) { + WLAND_DBG(ERROR, "read mac addr from flash fail\r\n"); + } else { + WLAND_DBG(INFO, "Done(ret:%d)"MACDBG"\r\n", ret, MAC2STRDBG(mac_addr)); + } + return ret; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_write_mac_addr(u8 *mac_addr) +{ + WLAND_DBG(INFO, "Enter"MACDBG"\r\n", MAC2STRDBG(mac_addr)); + return rda5981_write_user_data(mac_addr, 6, RDA5991H_USER_DATA_FLAG_MAC); +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_erase_uart(void) +{ + return rda5981_erase_user_data(RDA5991H_USER_DATA_FLAG_UART); +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_uart(u32 *uart) +{ + int ret; + WLAND_DBG(DEBUG, "Enter\r\n"); + ret = rda5981_read_user_data((u8 *)uart, 4, RDA5991H_USER_DATA_FLAG_UART); + if (ret) { + WLAND_DBG(ERROR, "read uart setting from flash fail\r\n"); + } + return ret; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_write_uart(u32 *uart) +{ + return rda5981_write_user_data((u8 *)uart, 4, RDA5991H_USER_DATA_FLAG_UART); +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_erase_sta_data(void) +{ + int ret; + ret = rda5981_erase_user_data(RDA5991H_USER_DATA_FLAG_PMK | + RDA5991H_USER_DATA_FLAG_STA); + return ret; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_sta_data(char *ssid, char *passwd) +{ + int ret; + wland_sta_data_t sta_data; + + WLAND_DBG(INFO, "Enter\r\n"); + + ret = rda5981_read_user_data((u8 *)&sta_data, sizeof(sta_data), RDA5991H_USER_DATA_FLAG_STA); + if (ret == 0) { + strcpy(ssid, sta_data.ssid); + strcpy(passwd, sta_data.key); + } + return ret; +} + +/* + * return 0:ok, else:error. + */ +extern u8 *rda_get_bssinfo_pmk(void); +extern u8 *rda_get_bssinfo_SSID(void); +int rda5981_flash_write_sta_data(const char *ssid, const char *passwd) +{ + int ret = 0, ret1; + wland_sta_data_t sta_data; + u8 *pbss_info_pmk = NULL, *pbss_info_SSID = NULL; + pbss_info_pmk = rda_get_bssinfo_pmk(); + pbss_info_SSID = rda_get_bssinfo_SSID(); + + WLAND_DBG(INFO, "Enter:ssid:%s,pw:%s, pmk:%02x %02x***\r\n", + ssid, passwd, pbss_info_pmk[0], pbss_info_SSID[1]); + if (strlen(ssid) == 0) { + WLAND_DBG(ERROR, "ssid is NULL\n"); + return -1; + } + + memset(&sta_data, 0xff, sizeof(sta_data)); + strcpy(sta_data.ssid, ssid); + strcpy(sta_data.key, passwd); + if (pbss_info_pmk[0] && memcmp(pbss_info_SSID, ssid, 6)==0) { + ret = rda5981_write_user_data(pbss_info_pmk, sizeof(pbss_info_pmk), RDA5991H_USER_DATA_FLAG_PMK); + } + ret1 = rda5981_write_user_data((u8 *)&sta_data, sizeof(sta_data), RDA5991H_USER_DATA_FLAG_STA); + return ret || ret1;; +} + + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_erase_dhcp_data(void) +{ + int ret;//, ret1; + //WLAND_DBG(INFO, "Enter\r\n"); + ret = rda5981_erase_user_data(RDA5991H_USER_DATA_FLAG_DHCP); + //ret1 = rda5981_erase_user_data(RDA5991H_USER_DATA_FLAG_PMK); + return ret; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_dhcp_data(unsigned int *fixip, unsigned int *ip, unsigned int *msk, unsigned int *gw) +{ + int ret; + wland_dhcp_t dhcp; + + WLAND_DBG(INFO, "Enter\r\n"); + + ret = rda5981_read_user_data((u8 *)&dhcp, sizeof(dhcp), RDA5991H_USER_DATA_FLAG_DHCP); + if (ret == 0) { + *fixip = dhcp.fixip; + *ip = dhcp.ip; + *msk = dhcp.msk; + *gw = dhcp.gw; + } + return ret; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_write_dhcp_data(unsigned int fixip, unsigned int ip, unsigned int msk, unsigned int gw) +{ + int ret = 0; + wland_dhcp_t dhcp; + + memset(&dhcp, 0xff, sizeof(dhcp)); + dhcp.fixip = fixip; + dhcp.ip = ip; + dhcp.msk = msk; + dhcp.gw = gw; + ret = rda5981_write_user_data((u8 *)&dhcp, sizeof(dhcp), RDA5991H_USER_DATA_FLAG_DHCP); + return ret; +} + + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_erase_ap_data(void) +{ + int ret; + ret = rda5981_erase_user_data(RDA5991H_USER_DATA_FLAG_AP); + return ret; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_write_ap_data(const char *ssid, const char *passwd, unsigned char channel) +{ + int ret = 0; + wland_ap_data_t ap_data; + + if (strlen(ssid) == 0) { + WLAND_DBG(ERROR, "ssid is NULL\n"); + return -1; + } + + memset(&ap_data, 0xff, sizeof(ap_data)); + strcpy(ap_data.ssid, ssid); + strcpy(ap_data.key, passwd); + ap_data.channel = channel; + ret = rda5981_write_user_data((u8 *)&ap_data, sizeof(ap_data), RDA5991H_USER_DATA_FLAG_AP); + return ret; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_ap_data(char *ssid, char *passwd, unsigned char *channel) +{ + int ret; + wland_ap_data_t ap_data; + + WLAND_DBG(INFO, "Enter\r\n"); + + ret = rda5981_read_user_data((u8 *)&ap_data, sizeof(ap_data), RDA5991H_USER_DATA_FLAG_AP); + if (ret == 0) { + strcpy(ssid, ap_data.ssid); + strcpy(passwd, ap_data.key); + *channel = ap_data.channel; + } + return ret; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_erase_ap_net_data(void) +{ + int ret; + ret = rda5981_erase_user_data(RDA5991H_USER_DATA_FLAG_APNET); + return ret; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_write_ap_net_data(unsigned int ip, unsigned int msk, unsigned int gw, + unsigned int dhcps, unsigned int dhcpe) +{ + int ret = 0; + wland_ap_net_data_t ap_net_data; + + WLAND_DBG(INFO, "Enter\r\n"); + + memset(&ap_net_data, 0xff, sizeof(ap_net_data)); + ap_net_data.ip = ip; + ap_net_data.msk = msk; + ap_net_data.gw = gw; + ap_net_data.dhcps = dhcps; + ap_net_data.dhcpe = dhcpe; + + ret = rda5981_write_user_data((u8 *)&ap_net_data, sizeof(ap_net_data), RDA5991H_USER_DATA_FLAG_APNET); + return ret; +} + +/* + * return 0:ok, else:error. + */ +int rda5981_flash_read_ap_net_data(unsigned int *ip, unsigned int *msk, unsigned int *gw, + unsigned int *dhcps, unsigned int *dhcpe) +{ + int ret = 0; + wland_ap_net_data_t ap_net_data; + + WLAND_DBG(INFO, "Enter\r\n"); + + ret = rda5981_read_user_data((u8 *)&ap_net_data, sizeof(ap_net_data), RDA5991H_USER_DATA_FLAG_APNET); + if (ret == 0) { + *ip = ap_net_data.ip; + *msk = ap_net_data.msk; + *gw = ap_net_data.gw; + *dhcps = ap_net_data.dhcps; + *dhcpe = ap_net_data.dhcpe; + } + return ret; +} + + +int rda5981_flash_read_pmk(u8 *pmk) +{ + WLAND_DBG(INFO, "Enter\r\n"); + return rda5981_read_user_data(pmk, 32, RDA5991H_USER_DATA_FLAG_PMK); +} + +int rda5981_flash_read_ip_addr(u8 *ip_addr, u8 *server_addr) +{ + int ret; + u8 buf[RDA5991H_USER_DATA_IP_LENGTH]; + WLAND_DBG(DEBUG, "Enter\r\n"); + ret = rda5981_read_user_data(buf, RDA5991H_USER_DATA_IP_LENGTH, RDA5991H_USER_DATA_FLAG_IP); + if (ret) { + WLAND_DBG(ERROR, "read ip addr from flash fail\r\n"); + } else { + memcpy(ip_addr, buf, 4); + memcpy(server_addr, buf+4, 4); + WLAND_DBG(INFO, "read ip:%u.%u.%u.%u\r\n", ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3]); + } + return ret; +} + +int rda5981_flash_write_ip_addr(u8 *ip_addr, u8 *server_addr) +{ + u8 buf[RDA5991H_USER_DATA_IP_LENGTH]; + WLAND_DBG(INFO, "write:%u.%u.%u.%u\r\n", ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3]); + memcpy(buf, ip_addr, 4); + memcpy(buf+4, server_addr, 4); + return rda5981_write_user_data(buf, RDA5991H_USER_DATA_IP_LENGTH, RDA5991H_USER_DATA_FLAG_IP); +} + +int rda5981_flash_read_3rdparter_data_length() +{ + int ret; + u32 data_len = 0; + + WLAND_DBG(INFO, "Enter\r\n"); + ret = rda5981_read_user_data((u8 *)(&data_len), 4, RDA5991H_USER_DATA_FLAG_PARTER_DATA_LEN); + if (ret) { + WLAND_DBG(ERROR, "read parter data length from flash fail(%d)\r\n", ret); + return -1; + } + return data_len; +} + +int rda5981_flash_read_3rdparter_data(u8 *buf, u32 buf_len) +{ + int ret; + u32 data_len = 0; + + WLAND_DBG(INFO, "Enter: %u\r\n", buf_len); + ret = rda5981_read_user_data((u8 *)(&data_len), 4, RDA5991H_USER_DATA_FLAG_PARTER_DATA_LEN); + if (ret) { + WLAND_DBG(ERROR, "read parter data length from flash fail(%d)\r\n", ret); + return -1; + } + + if (buf_len < data_len) + WLAND_DBG(ERROR, "The buf you prepared is to small(%u:%u)\r\n", buf_len, data_len); + + data_len = min(buf_len, data_len); + + ret = rda5981_read_flash(third_parter_data_location, + (char *)(buf), data_len); + if (ret) { + WLAND_DBG(ERROR, "read parter data from flash fail(%d)\r\n", ret); + return -2; + } + + return data_len; +} + +int rda5981_flash_erase_3rdparter_data() +{ + return rda5981_erase_user_data(RDA5991H_USER_DATA_FLAG_PARTER_DATA_LEN); +} + +int rda5981_flash_write_3rdparter_data(const u8 *buf, u32 buf_len) +{ + int ret; + + WLAND_DBG(INFO, "Enter: %u\r\n", buf_len); + if (buf_len > third_parter_data_len) { + WLAND_DBG(ERROR, "buf too long(%u), we have only %x flash space\r\n", + buf_len, third_parter_data_len); + return -1; + } + + rda5981_erase_flash(third_parter_data_location, buf_len); + ret = rda5981_write_flash(third_parter_data_location, + (char *)(buf), buf_len); + if (ret) { + WLAND_DBG(ERROR, "write parter data to flash fail\r\n"); + return -2; + } + + ret = rda5981_write_user_data((u8 *)(&buf_len), 4, RDA5991H_USER_DATA_FLAG_PARTER_DATA_LEN); + if (ret) { + WLAND_DBG(ERROR, "write parter data length to flash fail\r\n"); + return -3; + } + return 0; +} + +int rda5981_set_flash_size(const u32 size) +{ + + WLAND_DBG(INFO, "Enter set flash size: %x\r\n", size); + if (size == 0x100000 || + size == 0x200000 || + size == 0x400000) { + flash_size = size; + return 0; + } + + return -1; +} + +int rda5981_set_user_data_addr(const u32 sys_data_addr, + const u32 user_data_addr, const u32 user_data_len) +{ + WLAND_DBG(INFO, "Enter set userdata addr: %x:%x:%x\r\n", + sys_data_addr, user_data_addr, user_data_len); + if ((sys_data_addr&(SECTOR_SIZE-1)) || (user_data_addr&(SECTOR_SIZE-1))) { + return -1; + } + if (sys_data_addr == user_data_addr) { + return -2; + } + + if (sys_data_addr<=0x18001000 || user_data_addr<=0x18001000) { + return -3; + } + if (sys_data_addr+0x1000 > 0x18000000+flash_size) { + return -4; + } + if (user_data_addr+user_data_len > 0x18000000+flash_size) { + return -5; + } + + user_data_location = sys_data_addr; + third_parter_data_location = user_data_addr; + third_parter_data_len= user_data_len; + return 0; +} + +int rda5981_write_user_data_regs(u8 *reg, u8 *value, u32 flag) +{ + u16 reg16 = 0; + u32 reg32 = 0; + u8 idx = 0; + + if (!read_flag) { + if (0 == rda5981_read_flash(user_data_location, + (char *)(&wland_user_data), sizeof(wland_user_data))) { + read_flag = 1; + } else { + return -1; + } + } + + if ((wland_user_data.flag & RDA5991H_USER_DATA_FLAG_UNINITIALIZED) || + strcmp((const char *)(wland_user_data.rda5981_flag), RDA5981_FLAG_FLAG)) { + memset(&wland_user_data, 0xff, sizeof(wland_user_data)); + wland_user_data.flag = flag; + strcpy((char *)(wland_user_data.rda5981_flag), RDA5981_FLAG_FLAG); + } + + wland_user_data.flag |= flag; + + switch (flag) { + case RDA5991H_USER_DATA_FLAG_RF: + if (wland_user_data.rf.valid != 1) { + wland_user_data.rf.valid = 1; + wland_user_data.rf.flag = 0; + } + + reg16 = *((u16 *)reg); + if (wland_user_data.rf.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.rf.flag & BIT(idx)) && + (wland_user_data.rf.reg_val[idx][0] == reg16)) { + wland_user_data.rf.reg_val[idx][1] = *((u16 *)value); + break; + } else { + continue; + } + } + if ((8 == idx) && (0xFF == wland_user_data.rf.flag)) + return -2; + } + + if ((8 == idx) || (0 == wland_user_data.rf.flag)) { + for (idx = 0; idx < 8; idx++) { + if (!(wland_user_data.rf.flag & BIT(idx))) { + wland_user_data.rf.reg_val[idx][0] = reg16; + wland_user_data.rf.reg_val[idx][1] = *((u16 *)value); + wland_user_data.rf.flag |= BIT(idx); + break; + } else { + continue; + } + } + } + + break; + case RDA5991H_USER_DATA_FLAG_RF_CHANNELS: + if (wland_user_data.rf_channels.valid != 1) { + wland_user_data.rf_channels.valid = 1; + wland_user_data.rf_channels.flag = 0; + } + + reg16 = *((u16 *)reg); + if (wland_user_data.rf_channels.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.rf_channels.flag & BIT(idx)) && + (wland_user_data.rf_channels.reg_val[idx][0] == reg16)) { + memcpy(&wland_user_data.rf_channels.reg_val[idx][1], value, 14 * sizeof(u16)); + break; + } else { + continue; + } + } + if ((8 == idx) && (0xFF == wland_user_data.rf_channels.flag)) { + return -2; + } + } + + if ((8 == idx) || (0 == wland_user_data.rf_channels.flag)) { + for (idx = 0; idx < 8; idx++) { + if (!(wland_user_data.rf_channels.flag & BIT(idx))) { + wland_user_data.rf_channels.reg_val[idx][0] = reg16; + memcpy(&wland_user_data.rf_channels.reg_val[idx][1], value, 14 * sizeof(u16)); + wland_user_data.rf_channels.flag |= BIT(idx); + break; + } else { + continue; + } + } + } + break; + case RDA5991H_USER_DATA_FLAG_PHY: + if (wland_user_data.phy.valid != 1) { + wland_user_data.phy.valid = 1; + wland_user_data.phy.flag = 0; + } + + reg32 = *((u32 *)reg); + if (wland_user_data.phy.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.phy.flag & BIT(idx)) && + (wland_user_data.phy.reg_val[idx][0] == reg32)) { + wland_user_data.phy.reg_val[idx][1] = *((u32 *)value); + break; + } else { + continue; + } + } + if ((8 == idx) && (0xFF == wland_user_data.phy.flag)) { + return -2; + } + } + + if ((8 == idx) || (0 == wland_user_data.phy.flag)) { + for (idx = 0; idx < 8; idx++) { + if (!(wland_user_data.phy.flag & BIT(idx))) { + wland_user_data.phy.reg_val[idx][0] = reg32; + wland_user_data.phy.reg_val[idx][1] = *((u32 *)value); + wland_user_data.phy.flag |= BIT(idx); + break; + } else { + continue; + } + } + } + break; + case RDA5991H_USER_DATA_FLAG_PHY_CHANNELS: + if (wland_user_data.phy_channels.valid != 1) { + wland_user_data.phy_channels.valid = 1; + wland_user_data.phy_channels.flag = 0; + } + + reg32 = *((u32 *)reg); + if (wland_user_data.phy_channels.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.phy_channels.flag & BIT(idx)) && + (wland_user_data.phy_channels.reg_val[idx][0] == reg32)) { + memcpy(&wland_user_data.phy_channels.reg_val[idx][1], value, 14 * sizeof(u32)); + break; + } else { + continue; + } + } + if ((8 == idx) && (0xFF == wland_user_data.phy_channels.flag)) { + return -2; + } + } + + if ((8 == idx) || (0 == wland_user_data.phy_channels.flag)) { + for (idx = 0; idx < 8; idx++) { + if (!(wland_user_data.phy_channels.flag & BIT(idx))) { + wland_user_data.phy_channels.reg_val[idx][0] = reg32; + memcpy(&wland_user_data.phy_channels.reg_val[idx][1], value, 14 * sizeof(u32)); + wland_user_data.phy_channels.flag |= BIT(idx); + break; + } else { + continue; + } + } + } + break; + default: + WLAND_DBG(ERROR, "Unknown flag:0x%08x\n", flag); + return -3; + } + + rda5981_erase_flash(user_data_location, sizeof(wland_user_data)); + return rda5981_write_flash(user_data_location, + (char *)(&wland_user_data), sizeof(wland_user_data)); +} + +int rda5981_erase_user_data_regs(u8 *reg, u32 flag) +{ + u16 reg16 = 0; + u32 reg32 = 0; + u8 idx = 0; + + if (!read_flag) { + if (0 == rda5981_read_flash(user_data_location, + (char *)(&wland_user_data), sizeof(wland_user_data))) { + read_flag = 1; + } else { + return -1; + } + } + + if (wland_user_data.flag & RDA5991H_USER_DATA_FLAG_UNINITIALIZED) {//flash init is 0xffffffff + return -1; + } + if ((wland_user_data.flag & flag) == 0) { + return 0; + } + switch (flag) { + case RDA5991H_USER_DATA_FLAG_RF: + if (wland_user_data.rf.valid != 1) { + return 0; + } + + reg16 = *((u16 *)reg); + if (wland_user_data.rf.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.rf.flag & BIT(idx)) && + (wland_user_data.rf.reg_val[idx][0] == reg16)) { + memset(&wland_user_data.rf.reg_val[idx][0], 0xFF, 2 * sizeof(u16)); + wland_user_data.rf.flag &= ~BIT(idx); + break; + } else { + continue; + } + } + } + + if (0 == wland_user_data.rf.flag) { + wland_user_data.rf.valid = 0xFFFFFFFF; + wland_user_data.rf.flag = 0xFFFFFFFF; + wland_user_data.flag &= (~flag); + } + + break; + case RDA5991H_USER_DATA_FLAG_RF_CHANNELS: + if (wland_user_data.rf_channels.valid != 1) { + return 0; + } + + reg16 = *((u16 *)reg); + if (wland_user_data.rf_channels.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.rf_channels.flag & BIT(idx)) && + (wland_user_data.rf_channels.reg_val[idx][0] == reg16)) { + memset(&wland_user_data.rf_channels.reg_val[idx][0], 0xFF, 15 * sizeof(u16)); + wland_user_data.rf_channels.flag &= ~BIT(idx); + break; + } else { + continue; + } + } + } + + if (0 == wland_user_data.rf_channels.flag) { + wland_user_data.rf_channels.valid = 0xFFFFFFFF; + wland_user_data.rf_channels.flag = 0xFFFFFFFF; + wland_user_data.flag &= (~flag); + } + + break; + case RDA5991H_USER_DATA_FLAG_PHY: + if (wland_user_data.phy.valid != 1) { + return 0; + } + + reg32 = *((u32 *)reg); + if (wland_user_data.phy.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.phy.flag & BIT(idx)) && + (wland_user_data.phy.reg_val[idx][0] == reg32)) { + memset(&wland_user_data.phy.reg_val[idx][0], 0xFF, 2 * sizeof(u32)); + wland_user_data.phy.flag &= ~BIT(idx); + break; + } else { + continue; + } + } + } + + if (0 == wland_user_data.phy.flag) { + wland_user_data.phy.valid = 0xFFFFFFFF; + wland_user_data.phy.flag = 0xFFFFFFFF; + wland_user_data.flag &= (~flag); + } + + break; + case RDA5991H_USER_DATA_FLAG_PHY_CHANNELS: + if (wland_user_data.phy_channels.valid != 1) { + return 0; + } + + reg32 = *((u32 *)reg); + if (wland_user_data.phy_channels.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.phy_channels.flag & BIT(idx)) && + (wland_user_data.phy_channels.reg_val[idx][0] == reg32)) { + memset(&wland_user_data.phy_channels.reg_val[idx][0], 0xFF, 15 * sizeof(u32)); + wland_user_data.phy_channels.flag &= ~BIT(idx); + break; + } else { + continue; + } + } + } + + if (0 == wland_user_data.phy_channels.flag) { + wland_user_data.phy_channels.valid = 0xFFFFFFFF; + wland_user_data.phy_channels.flag = 0xFFFFFFFF; + wland_user_data.flag &= (~flag); + } + + break; + default: + WLAND_DBG(ERROR, "Unknown flag:0x%08x\n", flag); + return -3; + } + + rda5981_erase_flash(user_data_location, sizeof(wland_user_data)); + return rda5981_write_flash(user_data_location, + (char *)(&wland_user_data), sizeof(wland_user_data)); +} + + +int rda5981_read_user_data_regs(u8 *reg, u8 *value, u32 flag) +{ + u16 reg16 = 0; + u32 reg32 = 0; + u8 idx = 0; + + if (!read_flag) { + if(0 == rda5981_read_flash(user_data_location, + (char *)(&wland_user_data), sizeof(wland_user_data))) { + read_flag = 1; + } else { + return -1; + } + } + + if (wland_user_data.flag & RDA5991H_USER_DATA_FLAG_UNINITIALIZED) {//flash init is 0xffffffff + return -1; + } + if (strcmp((const char *)(wland_user_data.rda5981_flag), RDA5981_FLAG_FLAG)) { + return -2; + } + if ((wland_user_data.flag & flag) == 0) { + return -3; + } + switch (flag) { + case RDA5991H_USER_DATA_FLAG_RF: + if (wland_user_data.rf.valid != 1) { + return -4; + } + + reg16 = *((u16 *)reg); + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.rf.flag & BIT(idx)) && + (wland_user_data.rf.reg_val[idx][0] == reg16)) { + memcpy(value, &wland_user_data.rf.reg_val[idx][1], sizeof(u16)); + break; + } else { + continue; + } + } + + if (8 == idx) { + return -4; + } + break; + case RDA5991H_USER_DATA_FLAG_RF_CHANNELS: + if (wland_user_data.rf_channels.valid != 1) { + return -4; + } + + reg16 = *((u16 *)reg); + if (wland_user_data.rf_channels.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.rf_channels.flag & BIT(idx)) && + (wland_user_data.rf_channels.reg_val[idx][0] == reg16)) { + memcpy(value, &wland_user_data.rf_channels.reg_val[idx][1], 14 * sizeof(u16)); + break; + } else { + continue; + } + } + } + + if (8 == idx) { + return -4; + } + break; + case RDA5991H_USER_DATA_FLAG_PHY: + if (wland_user_data.phy.valid != 1) { + return -4; + } + + reg32 = *((u32 *)reg); + if (wland_user_data.phy.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.phy.flag & BIT(idx)) && + (wland_user_data.phy.reg_val[idx][0] == reg32)) { + memcpy(value, &wland_user_data.phy.reg_val[idx][1], sizeof(u32)); + break; + } else { + continue; + } + } + } + + if (8 == idx) { + return -4; + } + break; + case RDA5991H_USER_DATA_FLAG_PHY_CHANNELS: + if (wland_user_data.phy_channels.valid != 1) { + return -4; + } + + reg32 = *((u32 *)reg); + if (wland_user_data.phy_channels.flag != 0) { + for (idx = 0; idx < 8; idx++) { + if ((wland_user_data.phy_channels.flag & BIT(idx)) && + (wland_user_data.phy_channels.reg_val[idx][0] == reg32)) { + memcpy(value, &wland_user_data.phy_channels.reg_val[idx][1], 14 * sizeof(u32)); + break; + } else { + continue; + } + } + } + + if (8 == idx) { + return -4; + } + break; + default: + WLAND_DBG(ERROR, "Unknown flag:0x%08x\n", flag); + return -3; + } + + return 0; +} + +int rda5981_flash_get_mid(u8 *mid) +{ + *mid = 0xC8; + + return 0; +} + +int rda5981_flash_get_did(u8 *did) +{ + *did = 0x13; + + return 0; +} + +int rda5981_flash_get_jdid(u16 *jdid) +{ + *jdid = 0x4014; + + return 0; +} + +int rda5981_read_default_config(char *buf, u32 len, u32 flag) +{ + int ret = 0; + u32 addr; + u32 addr_offset = 0; + char *temp_buf = NULL, *temp_buf_aligned; + + switch (flag) { + case RDA5981_VBAT_CAL: + addr = 0x18000088; + break; + case RDA5981_GPADC0_CAL: + case RDA5981_GPADC1_CAL: + addr = 0x1800008C; + break; + case RDA5981_PRODUCT_ID: + addr = 0x18000084; + break; + case RDA5981_POWER_CLASS: + addr = 0x18000085; + break; + default: + WLAND_DBG(ERROR, "Unknown flag\n"); + return -1; + } + + addr_offset = addr % 4; + addr = (addr - addr_offset) & (flash_size -1); + + if (((u32)buf % 4) || (addr_offset != 0)) { + temp_buf = (char *)malloc(addr_offset + len + 4); + if (temp_buf == NULL) { + ret = -1; + goto out; + } + if ((u32)temp_buf % 4) { + temp_buf_aligned = temp_buf + (4 - (u32)temp_buf % 4); + } else { + temp_buf_aligned = temp_buf; + } + } else { + temp_buf_aligned = buf; + } + + core_util_critical_section_enter(); + spi_flash_flush_cache(); + SPI_FLASH_READ_DATA_FOR_MBED((void *)addr, temp_buf_aligned, (len + addr_offset)); + core_util_critical_section_exit(); + + if (temp_buf_aligned != buf) { + memcpy(buf, temp_buf_aligned + addr_offset, len); + } +out: + if (temp_buf) { + free(temp_buf); + } + return ret; +} + +int rda5981_flash_read_vbat_cal(float *k, float *b) +{ + int ret = 0; + u32 value = 0; + u32 x1 = 0;//y1 3.0f + u32 x2 = 0;//y2 4.2f + float k_tmp = 0; + float b_tmp = 0; + + ret = rda5981_read_default_config((char *)&value, 4, RDA5981_VBAT_CAL); + + if (ret < 0) { + WLAND_DBG(ERROR, "read vbat_cal form flash fail\n"); + return -1; + } + if ((0 == (value & 0xFFFFFUL)) || (0xFFFFFUL == (value & 0xFFFFFUL))) { + WLAND_DBG(ERROR, "invalid vbat_cal:0x%08x\n", value); + return -1; + } else { + x1 = value & 0x3FFUL; + x2 = (value >> 10) & 0x3FFUL; + } + + if (x1 == x2) { + return -1; + } + + k_tmp = (4.2f - 3.0f) / (float)(x2 - x1); + b_tmp = 4.2f - k_tmp * x2; + + *k = k_tmp; + *b = b_tmp; + + return ret; +} diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/wland_flash_wp.c b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/wland_flash_wp.c new file mode 100644 index 0000000000..6ff0181640 --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/wland_flash_wp.c @@ -0,0 +1,366 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#include "mbed_interface.h" +#include "wland_flash.h" + +//#define FLASH_PROTECT_ENABLE + +#define FLASH_CTL_REG_BASE 0x17fff000 +#define FLASH_CTL_TX_CMD_ADDR_REG (FLASH_CTL_REG_BASE + 0x00) +#define FLASH_CTL_TX_BLOCK_SIZE_REG (FLASH_CTL_REG_BASE + 0x04) +#define FLAHS_CTL_TX_FIFO_DATA_REG (FLASH_CTL_REG_BASE + 0x08) +#define FLASH_CTL_STATUS_REG (FLASH_CTL_REG_BASE + 0x0c) +#define FLAHS_CTL_RX_FIFO_DATA_REG (FLASH_CTL_REG_BASE + 0x10) + +#define WRITE_REG32(REG, VAL) ((*(volatile unsigned int*)(REG)) = (unsigned int)(VAL)) +#define WRITE_REG8(REG, VAL) ((*(volatile unsigned char*)(REG)) = (unsigned char)(VAL)) +#define MREAD_WORD(addr) *((volatile unsigned int *)(addr)) + +#define MID_GD 0xC8 +#define MID_WINBOND 0xEF + +#define FLASH_1M 0x100000 +#define FLASH_2M 0x200000 +#define FLASH_4M 0x400000 +extern unsigned int flash_size; + +#ifdef FLASH_PROTECT_ENABLE + +#define FLASH_WP_MASK 0x407c +#define FLASH_WP_NONE 0x0000 +#define FLASH_WP_ALL 0x1c + +#define FLASH_4M_WP_4K 0x0064 +#define FLASH_4M_WP_8K 0x0068 +#define FLASH_4M_WP_16K 0x006c +#define FLASH_4M_WP_32K 0x0070 +#define FLASH_4M_WP_1_64 0x0024 +#define FLASH_4M_WP_1_32 0x0028 +#define FLASH_4M_WP_1_16 0x002c +#define FLASH_4M_WP_1_8 0x0030 +#define FLASH_4M_WP_1_4 0x0034 +#define FLASH_4M_WP_1_2 0x0038 +#define FLASH_4M_WP_3_4 0x4014 +#define FLASH_4M_WP_7_8 0x4010 +#define FLASH_4M_WP_15_16 0x400c +#define FLASH_4M_WP_31_32 0x4008 +#define FLASH_4M_WP_63_64 0x4004 +#define FLASH_4M_WP_127_128 0x4058 +#define FLASH_4M_WP_255_256 0x404C +#define FLASH_4M_WP_1023_1024 0x4044 + +#define FLASH_2M_WP_4K 0x0064 +#define FLASH_2M_WP_8K 0x0068 +#define FLASH_2M_WP_16K 0x006c +#define FLASH_2M_WP_32K 0x0070 +#define FLASH_2M_WP_1_32 0x0024 +#define FLASH_2M_WP_1_16 0x0028 +#define FLASH_2M_WP_1_8 0x002c +#define FLASH_2M_WP_1_4 0x0050 +#define FLASH_2M_WP_1_2 0x0051 +#define FLASH_2M_WP_3_4 0x4010 +#define FLASH_2M_WP_7_8 0x400c +#define FLASH_2M_WP_15_16 0x4004 +#define FLASH_2M_WP_31_32 0x4000 +#define FLASH_2M_WP_63_64 0x4050 +#define FLASH_2M_WP_127_128 0x404c +#define FLASH_2M_WP_255_256 0x4048 +#define FLASH_2M_WP_511_512 0x4044 + + +#define FLASH_1M_WP_4K 0x0064 +#define FLASH_1M_WP_8K 0x0068 +#define FLASH_1M_WP_16K 0x006c +#define FLASH_1M_WP_32K 0x0070 +#define FLASH_1M_WP_1_16 0x0024 +#define FLASH_1M_WP_1_8 0x0028 +#define FLASH_1M_WP_1_4 0x002c +#define FLASH_1M_WP_1_2 0x0050 +#define FLASH_1M_WP_3_4 0x400C +#define FLASH_1M_WP_7_8 0x4008 +#define FLASH_1M_WP_15_16 0x4004 +#define FLASH_1M_WP_31_32 0x4050 +#define FLASH_1M_WP_63_64 0x404C +#define FLASH_1M_WP_127_128 0x4048 +#define FLASH_1M_WP_255_256 0x4044 + +static unsigned short flash_wrtie_protect_4M(unsigned short status, unsigned int offset) +{ + unsigned int wp = FLASH_WP_NONE; + if (offset >= flash_size - flash_size/1024) { + wp = FLASH_4M_WP_1023_1024; + } else if(offset >= flash_size - flash_size/256) { + wp = FLASH_4M_WP_255_256; + } else if(offset >= flash_size - flash_size/128) { + wp = FLASH_4M_WP_127_128; + } else if(offset >= flash_size - flash_size/64) { + wp = FLASH_4M_WP_63_64; + } else if(offset >= flash_size - flash_size/32) { + wp = FLASH_4M_WP_31_32; + } else if(offset >= flash_size - flash_size/16) { + wp = FLASH_4M_WP_15_16; + } else if(offset >= flash_size - flash_size/8) { + wp = FLASH_4M_WP_7_8; + } else if(offset >= flash_size - flash_size/4) { + wp = FLASH_4M_WP_3_4; + } else if(offset >= flash_size/2) { + wp = FLASH_4M_WP_1_2; + } else if(offset >= flash_size/4) { + wp = FLASH_4M_WP_1_4; + } else if(offset >= flash_size/8) { + wp = FLASH_4M_WP_1_8; + } else if(offset >= flash_size/16) { + wp = FLASH_4M_WP_1_16; + } else if(offset >= flash_size/32) { + wp = FLASH_4M_WP_1_32; + } else if(offset >= flash_size/64) { + wp = FLASH_4M_WP_1_64; + } else if(offset >= 32 * 1024) { + wp = FLASH_4M_WP_32K; + } else if(offset >= 16 * 1024) { + wp = FLASH_4M_WP_16K; + } else if(offset >= 8 * 1024) { + wp = FLASH_4M_WP_8K; + } else if(offset >= 4 * 1024) { + wp = FLASH_4M_WP_4K; + } + + return (status & ~FLASH_WP_MASK) | wp; + +} + +static unsigned short flash_wrtie_protect_2M(unsigned short status, unsigned int offset) +{ + unsigned int wp = FLASH_WP_NONE; + if (offset >= flash_size - flash_size/256) { + wp = FLASH_2M_WP_255_256; + } else if(offset >= flash_size - flash_size/128) { + wp = FLASH_2M_WP_127_128; + } else if(offset >= flash_size - flash_size/64) { + wp = FLASH_2M_WP_63_64; + } else if(offset >= flash_size - flash_size/32) { + wp = FLASH_2M_WP_31_32; + } else if(offset >= flash_size - flash_size/16) { + wp = FLASH_2M_WP_15_16; + } else if(offset >= flash_size - flash_size/8) { + wp = FLASH_2M_WP_7_8; + } else if(offset >= flash_size - flash_size/4) { + wp = FLASH_2M_WP_3_4; + } else if(offset >= flash_size/2) { + wp = FLASH_2M_WP_1_2; + } else if(offset >= flash_size/4) { + wp = FLASH_2M_WP_1_4; + } else if(offset >= flash_size/8) { + wp = FLASH_2M_WP_1_8; + } else if(offset >= flash_size/16) { + wp = FLASH_2M_WP_1_16; + } else if(offset >= flash_size/32) { + wp = FLASH_2M_WP_1_32; + } else if(offset >= 32 * 1024) { + wp = FLASH_2M_WP_32K; + } else if(offset >= 16 * 1024) { + wp = FLASH_2M_WP_16K; + } else if(offset >= 8 * 1024) { + wp = FLASH_2M_WP_8K; + } else if(offset >= 4 * 1024) { + wp = FLASH_2M_WP_4K; + } + + return (status & ~FLASH_WP_MASK) | wp; + +} + +static unsigned short flash_wrtie_protect_1M(unsigned short status, unsigned int offset) +{ + unsigned int wp = FLASH_WP_NONE; + + if (offset >= flash_size - flash_size/256) { + wp = FLASH_1M_WP_255_256; + } else if(offset >= flash_size - flash_size/128) { + wp = FLASH_1M_WP_127_128; + } else if(offset >= flash_size - flash_size/64) { + wp = FLASH_1M_WP_63_64; + } else if(offset >= flash_size - flash_size/32) { + wp = FLASH_1M_WP_31_32; + } else if(offset >= flash_size - flash_size/16) { + wp = FLASH_1M_WP_15_16; + } else if(offset >= flash_size - flash_size/8) { + wp = FLASH_1M_WP_7_8; + } else if(offset >= flash_size - flash_size/4) { + wp = FLASH_1M_WP_3_4; + } else if(offset >= flash_size/2) { + wp = FLASH_1M_WP_1_2; + } else if(offset >= flash_size/4) { + wp = FLASH_1M_WP_1_4; + } else if(offset >= flash_size/8) { + wp = FLASH_1M_WP_1_8; + } else if(offset >= flash_size/16) { + wp = FLASH_1M_WP_1_16; + } else if(offset >= 32 * 1024) { + wp = FLASH_1M_WP_32K; + } else if(offset >= 16 * 1024) { + wp = FLASH_1M_WP_16K; + } else if(offset >= 8 * 1024) { + wp = FLASH_1M_WP_8K; + } else if(offset >= 4 * 1024) { + wp = FLASH_1M_WP_4K; + } + + return (status & ~FLASH_WP_MASK) | wp; + +} + +void flash_wrtie_protect_all() +{ + unsigned short status; + unsigned char r1, r2; + core_util_critical_section_enter(); + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, 0x05); + wait_busy_down(); + r1 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, 0x35); + wait_busy_down(); + r2 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + //mbed_error_printf("status %x %x\r\n", r2, r1); + + status = (r2 << 8) | r1; + status = (status & ~FLASH_WP_MASK) | FLASH_WP_ALL; + //mbed_error_printf("status %04x\r\n", status); + + spi_write_reset(); + wait_busy_down(); + WRITE_REG8(FLAHS_CTL_TX_FIFO_DATA_REG, (status&0xff)); + WRITE_REG8(FLAHS_CTL_TX_FIFO_DATA_REG, ((status>>8)&0xff)); + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, 0x01); + wait_busy_down(); + spi_wip_reset(); + core_util_critical_section_exit(); + return; +} + +void flash_wrtie_protect_none() +{ + unsigned short status; + unsigned char r1, r2; + core_util_critical_section_enter(); + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, 0x05); + wait_busy_down(); + r1 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, 0x35); + wait_busy_down(); + r2 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + //mbed_error_printf("status %x %x\r\n", r2, r1); + + status = (r2 << 8) | r1; + status = status & ~FLASH_WP_MASK; + //mbed_error_printf("status %04x\r\n", status); + + spi_write_reset(); + wait_busy_down(); + WRITE_REG8(FLAHS_CTL_TX_FIFO_DATA_REG, (status&0xff)); + WRITE_REG8(FLAHS_CTL_TX_FIFO_DATA_REG, ((status>>8)&0xff)); + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, 0x01); + wait_busy_down(); + spi_wip_reset(); + core_util_critical_section_exit(); + return; +} + +void flash_wrtie_protect(unsigned int offset) +{ + unsigned short status; + unsigned char r1, r2; + core_util_critical_section_enter(); + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, 0x05); + wait_busy_down(); + r1 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, 0x35); + wait_busy_down(); + r2 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + //mbed_error_printf("status %x %x\r\n", r2, r1); + + status = (r2 << 8) | r1; + if (flash_size == FLASH_4M) { + status = flash_wrtie_protect_4M(status, offset); + } else if(flash_size == FLASH_2M) { + status = flash_wrtie_protect_2M(status, offset); + } else if(flash_size == FLASH_1M) { + status = flash_wrtie_protect_1M(status, offset); + } else [ + LWIP_DEBUGF(NETIF_DEBUG,"flash_size is error\r\n"); + } + //mbed_error_printf("status %04x\r\n", status); + + spi_write_reset(); + wait_busy_down(); + WRITE_REG8(FLAHS_CTL_TX_FIFO_DATA_REG, (status&0xff)); + WRITE_REG8(FLAHS_CTL_TX_FIFO_DATA_REG, ((status>>8)&0xff)); + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, 0x01); + wait_busy_down(); + spi_wip_reset(); + core_util_critical_section_exit(); + return; +} +#else +void flash_wrtie_protect_all() +{ + return; +} + +void flash_wrtie_protect_none() +{ + return; +} + +void flash_wrtie_protect(unsigned int offset) +{ + return; +} + +#endif +void rda5981_flash_init() +{ + unsigned int status3, status4, status5; + core_util_critical_section_enter(); + WRITE_REG32(FLASH_CTL_TX_BLOCK_SIZE_REG, 3<<8); + status3 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + status4 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + status5 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + + wait_busy_down(); + spi_wip_reset(); + WRITE_REG32(FLASH_CTL_TX_CMD_ADDR_REG, 0x9F); + wait_busy_down(); + //WRITE_REG32(FLASH_CTL_TX_BLOCK_SIZE_REG, 3<<8); + //wait_busy_down(); + status3 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + status4 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + status5 = MREAD_WORD(FLAHS_CTL_RX_FIFO_DATA_REG); + core_util_critical_section_exit(); + + if ((status5&0xff != 0x14) && (status5&0xff != 0x15) && (status5&0xff != 0x16)) { + mbed_error_printf("flash size error\r\n"); + return; + } + flash_size = (1 << (status5&0xff)); + flash_wrtie_protect_all(); + + return; +} diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/wland_ota.c b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/wland_ota.c new file mode 100644 index 0000000000..05a85abc0a --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/lwip-wifi/arch/TARGET_RDA/TARGET_UNO_91H/src/wland_ota.c @@ -0,0 +1,145 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#include "wland_ota.h" +#include "wland_flash.h" +#include "rda5981_ota.h" +#include "wland_dbg.h" +#include "wland_types.h" +#include "critical.h" +#include +#include + +#define IMAGE_MAGIC 0xAEAE + +u32 wland_ota_partition_addr = 0; +u32 wland_ota_partition_len = 0; +u32 wland_crc_result = ~0UL; + +static u32 crc32(const u8 *p, u32 len, u32 crc) +{ + const u32 *crc32_tab = (const u32 *)CRC32_TABLE_ADDR; + + if (rda_ccfg_hwver() >= 4) { + crc32_tab = (const u32 *)CRC32_TABLE_ADDR_4; + } + /* Calculate CRC */ + while(len--) { + crc = crc32_tab[((crc & 0xFF) ^ *p++)] ^ (crc >> 8); + } + + return crc; +} + +static int rda5981_ota_erase_flash(u32 addr, u32 len) +{ + addr &= (flash_size -1); + rda5981_spi_erase_partition((void *)addr, len); + return 0; +} +//write without erase +static int rda5981_ota_write_flash(u32 addr, char *buf, u32 len) +{ + int ret = 0; + u8 *temp_buf = NULL, *temp_buf_aligned; + + addr &= (flash_size -1); + if ((u32)buf % 4) { + temp_buf = malloc(len + 3); + if (temp_buf == NULL) { + goto out; + } + if ((u32)temp_buf % 4) { + temp_buf_aligned = temp_buf + (4-(u32)temp_buf%4); + } else { + temp_buf_aligned = temp_buf; + } + memcpy(temp_buf_aligned, (unsigned char *)buf, len); + } else { + temp_buf_aligned = (u8 *)buf; + } + core_util_critical_section_enter(); + RDA5991H_WRITE_FLASH(addr, temp_buf_aligned, len); + core_util_critical_section_exit(); + +out: + if (temp_buf) { + free(temp_buf); + } + return ret; +} + +int rda5981_write_partition_start(u32 addr, u32 img_len) +{ + if (addr < 0x18001000 || addr+img_len>0x18000000+flash_size) { + WLAND_DBG(ERROR,"write partition start addr error. (0x%08x, %u)\r\n", addr, img_len); + return -1; + } + if (addr%0x1000 || img_len%0x1000) { + WLAND_DBG(ERROR,"write partition start length error.(mast be 4k alignment) (0x%08x, %u)\r\n", addr, img_len); + return -1; + } + + WLAND_DBG(INFO, "rda5981_write_partition_start:0x%08x, %u\r\n", addr, img_len); + wland_ota_partition_addr = addr; + wland_ota_partition_len = img_len; + wland_crc_result = ~0U; + + rda5981_ota_erase_flash(addr, img_len); + return 0; +} +int rda5981_write_partition(u32 offset, const u8 *buf, u32 len) +{ + if (wland_ota_partition_addr==0 || offset+len>wland_ota_partition_len) { + WLAND_DBG(ERROR,"write partition error. out of start addr(0x%08x, %u). (0x%08x, %u)\r\n", + wland_ota_partition_addr, wland_ota_partition_len, offset, len); + return -1; + } + if (len%0x400) { + WLAND_DBG(ERROR,"write partition length error.(mast be 1k alignment) (0x%08x, %u)\r\n", offset, len); + return -1; + } + WLAND_DBG(DEBUG, "rda5981_write_partition:0x%08x, %u.(%02x)\r\n", + wland_ota_partition_addr + offset, len, buf[0]); + wland_crc_result = crc32(buf, len, wland_crc_result); + + WLAND_DBG(DEBUG, "rda5981_write_partition: wland_crc_result 0x%08x\r\n", + wland_crc_result); + return rda5981_ota_write_flash(wland_ota_partition_addr + offset, (char *)buf, len); + //return rda5981_write_flash(wland_ota_partition_addr + offset, buf, len); +} +int rda5981_write_partition_end(void) +{ + WLAND_DBG(INFO, "check crc32:0x%08x, %u\r\n", wland_ota_partition_addr, wland_ota_partition_len); + if (wland_ota_partition_addr == 0) { + WLAND_DBG(ERROR,"OTA is not started\r\n"); + return -1; + } + core_util_critical_section_enter(); + spi_flash_flush_cache(); + //u32 crc32_check = crc32(wland_ota_partition_addr, wland_ota_partition_len, ~0U); + u32 crc32_check = bootrom_crc32((unsigned char *)wland_ota_partition_addr, wland_ota_partition_len); + core_util_critical_section_exit(); + WLAND_DBG(INFO, "rda5981_write_partition_end:0x%08x:0x%08x\r\n", wland_crc_result, crc32_check); + wland_ota_partition_addr = 0UL; + + if (crc32_check == wland_crc_result) { + return 0; + } else { + WLAND_DBG(ERROR,"check crc32 error\r\n"); + return -1; + } +} diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/rda5981x_emac.cpp b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/rda5981x_emac.cpp new file mode 100644 index 0000000000..9305f0daeb --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/rda5981x_emac.cpp @@ -0,0 +1,293 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#include +#include "cmsis_os.h" +#include "mbed_interface.h" +#include "mbed_assert.h" +#include "mbed_shared_queues.h" +#include "netsocket/nsapi_types.h" +#include "lwip/arch.h" +#include "lwip/pbuf.h" +#include "rda5991h_wland.h" +#include "rda5981x_emac_config.h" +#include "rda5981x_emac.h" +#include "rda_sys_wrapper.h" +#include "maclib_task.h" + +#define RDA_HWADDR_SIZE (6) +#define RDA_ETH_MTU_SIZE 1500 +#define RDA_ETH_IF_NAME "st" + +#define RX_PRIORITY (osPriorityNormal) +#define TX_PRIORITY (osPriorityNormal) +#define PHY_PRIORITY (osPriorityNormal) + +extern void *packet_rx_queue; + +RDA5981x_EMAC::RDA5981x_EMAC() +{ +} + +/** + * This function should do the actual transmission of the packet. The packet is + * contained in the memory buffer chain that is passed to the function. + * + * @param buf the MAC packet to send (e.g. IP packet including MAC addresses and type) + * @return true if the packet could be sent + * false value if the packet couldn't be sent + * + * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to + * strange results. You might consider waiting for space in the DMA queue + * to become availale since the stack doesn't retry to send a packet + * dropped because of memory failure (except for the TCP timers). + */ +bool RDA5981x_EMAC::link_out(emac_mem_buf_t *buf) +{ + emac_mem_buf_t *q, *p = buf; + + u32_t actual_txlen = 0; + u8_t **data = NULL; + u16_t retry = 400; + + LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output enter, p:%08x\n", p)); + + while ((data == NULL) && (retry-- > 0)) { + data = (u8_t**)wland_get_databuf(); + osThreadYield(); + } + if (data == NULL) { + LWIP_DEBUGF(NETIF_DEBUG, ("rda91h_low_level_output, no PKT buf\r\n")); + memory_manager->free(buf); + return false; + } + + for (q = p; q != NULL; q = memory_manager->get_next(q)) { + /* Send the data from the pbuf to the interface, one pbuf at a + time. The size of the data in each pbuf is kept in the ->len + variable. */ + memcpy(&((*data)[actual_txlen+2]), memory_manager->get_ptr(q), memory_manager->get_len(q));//reserve wid header length + actual_txlen += memory_manager->get_len(q); + if (actual_txlen > 1514 || actual_txlen > memory_manager->get_total_len(p)) { + LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output err, actual_txlen:%d, tot_len%d\n", actual_txlen, memory_manager->get_total_len(p))); + memory_manager->free(buf); + return false; + } + } + + /* Signal rda5996 that packet should be sent */ + if (actual_txlen == memory_manager->get_total_len(p)) { + wland_txip_data((void*)data, actual_txlen, 0); + memory_manager->free(buf); + return true; + } + + LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output pkt len mismatch, actual_txlen:%d, tot_len%d\n", + actual_txlen, memory_manager->get_total_len(p))); + + memory_manager->free(buf); + return false; +} + +/** + * Should allocate a contiguous memory buffer and transfer the bytes of the incoming + * packet to the buffer. + * + * @param buf If a frame was received and the memory buffer allocation was successful, a memory + * buffer filled with the received packet (including MAC header) + * @return negative value when no more frames, + * zero when frame is received + */ +emac_mem_buf_t * RDA5981x_EMAC::low_level_input(u8_t *data, int len) +{ + emac_mem_buf_t *p, *q; + u16_t index = 0; + + LWIP_DEBUGF(NETIF_DEBUG, ("low_level_input enter, rxlen:%d\n", len)); + + /* Obtain the size of the packet and put it into the "len" + variable. */ + if (!len) { + return NULL; + } + + /* We allocate a pbuf chain of pbufs from the pool. */ + p = memory_manager->alloc_pool(len, 0); + if (p != NULL) { + /* We iterate over the pbuf chain until we have read the entire + * packet into the pbuf. */ + for (q = p; q != NULL; q = memory_manager->get_next(q)) { + /* Read enough bytes to fill this pbuf in the chain. The + * available data in the pbuf is given by the q->len + * variable. + * This does not necessarily have to be a memcpy, you can also preallocate + * pbufs for a DMA-enabled MAC and after receiving truncate it to the + * actually received size. In this case, ensure the tot_len member of the + * pbuf is the sum of the chained pbuf len members. + */ + /* load rx data from 96 to local mem_pool */ + memcpy(memory_manager->get_ptr(q), &data[index], memory_manager->get_len(q)); + index += memory_manager->get_len(q); + + if (index >= len) { + break; + } + } + + } else { + /* Drop this packet */ + LWIP_DEBUGF(NETIF_DEBUG, ("low_level_input pbuf_alloc fail, rxlen:%d\n", len)); + + return NULL; + } + return p; +} + + +/** \brief Attempt to read a packet from the EMAC interface. + * + */ +void RDA5981x_EMAC::packet_rx() +{ + rda_msg msg; + packet_rx_queue = rda_mail_create(10, sizeof(unsigned int)*4); + /* move received packet into a new buf */ + while (1) { + emac_mem_buf_t *p = NULL; + rda_mail_get(packet_rx_queue, (void*)&msg, osWaitForever); + switch(msg.type) { + case 0: + p = low_level_input((unsigned char*)msg.arg1, msg.arg2); + if (p == NULL) { + rda_sem_release((void*)msg.arg3); + break; + } + rda_sem_release((void*)msg.arg3); + if (p) { + emac_link_input_cb(p); + } + break; + case 1: + emac_link_state_cb(msg.arg1); + break; + default: + break; + } + } +} + +void RDA5981x_EMAC::thread_function(void *pvParameters) +{ + static struct RDA5981x_EMAC *rda5981x_enet = static_cast(pvParameters); + rda5981x_enet->packet_rx(); +} + +bool RDA5981x_EMAC::power_up() +{ + /* Initialize the hardware */ + static int init_flag = 0; + if (init_flag == 0) { + wland_reg_func(); + rda_thread_new("maclib_thread", maclib_task, NULL, DEFAULT_THREAD_STACKSIZE*8, PHY_PRIORITY); + rda_thread_new("wland_thread", wland_task, NULL, DEFAULT_THREAD_STACKSIZE*5, PHY_PRIORITY); + rda_thread_new("packet_rx", RDA5981x_EMAC::thread_function, this, DEFAULT_THREAD_STACKSIZE*5, PHY_PRIORITY); + /* Allow the PHY task to detect the initial link state and set up the proper flags */ + osDelay(100); + wland_sta_init(); + init_flag = 1; + } + + return true; +} + +uint32_t RDA5981x_EMAC::get_mtu_size() const +{ + return RDA_ETH_MTU_SIZE; +} + +uint32_t RDA5981x_EMAC::get_align_preference() const +{ + return 0; +} + +void RDA5981x_EMAC::get_ifname(char *name, uint8_t size) const +{ + memcpy(name, RDA_ETH_IF_NAME, (size < sizeof(RDA_ETH_IF_NAME)) ? size : sizeof(RDA_ETH_IF_NAME)); +} + +uint8_t RDA5981x_EMAC::get_hwaddr_size() const +{ + return RDA_HWADDR_SIZE; +} + +bool RDA5981x_EMAC::get_hwaddr(uint8_t *addr) const +{ + mbed_mac_address((char *)addr); + return true; +} + +void RDA5981x_EMAC::set_hwaddr(const uint8_t *addr) +{ + /* No-op at this stage */ +} + +void RDA5981x_EMAC::set_link_input_cb(emac_link_input_cb_t input_cb) +{ + emac_link_input_cb = input_cb; +} + +void RDA5981x_EMAC::set_link_state_cb(emac_link_state_change_cb_t state_cb) +{ + emac_link_state_cb = state_cb; +} + +void RDA5981x_EMAC::add_multicast_group(const uint8_t *addr) +{ + /* No-op at this stage */ +} + +void RDA5981x_EMAC::remove_multicast_group(const uint8_t *addr) +{ + /* No-op at this stage */ +} + +void RDA5981x_EMAC::set_all_multicast(bool all) +{ + /* No-op at this stage */ +} + +void RDA5981x_EMAC::power_down() +{ + /* No-op at this stage */ +} + +void RDA5981x_EMAC::set_memory_manager(EMACMemoryManager &mem_mngr) +{ + memory_manager = &mem_mngr; +} + +RDA5981x_EMAC &RDA5981x_EMAC::get_instance() +{ + static RDA5981x_EMAC emac; + return emac; +} + +// Weak so a module can override +MBED_WEAK EMAC &EMAC::get_default_instance() +{ + return RDA5981x_EMAC::get_instance(); +} + diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/rda5981x_emac.h b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/rda5981x_emac.h new file mode 100644 index 0000000000..62fda7374d --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/rda5981x_emac.h @@ -0,0 +1,161 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#ifndef STM32_EMAC_H_ +#define STM32_EMAC_H_ + +#include "EMAC.h" +#include "rtos/Semaphore.h" +#include "rtos/Mutex.h" + +class RDA5981x_EMAC : public EMAC { +public: + RDA5981x_EMAC(); + + static RDA5981x_EMAC &get_instance(); + + /** + * Return maximum transmission unit + * + * @return MTU in bytes + */ + virtual uint32_t get_mtu_size() const; + + /** + * Gets memory buffer alignment preference + * + * Gets preferred memory buffer alignment of the Emac device. IP stack may or may not + * align link out memory buffer chains using the alignment. + * + * @return Memory alignment requirement in bytes + */ + virtual uint32_t get_align_preference() const; + + /** + * Return interface name + * + * @param name Pointer to where the name should be written + * @param size Maximum number of character to copy + */ + virtual void get_ifname(char *name, uint8_t size) const; + + /** + * Returns size of the underlying interface HW address size. + * + * @return HW address size in bytes + */ + virtual uint8_t get_hwaddr_size() const; + + /** + * Return interface-supplied HW address + * + * Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size + * + * HW address need not be provided if this interface does not have its own HW + * address configuration; stack will choose address from central system + * configuration if the function returns false and does not write to addr. + * + * @param addr HW address for underlying interface + * @return true if HW address is available + */ + virtual bool get_hwaddr(uint8_t *addr) const; + + /** + * Set HW address for interface + * + * Provided address has to be of correct size, see @a get_hwaddr_size + * + * Called to set the MAC address to actually use - if @a get_hwaddr is provided + * the stack would normally use that, but it could be overridden, eg for test + * purposes. + * + * @param addr Address to be set + */ + virtual void set_hwaddr(const uint8_t *addr); + + /** + * Sends the packet over the link + * + * That can not be called from an interrupt context. + * + * @param buf Packet to be send + * @return True if the packet was send successfully, False otherwise + */ + virtual bool link_out(emac_mem_buf_t *buf); + + /** + * Initializes the HW + * + * @return True on success, False in case of an error. + */ + virtual bool power_up(); + + /** + * Deinitializes the HW + * + */ + virtual void power_down(); + + /** + * Sets a callback that needs to be called for packets received for that interface + * + * @param input_cb Function to be register as a callback + */ + virtual void set_link_input_cb(emac_link_input_cb_t input_cb); + + /** + * Sets a callback that needs to be called on link status changes for given interface + * + * @param state_cb Function to be register as a callback + */ + virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb); + + /** Add device to a multicast group + * + * @param address A multicast group hardware address + */ + virtual void add_multicast_group(const uint8_t *address); + + /** Remove device from a multicast group + * + * @param address A multicast group hardware address + */ + virtual void remove_multicast_group(const uint8_t *address); + + /** Request reception of all multicast packets + * + * @param all True to receive all multicasts + * False to receive only multicasts addressed to specified groups + */ + virtual void set_all_multicast(bool all); + + /** Sets memory manager that is used to handle memory buffers + * + * @param mem_mngr Pointer to memory manager + */ + virtual void set_memory_manager(EMACMemoryManager &mem_mngr); + +private: + void packet_rx(); + emac_mem_buf_t * low_level_input(u8_t *data, int len); + static void thread_function(void *pvParameters); + emac_link_input_cb_t emac_link_input_cb; /**< Callback for incoming data */ + emac_link_state_change_cb_t emac_link_state_cb; /**< Link state change callback */ + EMACMemoryManager *memory_manager; /**< Memory manager */ + +}; + +#endif /* K64F_EMAC_H_ */ diff --git a/features/netsocket/emac-drivers/TARGET_RDA_EMAC/rda5981x_emac_config.h b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/rda5981x_emac_config.h new file mode 100644 index 0000000000..717d423bfe --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_RDA_EMAC/rda5981x_emac_config.h @@ -0,0 +1,22 @@ +/* Copyright (c) 2019 Unisoc Communications Inc. + * 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 + * + * 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. + */ + +#ifndef STM32XX_EMAC_CONFIG_H__ +#define STM32XX_EMAC_CONFIG_H__ + +#define THREAD_STACKSIZE 512 + +#endif // #define STM32XX_EMAC_CONFIG_H__ diff --git a/features/netsocket/emac-drivers/TARGET_STM_EMAC/mbed_lib.json b/features/netsocket/emac-drivers/TARGET_STM_EMAC/mbed_lib.json new file mode 100644 index 0000000000..39ae08e4a4 --- /dev/null +++ b/features/netsocket/emac-drivers/TARGET_STM_EMAC/mbed_lib.json @@ -0,0 +1,13 @@ +{ + "name": "stm32-emac", + "config": { + "eth-rxbufnb": 4, + "eth-txbufnb": 4 + }, + "target_overrides": { + "NUCLEO_F207ZG": { + "eth-rxbufnb": 1, + "eth-txbufnb": 4 + } + } +} diff --git a/features/nfc/nfc/NFCController.h b/features/nfc/nfc/NFCController.h index fffb5e1ab2..df55292f13 100644 --- a/features/nfc/nfc/NFCController.h +++ b/features/nfc/nfc/NFCController.h @@ -31,15 +31,14 @@ namespace mbed { namespace nfc { +/** @addtogroup nfc + * @{ + */ + class NFCRemoteInitiator; class NFCRemoteTarget; class NFCControllerDriver; -/** - * @addtogroup nfc - * @{ - */ - /** * This class represents a NFC Controller. * @@ -178,11 +177,7 @@ private: bool _discovery_running; Span _ndef_buffer; }; - -/** - * @} - */ - +/** @}*/ } // namespace nfc } // namespace mbed diff --git a/features/nfc/nfc/NFCEEPROM.h b/features/nfc/nfc/NFCEEPROM.h index 1e940c745a..ed0deb301d 100644 --- a/features/nfc/nfc/NFCEEPROM.h +++ b/features/nfc/nfc/NFCEEPROM.h @@ -27,8 +27,7 @@ namespace mbed { namespace nfc { -/** - * @addtogroup nfc +/** @addtogroup nfc * @{ */ @@ -153,12 +152,7 @@ private: uint32_t _eeprom_address; nfc_err_t _operation_result; }; - -/** - * @} - */ - - +/** @}*/ } // namespace nfc } // namespace mbed diff --git a/features/nfc/nfc/ndef/MessageBuilder.h b/features/nfc/nfc/ndef/MessageBuilder.h index 0b2437108e..1b4e38e0d4 100644 --- a/features/nfc/nfc/ndef/MessageBuilder.h +++ b/features/nfc/nfc/ndef/MessageBuilder.h @@ -27,8 +27,7 @@ namespace mbed { namespace nfc { namespace ndef { -/** - * @addtogroup nfc +/** @addtogroup nfc * @{ */ @@ -189,11 +188,7 @@ private: bool _message_ended; bool _in_chunk; }; - -/** - * @} - */ - +/** @}*/ } // namespace ndef } // namespace nfc } // namespace mbed diff --git a/features/nfc/nfc/ndef/MessageParser.h b/features/nfc/nfc/ndef/MessageParser.h index 41c4a9e3a3..a0ac9391ed 100644 --- a/features/nfc/nfc/ndef/MessageParser.h +++ b/features/nfc/nfc/ndef/MessageParser.h @@ -18,19 +18,16 @@ #define NFC_NDEF_MESSAGEPARSER_H_ #include - #include "platform/Span.h" namespace mbed { namespace nfc { namespace ndef { -/** - * @addtogroup nfc +/** @addtogroup nfc * @{ */ - // Forward declaration class Record; @@ -165,11 +162,7 @@ private: Delegate *_delegate; }; - -/** - * @} - */ - +/** @}*/ } // namespace ndef } // namespace nfc } // namespace mbed diff --git a/features/nfc/nfc/ndef/common/SimpleMessageParser.h b/features/nfc/nfc/ndef/common/SimpleMessageParser.h index a4da0049f9..2f7bbbc274 100644 --- a/features/nfc/nfc/ndef/common/SimpleMessageParser.h +++ b/features/nfc/nfc/ndef/common/SimpleMessageParser.h @@ -30,8 +30,7 @@ namespace nfc { namespace ndef { namespace common { -/** - * @addtogroup nfc +/** @addtogroup nfc * @{ */ @@ -161,14 +160,11 @@ private: MimeParser _mime_parser; Delegate *_delegate; }; - -/** - * @} - */ - +/** @}*/ } // namespace common } // namespace ndef } // namespace nfc } // namespace mbed #endif /* NFC_COMMON_SIMPLEMESSAGEPARSER_H_ */ + diff --git a/features/storage/TESTS/blockdevice/general_block_device/main.cpp b/features/storage/TESTS/blockdevice/general_block_device/main.cpp index 5e47ad8b0e..fecfe1a0db 100644 --- a/features/storage/TESTS/blockdevice/general_block_device/main.cpp +++ b/features/storage/TESTS/blockdevice/general_block_device/main.cpp @@ -187,6 +187,11 @@ void basic_erase_program_read_test(BlockDevice *block_device, bd_size_t block_si { int err = 0; _mutex->lock(); + + // Make sure block address per each test is unique + static unsigned block_seed = 1; + srand(block_seed++); + // Find a random block bd_addr_t block = (rand() * block_size) % (block_device->size()); diff --git a/platform/mbed_board.c b/platform/mbed_board.c index 4b3844e2a4..9982182940 100644 --- a/platform/mbed_board.c +++ b/platform/mbed_board.c @@ -15,6 +15,7 @@ * limitations under the License. */ #include +#include #include "hal/gpio_api.h" #include "platform/mbed_wait_api.h" #include "platform/mbed_toolchain.h" diff --git a/platform/mbed_error.c b/platform/mbed_error.c index c1ee19d6fd..b34dfb23d7 100644 --- a/platform/mbed_error.c +++ b/platform/mbed_error.c @@ -49,15 +49,14 @@ static core_util_atomic_flag halt_in_progress = CORE_UTIL_ATOMIC_FLAG_INIT; static int error_count = 0; static mbed_error_ctx first_error_ctx = {0}; +static mbed_error_ctx last_error_ctx = {0}; +static mbed_error_hook_t error_hook = NULL; +static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsigned int error_value, const char *filename, int line_number, void *caller); + #if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED //Global for populating the context in exception handler static mbed_error_ctx *const report_error_ctx = (mbed_error_ctx *)(ERROR_CONTEXT_LOCATION); static bool is_reboot_error_valid = false; -#endif - -static mbed_error_ctx last_error_ctx = {0}; -static mbed_error_hook_t error_hook = NULL; -static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsigned int error_value, const char *filename, int line_number, void *caller); //Helper function to calculate CRC //NOTE: It would have been better to use MbedCRC implementation. But @@ -88,6 +87,7 @@ static unsigned int compute_crc32(const void *data, int datalen) return crc; } +#endif //Helper function to halt the system static MBED_NORETURN void mbed_halt_system(void) diff --git a/platform/mbed_sleep_manager.c b/platform/mbed_sleep_manager.c index c1d4c9b510..c792c783de 100644 --- a/platform/mbed_sleep_manager.c +++ b/platform/mbed_sleep_manager.c @@ -73,11 +73,14 @@ us_timestamp_t mbed_time_deepsleep(void) #ifdef MBED_SLEEP_TRACING_ENABLED +// Length of the identifier extracted from the driver name to store for logging. +#define IDENTIFIER_WIDTH 15 + // Number of drivers that can be stored in the structure #define STATISTIC_COUNT 10 typedef struct sleep_statistic { - const char *identifier; + char identifier[IDENTIFIER_WIDTH]; uint8_t count; } sleep_statistic_t; @@ -85,8 +88,13 @@ static sleep_statistic_t sleep_stats[STATISTIC_COUNT]; static sleep_statistic_t *sleep_tracker_find(const char *const filename) { + char temp[IDENTIFIER_WIDTH]; + strncpy(temp, filename, IDENTIFIER_WIDTH); + temp[IDENTIFIER_WIDTH - 1] = '\0'; + + // Search for the a driver matching the current name and return it's index for (int i = 0; i < STATISTIC_COUNT; ++i) { - if (sleep_stats[i].identifier == filename) { + if (strcmp(sleep_stats[i].identifier, temp) == 0) { return &sleep_stats[i]; } } @@ -96,9 +104,15 @@ static sleep_statistic_t *sleep_tracker_find(const char *const filename) static sleep_statistic_t *sleep_tracker_add(const char *const filename) { + char temp[IDENTIFIER_WIDTH]; + strncpy(temp, filename, IDENTIFIER_WIDTH); + temp[IDENTIFIER_WIDTH - 1] = '\0'; + for (int i = 0; i < STATISTIC_COUNT; ++i) { - if (sleep_stats[i].identifier == NULL) { - sleep_stats[i].identifier = filename; + if (sleep_stats[i].identifier[0] == '\0') { + core_util_critical_section_enter(); + strncpy(sleep_stats[i].identifier, temp, sizeof(temp)); + core_util_critical_section_exit(); return &sleep_stats[i]; } @@ -117,7 +131,7 @@ static void sleep_tracker_print_stats(void) continue; } - if (sleep_stats[i].identifier == NULL) { + if (sleep_stats[i].identifier[0] == '\0') { return; } diff --git a/requirements.txt b/requirements.txt index f6459351c0..de08793b17 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,5 +20,4 @@ beautifulsoup4>=4,<=4.6.3 fuzzywuzzy>=0.11,<=0.17 pyelftools>=0.24,<=0.25 git+https://github.com/armmbed/manifest-tool.git@v1.4.6 -pyocd>=0.14,<0.15 -icetea>=1.0.2,<1.1 +icetea>=1.2.1,<1.3 diff --git a/rtos/EventFlags.cpp b/rtos/EventFlags.cpp index 3d6b79321f..faa3057e3b 100644 --- a/rtos/EventFlags.cpp +++ b/rtos/EventFlags.cpp @@ -62,14 +62,14 @@ uint32_t EventFlags::get() const return osEventFlagsGet(_id); } -uint32_t EventFlags::wait_all(uint32_t flags, uint32_t timeout, bool clear) +uint32_t EventFlags::wait_all(uint32_t flags, uint32_t millisec, bool clear) { - return wait(flags, osFlagsWaitAll, timeout, clear); + return wait(flags, osFlagsWaitAll, millisec, clear); } -uint32_t EventFlags::wait_any(uint32_t flags, uint32_t timeout, bool clear) +uint32_t EventFlags::wait_any(uint32_t flags, uint32_t millisec, bool clear) { - return wait(flags, osFlagsWaitAny, timeout, clear); + return wait(flags, osFlagsWaitAny, millisec, clear); } EventFlags::~EventFlags() @@ -77,13 +77,13 @@ EventFlags::~EventFlags() osEventFlagsDelete(_id); } -uint32_t EventFlags::wait(uint32_t flags, uint32_t opt, uint32_t timeout, bool clear) +uint32_t EventFlags::wait(uint32_t flags, uint32_t opt, uint32_t millisec, bool clear) { if (clear == false) { opt |= osFlagsNoClear; } - return osEventFlagsWait(_id, flags, opt, timeout); + return osEventFlagsWait(_id, flags, opt, millisec); } } diff --git a/rtos/EventFlags.h b/rtos/EventFlags.h index a448807459..bac58ea588 100644 --- a/rtos/EventFlags.h +++ b/rtos/EventFlags.h @@ -87,23 +87,23 @@ public: /** Wait for all of the specified event flags to become signaled. @param flags the flags to wait for (default: 0 -- no flags). - @param timeout timeout value or 0 in case of no time-out (default: osWaitForever). + @param millisec timeout value (default: osWaitForever). @param clear clear specified event flags after waiting for them (default: true). @return event flags before clearing or error code if highest bit set (see @a osFlagsError for details). - @note You may call this function from ISR context if the timeout parameter is set to 0. + @note You may call this function from ISR context if the millisec parameter is set to 0. */ - uint32_t wait_all(uint32_t flags = 0, uint32_t timeout = osWaitForever, bool clear = true); + uint32_t wait_all(uint32_t flags = 0, uint32_t millisec = osWaitForever, bool clear = true); /** Wait for any of the specified event flags to become signaled. @param flags the flags to wait for (default: 0 -- no flags). - @param timeout timeout value or 0 in case of no timeout (default: osWaitForever). + @param millisec timeout value (default: osWaitForever). @param clear clear specified event flags after waiting for them (default: true). @return event flags before clearing or error code if highest bit set (see @a osFlagsError for details). - @note This function may be called from ISR context if the timeout parameter is set to 0. + @note This function may be called from ISR context if the millisec parameter is set to 0. */ - uint32_t wait_any(uint32_t flags = 0, uint32_t timeout = osWaitForever, bool clear = true); + uint32_t wait_any(uint32_t flags = 0, uint32_t millisec = osWaitForever, bool clear = true); /** EventFlags destructor. @@ -113,7 +113,7 @@ public: private: void constructor(const char *name = NULL); - uint32_t wait(uint32_t flags, uint32_t opt, uint32_t timeout, bool clear); + uint32_t wait(uint32_t flags, uint32_t opt, uint32_t millisec, bool clear); osEventFlagsId_t _id; mbed_rtos_storage_event_flags_t _obj_mem; }; diff --git a/rtos/Mail.h b/rtos/Mail.h index 4f8cc7cac1..70f6380d98 100644 --- a/rtos/Mail.h +++ b/rtos/Mail.h @@ -131,7 +131,7 @@ public: /** Get a mail from the queue. * - * @param millisec Timeout value or 0 in case of no timeout (default: osWaitForever). + * @param millisec Timeout value (default: osWaitForever). * * @return Event that contains mail information or error code. * @retval osEventMessage Message received. diff --git a/rtos/Mutex.h b/rtos/Mutex.h index a364b1c8dc..a4955a54c6 100644 --- a/rtos/Mutex.h +++ b/rtos/Mutex.h @@ -95,7 +95,7 @@ public: @deprecated Do not use this function. This function has been replaced with lock(), trylock() and trylock_for() functions. - @param millisec timeout value or 0 in case of no time-out. + @param millisec timeout value. @return status code that indicates the execution status of the function: @a osOK the mutex has been obtained. @a osErrorTimeout the mutex could not be obtained in the given time. @@ -117,7 +117,7 @@ public: bool trylock(); /** Try to lock the mutex for a specified time - @param millisec timeout value or 0 in case of no time-out. + @param millisec timeout value. @return true if the mutex was acquired, false otherwise. @note the underlying RTOS may have a limit to the maximum wait time due to internal 32-bit computations, but this is guaranteed to work if the diff --git a/rtos/Queue.h b/rtos/Queue.h index d204a75696..ff258915bf 100644 --- a/rtos/Queue.h +++ b/rtos/Queue.h @@ -167,7 +167,7 @@ public: * share the same priority level, they are retrieved in first-in, first-out * (FIFO) order. * - * @param millisec Timeout value or 0 in case of no time-out. + * @param millisec Timeout value. * (default: osWaitForever). * * @return Event information that includes the message in event. Message diff --git a/rtos/Semaphore.h b/rtos/Semaphore.h index 0bcd788de9..49e0f1e833 100644 --- a/rtos/Semaphore.h +++ b/rtos/Semaphore.h @@ -60,7 +60,7 @@ public: Semaphore(int32_t count, uint16_t max_count); /** Wait until a Semaphore resource becomes available. - @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever). + @param millisec timeout value. (default: osWaitForever). @return number of available tokens, before taking one; or -1 in case of incorrect parameters @note You may call this function from ISR context if the millisec parameter is set to 0. diff --git a/rtos/ThisThread.h b/rtos/ThisThread.h index c0104fc1e0..ed12fd406c 100644 --- a/rtos/ThisThread.h +++ b/rtos/ThisThread.h @@ -105,7 +105,7 @@ uint32_t flags_wait_any(uint32_t flags, bool clear = true); /** Wait for all of the specified Thread Flags to become signaled for the current thread. @param flags specifies the flags to wait for - @param millisec timeout value or 0 in case of no time-out. + @param millisec timeout value. @param clear whether to clear the specified flags after waiting for them. (default: true) @return actual thread flags before clearing, which may not satisfy the wait @note You cannot call this function from ISR context. @@ -129,7 +129,7 @@ uint32_t flags_wait_all_until(uint32_t flags, uint64_t millisec, bool clear = tr /** Wait for any of the specified Thread Flags to become signaled for the current thread. @param flags specifies the flags to wait for - @param millisec timeout value or 0 in case of no time-out. + @param millisec timeout value. @param clear whether to clear the specified flags after waiting for them. (default: true) @return actual thread flags before clearing, which may not satisfy the wait @note You cannot call this function from ISR context. diff --git a/rtos/Thread.h b/rtos/Thread.h index 34933e8bc2..34da08aa24 100644 --- a/rtos/Thread.h +++ b/rtos/Thread.h @@ -414,7 +414,7 @@ public: /** Wait for one or more Thread Flags to become signaled for the current RUNNING thread. @param signals wait until all specified signal flags are set or 0 for any single signal flag. - @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever). + @param millisec timeout value. (default: osWaitForever). @return event flag information or error code. @note if @a millisec is set to 0 and flag is no set the event carries osOK value. @note You cannot call this function from ISR context. diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg.c index cf7ac0229a..74c28aba2c 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg.c @@ -30,5 +30,5 @@ void init_cycfg_all(void) init_cycfg_peripherals(); init_cycfg_pins(); init_cycfg_platform(); - init_cycfg_connectivity(); + init_cycfg_routing(); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg.h index 68bb40bf09..ac6033d2bd 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg.h @@ -34,7 +34,7 @@ extern "C" { #include "cycfg_peripherals.h" #include "cycfg_pins.h" #include "cycfg_platform.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" void init_cycfg_all(void); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_peripherals.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_peripherals.h index 558a12aade..d3b2015e80 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_peripherals.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_peripherals.h @@ -35,7 +35,7 @@ #include "cy_mcwdt.h" #include "cy_rtc.h" #include "cy_tcpwm_pwm.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #include "cy_usbfs_dev_drv.h" #if defined(__cplusplus) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_pins.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_pins.h index c2f019c59e..edfb6d7fce 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_pins.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_pins.h @@ -27,7 +27,7 @@ #include "cycfg_notices.h" #include "cy_gpio.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #if defined(__cplusplus) extern "C" { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_connectivity.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_routing.c similarity index 93% rename from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_connectivity.c rename to targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_routing.c index c389562da2..ae79008829 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_connectivity.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_routing.c @@ -1,5 +1,5 @@ /******************************************************************************* -* File Name: cycfg_connectivity.c +* File Name: cycfg_routing.c * * Description: * Establishes all necessary connections between hardware elements. @@ -22,11 +22,11 @@ * limitations under the License. ********************************************************************************/ -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #include "cy_device_headers.h" -void init_cycfg_connectivity(void) +void init_cycfg_routing(void) { HSIOM->AMUX_SPLIT_CTL[2] = HSIOM_V2_AMUX_SPLIT_CTL_SWITCH_AA_SL_Msk | HSIOM_V2_AMUX_SPLIT_CTL_SWITCH_AA_SR_Msk | diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_connectivity.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_routing.h similarity index 93% rename from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_connectivity.h rename to targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_routing.h index a8554f2843..76a886ce97 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_connectivity.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_4343W/GeneratedSource/cycfg_routing.h @@ -1,5 +1,5 @@ /******************************************************************************* -* File Name: cycfg_connectivity.h +* File Name: cycfg_routing.h * * Description: * Establishes all necessary connections between hardware elements. @@ -22,16 +22,16 @@ * limitations under the License. ********************************************************************************/ -#if !defined(CYCFG_CONNECTIVITY_H) -#define CYCFG_CONNECTIVITY_H +#if !defined(CYCFG_ROUTING_H) +#define CYCFG_ROUTING_H #if defined(__cplusplus) extern "C" { #endif #include "cycfg_notices.h" -void init_cycfg_connectivity(void); - +void init_cycfg_routing(void); +#define init_cycfg_connectivity() init_cycfg_routing() #define ioss_0_port_11_pin_1_HSIOM P11_1_TCPWM1_LINE_COMPL1 #define ioss_0_port_11_pin_2_HSIOM P11_2_SMIF_SPI_SELECT0 #define ioss_0_port_11_pin_3_HSIOM P11_3_SMIF_SPI_DATA3 @@ -73,4 +73,4 @@ void init_cycfg_connectivity(void); #endif -#endif /* CYCFG_CONNECTIVITY_H */ +#endif /* CYCFG_ROUTING_H */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg.c index cf7ac0229a..74c28aba2c 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg.c @@ -30,5 +30,5 @@ void init_cycfg_all(void) init_cycfg_peripherals(); init_cycfg_pins(); init_cycfg_platform(); - init_cycfg_connectivity(); + init_cycfg_routing(); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg.h index 68bb40bf09..ac6033d2bd 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg.h @@ -34,7 +34,7 @@ extern "C" { #include "cycfg_peripherals.h" #include "cycfg_pins.h" #include "cycfg_platform.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" void init_cycfg_all(void); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_pins.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_pins.h index 39f5ff9f5e..874eac99dc 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_pins.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_pins.h @@ -27,7 +27,7 @@ #include "cycfg_notices.h" #include "cy_gpio.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #if defined(__cplusplus) extern "C" { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_platform.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_platform.c index 9e81fbf418..9cd3f7692b 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_platform.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_platform.c @@ -119,7 +119,7 @@ __STATIC_INLINE void Cy_SysClk_IloInit() __STATIC_INLINE void Cy_SysClk_ClkLfInit() { /* The WDT is unlocked in the default startup code */ - Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_ILO); + Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_WCO); } __STATIC_INLINE void Cy_SysClk_ClkPath0Init() { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_platform.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_platform.h index 8db1d577b5..391f01a0be 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_platform.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_platform.h @@ -35,7 +35,7 @@ extern "C" { #endif -#define CY_CFG_SYSCLK_CLKLF_FREQ_HZ 32000 +#define CY_CFG_SYSCLK_CLKLF_FREQ_HZ 32768 #define CY_CFG_PWR_VDDA_MV 3300 #define CY_CFG_PWR_VDDD_MV 3300 #define CY_CFG_PWR_VBACKUP_MV 3300 diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_connectivity.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_routing.c similarity index 93% rename from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_connectivity.c rename to targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_routing.c index d4beee5fd1..a1dadb2d0b 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_connectivity.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_routing.c @@ -1,5 +1,5 @@ /******************************************************************************* -* File Name: cycfg_connectivity.c +* File Name: cycfg_routing.c * * Description: * Establishes all necessary connections between hardware elements. @@ -22,11 +22,11 @@ * limitations under the License. ********************************************************************************/ -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #include "cy_device_headers.h" -void init_cycfg_connectivity(void) +void init_cycfg_routing(void) { HSIOM->AMUX_SPLIT_CTL[2] = HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SL_Msk | HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SR_Msk | diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_connectivity.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_routing.h similarity index 70% rename from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_connectivity.h rename to targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_routing.h index ad5cb15c79..92fbc92d25 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_connectivity.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_BLE/GeneratedSource/cycfg_routing.h @@ -1,5 +1,5 @@ /******************************************************************************* -* File Name: cycfg_connectivity.h +* File Name: cycfg_routing.h * * Description: * Establishes all necessary connections between hardware elements. @@ -22,43 +22,43 @@ * limitations under the License. ********************************************************************************/ -#if !defined(CYCFG_CONNECTIVITY_H) -#define CYCFG_CONNECTIVITY_H +#if !defined(CYCFG_ROUTING_H) +#define CYCFG_ROUTING_H #if defined(__cplusplus) extern "C" { #endif #include "cycfg_notices.h" -void init_cycfg_connectivity(void); - +void init_cycfg_routing(void); +#define init_cycfg_connectivity() init_cycfg_routing() #define ioss_0_port_11_pin_2_HSIOM P11_2_SMIF_SPI_SELECT0 #define ioss_0_port_11_pin_3_HSIOM P11_3_SMIF_SPI_DATA3 #define ioss_0_port_11_pin_4_HSIOM P11_4_SMIF_SPI_DATA2 #define ioss_0_port_11_pin_5_HSIOM P11_5_SMIF_SPI_DATA1 #define ioss_0_port_11_pin_6_HSIOM P11_6_SMIF_SPI_DATA0 #define ioss_0_port_11_pin_7_HSIOM P11_7_SMIF_SPI_CLK -#define ioss_0_port_1_pin_0_HSIOM HSIOM_SEL_AMUXB +#define ioss_0_port_1_pin_0_HSIOM HSIOM_SEL_AMUXA #define ioss_0_port_5_pin_1_HSIOM P5_1_SCB5_UART_TX #define ioss_0_port_6_pin_0_HSIOM P6_0_SCB3_I2C_SCL #define ioss_0_port_6_pin_1_HSIOM P6_1_SCB3_I2C_SDA #define ioss_0_port_6_pin_4_HSIOM P6_4_CPUSS_SWJ_SWO_TDO #define ioss_0_port_6_pin_6_HSIOM P6_6_CPUSS_SWJ_SWDIO_TMS #define ioss_0_port_6_pin_7_HSIOM P6_7_CPUSS_SWJ_SWCLK_TCLK -#define ioss_0_port_7_pin_1_HSIOM HSIOM_SEL_AMUXB -#define ioss_0_port_7_pin_2_HSIOM HSIOM_SEL_AMUXB -#define ioss_0_port_7_pin_7_HSIOM HSIOM_SEL_AMUXB -#define ioss_0_port_8_pin_1_HSIOM HSIOM_SEL_AMUXB -#define ioss_0_port_8_pin_2_HSIOM HSIOM_SEL_AMUXB -#define ioss_0_port_8_pin_3_HSIOM HSIOM_SEL_AMUXB -#define ioss_0_port_8_pin_4_HSIOM HSIOM_SEL_AMUXB -#define ioss_0_port_8_pin_5_HSIOM HSIOM_SEL_AMUXB -#define ioss_0_port_8_pin_6_HSIOM HSIOM_SEL_AMUXB -#define ioss_0_port_8_pin_7_HSIOM HSIOM_SEL_AMUXB +#define ioss_0_port_7_pin_1_HSIOM HSIOM_SEL_AMUXA +#define ioss_0_port_7_pin_2_HSIOM HSIOM_SEL_AMUXA +#define ioss_0_port_7_pin_7_HSIOM HSIOM_SEL_AMUXA +#define ioss_0_port_8_pin_1_HSIOM HSIOM_SEL_AMUXA +#define ioss_0_port_8_pin_2_HSIOM HSIOM_SEL_AMUXA +#define ioss_0_port_8_pin_3_HSIOM HSIOM_SEL_AMUXA +#define ioss_0_port_8_pin_4_HSIOM HSIOM_SEL_AMUXA +#define ioss_0_port_8_pin_5_HSIOM HSIOM_SEL_AMUXA +#define ioss_0_port_8_pin_6_HSIOM HSIOM_SEL_AMUXA +#define ioss_0_port_8_pin_7_HSIOM HSIOM_SEL_AMUXA #if defined(__cplusplus) } #endif -#endif /* CYCFG_CONNECTIVITY_H */ +#endif /* CYCFG_ROUTING_H */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg.c index cf7ac0229a..74c28aba2c 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg.c @@ -30,5 +30,5 @@ void init_cycfg_all(void) init_cycfg_peripherals(); init_cycfg_pins(); init_cycfg_platform(); - init_cycfg_connectivity(); + init_cycfg_routing(); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg.h index faa061e3c2..1709481df2 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg.h @@ -35,7 +35,7 @@ extern "C" { #include "cycfg_peripherals.h" #include "cycfg_pins.h" #include "cycfg_platform.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" void init_cycfg_all(void); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_peripherals.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_peripherals.h index 2170ac28c6..beadadac39 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_peripherals.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_peripherals.h @@ -34,7 +34,7 @@ #include "cy_mcwdt.h" #include "cy_rtc.h" #include "cy_tcpwm_pwm.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #include "cy_usbfs_dev_drv.h" #if defined(__cplusplus) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_pins.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_pins.h index 776325ec01..7496d6069e 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_pins.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_pins.h @@ -27,7 +27,7 @@ #include "cycfg_notices.h" #include "cy_gpio.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #if defined(__cplusplus) extern "C" { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_platform.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_platform.c index 8f247b0267..306a16a389 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_platform.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_platform.c @@ -152,7 +152,7 @@ __STATIC_INLINE void Cy_SysClk_IloInit() __STATIC_INLINE void Cy_SysClk_ClkLfInit() { /* The WDT is unlocked in the default startup code */ - Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_ILO); + Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_WCO); } __STATIC_INLINE void Cy_SysClk_ClkPath0Init() { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_platform.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_platform.h index 4feda6f95f..76dfbef7bc 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_platform.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_platform.h @@ -35,7 +35,7 @@ extern "C" { #endif -#define CY_CFG_SYSCLK_CLKLF_FREQ_HZ 32000 +#define CY_CFG_SYSCLK_CLKLF_FREQ_HZ 32768 #define CY_CFG_PWR_VDDA_MV 3300 #define CY_CFG_PWR_VDDD_MV 3300 #define CY_CFG_PWR_VBACKUP_MV 3300 diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_connectivity.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_routing.c similarity index 86% rename from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_connectivity.c rename to targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_routing.c index 12ffa2a389..8a1e655157 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_connectivity.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_routing.c @@ -1,5 +1,5 @@ /******************************************************************************* -* File Name: cycfg_connectivity.c +* File Name: cycfg_routing.c * * Description: * Establishes all necessary connections between hardware elements. @@ -22,7 +22,7 @@ * limitations under the License. ********************************************************************************/ -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #include "cy_trigmux.h" @@ -30,16 +30,16 @@ #include "cy_device_headers.h" -void init_cycfg_connectivity(void) +void init_cycfg_routing(void) { - Cy_TrigMux_Connect(TRIG0_IN_TR_GROUP14_OUTPUT0, TRIG0_OUT_CPUSS_DW0_TR_IN0, false, TRIGGER_TYPE_LEVEL); - Cy_TrigMux_Connect(TRIG0_IN_TR_GROUP14_OUTPUT3, TRIG0_OUT_CPUSS_DW0_TR_IN1, false, TRIGGER_TYPE_LEVEL); - Cy_TrigMux_Connect(TRIG14_IN_UDB_TR_UDB0, TRIG14_OUT_TR_GROUP1_INPUT47, false, TRIGGER_TYPE_LEVEL); - Cy_TrigMux_Connect(TRIG14_IN_UDB_TR_UDB1, TRIG14_OUT_TR_GROUP0_INPUT46, false, TRIGGER_TYPE_LEVEL); - Cy_TrigMux_Connect(TRIG14_IN_UDB_TR_UDB3, TRIG14_OUT_TR_GROUP0_INPUT43, false, TRIGGER_TYPE_LEVEL); - Cy_TrigMux_Connect(TRIG14_IN_UDB_TR_UDB7, TRIG14_OUT_TR_GROUP1_INPUT49, false, TRIGGER_TYPE_LEVEL); - Cy_TrigMux_Connect(TRIG1_IN_TR_GROUP14_OUTPUT4, TRIG1_OUT_CPUSS_DW1_TR_IN1, false, TRIGGER_TYPE_LEVEL); - Cy_TrigMux_Connect(TRIG1_IN_TR_GROUP14_OUTPUT6, TRIG1_OUT_CPUSS_DW1_TR_IN3, false, TRIGGER_TYPE_LEVEL); + Cy_TrigMux_Connect(TRIG0_IN_TR_GROUP14_OUTPUT3, TRIG0_OUT_CPUSS_DW0_TR_IN0, false, TRIGGER_TYPE_LEVEL); + Cy_TrigMux_Connect(TRIG0_IN_TR_GROUP14_OUTPUT4, TRIG0_OUT_CPUSS_DW0_TR_IN1, false, TRIGGER_TYPE_LEVEL); + Cy_TrigMux_Connect(TRIG14_IN_UDB_TR_UDB0, TRIG14_OUT_TR_GROUP1_INPUT44, false, TRIGGER_TYPE_LEVEL); + Cy_TrigMux_Connect(TRIG14_IN_UDB_TR_UDB1, TRIG14_OUT_TR_GROUP0_INPUT47, false, TRIGGER_TYPE_LEVEL); + Cy_TrigMux_Connect(TRIG14_IN_UDB_TR_UDB3, TRIG14_OUT_TR_GROUP0_INPUT46, false, TRIGGER_TYPE_LEVEL); + Cy_TrigMux_Connect(TRIG14_IN_UDB_TR_UDB7, TRIG14_OUT_TR_GROUP1_INPUT43, false, TRIGGER_TYPE_LEVEL); + Cy_TrigMux_Connect(TRIG1_IN_TR_GROUP14_OUTPUT0, TRIG1_OUT_CPUSS_DW1_TR_IN3, false, TRIGGER_TYPE_LEVEL); + Cy_TrigMux_Connect(TRIG1_IN_TR_GROUP14_OUTPUT1, TRIG1_OUT_CPUSS_DW1_TR_IN1, false, TRIGGER_TYPE_LEVEL); HSIOM->AMUX_SPLIT_CTL[2] = HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SL_Msk | HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SR_Msk | HSIOM_AMUX_SPLIT_CTL_SWITCH_BB_SL_Msk | diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_connectivity.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_routing.h similarity index 88% rename from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_connectivity.h rename to targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_routing.h index cf3efa8aa3..9d9b019eae 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_connectivity.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/GeneratedSource/cycfg_routing.h @@ -1,5 +1,5 @@ /******************************************************************************* -* File Name: cycfg_connectivity.h +* File Name: cycfg_routing.h * * Description: * Establishes all necessary connections between hardware elements. @@ -22,16 +22,16 @@ * limitations under the License. ********************************************************************************/ -#if !defined(CYCFG_CONNECTIVITY_H) -#define CYCFG_CONNECTIVITY_H +#if !defined(CYCFG_ROUTING_H) +#define CYCFG_ROUTING_H #if defined(__cplusplus) extern "C" { #endif #include "cycfg_notices.h" -void init_cycfg_connectivity(void); - +void init_cycfg_routing(void); +#define init_cycfg_connectivity() init_cycfg_routing() #define ioss_0_port_11_pin_1_HSIOM P11_1_TCPWM1_LINE_COMPL1 #define ioss_0_port_11_pin_2_HSIOM P11_2_SMIF_SPI_SELECT0 #define ioss_0_port_11_pin_3_HSIOM P11_3_SMIF_SPI_DATA3 @@ -73,17 +73,17 @@ void init_cycfg_connectivity(void); #define cpuss_0_dw1_0_chan_1_tr_in_0_TRIGGER_OUT TRIG1_OUT_CPUSS_DW1_TR_IN1 #define cpuss_0_dw1_0_chan_3_tr_in_0_TRIGGER_OUT TRIG1_OUT_CPUSS_DW1_TR_IN3 #define udb_0_out_p_116_TRIGGER_IN_0 TRIG14_IN_UDB_TR_UDB0 -#define udb_0_out_p_116_TRIGGER_IN_1 TRIG1_IN_TR_GROUP14_OUTPUT4 -#define udb_0_out_p_117_TRIGGER_IN_0 TRIG0_IN_TR_GROUP14_OUTPUT3 +#define udb_0_out_p_116_TRIGGER_IN_1 TRIG1_IN_TR_GROUP14_OUTPUT1 +#define udb_0_out_p_117_TRIGGER_IN_0 TRIG0_IN_TR_GROUP14_OUTPUT4 #define udb_0_out_p_117_TRIGGER_IN_1 TRIG14_IN_UDB_TR_UDB1 -#define udb_0_out_p_119_TRIGGER_IN_0 TRIG0_IN_TR_GROUP14_OUTPUT0 +#define udb_0_out_p_119_TRIGGER_IN_0 TRIG0_IN_TR_GROUP14_OUTPUT3 #define udb_0_out_p_119_TRIGGER_IN_1 TRIG14_IN_UDB_TR_UDB3 #define udb_0_out_p_123_TRIGGER_IN_0 TRIG14_IN_UDB_TR_UDB7 -#define udb_0_out_p_123_TRIGGER_IN_1 TRIG1_IN_TR_GROUP14_OUTPUT6 +#define udb_0_out_p_123_TRIGGER_IN_1 TRIG1_IN_TR_GROUP14_OUTPUT0 #if defined(__cplusplus) } #endif -#endif /* CYCFG_CONNECTIVITY_H */ +#endif /* CYCFG_ROUTING_H */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg.c index cf7ac0229a..74c28aba2c 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg.c @@ -30,5 +30,5 @@ void init_cycfg_all(void) init_cycfg_peripherals(); init_cycfg_pins(); init_cycfg_platform(); - init_cycfg_connectivity(); + init_cycfg_routing(); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg.h index 68bb40bf09..ac6033d2bd 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg.h @@ -34,7 +34,7 @@ extern "C" { #include "cycfg_peripherals.h" #include "cycfg_pins.h" #include "cycfg_platform.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" void init_cycfg_all(void); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_peripherals.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_peripherals.h index 9ab7fdc86c..2a1bfa380e 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_peripherals.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_peripherals.h @@ -35,7 +35,7 @@ #include "cy_mcwdt.h" #include "cy_rtc.h" #include "cy_tcpwm_pwm.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #if defined(__cplusplus) extern "C" { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_pins.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_pins.h index b8b6546bfb..d0709a2adc 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_pins.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_pins.h @@ -27,7 +27,7 @@ #include "cycfg_notices.h" #include "cy_gpio.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #if defined(__cplusplus) extern "C" { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_platform.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_platform.c index 9c14fabc8c..f0edc010bc 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_platform.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_platform.c @@ -86,7 +86,7 @@ __WEAK void cycfg_ClockStartupError(uint32_t error) } __STATIC_INLINE void Cy_SysClk_ClkBakInit() { - Cy_SysClk_ClkBakSetSource(CY_SYSCLK_BAK_IN_CLKLF); + Cy_SysClk_ClkBakSetSource(CY_SYSCLK_BAK_IN_WCO); } __STATIC_INLINE void Cy_SysClk_ClkFastInit() { @@ -129,7 +129,7 @@ __STATIC_INLINE void Cy_SysClk_IloInit() __STATIC_INLINE void Cy_SysClk_ClkLfInit() { /* The WDT is unlocked in the default startup code */ - Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_ILO); + Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_WCO); } __STATIC_INLINE void Cy_SysClk_ClkPath0Init() { @@ -175,12 +175,7 @@ void init_cycfg_platform(void) /* Set worst case memory wait states (! ultra low power, 150 MHz), will update at the end */ Cy_SysLib_SetWaitStates(false, 150UL); #if (CY_CFG_PWR_VBAC_SUPPLY == CY_CFG_PWR_VBAC_SUPPLY_VDD) - if (0u == Cy_SysLib_GetResetReason() /* POR, XRES, or BOD */) - { - Cy_SysLib_ResetBackupDomain(); - Cy_SysClk_IloDisable(); - Cy_SysClk_IloInit(); - } + if (0u == Cy_SysLib_GetResetReason() /* POR, XRES, or BOD */){ Cy_SysLib_ResetBackupDomain(); } #endif #ifdef CY_CFG_PWR_ENABLED /* Configure power mode */ @@ -215,9 +210,6 @@ void init_cycfg_platform(void) Cy_SysClk_FllDisable(); Cy_SysClk_ClkPathSetSource(CY_SYSCLK_CLKHF_IN_CLKPATH0, CY_SYSCLK_CLKPATH_IN_IMO); Cy_SysClk_ClkHfSetSource(0UL, CY_SYSCLK_CLKHF_IN_CLKPATH0); - #ifdef CY_IP_MXBLESS - (void)Cy_BLE_EcoReset(); - #endif #ifdef CY_CFG_SYSCLK_PLL1_AVAILABLE (void)Cy_SysClk_PllDisable(CY_SYSCLK_CLKHF_IN_CLKPATH2); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_platform.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_platform.h index 9778631b74..aa4aeb6159 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_platform.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_platform.h @@ -34,7 +34,7 @@ extern "C" { #endif -#define CY_CFG_SYSCLK_CLKLF_FREQ_HZ 32000 +#define CY_CFG_SYSCLK_CLKLF_FREQ_HZ 32768 #define CY_CFG_PWR_VDDA_MV 3300 #define CY_CFG_PWR_VDDD_MV 3300 #define CY_CFG_PWR_VBACKUP_MV 3300 diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_connectivity.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_routing.c similarity index 93% rename from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_connectivity.c rename to targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_routing.c index c389562da2..ae79008829 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_connectivity.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_routing.c @@ -1,5 +1,5 @@ /******************************************************************************* -* File Name: cycfg_connectivity.c +* File Name: cycfg_routing.c * * Description: * Establishes all necessary connections between hardware elements. @@ -22,11 +22,11 @@ * limitations under the License. ********************************************************************************/ -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #include "cy_device_headers.h" -void init_cycfg_connectivity(void) +void init_cycfg_routing(void) { HSIOM->AMUX_SPLIT_CTL[2] = HSIOM_V2_AMUX_SPLIT_CTL_SWITCH_AA_SL_Msk | HSIOM_V2_AMUX_SPLIT_CTL_SWITCH_AA_SR_Msk | diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_connectivity.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_routing.h similarity index 93% rename from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_connectivity.h rename to targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_routing.h index ff31e17f1e..191672e599 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_connectivity.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CMOD_062_4343W/TARGET_CY8CPROTO_062_4343W/GeneratedSource/cycfg_routing.h @@ -1,5 +1,5 @@ /******************************************************************************* -* File Name: cycfg_connectivity.h +* File Name: cycfg_routing.h * * Description: * Establishes all necessary connections between hardware elements. @@ -22,16 +22,16 @@ * limitations under the License. ********************************************************************************/ -#if !defined(CYCFG_CONNECTIVITY_H) -#define CYCFG_CONNECTIVITY_H +#if !defined(CYCFG_ROUTING_H) +#define CYCFG_ROUTING_H #if defined(__cplusplus) extern "C" { #endif #include "cycfg_notices.h" -void init_cycfg_connectivity(void); - +void init_cycfg_routing(void); +#define init_cycfg_connectivity() init_cycfg_routing() #define ioss_0_port_11_pin_1_HSIOM P11_1_TCPWM0_LINE_COMPL1 #define ioss_0_port_11_pin_2_HSIOM P11_2_SMIF_SPI_SELECT0 #define ioss_0_port_11_pin_3_HSIOM P11_3_SMIF_SPI_DATA3 @@ -72,4 +72,4 @@ void init_cycfg_connectivity(void); #endif -#endif /* CYCFG_CONNECTIVITY_H */ +#endif /* CYCFG_ROUTING_H */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg.c index cf7ac0229a..74c28aba2c 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg.c @@ -30,5 +30,5 @@ void init_cycfg_all(void) init_cycfg_peripherals(); init_cycfg_pins(); init_cycfg_platform(); - init_cycfg_connectivity(); + init_cycfg_routing(); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg.h index faa061e3c2..1709481df2 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg.h @@ -35,7 +35,7 @@ extern "C" { #include "cycfg_peripherals.h" #include "cycfg_pins.h" #include "cycfg_platform.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" void init_cycfg_all(void); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_peripherals.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_peripherals.h index 6104f938c3..404b85be4a 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_peripherals.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_peripherals.h @@ -34,7 +34,7 @@ #include "cy_mcwdt.h" #include "cy_rtc.h" #include "cy_tcpwm_pwm.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #include "cy_usbfs_dev_drv.h" #if defined(__cplusplus) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_pins.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_pins.h index 68fce9d2dd..f5e0b37d47 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_pins.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_pins.h @@ -27,7 +27,7 @@ #include "cycfg_notices.h" #include "cy_gpio.h" -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #if defined(__cplusplus) extern "C" { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_platform.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_platform.c index 341b5d7da8..877af05d9c 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_platform.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_platform.c @@ -104,7 +104,7 @@ __STATIC_INLINE void Cy_SysClk_ClkAltSysTickInit() } __STATIC_INLINE void Cy_SysClk_ClkBakInit() { - Cy_SysClk_ClkBakSetSource(CY_SYSCLK_BAK_IN_CLKLF); + Cy_SysClk_ClkBakSetSource(CY_SYSCLK_BAK_IN_WCO); } __STATIC_INLINE void Cy_SysClk_EcoInit() { @@ -166,7 +166,7 @@ __STATIC_INLINE void Cy_SysClk_IloInit() __STATIC_INLINE void Cy_SysClk_ClkLfInit() { /* The WDT is unlocked in the default startup code */ - Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_ILO); + Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_WCO); } __STATIC_INLINE void Cy_SysClk_ClkPath0Init() { diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_platform.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_platform.h index 4feda6f95f..76dfbef7bc 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_platform.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_platform.h @@ -35,7 +35,7 @@ extern "C" { #endif -#define CY_CFG_SYSCLK_CLKLF_FREQ_HZ 32000 +#define CY_CFG_SYSCLK_CLKLF_FREQ_HZ 32768 #define CY_CFG_PWR_VDDA_MV 3300 #define CY_CFG_PWR_VDDD_MV 3300 #define CY_CFG_PWR_VBACKUP_MV 3300 diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_connectivity.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_routing.c similarity index 95% rename from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_connectivity.c rename to targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_routing.c index daf39a82a4..ce54f0f125 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_connectivity.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_routing.c @@ -1,5 +1,5 @@ /******************************************************************************* -* File Name: cycfg_connectivity.c +* File Name: cycfg_routing.c * * Description: * Establishes all necessary connections between hardware elements. @@ -22,7 +22,7 @@ * limitations under the License. ********************************************************************************/ -#include "cycfg_connectivity.h" +#include "cycfg_routing.h" #include "cy_trigmux.h" @@ -30,7 +30,7 @@ #include "cy_device_headers.h" -void init_cycfg_connectivity(void) +void init_cycfg_routing(void) { Cy_TrigMux_Connect(TRIG0_IN_TR_GROUP14_OUTPUT0, TRIG0_OUT_CPUSS_DW0_TR_IN0, false, TRIGGER_TYPE_LEVEL); Cy_TrigMux_Connect(TRIG0_IN_TR_GROUP14_OUTPUT5, TRIG0_OUT_CPUSS_DW0_TR_IN1, false, TRIGGER_TYPE_LEVEL); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_connectivity.h b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_routing.h similarity index 95% rename from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_connectivity.h rename to targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_routing.h index cc92c76813..8b3a102733 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_connectivity.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/GeneratedSource/cycfg_routing.h @@ -1,5 +1,5 @@ /******************************************************************************* -* File Name: cycfg_connectivity.h +* File Name: cycfg_routing.h * * Description: * Establishes all necessary connections between hardware elements. @@ -22,16 +22,16 @@ * limitations under the License. ********************************************************************************/ -#if !defined(CYCFG_CONNECTIVITY_H) -#define CYCFG_CONNECTIVITY_H +#if !defined(CYCFG_ROUTING_H) +#define CYCFG_ROUTING_H #if defined(__cplusplus) extern "C" { #endif #include "cycfg_notices.h" -void init_cycfg_connectivity(void); - +void init_cycfg_routing(void); +#define init_cycfg_connectivity() init_cycfg_routing() #define ioss_0_port_11_pin_2_HSIOM P11_2_SMIF_SPI_SELECT0 #define ioss_0_port_11_pin_3_HSIOM P11_3_SMIF_SPI_DATA3 #define ioss_0_port_11_pin_4_HSIOM P11_4_SMIF_SPI_DATA2 @@ -90,4 +90,4 @@ void init_cycfg_connectivity(void); #endif -#endif /* CYCFG_CONNECTIVITY_H */ +#endif /* CYCFG_ROUTING_H */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/analogin_api.c b/targets/TARGET_Cypress/TARGET_PSOC6/analogin_api.c index 9133e88d4c..93df2f04c6 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/analogin_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/analogin_api.c @@ -44,7 +44,7 @@ const uint32_t SAR_BASE_CLOCK_HZ = 18000000; // 18 MHz or less CY_SAR_CHAN_SAMPLE_TIME_0 \ ) -#define CY_SAR_PORT_9 (9uL) +#define CY_SAR_PORT_9 (9uL) /** Global SAR configuration data, modified as channels are configured. */ @@ -173,11 +173,10 @@ uint16_t analogin_read_u16(analogin_t *obj) if (CY_SAR_PORT_9 != port) { /* Connect the SAR Vplus input to the pin directly */ Cy_SAR_SetAnalogSwitch(obj->base, CY_SAR_MUX_SWITCH0, obj->channel_mask, CY_SAR_SWITCH_CLOSE); - } - else { + } else { /* Connect the SAR Vplus input to the AMUXA bus */ Cy_SAR_SetAnalogSwitch(obj->base, CY_SAR_MUX_SWITCH0, SAR_MUX_SWITCH0_MUX_FW_AMUXBUSA_VPLUS_Msk, CY_SAR_SWITCH_CLOSE); - + /* Connect the AMUXA bus to the pin */ Cy_GPIO_SetHSIOM(portPrt, CY_PIN(obj->pin), HSIOM_SEL_AMUXA); } @@ -188,15 +187,14 @@ uint16_t analogin_read_u16(analogin_t *obj) } else { error("ANALOG IN: measurement failed!"); } - + if (CY_SAR_PORT_9 != port) { /* Disconnect the SAR Vplus input from the pin */ Cy_SAR_SetAnalogSwitch(obj->base, CY_SAR_MUX_SWITCH0, obj->channel_mask, CY_SAR_SWITCH_OPEN); - } - else { + } else { /* Disconnect the AMUXA bus from the pin */ Cy_GPIO_SetHSIOM(portPrt, CY_PIN(obj->pin), HSIOM_SEL_GPIO); - + /* Disconnect the SAR Vplus input from the AMUXA bus */ Cy_SAR_SetAnalogSwitch(obj->base, CY_SAR_MUX_SWITCH0, SAR_MUX_SWITCH0_MUX_FW_AMUXBUSA_VPLUS_Msk, CY_SAR_SWITCH_OPEN); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/crc_api.c b/targets/TARGET_Cypress/TARGET_PSOC6/crc_api.c index 9b8fba9a26..0f713984ed 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/crc_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/crc_api.c @@ -26,11 +26,11 @@ #include "cy_crypto_core_crc.h" -static uint32_t crcWidth = 0; -static uint32_t crcShift = 0; +static uint32_t crcWidth = 0UL; +static uint32_t crcShift = 0UL; static uint32_t crcXorMask; -/* Cypress CRYPTO HW supports ANY CRC algorithms from CRC-3 to CRC-32 */ +/* Cypress CRYPTO hardware supports any CRC algorithms from CRC-3 to CRC-32 */ bool hal_crc_is_supported(const crc_mbed_config_t *config) { return (config != NULL); @@ -38,20 +38,19 @@ bool hal_crc_is_supported(const crc_mbed_config_t *config) void hal_crc_compute_partial_start(const crc_mbed_config_t *config) { - uint32_t myMask = 0; + uint32_t myMask = 0UL; - if (!hal_crc_is_supported(config) || (cy_reserve_crypto(CY_CRYPTO_CRC_HW) != 0)) - { + if (!hal_crc_is_supported(config) || (cy_reserve_crypto(CY_CRYPTO_CRC_HW) != 0U)) { return; } crcWidth = config->width; - crcShift = (uint32_t)(!config->reflect_out) * (crcWidth & 7u); - if (crcShift) { - crcShift = 8u - crcShift; - for (uint32_t i = 0; i < crcShift; i++) { - myMask |= 1 << i; + crcShift = (uint32_t)(!config->reflect_out) * (crcWidth & 7U); + if (0U != crcShift) { + crcShift = 8U - crcShift; + for (uint32_t i = 0U; i < crcShift; i++) { + myMask |= 1U << i; } crcXorMask = config->final_xor & myMask; } @@ -59,7 +58,7 @@ void hal_crc_compute_partial_start(const crc_mbed_config_t *config) Cy_Crypto_Core_Crc_CalcInit(CRYPTO, config->width, config->polynomial, config->reflect_in, - 0, + 0U, config->reflect_out, config->final_xor >> crcShift, config->initial_xor); @@ -67,7 +66,7 @@ void hal_crc_compute_partial_start(const crc_mbed_config_t *config) void hal_crc_compute_partial(const uint8_t *data, const size_t size) { - if ((data == NULL) || (size <= 0) || (crcWidth == 0)) { + if ((data == NULL) || (size <= 0U) || (crcWidth == 0U)) { return; } @@ -76,10 +75,10 @@ void hal_crc_compute_partial(const uint8_t *data, const size_t size) uint32_t hal_crc_get_result(void) { - uint32_t result = 0; + uint32_t result = 0UL; - if (crcWidth == 0) { - return 0xffffffffu; + if (crcWidth == 0UL) { + return 0xFFFFFFFFUL; } Cy_Crypto_Core_Crc_CalcFinish(CRYPTO, crcWidth, &result); @@ -89,7 +88,7 @@ uint32_t hal_crc_get_result(void) result = result ^ crcXorMask; } - crcWidth = 0; + crcWidth = 0UL; cy_free_crypto(CY_CRYPTO_CRC_HW); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/port_api.c b/targets/TARGET_Cypress/TARGET_PSOC6/port_api.c index b1d849fd9c..ddcc0bc5d5 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/port_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/port_api.c @@ -109,8 +109,8 @@ void port_write(port_t *obj, int value) for (pin = 0; pin < 8; ++pin) { if (obj->mask & (1 << pin)) { Cy_GPIO_Write(obj->port, pin, value & 0x1); - value >>= 1; } + value >>= 1; } } } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6_utils.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6_utils.c index dc88242ee3..84af989a07 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6_utils.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6_utils.c @@ -360,9 +360,9 @@ static uint8_t crypto_reservations[NUM_CRYPTO_HW] = { 0u }; static int cy_crypto_reserved_status(void) { return ((int)(crypto_reservations[CY_CRYPTO_TRNG_HW] | - crypto_reservations[CY_CRYPTO_CRC_HW] | - crypto_reservations[CY_CRYPTO_VU_HW] | - crypto_reservations[CY_CRYPTO_COMMON_HW])); + crypto_reservations[CY_CRYPTO_CRC_HW] | + crypto_reservations[CY_CRYPTO_VU_HW] | + crypto_reservations[CY_CRYPTO_COMMON_HW])); } @@ -370,26 +370,20 @@ int cy_reserve_crypto(cy_en_crypto_submodule_t module_num) { int result = (-1); - if (module_num < NUM_CRYPTO_HW) - { + if (module_num < NUM_CRYPTO_HW) { core_util_critical_section_enter(); - if (cy_crypto_reserved_status() == 0) - { + if (cy_crypto_reserved_status() == 0) { /* Enable Crypto IP on demand */ Cy_Crypto_Core_Enable(CRYPTO); } - if (module_num == CY_CRYPTO_COMMON_HW) - { - if (crypto_reservations[module_num] != 1) - { + if (module_num == CY_CRYPTO_COMMON_HW) { + if (crypto_reservations[module_num] != 1) { crypto_reservations[module_num] = 1; result = 0; } - } - else - { + } else { crypto_reservations[module_num] = 1; result = 0; } @@ -405,16 +399,13 @@ void cy_free_crypto(cy_en_crypto_submodule_t module_num) { int result = (-1); - if (module_num < NUM_CRYPTO_HW) - { + if (module_num < NUM_CRYPTO_HW) { core_util_critical_section_enter(); - if (crypto_reservations[module_num] == 1) - { + if (crypto_reservations[module_num] == 1) { crypto_reservations[module_num] = 0; - if (cy_crypto_reserved_status() == 0) - { + if (cy_crypto_reserved_status() == 0) { /* Crypto hardware is still in enabled state; to disable: Cy_Crypto_Core_Disable(CRYPTO) */ } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6_utils.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6_utils.h index b9adf938d9..452940542a 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6_utils.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6_utils.h @@ -215,8 +215,7 @@ static inline uint32_t gpio_get_cy_drive_mode(PinDirection dir, PinMode mode) return cymode; } -typedef enum -{ +typedef enum { CY_CRYPTO_TRNG_HW, CY_CRYPTO_CRC_HW, CY_CRYPTO_VU_HW, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_ble_clk.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_ble_clk.h index 8a2beb8903..47bd9b8793 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_ble_clk.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_ble_clk.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_ble_clk.h -* \version 3.0 +* \version 3.10 * * The header file of the BLE ECO clock driver. * @@ -70,7 +70,14 @@ * * * -* +* +* +* +* +* +* * * * diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto.h index 0ee2810f3f..af3a29cd77 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto.h @@ -26,18 +26,51 @@ * \addtogroup group_crypto * \{ * The Crypto driver provides a public API to perform cryptographic and hash -* operations, as well as generate both true and pseudo random numbers -* (TRNG, PRNG). +* operations, as well as generate both true and pseudo random numbers. * * It uses a hardware IP block to accelerate operations. * * The functions and other declarations used in this driver are in cy_crypto.h, -* cy_crypto_core.h, and cy_crypto_server.h. You can also include cy_pdl.h +* cy_crypto_core.h, and cy_crypto_server.h. You can also include cy_pdl.h * (ModusToolbox only) to get access to all functions and declarations in the PDL. * -* The driver -* supports these standards: DES, TDES, AES (128, 192, 256 bits), CMAC-AES, SHA, -* HMAC, PRNG, TRNG, CRC, and RSA. +* The driver implements two usage models: +* * \ref group_crypto_cli_srv +* * \ref group_crypto_lld_api +* +* Mixing these usage models will result in undefined behaviour. +* +* The Crypto driver supports these standards: DES, TDES, AES (128, 192, 256 bits), CMAC-AES, SHA, +* HMAC, PRNG, TRNG, CRC, RSA, ECP, and ECDSA. +* \note ECP and ECDSA are only implemented for the \ref group_crypto_lld_api model. +* +* \section group_crypto_configuration_considerations Configuration Considerations +* +* Firmware sets up a cryptographic operation by passing in the required data as +* parameters in the function calls. +* +* All Crypto functions require a context. A context is a data +* structure that the driver uses for its operations. Firmware declares a +* context (allocates memory) but does not write or read the values in that +* context. In effect, the context is a scratch pad you provide to the driver. +* The driver uses the context to store and manipulate data during cryptographic +* operations. +* +* Several methods require an additional context unique to the particular +* cryptographic technique. +* The Crypto driver header files declare all the required structures for both +* configuration and context. +* +* Some encryption techniques require additional initialization specific to the +* technique. If there is an Init function, you must call it before using any +* other function for that technique, and re-initialize after you use a different +* encryption technique. +* +* For example, use \ref Cy_Crypto_Aes_Init to configure an AES encryption +* operation with the encryption key, and key length. +* Provide pointers to two context structures. You can then call the AES Run functions. +* If you use DES after that, you must re-initialize the AES encryption before using +* it again. * * \section group_crypto_definitions Definitions * @@ -63,16 +96,16 @@ * This function takes a fixed-size key and a block of plaintext data from * the message and encrypts it to generate ciphertext. Block ciphers are * reversible. The function performed on a block of encrypted data will -* decrypt it. +* decrypt that data. * * * * -* * * @@ -80,8 +113,8 @@ * * * * @@ -89,7 +122,7 @@ * * @@ -99,17 +132,17 @@ * * * * * * -* * -* * For more information see [Recommendation for Block Cipher Modes of Operation] * (https://nvlpubs.nist.gov/nistpubs/specialpublications/nist.sp.800-38b.pdf). @@ -144,7 +177,7 @@ * * * -* * -* * * @@ -176,15 +209,15 @@ * * * -* * *
VersionChangesReason of Change
3.0.03.10Updated the Cy_BLE_EcoConfigure() use case, when the voltageReg parameter is CY_BLE_ECO_VOLTAGE_REG_BLESSLDO +* and the Buck core regulator is enabled.Defect fixing: Before, when the Cy_BLE_EcoConfigure() function included the BLE LDO regulator option, the function returned CY_BLE_ECO_HARDWARE_ERROR if +* the Buck core regulator had been enabled.
3.0The initial version. \n The functionality of the BLE ECO clock is migrated from the BLE Middleware to the separated driver (ble_clk).Independent usage of BLE ECO clock without BLE Middleware.
Block Cipher ModeA mode of encrypting a message using block ciphers for messages of +* A mode of encrypting a message using block ciphers for messages of an * arbitrary length. The message is padded so that its length is an integer * multiple of the block size. ECB (Electronic Code Book), CBC (Cipher Block * Chaining), and CFB (Cipher Feedback) are all modes of using block ciphers -* to create an encrypted message of arbitrary length. +* to create an encrypted message of an arbitrary length. *
Data Encryption Standard (DES)The [DES standard] * (https://csrc.nist.gov/csrc/media/publications/fips/46/3/archive/1999-10-25/documents/fips46-3.pdf) -* specifies a symmetric-key algorithm for the encryption of electronic data. -* It uses a 56-bit key and a 64-bit message block size. +* specifies a symmetric-key algorithm for encryption of electronic data. +* It uses a 56-bit key. The block size is 64-bits. *
Triple DES (3DES or TDES)The [TDES standard] * (https://csrc.nist.gov/csrc/media/publications/fips/46/3/archive/1999-10-25/documents/fips46-3.pdf) -* specifies a symmetric-key block cipher, which applies the Data Encryption +* specifies a symmetric-key block cipher that applies the Data Encryption * Standard (DES) cipher algorithm three times to each data block. * It uses three 56-bit keys. The block size is 64-bits. * Advanced Encryption Standard (AES)The [AES standard] (https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.197.pdf) * specifies the Rijndael algorithm, a symmetric block -* cipher that can process data blocks of 128 bits, using cipher keys with -* lengths of 128, 192, and 256 bits. Rijndael was designed to handle -* additional block sizes and key lengths, however they are not adopted in +* cipher that can process 128-bit data blocks, using cipher keys with +* 128-, 192-, and 256-bit lengths. Rijndael was designed to handle +* additional block sizes and key lengths. However, they are not adopted in * this standard. AES is also used for message authentication. *
Secure Hash Algorithm (SHA)Is a cryptographic hash function. -* This function takes a message of the arbitrary length and reduces it to a +* A cryptographic hash function. +* This function takes a message of an arbitrary length and reduces it to a * fixed-length residue or message digest after performing a series of * mathematically defined operations that practically guarantee that any * change in the message will change the hash value. It is used for message @@ -136,7 +169,7 @@ * *
Cipher-based Message Authentication Code (CMAC)This is a block cipher-based message authentication code algorithm. +* A block cipher-based message authentication code algorithm. * It computes the MAC value using the AES block cipher algorithm.
Hash Message Authentication Code (HMAC)Is a specific type of message authentication code (MAC) involving a +* A specific type of message authentication code (MAC) that involves a * cryptographic hash function and a secret cryptographic key. * It computes the MAC value using a Hash algorithm. * For more information see [The Keyed-Hash Message Authentication Code standard] @@ -154,7 +187,7 @@ * *
Pseudo Random Number Generator (PRNG)Is a Linear Feedback Shift Registers-based algorithm for generating a +* A Linear Feedback Shift Registers-based algorithm for generating a * sequence of numbers starting from a non-zero seed.
Asymmetric Key CryptographyAlso referred to as Public Key encryption. Someone who wishes to -* receive a message, publishes a very large public key (up to 4096 bits -* currently), which is one of two prime factors of a very large number. The -* other prime factor is the private key of the recipient and a secret. -* Someone wishing to send a message to the publisher of the public key -* encrypts the message with the public key. This message can now be -* decrypted only with the private key (the other prime factor held secret by +* Also referred to as Public Key encryption. To receive a message, +* you publish a very large public key (up to 4096 bits currently). +* That key is one of the two prime factors of a very large number. The +* other prime factor is the recipient's private (secret) key. +* To send a message to the publisher of the public key, you +* encrypt the message with the public key. This message can now be +* decrypted only with the private key (the other prime factor held in secret by * the recipient). The message is now sent over any channel to the recipient -* who can decrypt it with the private, secret, key. The same process is used +* who can decrypt it with the private (secret) key. The same process is used * to send messages to the sender of the original message. The asymmetric * cryptography relies on the mathematical impracticality (usually related to * the processing power available at any given time) of factoring the keys. @@ -192,7 +225,7 @@ * The public key is described by the pair (n, e) where n is a product of two * randomly chosen primes p and q. The exponent e is a random integer * 1 < e < Q where Q = (p-1) (q-1). The private key d is uniquely defined -* by the integer 1 < d < Q such that ed congruent to 1 (mod Q ). +* by the integer 1 < d < Q so that ed congruent with 1 (mod Q ). *
@@ -202,10 +235,51 @@ * RSASSA-PKCS1-v1_5 described here, page 31: * http://www.emc.com/collateral/white-papers/h11300-pkcs-1v2-2-rsa-cryptography-standard-wp.pdf * -* See the Cryptographic Function Block chapter of the Technical Reference Manual. +* See the "Cryptographic Function Block" chapter of the Technical Reference Manual. * * \section group_crypto_MISRA MISRA-C Compliance -* This driver does not contains any driver-specific MISRA violations. +* The Crypto driver has the following specific deviations: +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +*
MISRA RuleRule Class (Required/Advisory)Rule DescriptionDescription of Deviation(s)
8.8AAn external object or function shall be declared in one and only +* one file.The pointer to the operation context memory can not be public +* accessible (can not be defined in the header file) but it should be +* extarnally accessed, because it is used by other Cypress software +* resources.
11.4AA cast should not be performed between a pointer to object type and +* a different pointer to object type.The pointers to the context memory are void to allow handling of +* different data types for different operations. +* The cast operation is safe because the configuration is verified +* before operation is performed. +*
16.7AA pointer parameter in a function prototype should be declared as +* pointer to const if the pointer is not used to modify the addressed +* object.The objects pointed to by the base addresses of the CRYPTO are not +* always modified. While a const qualifier can be used in select +* scenarios, it brings little benefit in adding this to the affected +* functions.
* * \section group_crypto_changelog Changelog * @@ -214,15 +288,16 @@ * * * * * -* * * * * -* * * * * -* +* * * * @@ -267,7 +342,7 @@ * * * -* * @@ -278,7 +353,7 @@ * * * -* +* * * * @@ -289,15 +364,15 @@ * \ref Cy_Crypto_Trng_Generate, \ref Cy_Crypto_Des_Run, * \ref Cy_Crypto_Tdes_Run, \ref Cy_Crypto_Rsa_Proc * -* +* * * * -* +* * * * @@ -306,29 +381,24 @@ * *
2.20 *
    -*
  • Moved from pre-compiled library to Open Source under +*
  • Moved from a pre-compiled library to Open Source under * Apache 2.0 license.
  • -*
  • Added ECP and ECDSA support for NIST P curves: +*
  • Core (server) This API is now available.
  • +*
  • Added ECP and ECDSA support for the NIST P curves: * SECP192R1, SECP224R1, SECP256R1, SECP384R1, SECP521R1.
  • *
  • ECP and ECDSA only supported with direct calls to Crypto APIs, -* no client interface functions present.
  • -*
  • Added chunk mode for CRC.
  • -*
  • Added chunk mode for SHA, chunk size is limited to -* SHA block size.
  • +* no client interface functions are present. +*
  • Added Chunk mode for CRC.
  • +*
  • Added Chunk mode for SHA, the chunk size is limited to +* the SHA block size.
  • *
*
ECC support added.
@@ -232,22 +307,22 @@ *
2.11bSame as production 2.10; only newly added Elliptic Curve point +* The same as production 2.10; only the newly-added Elliptic Curve point * multiplication functionality (NIST P256) is pre-production. * Open source under Apache version 2.0 license.
2.11Based on pre-production 2.10, except newly added Elliptic Curve point +* Based on pre-production 2.10, except the newly-added Elliptic Curve point * multiplication functionality (NIST P256). -* Does not incorporate production level documentation. +* Does not incorporate the production level documentation. * Open source under Apache version 2.0 license.ECC support.
2.10bSame as production 2.10. Open source under Apache version 2.0 license.The same as production 2.10. Open source under Apache version 2.0 license.
Added register access layer. Use register access macros instead +* Added the register access layer. Use register access macros instead * of direct register access using dereferenced pointers.Makes register access device-independent, so that the PDL does * not need to be recompiled for each supported part number.
2.0bSame as production 2.0. Open source under Apache version 2.0 license.The same as production 2.0. Open source under Apache version 2.0 license.
Documentation update and clarificationDocumentation update and clarification.
-* Changed crypto IP power control
-* Enhanced Vector Unit functionality for RSA crypto algorithm
-* Added support of the single-core devices +* Changed crypto IP power control.
+* Enhanced Vector Unit functionality for RSA crypto algorithm.
+* Added support of the single-core devices. *
New device supportNew device support.
1.0
* -* \defgroup group_crypto_cli_srv Client-Server API +* \defgroup group_crypto_cli_srv Client-Server Model * \{ -* \defgroup group_crypto_client Client +* \defgroup group_crypto_cli_srv_macros Macros +* \defgroup group_crypto_cli_srv_functions Functions * \{ -* Client part of the Crypto. -* \defgroup group_crypto_macros Macros -* \defgroup group_crypto_cli_functions Functions -* \defgroup group_crypto_cli_data_structures Data Structures -* \defgroup group_crypto_enums Enumerated Types +* \defgroup group_crypto_cli_functions Client Functions +* \defgroup group_crypto_srv_functions Server Functions * \} -* \defgroup group_crypto_server Server +* \defgroup group_crypto_cli_srv_data_structures Data Structures * \{ -* Server part of the Crypto. -* \defgroup group_crypto_srv_functions Functions -* \defgroup group_crypto_srv_data_structures Data Structures -* \} -* \defgroup group_crypto_config_structure Configuration Structure -* \{ -* Crypto initialization configuration. -* \note Should be the same for Crypto Server and Crypto Client initializations. +* \defgroup group_crypto_config_structure Common Data Structures +* \defgroup group_crypto_cli_data_structures Client Data Structures +* \defgroup group_crypto_srv_data_structures Server Data Structures * \} * \} -* \defgroup group_crypto_lld_api Low-Level API +* \defgroup group_crypto_lld_api Direct Crypto Core Access +* \defgroup group_crypto_data_structures Common Data Structures +* \defgroup group_crypto_enums Common Enumerated Types */ /** @@ -339,23 +409,22 @@ * * The functions and other declarations used in this part of the driver are in * cy_crypto.h and cy_crypto_server.h. You can also include cy_pdl.h -* (ModusToolbox only) to get access to all functions and declarations in the +* (ModusToolbox only) to get access to all functions and declarations in the * PDL. * -* Firmware initializes and starts the Crypto server. The server can run on any +* The firmware initializes and starts the Crypto server. The server can run on any * core and works with the Crypto hardware. The Crypto server is implemented as * a secure block. It performs all cryptographic operations for the client. * Access to the server is through the Inter Process Communication (IPC) driver. * Direct access is not allowed. * -* The Crypto client can run on any core too. Firmware initializes and starts -* the client. The firmware then provides the configuration data required for -* the desired cryptographic technique, and requests that the server run the +* The Crypto client can run on any core too. The firmware initializes and starts +* the client. The firmware then provides configuration data required for +* the desired cryptographic technique and a request that the server run the * cryptographic operation. * * This document contains the following topics: * - \ref group_crypto_architecture -* - \ref group_crypto_configuration_considerations * - \ref group_crypto_configuration_structure * - \ref group_crypto_server_init * - \ref group_crypto_client_init @@ -396,23 +465,6 @@ * Using IPC for communication provides a simple synchronization mechanism to * handle concurrent requests from different cores. * -* \section group_crypto_configuration_considerations Configuration Considerations -* -* Firmware sets up a cryptographic operation by passing in required data as -* parameters in function calls. -* -* All Crypto functions require a context. A context is a data -* structure that the driver uses for its operations. Firmware declares the -* context (allocates memory) but does not write or read the values in the -* context. In effect the context is a scratch pad you provide to the driver. -* The driver uses the context to store and manipulate data during cryptographic -* operations. -* -* Several methods require an additional context unique to the particular -* cryptographic technique. -* The Crypto driver header files declare all the required structures for both -* configuration and context. -* * \section group_crypto_configuration_structure Configuration Structure * * IPC communication for the Crypto driver is handled transparently. User should @@ -527,17 +579,6 @@ * * \snippet crypto/2.10/snippet/main.c snippet_myCryptoInit * -* Some encryption techniques require additional initialization specific to the -* technique. If there is an Init function, you must call it before using any -* other function for that technique, and reinitialize after you use a different -* encryption technique. -* -* For example, use \ref Cy_Crypto_Aes_Init to configure an AES encryption -* operation with the encryption key, and key length. -* Provide pointers to two context structures. You can then call AES Run functions. -* If later on you use DES, you must re-initialize AES encryption before using -* it again. -* * \section group_crypto_common_use_cases Common Use Cases * * \subsection group_crypto_Use_CRC CRC Calculation @@ -667,9 +708,9 @@ * (2^moduloLength mod modulo). These fields are optional, and can be set to NULL. * * Calculate these coefficients with \ref Cy_Crypto_Rsa_CalcCoefs. -* Pass in the address of the key structure with the modulus and exponent values -* for the key. The function returns the coefficients for the key in the key -* structure, replacing any previous values. +* Pass them in the address of the key structure with the modulus and exponent +* values for the key. The function returns the coefficients for the key in the +* key structure, replacing any previous values. * * The RSA functionality also implements functions to decrypt a signature using * a public key. This signature must follow the RSASSA-PKCS-v1_5 standard. @@ -786,7 +827,7 @@ cy_en_crypto_status_t Cy_Crypto_GetLibraryInfo(cy_en_crypto_lib_info_t *cryptoIn * that stores the Crypto driver common context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoInit @@ -801,7 +842,7 @@ cy_en_crypto_status_t Cy_Crypto_Init(cy_stc_crypto_config_t const *config, cy_st * This function de-initializes the Crypto driver. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_DeInit(void); @@ -813,7 +854,7 @@ cy_en_crypto_status_t Cy_Crypto_DeInit(void); * This function enables (turns on) the Crypto hardware. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Enable(void); @@ -825,7 +866,7 @@ cy_en_crypto_status_t Cy_Crypto_Enable(void); * This function disables (turns off) the Crypto hardware. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Disable(void); @@ -843,7 +884,7 @@ cy_en_crypto_status_t Cy_Crypto_Disable(void); * False - is not blocking. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Sync(bool isBlocking); @@ -859,7 +900,7 @@ cy_en_crypto_status_t Cy_Crypto_Sync(bool isBlocking); * \ref cy_stc_crypto_hw_error_t. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_GetErrorStatus(cy_stc_crypto_hw_error_t *hwErrorCause); @@ -890,7 +931,7 @@ cy_en_crypto_status_t Cy_Crypto_GetErrorStatus(cy_stc_crypto_hw_error_t *hwError * the Crypto function context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoPrngUse @@ -920,7 +961,7 @@ cy_en_crypto_status_t Cy_Crypto_Prng_Init(uint32_t lfsr32InitState, * the Crypto function context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoPrngUse @@ -953,7 +994,7 @@ cy_en_crypto_status_t Cy_Crypto_Prng_Generate(uint32_t max, * internal variables the Crypto driver requires. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoAesEcbUse @@ -986,7 +1027,7 @@ cy_en_crypto_status_t Cy_Crypto_Aes_Init(uint32_t *key, * that stores all AES internal variables. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoAesEcbUse @@ -1025,7 +1066,7 @@ cy_en_crypto_status_t Cy_Crypto_Aes_Ecb_Run(cy_en_crypto_dir_mode_t dirMode, * internal variables the Crypto driver requires. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Aes_Cbc_Run(cy_en_crypto_dir_mode_t dirMode, @@ -1053,17 +1094,17 @@ cy_en_crypto_status_t Cy_Crypto_Aes_Cbc_Run(cy_en_crypto_dir_mode_t dirMode, * The pointer to the initial vector. __Must be 4-byte aligned.__ * * \param dst -* The pointer to a destination cipher text. __Must be 4-byte aligned.__ +* The pointer to the destination cipher text. __Must be 4-byte aligned.__ * * \param src -* The pointer to a source plain text. __Must be 4-byte aligned.__ +* The pointer to the source plain text. __Must be 4-byte aligned.__ * * \param cfContext * The pointer to the \ref cy_stc_crypto_context_aes_t structure that stores all * internal variables the Crypto driver requires. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Aes_Cfb_Run(cy_en_crypto_dir_mode_t dirMode, @@ -1102,17 +1143,17 @@ cy_en_crypto_status_t Cy_Crypto_Aes_Cfb_Run(cy_en_crypto_dir_mode_t dirMode, * __Must be 4-byte aligned.__ * * \param dst -* The pointer to a destination cipher text. __Must be 4-byte aligned.__ +* The pointer to the destination cipher text. __Must be 4-byte aligned.__ * * \param src -* The pointer to a source plain text. __Must be 4-byte aligned.__ +* The pointer to the source plain text. __Must be 4-byte aligned.__ * * \param cfContext * The pointer to the \ref cy_stc_crypto_context_aes_t structure that stores all * internal variables the Crypto driver requires. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Aes_Ctr_Run(cy_en_crypto_dir_mode_t dirMode, @@ -1134,7 +1175,7 @@ cy_en_crypto_status_t Cy_Crypto_Aes_Ctr_Run(cy_en_crypto_dir_mode_t dirMode, * the context structure when making this function call. * * \param src -* The pointer to a source plain text. __Must be 4-byte aligned.__ +* The pointer to the source plain text. __Must be 4-byte aligned.__ * * \param srcSize * The size of a source plain text. @@ -1153,7 +1194,7 @@ cy_en_crypto_status_t Cy_Crypto_Aes_Ctr_Run(cy_en_crypto_dir_mode_t dirMode, * internal variables the Crypto driver requires. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoCmacUse @@ -1189,7 +1230,7 @@ cy_en_crypto_status_t Cy_Crypto_Aes_Cmac_Run(uint32_t *src, * The size of a message. * * \param digest -* The pointer to the hash digest. Hash size depends to selected SHA mode +* The pointer to the hash digest. The hash size depends on the selected SHA mode * (from 20 to 64 bytes, see \ref CY_CRYPTO_SHA_MAX_DIGEST_SIZE). * __Must be 4-byte aligned.__ * @@ -1198,7 +1239,7 @@ cy_en_crypto_status_t Cy_Crypto_Aes_Cmac_Run(uint32_t *src, * internal variables for Crypto driver. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoSha256Use @@ -1246,7 +1287,7 @@ cy_en_crypto_status_t Cy_Crypto_Sha_Run(uint32_t *message, * internal variables for the Crypto driver. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoHmacUse @@ -1288,7 +1329,7 @@ cy_en_crypto_status_t Cy_Crypto_Hmac_Run(uint32_t *hmac, * internal variables for the Crypto driver. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Str_MemCpy(void *dst, @@ -1320,7 +1361,7 @@ cy_en_crypto_status_t Cy_Crypto_Str_MemCpy(void *dst, * internal variables for the Crypto driver. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Str_MemSet(void *dst, @@ -1357,7 +1398,7 @@ cy_en_crypto_status_t Cy_Crypto_Str_MemSet(void *dst, * internal variables for the Crypto driver. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Str_MemCmp(void const *src0, @@ -1395,7 +1436,7 @@ cy_en_crypto_status_t Cy_Crypto_Str_MemCmp(void const *src0, * internal variables for the Crypto driver. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Str_MemXor(void const *src0, @@ -1508,7 +1549,7 @@ cy_en_crypto_status_t Cy_Crypto_Str_MemXor(void const *src0, * the Crypto driver context. * * \return -* A Crypto status \ref cy_en_crypto_status_t +* \ref cy_en_crypto_status_t * * \note * The polynomial, initial seed and remainder XOR values are always @@ -1551,7 +1592,7 @@ cy_en_crypto_status_t Cy_Crypto_Crc_Init(uint32_t polynomial, * the Crypto driver context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \note * The polynomial, initial seed and remainder XOR values are always @@ -1594,7 +1635,7 @@ cy_en_crypto_status_t Cy_Crypto_Crc_Run(void *data, * the Crypto driver context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoTrngUse @@ -1636,7 +1677,7 @@ cy_en_crypto_status_t Cy_Crypto_Trng_Generate(uint32_t GAROPol, * the Crypto driver context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Des_Run(cy_en_crypto_dir_mode_t dirMode, @@ -1673,7 +1714,7 @@ cy_en_crypto_status_t Cy_Crypto_Des_Run(cy_en_crypto_dir_mode_t dirMode, * the Crypto driver context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoTdesUse @@ -1735,7 +1776,7 @@ cy_en_crypto_status_t Cy_Crypto_Tdes_Run(cy_en_crypto_dir_mode_t dirMode, * the RSA context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Rsa_Proc(cy_stc_crypto_rsa_pub_key_t const *pubKey, @@ -1774,7 +1815,7 @@ cy_en_crypto_status_t Cy_Crypto_Rsa_Proc(cy_stc_crypto_rsa_pub_key_t const *pubK * the RSA context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Rsa_CalcCoefs(cy_stc_crypto_rsa_pub_key_t const *pubKey, @@ -1818,7 +1859,7 @@ cy_en_crypto_status_t Cy_Crypto_Rsa_CalcCoefs(cy_stc_crypto_rsa_pub_key_t const * the RSA context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Rsa_Verify(cy_en_crypto_rsa_ver_result_t *verResult, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_common.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_common.h index 47301afbca..1fe68ef5e2 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_common.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_common.h @@ -60,7 +60,7 @@ #define CY_CRYPTO_DRV_VERSION_MINOR 20 /** -* \addtogroup group_crypto_macros +* \addtogroup group_crypto_cli_srv_macros * \{ */ @@ -70,7 +70,7 @@ /** Defines Crypto_Sync non-blocking execution type parameter */ #define CY_CRYPTO_SYNC_NON_BLOCKING (false) -/** Defines the Crypto DES block size (in bytes) */ +/** Defines the Crypto DES block size (in bytes). */ #define CY_CRYPTO_DES_BLOCK_SIZE (8u) /** Defines the Crypto DES key size (in bytes) */ @@ -114,7 +114,7 @@ #define CY_CRYPTO_SHA512_224_DIGEST_SIZE (28u) /** Hash size for the SHA512_256 mode (in bytes) */ #define CY_CRYPTO_SHA512_256_DIGEST_SIZE (32u) -/** Maximal hash size for the SHA modes (in bytes) */ +/** The maximal Hash size for the SHA modes (in bytes). */ #define CY_CRYPTO_SHA_MAX_DIGEST_SIZE (CY_CRYPTO_SHA512_DIGEST_SIZE) /** Block size for the SHA1 mode (in bytes) */ @@ -141,6 +141,9 @@ #define CY_CRYPTO_SHA512_ROUND_MEM_SIZE (640uL) #define CY_CRYPTO_SHA_MAX_ROUND_MEM_SIZE (CY_CRYPTO_SHA512_ROUND_MEM_SIZE) +/* The width of the Crypto hardware registers values in bits. */ +#define CY_CRYPTO_HW_REGS_WIDTH (32UL) + /** \endcond */ #endif /* #if (CPUSS_CRYPTO_SHA == 1) */ @@ -161,11 +164,13 @@ /** Crypto Driver PDL ID */ #define CY_CRYPTO_ID CY_PDL_DRV_ID(0x0Cu) -/** \} group_crypto_macros */ +/** \} group_crypto_cli_srv_macros */ /** * \addtogroup group_crypto_config_structure * \{ + The Crypto initialization configuration. +* \note Should be the same for the Crypto Server and Crypto Client initialization. */ /** The Crypto user callback function type. @@ -231,32 +236,37 @@ typedef struct /** \} group_crypto_config_structure */ /** -* \addtogroup group_crypto_cli_data_structures +* \addtogroup group_crypto_data_structures * \{ */ #if (CPUSS_CRYPTO_VU == 1) + /** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the RSA public key and - * additional coefficients to accelerate RSA calculation. - * - * RSA key contained from two fields: - * - n - modulus part of the key - * - e - exponent part of the key. - * - * Other fields are accelerating coefficients and can be calculated by - * \ref Cy_Crypto_Rsa_CalcCoefs. - * - * \note The modulus and exponent values in the - * \ref cy_stc_crypto_rsa_pub_key_t must also be in little-endian order.
- * Use \ref Cy_Crypto_Rsa_InvertEndianness function to convert to or from - * little-endian order. - * +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +* +* The driver uses this structure to store and manipulate the RSA public key and +* additional coefficients to accelerate RSA calculation. +* +* RSA key contained from two fields: +* - n - modulus part of the key +* - e - exponent part of the key. +* +* Other fields are accelerating coefficients and can be calculated by +* \ref Cy_Crypto_Rsa_CalcCoefs. +* +* \note The modulus and exponent values in the +* \ref cy_stc_crypto_rsa_pub_key_t must also be in little-endian order.
+* Use \ref Cy_Crypto_Rsa_InvertEndianness function to convert to or from +* little-endian order. */ typedef struct { + /** \cond INTERNAL */ /** The pointer to the modulus part of public key. */ uint8_t *moduloPtr; /** The modulus length, in bits, maximum supported size is 2048Bit */ @@ -278,10 +288,18 @@ typedef struct /** The pointer to the (2^moduloLength mod modulo). Memory for it should be allocated by user with size moduloLength */ uint8_t *rBarPtr; +/** \endcond */ } cy_stc_crypto_rsa_pub_key_t; #endif /* #if (CPUSS_CRYPTO_VU == 1) */ +/** \} group_crypto_data_structures */ + +/** +* \addtogroup group_crypto_cli_data_structures +* \{ +*/ + /** Structure for storing a description of a Crypto hardware error */ typedef struct { @@ -484,17 +502,25 @@ typedef enum /** \endcond */ /** -* \addtogroup group_crypto_cli_data_structures +* \addtogroup group_crypto_data_structures * \{ */ #if (CPUSS_CRYPTO_AES == 1) -/** Structure for storing the AES state */ + +/** The structure for storing the AES state. +* All fields for this structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ /** Pointer to AES key */ uint8_t *key; - /** Pointer to AES inversed key */ + /** Pointer to AES inverse key */ uint8_t *invKey; /** AES key length */ cy_en_crypto_aes_key_length_t keyLength; @@ -502,10 +528,39 @@ typedef struct uint32_t *buffers; /** AES processed block index (for CMAC, SHA operations) */ uint32_t blockIdx; + /** \endcond */ } cy_stc_crypto_aes_state_t; #endif /* #if (CPUSS_CRYPTO_AES == 1) */ -/** \} group_crypto_cli_data_structures */ +#if (CPUSS_CRYPTO_SHA == 1) + +/** The structure for storing the SHA state. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ +typedef struct +{ + /** \cond INTERNAL */ + uint32_t mode; + uint8_t *block; + uint32_t blockSize; + uint8_t *hash; + uint32_t hashSize; + uint8_t *roundMem; + uint32_t roundMemSize; + uint32_t messageSize; + uint32_t digestSize; + uint32_t blockIdx; + uint8_t const *initialHash; + /** \endcond */ +} cy_stc_crypto_sha_state_t; + +#endif /* (CPUSS_CRYPTO_SHA == 1) */ + +/** \} group_crypto_data_structures */ /************************************************************* * Structures used for communication between Client and Server @@ -516,14 +571,16 @@ typedef struct * \{ */ -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the server - * context. - */ +/** The structure for storing the crypto server context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ /** IPC communication channel number */ uint32_t ipcChannel; /** IPC acquire interrupt channel number */ @@ -540,6 +597,7 @@ typedef struct bool isHwErrorOccured; /** Hardware processing errors */ cy_stc_crypto_hw_error_t hwErrorStatus; + /** \endcond */ } cy_stc_crypto_server_context_t; /** \} group_crypto_srv_data_structures */ @@ -549,14 +607,16 @@ typedef struct * \{ */ -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the global - * context. - */ +/** The structure for storing the crypto client context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ /** Operation instruction code */ cy_en_crypto_comm_instr_t instr; /** Response from executed crypto function */ @@ -575,18 +635,21 @@ typedef struct cy_stc_sysint_t releaseNotifierConfig; /** Pointer to the crypto function specific context data */ void *xdata; + /** \endcond */ } cy_stc_crypto_context_t; #if (CPUSS_CRYPTO_DES == 1) -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the DES operational - * context. - */ +/** The structure for storing the DES context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ /** Operation direction (Encrypt / Decrypt) */ cy_en_crypto_dir_mode_t dirMode; /** Pointer to key data */ @@ -595,18 +658,21 @@ typedef struct uint32_t *dst; /** Pointer to data source block */ uint32_t *src; + /** \endcond */ } cy_stc_crypto_context_des_t; #endif /* #if (CPUSS_CRYPTO_DES == 1) */ #if (CPUSS_CRYPTO_AES == 1) -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the AES operational - * context. - */ +/** The structure for storing the AES context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ /** AES state data */ cy_stc_crypto_aes_state_t aesState; /** Operation direction (Encrypt / Decrypt) */ @@ -627,38 +693,22 @@ typedef struct uint32_t *dst; /** Pointer to data source block */ uint32_t *src; + /** \endcond */ } cy_stc_crypto_context_aes_t; #endif /* #if (CPUSS_CRYPTO_AES == 1) */ #if (CPUSS_CRYPTO_SHA == 1) -/** \cond INTERNAL */ -/* The structure for storing the SHA context */ -typedef struct -{ - uint32_t mode; - uint8_t *block; - uint32_t blockSize; - uint8_t *hash; - uint32_t hashSize; - uint8_t *roundMem; - uint32_t roundMemSize; - uint32_t messageSize; - uint32_t digestSize; - uint32_t blockIdx; - uint8_t const *initialHash; -} cy_stc_crypto_sha_state_t; - -/** \endcond */ - -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the SHA operational - * context. - */ +/** The structure for storing the SHA context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ /** Pointer to data source block */ uint32_t *message; /** Operation data size */ @@ -671,35 +721,41 @@ typedef struct uint32_t *key; /** Key data length (for HMAC only) */ uint32_t keyLength; + /** \endcond */ } cy_stc_crypto_context_sha_t; #endif /* #if (CPUSS_CRYPTO_SHA == 1) */ #if (CPUSS_CRYPTO_PR == 1) -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the PRNG operational - * context. - */ +/** The structure for storing the PRNG context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ uint32_t lfsr32InitState; /**< lfsr32 initialization data */ uint32_t lfsr31InitState; /**< lfsr31 initialization data */ uint32_t lfsr29InitState; /**< lfsr29 initialization data */ uint32_t max; /**< Maximum of the generated value */ uint32_t *prngNum; /**< Pointer to generated value */ + /** \endcond */ } cy_stc_crypto_context_prng_t; #endif /* #if (CPUSS_CRYPTO_PR == 1) */ #if (CPUSS_CRYPTO_TR == 1) -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the TRNG operational - * context. - */ +/** The structure for storing the TRNG context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ /** The polynomial for the programmable Galois ring oscillator (TR_GARO_CTL). The polynomial is represented WITHOUT the high order bit (this bit is @@ -721,35 +777,41 @@ typedef struct uint32_t max; /** Pointer to generated value */ uint32_t *trngNum; + /** \endcond */ } cy_stc_crypto_context_trng_t; #endif /* #if (CPUSS_CRYPTO_TR == 1) */ #if (CPUSS_CRYPTO_STR == 1) -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the STR operational - * context. - */ +/** The structure for storing the string context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ void const *src0; /**< Pointer to 1-st string source */ void const *src1; /**< Pointer to 2-nd string source */ void *dst; /**< Pointer to string destination */ uint32_t dataSize; /**< Operation data size */ uint32_t data; /**< Operation data value (for memory setting) */ + /** \endcond */ } cy_stc_crypto_context_str_t; #endif /* #if (CPUSS_CRYPTO_STR == 1) */ #if (CPUSS_CRYPTO_CRC == 1) -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the CRC operational - * context. - */ +/** The structure for storing the CRC context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ void* data; /**< Pointer to data source block */ uint32_t dataSize; /**< Operation data size */ uint32_t *crc; /**< Pointer to CRC destination variable */ @@ -759,20 +821,23 @@ typedef struct uint32_t dataXor; /**< Input data XOR flag */ uint32_t remReverse; /**< Output data reverse flag */ uint32_t remXor; /**< Output data XOR flag */ + /** \endcond */ } cy_stc_crypto_context_crc_t; #endif /* #if (CPUSS_CRYPTO_CRC == 1) */ #if (CPUSS_CRYPTO_VU == 1) #if (CPUSS_CRYPTO_SHA == 1) -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the RSA verifying - * context. - */ +/** The structure for storing the RSA verification context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in the function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ /** Pointer to verification result /ref cy_en_crypto_rsa_ver_result_t */ cy_en_crypto_rsa_ver_result_t *verResult; /** SHA digest type, used with SHA calculation of the message */ @@ -783,17 +848,20 @@ typedef struct uint32_t const *decryptedSignature; /** Length of the decrypted RSA signature */ uint32_t decryptedSignatureLength; + /** \endcond */ } cy_stc_crypto_context_rsa_ver_t; #endif /* #if (CPUSS_CRYPTO_SHA == 1) */ -/** - * Firmware allocates memory and provides a pointer to this structure in - * function calls. Firmware does not write or read values in this structure. - * The driver uses this structure to store and manipulate the RSA operational - * context. - */ +/** The structure for storing the RSA context. +* All fields for the context structure are internal. Firmware never reads or +* writes these values. Firmware allocates the structure and provides the +* address of the structure to the driver in function calls. Firmware must +* ensure that the defined instance of this structure remains in scope +* while the drive is in use. +*/ typedef struct { + /** \cond INTERNAL */ /** Pointer to key data */ cy_stc_crypto_rsa_pub_key_t const *key; /** Pointer to data source block */ @@ -802,6 +870,7 @@ typedef struct uint32_t messageSize; /** Pointer to data destination block */ uint32_t *result; + /** \endcond */ } cy_stc_crypto_context_rsa_t; #endif /* #if (CPUSS_CRYPTO_VU == 1) */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core.h index fe64336cfb..31c67a5bfb 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core.h @@ -36,10 +36,43 @@ * provides the configuration data required for the desired cryptographic * technique. * -* \defgroup group_crypto_llc_macros Macros -* \defgroup group_crypto_llc_functions Functions -* \defgroup group_crypto_llc_data_structures Data Structures -* \defgroup group_crypto_llc_enums Enumerated Types +* \defgroup group_crypto_lld_hw Control and Status +* \{ +* \defgroup group_crypto_lld_hw_functions Functions +* \} +* \defgroup group_crypto_lld_symmetric Symmetric Key Algorithms (AES, DES, TDES) +* \{ +* \defgroup group_crypto_lld_symmetric_functions Functions +* \} +* \defgroup group_crypto_lld_asymmetric Asymmetric Key Algorithms (RSA, ECP, ECDSA) +* \{ +* \defgroup group_crypto_lld_asymmetric_functions Functions +* \defgroup group_crypto_lld_asymmetric_enums Enumerated Types +* \} +* \defgroup group_crypto_lld_sha Hash Operations (SHA) +* \{ +* \defgroup group_crypto_lld_sha_functions Functions +* \} +* \defgroup group_crypto_lld_mac Message Authentication Code (CMAC, HMAC) +* \{ +* \defgroup group_crypto_lld_mac_functions Functions +* \} +* \defgroup group_crypto_lld_crc Cyclic Redundancy Code (CRC) +* \{ +* \defgroup group_crypto_lld_crc_functions Functions +* \} +* \defgroup group_crypto_lld_rng Random Number Generation (TRNG, PRNG) +* \{ +* \defgroup group_crypto_lld_rng_functions Functions +* \} +* \defgroup group_crypto_lld_vu Vector Unit (VU) +* \{ +* \defgroup group_crypto_lld_vu_functions Functions +* \} +* \defgroup group_crypto_lld_mem Memory Streaming Functions +* \{ +* \defgroup group_crypto_lld_mem_functions Functions +* \} * \} */ #if !defined(CY_CRYPTO_CORE_H) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_aes.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_aes.h index 7f93678932..0f6e960941 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_aes.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_aes.h @@ -72,15 +72,19 @@ typedef cy_en_crypto_status_t (*cy_crypto_aes_ctr_func_t)(CRYPTO_Type *base, uint8_t const *src, cy_stc_crypto_aes_state_t *aesState); +/** +* \addtogroup group_crypto_lld_symmetric_functions +* \{ +*/ /******************************************************************************* * Function Name: Cy_Crypto_Core_Aes_Init ****************************************************************************//** * -* Sets Aes mode and prepare inversed key. +* Initializes AES mode of operation and prepares an inverse key. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param key * The pointer to the encryption/decryption key. @@ -89,10 +93,11 @@ typedef cy_en_crypto_status_t (*cy_crypto_aes_ctr_func_t)(CRYPTO_Type *base, * \ref cy_en_crypto_aes_key_length_t * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Init(CRYPTO_Type *base, @@ -100,44 +105,45 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Init(CRYPTO_Type *base, cy_en_crypto_aes_key_length_t keyLength, cy_stc_crypto_aes_state_t *aesState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Aes_Init(base, key, keyLength, aesState); + tmpResult = Cy_Crypto_Core_V1_Aes_Init(base, key, keyLength, aesState); } else { - myResult = Cy_Crypto_Core_V2_Aes_Init(base, key, keyLength, aesState); + tmpResult = Cy_Crypto_Core_V2_Aes_Init(base, key, keyLength, aesState); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Aes_Ecb ****************************************************************************//** * -* Performs AES operation on one Block. +* Performs the AES operation on a single block. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT * (\ref cy_en_crypto_dir_mode_t). * * \param dst -* The pointer to a destination cipher block. +* The pointer to the destination cipher block. * * \param src -* The pointer to a source block. +* The pointer to the source block. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Ecb(CRYPTO_Type *base, @@ -146,28 +152,29 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Ecb(CRYPTO_Type *base, uint8_t const *src, cy_stc_crypto_aes_state_t *aesState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Aes_Ecb(base, dirMode, dst, src, aesState); + tmpResult = Cy_Crypto_Core_V1_Aes_Ecb(base, dirMode, dst, src, aesState); } else { - myResult = Cy_Crypto_Core_V2_Aes_Ecb(base, dirMode, dst, src, aesState); + tmpResult = Cy_Crypto_Core_V2_Aes_Ecb(base, dirMode, dst, src, aesState); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Aes_Cbc ****************************************************************************//** * -* Performs AES operation on a plain text with Cipher Block Chaining (CBC). +* Performs the AES-CBC operation defined in the dirMode parameter on a plain text +* defined in the src parameter. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -180,16 +187,17 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Ecb(CRYPTO_Type *base, * The pointer to the initial vector. * * \param dst -* The pointer to a destination cipher text. +* The pointer to the destination cipher text. * * \param src -* The pointer to a source plain text. +* The pointer to the source plain text. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Cbc(CRYPTO_Type *base, @@ -200,28 +208,29 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Cbc(CRYPTO_Type *base, uint8_t const *src, cy_stc_crypto_aes_state_t *aesState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Aes_Cbc(base, dirMode, srcSize, ivPtr, dst, src, aesState); + tmpResult = Cy_Crypto_Core_V1_Aes_Cbc(base, dirMode, srcSize, ivPtr, dst, src, aesState); } else { - myResult = Cy_Crypto_Core_V2_Aes_Cbc(base, dirMode, srcSize, ivPtr, dst, src, aesState); + tmpResult = Cy_Crypto_Core_V2_Aes_Cbc(base, dirMode, srcSize, ivPtr, dst, src, aesState); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Aes_Cfb -******************************************************************************** +****************************************************************************//** * -* Performs AES operation on a plain text with the Cipher Feedback Block method (CFB). +* Performs the AES-CFB operation defined in the dirMode parameter on a plain text +* defined in the SRC parameter. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -234,16 +243,17 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Cbc(CRYPTO_Type *base, * The pointer to the initial vector. * * \param dst -* The pointer to a destination cipher text. +* The pointer to the destination cipher text. * * \param src -* The pointer to a source plain text. +* The pointer to the source plain text. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Cfb(CRYPTO_Type *base, @@ -254,31 +264,31 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Cfb(CRYPTO_Type *base, uint8_t const *src, cy_stc_crypto_aes_state_t *aesState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Aes_Cfb(base, dirMode, srcSize, ivPtr, dst, src, aesState); + tmpResult = Cy_Crypto_Core_V1_Aes_Cfb(base, dirMode, srcSize, ivPtr, dst, src, aesState); } else { - myResult = Cy_Crypto_Core_V2_Aes_Cfb(base, dirMode, srcSize, ivPtr, dst, src, aesState); + tmpResult = Cy_Crypto_Core_V2_Aes_Cfb(base, dirMode, srcSize, ivPtr, dst, src, aesState); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Aes_Ctr -******************************************************************************** +****************************************************************************//** * -* Performs AES operation on a plain text using the counter method (CTR). +* Performs the AES-CTR operation on a plain text defined in the src parameter. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcSize -* The size of a source plain text. +* The size of the source plain text. * * \param srcOffset * The size of an offset within the current block stream for resuming within the @@ -291,16 +301,17 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Cfb(CRYPTO_Type *base, * The saved stream-block for resuming. Is over-written by the function. * * \param dst -* The pointer to a destination cipher text. +* The pointer to the destination cipher text. * * \param src -* The pointer to a source plain text. Must be 4-Byte aligned. +* The pointer to the source plain text. Must be 4-Byte aligned. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Ctr(CRYPTO_Type *base, @@ -312,20 +323,22 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Aes_Ctr(CRYPTO_Type *base, uint8_t const *src, cy_stc_crypto_aes_state_t *aesState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Aes_Ctr(base, srcSize, srcOffset, ivPtr, streamBlock, dst, src, aesState); + tmpResult = Cy_Crypto_Core_V1_Aes_Ctr(base, srcSize, srcOffset, ivPtr, streamBlock, dst, src, aesState); } else { - myResult = Cy_Crypto_Core_V2_Aes_Ctr(base, srcSize, srcOffset, ivPtr, streamBlock, dst, src, aesState); + tmpResult = Cy_Crypto_Core_V2_Aes_Ctr(base, srcSize, srcOffset, ivPtr, streamBlock, dst, src, aesState); } - return myResult; + return tmpResult; } +/** \} group_crypto_lld_symmetric_functions */ + #endif /* #if (CPUSS_CRYPTO_AES == 1) */ #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_cmac.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_cmac.h index 710fe59921..c4e908c068 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_cmac.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_cmac.h @@ -47,21 +47,26 @@ typedef cy_en_crypto_status_t (*cy_crypto_cmac_func_t)(CRYPTO_Type *base, cy_stc_crypto_aes_state_t *aesState); /** \endcond */ +/** +* \addtogroup group_crypto_lld_mac_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_Cmac ****************************************************************************//** * -* Performs CMAC(Cipher-based Message Authentication Code) operation -* on a message to produce message authentication code using AES. +* Calculates the AES Cipher-based Message Authentication Code (CMAC) on the input +* message with the provided key. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param message -* The pointer to a source plain text. Must be 4-byte aligned. +* The pointer to the source plain text. Must be 4-byte aligned. * * \param messageSize -* The size of a source plain text. +* The size of the source plain text in bytes. * * \param key * The pointer to the encryption key. Must be 4-byte aligned. @@ -73,10 +78,11 @@ typedef cy_en_crypto_status_t (*cy_crypto_cmac_func_t)(CRYPTO_Type *base, * The pointer to the calculated CMAC. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac(CRYPTO_Type *base, @@ -87,20 +93,22 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac(CRYPTO_Type *base, uint8_t *cmac, cy_stc_crypto_aes_state_t *aesState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Cmac(base, message, messageSize, key, keyLength, cmac, aesState); + tmpResult = Cy_Crypto_Core_V1_Cmac(base, message, messageSize, key, keyLength, cmac, aesState); } else { - myResult = Cy_Crypto_Core_V2_Cmac(base, message, messageSize, key, keyLength, cmac, aesState); + tmpResult = Cy_Crypto_Core_V2_Cmac(base, message, messageSize, key, keyLength, cmac, aesState); } - return myResult; + return tmpResult; } +/** \} group_crypto_lld_mac_functions */ + #endif /* (CPUSS_CRYPTO_AES == 1) */ #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc.h index 921f474c90..6890e6654b 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc.h @@ -49,14 +49,19 @@ typedef cy_en_crypto_status_t (*cy_crypto_crc_func_t)(CRYPTO_Type *base, uint32_t dataSize, uint32_t lfsrInitState); +/** +* \addtogroup group_crypto_lld_crc_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_Crc_Init ****************************************************************************//** * -* Initializes CRC calculation. +* Initializes the CRC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param polynomial * The polynomial (specified using 32 bits) used in the computing CRC. @@ -65,16 +70,16 @@ typedef cy_en_crypto_status_t (*cy_crypto_crc_func_t)(CRYPTO_Type *base, * The order in which data bytes are processed. 0 - MSB first; 1- LSB first. * * \param dataXor -* The byte mask for XORing data +* The byte mask for XORing data. * * \param remReverse * A remainder reverse: 0 means the remainder is not reversed. 1 means reversed. * * \param remXor -* Specifies a mask with which the LFSR32 register is XORed to produce a remainder. +* Specifies the mask with which the LFSR32 register is XORed to produce a remainder. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_Init(CRYPTO_Type *base, @@ -84,28 +89,28 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_Init(CRYPTO_Type *base, uint32_t remReverse, uint32_t remXor) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Crc_Init(base, polynomial, dataReverse, dataXor, remReverse, remXor); + tmpResult = Cy_Crypto_Core_V1_Crc_Init(base, polynomial, dataReverse, dataXor, remReverse, remXor); } else { - myResult = Cy_Crypto_Core_V2_Crc_Init(base, polynomial, dataReverse, dataXor, remReverse, remXor); + tmpResult = Cy_Crypto_Core_V2_Crc_Init(base, polynomial, dataReverse, dataXor, remReverse, remXor); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Crc ****************************************************************************//** * -* Performs CRC calculation on a message. +* Performs the CRC calculation on a message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param crc * The pointer to a computed CRC value. Must be 4-byte aligned. @@ -120,7 +125,7 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_Init(CRYPTO_Type *base, * The initial state of the LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc(CRYPTO_Type *base, @@ -129,28 +134,28 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc(CRYPTO_Type *base, uint32_t dataSize, uint32_t lfsrInitState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Crc(base, crc, data, dataSize, lfsrInitState); + tmpResult = Cy_Crypto_Core_V1_Crc(base, crc, data, dataSize, lfsrInitState); } else { - myResult = Cy_Crypto_Core_V2_Crc(base, crc, data, dataSize, lfsrInitState); + tmpResult = Cy_Crypto_Core_V2_Crc(base, crc, data, dataSize, lfsrInitState); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Crc_CalcInit ****************************************************************************//** * -* Initializes CRC calculation. +* Initializes the CRC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -159,7 +164,7 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc(CRYPTO_Type *base, * The polynomial (specified using 32 bits) used in the computing CRC. * * \param dataReverse -* The order in which data bytes are processed. 0 - MSB first; 1- LSB first. +* The order in which data bytes are processed. 0 - MSB first; 1 - LSB first. * * \param dataXor * The byte mask for XORing data @@ -168,13 +173,13 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc(CRYPTO_Type *base, * A remainder reverse: 0 means the remainder is not reversed. 1 means reversed. * * \param remXor -* Specifies a mask with which the LFSR32 register is XORed to produce a remainder. +* Specifies the mask with which the LFSR32 register is XORed to produce a remainder. * * \param lfsrInitState * The initial state of the LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcInit(CRYPTO_Type *base, @@ -186,30 +191,30 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcInit(CRYPTO_Type *b uint32_t remXor, uint32_t lfsrInitState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Crc_CalcInit(base, width, polynomial, dataReverse, dataXor, + tmpResult = Cy_Crypto_Core_V1_Crc_CalcInit(base, width, polynomial, dataReverse, dataXor, remReverse, remXor, lfsrInitState); } else { - myResult = Cy_Crypto_Core_V2_Crc_CalcInit(base, width, polynomial, dataReverse, dataXor, + tmpResult = Cy_Crypto_Core_V2_Crc_CalcInit(base, width, polynomial, dataReverse, dataXor, remReverse, remXor, lfsrInitState); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Crc_CalcStart ****************************************************************************//** * -* Prepares CRC calculation by setting an initial seeds value. +* Prepares the CRC calculation by setting an initial seed value. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -218,34 +223,34 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcInit(CRYPTO_Type *b * The initial state of the LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcStart(CRYPTO_Type *base, uint32_t width, uint32_t lfsrInitState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Crc_CalcStart(base, width, lfsrInitState); + tmpResult = Cy_Crypto_Core_V1_Crc_CalcStart(base, width, lfsrInitState); } else { - myResult = Cy_Crypto_Core_V2_Crc_CalcStart(base, width, lfsrInitState); + tmpResult = Cy_Crypto_Core_V2_Crc_CalcStart(base, width, lfsrInitState); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Crc_CalcPartial ****************************************************************************//** * -* Performs CRC calculation of a message part. +* Performs the CRC calculation of a message part. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param data * The pointer to the message whose CRC is being computed. @@ -254,34 +259,34 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcStart(CRYPTO_Type * * The size of a message in bytes. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcPartial(CRYPTO_Type *base, void const *data, uint32_t dataSize) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Crc_CalcPartial(base, data, dataSize); + tmpResult = Cy_Crypto_Core_V1_Crc_CalcPartial(base, data, dataSize); } else { - myResult = Cy_Crypto_Core_V2_Crc_CalcPartial(base, data, dataSize); + tmpResult = Cy_Crypto_Core_V2_Crc_CalcPartial(base, data, dataSize); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Crc_CalcFinish ****************************************************************************//** * -* Finalizes CRC calculation. +* Finalizes the CRC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -290,33 +295,33 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcPartial(CRYPTO_Type * The pointer to a computed CRC value. Must be 4-byte aligned. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcFinish(CRYPTO_Type *base, uint32_t width, uint32_t *crc) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Crc_CalcFinish(base, width, crc); + tmpResult = Cy_Crypto_Core_V1_Crc_CalcFinish(base, width, crc); } else { - myResult = Cy_Crypto_Core_V2_Crc_CalcFinish(base, width, crc); + tmpResult = Cy_Crypto_Core_V2_Crc_CalcFinish(base, width, crc); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Crc_Calc ****************************************************************************//** * -* Performs CRC calculation on a message. +* Performs the CRC calculation on a message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -331,27 +336,29 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_CalcFinish(CRYPTO_Type * The size of a message in bytes. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Crc_Calc(CRYPTO_Type *base, uint32_t width, uint32_t *crc, void const *data, uint32_t dataSize) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Crc_Calc(base, width, crc, data, dataSize); + tmpResult = Cy_Crypto_Core_V1_Crc_Calc(base, width, crc, data, dataSize); } else { - myResult = Cy_Crypto_Core_V2_Crc_Calc(base, width, crc, data, dataSize); + tmpResult = Cy_Crypto_Core_V2_Crc_Calc(base, width, crc, data, dataSize); } - return myResult; + return tmpResult; } +/** \} group_crypto_lld_crc_functions */ + #endif /* #if (CPUSS_CRYPTO_CRC == 1) */ #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc_v1.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc_v1.h index c4feeef338..f9f17ec657 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc_v1.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc_v1.h @@ -48,7 +48,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc(CRYPTO_Type *base, uint32_t dataSize, uint32_t lfsrInitState); -/* New Partial calculation interface */ +/* The new partial calculation interface. */ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcInit(CRYPTO_Type *base, uint32_t width, uint32_t polynomial, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc_v2.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc_v2.h index 319ce82a5d..58c4b7de92 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc_v2.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_crc_v2.h @@ -48,7 +48,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc(CRYPTO_Type *base, uint32_t dataSize, uint32_t lfsrInitState); -/* New Partial calculation interface */ +/* The new partial calculation interface. */ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcInit(CRYPTO_Type *base, uint32_t width, uint32_t polynomial, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_des.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_des.h index 14ec3290c5..4acf65c0ad 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_des.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_des.h @@ -42,16 +42,21 @@ typedef cy_en_crypto_status_t (*cy_crypto_des_func_t)(CRYPTO_Type *base, uint8_t *dst, uint8_t const *src); +/** +* \addtogroup group_crypto_lld_symmetric_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_Des ****************************************************************************//** * -* Performs DES operation on a Single Block. All addresses must be 4-Byte aligned. -* Ciphertext (dstBlock) may overlap with plaintext (srcBlock) +* Performs the DES operation on a single block. All addresses must be 4-byte aligned. +* Ciphertext (dst) may overlap with plaintext (src). * This function is independent from the previous Crypto state. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -61,13 +66,13 @@ typedef cy_en_crypto_status_t (*cy_crypto_des_func_t)(CRYPTO_Type *base, * The pointer to the encryption/decryption key. * * \param dst -* The pointer to a destination cipher block. +* The pointer to the destination cipher block. * * \param src -* The pointer to a source block. +* The pointer to the source block. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Des(CRYPTO_Type *base, @@ -76,30 +81,30 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Des(CRYPTO_Type *base, uint8_t *dst, uint8_t const *src) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Des(base, dirMode, key, dst, src); + tmpResult = Cy_Crypto_Core_V1_Des(base, dirMode, key, dst, src); } else { - myResult = Cy_Crypto_Core_V2_Des(base, dirMode, key, dst, src); + tmpResult = Cy_Crypto_Core_V2_Des(base, dirMode, key, dst, src); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Tdes ****************************************************************************//** * -* Performs TDES operation on a Single Block. All addresses must be 4-Byte aligned. -* Ciphertext (dstBlock) may overlap with plaintext (srcBlock) +* Performs the TDES operation on a single block. All addresses must be 4-byte aligned. +* Ciphertext (dst) may overlap with plaintext (src). * This function is independent from the previous Crypto state. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -109,13 +114,13 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Des(CRYPTO_Type *base, * The pointer to the encryption/decryption keys. * * \param dst -* The pointer to a destination cipher block. +* The pointer to the destination cipher block. * * \param src -* The pointer to a source data block. +* The pointer to the source data block. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Tdes(CRYPTO_Type *base, @@ -124,20 +129,22 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Tdes(CRYPTO_Type *base, uint8_t *dst, uint8_t const *src) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Tdes(base, dirMode, key, dst, src); + tmpResult = Cy_Crypto_Core_V1_Tdes(base, dirMode, key, dst, src); } else { - myResult = Cy_Crypto_Core_V2_Tdes(base, dirMode, key, dst, src); + tmpResult = Cy_Crypto_Core_V2_Tdes(base, dirMode, key, dst, src); } - return myResult; + return tmpResult; } +/** \} group_crypto_lld_symmetric_functions */ + #endif /* #if (CPUSS_CRYPTO_DES == 1) */ #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_ecc.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_ecc.h index 6a68d63e9f..fb98ccb491 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_ecc.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_ecc.h @@ -34,6 +34,12 @@ #if (CPUSS_CRYPTO_VU == 1) +/** +* \addtogroup group_crypto_lld_asymmetric_enums +* \{ +*/ + +/** List of supported elliptic curve IDs */ typedef enum { CY_CRYPTO_ECC_ECP_NONE = 0, CY_CRYPTO_ECC_ECP_SECP192R1, @@ -45,6 +51,8 @@ typedef enum { CY_CRYPTO_ECC_ECP_CURVES_CNT } cy_en_crypto_ecc_curve_id_t; +/** \} group_crypto_lld_asymmetric_enums */ + typedef enum cy_en_red_mul_algs { CY_CRYPTO_NIST_P_CURVE_SPECIFIC_RED_ALG = 0, CY_CRYPTO_NIST_P_SHIFT_MUL_RED_ALG, @@ -60,7 +68,7 @@ typedef struct { uint32_t size; /** name of curve */ - const char *name; + const char_t *name; /** ECC calculation default algorithm */ cy_en_crypto_ecc_red_mul_algs_t algo; @@ -118,7 +126,14 @@ typedef struct { } cy_stc_crypto_ecc_key; -typedef int (*cy_func_get_random_data_t)(void *, unsigned char *, size_t); +/** +* \addtogroup group_crypto_lld_asymmetric_functions +* \{ +*/ + +/** Pointer to a random number supplier function */ +typedef int (*cy_func_get_random_data_t)(void *rndInfo, uint8_t *rndData, size_t rndSize); + cy_en_crypto_status_t Cy_Crypto_Core_ECC_MakeKeyPair(CRYPTO_Type *base, cy_en_crypto_ecc_curve_id_t curveID, cy_stc_crypto_ecc_key *key, @@ -127,22 +142,24 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_SignHash(CRYPTO_Type *base, const uint8_t *hash, uint32_t hashlen, uint8_t *sig, - cy_stc_crypto_ecc_key *key, - uint8_t *messageKey); + const cy_stc_crypto_ecc_key *key, + const uint8_t *messageKey); cy_en_crypto_status_t Cy_Crypto_Core_ECC_VerifyHash(CRYPTO_Type *base, - const uint8_t *sig, - const uint8_t *hash, - uint32_t hashlen, - uint8_t *status, - cy_stc_crypto_ecc_key *key); + const uint8_t *sig, + const uint8_t *hash, + uint32_t hashlen, + uint8_t *stat, + const cy_stc_crypto_ecc_key *key); cy_en_crypto_status_t Cy_Crypto_Core_ECC_MakePrivateKey(CRYPTO_Type *base, cy_en_crypto_ecc_curve_id_t curveID, uint8_t *key, cy_func_get_random_data_t GetRandomDataFunc, void *randomDataInfo); cy_en_crypto_status_t Cy_Crypto_Core_ECC_MakePublicKey(CRYPTO_Type *base, cy_en_crypto_ecc_curve_id_t curveID, - uint8_t *privateKey, + const uint8_t *privateKey, cy_stc_crypto_ecc_key *publicKey); +/** \} group_crypto_lld_asymmetric_functions */ + /** Calculates the actual size in bytes of the bits value */ #define CY_CRYPTO_BYTE_SIZE_OF_BITS(x) (uint32_t)(((x) + 7u) >> 3u) @@ -166,11 +183,11 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_MakePublicKey(CRYPTO_Type *base, #define CY_CRYPTO_ECC_MAX_BYTE_SIZE (CY_CRYPTO_ECC_P521_BYTE_SIZE) /* "Global" vector unit registers. */ -#define VR_D 10 -#define VR_S_X 11 -#define VR_S_Y 12 -#define VR_BARRETT 13 -#define VR_P 14 /* polynomial */ +#define VR_D 10u +#define VR_S_X 11u +#define VR_S_Y 12u +#define VR_BARRETT 13u +#define VR_P 14u /* polynomial */ #endif /* #if (CPUSS_CRYPTO_VU == 1) */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_ecc_nist_p.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_ecc_nist_p.h index 6fec27fa7b..33e5b3a824 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_ecc_nist_p.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_ecc_nist_p.h @@ -33,38 +33,39 @@ #if (CPUSS_CRYPTO_VU == 1) -void Cy_Crypto_Core_EC_NistP_SetMode(int bitsize); +void Cy_Crypto_Core_EC_NistP_SetMode(uint32_t bitsize); void Cy_Crypto_Core_EC_NistP_SetRedAlg(cy_en_crypto_ecc_red_mul_algs_t alg); -void Cy_Crypto_Core_EC_NistP_PointMul(CRYPTO_Type *base, int p_x, int p_y, int p_d, int p_order, int bitsize); + +/** +* \addtogroup group_crypto_lld_asymmetric_functions +* \{ +*/ cy_en_crypto_status_t Cy_Crypto_Core_EC_NistP_PointMultiplication(CRYPTO_Type *base, cy_en_crypto_ecc_curve_id_t curveID, - uint8_t* ecpGX, - uint8_t* ecpGY, - uint8_t* ecpD, - uint8_t* ecpQX, - uint8_t* ecpQY); -void Cy_Crypto_Core_EC_MulMod( CRYPTO_Type *base, - int z, - int a, - int b, - int size); -void Cy_Crypto_Core_EC_DivMod( CRYPTO_Type *base, - int z, - int a, - int b, - int size); -void Cy_Crypto_Core_EC_SquareMod( CRYPTO_Type *base, - int z, - int a, - int size); -void Cy_Crypto_Core_EC_Bar_MulRed(CRYPTO_Type *base, - int z, - int x, - int size -); -void Cy_Crypto_Core_EC_AddMod( CRYPTO_Type *base, int z, int a, int b); -void Cy_Crypto_Core_EC_SubMod( CRYPTO_Type *base, int z, int a, int b); -void Cy_Crypto_Core_EC_HalfMod( CRYPTO_Type *base, int z, int a); + const uint8_t *ecpGX, + const uint8_t *ecpGY, + const uint8_t *ecpD, + uint8_t *ecpQX, + uint8_t *ecpQY); +/** \} group_crypto_lld_asymmetric_functions */ + +void Cy_Crypto_Core_EC_MulMod( CRYPTO_Type *base, uint32_t z, uint32_t a, uint32_t b, uint32_t size); +void Cy_Crypto_Core_EC_DivMod( CRYPTO_Type *base, uint32_t z, uint32_t a, uint32_t b, uint32_t size); +void Cy_Crypto_Core_EC_SquareMod( CRYPTO_Type *base, uint32_t z, uint32_t a, uint32_t size); +void Cy_Crypto_Core_EC_Bar_MulRed(CRYPTO_Type *base, uint32_t z, uint32_t x, uint32_t size); + +void Cy_Crypto_Core_EC_AddMod( CRYPTO_Type *base, uint32_t z, uint32_t a, uint32_t b); +void Cy_Crypto_Core_EC_SubMod( CRYPTO_Type *base, uint32_t z, uint32_t a, uint32_t b); +void Cy_Crypto_Core_EC_HalfMod( CRYPTO_Type *base, uint32_t z, uint32_t a); + +void Cy_Crypto_Core_JacobianEcAdd(CRYPTO_Type *base, uint32_t s_x, uint32_t s_y, uint32_t s_z, uint32_t t_x, uint32_t t_y, uint32_t size); +void Cy_Crypto_Core_JacobianEcDouble(CRYPTO_Type *base, uint32_t s_x, uint32_t s_y, uint32_t s_z, uint32_t size); +void Cy_Crypto_Core_JacobianEcScalarMul(CRYPTO_Type *base, uint32_t s_x, uint32_t s_y, uint32_t d, uint32_t size); + +void Cy_Crypto_Core_JacobianTransform(CRYPTO_Type *base, uint32_t s_x, uint32_t s_y, uint32_t s_z); +void Cy_Crypto_Core_JacobianInvTransform(CRYPTO_Type *base, uint32_t s_x, uint32_t s_y, uint32_t s_z, uint32_t size); + +void Cy_Crypto_Core_EC_NistP_PointMul(CRYPTO_Type *base, uint32_t p_x, uint32_t p_y, uint32_t p_d, uint32_t p_order, uint32_t bitsize); #endif /* #if (CPUSS_CRYPTO_VU == 1) */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hmac.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hmac.h index 8dabf45ad5..d920990cf9 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hmac.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hmac.h @@ -44,23 +44,28 @@ typedef cy_en_crypto_status_t (*cy_crypto_hmac_func_t)(CRYPTO_Type *base, uint32_t keyLength, cy_en_crypto_sha_mode_t mode); +/** +* \addtogroup group_crypto_lld_mac_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_Hmac ****************************************************************************//** * -* Performs HMAC calculation. +* Performs the HMAC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hmac * The pointer to the calculated HMAC. Must be 4-byte aligned. * * \param message -* The pointer to a message whose hash value is being computed. +* The pointer to the message whose hash value is being computed. * * \param messageSize -* The size of a message. +* The size of the message. * * \param key * The pointer to the key. @@ -72,7 +77,7 @@ typedef cy_en_crypto_status_t (*cy_crypto_hmac_func_t)(CRYPTO_Type *base, * \ref cy_en_crypto_sha_mode_t * * \return -* A Crypto status \ref en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac(CRYPTO_Type *base, @@ -83,20 +88,22 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Hmac(CRYPTO_Type *base, uint32_t keyLength, cy_en_crypto_sha_mode_t mode) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Hmac(base, hmac, message, messageSize, key, keyLength, mode); + tmpResult = Cy_Crypto_Core_V1_Hmac(base, hmac, message, messageSize, key, keyLength, mode); } else { - myResult = Cy_Crypto_Core_V2_Hmac(base, hmac, message, messageSize, key, keyLength, mode); + tmpResult = Cy_Crypto_Core_V2_Hmac(base, hmac, message, messageSize, key, keyLength, mode); } - return myResult; + return tmpResult; } +/** \} group_crypto_lld_mac_functions */ + #endif /* #if (CPUSS_CRYPTO_SHA == 1) */ #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw.h index c7df544ae8..ff2ddf9c86 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw.h @@ -108,9 +108,9 @@ #define REG_CRYPTO_DEV_KEY_CTL0(base) (((CRYPTO_V2_Type*)(base))->DEV_KEY_CTL0) #define REG_CRYPTO_DEV_KEY_CTL1(base) (((CRYPTO_V2_Type*)(base))->DEV_KEY_CTL1) -/* CRYPTO internal memory buffer size IN BYTES */ +/* The CRYPTO internal-memory buffer-size in bytes. */ #define CY_CRYPTO_MEM_BUFF_SIZE ((cy_device->cryptoMemSize) * 4u) -/* CRYPTO internal memory buffer size IN 32 bit WORDS */ +/* The CRYPTO internal-memory buffer-size in 32-bit words. */ #define CY_CRYPTO_MEM_BUFF_SIZE_U32 (cy_device->cryptoMemSize) /* Device Crypto IP descriptor type */ @@ -220,6 +220,11 @@ typedef enum /** \endcond */ +/** +* \addtogroup group_crypto_lld_hw_functions +* \{ +*/ + void Cy_Crypto_Core_HwInit(void); cy_en_crypto_status_t Cy_Crypto_Core_Enable(CRYPTO_Type *base); @@ -239,10 +244,10 @@ void Cy_Crypto_Core_InvertEndianness(void *inArrPtr, uint32_t byteSize); * The function checks whether the Crypto hardware is enabled. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \return -* Crypto status \ref cy_en_crypto_status_t. +* Crypto status \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE bool Cy_Crypto_Core_IsEnabled(CRYPTO_Type *base) @@ -265,7 +270,7 @@ __STATIC_INLINE bool Cy_Crypto_Core_IsEnabled(CRYPTO_Type *base) * - from 0 to 16 for MXCRYPTO_ver2 IP block * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * *******************************************************************************/ __STATIC_INLINE uint8_t Cy_Crypto_Core_GetFIFODepth(CRYPTO_Type *base) @@ -281,7 +286,7 @@ __STATIC_INLINE uint8_t Cy_Crypto_Core_GetFIFODepth(CRYPTO_Type *base) * The value of this field ranges from 0 to 8 * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * *******************************************************************************/ __STATIC_INLINE uint8_t Cy_Crypto_Core_GetFIFOUsed(CRYPTO_Type *base) @@ -299,7 +304,7 @@ __STATIC_INLINE uint8_t Cy_Crypto_Core_GetFIFOUsed(CRYPTO_Type *base) * By default EVENT_LEVEL = 0; * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * *******************************************************************************/ __STATIC_INLINE void Cy_Crypto_Core_WaitForFifoAvailable(CRYPTO_Type *base) @@ -316,7 +321,7 @@ __STATIC_INLINE void Cy_Crypto_Core_WaitForFifoAvailable(CRYPTO_Type *base) * Waits until all instruction in FIFO will be completed * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * *******************************************************************************/ __STATIC_INLINE void Cy_Crypto_Core_WaitForReady(CRYPTO_Type *base) @@ -333,7 +338,7 @@ __STATIC_INLINE void Cy_Crypto_Core_WaitForReady(CRYPTO_Type *base) * Masks / unmasks multiple interrupt sources. * * \param base -* Pointer to Crypto instance address +* The pointer to the CRYPTO instance. * * \param interrupts * Mask bits. See definitions above. @@ -351,7 +356,7 @@ __STATIC_INLINE void Cy_Crypto_Core_SetInterruptMask(CRYPTO_Type *base, uint32_t * Reports mask / unmask multiple interrupt sources. * * \param base -* Pointer to Crypto instance address +* The pointer to the CRYPTO instance. * * \return * Mask bits. See definitions above. @@ -369,7 +374,7 @@ __STATIC_INLINE uint32_t Cy_Crypto_Core_GetInterruptMask(CRYPTO_Type const *base * Reports states of multiple enabled interrupt sources. * * \param base -* Pointer to Crypto instance address +* The pointer to the CRYPTO instance. * * \return * Source bits. See definitions above. @@ -387,7 +392,7 @@ __STATIC_INLINE uint32_t Cy_Crypto_Core_GetInterruptStatusMasked(CRYPTO_Type con * Reports states of multiple interrupt sources. * * \param base -* Pointer to Crypto instance address +* The pointer to the CRYPTO instance. * * \return * Source bits. See definitions above. @@ -405,7 +410,7 @@ __STATIC_INLINE uint32_t Cy_Crypto_Core_GetInterruptStatus(CRYPTO_Type *base) * Sets one of more interrupt sources * * \param base -* Pointer to Crypto instance address +* The pointer to the CRYPTO instance. * * \param interrupts * Source bit(s) @@ -423,7 +428,7 @@ __STATIC_INLINE void Cy_Crypto_Core_SetInterrupt(CRYPTO_Type *base, uint32_t in * Clears multiple interrupt sources. * * \param base -* Pointer to Crypto instance address +* The pointer to the CRYPTO instance. * * \param interrupts * Source bit(s). See definitions above. @@ -435,6 +440,7 @@ __STATIC_INLINE void Cy_Crypto_Core_ClearInterrupt(CRYPTO_Type *base, uint32_t (void) REG_CRYPTO_INTR(base); } +/** \} group_crypto_lld_hw_functions */ #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw_v2.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw_v2.h index fb8e1b11ac..33eef6dad5 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw_v2.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw_v2.h @@ -151,8 +151,8 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_FFStart(CRYPTO_Type *base, { } - REG_CRYPTO_INSTR_FF_WR(base) = (CY_CRYPTO_V2_FF_START_OPC << CY_CRYPTO_OPCODE_POS) - | (ff_idx << CY_CRYPTO_RSRC0_SHIFT); + REG_CRYPTO_INSTR_FF_WR(base) = ((uint32_t)CY_CRYPTO_V2_FF_START_OPC << CY_CRYPTO_OPCODE_POS) | + (ff_idx << CY_CRYPTO_RSRC0_SHIFT); REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t) p_mem; REG_CRYPTO_INSTR_FF_WR(base) = size; } @@ -168,8 +168,8 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_FFContinue(CRYPTO_Type *base, /* Wait for previous loading has been completed. */ (CY_CRYPTO_V2_RB_FF_LOAD0 == ff_idx) ? Cy_Crypto_Core_V2_FFLoad0Sync(base) : Cy_Crypto_Core_V2_FFLoad1Sync(base); - REG_CRYPTO_INSTR_FF_WR(base) = (CY_CRYPTO_V2_FF_CONTINUE_OPC << CY_CRYPTO_OPCODE_POS) - | (ff_idx << CY_CRYPTO_RSRC0_SHIFT); + REG_CRYPTO_INSTR_FF_WR(base) = ((uint32_t)CY_CRYPTO_V2_FF_CONTINUE_OPC << CY_CRYPTO_OPCODE_POS) | + (ff_idx << CY_CRYPTO_RSRC0_SHIFT); REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t) p_mem; REG_CRYPTO_INSTR_FF_WR(base) = size; } @@ -181,7 +181,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_FFStop(CRYPTO_Type *base, uint32_t ff_idx { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((CY_CRYPTO_V2_FF_STOP_OPC << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(((uint32_t)CY_CRYPTO_V2_FF_STOP_OPC << CY_CRYPTO_OPCODE_POS) | (ff_idx << CY_CRYPTO_RSRC0_SHIFT)); } @@ -193,7 +193,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_BlockMov(CRYPTO_Type *base, { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((CY_CRYPTO_V2_BLOCK_MOV_OPC << CY_CRYPTO_OPCODE_POS) + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(((uint32_t)CY_CRYPTO_V2_BLOCK_MOV_OPC << CY_CRYPTO_OPCODE_POS) | (size << CY_CRYPTO_RSRC16_SHIFT) | (dst_idx << CY_CRYPTO_RSRC12_SHIFT) | (src_idx << CY_CRYPTO_RSRC0_SHIFT)); @@ -207,8 +207,8 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_BlockMov_Reflect(CRYPTO_Type *base, { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((CY_CRYPTO_V2_BLOCK_MOV_OPC << CY_CRYPTO_OPCODE_POS) - | (1u << CY_CRYPTO_RSRC23_SHIFT) + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(((uint32_t)CY_CRYPTO_V2_BLOCK_MOV_OPC << CY_CRYPTO_OPCODE_POS) + | (1UL << CY_CRYPTO_RSRC23_SHIFT) | (size << CY_CRYPTO_RSRC16_SHIFT) | (dst_idx << CY_CRYPTO_RSRC12_SHIFT) | (src_idx << CY_CRYPTO_RSRC0_SHIFT)); @@ -222,7 +222,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_BlockSet(CRYPTO_Type *base, { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((CY_CRYPTO_V2_BLOCK_SET_OPC << CY_CRYPTO_OPCODE_POS) + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(((uint32_t)CY_CRYPTO_V2_BLOCK_SET_OPC << CY_CRYPTO_OPCODE_POS) | (size << CY_CRYPTO_RSRC16_SHIFT) | (dst_idx << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)(data) << CY_CRYPTO_RSRC0_SHIFT)); @@ -236,7 +236,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_BlockCmp(CRYPTO_Type *base, { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((CY_CRYPTO_V2_BLOCK_CMP_OPC << CY_CRYPTO_OPCODE_POS) + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(((uint32_t)CY_CRYPTO_V2_BLOCK_CMP_OPC << CY_CRYPTO_OPCODE_POS) | (size << CY_CRYPTO_RSRC16_SHIFT) | (src1_idx << CY_CRYPTO_RSRC4_SHIFT) | (src0_idx << CY_CRYPTO_RSRC0_SHIFT)); @@ -250,7 +250,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_BlockXor(CRYPTO_Type *base, { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((CY_CRYPTO_V2_BLOCK_XOR_OPC << CY_CRYPTO_OPCODE_POS) + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(((uint32_t)CY_CRYPTO_V2_BLOCK_XOR_OPC << CY_CRYPTO_OPCODE_POS) | (size << CY_CRYPTO_RSRC16_SHIFT) | (dst_idx << CY_CRYPTO_RSRC12_SHIFT) | (src1_idx << CY_CRYPTO_RSRC4_SHIFT) @@ -264,7 +264,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_BlockGcm(CRYPTO_Type *base) { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(CY_CRYPTO_V2_BLOCK_GCM_OPC << CY_CRYPTO_OPCODE_POS); + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((uint32_t)CY_CRYPTO_V2_BLOCK_GCM_OPC << CY_CRYPTO_OPCODE_POS); } __STATIC_INLINE void Cy_Crypto_Core_V2_Run(CRYPTO_Type *base, uint32_t opc) @@ -284,7 +284,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_RBClear(CRYPTO_Type *base) { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(CY_CRYPTO_V2_RB_CLEAR_OPC << CY_CRYPTO_OPCODE_POS); + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((uint32_t)CY_CRYPTO_V2_RB_CLEAR_OPC << CY_CRYPTO_OPCODE_POS); } __STATIC_INLINE void Cy_Crypto_Core_V2_RBSwap(CRYPTO_Type *base) @@ -294,7 +294,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_RBSwap(CRYPTO_Type *base) { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(CY_CRYPTO_V2_RB_SWAP_OPC << CY_CRYPTO_OPCODE_POS); + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((uint32_t)CY_CRYPTO_V2_RB_SWAP_OPC << CY_CRYPTO_OPCODE_POS); } __STATIC_INLINE void Cy_Crypto_Core_V2_RBXor(CRYPTO_Type *base, uint32_t offset, uint32_t size) @@ -304,7 +304,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_RBXor(CRYPTO_Type *base, uint32_t offset, { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((CY_CRYPTO_V2_RB_XOR_OPC << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(((uint32_t)CY_CRYPTO_V2_RB_XOR_OPC << CY_CRYPTO_OPCODE_POS) | (offset << CY_CRYPTO_RSRC8_SHIFT) | (size << CY_CRYPTO_RSRC0_SHIFT)); } @@ -316,7 +316,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_RBStore(CRYPTO_Type *base, uint32_t offse { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((CY_CRYPTO_V2_RB_STORE_OPC << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(((uint32_t)CY_CRYPTO_V2_RB_STORE_OPC << CY_CRYPTO_OPCODE_POS) | (offset << CY_CRYPTO_RSRC8_SHIFT) | (size << CY_CRYPTO_RSRC0_SHIFT));} @@ -327,7 +327,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_RBSetByte(CRYPTO_Type *base, uint32_t off { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((CY_CRYPTO_V2_RB_BYTE_SET_OPC << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(((uint32_t)CY_CRYPTO_V2_RB_BYTE_SET_OPC << CY_CRYPTO_OPCODE_POS) | (offset << CY_CRYPTO_RSRC8_SHIFT) | ((uint32_t)(byte) << CY_CRYPTO_RSRC0_SHIFT)); } @@ -339,7 +339,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_RunAes(CRYPTO_Type *base) { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(CY_CRYPTO_V2_AES_OPC << CY_CRYPTO_OPCODE_POS); + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((uint32_t)CY_CRYPTO_V2_AES_OPC << CY_CRYPTO_OPCODE_POS); } __STATIC_INLINE void Cy_Crypto_Core_V2_RunAesInv(CRYPTO_Type *base) @@ -349,7 +349,7 @@ __STATIC_INLINE void Cy_Crypto_Core_V2_RunAesInv(CRYPTO_Type *base) { } - REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)(CY_CRYPTO_V2_AES_INV_OPC << CY_CRYPTO_OPCODE_POS); + REG_CRYPTO_INSTR_FF_WR(base) = (uint32_t)((uint32_t)CY_CRYPTO_V2_AES_INV_OPC << CY_CRYPTO_OPCODE_POS); } __STATIC_INLINE void Cy_Crypto_Core_V2_RunChacha(CRYPTO_Type *base, uint8_t roundNum) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw_vu.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw_vu.h index c883594c2c..7780982475 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw_vu.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_hw_vu.h @@ -191,8 +191,8 @@ #define CY_CRYPTO_VU2_INV_BIT_IMM_OPC (0x2Eu) -__STATIC_INLINE void CY_CRYPTO_VU_SAVE_REG (CRYPTO_Type *base, uint32_t rsrc, uint32_t *ddata); -__STATIC_INLINE void CY_CRYPTO_VU_RESTORE_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t ddata); +__STATIC_INLINE void CY_CRYPTO_VU_SAVE_REG (CRYPTO_Type *base, uint32_t rsrc, uint32_t *data); +__STATIC_INLINE void CY_CRYPTO_VU_RESTORE_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t data); __STATIC_INLINE void CY_CRYPTO_VU_SET_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t data, uint32_t size); @@ -200,7 +200,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_MOV_REG_TO_STATUS (CRYPTO_Type *base, uin { REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_MOV_REG_TO_STATUS_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | - (uint32_t)rsrc); + ((uint32_t)rsrc)); } __STATIC_INLINE void CY_CRYPTO_VU_MOV_REG_TO_STATUS (CRYPTO_Type *base, uint32_t rsrc) @@ -222,18 +222,19 @@ __STATIC_INLINE void CY_CRYPTO_VU_MOV_STATUS_TO_REG (CRYPTO_Type *base, uint32_t __STATIC_INLINE void CY_CRYPTO_VU_COND_MOV_IMM_TO_STATUS (CRYPTO_Type *base, uint32_t cc, uint32_t imm4) { - if (cy_device->cryptoVersion == 1) + if (CY_CRYPTO_HW_V1) { /******* V1 *********/ - int tmp_reg = CY_CRYPTO_VU_HW_REG14; - uint32_t tmp_data; + uint32_t tmpReg = CY_CRYPTO_VU_HW_REG14; + uint32_t tmpData; - CY_CRYPTO_VU_SAVE_REG(base, tmp_reg, &tmp_data); + CY_CRYPTO_VU_SAVE_REG(base, tmpReg, &tmpData); - CY_CRYPTO_VU_SET_REG(base, tmp_reg, imm4, 4); - CY_CRYPTO_VU_COND_MOV_REG_TO_STATUS(base, cc, tmp_reg); + /* Load 4 bit immediate value */ + CY_CRYPTO_VU_SET_REG(base, tmpReg, imm4, 4u); + CY_CRYPTO_VU_COND_MOV_REG_TO_STATUS(base, cc, tmpReg); - CY_CRYPTO_VU_RESTORE_REG(base, tmp_reg, tmp_data); + CY_CRYPTO_VU_RESTORE_REG(base, tmpReg, tmpData); } else { @@ -255,8 +256,8 @@ __STATIC_INLINE void CY_CRYPTO_VU_SET_REG (CRYPTO_Type *base, uint32_t rdst, uin { REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_SET_REG_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)rdst << CY_CRYPTO_RSRC26_SHIFT) | - ((uint32_t)data << ((cy_device->cryptoVersion == 1) ? CY_CRYPTO_RSRC12_SHIFT : CY_CRYPTO_RSRC13_SHIFT)) | - (((uint32_t)size - 1) << CY_CRYPTO_RSRC0_SHIFT)); + ((uint32_t)data << ((CY_CRYPTO_HW_V1) ? CY_CRYPTO_RSRC12_SHIFT : CY_CRYPTO_RSRC13_SHIFT)) | + (((uint32_t)size - 1u) << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_COND_LD_REG (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc) @@ -317,7 +318,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_ADD_REG (CRYPTO_Type *base, uint32_t cc, ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_ADD_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -331,7 +332,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_SUB_REG (CRYPTO_Type *base, uint32_t cc, ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_SUB_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -345,7 +346,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_OR_REG (CRYPTO_Type *base, uint32_t cc, u ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_OR_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -359,7 +360,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_AND_REG (CRYPTO_Type *base, uint32_t cc, ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_AND_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -373,7 +374,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_XOR_REG (CRYPTO_Type *base, uint32_t cc, ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_XOR_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -387,7 +388,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_NOR_REG (CRYPTO_Type *base, uint32_t cc, ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_NOR_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -401,7 +402,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_NAND_REG (CRYPTO_Type *base, uint32_t cc, ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_NAND_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -415,7 +416,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_MIN_REG (CRYPTO_Type *base, uint32_t cc, ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_MIN_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -429,7 +430,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_MAX_REG (CRYPTO_Type *base, uint32_t cc, ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_MAX_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -464,8 +465,8 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_ALLOC_MEM (CRYPTO_Type *base, uint32_t cc REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_ALLOC_MEM_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | - ((uint32_t)rdst << ((cy_device->cryptoVersion == 1) ? CY_CRYPTO_RSRC12_SHIFT : CY_CRYPTO_RSRC16_SHIFT)) | - (((uint32_t)size - 1) << CY_CRYPTO_RSRC0_SHIFT)); + ((uint32_t)rdst << ((CY_CRYPTO_HW_V1) ? CY_CRYPTO_RSRC12_SHIFT : CY_CRYPTO_RSRC16_SHIFT)) | + (((uint32_t)size - 1u) << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_ALLOC_MEM (CRYPTO_Type *base, uint32_t rdst, uint32_t size) @@ -477,7 +478,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_FREE_MEM (CRYPTO_Type *base, uint32_t cc, { REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_FREE_MEM_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | - (uint32_t)reg_mask); + ((uint32_t)reg_mask)); } __STATIC_INLINE void CY_CRYPTO_VU_FREE_MEM (CRYPTO_Type *base, uint32_t reg_mask) @@ -491,7 +492,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_LSL (CRYPTO_Type *base, uint32_t cc, uint ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_LSL (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -501,7 +502,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_LSL (CRYPTO_Type *base, uint32_t rdst, uint32_ __STATIC_INLINE void CY_CRYPTO_VU_COND_LSL1 (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc1) { - if (cy_device->cryptoVersion == 1) + if (CY_CRYPTO_HW_V1) { /******* V1 *********/ REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_LSL1_OPC << CY_CRYPTO_OPCODE_POS) | @@ -527,7 +528,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_LSL1 (CRYPTO_Type *base, uint32_t rdst, uint32 __STATIC_INLINE void CY_CRYPTO_VU_COND_LSL1_WITH_CARRY (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc1) { - if (cy_device->cryptoVersion == 1) + if (CY_CRYPTO_HW_V1) { /******* V1 *********/ REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_LSL1_WITH_CARRY_OPC << CY_CRYPTO_OPCODE_POS) | @@ -553,11 +554,11 @@ __STATIC_INLINE void CY_CRYPTO_VU_LSL1_WITH_CARRY (CRYPTO_Type *base, uint32_t r __STATIC_INLINE void CY_CRYPTO_VU_COND_LSR (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) { - REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((cy_device->cryptoVersion == 1) ? CY_CRYPTO_VU1_LSR_OPC : CY_CRYPTO_VU2_LSR_OPC) << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((CY_CRYPTO_HW_V1) ? CY_CRYPTO_VU1_LSR_OPC : CY_CRYPTO_VU2_LSR_OPC) << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_LSR (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -567,7 +568,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_LSR (CRYPTO_Type *base, uint32_t rdst, uint32_ __STATIC_INLINE void CY_CRYPTO_VU_COND_LSR1 (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc1) { - if (cy_device->cryptoVersion == 1) + if (CY_CRYPTO_HW_V1) { /******* V1 *********/ REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)(CY_CRYPTO_VU1_LSR1_OPC) << CY_CRYPTO_OPCODE_POS) | @@ -593,7 +594,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_LSR1 (CRYPTO_Type *base, uint32_t rdst, uint32 __STATIC_INLINE void CY_CRYPTO_VU_COND_LSR1_WITH_CARRY (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc1) { - if (cy_device->cryptoVersion == 1) + if (CY_CRYPTO_HW_V1) { /******* V1 *********/ REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)(CY_CRYPTO_VU1_LSR1_WITH_CARRY_OPC) << CY_CRYPTO_OPCODE_POS) | @@ -619,11 +620,11 @@ __STATIC_INLINE void CY_CRYPTO_VU_LSR1_WITH_CARRY (CRYPTO_Type *base, uint32_t r __STATIC_INLINE void CY_CRYPTO_VU_COND_CLSAME (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) { - REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((cy_device->cryptoVersion == 1) ? CY_CRYPTO_VU1_CLSAME_OPC : CY_CRYPTO_VU2_CLSAME_OPC) << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((CY_CRYPTO_HW_V1) ? CY_CRYPTO_VU1_CLSAME_OPC : CY_CRYPTO_VU2_CLSAME_OPC) << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_CLSAME (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -633,11 +634,11 @@ __STATIC_INLINE void CY_CRYPTO_VU_CLSAME (CRYPTO_Type *base, uint32_t rdst, uint __STATIC_INLINE void CY_CRYPTO_VU_COND_CTSAME (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) { - REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((cy_device->cryptoVersion == 1) ? CY_CRYPTO_VU1_CTSAME_OPC : CY_CRYPTO_VU2_CTSAME_OPC) << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((CY_CRYPTO_HW_V1) ? CY_CRYPTO_VU1_CTSAME_OPC : CY_CRYPTO_VU2_CTSAME_OPC) << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_CTSAME (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -647,10 +648,10 @@ __STATIC_INLINE void CY_CRYPTO_VU_CTSAME (CRYPTO_Type *base, uint32_t rdst, uint __STATIC_INLINE void CY_CRYPTO_VU_COND_SET_BIT (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc) { - REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((cy_device->cryptoVersion == 1) ? CY_CRYPTO_VU1_SET_BIT_OPC : CY_CRYPTO_VU2_SET_BIT_OPC) << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((CY_CRYPTO_HW_V1) ? CY_CRYPTO_VU1_SET_BIT_OPC : CY_CRYPTO_VU2_SET_BIT_OPC) << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | - (uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_SET_BIT (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc) @@ -660,10 +661,10 @@ __STATIC_INLINE void CY_CRYPTO_VU_SET_BIT (CRYPTO_Type *base, uint32_t rdst, uin __STATIC_INLINE void CY_CRYPTO_VU_COND_CLR_BIT (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc) { - REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((cy_device->cryptoVersion == 1) ? CY_CRYPTO_VU1_CLR_BIT_OPC : CY_CRYPTO_VU2_CLR_BIT_OPC) << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((CY_CRYPTO_HW_V1) ? CY_CRYPTO_VU1_CLR_BIT_OPC : CY_CRYPTO_VU2_CLR_BIT_OPC) << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | - (uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_CLR_BIT (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc) @@ -673,10 +674,10 @@ __STATIC_INLINE void CY_CRYPTO_VU_CLR_BIT (CRYPTO_Type *base, uint32_t rdst, uin __STATIC_INLINE void CY_CRYPTO_VU_COND_INV_BIT (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc) { - REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((cy_device->cryptoVersion == 1) ? CY_CRYPTO_VU1_INV_BIT_OPC : CY_CRYPTO_VU2_INV_BIT_OPC) << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((CY_CRYPTO_HW_V1) ? CY_CRYPTO_VU1_INV_BIT_OPC : CY_CRYPTO_VU2_INV_BIT_OPC) << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | - (uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_INV_BIT (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc) @@ -686,11 +687,11 @@ __STATIC_INLINE void CY_CRYPTO_VU_INV_BIT (CRYPTO_Type *base, uint32_t rdst, uin __STATIC_INLINE void CY_CRYPTO_VU_COND_GET_BIT (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) { - REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((cy_device->cryptoVersion == 1) ? CY_CRYPTO_VU1_GET_BIT_OPC : CY_CRYPTO_VU2_GET_BIT_OPC) << CY_CRYPTO_OPCODE_POS) | + REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)((CY_CRYPTO_HW_V1) ? CY_CRYPTO_VU1_GET_BIT_OPC : CY_CRYPTO_VU2_GET_BIT_OPC) << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_GET_BIT (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -701,17 +702,18 @@ __STATIC_INLINE void CY_CRYPTO_VU_GET_BIT (CRYPTO_Type *base, uint32_t rdst, uin /******************************************************************************/ __STATIC_INLINE void CY_CRYPTO_VU_COND_SET_BIT_IMM (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t imm13) { - if (cy_device->cryptoVersion == 1) + if (CY_CRYPTO_HW_V1) { /******** V1 ********/ - int tmp_reg = (rdst != CY_CRYPTO_VU_HW_REG14) ? CY_CRYPTO_VU_HW_REG14 : CY_CRYPTO_VU_HW_REG13; - uint32_t tmp_data; - CY_CRYPTO_VU_SAVE_REG(base, tmp_reg, &tmp_data); + uint32_t tmpReg = (rdst != CY_CRYPTO_VU_HW_REG14) ? CY_CRYPTO_VU_HW_REG14 : CY_CRYPTO_VU_HW_REG13; + uint32_t tmpData; + CY_CRYPTO_VU_SAVE_REG(base, tmpReg, &tmpData); - CY_CRYPTO_VU_SET_REG(base, tmp_reg, imm13, 13); - CY_CRYPTO_VU_COND_SET_BIT(base, cc, rdst, tmp_reg); + /* Load 13 bit immediate value */ + CY_CRYPTO_VU_SET_REG(base, tmpReg, imm13, 13u); + CY_CRYPTO_VU_COND_SET_BIT(base, cc, rdst, tmpReg); - CY_CRYPTO_VU_RESTORE_REG(base, tmp_reg, tmp_data); + CY_CRYPTO_VU_RESTORE_REG(base, tmpReg, tmpData); } else { @@ -719,7 +721,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_SET_BIT_IMM (CRYPTO_Type *base, uint32_t REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU2_SET_BIT_IMM_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC16_SHIFT) | - (uint32_t)imm13 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)imm13 << CY_CRYPTO_RSRC0_SHIFT)); } } @@ -730,17 +732,18 @@ __STATIC_INLINE void CY_CRYPTO_VU_SET_BIT_IMM (CRYPTO_Type *base, uint32_t rdst, __STATIC_INLINE void CY_CRYPTO_VU_COND_CLR_BIT_IMM (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t imm13) { - if (cy_device->cryptoVersion == 1) + if (CY_CRYPTO_HW_V1) { /******** V1 ********/ - int tmp_reg = (rdst != CY_CRYPTO_VU_HW_REG14) ? CY_CRYPTO_VU_HW_REG14 : CY_CRYPTO_VU_HW_REG13; - uint32_t tmp_data; - CY_CRYPTO_VU_SAVE_REG(base, tmp_reg, &tmp_data); + uint32_t tmpReg = (rdst != CY_CRYPTO_VU_HW_REG14) ? CY_CRYPTO_VU_HW_REG14 : CY_CRYPTO_VU_HW_REG13; + uint32_t tmpData; + CY_CRYPTO_VU_SAVE_REG(base, tmpReg, &tmpData); - CY_CRYPTO_VU_SET_REG(base, tmp_reg, imm13, 13); - CY_CRYPTO_VU_COND_CLR_BIT(base, cc, rdst, tmp_reg); + /* Load 13 bit immediate value */ + CY_CRYPTO_VU_SET_REG(base, tmpReg, imm13, 13u); + CY_CRYPTO_VU_COND_CLR_BIT(base, cc, rdst, tmpReg); - CY_CRYPTO_VU_RESTORE_REG(base, tmp_reg, tmp_data); + CY_CRYPTO_VU_RESTORE_REG(base, tmpReg, tmpData); } else { @@ -748,7 +751,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_CLR_BIT_IMM (CRYPTO_Type *base, uint32_t REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU2_CLR_BIT_IMM_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC16_SHIFT) | - (uint32_t)imm13 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)imm13 << CY_CRYPTO_RSRC0_SHIFT)); } } @@ -759,17 +762,18 @@ __STATIC_INLINE void CY_CRYPTO_VU_CLR_BIT_IMM (CRYPTO_Type *base, uint32_t rdst, __STATIC_INLINE void CY_CRYPTO_VU_COND_INV_BIT_IMM (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t imm13) { - if (cy_device->cryptoVersion == 1) + if (CY_CRYPTO_HW_V1) { /******** V1 ********/ - int tmp_reg = (rdst != CY_CRYPTO_VU_HW_REG14) ? CY_CRYPTO_VU_HW_REG14 : CY_CRYPTO_VU_HW_REG13; - uint32_t tmp_data; - CY_CRYPTO_VU_SAVE_REG(base, tmp_reg, &tmp_data); + uint32_t tmpReg = (rdst != CY_CRYPTO_VU_HW_REG14) ? CY_CRYPTO_VU_HW_REG14 : CY_CRYPTO_VU_HW_REG13; + uint32_t tmpData; + CY_CRYPTO_VU_SAVE_REG(base, tmpReg, &tmpData); - CY_CRYPTO_VU_SET_REG(base, tmp_reg, imm13, 13); - CY_CRYPTO_VU_COND_INV_BIT(base, cc, rdst, tmp_reg); + /* Load 13 bit immediate value */ + CY_CRYPTO_VU_SET_REG(base, tmpReg, imm13, 13u); + CY_CRYPTO_VU_COND_INV_BIT(base, cc, rdst, tmpReg); - CY_CRYPTO_VU_RESTORE_REG(base, tmp_reg, tmp_data); + CY_CRYPTO_VU_RESTORE_REG(base, tmpReg, tmpData); } else { @@ -777,7 +781,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_INV_BIT_IMM (CRYPTO_Type *base, uint32_t REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU2_INV_BIT_IMM_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC16_SHIFT) | - (uint32_t)imm13 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)imm13 << CY_CRYPTO_RSRC0_SHIFT)); } } @@ -791,7 +795,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_TST (CRYPTO_Type *base, uint32_t cc, uint { REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_TST_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | - (uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_TST (CRYPTO_Type *base, uint32_t rsrc) @@ -804,7 +808,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_MOV (CRYPTO_Type *base, uint32_t cc, uint REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_MOV_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | - (uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_MOV (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc) @@ -817,7 +821,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_XSQUARE (CRYPTO_Type *base, uint32_t cc, REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_XSQUARE_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | - (uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_XSQUARE (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc) @@ -831,7 +835,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_XMUL (CRYPTO_Type *base, uint32_t cc, uin ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_XMUL (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -846,7 +850,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_UMUL (CRYPTO_Type *base, uint32_t cc, uin ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_UMUL (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -856,7 +860,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_UMUL (CRYPTO_Type *base, uint32_t rdst, uint32 __STATIC_INLINE void CY_CRYPTO_VU_COND_USQUARE (CRYPTO_Type *base, uint32_t cc, uint32_t rdst, uint32_t rsrc) { - if (cy_device->cryptoVersion == 1) + if (CY_CRYPTO_HW_V1) { /***** V1 *******/ CY_CRYPTO_VU_COND_UMUL(base, cc, rdst, rsrc, rsrc); @@ -867,7 +871,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_USQUARE (CRYPTO_Type *base, uint32_t cc, REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU2_USQUARE_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | - (uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc << CY_CRYPTO_RSRC0_SHIFT)); } } @@ -906,7 +910,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_ADD (CRYPTO_Type *base, uint32_t cc, uint ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_ADD (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -920,7 +924,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_SUB (CRYPTO_Type *base, uint32_t cc, uint ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_SUB (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -934,7 +938,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_OR (CRYPTO_Type *base, uint32_t cc, uint3 ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_OR (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -948,7 +952,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_AND (CRYPTO_Type *base, uint32_t cc, uint ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_AND (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -962,7 +966,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_XOR (CRYPTO_Type *base, uint32_t cc, uint ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_XOR (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -976,7 +980,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_NOR (CRYPTO_Type *base, uint32_t cc, uint ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_NOR (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -990,7 +994,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_NAND (CRYPTO_Type *base, uint32_t cc, uin ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rdst << CY_CRYPTO_RSRC12_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_NAND (CRYPTO_Type *base, uint32_t rdst, uint32_t rsrc1, uint32_t rsrc0) @@ -1003,7 +1007,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_CMP_SUB (CRYPTO_Type *base, uint32_t cc, REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_CMP_SUB_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_CMP_SUB (CRYPTO_Type *base, uint32_t rsrc1, uint32_t rsrc0) @@ -1016,7 +1020,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_COND_CMP_DEGREE (CRYPTO_Type *base, uint32_t c REG_CRYPTO_INSTR_FF_WR(base) = (((uint32_t)CY_CRYPTO_VU_CMP_DEGREE_OPC << CY_CRYPTO_OPCODE_POS) | ((uint32_t)cc << CY_CRYPTO_RSRC20_SHIFT) | ((uint32_t)rsrc1 << CY_CRYPTO_RSRC4_SHIFT) | - (uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT); + ((uint32_t)rsrc0 << CY_CRYPTO_RSRC0_SHIFT)); } __STATIC_INLINE void CY_CRYPTO_VU_CMP_DEGREE (CRYPTO_Type *base, uint32_t rsrc1, uint32_t rsrc0) @@ -1031,7 +1035,7 @@ __STATIC_INLINE void CY_CRYPTO_VU_SAVE_REG (CRYPTO_Type *base, uint32_t rsrc, ui __STATIC_INLINE void CY_CRYPTO_VU_RESTORE_REG (CRYPTO_Type *base, uint32_t rdst, uint32_t data) { - CY_CRYPTO_VU_SET_REG(base, rdst, CY_CRYPTO_VU_GET_REG_DATA(data), CY_CRYPTO_VU_GET_REG_SIZE(data) + 1); + CY_CRYPTO_VU_SET_REG(base, rdst, CY_CRYPTO_VU_GET_REG_DATA(data), CY_CRYPTO_VU_GET_REG_SIZE(data) + 1u); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_mem.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_mem.h index 2e7f548619..f779b43e4c 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_mem.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_mem.h @@ -44,6 +44,11 @@ typedef uint32_t (*cy_crypto_memcmp_func_t)(CRYPTO_Type *base, typedef void (*cy_crypto_memxor_func_t)(CRYPTO_Type *base, void* dst, void const *src0, void const *src1, uint16_t size); +/** +* \addtogroup group_crypto_lld_mem_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_MemCpy ****************************************************************************//** @@ -53,7 +58,7 @@ typedef void (*cy_crypto_memxor_func_t)(CRYPTO_Type *base, void* dst, * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dst * The pointer to the destination of MemCpy. @@ -67,7 +72,7 @@ typedef void (*cy_crypto_memxor_func_t)(CRYPTO_Type *base, void* dst, *******************************************************************************/ __STATIC_INLINE void Cy_Crypto_Core_MemCpy(CRYPTO_Type *base, void* dst, void const *src, uint16_t size) { - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { Cy_Crypto_Core_V1_MemCpy(base, dst, src, size); } @@ -85,7 +90,7 @@ __STATIC_INLINE void Cy_Crypto_Core_MemCpy(CRYPTO_Type *base, void* dst, void co * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dst * The pointer to the destination of MemSet. @@ -99,7 +104,7 @@ __STATIC_INLINE void Cy_Crypto_Core_MemCpy(CRYPTO_Type *base, void* dst, void co *******************************************************************************/ __STATIC_INLINE void Cy_Crypto_Core_MemSet(CRYPTO_Type *base, void* dst, uint8_t data, uint16_t size) { - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { Cy_Crypto_Core_V1_MemSet(base, dst, data, size); } @@ -117,7 +122,7 @@ __STATIC_INLINE void Cy_Crypto_Core_MemSet(CRYPTO_Type *base, void* dst, uint8_t * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param src0 * The pointer to the first source of MemCmp. @@ -134,17 +139,17 @@ __STATIC_INLINE void Cy_Crypto_Core_MemSet(CRYPTO_Type *base, void* dst, uint8_t *******************************************************************************/ __STATIC_INLINE uint32_t Cy_Crypto_Core_MemCmp(CRYPTO_Type *base, void const *src0, void const *src1, uint16_t size) { - uint32_t result; - if (cy_device->cryptoVersion == 1u) + uint32_t tmpResult; + if (CY_CRYPTO_HW_V1) { - result = Cy_Crypto_Core_V1_MemCmp(base, src0, src1, size); + tmpResult = Cy_Crypto_Core_V1_MemCmp(base, src0, src1, size); } else { - result = Cy_Crypto_Core_V2_MemCmp(base, src0, src1, size); + tmpResult = Cy_Crypto_Core_V2_MemCmp(base, src0, src1, size); } - return (result); + return (tmpResult); } /******************************************************************************* @@ -156,7 +161,7 @@ __STATIC_INLINE uint32_t Cy_Crypto_Core_MemCmp(CRYPTO_Type *base, void const *sr * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dst * The pointer to the destination of MemXor. @@ -174,7 +179,7 @@ __STATIC_INLINE uint32_t Cy_Crypto_Core_MemCmp(CRYPTO_Type *base, void const *sr __STATIC_INLINE void Cy_Crypto_Core_MemXor(CRYPTO_Type *base, void* dst, void const *src0, void const *src1, uint16_t size) { - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { Cy_Crypto_Core_V1_MemXor(base, dst, src0, src1, size); } @@ -184,6 +189,7 @@ __STATIC_INLINE void Cy_Crypto_Core_MemXor(CRYPTO_Type *base, void* dst, } } +/** \} group_crypto_lld_mem_functions */ #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_prng.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_prng.h index cad1b88604..fcdf41a24b 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_prng.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_prng.h @@ -45,6 +45,11 @@ typedef cy_en_crypto_status_t (*cy_crypto_prng_func_t)(CRYPTO_Type *base, uint32_t max, uint32_t *randomNum); +/** +* \addtogroup group_crypto_lld_rng_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_Prng_Init ****************************************************************************//** @@ -53,7 +58,7 @@ typedef cy_en_crypto_status_t (*cy_crypto_prng_func_t)(CRYPTO_Type *base, * Invoking this function causes a restart of the pseudo-random sequence. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param lfsr32InitState * A non-zero seed value for the first LFSR. @@ -65,7 +70,7 @@ typedef cy_en_crypto_status_t (*cy_crypto_prng_func_t)(CRYPTO_Type *base, * A non-zero seed value for the third LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Prng_Init(CRYPTO_Type *base, @@ -73,18 +78,18 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Prng_Init(CRYPTO_Type *base uint32_t lfsr31InitState, uint32_t lfsr29InitState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Prng_Init(base, lfsr32InitState, lfsr31InitState, lfsr29InitState); + tmpResult = Cy_Crypto_Core_V1_Prng_Init(base, lfsr32InitState, lfsr31InitState, lfsr29InitState); } else { - myResult = Cy_Crypto_Core_V2_Prng_Init(base, lfsr32InitState, lfsr31InitState, lfsr29InitState); + tmpResult = Cy_Crypto_Core_V2_Prng_Init(base, lfsr32InitState, lfsr31InitState, lfsr29InitState); } - return myResult; + return tmpResult; } /******************************************************************************* @@ -94,7 +99,7 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Prng_Init(CRYPTO_Type *base * Generates a Pseudo Random Number. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param max * The maximum value of a random number. @@ -103,27 +108,29 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Prng_Init(CRYPTO_Type *base * The pointer to a variable to store the generated pseudo random number. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Prng(CRYPTO_Type *base, uint32_t max, uint32_t *randomNum) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Prng(base, max, randomNum); + tmpResult = Cy_Crypto_Core_V1_Prng(base, max, randomNum); } else { - myResult = Cy_Crypto_Core_V2_Prng(base, max, randomNum); + tmpResult = Cy_Crypto_Core_V2_Prng(base, max, randomNum); } - return myResult; + return tmpResult; } +/** \} group_crypto_lld_rng_functions */ + #endif /* #if (CPUSS_CRYPTO_PR == 1) */ #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha.h index 783b54c06f..caf2e587fe 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha.h @@ -42,6 +42,11 @@ typedef cy_en_crypto_status_t (*cy_crypto_sha_func_t)(CRYPTO_Type *base, uint8_t *digest, cy_en_crypto_sha_mode_t mode); +/** +* \addtogroup group_crypto_lld_sha_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_Sha ****************************************************************************//** @@ -49,22 +54,22 @@ typedef cy_en_crypto_status_t (*cy_crypto_sha_func_t)(CRYPTO_Type *base, * Performs the SHA Hash function. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param mode * \ref cy_en_crypto_sha_mode_t * * \param message -* The pointer to a message whose hash value is being computed. +* The pointer to the message whose hash value is being computed. * * \param messageSize -* The size of a message. +* The size of the message. * * \param digest * The pointer to the hash digest. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha(CRYPTO_Type *base, @@ -73,41 +78,41 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha(CRYPTO_Type *base, uint8_t *digest, cy_en_crypto_sha_mode_t mode) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Sha(base, message, messageSize, digest, mode); + tmpResult = Cy_Crypto_Core_V1_Sha(base, message, messageSize, digest, mode); } else { - myResult = Cy_Crypto_Core_V2_Sha(base, message, messageSize, digest, mode); + tmpResult = Cy_Crypto_Core_V2_Sha(base, message, messageSize, digest, mode); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Sha_Init ****************************************************************************//** * -* The function to initialize SHA operation. +* The function to initialize the SHA operation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param shaHashState -* The pointer to a Hash State. +* The pointer to a Hash state. * * \param mode * One of these: CY_CRYPTO_SHA256, CY_CRYPTO_SHA1, CY_CRYPTO_SHA256_224, * CY_CRYPTO_SHA512, CY_CRYPTO_SHA384, CY_CRYPTO_SHA512_224, CY_CRYPTO_SHA512_256 * * \param shaBuffers -* The pointer to memory buffers storage +* The pointer to the memory buffers storage. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Init(CRYPTO_Type *base, @@ -115,50 +120,50 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Init(CRYPTO_Type *base, cy_en_crypto_sha_mode_t mode, void *shaBuffers) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Sha_Init(base, shaHashState, mode, shaBuffers); + tmpResult = Cy_Crypto_Core_V1_Sha_Init(base, shaHashState, mode, shaBuffers); } else { - myResult = Cy_Crypto_Core_V2_Sha_Init(base, shaHashState, mode, shaBuffers); + tmpResult = Cy_Crypto_Core_V2_Sha_Init(base, shaHashState, mode, shaBuffers); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_Sha_Start ****************************************************************************//** * -* Initializes the initial hash vector. +* Initializes the initial Hash vector. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Start(CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Sha_Start(base, hashState); + tmpResult = Cy_Crypto_Core_V1_Sha_Start(base, hashState); } else { - myResult = Cy_Crypto_Core_V2_Sha_Start(base, hashState); + tmpResult = Cy_Crypto_Core_V2_Sha_Start(base, hashState); } - return myResult; + return tmpResult; } /******************************************************************************* @@ -168,7 +173,7 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Start(CRYPTO_Type *base * Performs the SHA calculation on one message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. @@ -180,12 +185,12 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Start(CRYPTO_Type *base * The size of the message whose Hash is being computed. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \note * This function can be called several times only with message lengths dividable -* by block size. Only the last call to the function can process a message with -* the not dividable size. +* by the block size. Only the last call to the function can process a message with +* a not-dividable size. * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Update(CRYPTO_Type *base, @@ -193,55 +198,55 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Update(CRYPTO_Type *bas uint8_t const *message, uint32_t messageSize) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Sha_Update(base, hashState, message, messageSize); + tmpResult = Cy_Crypto_Core_V1_Sha_Update(base, hashState, message, messageSize); } else { - myResult = Cy_Crypto_Core_V2_Sha_Update(base, hashState, message, messageSize); + tmpResult = Cy_Crypto_Core_V2_Sha_Update(base, hashState, message, messageSize); } - return myResult; + return tmpResult; } /******************************************************************************* * Function Name: Cy_Crypto_Core_V1_Sha_Finish ****************************************************************************//** * -* Completes SHA calculation. +* Completes the SHA calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. * * \param digest -* The pointer to the calculated hash digest. +* The pointer to the calculated Hash digest. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Finish(CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState, uint8_t *digest) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Sha_Finish(base, hashState, digest); + tmpResult = Cy_Crypto_Core_V1_Sha_Finish(base, hashState, digest); } else { - myResult = Cy_Crypto_Core_V2_Sha_Finish(base, hashState, digest); + tmpResult = Cy_Crypto_Core_V2_Sha_Finish(base, hashState, digest); } - return myResult; + return tmpResult; } /******************************************************************************* @@ -251,31 +256,32 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Finish(CRYPTO_Type *bas * Clears the used memory buffers. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Sha_Free(CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState) { - cy_en_crypto_status_t myResult; + cy_en_crypto_status_t tmpResult; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { - myResult = Cy_Crypto_Core_V1_Sha_Free(base, hashState); + tmpResult = Cy_Crypto_Core_V1_Sha_Free(base, hashState); } else { - myResult = Cy_Crypto_Core_V2_Sha_Free(base, hashState); + tmpResult = Cy_Crypto_Core_V2_Sha_Free(base, hashState); } - return myResult; + return tmpResult; } +/** \} group_crypto_lld_sha_functions */ #endif /* #if (CPUSS_CRYPTO_SHA == 1) */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha_v1.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha_v1.h index ec23625dc0..621272f47e 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha_v1.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha_v1.h @@ -38,37 +38,37 @@ typedef struct { - /* Allocate CRYPTO_MAX_BLOCK_SIZE Bytes for block */ + /* Allocates CRYPTO_MAX_BLOCK_SIZE Bytes for the block. */ uint32_t block[CY_CRYPTO_SHA1_BLOCK_SIZE / 4u]; - /* Allocate CRYPTO_MAX_HASH_SIZE Bytes for hash */ + /* Allocates CRYPTO_MAX_HASH_SIZE Bytes for the hash. */ uint32_t hash[CY_CRYPTO_SHA1_HASH_SIZE / 4u]; - /* Allocate CRYPTO_MAX_ROUND_MEM_SIZE Bytes for roundMem */ + /* Allocates CRYPTO_MAX_ROUND_MEM_SIZE Bytes for roundMem. */ uint32_t roundMem[CY_CRYPTO_SHA1_ROUND_MEM_SIZE / 4u]; } cy_stc_crypto_v1_sha1_buffers_t; typedef struct { - /* Allocate CRYPTO_MAX_BLOCK_SIZE Bytes for block */ + /* Allocates CRYPTO_MAX_BLOCK_SIZE Bytes for the block. */ uint32_t block[CY_CRYPTO_SHA256_BLOCK_SIZE / 4u]; - /* Allocate CRYPTO_MAX_HASH_SIZE Bytes for hash */ + /* Allocates CRYPTO_MAX_HASH_SIZE Bytes for the hash. */ uint32_t hash[CY_CRYPTO_SHA256_HASH_SIZE / 4u]; - /* Allocate CRYPTO_MAX_ROUND_MEM_SIZE Bytes for roundMem */ + /* Allocates CRYPTO_MAX_ROUND_MEM_SIZE Bytes for roundMem. */ uint32_t roundMem[CY_CRYPTO_SHA256_ROUND_MEM_SIZE / 4u]; } cy_stc_crypto_v1_sha256_buffers_t; typedef struct { - /* Allocate CRYPTO_MAX_BLOCK_SIZE Bytes for block */ + /* Allocates CRYPTO_MAX_BLOCK_SIZE Bytes for the block. */ uint32_t block[CY_CRYPTO_SHA512_BLOCK_SIZE / 4u]; - /* Allocate CRYPTO_MAX_HASH_SIZE Bytes for hash */ + /* Allocates CRYPTO_MAX_HASH_SIZE Bytes for the hash. */ uint32_t hash[CY_CRYPTO_SHA512_HASH_SIZE / 4u]; - /* Allocate CRYPTO_MAX_ROUND_MEM_SIZE Bytes for roundMem */ + /* Allocates CRYPTO_MAX_ROUND_MEM_SIZE Bytes for roundMem. */ uint32_t roundMem[CY_CRYPTO_SHA512_ROUND_MEM_SIZE / 4u]; } cy_stc_crypto_v1_sha512_buffers_t; diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha_v2.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha_v2.h index 720dd31d9d..11e842b0e0 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha_v2.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_sha_v2.h @@ -38,7 +38,7 @@ /** \cond INTERNAL */ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Init(CRYPTO_Type *base, - cy_stc_crypto_sha_state_t *shaHashState, + cy_stc_crypto_sha_state_t *hashState, cy_en_crypto_sha_mode_t mode, void *shaBuffers); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng.h index a9c234fd94..def797749e 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng.h @@ -42,15 +42,19 @@ typedef cy_en_crypto_status_t (*cy_crypto_trng_func_t)(CRYPTO_Type *base, uint32_t max, uint32_t *randomNum); +/** +* \addtogroup group_crypto_lld_rng_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_Trng ****************************************************************************//** * -* Generates a True Random Number and returns it in the -* cfContext->trngNumPtr. +* Generates a True Random Number. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param GAROPol * The polynomial for the programmable Galois ring oscillator. @@ -59,13 +63,13 @@ typedef cy_en_crypto_status_t (*cy_crypto_trng_func_t)(CRYPTO_Type *base, * The polynomial for the programmable Fibonacci ring oscillator. * * \param max -* The maximum length of a random number, in the range [0, 32] bits. +* The maximum length of a random number, in the range of [0, 32] bits. * * \param randomNum * The pointer to a generated true random number. Must be 4-byte aligned. * * \return -* A Crypto status \ref en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Trng(CRYPTO_Type *base, @@ -74,18 +78,19 @@ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Trng(CRYPTO_Type *base, uint32_t max, uint32_t *randomNum) { - cy_en_crypto_status_t result; - if (cy_device->cryptoVersion == 1u) + cy_en_crypto_status_t tmpResult; + if (CY_CRYPTO_HW_V1) { - result = Cy_Crypto_Core_V1_Trng(base, GAROPol, FIROPol, max, randomNum); + tmpResult = Cy_Crypto_Core_V1_Trng(base, GAROPol, FIROPol, max, randomNum); } else { - result = Cy_Crypto_Core_V2_Trng(base, GAROPol, FIROPol, max, randomNum); + tmpResult = Cy_Crypto_Core_V2_Trng(base, GAROPol, FIROPol, max, randomNum); } - return (result); + return (tmpResult); } +/** \} group_crypto_lld_rng_functions */ #endif /* #if (CPUSS_CRYPTO_TR == 1) */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_config_v1.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_config_v1.h index 065c5672de..0eb516b9b3 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_config_v1.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_config_v1.h @@ -182,11 +182,11 @@ #define CY_CRYPTO_V1_TR_CUTOFF_COUNT8 (1UL) /** -Cut-off count (legal range is [1, 65535]). -"0": Illegal. -"1": 1 occurrence. -... -"65535": 65535 occurrences. +* Cut-off count (legal range is [1, 65535]). +* "0": Illegal. +* "1": 1 occurrence. +* ... +* "65535": 65535 occurrences. */ #define CY_CRYPTO_V1_TR_CUTOFF_COUNT16 (1UL) @@ -196,9 +196,9 @@ Cut-off count (legal range is [1, 65535]). * ... * "65535": 65536 bits. */ -#define CY_CRYPTO_V1_TR_WINDOW_SIZE (1uL) +#define CY_CRYPTO_V1_TR_WINDOW_SIZE (1UL) -/** the composed value for the TR_CTL0 register */ +/** The composed value for the TR_CTL0 register */ #define CY_CRYPTO_V1_TR_CTL0_VAL (_VAL2FLD(CRYPTO_TR_CTL0_SAMPLE_CLOCK_DIV, CY_CRYPTO_V1_TR_SAMPLE_CLOCK_DIV) | \ _VAL2FLD(CRYPTO_TR_CTL0_RED_CLOCK_DIV, CY_CRYPTO_V1_TR_RED_CLOCK_DIV) | \ _VAL2FLD(CRYPTO_TR_CTL0_INIT_DELAY, CY_CRYPTO_V1_TR_INIT_DELAY) | \ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_config_v2.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_config_v2.h index b193efdfbc..165b12aeb7 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_config_v2.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_config_v2.h @@ -182,11 +182,11 @@ #define CY_CRYPTO_V2_TR_CUTOFF_COUNT8 (1UL) /** -Cut-off count (legal range is [1, 65535]). -"0": Illegal. -"1": 1 occurrence. -... -"65535": 65535 occurrences. +* Cut-off count (legal range is [1, 65535]). +* "0": Illegal. +* "1": 1 occurrence. +* ... +* "65535": 65535 occurrences. */ #define CY_CRYPTO_V2_TR_CUTOFF_COUNT16 (1UL) @@ -196,9 +196,9 @@ Cut-off count (legal range is [1, 65535]). * ... * "65535": 65536 bits. */ -#define CY_CRYPTO_V2_TR_WINDOW_SIZE (1uL) +#define CY_CRYPTO_V2_TR_WINDOW_SIZE (1UL) -/** the composed value for the TR_CTL0 register */ +/** The composed value for the TR_CTL0 register */ #define CY_CRYPTO_V2_TR_CTL0_VAL (_VAL2FLD(CRYPTO_TR_CTL0_SAMPLE_CLOCK_DIV, CY_CRYPTO_V2_TR_SAMPLE_CLOCK_DIV) | \ _VAL2FLD(CRYPTO_TR_CTL0_RED_CLOCK_DIV, CY_CRYPTO_V2_TR_RED_CLOCK_DIV) | \ _VAL2FLD(CRYPTO_TR_CTL0_INIT_DELAY, CY_CRYPTO_V2_TR_INIT_DELAY) | \ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_v1.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_v1.h index ad6b4b1a49..b4d79349ec 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_v1.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_trng_v1.h @@ -46,7 +46,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Trng(CRYPTO_Type *base, #endif /* CY_IP_MXCRYPTO */ -#endif /* #if !defined(CY_CRYPTO_CORE_TRNG_H) */ +#endif /* #if !defined(CY_CRYPTO_CORE_TRNG_V1_H) */ /* [] END OF FILE */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_vu.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_vu.h index 27cbdd49e9..c0741a4a27 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_vu.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_core_vu.h @@ -41,17 +41,22 @@ #define CY_CRYPTO_VU_DATA_FLD_MASK (0x00003fffuL) #define CY_CRYPTO_VU_DATA_FLD_POS (16u) +/** +* \addtogroup group_crypto_lld_vu_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_Cleanup ****************************************************************************//** * -* Cleanup the the CRYPTO block. +* Cleans up the Crypto block. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_Cleanup(CRYPTO_Type *base); @@ -60,10 +65,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_Cleanup(CRYPTO_Type *base); * Function Name: Cy_Crypto_Core_Vu_SetMemValue ****************************************************************************//** * -* Sets the value in the crypto memory allocated by destination VU register. +* Sets the value in the Crypto memory allocated by the destination VU register. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dstReg * The destination vector unit register. @@ -84,7 +89,7 @@ void Cy_Crypto_Core_Vu_SetMemValue(CRYPTO_Type *base, uint32_t dstReg, uint8_t c * Gets the value located in the crypto memory and pointed by source VU register. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dst * The pointer to the destination value. @@ -102,10 +107,10 @@ void Cy_Crypto_Core_Vu_GetMemValue(CRYPTO_Type *base, uint8_t *dst, uint32_t src * Function Name: Cy_Crypto_Core_Vu_IsRegZero ****************************************************************************//** * -* Returns TRUE if srcReg contains 0. FALSE otherwise. +* Returns TRUE if srcReg contains 0. FALSE - otherwise. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcReg * The source vector unit register. @@ -120,10 +125,10 @@ bool Cy_Crypto_Core_Vu_IsRegZero(CRYPTO_Type *base, uint32_t srcReg); * Function Name: Cy_Crypto_Core_Vu_IsRegEqual ****************************************************************************//** * -* Returns TRUE if srcReg0 contains the same value as srcReg1. FALSE otherwise. +* Returns TRUE if srcReg0 contains the same value as srcReg1. FALSE - otherwise. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcReg0 * The source 0 vector unit register. @@ -142,10 +147,10 @@ bool Cy_Crypto_Core_Vu_IsRegEqual(CRYPTO_Type *base, uint32_t srcReg0, uint32_t ****************************************************************************//** * * Returns TRUE if srcReg0 contains the value less than value of srcReg1. -* FALSE otherwise. +* FALSE - otherwise. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcReg0 * The source 0 vector unit register. @@ -163,10 +168,10 @@ bool Cy_Crypto_Core_Vu_IsRegLess(CRYPTO_Type *base, uint32_t srcReg0, uint32_t s * Function Name: Cy_Crypto_Core_Vu_RegRead ****************************************************************************//** * -* Returns the data pointed in given register +* Returns the data pointed in a given register. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcReg * The source vector unit register. @@ -185,7 +190,7 @@ __STATIC_INLINE uint32_t Cy_Crypto_Core_Vu_RegRead(CRYPTO_Type *base, uint32_t s * it is lower 12Bit of the 32Bit word * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcReg * The source vector unit register. @@ -204,7 +209,7 @@ __STATIC_INLINE uint16_t Cy_Crypto_Core_Vu_RegSizeRead(CRYPTO_Type *base, uint32 * It is lower 12Bit of the 32Bit word * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcReg * The source vector unit register. @@ -223,7 +228,7 @@ __STATIC_INLINE uint16_t Cy_Crypto_Core_Vu_RegBitSizeRead(CRYPTO_Type *base, uin * It is lower 12Bit of the 32Bit word * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcReg * The source vector unit register. @@ -242,7 +247,7 @@ __STATIC_INLINE uint16_t Cy_Crypto_Core_Vu_RegByteSizeRead(CRYPTO_Type *base, ui * It is lower 12Bit of the 32Bit word * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcReg * The source vector unit register. @@ -261,7 +266,7 @@ __STATIC_INLINE uint16_t Cy_Crypto_Core_Vu_RegWordSizeRead(CRYPTO_Type *base, ui * it is upper 16Bit of the 32Bir word. Pointer is in words (uint32_t). * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcReg * The source vector unit register. @@ -269,7 +274,7 @@ __STATIC_INLINE uint16_t Cy_Crypto_Core_Vu_RegWordSizeRead(CRYPTO_Type *base, ui *******************************************************************************/ __STATIC_INLINE uint16_t Cy_Crypto_Core_Vu_RegDataPtrRead(CRYPTO_Type *base, uint32_t srcReg) { - return ((uint16_t)(_FLD2VAL(CRYPTO_RF_DATA_DATA32, REG_CRYPTO_VU_RF_DATA(base, srcReg)) >> CY_CRYPTO_VU_DATA_FLD_POS) + return (uint16_t)((_FLD2VAL(CRYPTO_RF_DATA_DATA32, REG_CRYPTO_VU_RF_DATA(base, srcReg)) >> CY_CRYPTO_VU_DATA_FLD_POS) & CY_CRYPTO_VU_DATA_FLD_MASK); } @@ -280,7 +285,7 @@ __STATIC_INLINE uint16_t Cy_Crypto_Core_Vu_RegDataPtrRead(CRYPTO_Type *base, uin * Returns the memory address of the data pointed in given register. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcReg * The source vector unit register. @@ -288,7 +293,7 @@ __STATIC_INLINE uint16_t Cy_Crypto_Core_Vu_RegDataPtrRead(CRYPTO_Type *base, uin *******************************************************************************/ __STATIC_INLINE uint32_t * Cy_Crypto_Core_Vu_RegMemPointer(CRYPTO_Type *base, uint32_t srcReg) { - return (uint32_t *)((uint32_t)REG_CRYPTO_MEM_BUFF(base) + 4u * (uint32_t)Cy_Crypto_Core_Vu_RegDataPtrRead(base, srcReg)); + return (uint32_t *)((uint32_t)REG_CRYPTO_MEM_BUFF(base) + (4u * (uint32_t)Cy_Crypto_Core_Vu_RegDataPtrRead(base, srcReg))); } /******************************************************************************* @@ -298,13 +303,13 @@ __STATIC_INLINE uint32_t * Cy_Crypto_Core_Vu_RegMemPointer(CRYPTO_Type *base, ui * Waits until VU instruction will be completed * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * *******************************************************************************/ __STATIC_INLINE void Cy_Crypto_Core_Vu_WaitForComplete(CRYPTO_Type *base) { /* Wait until the VU instruction is complete */ - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { while (0uL != _FLD2VAL(CRYPTO_STATUS_VU_BUSY, REG_CRYPTO_STATUS(base))) { @@ -322,19 +327,20 @@ __STATIC_INLINE void Cy_Crypto_Core_Vu_WaitForComplete(CRYPTO_Type *base) * Function Name: Cy_Crypto_Core_Vu_StatusRead ****************************************************************************//** * -* Returns value of the VU status register +* Returns the value of the VU status register. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * *******************************************************************************/ -__STATIC_INLINE uint16_t Cy_Crypto_Core_Vu_StatusRead(CRYPTO_Type *base) +__STATIC_INLINE uint32_t Cy_Crypto_Core_Vu_StatusRead(CRYPTO_Type *base) { Cy_Crypto_Core_Vu_WaitForComplete(base); - return((uint16_t)REG_CRYPTO_VU_STATUS(base)); + return((uint32_t)REG_CRYPTO_VU_STATUS(base)); } +/** \} group_crypto_lld_vu_functions */ #endif /* #if (CPUSS_CRYPTO_VU == 1) */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_server.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_server.h index f25efba8d4..99d9ce5996 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_server.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_crypto_server.h @@ -63,7 +63,7 @@ extern "C" { * the Crypto server context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \funcusage * \snippet crypto/2.10/snippet/main.c snippet_myCryptoServerStartBase @@ -94,7 +94,7 @@ cy_en_crypto_status_t Cy_Crypto_Server_Start_Base(cy_stc_crypto_config_t const * * the Crypto server context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * Refer to \ref Cy_Crypto_Server_Start_Base for the function usage example. * @@ -124,7 +124,7 @@ cy_en_crypto_status_t Cy_Crypto_Server_Start_Extra(cy_stc_crypto_config_t const * the Crypto server context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * Refer to \ref Cy_Crypto_Server_Start_Base for the function usage example. * @@ -142,7 +142,7 @@ cy_en_crypto_status_t Cy_Crypto_Server_Start_Full(cy_stc_crypto_config_t const * * This function available for Server side only. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Server_Stop(void); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_device.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_device.h index 44ecd5499e..f60560f49c 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_device.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_device.h @@ -189,6 +189,8 @@ void Cy_PDL_Init(const cy_stc_device_t * device); * Register Access Helper Macros *******************************************************************************/ +#define CY_CRYPTO_HW_V1 (1U == cy_device->cryptoVersion) /* true if the mxcrypto version is 1 */ + #define CY_SRSS_NUM_CLKPATH ((uint32_t)(cy_device->srssNumClkpath)) #define CY_SRSS_NUM_PLL ((uint32_t)(cy_device->srssNumPll)) #define CY_SRSS_NUM_HFROOT ((uint32_t)(cy_device->srssNumHfroot)) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_pdl.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_pdl.h index 5c1a7f182a..3ed8b87027 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_pdl.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_pdl.h @@ -36,6 +36,7 @@ #include "cy_ctb.h" #include "cy_ctdac.h" #include "cy_dma.h" +#include "cy_dmac.h" #include "cy_efuse.h" #include "cy_flash.h" #include "cy_gpio.h" @@ -55,8 +56,10 @@ #include "cy_scb_i2c.h" #include "cy_scb_spi.h" #include "cy_scb_uart.h" +#include "cy_sd_host.h" #include "cy_smartio.h" #include "cy_smif.h" +#include "cy_smif_memslot.h" #include "cy_sysanalog.h" #include "cy_sysclk.h" #include "cy_sysint.h" diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_sysclk.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_sysclk.h index f2811c245e..3c71b78aab 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_sysclk.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/include/cy_sysclk.h @@ -112,6 +112,7 @@ * Updated the following functions implementation: \ref Cy_SysClk_EcoEnable, \ref Cy_SysClk_EcoGetStatus, \ref Cy_SysClk_FllGetConfiguration \n * and \ref Cy_SysClk_DeepSleepCallback. \n * The \ref Cy_SysClk_DeepSleepCallback now implements all four SysPm callback modes \ref cy_en_syspm_callback_mode_t. \n +* The actions that were done in \ref CY_SYSPM_CHECK_READY case are moved to \ref CY_SYSPM_BEFORE_TRANSITION. \n * So the \ref cy_stc_syspm_callback_t::skipMode must be set to 0UL. * Defect fixing. * diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_ble_clk.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_ble_clk.c index e14ba10b10..cd2e3a1f8a 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_ble_clk.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_ble_clk.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_ble_clk.c -* \version 3.0 +* \version 3.10 * * \brief * This driver provides the source code for API BLE ECO clock. @@ -138,8 +138,8 @@ static cy_en_ble_eco_status_t Cy_BLE_HAL_MxdRadioEnableClocks(cy_en_ble_eco_freq /* Range for inputs parameters */ -#define CY_BLE_ECO_XTAL_SRART_UP_TIME_MAX ((uint8_t) (4593.75 / 31.25)) -#define CY_BLE_ECO_XTAL_SRART_UP_TIME_MIN ((uint8_t) (400 / 31.25)) +#define CY_BLE_ECO_XTAL_START_UP_TIME_MAX ((uint8_t) (4593.75 / 31.25)) +#define CY_BLE_ECO_XTAL_START_UP_TIME_MIN ((uint8_t) (400 / 31.25)) #define CY_BLE_ECO_CLOAD_MIN ((uint8_t) ((7.5 - 7.5)/0.075)) #define CY_BLE_ECO_CLOAD_MAX ((uint8_t) ((26.325 - 7.5)/0.075)) @@ -220,7 +220,7 @@ cy_en_ble_eco_status_t Cy_BLE_EcoConfigure(cy_en_ble_eco_freq_t freq, cy_en_ble_ uint32_t temp = 0UL; if( (freq > CY_BLE_BLESS_ECO_FREQ_32MHZ) || (sysClkDiv > CY_BLE_SYS_ECO_CLK_DIV_8) || - (xtalStartUpTime > CY_BLE_ECO_XTAL_SRART_UP_TIME_MAX) || (xtalStartUpTime < CY_BLE_ECO_XTAL_SRART_UP_TIME_MIN) || + (xtalStartUpTime > CY_BLE_ECO_XTAL_START_UP_TIME_MAX) || (xtalStartUpTime < CY_BLE_ECO_XTAL_START_UP_TIME_MIN) || (cLoad > CY_BLE_ECO_CLOAD_MAX)) { status = CY_BLE_ECO_BAD_PARAM; @@ -355,7 +355,7 @@ cy_en_ble_eco_status_t Cy_BLE_EcoConfigure(cy_en_ble_eco_freq_t freq, cy_en_ble_ /* Clear the BLERD_ACTIVE_INTR */ BLE_BLESS_INTR_STAT |= BLE_BLESS_INTR_STAT_BLERD_ACTIVE_INTR_Msk; - if(!Cy_SysPm_SimoBuckOutputIsEnabled(CY_SYSPM_BUCK_VRF)) + if((!Cy_SysPm_SimoBuckOutputIsEnabled(CY_SYSPM_BUCK_VRF)) || (voltageReg == CY_BLE_ECO_VOLTAGE_REG_BLESSLDO)) { temp |= BLE_BLESS_MT_CFG_ACT_LDO_NOT_BUCK_Msk; } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto.c index 0fd3c1604a..66bd2e6184 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto.c @@ -171,7 +171,7 @@ cy_en_crypto_status_t Cy_Crypto_Sync(bool isBlocking) * This function is internal and should not to be called directly by user software. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ static cy_en_crypto_status_t Cy_Crypto_Client_Send(void) @@ -309,7 +309,7 @@ cy_en_crypto_status_t Cy_Crypto_Enable(void) * The pointer to a variable to store gathered crypto library information. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_GetLibraryInfo(cy_en_crypto_lib_info_t *cryptoInfo) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_aes_v1.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_aes_v1.c index 4f3e3c082e..f7a67e20b5 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_aes_v1.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_aes_v1.c @@ -44,10 +44,11 @@ static void Cy_Crypto_Core_V1_Aes_InvKey(CRYPTO_Type *base, cy_stc_crypto_aes_st * Performs the AES block cipher. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \param dirMode * One of CRYPTO_ENCRYPT or CRYPTO_DECRYPT. @@ -90,10 +91,11 @@ void Cy_Crypto_Core_V1_Aes_ProcessBlock(CRYPTO_Type *base, * All addresses must be 4-Byte aligned! * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \param dstBlock * The pointer to the memory structure with the XOR results. @@ -136,10 +138,11 @@ void Cy_Crypto_Core_V1_Aes_Xor(CRYPTO_Type *base, * Calculates an inverse block cipher key from the block cipher key. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * *******************************************************************************/ static void Cy_Crypto_Core_V1_Aes_InvKey(CRYPTO_Type *base, cy_stc_crypto_aes_state_t const *aesState) @@ -162,10 +165,10 @@ static void Cy_Crypto_Core_V1_Aes_InvKey(CRYPTO_Type *base, cy_stc_crypto_aes_st * Function Name: Cy_Crypto_Core_V1_Aes_Init ****************************************************************************//** * -* Sets Aes mode and prepare inversed key. +* Sets AES mode and prepares an inverse key. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param key * The pointer to the encryption/decryption key. @@ -174,10 +177,11 @@ static void Cy_Crypto_Core_V1_Aes_InvKey(CRYPTO_Type *base, cy_stc_crypto_aes_st * \ref cy_en_crypto_aes_key_length_t * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Init(CRYPTO_Type *base, @@ -212,10 +216,10 @@ void Cy_Crypto_Core_V1_Aes_Free(CRYPTO_Type *base) * Function Name: Cy_Crypto_Core_V1_Aes_Ecb ****************************************************************************//** * -* Performs AES operation on one Block. +* Performs an AES operation on one block. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -228,10 +232,11 @@ void Cy_Crypto_Core_V1_Aes_Free(CRYPTO_Type *base) * The pointer to a source block. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Ecb(CRYPTO_Type *base, @@ -258,7 +263,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Ecb(CRYPTO_Type *base, * Performs AES operation on a plain text with Cipher Block Chaining (CBC). * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -277,10 +282,11 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Ecb(CRYPTO_Type *base, * The pointer to a source plain text. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cbc(CRYPTO_Type *base, @@ -298,17 +304,17 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cbc(CRYPTO_Type *base, uint32_t *srcBuff = (uint32_t*)(&aesBuffers->block0); uint32_t *dstBuff = (uint32_t*)(&aesBuffers->block1); - cy_en_crypto_status_t myResult = CY_CRYPTO_SIZE_NOT_X16; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SIZE_NOT_X16; /* Check whether the data size is multiple of CY_CRYPTO_AES_BLOCK_SIZE */ - if (0uL == (uint32_t)(size & (CY_CRYPTO_AES_BLOCK_SIZE - 1u))) + if (0UL == (uint32_t)(size & (CY_CRYPTO_AES_BLOCK_SIZE - 1U))) { /* Copy the Initialization Vector to the local buffer because it changes during calculation */ Cy_Crypto_Core_V1_MemCpy(base, tempBuff, ivPtr, CY_CRYPTO_AES_BLOCK_SIZE); if (CY_CRYPTO_DECRYPT == dirMode) { - while (size > 0uL) + while (size != 0UL) { /* source message block */ Cy_Crypto_Core_V1_MemCpy(base, srcBuff, src, CY_CRYPTO_AES_BLOCK_SIZE); @@ -329,7 +335,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cbc(CRYPTO_Type *base, } else { - while (size > 0uL) + while (size != 0UL) { /* source message block */ Cy_Crypto_Core_V1_MemCpy(base, srcBuff, src, CY_CRYPTO_AES_BLOCK_SIZE); @@ -349,10 +355,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cbc(CRYPTO_Type *base, } } - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } - return (myResult); + return (tmpResult); } /******************************************************************************* @@ -362,7 +368,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cbc(CRYPTO_Type *base, * Performs AES operation on a plain text with the Cipher Feedback Block method (CFB). * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -381,10 +387,11 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cbc(CRYPTO_Type *base, * The pointer to a source plain text. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user must +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cfb(CRYPTO_Type *base, @@ -396,7 +403,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cfb(CRYPTO_Type *base, cy_stc_crypto_aes_state_t *aesState) { uint32_t size = srcSize; - cy_en_crypto_status_t myResult = CY_CRYPTO_SIZE_NOT_X16; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SIZE_NOT_X16; cy_stc_crypto_aes_buffers_t *aesBuffers = (cy_stc_crypto_aes_buffers_t*)aesState->buffers; @@ -406,17 +413,17 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cfb(CRYPTO_Type *base, uint32_t *encBuff = dstBuff; /* Default operation is ENCRYPT */ /* Check whether the data size is multiple of CY_CRYPTO_AES_BLOCK_SIZE */ - if (0uL == (size & (CY_CRYPTO_AES_BLOCK_SIZE - 1u))) + if (0UL == (size & (CY_CRYPTO_AES_BLOCK_SIZE - 1U))) { if (CY_CRYPTO_DECRYPT == dirMode) { encBuff = srcBuff; } - /* Copy the Initialization Vector to local encode buffer */ + /* Copies the Initialization Vector to the local encode buffer. */ Cy_Crypto_Core_V1_MemCpy(base, encBuff, ivPtr, CY_CRYPTO_AES_BLOCK_SIZE); - while (size > 0uL) + while (size != 0UL) { /* In this mode, (CFB) is always an encryption! */ Cy_Crypto_Core_V1_Aes_ProcessBlock(base, aesState, CY_CRYPTO_ENCRYPT, dstBuff, encBuff); @@ -435,20 +442,20 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cfb(CRYPTO_Type *base, size -= CY_CRYPTO_AES_BLOCK_SIZE; } - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } - return (myResult); + return (tmpResult); } /******************************************************************************* * Function Name: Cy_Crypto_Core_V1_Aes_Ctr ******************************************************************************** * -* Performs AES operation on a plain text using the counter method (CTR). +* Performs an AES operation on a plain text using the counter method (CTR). * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcSize * The size of a source plain text. @@ -458,7 +465,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cfb(CRYPTO_Type *base, * current cipher stream. * * \param ivPtr -* The 128-bit nonce and counter. +* The 128-bit initial vector and counter. * * \param streamBlock * The saved stream-block for resuming. Is over-written by the function. @@ -470,13 +477,14 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Cfb(CRYPTO_Type *base, * The pointer to a source plain text. Must be 4-Byte aligned. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user must +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ -#define CY_CRYPTO_AES_CTR_CNT_POS (0x02u) +#define CY_CRYPTO_AES_CTR_CNT_POS (0x02U) cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Ctr(CRYPTO_Type *base, uint32_t srcSize, uint32_t *srcOffset, @@ -491,28 +499,28 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Ctr(CRYPTO_Type *base, uint64_t counter; cy_stc_crypto_aes_buffers_t *aesBuffers = (cy_stc_crypto_aes_buffers_t*)aesState->buffers; - uint32_t *nonceCounter = (uint32_t*)(&aesBuffers->iv); + uint32_t *blockCounter = (uint32_t*)(&aesBuffers->iv); uint32_t *srcBuff = (uint32_t*)(&aesBuffers->block0); uint32_t *dstBuff = (uint32_t*)(&aesBuffers->block1); uint32_t *streamBuff = (uint32_t*)(&aesBuffers->block2); - Cy_Crypto_Core_V1_MemCpy(base, nonceCounter, ivPtr, CY_CRYPTO_AES_BLOCK_SIZE); + Cy_Crypto_Core_V1_MemCpy(base, blockCounter, ivPtr, CY_CRYPTO_AES_BLOCK_SIZE); - counter = CY_SWAP_ENDIAN64(*(uint64_t*)(nonceCounter + CY_CRYPTO_AES_CTR_CNT_POS)); + counter = CY_SWAP_ENDIAN64(*(uint64_t*)(blockCounter + CY_CRYPTO_AES_CTR_CNT_POS)); cnt = (uint32_t)(srcSize / CY_CRYPTO_AES_BLOCK_SIZE); - for (i = 0uL; i < cnt; i++) + for (i = 0UL; i < cnt; i++) { /* source message block */ Cy_Crypto_Core_V1_MemCpy(base, srcBuff, src, CY_CRYPTO_AES_BLOCK_SIZE); /* In this mode, (CTR) is always an encryption! */ - Cy_Crypto_Core_V1_Aes_ProcessBlock(base, aesState, CY_CRYPTO_ENCRYPT, streamBuff, nonceCounter); + Cy_Crypto_Core_V1_Aes_ProcessBlock(base, aesState, CY_CRYPTO_ENCRYPT, streamBuff, blockCounter); - /* Increment the nonce counter, at least 64Bits (from 128) is the counter part */ + /* Increment the block counter, at least 64Bits (from 128) is the counter part */ counter++; - *(uint64_t*)(nonceCounter + CY_CRYPTO_AES_CTR_CNT_POS) = CY_SWAP_ENDIAN64(counter); + *(uint64_t*)(blockCounter + CY_CRYPTO_AES_CTR_CNT_POS) = CY_SWAP_ENDIAN64(counter); Cy_Crypto_Core_V1_Aes_Xor(base, aesState, dstBuff, srcBuff, streamBuff); @@ -523,7 +531,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Aes_Ctr(CRYPTO_Type *base, dst += CY_CRYPTO_AES_BLOCK_SIZE; } - Cy_Crypto_Core_V1_MemCpy(base, ivPtr, nonceCounter, CY_CRYPTO_AES_BLOCK_SIZE); + Cy_Crypto_Core_V1_MemCpy(base, ivPtr, blockCounter, CY_CRYPTO_AES_BLOCK_SIZE); /* Save the reminder of the last non-complete block */ *srcOffset = (uint32_t)(srcSize % CY_CRYPTO_AES_BLOCK_SIZE); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_aes_v2.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_aes_v2.c index 54015cc8a8..173e232774 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_aes_v2.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_aes_v2.c @@ -45,10 +45,11 @@ * Calculates an inverse block cipher key from the block cipher key. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * *******************************************************************************/ void Cy_Crypto_Core_V2_Aes_LoadEncKey(CRYPTO_Type *base, @@ -77,10 +78,11 @@ void Cy_Crypto_Core_V2_Aes_LoadEncKey(CRYPTO_Type *base, * Calculates an inverse block cipher key from the block cipher key. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * *******************************************************************************/ void Cy_Crypto_Core_V2_Aes_LoadDecKey(CRYPTO_Type *base, @@ -109,10 +111,10 @@ void Cy_Crypto_Core_V2_Aes_LoadDecKey(CRYPTO_Type *base, * Function Name: Cy_Crypto_Core_V2_Aes_Init ****************************************************************************//** * -* Sets Aes mode and prepare inversed key. +* Sets AES mode and prepares inverse key. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param key * The pointer to the encryption/decryption key. @@ -121,10 +123,11 @@ void Cy_Crypto_Core_V2_Aes_LoadDecKey(CRYPTO_Type *base, * \ref cy_en_crypto_aes_key_length_t * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Init(CRYPTO_Type *base, @@ -150,10 +153,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Init(CRYPTO_Type *base, * Function Name: Cy_Crypto_Core_V2_Aes_Ecb ****************************************************************************//** * -* Performs AES operation on one Block. +* Performs an AES operation on one block. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -166,10 +169,11 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Init(CRYPTO_Type *base, * The pointer to a source block. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Ecb(CRYPTO_Type *base, @@ -202,7 +206,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Ecb(CRYPTO_Type *base, * Performs AES operation on a plain text with Cipher Block Chaining (CBC). * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -221,10 +225,11 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Ecb(CRYPTO_Type *base, * The pointer to a source plain text. Must be 4-Byte aligned. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cbc(CRYPTO_Type *base, @@ -236,10 +241,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cbc(CRYPTO_Type *base, cy_stc_crypto_aes_state_t *aesState) { uint32_t size = srcSize; - cy_en_crypto_status_t myResult = CY_CRYPTO_SIZE_NOT_X16; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SIZE_NOT_X16; /* Check whether the data size is multiple of CY_CRYPTO_AES_BLOCK_SIZE */ - if (0uL == (uint32_t)(srcSize & (uint32_t)(CY_CRYPTO_AES_BLOCK_SIZE - 1u))) + if (0UL == (uint32_t)(srcSize & (uint32_t)(CY_CRYPTO_AES_BLOCK_SIZE - 1U))) { (CY_CRYPTO_ENCRYPT == dirMode) ? \ @@ -254,7 +259,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cbc(CRYPTO_Type *base, { Cy_Crypto_Core_V2_BlockMov(base, CY_CRYPTO_V2_RB_BLOCK1, CY_CRYPTO_V2_RB_FF_LOAD1, CY_CRYPTO_AES_BLOCK_SIZE); - while (size != 0u) + while (size != 0U) { Cy_Crypto_Core_V2_BlockXor(base, CY_CRYPTO_V2_RB_BLOCK0, CY_CRYPTO_V2_RB_FF_LOAD0, CY_CRYPTO_V2_RB_BLOCK1, CY_CRYPTO_AES_BLOCK_SIZE); @@ -268,7 +273,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cbc(CRYPTO_Type *base, { Cy_Crypto_Core_V2_BlockMov(base, CY_CRYPTO_V2_RB_BLOCK2, CY_CRYPTO_V2_RB_FF_LOAD1, CY_CRYPTO_AES_BLOCK_SIZE); - while (size != 0u) + while (size != 0U) { Cy_Crypto_Core_V2_BlockMov(base, CY_CRYPTO_V2_RB_BLOCK0, CY_CRYPTO_V2_RB_FF_LOAD0, CY_CRYPTO_AES_BLOCK_SIZE); Cy_Crypto_Core_V2_RunAesInv(base); @@ -280,12 +285,12 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cbc(CRYPTO_Type *base, } } - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } Cy_Crypto_Core_WaitForReady(base); - return (myResult); + return (tmpResult); } /******************************************************************************* @@ -295,7 +300,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cbc(CRYPTO_Type *base, * Performs AES operation on a plain text with the Cipher Feedback Block method (CFB). * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -314,10 +319,11 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cbc(CRYPTO_Type *base, * The pointer to a source plain text. Must be 4-Byte aligned. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cfb(CRYPTO_Type *base, @@ -330,10 +336,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cfb(CRYPTO_Type *base, { uint32_t size = srcSize; - cy_en_crypto_status_t myResult = CY_CRYPTO_SIZE_NOT_X16; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SIZE_NOT_X16; /* Check whether the data size is multiple of CY_CRYPTO_AES_BLOCK_SIZE */ - if (0uL == (uint32_t)(size & (uint32_t)(CY_CRYPTO_AES_BLOCK_SIZE - 1u))) + if (0UL == (uint32_t)(size & (uint32_t)(CY_CRYPTO_AES_BLOCK_SIZE - 1U))) { Cy_Crypto_Core_V2_Aes_LoadEncKey(base, aesState); @@ -345,7 +351,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cfb(CRYPTO_Type *base, if (CY_CRYPTO_ENCRYPT == dirMode) { - while (size != 0u) + while (size != 0U) { Cy_Crypto_Core_V2_RunAes(base); Cy_Crypto_Core_V2_BlockXor(base, CY_CRYPTO_V2_RB_BLOCK0, CY_CRYPTO_V2_RB_FF_LOAD0, @@ -357,7 +363,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cfb(CRYPTO_Type *base, } else { - while (size != 0u) + while (size != 0U) { Cy_Crypto_Core_V2_RunAes(base); Cy_Crypto_Core_V2_BlockMov(base, CY_CRYPTO_V2_RB_BLOCK0, CY_CRYPTO_V2_RB_FF_LOAD0, CY_CRYPTO_AES_BLOCK_SIZE); @@ -368,12 +374,12 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cfb(CRYPTO_Type *base, } } - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } Cy_Crypto_Core_WaitForReady(base); - return (myResult); + return (tmpResult); } /******************************************************************************* @@ -383,7 +389,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cfb(CRYPTO_Type *base, * Performs AES operation on a plain text using the counter method (CTR). * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param srcSize * The size of a source plain text. @@ -405,13 +411,14 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Cfb(CRYPTO_Type *base, * The pointer to a source plain text. Must be 4-Byte aligned. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ -#define CY_CRYPTO_AES_CTR_CNT_POS (2u) +#define CY_CRYPTO_AES_CTR_CNT_POS (2U) cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Ctr(CRYPTO_Type *base, uint32_t srcSize, uint32_t *srcOffset, @@ -421,28 +428,28 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Ctr(CRYPTO_Type *base, uint8_t const *src, cy_stc_crypto_aes_state_t *aesState) { - uint32_t nonceCounter[4]; + uint32_t blockCounter[4]; uint64_t counter; uint32_t cnt; uint32_t i; - nonceCounter[ 0] = (uint32_t) CY_CRYPTO_MERGE_BYTES(ivPtr[ 3], ivPtr[ 2], ivPtr[ 1], ivPtr[0]); - nonceCounter[ 1] = (uint32_t) CY_CRYPTO_MERGE_BYTES(ivPtr[ 7], ivPtr[ 6], ivPtr[ 5], ivPtr[4]); - nonceCounter[ 2] = (uint32_t) CY_CRYPTO_MERGE_BYTES(ivPtr[11], ivPtr[10], ivPtr[ 9], ivPtr[8]); - nonceCounter[ 3] = (uint32_t) CY_CRYPTO_MERGE_BYTES(ivPtr[15], ivPtr[14], ivPtr[13], ivPtr[12]); + blockCounter[ 0] = (uint32_t) CY_CRYPTO_MERGE_BYTES(ivPtr[ 3], ivPtr[ 2], ivPtr[ 1], ivPtr[0]); + blockCounter[ 1] = (uint32_t) CY_CRYPTO_MERGE_BYTES(ivPtr[ 7], ivPtr[ 6], ivPtr[ 5], ivPtr[4]); + blockCounter[ 2] = (uint32_t) CY_CRYPTO_MERGE_BYTES(ivPtr[11], ivPtr[10], ivPtr[ 9], ivPtr[8]); + blockCounter[ 3] = (uint32_t) CY_CRYPTO_MERGE_BYTES(ivPtr[15], ivPtr[14], ivPtr[13], ivPtr[12]); - counter = CY_SWAP_ENDIAN64(*(uint64_t*)(nonceCounter + CY_CRYPTO_AES_CTR_CNT_POS)); + counter = CY_SWAP_ENDIAN64(*(uint64_t*)(blockCounter + CY_CRYPTO_AES_CTR_CNT_POS)); Cy_Crypto_Core_V2_Aes_LoadEncKey(base, aesState); - Cy_Crypto_Core_V2_FFContinue(base, CY_CRYPTO_V2_RB_FF_LOAD1, (const uint8_t *) &nonceCounter, CY_CRYPTO_AES_BLOCK_SIZE); + Cy_Crypto_Core_V2_FFContinue(base, CY_CRYPTO_V2_RB_FF_LOAD1, (const uint8_t *) &blockCounter, CY_CRYPTO_AES_BLOCK_SIZE); Cy_Crypto_Core_V2_BlockMov (base, CY_CRYPTO_V2_RB_BLOCK0, CY_CRYPTO_V2_RB_FF_LOAD1, CY_CRYPTO_AES_BLOCK_SIZE); /* CTR counter is placed into last 4 bytes of the Nonce block */ - Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 4u, (uint8_t)((counter >> 24u) & 0xffu)); - Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 3u, (uint8_t)((counter >> 16u) & 0xffu)); - Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 2u, (uint8_t)((counter >> 8u) & 0xffu)); - Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 1u, (uint8_t)((counter) & 0xffu)); + Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 4U, (uint8_t)((counter >> 24U) & 0xffU)); + Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 3U, (uint8_t)((counter >> 16U) & 0xffU)); + Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 2U, (uint8_t)((counter >> 8U) & 0xffU)); + Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 1U, (uint8_t)((counter) & 0xffU)); Cy_Crypto_Core_V2_RunAes(base); @@ -457,19 +464,19 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Aes_Ctr(CRYPTO_Type *base, /* Increment the nonce counter */ counter++; - *(uint64_t*)(nonceCounter + CY_CRYPTO_AES_CTR_CNT_POS) = CY_SWAP_ENDIAN64(counter); + *(uint64_t*)(blockCounter + CY_CRYPTO_AES_CTR_CNT_POS) = CY_SWAP_ENDIAN64(counter); /* CTR counter is placed into last 4 bytes of the Nonce block */ - Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 4u, (uint8_t)((counter >> 24u) & 0xffu)); - Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 3u, (uint8_t)((counter >> 16u) & 0xffu)); - Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 2u, (uint8_t)((counter >> 8u) & 0xffu)); - Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 1u, (uint8_t)((counter) & 0xffu)); + Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 4U, (uint8_t)((counter >> 24u) & 0xffU)); + Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 3U, (uint8_t)((counter >> 16u) & 0xffU)); + Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 2U, (uint8_t)((counter >> 8u) & 0xffU)); + Cy_Crypto_Core_V2_RBSetByte(base, CY_CRYPTO_AES_BLOCK_SIZE - 1U, (uint8_t)((counter) & 0xffU)); Cy_Crypto_Core_V2_RBXor (base, CY_CRYPTO_AES_BLOCK_SIZE, CY_CRYPTO_AES_BLOCK_SIZE); Cy_Crypto_Core_V2_RBStore(base, CY_CRYPTO_AES_BLOCK_SIZE, CY_CRYPTO_AES_BLOCK_SIZE); } - Cy_Crypto_Core_V2_MemCpy(base, ivPtr, nonceCounter, CY_CRYPTO_AES_BLOCK_SIZE); + Cy_Crypto_Core_V2_MemCpy(base, ivPtr, blockCounter, CY_CRYPTO_AES_BLOCK_SIZE); /* Save the reminder of the last non-complete block */ *srcOffset = (uint32_t)(srcSize % CY_CRYPTO_AES_BLOCK_SIZE); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_cmac_v1.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_cmac_v1.c index 2a6f130c3a..59d73f6317 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_cmac_v1.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_cmac_v1.c @@ -56,20 +56,20 @@ static void Cy_Crypto_Core_V1_Cmac_CalcSubKey(uint8_t *srcDstPtr) { int32_t i; uint32_t c; - uint32_t msb = 0uL; + uint32_t msb = 0UL; - for (i = (int32_t)(CY_CRYPTO_AES_BLOCK_SIZE - 1); i >= 0; i--) + for (i = (int32_t)((int32_t)CY_CRYPTO_AES_BLOCK_SIZE - 1); i >= 0; i--) { c = (uint32_t)srcDstPtr[i]; - c = (c << 1u) | msb; + c = (c << 1U) | msb; srcDstPtr[i] = (uint8_t) c; - msb = (c >> 8u) & 1uL; + msb = (c >> 8U) & 1UL; } - if (0uL != msb) + if (0UL != msb) { /* Just one byte is valuable, the rest are zeros */ - srcDstPtr[(uint8_t)(CY_CRYPTO_AES_BLOCK_SIZE - 1u)] ^= CY_CRYPTO_CMAC_RB; + srcDstPtr[(uint8_t)(CY_CRYPTO_AES_BLOCK_SIZE - 1U)] ^= CY_CRYPTO_CMAC_RB; } } @@ -110,13 +110,13 @@ void Cy_Crypto_Core_V1_Cmac_Init(cy_stc_crypto_v1_cmac_state_t* cmacState, * Starts CMAC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param aesState * The pointer to the structure which stores the AES context. * * \param cmacState -* the pointer to the structure which stores the CMAC context. +* The pointer to the structure which stores the CMAC context. * *******************************************************************************/ void Cy_Crypto_Core_V1_Cmac_Start(CRYPTO_Type *base, @@ -127,7 +127,7 @@ void Cy_Crypto_Core_V1_Cmac_Start(CRYPTO_Type *base, uint32_t *tempTmp = cmacState->temp; /* Calculate the K1 sub-key */ - Cy_Crypto_Core_V1_MemSet(base, (void*)tempTmp, 0u, CY_CRYPTO_AES_BLOCK_SIZE); + Cy_Crypto_Core_V1_MemSet(base, (void*)tempTmp, 0U, CY_CRYPTO_AES_BLOCK_SIZE); Cy_Crypto_Core_V1_Aes_ProcessBlock(base, aesState, CY_CRYPTO_ENCRYPT, kTmp, tempTmp); @@ -141,7 +141,7 @@ void Cy_Crypto_Core_V1_Cmac_Start(CRYPTO_Type *base, * Calculates CMAC on a message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param aesState * The pointer to the structure which stores the AES context. @@ -166,7 +166,7 @@ void Cy_Crypto_Core_V1_Cmac_Update(CRYPTO_Type *base, uint32_t *tempBuff = cmacState->temp; /* Clear the argument for XOR for the first block */ - Cy_Crypto_Core_V1_MemSet(base, (void* )tempBuff, 0x00u, CY_CRYPTO_AES_BLOCK_SIZE); + Cy_Crypto_Core_V1_MemSet(base, (void* )tempBuff, 0x00U, CY_CRYPTO_AES_BLOCK_SIZE); /* Process all blocks except last */ while (messageSize > CY_CRYPTO_AES_BLOCK_SIZE) @@ -197,7 +197,7 @@ void Cy_Crypto_Core_V1_Cmac_Update(CRYPTO_Type *base, * Completes CMAC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param aesState * the pointer to the structure which stores the AES context. @@ -226,11 +226,11 @@ void Cy_Crypto_Core_V1_Cmac_Finish(CRYPTO_Type *base, Cy_Crypto_Core_V1_Cmac_CalcSubKey((uint8_t* )kPtrTmp); /* Appended '1' bit to the end of message, followed by '0' */ - *((uint8_t* )blockBuff + blockIdxTmp) = 0x80u; + *((uint8_t* )blockBuff + blockIdxTmp) = 0x80U; /* Write zeros into the rest of the message */ copySize = CY_CRYPTO_AES_BLOCK_SIZE - 1u - blockIdxTmp; - Cy_Crypto_Core_V1_MemSet(base, ((uint8_t* )blockBuff + blockIdxTmp + 1), 0x00u, (uint16_t)copySize); + Cy_Crypto_Core_V1_MemSet(base, ((uint8_t* )blockBuff + blockIdxTmp + 1), 0x00U, (uint16_t)copySize); } Cy_Crypto_Core_V1_Aes_Xor(base, aesState, blockBuff, blockBuff, tempBuff); @@ -250,7 +250,7 @@ void Cy_Crypto_Core_V1_Cmac_Finish(CRYPTO_Type *base, * on a message to produce message authentication code using AES. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param message * The pointer to a source plain text. Must be 4-byte aligned. @@ -268,10 +268,11 @@ void Cy_Crypto_Core_V1_Cmac_Finish(CRYPTO_Type *base, * The pointer to the calculated CMAC. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Cmac(CRYPTO_Type *base, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_cmac_v2.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_cmac_v2.c index e144b20dce..cd10dde848 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_cmac_v2.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_cmac_v2.c @@ -66,20 +66,20 @@ static void Cy_Crypto_Core_V2_Cmac_CalcSubKey(uint8_t *srcDstPtr) { int32_t i; uint32_t c; - uint32_t msb = 0uL; + uint32_t msb = 0UL; - for (i = (int32_t)(CY_CRYPTO_AES_BLOCK_SIZE - 1); i >= 0; i--) + for (i = (int32_t)((int32_t)CY_CRYPTO_AES_BLOCK_SIZE - 1); i >= 0; i--) { c = (uint32_t)srcDstPtr[i]; - c = (c << 1u) | msb; + c = (c << 1U) | msb; srcDstPtr[i] = (uint8_t) c; - msb = (c >> 8u) & 1uL; + msb = (c >> 8U) & 1UL; } - if (0uL != msb) + if (0UL != msb) { /* Just one byte is valuable, the rest are zeros */ - srcDstPtr[(uint8_t)(CY_CRYPTO_AES_BLOCK_SIZE - 1u)] ^= CY_CRYPTO_CMAC_RB; + srcDstPtr[(uint8_t)(CY_CRYPTO_AES_BLOCK_SIZE - 1U)] ^= CY_CRYPTO_CMAC_RB; } } @@ -105,7 +105,7 @@ void Cy_Crypto_Core_V2_Cmac_Init(cy_stc_crypto_v2_cmac_state_t* cmacState, uint8 * Starts CMAC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param cmacState * the pointer to the structure which stores the CMAC context. @@ -114,7 +114,7 @@ void Cy_Crypto_Core_V2_Cmac_Init(cy_stc_crypto_v2_cmac_state_t* cmacState, uint8 void Cy_Crypto_Core_V2_Cmac_Start(CRYPTO_Type *base, cy_stc_crypto_v2_cmac_state_t *cmacState) { - cmacState->block_idx = 0u; + cmacState->block_idx = 0U; /* Calculate the K1 sub-key */ Cy_Crypto_Core_V2_BlockXor(base, CY_CRYPTO_V2_RB_BLOCK0, CY_CRYPTO_V2_RB_BLOCK0, @@ -137,7 +137,7 @@ void Cy_Crypto_Core_V2_Cmac_Start(CRYPTO_Type *base, * Calculates CMAC on a message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param cmacState * The pointer to the structure which stores the CMAC context. @@ -177,7 +177,7 @@ void Cy_Crypto_Core_V2_Cmac_Update(CRYPTO_Type *base, * Completes CMAC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param cmacState * The pointer to the structure which stores the CMAC context. @@ -226,7 +226,7 @@ void Cy_Crypto_Core_V2_Cmac_Finish(CRYPTO_Type *base, * on a message to produce message authentication code using AES. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param message * The pointer to a source plain text. Must be 4-byte aligned. @@ -244,10 +244,11 @@ void Cy_Crypto_Core_V2_Cmac_Finish(CRYPTO_Type *base, * The pointer to the calculated CMAC. * * \param aesState -* The pointer to the aesState structure which stores the AES context. +* The pointer to the AES state structure allocated by the user. The user +* must not modify anything in this structure. * * \return -* A Crypto status \ref en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Cmac(CRYPTO_Type *base, @@ -259,7 +260,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Cmac(CRYPTO_Type *base, cy_stc_crypto_aes_state_t *aesState) { /* Allocate space for the structure which stores the CMAC context */ - cy_stc_crypto_v2_cmac_buffers_t cmacBuffersData; + cy_stc_crypto_v2_cmac_buffers_t cmacBuffersData = { 0 }; cy_stc_crypto_v2_cmac_buffers_t *cmacBuffers = &cmacBuffersData; uint8_t *myK = cmacBuffers->k; diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_crc_v1.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_crc_v1.c index eba47c10fb..b661fd2f4b 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_crc_v1.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_crc_v1.c @@ -41,7 +41,7 @@ * Initializes CRC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param polynomial * The polynomial (specified using 32 bits) used in the computing CRC. @@ -59,7 +59,7 @@ * Specifies a mask with which the LFSR32 register is XORed to produce a remainder. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_Init(CRYPTO_Type *base, @@ -85,7 +85,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_Init(CRYPTO_Type *base, * (this bit is always assumed '1'). */ REG_CRYPTO_CRC_POL_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_CRC_POL_CTL_POLYNOMIAL, polynomial)); - /*Specifies a mask with which the CRC_LFSR_CTL.LFSR32 register is XORed to produce a remainder. + /* Specifies a mask with which the CRC_LFSR_CTL.LFSR32 register is XORed to produce a remainder. * The XOR is performed before remainder reversal. */ REG_CRYPTO_CRC_REM_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_CRC_REM_CTL_REM_XOR, remXor)); @@ -99,7 +99,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_Init(CRYPTO_Type *base, * Performs CRC calculation on a message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param crc * The pointer to a computed CRC value. Must be 4-byte aligned. @@ -114,7 +114,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_Init(CRYPTO_Type *base, * The initial state of the LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc(CRYPTO_Type *base, @@ -148,10 +148,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc(CRYPTO_Type *base, * Function Name: Cy_Crypto_Core_V1_Crc_CalcInit ****************************************************************************//** * -* Initializes CRC calculation. +* Initializes the CRC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -163,19 +163,19 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc(CRYPTO_Type *base, * The order in which data bytes are processed. 0 - MSB first; 1- LSB first. * * \param dataXor -* The byte mask for XORing data +* The byte mask for XORing data. * * \param remReverse -* A remainder reverse: 0 means the remainder is not reversed. 1 means reversed. +* A remainder reverse: 0 means the remainder is not reversed. 1 means it is reversed. * * \param remXor -* Specifies a mask with which the LFSR32 register is XORed to produce a remainder. +* Specifies the mask with which the LFSR32 register is XORed to produce a remainder. * * \param lfsrInitState * The initial state of the LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcInit(CRYPTO_Type *base, @@ -187,30 +187,33 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcInit(CRYPTO_Type *base, uint32_t remXor, uint32_t lfsrInitState) { - CY_ASSERT_L1((width >= 1) && (width <=32u)); + CY_ASSERT_L1((width >= 1U) && (width <= CY_CRYPTO_HW_REGS_WIDTH)); - /* Specifies the bit order in which a data Byte is processed + /* Specifies the bit order in which a data byte is processed * (reversal is performed after XORing): * '0': Most significant bit (bit 1) first. * '1': Least significant bit (bit 0) first. */ REG_CRYPTO_CRC_CTL(base) = (uint32_t)( (_VAL2FLD(CRYPTO_CRC_CTL_DATA_REVERSE, dataReverse)) | (_VAL2FLD(CRYPTO_CRC_CTL_REM_REVERSE, remReverse)) ); - /* Specifies a byte mask with which each data byte is XORed. + /* Specifies the byte mask with which each data byte is XORed. * The XOR is performed before data reversal. */ REG_CRYPTO_CRC_DATA_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_CRC_DATA_CTL_DATA_XOR, dataXor)); - /* CRC polynomial. The polynomial is represented WITHOUT the high order bit + /* The CRC polynomial. The polynomial is represented WITHOUT the high-order bit * (this bit is always assumed '1'). * CRC_POLYNOMIAL << (32 - CRC_BITLEN) */ - REG_CRYPTO_CRC_POL_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_CRC_POL_CTL_POLYNOMIAL, polynomial << (32u - width))); + REG_CRYPTO_CRC_POL_CTL(base) = + (uint32_t)(_VAL2FLD(CRYPTO_CRC_POL_CTL_POLYNOMIAL, polynomial << (CY_CRYPTO_HW_REGS_WIDTH - width))); - /*Specifies a mask with which the CRC_LFSR_CTL.LFSR32 register is XORed to produce a remainder. + /*Specifies the mask with which the CRC_LFSR_CTL.LFSR32 register is XORed to produce a remainder. * The XOR is performed before remainder reversal. */ - REG_CRYPTO_CRC_REM_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_CRC_REM_CTL_REM_XOR, remXor << (32u - width))); + REG_CRYPTO_CRC_REM_CTL(base) = + (uint32_t)(_VAL2FLD(CRYPTO_CRC_REM_CTL_REM_XOR, remXor << (CY_CRYPTO_HW_REGS_WIDTH - width))); - /* A state of 32-bit Linear Feedback Shift Registers (LFSR) used to implement CRC. */ - REG_CRYPTO_CRC_LFSR_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_CRC_LFSR_CTL_LFSR32, lfsrInitState << (32u - width))); + /* The state of 32-bit Linear Feedback Shift Registers (LFSR) used to implement the CRC. */ + REG_CRYPTO_CRC_LFSR_CTL(base) = + (uint32_t)(_VAL2FLD(CRYPTO_CRC_LFSR_CTL_LFSR32, lfsrInitState << (CY_CRYPTO_HW_REGS_WIDTH - width))); return (CY_CRYPTO_SUCCESS); } @@ -219,10 +222,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcInit(CRYPTO_Type *base, * Function Name: Cy_Crypto_Core_V1_Crc_CalcStart ****************************************************************************//** * -* Prepare CRC calculation by setting an initial seeds value. +* Prepares the CRC calculation by setting an initial seed value. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -231,15 +234,16 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcInit(CRYPTO_Type *base, * The initial state of the LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcStart(CRYPTO_Type *base, uint32_t width, uint32_t lfsrInitState) { - CY_ASSERT_L1((width >= 1) && (width <=32u)); + CY_ASSERT_L1((width >= 1U) && (width <= CY_CRYPTO_HW_REGS_WIDTH)); - /* A state of 32-bit Linear Feedback Shift Registers (LFSR) used to implement CRC. */ - REG_CRYPTO_CRC_LFSR_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_CRC_LFSR_CTL_LFSR32, lfsrInitState << (32u - width))); + /* The state of 32-bit Linear Feedback Shift Registers (LFSR) used to implement the CRC. */ + REG_CRYPTO_CRC_LFSR_CTL(base) = + (uint32_t)(_VAL2FLD(CRYPTO_CRC_LFSR_CTL_LFSR32, lfsrInitState << (CY_CRYPTO_HW_REGS_WIDTH - width))); return (CY_CRYPTO_SUCCESS); } @@ -248,10 +252,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcStart(CRYPTO_Type *base, uint32_ * Function Name: Cy_Crypto_Core_V1_Crc_CalcPartial ****************************************************************************//** * -* Performs CRC calculation of a message part. +* Performs the CRC calculation of a message part. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param data * The pointer to the message whose CRC is being computed. @@ -260,19 +264,19 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcStart(CRYPTO_Type *base, uint32_ * The size of a message in bytes. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcPartial(CRYPTO_Type *base, void const *data, uint32_t dataSize) { - /* Fill the FIFO with the instruction parameters */ + /* Fills the FIFO with the instruction parameters. */ Cy_Crypto_SetReg2Instr(base, (uint32_t)data, dataSize ); - /* Issue the CRC instruction */ + /* Issues the CRC instruction. */ Cy_Crypto_Run2ParamInstr(base, CY_CRYPTO_V1_CRC_OPC, CY_CRYPTO_RSRC0_SHIFT, CY_CRYPTO_RSRC4_SHIFT); - /* Wait until CRC instruction is complete */ + /* Waits until the CRC instruction is complete. */ while(0uL != _FLD2VAL(CRYPTO_STATUS_CRC_BUSY, REG_CRYPTO_STATUS(base))) { } @@ -284,10 +288,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcPartial(CRYPTO_Type *base, * Function Name: Cy_Crypto_Core_V1_Crc_CalcFinish ****************************************************************************//** * -* Finalizes CRC calculation. +* Finalizes the CRC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -296,22 +300,22 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcPartial(CRYPTO_Type *base, * The pointer to a computed CRC value. Must be 4-byte aligned. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcFinish(CRYPTO_Type *base, uint32_t width, uint32_t *crc) { - CY_ASSERT_L1((width >= 1) && (width <=32u)); + CY_ASSERT_L1((width >= 1U) && (width <= CY_CRYPTO_HW_REGS_WIDTH)); uint32_t calculatedCrc; - /* Copy the result from the CRC_REM_RESULT register */ + /* Copies the result from the CRC_REM_RESULT register. */ calculatedCrc = (uint32_t)_FLD2VAL(CRYPTO_CRC_REM_RESULT_REM, REG_CRYPTO_CRC_REM_RESULT(base)); - /* Note: Calculated CRC value is MSB aligned and should be shifted WHEN CRC_DATA_REVERSE is zero. */ + /* NOTE The calculated CRC value is MSB-aligned and should be shifted WHEN CRC_DATA_REVERSE is zero. */ if (_FLD2VAL(CRYPTO_CRC_CTL_REM_REVERSE, REG_CRYPTO_CRC_CTL(base)) == 0u) { - calculatedCrc = calculatedCrc >> (32u - width); + calculatedCrc = calculatedCrc >> (CY_CRYPTO_HW_REGS_WIDTH - width); } *crc = calculatedCrc; @@ -323,10 +327,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcFinish(CRYPTO_Type *base, uint32 * Function Name: Cy_Crypto_Core_V1_Crc_Calc ****************************************************************************//** * -* Performs CRC calculation on a message. +* Performs the CRC calculation on a message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -341,7 +345,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_CalcFinish(CRYPTO_Type *base, uint32 * The size of a message in bytes. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_Calc(CRYPTO_Type *base, @@ -350,28 +354,28 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Crc_Calc(CRYPTO_Type *base, void const *data, uint32_t dataSize) { - CY_ASSERT_L1((width >= 1) && (width <=32u)); + CY_ASSERT_L1((width >= 1U) && (width <= CY_CRYPTO_HW_REGS_WIDTH)); uint32_t calculatedCrc; - /* Fill the FIFO with the instruction parameters */ + /* Fills the FIFO with the instruction parameters. */ Cy_Crypto_SetReg2Instr(base, (uint32_t)data, dataSize ); - /* Issue the CRC instruction */ + /* Issues the CRC instruction. */ Cy_Crypto_Run2ParamInstr(base, CY_CRYPTO_V1_CRC_OPC, CY_CRYPTO_RSRC0_SHIFT, CY_CRYPTO_RSRC4_SHIFT); - /* Wait until CRC instruction is complete */ + /* Waits until the CRC instruction is complete. */ while(0uL != _FLD2VAL(CRYPTO_STATUS_CRC_BUSY, REG_CRYPTO_STATUS(base))) { } - /* Copy the result from the CRC_REM_RESULT register */ + /* Copies the result from the CRC_REM_RESULT register. */ calculatedCrc = (uint32_t)_FLD2VAL(CRYPTO_CRC_REM_RESULT_REM, REG_CRYPTO_CRC_REM_RESULT(base)); - /* Note: Calculated CRC value is MSB aligned and should be shifted WHEN CRC_DATA_REVERSE is zero. */ + /* NOTE The calculated CRC value is MSB-aligned and should be shifted WHEN CRC_DATA_REVERSE is zero. */ if (_FLD2VAL(CRYPTO_CRC_CTL_REM_REVERSE, REG_CRYPTO_CRC_CTL(base)) == 0u) { - calculatedCrc = calculatedCrc >> (32u - width); + calculatedCrc = calculatedCrc >> (CY_CRYPTO_HW_REGS_WIDTH - width); } *crc = calculatedCrc; diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_crc_v2.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_crc_v2.c index 5c5878384d..a27ce9b677 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_crc_v2.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_crc_v2.c @@ -42,7 +42,7 @@ * Initializes CRC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param polynomial * The polynomial (specified using 32 bits) used in the computing CRC. @@ -60,7 +60,7 @@ * Specifies a mask with which the LFSR32 register is XORed to produce a remainder. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_Init(CRYPTO_Type *base, @@ -100,7 +100,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_Init(CRYPTO_Type *base, * Performs CRC calculation on a message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param crc * The pointer to a computed CRC value. Must be 4-byte aligned. @@ -115,7 +115,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_Init(CRYPTO_Type *base, * The initial state of the LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc(CRYPTO_Type *base, @@ -146,10 +146,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc(CRYPTO_Type *base, * Function Name: Cy_Crypto_Core_V2_Crc_CalcInit ****************************************************************************//** * -* Initializes CRC calculation. +* Initializes the CRC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -161,19 +161,19 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc(CRYPTO_Type *base, * The order in which data bytes are processed. 0 - MSB first; 1- LSB first. * * \param dataXor -* The byte mask for XORing data +* The byte mask for XORing data. * * \param remReverse -* A remainder reverse: 0 means the remainder is not reversed. 1 means reversed. +* The remainder reverse: 0 means the remainder is not reversed; 1 means it is reversed. * * \param remXor -* Specifies a mask with which the LFSR32 register is XORed to produce a remainder. +* Specifies the mask with which the LFSR32 register is XORed to produce a remainder. * * \param lfsrInitState * The initial state of the LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcInit(CRYPTO_Type *base, @@ -185,29 +185,32 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcInit(CRYPTO_Type *base, uint32_t remXor, uint32_t lfsrInitState) { - CY_ASSERT_L1((width >= 1) && (width <=32u)); + CY_ASSERT_L1((width >= 1U) && (width <= CY_CRYPTO_HW_REGS_WIDTH)); - /* Specifies the bit order in which a data Byte is processed + /* Specifies the bit order in which a data byte is processed * (reversal is performed after XORing): * '0': Most significant bit (bit 1) first. * '1': Least significant bit (bit 0) first. */ REG_CRYPTO_CRC_CTL(base) = (uint32_t)( (_VAL2FLD(CRYPTO_V2_CRC_CTL_DATA_REVERSE, dataReverse)) | (_VAL2FLD(CRYPTO_V2_CRC_CTL_REM_REVERSE, remReverse)) ); - /* Specifies a byte mask with which each data byte is XORed. + /* Specifies the byte mask with which each data byte is XORed. * The XOR is performed before data reversal. */ REG_CRYPTO_CRC_DATA_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_V2_CRC_DATA_CTL_DATA_XOR, dataXor)); - /* CRC polynomial. The polynomial is represented WITHOUT the high order bit + /* The CRC polynomial. The polynomial is represented WITHOUT the high-order bit * (this bit is always assumed '1'). */ - REG_CRYPTO_CRC_POL_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_V2_CRC_POL_CTL_POLYNOMIAL, polynomial << (32u - width))); + REG_CRYPTO_CRC_POL_CTL(base) = + (uint32_t)(_VAL2FLD(CRYPTO_V2_CRC_POL_CTL_POLYNOMIAL, polynomial << (CY_CRYPTO_HW_REGS_WIDTH - width))); - /*Specifies a mask with which the CRC_LFSR_CTL.LFSR32 register is XORed to produce a remainder. + /*Specifies the mask with which the CRC_LFSR_CTL.LFSR32 register is XORed to produce a remainder. * The XOR is performed before remainder reversal. */ - REG_CRYPTO_CRC_REM_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_V2_CRC_REM_CTL_REM_XOR, remXor << (32u - width))); + REG_CRYPTO_CRC_REM_CTL(base) = + (uint32_t)(_VAL2FLD(CRYPTO_V2_CRC_REM_CTL_REM_XOR, remXor << (CY_CRYPTO_HW_REGS_WIDTH - width))); - /* A state of 32-bit Linear Feedback Shift Registers (LFSR) used to implement CRC. */ - REG_CRYPTO_RESULT(base) = (uint32_t)(_VAL2FLD(CRYPTO_V2_RESULT_DATA, lfsrInitState << (32u - width))); + /* The state of 32-bit Linear Feedback Shift Registers (LFSR) used to implement the CRC. */ + REG_CRYPTO_RESULT(base) = + (uint32_t)(_VAL2FLD(CRYPTO_V2_RESULT_DATA, lfsrInitState << (CY_CRYPTO_HW_REGS_WIDTH - width))); return (CY_CRYPTO_SUCCESS); } @@ -216,10 +219,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcInit(CRYPTO_Type *base, * Function Name: Cy_Crypto_Core_V2_Crc_CalcStart ****************************************************************************//** * -* Prepares CRC calculation by setting an initial seeds value. +* Prepares the CRC calculation by setting an initial seed value. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -228,15 +231,15 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcInit(CRYPTO_Type *base, * The initial state of the LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcStart(CRYPTO_Type *base, uint32_t width, uint32_t lfsrInitState) { - CY_ASSERT_L1((width >= 1) && (width <=32u)); + CY_ASSERT_L1((width >= 1U) && (width <= CY_CRYPTO_HW_REGS_WIDTH)); - /* A state of 32-bit Linear Feedback Shift Registers (LFSR) used to implement CRC. */ - REG_CRYPTO_RESULT(base) = (uint32_t)(_VAL2FLD(CRYPTO_V2_RESULT_DATA, lfsrInitState << (32u - width))); + /* The state of 32-bit Linear Feedback Shift Registers (LFSR) used to implement the CRC. */ + REG_CRYPTO_RESULT(base) = (uint32_t)(_VAL2FLD(CRYPTO_V2_RESULT_DATA, lfsrInitState << (CY_CRYPTO_HW_REGS_WIDTH - width))); return (CY_CRYPTO_SUCCESS); } @@ -245,10 +248,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcStart(CRYPTO_Type *base, uint32_ * Function Name: Cy_Crypto_Core_V2_Crc_CalcPartial ****************************************************************************//** * -* Performs CRC calculation of a message part. +* Performs the CRC calculation of a message part. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param data * The pointer to the message whose CRC is being computed. @@ -257,19 +260,19 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcStart(CRYPTO_Type *base, uint32_ * The size of a message in bytes. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcPartial(CRYPTO_Type *base, void const *data, uint32_t dataSize) { - /* Fill the FIFO with the instruction parameters */ + /* Fills the FIFO with the instruction parameters. */ Cy_Crypto_Core_V2_FFStart(base, CY_CRYPTO_V2_RB_FF_LOAD0, (uint8_t const *)data, dataSize); - /* Issue the CRC instruction */ + /* Issues the CRC instruction. */ Cy_Crypto_Core_V2_Run(base, CY_CRYPTO_V2_CRC_OPC); - /* Wait until CRC instruction is complete */ + /* Waits until the CRC instruction is complete. */ Cy_Crypto_Core_V2_Sync(base); return (CY_CRYPTO_SUCCESS); @@ -279,10 +282,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcPartial(CRYPTO_Type *base, * Function Name: Cy_Crypto_Core_V2_Crc_CalcFinish ****************************************************************************//** * -* Finalizes CRC calculation. +* Finalizes the CRC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -291,22 +294,22 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcPartial(CRYPTO_Type *base, * The pointer to a computed CRC value. Must be 4-byte aligned. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcFinish(CRYPTO_Type *base, uint32_t width, uint32_t *crc) { - CY_ASSERT_L1((width >= 1) && (width <=32u)); + CY_ASSERT_L1((width >= 1U) && (width <= CY_CRYPTO_HW_REGS_WIDTH)); uint32_t calculatedCrc; - /* Copy the result from the CRC_REM_RESULT register */ + /* Copies the result from the CRC_REM_RESULT register. */ calculatedCrc = (uint32_t)_FLD2VAL(CRYPTO_V2_CRC_REM_RESULT_REM, REG_CRYPTO_CRC_REM_RESULT(base)); - /* Note: Calculated CRC value is MSB aligned and should be shifted WHEN CRC_DATA_REVERSE is zero. */ - if (_FLD2VAL(CRYPTO_V2_CRC_CTL_REM_REVERSE, REG_CRYPTO_CRC_CTL(base)) == 0u) + /* NOTE The calculated CRC value is MSB-aligned and should be shifted WHEN CRC_DATA_REVERSE is zero. */ + if (_FLD2VAL(CRYPTO_V2_CRC_CTL_REM_REVERSE, REG_CRYPTO_CRC_CTL(base)) == 0U) { - calculatedCrc = calculatedCrc >> (32u - width); + calculatedCrc = calculatedCrc >> (CY_CRYPTO_HW_REGS_WIDTH - width); } *crc = calculatedCrc; @@ -318,10 +321,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcFinish(CRYPTO_Type *base, uint32 * Function Name: Cy_Crypto_Core_V2_Crc_Calc ****************************************************************************//** * -* Performs CRC calculation on a message. +* Performs the CRC calculation on a message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param width * The CRC width in bits. @@ -336,7 +339,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_CalcFinish(CRYPTO_Type *base, uint32 * The size of a message in bytes. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_Calc(CRYPTO_Type *base, @@ -345,26 +348,26 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Crc_Calc(CRYPTO_Type *base, void const *data, uint32_t dataSize) { - CY_ASSERT_L1((width >= 1) && (width <=32u)); + CY_ASSERT_L1((width >= 1U) && (width <= CY_CRYPTO_HW_REGS_WIDTH)); uint32_t calculatedCrc; - /* Fill the FIFO with the instruction parameters */ + /* Fills the FIFO with the instruction parameters. */ Cy_Crypto_Core_V2_FFStart(base, CY_CRYPTO_V2_RB_FF_LOAD0, (uint8_t const *)data, dataSize); - /* Issue the CRC instruction */ + /* Issues the CRC instruction. */ Cy_Crypto_Core_V2_Run(base, CY_CRYPTO_V2_CRC_OPC); - /* Wait until CRC instruction is complete */ + /* Waits until the CRC instruction is complete. */ Cy_Crypto_Core_V2_Sync(base); - /* Copy the result from the CRC_REM_RESULT register */ + /* Copies the result from the CRC_REM_RESULT register. */ calculatedCrc = (uint32_t)_FLD2VAL(CRYPTO_V2_CRC_REM_RESULT_REM, REG_CRYPTO_CRC_REM_RESULT(base)); - /* Note: Calculated CRC value is MSB aligned and should be shifted WHEN CRC_DATA_REVERSE is zero. */ - if (_FLD2VAL(CRYPTO_V2_CRC_CTL_REM_REVERSE, REG_CRYPTO_CRC_CTL(base)) == 0u) + /* NOTE The calculated CRC value is MSB-aligned and should be shifted WHEN CRC_DATA_REVERSE is zero. */ + if (_FLD2VAL(CRYPTO_V2_CRC_CTL_REM_REVERSE, REG_CRYPTO_CRC_CTL(base)) == 0U) { - calculatedCrc = calculatedCrc >> (32u - width); + calculatedCrc = calculatedCrc >> (CY_CRYPTO_HW_REGS_WIDTH - width); } *crc = calculatedCrc; diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_des_v1.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_des_v1.c index 5fe50a3f38..73c53e78c1 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_des_v1.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_des_v1.c @@ -91,7 +91,7 @@ static void Cy_Crypto_Core_V1_Des_ProcessBlock(CRYPTO_Type *base, * srcBlock could overlap dstBlock. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * One of CRYPTO_ENCRYPT or CRYPTO_DECRYPT. @@ -145,7 +145,7 @@ static void Cy_Crypto_Core_V1_Des_ProcessBlock(CRYPTO_Type *base, * This function is independent from the previous Crypto state. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -161,7 +161,7 @@ static void Cy_Crypto_Core_V1_Des_ProcessBlock(CRYPTO_Type *base, * The pointer to a source block. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Des(CRYPTO_Type *base, @@ -176,12 +176,11 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Des(CRYPTO_Type *base, cy_stc_crypto_des_buffers_t *desBuffers = (cy_stc_crypto_des_buffers_t *)REG_CRYPTO_MEM_BUFF(base); /* Check weak keys */ - for (i = 0u; i < CY_CRYPTO_DES_WEAK_KEY_COUNT; i++) + for (i = 0U; (i < CY_CRYPTO_DES_WEAK_KEY_COUNT) && (CY_CRYPTO_SUCCESS == status); i++) { - if (memcmp(key, (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0) + if (Cy_Crypto_Core_V1_MemCmp(base, key, (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0U) { status = CY_CRYPTO_DES_WEAK_KEY; - break; } } @@ -205,7 +204,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Des(CRYPTO_Type *base, * This function is independent from the previous Crypto state. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -221,7 +220,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Des(CRYPTO_Type *base, * The pointer to a source data block. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Tdes(CRYPTO_Type *base, @@ -236,30 +235,18 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Tdes(CRYPTO_Type *base, cy_stc_crypto_des_buffers_t *desBuffers = (cy_stc_crypto_des_buffers_t *)REG_CRYPTO_MEM_BUFF(base); /* Check weak keys */ - for (i = 0u; i < CY_CRYPTO_DES_WEAK_KEY_COUNT; i++) + for (i = 0U; (i < CY_CRYPTO_DES_WEAK_KEY_COUNT) && (CY_CRYPTO_SUCCESS == status); i++) { - if (memcmp(key, (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0) + for (uint32_t keynum=0U; (keynum < (CY_CRYPTO_TDES_KEY_SIZE / CY_CRYPTO_DES_KEY_SIZE)) && (CY_CRYPTO_SUCCESS == status); keynum++) { - status = CY_CRYPTO_DES_WEAK_KEY; - break; - } - - if (memcmp(&(key[CY_CRYPTO_DES_KEY_BYTE_LENGTH]), - (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0) - { - status = CY_CRYPTO_DES_WEAK_KEY; - break; - } - - if (memcmp(&(key[2u * CY_CRYPTO_DES_KEY_BYTE_LENGTH]), - (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0) - { - status = CY_CRYPTO_DES_WEAK_KEY; - break; + if (Cy_Crypto_Core_V1_MemCmp(base, &(key[keynum * CY_CRYPTO_DES_KEY_BYTE_LENGTH]), (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0U) + { + status = CY_CRYPTO_DES_WEAK_KEY; + } } } - Cy_Crypto_Core_V1_MemCpy(base, desBuffers->key, key, CY_CRYPTO_DES_KEY_BYTE_LENGTH * 3u); + Cy_Crypto_Core_V1_MemCpy(base, desBuffers->key, key, CY_CRYPTO_DES_KEY_BYTE_LENGTH * 3U); Cy_Crypto_Core_V1_MemCpy(base, desBuffers->block0, src, CY_CRYPTO_DES_KEY_BYTE_LENGTH); Cy_Crypto_Core_V1_Des_ProcessBlock(base, CY_CRYPTO_DES_MODE_TRIPLE, dirMode, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_des_v2.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_des_v2.c index c0152db4e1..e1ea2b72d0 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_des_v2.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_des_v2.c @@ -36,8 +36,8 @@ #if (CPUSS_CRYPTO_DES == 1) -#define CY_CRYPTO_DES_WEAK_KEY_COUNT (16u) -#define CY_CRYPTO_DES_KEY_BYTE_LENGTH (8u) +#define CY_CRYPTO_DES_WEAK_KEY_COUNT (16U) +#define CY_CRYPTO_DES_KEY_BYTE_LENGTH (8U) typedef enum { @@ -78,7 +78,7 @@ static uint8_t const cy_desWeakKeys[CY_CRYPTO_DES_WEAK_KEY_COUNT][CY_CRYPTO_DES_ * This function is independent from the previous Crypto state. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -94,7 +94,7 @@ static uint8_t const cy_desWeakKeys[CY_CRYPTO_DES_WEAK_KEY_COUNT][CY_CRYPTO_DES_ * The pointer to a source data block. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Des(CRYPTO_Type *base, @@ -107,9 +107,9 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Des(CRYPTO_Type *base, cy_en_crypto_status_t status = CY_CRYPTO_SUCCESS; /* Check weak keys */ - for (i = 0u; i < CY_CRYPTO_DES_WEAK_KEY_COUNT; i++) + for (i = 0U; i < CY_CRYPTO_DES_WEAK_KEY_COUNT; i++) { - if (Cy_Crypto_Core_V2_MemCmp(base, key, (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0u) + if (Cy_Crypto_Core_V2_MemCmp(base, key, (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0U) { status = CY_CRYPTO_DES_WEAK_KEY; break; @@ -139,7 +139,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Des(CRYPTO_Type *base, * This function is independent from the previous Crypto state. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dirMode * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT @@ -155,7 +155,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Des(CRYPTO_Type *base, * The pointer to a source data block. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Tdes(CRYPTO_Type *base, @@ -168,36 +168,24 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Tdes(CRYPTO_Type *base, cy_en_crypto_status_t status = CY_CRYPTO_SUCCESS; /* Check weak keys */ - for (i = 0u; i < CY_CRYPTO_DES_WEAK_KEY_COUNT; i++) + for (i = 0U; (i < CY_CRYPTO_DES_WEAK_KEY_COUNT) && (CY_CRYPTO_SUCCESS == status); i++) { - if (Cy_Crypto_Core_V2_MemCmp(base, key, (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0u) + for (uint32_t keynum=0U; (keynum < (CY_CRYPTO_TDES_KEY_SIZE / CY_CRYPTO_DES_KEY_SIZE)) && (CY_CRYPTO_SUCCESS == status); keynum++) { - status = CY_CRYPTO_DES_WEAK_KEY; - break; - } - - if (Cy_Crypto_Core_V2_MemCmp(base, &(key[CY_CRYPTO_DES_KEY_BYTE_LENGTH]), - (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0u) - { - status = CY_CRYPTO_DES_WEAK_KEY; - break; - } - - if (Cy_Crypto_Core_V2_MemCmp(base, &(key[2u * CY_CRYPTO_DES_KEY_BYTE_LENGTH]), - (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0u) - { - status = CY_CRYPTO_DES_WEAK_KEY; - break; + if (Cy_Crypto_Core_V2_MemCmp(base, &(key[keynum * CY_CRYPTO_DES_KEY_BYTE_LENGTH]), (uint8_t const *)cy_desWeakKeys[i], CY_CRYPTO_DES_KEY_BYTE_LENGTH) == 0U) + { + status = CY_CRYPTO_DES_WEAK_KEY; + } } } /* Load keys */ - Cy_Crypto_Core_V2_FFContinue(base, CY_CRYPTO_V2_RB_FF_LOAD0, key, CY_CRYPTO_DES_KEY_BYTE_LENGTH * 3u); - Cy_Crypto_Core_V2_BlockMov (base, CY_CRYPTO_V2_RB_KEY0, CY_CRYPTO_V2_RB_FF_LOAD0, CY_CRYPTO_DES_KEY_BYTE_LENGTH * 2u); + Cy_Crypto_Core_V2_FFContinue(base, CY_CRYPTO_V2_RB_FF_LOAD0, key, CY_CRYPTO_DES_KEY_BYTE_LENGTH * 3U); + Cy_Crypto_Core_V2_BlockMov (base, CY_CRYPTO_V2_RB_KEY0, CY_CRYPTO_V2_RB_FF_LOAD0, CY_CRYPTO_DES_KEY_BYTE_LENGTH * 2U); Cy_Crypto_Core_V2_BlockMov (base, CY_CRYPTO_V2_RB_KEY1, CY_CRYPTO_V2_RB_FF_LOAD0, CY_CRYPTO_DES_KEY_BYTE_LENGTH); Cy_Crypto_Core_V2_FFContinue(base, CY_CRYPTO_V2_RB_FF_LOAD0, src, CY_CRYPTO_DES_KEY_BYTE_LENGTH); - Cy_Crypto_Core_V2_FFStart (base, CY_CRYPTO_V2_RB_FF_STORE, dst, CY_CRYPTO_DES_KEY_BYTE_LENGTH); + Cy_Crypto_Core_V2_FFStart (base, CY_CRYPTO_V2_RB_FF_STORE, dst, CY_CRYPTO_DES_KEY_BYTE_LENGTH); Cy_Crypto_Core_V2_BlockMov(base, CY_CRYPTO_V2_RB_BLOCK0, CY_CRYPTO_V2_RB_FF_LOAD0, CY_CRYPTO_DES_KEY_BYTE_LENGTH); Cy_Crypto_Core_V2_Run(base, (uint32_t)((dirMode == CY_CRYPTO_ENCRYPT) ? (CY_CRYPTO_V2_TDES_OPC) : (CY_CRYPTO_V2_TDES_INV_OPC))); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_domain_params.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_domain_params.c index 2b1f0122f6..f0c41ba4eb 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_domain_params.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_domain_params.c @@ -27,445 +27,444 @@ #include "cy_crypto_core_ecc.h" #include "cy_syslib.h" -const cy_stc_crypto_ecc_dp_type eccDomainParams[]; - /******************************************************************************* * Function Name: Cy_Crypto_Core_ECC_GetCurveParams ****************************************************************************//** * -* . +* Get curve domain parameters if this curve is supported. * * \param curveID * See \ref cy_en_crypto_ecc_curve_id_t. * -* \return status code. See \ref cy_stc_crypto_ecc_dp_type. +* \return +* Pointer to curve domain parameters. See \ref cy_stc_crypto_ecc_dp_type. * *******************************************************************************/ cy_stc_crypto_ecc_dp_type *Cy_Crypto_Core_ECC_GetCurveParams(cy_en_crypto_ecc_curve_id_t curveId) { - cy_stc_crypto_ecc_dp_type *result = NULL; + /* P192 CURVE PARAMETERS */ + CY_ALIGN(4) static const uint8_t eccP192Polynomial[CY_CRYPTO_ECC_P192_BYTE_SIZE] = + { + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xfeu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + }; + + CY_ALIGN(4) static const uint8_t eccP192PolyBarrett[CY_CRYPTO_ECC_P192_BYTE_SIZE + 1u] = + { /* pre-calculated */ + 0x01u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x01u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x01u + }; + CY_ALIGN(4) static const uint8_t eccP192Order[CY_CRYPTO_ECC_P192_BYTE_SIZE] = + { + 0x31u, 0x28u, 0xD2u, 0xB4u, 0xB1u, 0xC9u, 0x6Bu, 0x14u, + 0x36u, 0xF8u, 0xDEu, 0x99u, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu + }; + + /* barrett_o: "1000000000000000000000000662107c9eb94364e4b2dd7cf" */ + CY_ALIGN(4) static const uint8_t eccP192OrderBarrett[CY_CRYPTO_ECC_P192_BYTE_SIZE + 1u] = + { /* pre-calculated */ + 0xcfu, 0xd7u, 0x2du, 0x4bu, 0x4eu, 0x36u, 0x94u, 0xebu, + 0xc9u, 0x07u, 0x21u, 0x66u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x01u + }; + + /* base point x: "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012" */ + CY_ALIGN(4) static const uint8_t eccP192BasePointX[CY_CRYPTO_ECC_P192_BYTE_SIZE] = + { + 0x12u, 0x10u, 0xffu, 0x82u, 0xfdu, 0x0au, 0xffu, 0xf4u, + 0x00u, 0x88u, 0xa1u, 0x43u, 0xebu, 0x20u, 0xbfu, 0x7cu, + 0xf6u, 0x90u, 0x30u, 0xb0u, 0x0eu, 0xa8u, 0x8du, 0x18u + }; + + /* base point y: "07192B95FFC8DA78631011ED6B24CDD573F977A11E794811" */ + CY_ALIGN(4) static const uint8_t eccP192BasePointY[CY_CRYPTO_ECC_P192_BYTE_SIZE] = + { + 0x11u, 0x48u, 0x79u, 0x1eu, 0xa1u, 0x77u, 0xf9u, 0x73u, + 0xd5u, 0xcdu, 0x24u, 0x6bu, 0xedu, 0x11u, 0x10u, 0x63u, + 0x78u, 0xdau, 0xc8u, 0xffu, 0x95u, 0x2bu, 0x19u, 0x07u + }; + + /* P224 CURVE PARAMETERS */ + CY_ALIGN(4) static const uint8_t eccP224Polynomial[CY_CRYPTO_ECC_P224_BYTE_SIZE] = + { + 0x01u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu + }; + + CY_ALIGN(4) static const uint8_t eccP224PolyBarrett[CY_CRYPTO_ECC_P224_BYTE_SIZE + 1u] = + { /* pre-calculated */ + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x01u + }; + + CY_ALIGN(4) static const uint8_t eccP224Order[CY_CRYPTO_ECC_P224_BYTE_SIZE] = + { + 0x3Du, 0x2Au, 0x5Cu, 0x5Cu, 0x45u, 0x29u, 0xDDu, 0x13u, + 0x3Eu, 0xF0u, 0xB8u, 0xE0u, 0xA2u, 0x16u, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu + }; + /* barrett_o: "10000000000000000000000000000e95d1f470fc1ec22d6baa3a3d5c3" */ + CY_ALIGN(4) static const uint8_t eccP224OrderBarrett[CY_CRYPTO_ECC_P224_BYTE_SIZE + 1u] = + { /* pre-calculated */ + 0xc3u, 0xd5u, 0xa3u, 0xa3u, 0xbau, 0xd6u, 0x22u, 0xecu, + 0xc1u, 0x0fu, 0x47u, 0x1fu, 0x5du, 0xe9u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x01u + }; + + /* Gx - base point x: "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21" */ + CY_ALIGN(4) static const uint8_t eccP224BasePointX[CY_CRYPTO_ECC_P224_BYTE_SIZE] = + { + 0x21u, 0x1du, 0x5cu, 0x11u, 0xd6u, 0x80u, 0x32u, 0x34u, + 0x22u, 0x11u, 0xc2u, 0x56u, 0xd3u, 0xc1u, 0x03u, 0x4au, + 0xb9u, 0x90u, 0x13u, 0x32u, 0x7fu, 0xbfu, 0xb4u, 0x6bu, + 0xbdu, 0x0cu, 0x0eu, 0xb7u + }; + + /* Gy - base point y: "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34" */ + CY_ALIGN(4) static const uint8_t eccP224BasePointY[CY_CRYPTO_ECC_P224_BYTE_SIZE] = + { + 0x34u, 0x7eu, 0x00u, 0x85u, 0x99u, 0x81u, 0xd5u, 0x44u, + 0x64u, 0x47u, 0x07u, 0x5au, 0xa0u, 0x75u, 0x43u, 0xcdu, + 0xe6u, 0xdfu, 0x22u, 0x4cu, 0xfbu, 0x23u, 0xf7u, 0xb5u, + 0x88u, 0x63u, 0x37u, 0xbdu + }; + + + /* P256 CURVE PARAMETERS */ + /* prime: "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF" */ + CY_ALIGN(4) static const uint8_t eccP256Polynomial[CY_CRYPTO_ECC_P256_BYTE_SIZE] = + { + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x01u, 0x00u, 0x00u, 0x00u, 0xffu, 0xffu, 0xffu, 0xffu + }; + + /* barrett_p: "100000000fffffffffffffffefffffffefffffffeffffffff0000000000000003" */ + CY_ALIGN(4) static const uint8_t eccP256PolyBarrett[CY_CRYPTO_ECC_P256_BYTE_SIZE + 1u] = + { /* pre-calculated! */ + 0x03u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0xffu, 0xffu, 0xffu, 0xffu, 0xfeu, 0xffu, 0xffu, 0xffu, + 0xfeu, 0xffu, 0xffu, 0xffu, 0xfeu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, + 0x01u + }; + + /* order: "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551" */ + CY_ALIGN(4) static const uint8_t eccP256Order[CY_CRYPTO_ECC_P256_BYTE_SIZE] = + { + 0x51u, 0x25u, 0x63u, 0xfcu, 0xc2u, 0xcau, 0xb9u, 0xf3u, + 0x84u, 0x9eu, 0x17u, 0xa7u, 0xadu, 0xfau, 0xe6u, 0xbcu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0x00u, 0x00u, 0x00u, 0x00u, 0xffu, 0xffu, 0xffu, 0xffu + }; + + /* barrett_o: 100000000fffffffffffffffeffffffff43190552df1a6c21012ffd85eedf9bfe" */ + CY_ALIGN(4) static const uint8_t eccP256OrderBarrett[CY_CRYPTO_ECC_P256_BYTE_SIZE + 1u] = + { /* pre-calculated */ + 0xfeu, 0x9bu, 0xdfu, 0xeeu, 0x85u, 0xfdu, 0x2fu, 0x01u, + 0x21u, 0x6cu, 0x1au, 0xdfu, 0x52u, 0x05u, 0x19u, 0x43u, + 0xffu, 0xffu, 0xffu, 0xffu, 0xfeu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, + 0x01u + }; + + /* base point x: "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296" */ + CY_ALIGN(4) static const uint8_t eccP256BasePointX[CY_CRYPTO_ECC_P256_BYTE_SIZE] = + { + 0x96u, 0xc2u, 0x98u, 0xd8u, 0x45u, 0x39u, 0xa1u, 0xf4u, + 0xa0u, 0x33u, 0xebu, 0x2du, 0x81u, 0x7du, 0x03u, 0x77u, + 0xf2u, 0x40u, 0xa4u, 0x63u, 0xe5u, 0xe6u, 0xbcu, 0xf8u, + 0x47u, 0x42u, 0x2cu, 0xe1u, 0xf2u, 0xd1u, 0x17u, 0x6bu + }; + + /* base point y: "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5" */ + CY_ALIGN(4) static const uint8_t eccP256BasePointY[CY_CRYPTO_ECC_P256_BYTE_SIZE] = + { + 0xf5u, 0x51u, 0xbfu, 0x37u, 0x68u, 0x40u, 0xb6u, 0xcbu, + 0xceu, 0x5eu, 0x31u, 0x6bu, 0x57u, 0x33u, 0xceu, 0x2bu, + 0x16u, 0x9eu, 0x0fu, 0x7cu, 0x4au, 0xebu, 0xe7u, 0x8eu, + 0x9bu, 0x7fu, 0x1au, 0xfeu, 0xe2u, 0x42u, 0xe3u, 0x4fu, + }; + + /* prime: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF" */ + CY_ALIGN(4) static const uint8_t eccP384Polynomial[CY_CRYPTO_ECC_P384_BYTE_SIZE] = + { + 0xffu, 0xffu, 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0xffu, 0xffu, 0xffu, 0xffu, + 0xfeu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu + }; + + /* barrett_p: "1000000000000000000000000000000000000000000000000000000000000000100000000ffffffffffffffff00000001" */ + CY_ALIGN(4) static const uint8_t eccP384PolyBarrett[CY_CRYPTO_ECC_P384_BYTE_SIZE + 1u] = + { /* pre-calculated */ + 0x01u, 0x00u, 0x00u, 0x00u, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, + 0x01u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x01u + }; + + /* order: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973" */ + CY_ALIGN(4) static const uint8_t eccP384Order[CY_CRYPTO_ECC_P384_BYTE_SIZE] = + { + 0x73u, 0x29u, 0xC5u, 0xCCu, 0x6Au, 0x19u, 0xECu, 0xECu, + 0x7Au, 0xA7u, 0xB0u, 0x48u, 0xB2u, 0x0Du, 0x1Au, 0x58u, + 0xDFu, 0x2Du, 0x37u, 0xF4u, 0x81u, 0x4Du, 0x63u, 0xC7u, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu + }; + + /* barrett_o: "1000000000000000000000000000000000000000000000000389cb27e0bc8d220a7e5f24db74f58851313e695333ad68d" */ + CY_ALIGN(4) static const uint8_t eccP384OrderBarrett[CY_CRYPTO_ECC_P384_BYTE_SIZE + 1u] = + { /* pre-calculated */ + 0x8du, 0xd6u, 0x3au, 0x33u, 0x95u, 0xe6u, 0x13u, 0x13u, + 0x85u, 0x58u, 0x4fu, 0xb7u, 0x4du, 0xf2u, 0xe5u, 0xa7u, + 0x20u, 0xd2u, 0xc8u, 0x0bu, 0x7eu, 0xb2u, 0x9cu, 0x38u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x01u + }; + + /* base point x: "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7" */ + CY_ALIGN(4) static const uint8_t eccP384BasePointX[CY_CRYPTO_ECC_P384_BYTE_SIZE] = + { + 0xb7u, 0x0au, 0x76u, 0x72u, 0x38u, 0x5eu, 0x54u, 0x3au, + 0x6cu, 0x29u, 0x55u, 0xbfu, 0x5du, 0xf2u, 0x02u, 0x55u, + 0x38u, 0x2au, 0x54u, 0x82u, 0xe0u, 0x41u, 0xf7u, 0x59u, + 0x98u, 0x9bu, 0xa7u, 0x8bu, 0x62u, 0x3bu, 0x1du, 0x6eu, + 0x74u, 0xadu, 0x20u, 0xf3u, 0x1eu, 0xc7u, 0xb1u, 0x8eu, + 0x37u, 0x05u, 0x8bu, 0xbeu, 0x22u, 0xcau, 0x87u, 0xaau + }; + + /* base point y: "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F" */ + CY_ALIGN(4) static const uint8_t eccP384BasePointY[CY_CRYPTO_ECC_P384_BYTE_SIZE] = + { + 0x5fu, 0x0eu, 0xeau, 0x90u, 0x7cu, 0x1du, 0x43u, 0x7au, + 0x9du, 0x81u, 0x7eu, 0x1du, 0xceu, 0xb1u, 0x60u, 0x0au, + 0xc0u, 0xb8u, 0xf0u, 0xb5u, 0x13u, 0x31u, 0xdau, 0xe9u, + 0x7cu, 0x14u, 0x9au, 0x28u, 0xbdu, 0x1du, 0xf4u, 0xf8u, + 0x29u, 0xdcu, 0x92u, 0x92u, 0xbfu, 0x98u, 0x9eu, 0x5du, + 0x6fu, 0x2cu, 0x26u, 0x96u, 0x4au, 0xdeu, 0x17u, 0x36u + }; + + CY_ALIGN(4) static const uint8_t eccP521Polynomial[CY_CRYPTO_ECC_P521_BYTE_SIZE] = + { + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0x01u + }; + + CY_ALIGN(4) static const uint8_t eccP521PolyBarrett[CY_CRYPTO_ECC_P521_BYTE_SIZE] = + { /* pre-calculated */ + 0x01u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x02u + }; + + CY_ALIGN(4) static const uint8_t eccP521Order[CY_CRYPTO_ECC_P521_BYTE_SIZE] = + { + 0x09u, 0x64u, 0x38u, 0x91u, 0x1Eu, 0xB7u, 0x6Fu, 0xBBu, + 0xAEu, 0x47u, 0x9Cu, 0x89u, 0xB8u, 0xC9u, 0xB5u, 0x3Bu, + 0xD0u, 0xA5u, 0x09u, 0xF7u, 0x48u, 0x01u, 0xCCu, 0x7Fu, + 0x6Bu, 0x96u, 0x2Fu, 0xBFu, 0x83u, 0x87u, 0x86u, 0x51u, + 0xFAu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, + 0xffu, 0x01u + }; + + /* barrett_o: "2000000000000000000000000000000000000000000000000000000000000000005ae79787c40d069948033feb708f65a2fc44a36477663b851449048e16ec79bf7" */ + CY_ALIGN(4) static const uint8_t eccP521OrderBarrett[CY_CRYPTO_ECC_P521_BYTE_SIZE] = + { /* pre-calculated */ + 0xf7u, 0x9bu, 0xc7u, 0x6eu, 0xe1u, 0x48u, 0x90u, 0x44u, + 0x51u, 0xb8u, 0x63u, 0x76u, 0x47u, 0x36u, 0x4au, 0xc4u, + 0x2fu, 0x5au, 0xf6u, 0x08u, 0xb7u, 0xfeu, 0x33u, 0x80u, + 0x94u, 0x69u, 0xd0u, 0x40u, 0x7cu, 0x78u, 0x79u, 0xaeu, + 0x05u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x02u + }; + + /* base point x: "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66" */ + CY_ALIGN(4) static const uint8_t eccP521BasePointX[CY_CRYPTO_ECC_P521_BYTE_SIZE] = + { + 0x66u, 0xbdu, 0xe5u, 0xc2u, 0x31u, 0x7eu, 0x7eu, 0xf9u, + 0x9bu, 0x42u, 0x6au, 0x85u, 0xc1u, 0xb3u, 0x48u, 0x33u, + 0xdeu, 0xa8u, 0xffu, 0xa2u, 0x27u, 0xc1u, 0x1du, 0xfeu, + 0x28u, 0x59u, 0xe7u, 0xefu, 0x77u, 0x5eu, 0x4bu, 0xa1u, + 0xbau, 0x3du, 0x4du, 0x6bu, 0x60u, 0xafu, 0x28u, 0xf8u, + 0x21u, 0xb5u, 0x3fu, 0x05u, 0x39u, 0x81u, 0x64u, 0x9cu, + 0x42u, 0xb4u, 0x95u, 0x23u, 0x66u, 0xcbu, 0x3eu, 0x9eu, + 0xcdu, 0xe9u, 0x04u, 0x04u, 0xb7u, 0x06u, 0x8eu, 0x85u, + 0xc6u, 0x00u + }; + + /* base point y: "011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650" */ + CY_ALIGN(4) static const uint8_t eccP521BasePointY[CY_CRYPTO_ECC_P521_BYTE_SIZE] = + { + 0x50u, 0x66u, 0xd1u, 0x9fu, 0x76u, 0x94u, 0xbeu, 0x88u, + 0x40u, 0xc2u, 0x72u, 0xa2u, 0x86u, 0x70u, 0x3cu, 0x35u, + 0x61u, 0x07u, 0xadu, 0x3fu, 0x01u, 0xb9u, 0x50u, 0xc5u, + 0x40u, 0x26u, 0xf4u, 0x5eu, 0x99u, 0x72u, 0xeeu, 0x97u, + 0x2cu, 0x66u, 0x3eu, 0x27u, 0x17u, 0xbdu, 0xafu, 0x17u, + 0x68u, 0x44u, 0x9bu, 0x57u, 0x49u, 0x44u, 0xf5u, 0x98u, + 0xd9u, 0x1bu, 0x7du, 0x2cu, 0xb4u, 0x5fu, 0x8au, 0x5cu, + 0x04u, 0xc0u, 0x3bu, 0x9au, 0x78u, 0x6au, 0x29u, 0x39u, + 0x18u, 0x01u + }; + + static const cy_stc_crypto_ecc_dp_type eccDomainParams[] = + { + { + CY_CRYPTO_ECC_ECP_NONE, + 0u, + NULL, + CY_CRYPTO_NIST_P_CURVE_SPECIFIC_RED_ALG, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL + }, + { + CY_CRYPTO_ECC_ECP_SECP192R1, + CY_CRYPTO_ECC_P192_SIZE, + "NIST P-192", + CY_CRYPTO_NIST_P_CURVE_SPECIFIC_RED_ALG, + /* prime: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF" */ + eccP192Polynomial, + /* barrett_p: "1000000000000000000000000000000010000000000000001" */ + eccP192PolyBarrett, + /* order: "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831" */ + eccP192Order, + /* barrett_o: "1000000000000000000000000662107c9eb94364e4b2dd7cf" */ + eccP192OrderBarrett, + /* base point x: "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012" */ + eccP192BasePointX, + /* base point y: "07192B95FFC8DA78631011ED6B24CDD573F977A11E794811" */ + eccP192BasePointY + }, + { + CY_CRYPTO_ECC_ECP_SECP224R1, + CY_CRYPTO_ECC_P224_SIZE, + "NIST P-224", + CY_CRYPTO_NIST_P_CURVE_SPECIFIC_RED_ALG, + /* prime: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001" */ + eccP224Polynomial, + /* barrett_p: "100000000000000000000000000000000ffffffffffffffffffffffff" */ + eccP224PolyBarrett, + /* order: "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D" */ + eccP224Order, + /* barrett_o: "10000000000000000000000000000e95d1f470fc1ec22d6baa3a3d5c3" */ + eccP224OrderBarrett, + /* Gx - base point x: "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21" */ + eccP224BasePointX, + /* Gy - base point y: "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34" */ + eccP224BasePointY + }, + { + CY_CRYPTO_ECC_ECP_SECP256R1, + CY_CRYPTO_ECC_P256_SIZE, + "NIST P-256", + CY_CRYPTO_NIST_P_BARRETT_RED_ALG, + /* prime: "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF" */ + eccP256Polynomial, + /* barrett_p: "100000000fffffffffffffffefffffffefffffffeffffffff0000000000000003" */ + eccP256PolyBarrett, + /* order: "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551" */ + eccP256Order, + /* barrett_o: "100000000fffffffffffffffeffffffff43190552df1a6c21012ffd85eedf9bfe" */ + eccP256OrderBarrett, + /* Gx - base point x: "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296" */ + eccP256BasePointX, + /* Gy - base point y: "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5" */ + eccP256BasePointY + }, + { + CY_CRYPTO_ECC_ECP_SECP384R1, + CY_CRYPTO_ECC_P384_SIZE, + "NIST P-384", + CY_CRYPTO_NIST_P_BARRETT_RED_ALG, + /* prime: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF" */ + eccP384Polynomial, + /* barrett_p: "1000000000000000000000000000000000000000000000000000000000000000100000000ffffffffffffffff00000001" */ + eccP384PolyBarrett, + /* order: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973" */ + eccP384Order, + /* barrett_o: "1000000000000000000000000000000000000000000000000389cb27e0bc8d220a7e5f24db74f58851313e695333ad68d" */ + eccP384OrderBarrett, + /* base point x: "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7" */ + eccP384BasePointX, + /* base point y: "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F" */ + eccP384BasePointY + }, + { + CY_CRYPTO_ECC_ECP_SECP521R1, + CY_CRYPTO_ECC_P521_SIZE, + "NIST P-521", + /* Currently driver uses CY_CRYPTO_NIST_P_BARRETT_RED_ALG algorithm instead of + curve specific CY_CRYPTO_NIST_P_CURVE_SPECIFIC_RED_ALG */ + CY_CRYPTO_NIST_P_BARRETT_RED_ALG, + /* prime: "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" */ + eccP521Polynomial, + /* barrett_p: "20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" */ + eccP521PolyBarrett, + /* order: "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409" */ + eccP521Order, + /* barrett_o: "2000000000000000000000000000000000000000000000000000000000000000005ae79787c40d069948033feb708f65a2fc44a36477663b851449048e16ec79bf7" */ + eccP521OrderBarrett, + /* base point x: "0C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66" */ + eccP521BasePointX, + /* base point y: "11839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650" */ + eccP521BasePointY + } + }; + + cy_stc_crypto_ecc_dp_type *tmpResult = NULL; if ((curveId > CY_CRYPTO_ECC_ECP_NONE) && (curveId < CY_CRYPTO_ECC_ECP_CURVES_CNT)) { - result = (cy_stc_crypto_ecc_dp_type *)&eccDomainParams[curveId]; + tmpResult = (cy_stc_crypto_ecc_dp_type *)&eccDomainParams[curveId]; } - return result; + return tmpResult; } -/* P192 CURVE PARAMETERS */ -CY_ALIGN(4) const uint8_t eccP192Polynomial[CY_CRYPTO_ECC_P192_BYTE_SIZE] = -{ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -}; - -CY_ALIGN(4) const uint8_t eccP192PolyBarrett[CY_CRYPTO_ECC_P192_BYTE_SIZE + 1u] = -{ /* pre-calculated */ - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01 -}; -CY_ALIGN(4) const uint8_t eccP192Order[CY_CRYPTO_ECC_P192_BYTE_SIZE] = -{ - 0x31, 0x28, 0xD2, 0xB4, 0xB1, 0xC9, 0x6B, 0x14, - 0x36, 0xF8, 0xDE, 0x99, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; - -/* barrett_o: "1000000000000000000000000662107c9eb94364e4b2dd7cf" */ -CY_ALIGN(4) const uint8_t eccP192OrderBarrett[CY_CRYPTO_ECC_P192_BYTE_SIZE + 1u] = -{ /* pre-calculated */ - 0xcf, 0xd7, 0x2d, 0x4b, 0x4e, 0x36, 0x94, 0xeb, - 0xc9, 0x07, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01 -}; - -/* base point x: "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012" */ -CY_ALIGN(4) const uint8_t eccP192BasePointX[CY_CRYPTO_ECC_P192_BYTE_SIZE] = -{ - 0x12, 0x10, 0xff, 0x82, 0xfd, 0x0a, 0xff, 0xf4, - 0x00, 0x88, 0xa1, 0x43, 0xeb, 0x20, 0xbf, 0x7c, - 0xf6, 0x90, 0x30, 0xb0, 0x0e, 0xa8, 0x8d, 0x18 -}; - -/* base point y: "07192B95FFC8DA78631011ED6B24CDD573F977A11E794811" */ -CY_ALIGN(4) const uint8_t eccP192BasePointY[CY_CRYPTO_ECC_P192_BYTE_SIZE] = -{ - 0x11, 0x48, 0x79, 0x1e, 0xa1, 0x77, 0xf9, 0x73, - 0xd5, 0xcd, 0x24, 0x6b, 0xed, 0x11, 0x10, 0x63, - 0x78, 0xda, 0xc8, 0xff, 0x95, 0x2b, 0x19, 0x07 -}; - -/* P224 CURVE PARAMETERS */ -CY_ALIGN(4) const uint8_t eccP224Polynomial[CY_CRYPTO_ECC_P224_BYTE_SIZE] = -{ - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff -}; - -CY_ALIGN(4) const uint8_t eccP224PolyBarrett[CY_CRYPTO_ECC_P224_BYTE_SIZE + 1u] = -{ /* pre-calculated */ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01 -}; - -CY_ALIGN(4) const uint8_t eccP224Order[CY_CRYPTO_ECC_P224_BYTE_SIZE] = -{ - 0x3D, 0x2A, 0x5C, 0x5C, 0x45, 0x29, 0xDD, 0x13, - 0x3E, 0xF0, 0xB8, 0xE0, 0xA2, 0x16, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF -}; -/* barrett_o: "10000000000000000000000000000e95d1f470fc1ec22d6baa3a3d5c3" */ -CY_ALIGN(4) const uint8_t eccP224OrderBarrett[CY_CRYPTO_ECC_P224_BYTE_SIZE + 1u] = -{ /* pre-calculated */ - 0xc3, 0xd5, 0xa3, 0xa3, 0xba, 0xd6, 0x22, 0xec, - 0xc1, 0x0f, 0x47, 0x1f, 0x5d, 0xe9, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01 -}; - -/* Gx - base point x: "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21" */ -CY_ALIGN(4) const uint8_t eccP224BasePointX[CY_CRYPTO_ECC_P224_BYTE_SIZE] = -{ - 0x21, 0x1d, 0x5c, 0x11, 0xd6, 0x80, 0x32, 0x34, - 0x22, 0x11, 0xc2, 0x56, 0xd3, 0xc1, 0x03, 0x4a, - 0xb9, 0x90, 0x13, 0x32, 0x7f, 0xbf, 0xb4, 0x6b, - 0xbd, 0x0c, 0x0e, 0xb7 -}; - -/* Gy - base point y: "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34" */ -CY_ALIGN(4) const uint8_t eccP224BasePointY[CY_CRYPTO_ECC_P224_BYTE_SIZE] = -{ - 0x34, 0x7e, 0x00, 0x85, 0x99, 0x81, 0xd5, 0x44, - 0x64, 0x47, 0x07, 0x5a, 0xa0, 0x75, 0x43, 0xcd, - 0xe6, 0xdf, 0x22, 0x4c, 0xfb, 0x23, 0xf7, 0xb5, - 0x88, 0x63, 0x37, 0xbd -}; - - -/* P256 CURVE PARAMETERS */ -/* prime: "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF" */ -CY_ALIGN(4) const uint8_t eccP256Polynomial[CY_CRYPTO_ECC_P256_BYTE_SIZE] = -{ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; - -/* barrett_p: "100000000fffffffffffffffefffffffefffffffeffffffff0000000000000003" */ -CY_ALIGN(4) const uint8_t eccP256PolyBarrett[CY_CRYPTO_ECC_P256_BYTE_SIZE + 1u] = -{ /* pre-calculated! */ - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, - 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x01 -}; - -/* order: "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551" */ -CY_ALIGN(4) const uint8_t eccP256Order[CY_CRYPTO_ECC_P256_BYTE_SIZE] = -{ - 0x51, 0x25, 0x63, 0xfc, 0xc2, 0xca, 0xb9, 0xf3, - 0x84, 0x9e, 0x17, 0xa7, 0xad, 0xfa, 0xe6, 0xbc, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; - -/* barrett_o: 100000000fffffffffffffffeffffffff43190552df1a6c21012ffd85eedf9bfe" */ -CY_ALIGN(4) const uint8_t eccP256OrderBarrett[CY_CRYPTO_ECC_P256_BYTE_SIZE + 1u] = -{ /* pre-calculated */ - 0xfe, 0x9b, 0xdf, 0xee, 0x85, 0xfd, 0x2f, 0x01, - 0x21, 0x6c, 0x1a, 0xdf, 0x52, 0x05, 0x19, 0x43, - 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x01 -}; - -/* base point x: "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296" */ -CY_ALIGN(4) const uint8_t eccP256BasePointX[CY_CRYPTO_ECC_P256_BYTE_SIZE] = -{ - 0x96, 0xc2, 0x98, 0xd8, 0x45, 0x39, 0xa1, 0xf4, - 0xa0, 0x33, 0xeb, 0x2d, 0x81, 0x7d, 0x03, 0x77, - 0xf2, 0x40, 0xa4, 0x63, 0xe5, 0xe6, 0xbc, 0xf8, - 0x47, 0x42, 0x2c, 0xe1, 0xf2, 0xd1, 0x17, 0x6b -}; - -/* base point y: "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5" */ -CY_ALIGN(4) const uint8_t eccP256BasePointY[CY_CRYPTO_ECC_P256_BYTE_SIZE] = -{ - 0xf5, 0x51, 0xbf, 0x37, 0x68, 0x40, 0xb6, 0xcb, - 0xce, 0x5e, 0x31, 0x6b, 0x57, 0x33, 0xce, 0x2b, - 0x16, 0x9e, 0x0f, 0x7c, 0x4a, 0xeb, 0xe7, 0x8e, - 0x9b, 0x7f, 0x1a, 0xfe, 0xe2, 0x42, 0xe3, 0x4f, -}; - -/* prime: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF" */ -CY_ALIGN(4) const uint8_t eccP384Polynomial[CY_CRYPTO_ECC_P384_BYTE_SIZE] = -{ - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff -}; - -/* barrett_p: "1000000000000000000000000000000000000000000000000000000000000000100000000ffffffffffffffff00000001" */ -CY_ALIGN(4) const uint8_t eccP384PolyBarrett[CY_CRYPTO_ECC_P384_BYTE_SIZE + 1u] = -{ /* pre-calculated */ - 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01 -}; - -/* order: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973" */ -CY_ALIGN(4) const uint8_t eccP384Order[CY_CRYPTO_ECC_P384_BYTE_SIZE] = -{ - 0x73, 0x29, 0xC5, 0xCC, 0x6A, 0x19, 0xEC, 0xEC, - 0x7A, 0xA7, 0xB0, 0x48, 0xB2, 0x0D, 0x1A, 0x58, - 0xDF, 0x2D, 0x37, 0xF4, 0x81, 0x4D, 0x63, 0xC7, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; - -/* barrett_o: "1000000000000000000000000000000000000000000000000389cb27e0bc8d220a7e5f24db74f58851313e695333ad68d" */ -CY_ALIGN(4) const uint8_t eccP384OrderBarrett[CY_CRYPTO_ECC_P384_BYTE_SIZE + 1u] = -{ /* pre-calculated */ - 0x8d, 0xd6, 0x3a, 0x33, 0x95, 0xe6, 0x13, 0x13, - 0x85, 0x58, 0x4f, 0xb7, 0x4d, 0xf2, 0xe5, 0xa7, - 0x20, 0xd2, 0xc8, 0x0b, 0x7e, 0xb2, 0x9c, 0x38, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01 -}; - -/* base point x: "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7" */ -CY_ALIGN(4) const uint8_t eccP384BasePointX[CY_CRYPTO_ECC_P384_BYTE_SIZE] = -{ - 0xb7, 0x0a, 0x76, 0x72, 0x38, 0x5e, 0x54, 0x3a, - 0x6c, 0x29, 0x55, 0xbf, 0x5d, 0xf2, 0x02, 0x55, - 0x38, 0x2a, 0x54, 0x82, 0xe0, 0x41, 0xf7, 0x59, - 0x98, 0x9b, 0xa7, 0x8b, 0x62, 0x3b, 0x1d, 0x6e, - 0x74, 0xad, 0x20, 0xf3, 0x1e, 0xc7, 0xb1, 0x8e, - 0x37, 0x05, 0x8b, 0xbe, 0x22, 0xca, 0x87, 0xaa -}; - -/* base point y: "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F" */ -CY_ALIGN(4) const uint8_t eccP384BasePointY[CY_CRYPTO_ECC_P384_BYTE_SIZE] = -{ - 0x5f, 0x0e, 0xea, 0x90, 0x7c, 0x1d, 0x43, 0x7a, - 0x9d, 0x81, 0x7e, 0x1d, 0xce, 0xb1, 0x60, 0x0a, - 0xc0, 0xb8, 0xf0, 0xb5, 0x13, 0x31, 0xda, 0xe9, - 0x7c, 0x14, 0x9a, 0x28, 0xbd, 0x1d, 0xf4, 0xf8, - 0x29, 0xdc, 0x92, 0x92, 0xbf, 0x98, 0x9e, 0x5d, - 0x6f, 0x2c, 0x26, 0x96, 0x4a, 0xde, 0x17, 0x36 -}; - -CY_ALIGN(4) const uint8_t eccP521Polynomial[CY_CRYPTO_ECC_P521_BYTE_SIZE] = -{ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x01 -}; - -CY_ALIGN(4) const uint8_t eccP521PolyBarrett[CY_CRYPTO_ECC_P521_BYTE_SIZE] = -{ /* pre-calculated */ - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x02 -}; - -CY_ALIGN(4) const uint8_t eccP521Order[CY_CRYPTO_ECC_P521_BYTE_SIZE] = -{ - 0x09, 0x64, 0x38, 0x91, 0x1E, 0xB7, 0x6F, 0xBB, - 0xAE, 0x47, 0x9C, 0x89, 0xB8, 0xC9, 0xB5, 0x3B, - 0xD0, 0xA5, 0x09, 0xF7, 0x48, 0x01, 0xCC, 0x7F, - 0x6B, 0x96, 0x2F, 0xBF, 0x83, 0x87, 0x86, 0x51, - 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x01 -}; - -/* barrett_o: "2000000000000000000000000000000000000000000000000000000000000000005ae79787c40d069948033feb708f65a2fc44a36477663b851449048e16ec79bf7" */ -CY_ALIGN(4) const uint8_t eccP521OrderBarrett[CY_CRYPTO_ECC_P521_BYTE_SIZE] = -{ /* pre-calculated */ - 0xf7, 0x9b, 0xc7, 0x6e, 0xe1, 0x48, 0x90, 0x44, - 0x51, 0xb8, 0x63, 0x76, 0x47, 0x36, 0x4a, 0xc4, - 0x2f, 0x5a, 0xf6, 0x08, 0xb7, 0xfe, 0x33, 0x80, - 0x94, 0x69, 0xd0, 0x40, 0x7c, 0x78, 0x79, 0xae, - 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x02 -}; - -/* base point x: "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66" */ -CY_ALIGN(4) const uint8_t eccP521BasePointX[CY_CRYPTO_ECC_P521_BYTE_SIZE] = -{ - 0x66, 0xbd, 0xe5, 0xc2, 0x31, 0x7e, 0x7e, 0xf9, - 0x9b, 0x42, 0x6a, 0x85, 0xc1, 0xb3, 0x48, 0x33, - 0xde, 0xa8, 0xff, 0xa2, 0x27, 0xc1, 0x1d, 0xfe, - 0x28, 0x59, 0xe7, 0xef, 0x77, 0x5e, 0x4b, 0xa1, - 0xba, 0x3d, 0x4d, 0x6b, 0x60, 0xaf, 0x28, 0xf8, - 0x21, 0xb5, 0x3f, 0x05, 0x39, 0x81, 0x64, 0x9c, - 0x42, 0xb4, 0x95, 0x23, 0x66, 0xcb, 0x3e, 0x9e, - 0xcd, 0xe9, 0x04, 0x04, 0xb7, 0x06, 0x8e, 0x85, - 0xc6, 0x00 -}; - -/* base point y: "011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650" */ -CY_ALIGN(4) const uint8_t eccP521BasePointY[CY_CRYPTO_ECC_P521_BYTE_SIZE] = -{ - 0x50, 0x66, 0xd1, 0x9f, 0x76, 0x94, 0xbe, 0x88, - 0x40, 0xc2, 0x72, 0xa2, 0x86, 0x70, 0x3c, 0x35, - 0x61, 0x07, 0xad, 0x3f, 0x01, 0xb9, 0x50, 0xc5, - 0x40, 0x26, 0xf4, 0x5e, 0x99, 0x72, 0xee, 0x97, - 0x2c, 0x66, 0x3e, 0x27, 0x17, 0xbd, 0xaf, 0x17, - 0x68, 0x44, 0x9b, 0x57, 0x49, 0x44, 0xf5, 0x98, - 0xd9, 0x1b, 0x7d, 0x2c, 0xb4, 0x5f, 0x8a, 0x5c, - 0x04, 0xc0, 0x3b, 0x9a, 0x78, 0x6a, 0x29, 0x39, - 0x18, 0x01 -}; - -const cy_stc_crypto_ecc_dp_type eccDomainParams[] = -{ - { - CY_CRYPTO_ECC_ECP_NONE, - 0, - NULL, - CY_CRYPTO_NIST_P_CURVE_SPECIFIC_RED_ALG, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL - }, - { - CY_CRYPTO_ECC_ECP_SECP192R1, - CY_CRYPTO_ECC_P192_SIZE, - "NIST P-192", - CY_CRYPTO_NIST_P_CURVE_SPECIFIC_RED_ALG, - /* prime: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF" */ - eccP192Polynomial, - /* barrett_p: "1000000000000000000000000000000010000000000000001" */ - eccP192PolyBarrett, - /* order: "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831" */ - eccP192Order, - /* barrett_o: "1000000000000000000000000662107c9eb94364e4b2dd7cf" */ - eccP192OrderBarrett, - /* base point x: "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012" */ - eccP192BasePointX, - /* base point y: "07192B95FFC8DA78631011ED6B24CDD573F977A11E794811" */ - eccP192BasePointY - }, - { - CY_CRYPTO_ECC_ECP_SECP224R1, - CY_CRYPTO_ECC_P224_SIZE, - "NIST P-224", - CY_CRYPTO_NIST_P_CURVE_SPECIFIC_RED_ALG, - /* prime: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001" */ - eccP224Polynomial, - /* barrett_p: "100000000000000000000000000000000ffffffffffffffffffffffff" */ - eccP224PolyBarrett, - /* order: "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D" */ - eccP224Order, - /* barrett_o: "10000000000000000000000000000e95d1f470fc1ec22d6baa3a3d5c3" */ - eccP224OrderBarrett, - /* Gx - base point x: "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21" */ - eccP224BasePointX, - /* Gy - base point y: "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34" */ - eccP224BasePointY - }, - { - CY_CRYPTO_ECC_ECP_SECP256R1, - CY_CRYPTO_ECC_P256_SIZE, - "NIST P-256", - CY_CRYPTO_NIST_P_BARRETT_RED_ALG, - /* prime: "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF" */ - eccP256Polynomial, - /* barrett_p: "100000000fffffffffffffffefffffffefffffffeffffffff0000000000000003" */ - eccP256PolyBarrett, - /* order: "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551" */ - eccP256Order, - /* barrett_o: "100000000fffffffffffffffeffffffff43190552df1a6c21012ffd85eedf9bfe" */ - eccP256OrderBarrett, - /* Gx - base point x: "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296" */ - eccP256BasePointX, - /* Gy - base point y: "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5" */ - eccP256BasePointY - }, - { - CY_CRYPTO_ECC_ECP_SECP384R1, - CY_CRYPTO_ECC_P384_SIZE, - "NIST P-384", - CY_CRYPTO_NIST_P_BARRETT_RED_ALG, - /* prime: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF" */ - eccP384Polynomial, - /* barrett_p: "1000000000000000000000000000000000000000000000000000000000000000100000000ffffffffffffffff00000001" */ - eccP384PolyBarrett, - /* order: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973" */ - eccP384Order, - /* barrett_o: "1000000000000000000000000000000000000000000000000389cb27e0bc8d220a7e5f24db74f58851313e695333ad68d" */ - eccP384OrderBarrett, - /* base point x: "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7" */ - eccP384BasePointX, - /* base point y: "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F" */ - eccP384BasePointY - }, - { - CY_CRYPTO_ECC_ECP_SECP521R1, - CY_CRYPTO_ECC_P521_SIZE, - "NIST P-521", - /* Currently driver uses CY_CRYPTO_NIST_P_BARRETT_RED_ALG algorithm instead of - curve specific CY_CRYPTO_NIST_P_CURVE_SPECIFIC_RED_ALG */ - CY_CRYPTO_NIST_P_BARRETT_RED_ALG, - /* prime: "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" */ - eccP521Polynomial, - /* barrett_p: "20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" */ - eccP521PolyBarrett, - /* order: "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409" */ - eccP521Order, - /* barrett_o: "2000000000000000000000000000000000000000000000000000000000000000005ae79787c40d069948033feb708f65a2fc44a36477663b851449048e16ec79bf7" */ - eccP521OrderBarrett, - /* base point x: "0C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66" */ - eccP521BasePointX, - /* base point y: "11839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650" */ - eccP521BasePointY - } -}; - /* [] END OF FILE */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_ecdsa.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_ecdsa.c index aa7144819a..9ab6d7f46b 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_ecdsa.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_ecdsa.c @@ -31,16 +31,6 @@ #include -#define ECC_ECDSA_DEBUG 0 - -#if ECC_ECDSA_DEBUG -#include "cy_crypto_core_my_support.h" -#ifndef Tb_PrintStr -#include -#define Tb_PrintStr(s) printf("%s\n", s) -#endif -#endif - /******************************************************************************* * Function Name: Cy_Crypto_Core_ECC_SignHash @@ -70,22 +60,22 @@ * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_ECC_SignHash(CRYPTO_Type *base, const uint8_t *hash, uint32_t hashlen, uint8_t *sig, - cy_stc_crypto_ecc_key *key, uint8_t *messageKey) + const cy_stc_crypto_ecc_key *key, const uint8_t *messageKey) { - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; cy_stc_crypto_ecc_key ephKey; uint8_t myKGX[CY_CRYPTO_ECC_MAX_BYTE_SIZE]; uint8_t myKGY[CY_CRYPTO_ECC_MAX_BYTE_SIZE]; const cy_stc_crypto_ecc_dp_type *eccDp; - uint32_t mallocMask = 0; + uint32_t mallocMask = 0U; uint32_t bitsize; /* NULL parameters checking */ if ((hash != NULL) && (sig != NULL) && (key != NULL) && (messageKey != NULL)) { - myResult = CY_CRYPTO_NOT_SUPPORTED; + tmpResult = CY_CRYPTO_NOT_SUPPORTED; eccDp = Cy_Crypto_Core_ECC_GetCurveParams(key->curveID); @@ -93,44 +83,27 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_SignHash(CRYPTO_Type *base, const uint8 { bitsize = eccDp->size; - #if ECC_ECDSA_DEBUG - Tb_PrintStr("\necc_sign_hash() for "); - Tb_PrintStr(eccDp->name); - Tb_PrintStr("\n"); - #endif /* ECC_ECDSA_DEBUG */ - /* make ephemeral key pair */ ephKey.pubkey.x = myKGX; ephKey.pubkey.y = myKGY; - myResult = Cy_Crypto_Core_ECC_MakePublicKey(base, key->curveID, messageKey, &ephKey); + tmpResult = Cy_Crypto_Core_ECC_MakePublicKey(base, key->curveID, messageKey, &ephKey); - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { - myResult = CY_CRYPTO_BAD_PARAMS; + tmpResult = CY_CRYPTO_BAD_PARAMS; - int dividend = 0; /* for whatever reason Crypto_EC_DivMod only works if dividend is in register 0 */ - int p_temp = 8; - int p_r = 9; - int p_s = 10; - int p_d = 11; - - #if ECC_ECDSA_DEBUG - Tb_PrintStr("%10s: \t", "hash"); - Crypto_PrintNumber((uint8_t *)hash, hashlen); - - Tb_PrintStr("%10s: \t", "k"); - Crypto_PrintNumber(messageKey, CY_CRYPTO_BYTE_SIZE_OF_BITS(bitsize)); - - Tb_PrintStr("%10s: \t", "x1"); - Crypto_PrintNumber((uint8_t *)ephKey.pubkey.x, CY_CRYPTO_BYTE_SIZE_OF_BITS(bitsize)); - #endif /* ECC_ECDSA_DEBUG */ + uint32_t dividend = 0U; /* for whatever reason Crypto_EC_DivMod only works if dividend is in register 0 */ + uint32_t p_temp = 8U; + uint32_t p_r = 9U; + uint32_t p_s = 10U; + uint32_t p_d = 11U; /* load values needed for reduction modulo order of the base point */ CY_CRYPTO_VU_ALLOC_MEM (base, VR_P, bitsize); Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, (uint8_t *)eccDp->order, bitsize); - CY_CRYPTO_VU_ALLOC_MEM (base, VR_BARRETT, bitsize + 1); + CY_CRYPTO_VU_ALLOC_MEM (base, VR_BARRETT, bitsize + 1U); Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, (uint8_t *)eccDp->barrett_o, bitsize); CY_CRYPTO_VU_ALLOC_MEM (base, p_r, bitsize); @@ -140,7 +113,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_SignHash(CRYPTO_Type *base, const uint8 if (!Cy_Crypto_Core_Vu_IsRegZero(base, p_r)) { - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; CY_CRYPTO_VU_ALLOC_MEM (base, p_d, bitsize); CY_CRYPTO_VU_ALLOC_MEM (base, p_s, bitsize); @@ -162,15 +135,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_SignHash(CRYPTO_Type *base, const uint8 /* r = x1 mod n */ Cy_Crypto_Core_Vu_GetMemValue (base, sig, p_r, bitsize); - #if ECC_ECDSA_DEBUG - Tb_PrintStr("x1 after reduction modulo order: "); - Crypto_RegMemNumberPrint(p_r); - #endif /* ECC_ECDSA_DEBUG */ - if (Cy_Crypto_Core_Vu_IsRegZero(base, p_r)) { /* R is zero!!! */ - myResult = CY_CRYPTO_HW_ERROR; + tmpResult = CY_CRYPTO_HW_ERROR; } } else @@ -180,14 +148,14 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_SignHash(CRYPTO_Type *base, const uint8 Cy_Crypto_Core_MemCpy(base, sig, ephKey.pubkey.x, (uint16_t)CY_CRYPTO_BYTE_SIZE_OF_BITS(bitsize)); } - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { /* find s = (e + d*r)/k */ /* load signing private key */ Cy_Crypto_Core_Vu_SetMemValue (base, p_d, (uint8_t *)key->k, bitsize); - /* use barrett reduction algorithm for operations modulo n (order of the base point) */ + /* use Barrett reduction algorithm for operations modulo n (order of the base point) */ Cy_Crypto_Core_EC_NistP_SetRedAlg(CY_CRYPTO_NIST_P_BARRETT_RED_ALG); /* d*r mod n */ @@ -202,7 +170,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_SignHash(CRYPTO_Type *base, const uint8 } else { - Cy_Crypto_Core_Vu_SetMemValue (base, p_d, (uint8_t *)hash, hashlen * 8); + Cy_Crypto_Core_Vu_SetMemValue (base, p_d, (uint8_t *)hash, hashlen * 8U); } Cy_Crypto_Core_Vu_SetMemValue (base, p_r, messageKey, bitsize); @@ -226,14 +194,8 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_SignHash(CRYPTO_Type *base, const uint8 } else { - myResult = CY_CRYPTO_HW_ERROR; + tmpResult = CY_CRYPTO_HW_ERROR; } - - #if ECC_ECDSA_DEBUG - Crypto_PrintRegister(p_r, "k"); - Crypto_PrintRegister(p_s, "(e+d*r)/k"); - #endif /* ECC_ECDSA_DEBUG */ - } } @@ -243,7 +205,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_SignHash(CRYPTO_Type *base, const uint8 } } - return (myResult); + return (tmpResult); } @@ -276,47 +238,40 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_SignHash(CRYPTO_Type *base, const uint8 *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_ECC_VerifyHash(CRYPTO_Type *base, const uint8_t *sig, const uint8_t *hash, uint32_t hashlen, - uint8_t *stat, cy_stc_crypto_ecc_key *key) + uint8_t *stat, const cy_stc_crypto_ecc_key *key) { - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; const cy_stc_crypto_ecc_dp_type *eccDp; uint32_t bitsize; - uint32_t mallocMask = 0; + uint32_t mallocMask = 0U; /* NULL parameters checking */ if ((sig != NULL) && (hash != NULL) && (stat != NULL) && (key != NULL)) { - myResult = CY_CRYPTO_NOT_SUPPORTED; + tmpResult = CY_CRYPTO_NOT_SUPPORTED; eccDp = Cy_Crypto_Core_ECC_GetCurveParams(key->curveID); if (eccDp != NULL) { - - #if ECC_ECDSA_DEBUG - Tb_PrintStr("\necc_verify_hash() for "); - Tb_PrintStr((char *)eccDp->name); - Tb_PrintStr("\n"); - #endif /* ECC_ECDSA_DEBUG */ - bitsize = eccDp->size; - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; - int dividend = 0; /* for whatever reason Crypto_EC_DivMod only works if dividend is in register 0 */ - int p_r = 4; - int p_s = 5; - int p_u1 = 6; - int p_u2 = 7; - int p_o = 8; - int p_gx = 9; - int p_gy = 10; - int p_qx = 11; - int p_qy = 12; + uint32_t dividend = 0u; /* for whatever reason Crypto_EC_DivMod only works if dividend is in register 0 */ + uint32_t p_r = 4U; + uint32_t p_s = 5U; + uint32_t p_u1 = 6U; + uint32_t p_u2 = 7U; + uint32_t p_o = 8U; + uint32_t p_gx = 9U; + uint32_t p_gy = 10U; + uint32_t p_qx = 11U; + uint32_t p_qy = 12U; - /* use barrett reduction algorithm for operations modulo n (order of the base point) */ + /* use Barrett reduction algorithm for operations modulo n (order of the base point) */ Cy_Crypto_Core_EC_NistP_SetRedAlg(CY_CRYPTO_NIST_P_BARRETT_RED_ALG); Cy_Crypto_Core_EC_NistP_SetMode(bitsize); @@ -325,13 +280,13 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_VerifyHash(CRYPTO_Type *base, CY_CRYPTO_VU_ALLOC_MEM (base, VR_P, bitsize); Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, (uint8_t *)eccDp->order, bitsize); - CY_CRYPTO_VU_ALLOC_MEM (base, VR_BARRETT, bitsize + 1); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, (uint8_t *)eccDp->barrett_o, bitsize + 1); + CY_CRYPTO_VU_ALLOC_MEM (base, VR_BARRETT, bitsize + 1U); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, (uint8_t *)eccDp->barrett_o, bitsize + 1U); /*******************************************************************************/ /* check that R and S are within the valid range, i.e. 0 < R < n and 0 < S < n */ - CY_CRYPTO_VU_ALLOC_MEM (base, p_r, bitsize); - CY_CRYPTO_VU_ALLOC_MEM (base, p_s, bitsize); + CY_CRYPTO_VU_ALLOC_MEM (base, p_r, bitsize); + CY_CRYPTO_VU_ALLOC_MEM (base, p_s, bitsize); Cy_Crypto_Core_Vu_SetMemValue (base, p_r, (uint8_t *)sig, bitsize); Cy_Crypto_Core_Vu_SetMemValue (base, p_s, (uint8_t *)&sig[CY_CRYPTO_BYTE_SIZE_OF_BITS(bitsize)], bitsize); @@ -342,28 +297,28 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_VerifyHash(CRYPTO_Type *base, if (Cy_Crypto_Core_Vu_IsRegZero(base, p_r)) { /* R is zero!!! */ - myResult = CY_CRYPTO_BAD_PARAMS; + tmpResult = CY_CRYPTO_BAD_PARAMS; } if (!Cy_Crypto_Core_Vu_IsRegLess(base, p_r, VR_P)) { /* R is not less than n!!! */ - myResult = CY_CRYPTO_BAD_PARAMS; + tmpResult = CY_CRYPTO_BAD_PARAMS; } if (Cy_Crypto_Core_Vu_IsRegZero(base, p_s)) { /* S is zero!!! */ - myResult = CY_CRYPTO_BAD_PARAMS; + tmpResult = CY_CRYPTO_BAD_PARAMS; } if (!Cy_Crypto_Core_Vu_IsRegLess(base, p_s, VR_P)) { /* S is not less than n!!! */ - myResult = CY_CRYPTO_BAD_PARAMS; + tmpResult = CY_CRYPTO_BAD_PARAMS; } - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { CY_CRYPTO_VU_ALLOC_MEM (base, dividend, bitsize); - CY_CRYPTO_VU_ALLOC_MEM (base, p_o, bitsize); + CY_CRYPTO_VU_ALLOC_MEM (base, p_o, bitsize); CY_CRYPTO_VU_ALLOC_MEM (base, p_u1, bitsize); CY_CRYPTO_VU_ALLOC_MEM (base, p_u2, bitsize); @@ -386,41 +341,25 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_VerifyHash(CRYPTO_Type *base, } else { - Cy_Crypto_Core_Vu_SetMemValue (base, p_u1, (uint8_t *)hash, hashlen * 8); + Cy_Crypto_Core_Vu_SetMemValue (base, p_u1, (uint8_t *)hash, hashlen * 8U); } - #if ECC_ECDSA_DEBUG - Crypto_PrintRegister(p_u1, "hash"); - Crypto_PrintRegister(p_r, "R"); - Crypto_PrintRegister(p_s, "S"); - Tb_PrintStr("\n"); - #endif /* ECC_ECDSA_DEBUG */ - /* w = s^-1 mod n */ CY_CRYPTO_VU_SET_TO_ONE(base, dividend); Cy_Crypto_Core_EC_DivMod(base, p_s, dividend, p_s, bitsize); - #if ECC_ECDSA_DEBUG - Crypto_PrintRegister(p_s, "w"); - #endif /* ECC_ECDSA_DEBUG */ - /* u1 = e*w mod n */ Cy_Crypto_Core_EC_MulMod(base, p_u1, p_u1, p_s, bitsize); /* u2 = r*w mod n */ - Cy_Crypto_Core_EC_MulMod(base, p_u2, p_r, p_s, bitsize); - - #if ECC_ECDSA_DEBUG - Crypto_PrintRegister(p_u1, "u1"); - Crypto_PrintRegister(p_u2, "u2"); - #endif /* ECC_ECDSA_DEBUG */ + Cy_Crypto_Core_EC_MulMod(base, p_u2, p_r, p_s, bitsize); /* Initialize point multiplication */ Cy_Crypto_Core_EC_NistP_SetRedAlg(eccDp->algo); - /* load prime, order and barrett coefficient */ - Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, (uint8_t *)eccDp->prime, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, p_o, (uint8_t *)eccDp->order, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, (uint8_t *)eccDp->barrett_p, bitsize + 1); + /* load prime, order and Barrett coefficient */ + Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, (uint8_t *)eccDp->prime, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, p_o, (uint8_t *)eccDp->order, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, (uint8_t *)eccDp->barrett_p, bitsize + 1U); /* load base Point G */ Cy_Crypto_Core_Vu_SetMemValue (base, p_gx, (uint8_t *)eccDp->Gx, bitsize); @@ -439,40 +378,22 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_VerifyHash(CRYPTO_Type *base, /* u2 * Qa */ Cy_Crypto_Core_EC_NistP_PointMul(base, p_qx, p_qy, p_u2, p_o, bitsize); - #if ECC_ECDSA_DEBUG - Tb_PrintStr("u1 * G: \n"); - Crypto_PrintRegister(p_gx, " u1*G(x)"); - Crypto_PrintRegister(p_gy, " u1*G(y)"); - Tb_PrintStr("u2 * Q: \n"); - Crypto_PrintRegister(p_qx, " u2*Q(x)"); - Crypto_PrintRegister(p_qy, " u2*Q(x)"); - #endif /* ECC_ECDSA_DEBUG */ - /* P = u1 * G + u2 * Qa. Only Px is needed */ Cy_Crypto_Core_EC_SubMod(base, dividend, p_qy, p_gy); /* (y2-y1) */ Cy_Crypto_Core_EC_SubMod(base, p_s, p_qx, p_gx); /* (x2-x1) */ Cy_Crypto_Core_EC_DivMod(base, p_s, dividend, p_s, bitsize); /* s = (y2-y1)/(x2-x1) */ - #if ECC_ECDSA_DEBUG - Tb_PrintStr("Point addition: \n"); - Crypto_PrintRegister(p_s, "s"); - #endif /* ECC_ECDSA_DEBUG */ - Cy_Crypto_Core_EC_SquareMod (base, p_s, p_s, bitsize); /* s^2 */ Cy_Crypto_Core_EC_SubMod (base, p_s, p_s, p_gx); /* s^2 - x1 */ Cy_Crypto_Core_EC_SubMod (base, p_s, p_s, p_qx); /* s^2 - x1 - x2 which is Px mod n */ - #if ECC_ECDSA_DEBUG - Crypto_PrintRegister(p_s, "px"); - #endif /* ECC_ECDSA_DEBUG */ - if (Cy_Crypto_Core_Vu_IsRegEqual(base, p_s, p_r)) { - *stat = 1; + *stat = 1u; } else { - *stat = 0; + *stat = 0u; } } @@ -481,7 +402,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_VerifyHash(CRYPTO_Type *base, } } - return (myResult); + return (tmpResult); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_key_gen.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_key_gen.c index 2bc05400f4..43a8018b58 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_key_gen.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_key_gen.c @@ -29,11 +29,8 @@ #include "cy_crypto_core_vu.h" #include "cy_crypto_core_trng.h" -#define CY_ECC_CONFIG_TR_GARO_CTL 0x6C740B8Du -#define CY_ECC_CONFIG_TR_FIRO_CTL 0x52D246E1u - -/* print some debug information. enabling this will render meaningless all time measurements */ -#define ECC_KEY_GEN_DEBUG 0 +#define CY_ECC_CONFIG_TR_GARO_CTL 0x6C740B8DuL +#define CY_ECC_CONFIG_TR_FIRO_CTL 0x52D246E1uL /******************************************************************************* @@ -65,152 +62,135 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_MakeKeyPair(CRYPTO_Type *base, cy_func_get_random_data_t GetRandomDataFunc, void *randomDataInfo) { + cy_en_crypto_status_t tmpResult = CY_CRYPTO_NOT_SUPPORTED; + cy_stc_crypto_ecc_dp_type *eccDp = Cy_Crypto_Core_ECC_GetCurveParams(curveID); - if (eccDp == NULL || key == NULL) + if ((eccDp != NULL) && (key != NULL)) { - /* NULL parameter detected in Cy_Crypto_Core_ECC_MakeKeyPair()!!! */ - return CY_CRYPTO_NOT_SUPPORTED; - } + tmpResult = CY_CRYPTO_SUCCESS; -#if ECC_KEY_GEN_DEBUG - Tb_PrintStr("\necc_make_key() for "); - Tb_PrintStr((int8_t *)eccDp->name); - Tb_PrintStr("\n"); -#endif /* ECC_KEY_GEN_DEBUG */ + uint32_t bitsize = eccDp->size; - int bitsize = eccDp->size; + /* used VU registers. Same values as in crypto_NIST_P.c */ + uint32_t p_temp = 8u; /* temporal values */ + uint32_t p_order = 9u; /* order of the curve */ + uint32_t p_d = 10u; /* private key */ + uint32_t p_x = 11u; /* x coordinate */ + uint32_t p_y = 12u; /* y coordinate */ - /* used VU registers. Same values as in crypto_NIST_P.c */ - int p_temp = 8; /* temporal values */ - int p_order = 9; /* order of the curve */ - int p_d = 10; /* private key */ - int p_x = 11; /* x coordinate */ - int p_y = 12; /* y coordinate */ + CY_CRYPTO_VU_ALLOC_MEM(base, VR_P, bitsize); + CY_CRYPTO_VU_ALLOC_MEM(base, p_order, bitsize); + CY_CRYPTO_VU_ALLOC_MEM(base, VR_BARRETT, bitsize + 1U); + CY_CRYPTO_VU_ALLOC_MEM(base, p_x, bitsize); + CY_CRYPTO_VU_ALLOC_MEM(base, p_y, bitsize); - CY_CRYPTO_VU_ALLOC_MEM(base, VR_P, bitsize); - CY_CRYPTO_VU_ALLOC_MEM(base, p_order, bitsize); - CY_CRYPTO_VU_ALLOC_MEM(base, VR_BARRETT, bitsize + 1); - CY_CRYPTO_VU_ALLOC_MEM(base, p_x, bitsize); - CY_CRYPTO_VU_ALLOC_MEM(base, p_y, bitsize); + /*************************************************************** + * Apply domain parameters + ***************************************************************/ + /* load prime and order defining the curve as well as the Barrett coefficient. */ + /* P and BARRETT_U are "globally" defined in cy_crypto_core_ecc.h */ + Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, eccDp->prime, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, p_order, eccDp->order, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, eccDp->barrett_p, bitsize + 1U); - /*************************************************************** - * Apply domain parameters - ***************************************************************/ - /* load prime and order defining the curve as well as the barrett coefficient. */ + /* Base Point, G = (p_x, p_y) */ + Cy_Crypto_Core_Vu_SetMemValue (base, p_x, eccDp->Gx, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, p_y, eccDp->Gy, bitsize); - /* P and BARRETT_U are "globally" defined in cy_crypto_core_ecc.h */ - Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, eccDp->prime, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, p_order, eccDp->order, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, eccDp->barrett_p, bitsize + 1); + Cy_Crypto_Core_EC_NistP_SetMode(bitsize); + Cy_Crypto_Core_EC_NistP_SetRedAlg(eccDp->algo); - /* Base Point, G = (p_x, p_y) */ - Cy_Crypto_Core_Vu_SetMemValue (base, p_x, eccDp->Gx, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, p_y, eccDp->Gy, bitsize); - - Cy_Crypto_Core_EC_NistP_SetMode(bitsize); - Cy_Crypto_Core_EC_NistP_SetRedAlg(eccDp->algo); - - - /*************************************************************** - * generate random string - ***************************************************************/ - if (GetRandomDataFunc != NULL) - { - GetRandomDataFunc( randomDataInfo, key->k, (bitsize + 7u) >> 3u ); - } - else - { - for (int i = 0, randomsize = bitsize; randomsize > 0; randomsize-=32, i++) + /*************************************************************** + * generate random string + ***************************************************************/ + if (GetRandomDataFunc != NULL) { - int randombits = CY_CRYPTO_MIN(randomsize, 32); + (void)GetRandomDataFunc( randomDataInfo, (uint8_t*)key->k, ((bitsize + 7U) >> 3U) ); + } + else + { + uint32_t i = 0U; + int32_t randomsize = (int32_t)bitsize; + cy_en_crypto_status_t status = CY_CRYPTO_SUCCESS; - cy_en_crypto_status_t error = Cy_Crypto_Core_Trng(base, CY_ECC_CONFIG_TR_GARO_CTL, CY_ECC_CONFIG_TR_FIRO_CTL, - randombits, &((uint32_t *)key->k)[i]); - - if (CY_CRYPTO_SUCCESS != error) + while ((randomsize > 0) && (CY_CRYPTO_SUCCESS == status)) { - return CY_CRYPTO_HW_ERROR; + uint32_t randombits = (uint32_t)CY_CRYPTO_MIN(randomsize, 32); + + status = Cy_Crypto_Core_Trng(base, CY_ECC_CONFIG_TR_GARO_CTL, CY_ECC_CONFIG_TR_FIRO_CTL, + randombits, &((uint32_t *)key->k)[i]); + randomsize -= 32; + i++; + + if (CY_CRYPTO_SUCCESS != status) + { + tmpResult = CY_CRYPTO_HW_ERROR; + } } } + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + /*************************************************************** + * Load random data into VU + ***************************************************************/ + CY_CRYPTO_VU_ALLOC_MEM(base, p_d, bitsize); + Cy_Crypto_Core_Vu_SetMemValue(base, p_d, (uint8_t *)key->k, bitsize); + + /* check that the key is smaller than the order of base point */ + CY_CRYPTO_VU_CMP_SUB (base, p_d, p_order); /* C = (a >= b) */ + uint32_t status = Cy_Crypto_Core_Vu_StatusRead(base); + + if (0u != (status & CY_CRYPTO_VU_STATUS_CARRY_BIT)) + { + /* random data >= order, needs reduction */ + + CY_CRYPTO_VU_PUSH_REG(base); + + /* load values needed for reduction modulo curve order */ + CY_CRYPTO_VU_ALLOC_MEM(base, VR_P, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, eccDp->order, bitsize); + + CY_CRYPTO_VU_ALLOC_MEM(base, VR_BARRETT, bitsize + 1u); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, eccDp->barrett_o, bitsize + 1u); + + CY_CRYPTO_VU_ALLOC_MEM(base, p_temp, bitsize); + CY_CRYPTO_VU_MOV(base, p_temp, p_d); + + /* z = x % mod */ + Cy_Crypto_Core_EC_Bar_MulRed(base, p_d, p_temp, bitsize); + + CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(p_temp) | CY_CRYPTO_VU_REG_BIT(VR_P) | CY_CRYPTO_VU_REG_BIT(VR_BARRETT)); + + Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)key->k, p_d, bitsize); + + /* restore previous prime and Barrett values */ + CY_CRYPTO_VU_POP_REG(base); + } + + /* + * Make the public key + * EC scalar multiplication - X,Y-only co-Z arithmetic + */ + Cy_Crypto_Core_EC_NistP_PointMul(base, p_x, p_y, p_d, p_order, bitsize); + + Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)key->pubkey.x, p_x, bitsize); + Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)key->pubkey.y, p_y, bitsize); + + key->type = PK_PRIVATE; + key->curveID = curveID; + + tmpResult = CY_CRYPTO_SUCCESS; + } + + CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(VR_P) | CY_CRYPTO_VU_REG_BIT(VR_BARRETT) | + CY_CRYPTO_VU_REG_BIT(p_x) | CY_CRYPTO_VU_REG_BIT(p_y) | + CY_CRYPTO_VU_REG_BIT(p_order) | CY_CRYPTO_VU_REG_BIT(p_d)); } - - /*************************************************************** - * Load random data into VU - ***************************************************************/ - CY_CRYPTO_VU_ALLOC_MEM(base, p_d, bitsize); - Cy_Crypto_Core_Vu_SetMemValue(base, p_d, (uint8_t *)key->k, bitsize); - -#if ECC_KEY_GEN_DEBUG - Tb_PrintStr("random data: "); - Crypto_RegMemNumberPrint(p_d); - Tb_PrintStr("p_order: "); - Crypto_RegMemNumberPrint(p_order); -#endif /*ECC_KEY_GEN_DEBUG */ - - /* check that the key is smaller than the order of base point */ - CY_CRYPTO_VU_CMP_SUB (base, p_d, p_order); /* C = (a >= b) */ - uint16_t status = Cy_Crypto_Core_Vu_StatusRead(base); - - if (status & CY_CRYPTO_VU_STATUS_CARRY_BIT) - { - /* random data >= order, needs reduction */ - - CY_CRYPTO_VU_PUSH_REG(base); - - /* load values needed for reduction modulo curve order */ - CY_CRYPTO_VU_ALLOC_MEM(base, VR_P, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, eccDp->order, bitsize); - - CY_CRYPTO_VU_ALLOC_MEM(base, VR_BARRETT, bitsize + 1u); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, eccDp->barrett_o, bitsize + 1u); - - CY_CRYPTO_VU_ALLOC_MEM(base, p_temp, bitsize); - CY_CRYPTO_VU_MOV(base, p_temp, p_d); - - /* z = x % mod */ - Cy_Crypto_Core_EC_Bar_MulRed(base, p_d, p_temp, bitsize); - - CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(p_temp) | CY_CRYPTO_VU_REG_BIT(VR_P) | CY_CRYPTO_VU_REG_BIT(VR_BARRETT)); - - Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)key->k, p_d, bitsize); - - /* restore previous prime and barrett values */ - CY_CRYPTO_VU_POP_REG(base); - -#if ECC_KEY_GEN_DEBUG - Tb_PrintStr("random data after reduction modulo order: "); - Crypto_RegMemNumberPrint(p_d); -#endif /* ECC_KEY_GEN_DEBUG */ - - } - else - { - /* carry is clear, i. e. p_d < p_order */ - } - - /* make the public key - * EC scalar multiplication - X,Y-only co-Z arithmetic - */ -#if ECC_KEY_GEN_DEBUG - Tb_PrintStr("Doing scalar multiplication\n"); -#endif /* ECC_KEY_GEN_DEBUG */ - - Cy_Crypto_Core_EC_NistP_PointMul(base, p_x, p_y, p_d, p_order, bitsize); - - Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)key->pubkey.x, p_x, bitsize); - Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)key->pubkey.y, p_y, bitsize); - - key->type = PK_PRIVATE; - key->curveID = curveID; - - CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(VR_P) | CY_CRYPTO_VU_REG_BIT(VR_BARRETT) | - CY_CRYPTO_VU_REG_BIT(p_x) | CY_CRYPTO_VU_REG_BIT(p_y) | - CY_CRYPTO_VU_REG_BIT(p_order) | CY_CRYPTO_VU_REG_BIT(p_d)); - - return CY_CRYPTO_SUCCESS; + return (tmpResult); } @@ -242,105 +222,88 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_MakePrivateKey(CRYPTO_Type *base, uint8_t *key, cy_func_get_random_data_t GetRandomDataFunc, void *randomDataInfo) { + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; + const cy_stc_crypto_ecc_dp_type *eccDp = Cy_Crypto_Core_ECC_GetCurveParams(curveID); - if (eccDp == NULL || key == NULL) + if ((eccDp != NULL) && (key != NULL)) { - /* NULL parameter detected in Cy_Crypto_Core_ECC_MakeKey()!!! */ - return CY_CRYPTO_NOT_SUPPORTED; - } + tmpResult = CY_CRYPTO_SUCCESS; -#if ECC_KEY_GEN_DEBUG - Tb_PrintStr("\necc_make_key() for "); - Tb_PrintStr((int8_t *)eccDp->name); - Tb_PrintStr("\n"); -#endif /* ECC_KEY_GEN_DEBUG */ + uint32_t bitsize = eccDp->size; - int bitsize = eccDp->size; + uint32_t p_temp = 8u; /* temporal values */ + uint32_t p_d = 10u; /* private key */ - int p_temp = 8; /* temporal values */ - int p_d = 10; /* private key */ - - /* generate random string */ - if (GetRandomDataFunc != NULL) - { - GetRandomDataFunc( randomDataInfo, key, (bitsize + 7u) >> 3u ); - } - else - { - for (int i = 0, randomsize = bitsize; randomsize > 0; randomsize-=32, i++) + /* generate random string */ + if (GetRandomDataFunc != NULL) { - int randombits = CY_CRYPTO_MIN(randomsize, 32); + (void)GetRandomDataFunc( randomDataInfo, key, ((bitsize + 7U) >> 3U) ); + } + else + { + uint32_t i = 0U; + int32_t randomsize = (int32_t)bitsize; + cy_en_crypto_status_t status = CY_CRYPTO_SUCCESS; - cy_en_crypto_status_t error = Cy_Crypto_Core_Trng(base, CY_ECC_CONFIG_TR_GARO_CTL, CY_ECC_CONFIG_TR_FIRO_CTL, - randombits, &((uint32_t *)key)[i]); - - if (CY_CRYPTO_SUCCESS != error) + while ((randomsize > 0) && (CY_CRYPTO_SUCCESS == status)) { - return CY_CRYPTO_HW_ERROR; + uint32_t randombits = (uint32_t)CY_CRYPTO_MIN(randomsize, 32); + + status = Cy_Crypto_Core_Trng(base, CY_ECC_CONFIG_TR_GARO_CTL, CY_ECC_CONFIG_TR_FIRO_CTL, + randombits, &((uint32_t *)key)[i]); + randomsize -= 32; + i++; + + if (CY_CRYPTO_SUCCESS != status) + { + tmpResult = CY_CRYPTO_HW_ERROR; + } } } + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + /* load prime and order defining the curve as well as the barrett coefficient. */ + /* P and BARRETT_U are "globally" defined in cy_crypto_core_ecc.h */ + CY_CRYPTO_VU_ALLOC_MEM(base, VR_P, bitsize); + CY_CRYPTO_VU_ALLOC_MEM(base, VR_BARRETT, bitsize + 1u); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, eccDp->order, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, eccDp->barrett_o, bitsize + 1u); + + /* Load random data into VU */ + CY_CRYPTO_VU_ALLOC_MEM(base, p_d, bitsize); + Cy_Crypto_Core_Vu_SetMemValue(base, p_d, (uint8_t *)key, bitsize); + + CY_CRYPTO_VU_ALLOC_MEM(base, p_temp, bitsize); + CY_CRYPTO_VU_MOV(base, p_temp, p_d); + + /* check that the key is smaller than the order of base point */ + CY_CRYPTO_VU_CMP_SUB (base, p_d, VR_P); /* C = (a >= b) */ + uint32_t status = Cy_Crypto_Core_Vu_StatusRead(base); + + if (0u != (status & CY_CRYPTO_VU_STATUS_CARRY_BIT)) + { + /* private key (random data) >= order, needs reduction */ + + /* use Barrett reduction algorithm for operations modulo n (order of the base point) */ + Cy_Crypto_Core_EC_NistP_SetRedAlg(eccDp->algo); + Cy_Crypto_Core_EC_NistP_SetMode(bitsize); + + /* z = x % mod */ + Cy_Crypto_Core_EC_Bar_MulRed(base, p_d, p_temp, bitsize); + + Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)key, p_d, bitsize); + } + + CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(VR_P) | CY_CRYPTO_VU_REG_BIT(VR_BARRETT) | + CY_CRYPTO_VU_REG_BIT(p_d) | CY_CRYPTO_VU_REG_BIT(p_temp)); + + tmpResult = CY_CRYPTO_SUCCESS; + } } -#if ECC_KEY_GEN_DEBUG - Tb_PrintStr("private key: "); - Crypto_PrintNumber((uint8_t *)key, CY_CRYPTO_BYTE_SIZE_OF_BITS(bitsize)); -#endif /* ECC_KEY_GEN_DEBUG */ - - - /* load prime and order defining the curve as well as the barrett coefficient. */ - /* P and BARRETT_U are "globally" defined in cy_crypto_core_ecc.h */ - CY_CRYPTO_VU_ALLOC_MEM(base, VR_P, bitsize); - CY_CRYPTO_VU_ALLOC_MEM(base, VR_BARRETT, bitsize + 1); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, eccDp->order, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, eccDp->barrett_o, bitsize + 1); - - /* Load random data into VU */ - CY_CRYPTO_VU_ALLOC_MEM(base, p_d, bitsize); - Cy_Crypto_Core_Vu_SetMemValue(base, p_d, (uint8_t *)key, bitsize); - - CY_CRYPTO_VU_ALLOC_MEM(base, p_temp, bitsize); - CY_CRYPTO_VU_MOV(base, p_temp, p_d); - -#if ECC_KEY_GEN_DEBUG - Tb_PrintStr("random data: "); - Crypto_RegMemNumberPrint(p_d); - Tb_PrintStr("p_order: "); - Crypto_RegMemNumberPrint(VR_P); -#endif /* ECC_KEY_GEN_DEBUG */ - - /* check that the key is smaller than the order of base point */ - CY_CRYPTO_VU_CMP_SUB (base, p_d, VR_P); /* C = (a >= b) */ - uint16_t status = Cy_Crypto_Core_Vu_StatusRead(base); - - if (status & CY_CRYPTO_VU_STATUS_CARRY_BIT) - { - /* private key (random data) >= order, needs reduction */ - - /* use barrett reduction algorithm for operations modulo n (order of the base point) */ - Cy_Crypto_Core_EC_NistP_SetRedAlg(eccDp->algo); - Cy_Crypto_Core_EC_NistP_SetMode(bitsize); - - /* z = x % mod */ - Cy_Crypto_Core_EC_Bar_MulRed(base, p_d, p_temp, bitsize); - - Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)key, p_d, bitsize); - -#if ECC_KEY_GEN_DEBUG - Tb_PrintStr("private key after reduction modulo order: "); - Crypto_RegMemNumberPrint(p_d); -#endif /* ECC_KEY_GEN_DEBUG */ - - } - else - { - /* carry is clear, i. e. p_d < p_order */ - } - - CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(VR_P) | CY_CRYPTO_VU_REG_BIT(VR_BARRETT) | - CY_CRYPTO_VU_REG_BIT(p_d) | CY_CRYPTO_VU_REG_BIT(p_temp)); - - return CY_CRYPTO_SUCCESS; + return (tmpResult); } @@ -367,71 +330,66 @@ cy_en_crypto_status_t Cy_Crypto_Core_ECC_MakePrivateKey(CRYPTO_Type *base, *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_ECC_MakePublicKey(CRYPTO_Type *base, cy_en_crypto_ecc_curve_id_t curveID, - uint8_t *privateKey, + const uint8_t *privateKey, cy_stc_crypto_ecc_key *publicKey) { + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; + cy_stc_crypto_ecc_dp_type *eccDp = Cy_Crypto_Core_ECC_GetCurveParams(curveID); - if (eccDp == NULL || privateKey == NULL || publicKey == NULL) + if ((eccDp != NULL) && (privateKey != NULL) && (publicKey != NULL)) { - /* NULL parameter detected in Cy_Crypto_Core_ECC_MakeKey()!!! */ - return CY_CRYPTO_NOT_SUPPORTED; + uint32_t bitsize = eccDp->size; + + uint32_t p_order = 9u; /* order of the curve */ + uint32_t p_d = 10u; /* private key */ + uint32_t p_x = 11u; /* x coordinate */ + uint32_t p_y = 12u; /* y coordinate */ + + /* make the public key + * EC scalar multiplication - X,Y-only co-Z arithmetic + */ + CY_CRYPTO_VU_ALLOC_MEM(base, VR_P, bitsize); + CY_CRYPTO_VU_ALLOC_MEM(base, p_order, bitsize); + CY_CRYPTO_VU_ALLOC_MEM(base, VR_BARRETT, bitsize + 1u); + CY_CRYPTO_VU_ALLOC_MEM(base, p_x, bitsize); + CY_CRYPTO_VU_ALLOC_MEM(base, p_y, bitsize); + + /* Apply domain parameters */ + + /* load prime and order defining the curve as well as the barrett coefficient. */ + + /* P and BARRETT_U are "globally" defined in cy_crypto_core_ecc.h */ + Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, eccDp->prime, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, p_order, eccDp->order, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, eccDp->barrett_p, bitsize + 1u); + + /*Base Point, G = (p_x, p_y) */ + Cy_Crypto_Core_Vu_SetMemValue (base, p_x, eccDp->Gx, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, p_y, eccDp->Gy, bitsize); + + Cy_Crypto_Core_EC_NistP_SetMode(bitsize); + Cy_Crypto_Core_EC_NistP_SetRedAlg(eccDp->algo); + + /* Load random data into VU */ + CY_CRYPTO_VU_ALLOC_MEM(base, p_d, bitsize); + Cy_Crypto_Core_Vu_SetMemValue(base, p_d, (uint8_t *)privateKey, bitsize); + + Cy_Crypto_Core_EC_NistP_PointMul(base, p_x, p_y, p_d, p_order, bitsize); + + Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)publicKey->pubkey.x, p_x, bitsize); + Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)publicKey->pubkey.y, p_y, bitsize); + + publicKey->type = PK_PUBLIC; + publicKey->curveID = curveID; + + CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(VR_P) | CY_CRYPTO_VU_REG_BIT(p_order) | CY_CRYPTO_VU_REG_BIT(VR_BARRETT) | + CY_CRYPTO_VU_REG_BIT(p_x) | CY_CRYPTO_VU_REG_BIT(p_y) | CY_CRYPTO_VU_REG_BIT(p_d)); + + tmpResult = CY_CRYPTO_SUCCESS; } -#if ECC_KEY_GEN_DEBUG - Tb_PrintStr("\necc_make public key() for "); - Tb_PrintStr((int8_t *)eccDp->name); - Tb_PrintStr("\n"); -#endif /* ECC_KEY_GEN_DEBUG */ - - int bitsize = eccDp->size; - - int p_order = 9; /* order of the curve */ - int p_d = 10; /* private key */ - int p_x = 11; /* x coordinate */ - int p_y = 12; /* y coordinate */ - - /* make the public key - * EC scalar multiplication - X,Y-only co-Z arithmetic - */ - CY_CRYPTO_VU_ALLOC_MEM(base, VR_P, bitsize); - CY_CRYPTO_VU_ALLOC_MEM(base, p_order, bitsize); - CY_CRYPTO_VU_ALLOC_MEM(base, VR_BARRETT, bitsize + 1); - CY_CRYPTO_VU_ALLOC_MEM(base, p_x, bitsize); - CY_CRYPTO_VU_ALLOC_MEM(base, p_y, bitsize); - - /* Apply domain parameters */ - - /* load prime and order defining the curve as well as the barrett coefficient. */ - - /* P and BARRETT_U are "globally" defined in cy_crypto_core_ecc.h */ - Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, eccDp->prime, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, p_order, eccDp->order, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, eccDp->barrett_p, bitsize + 1); - - /*Base Point, G = (p_x, p_y) */ - Cy_Crypto_Core_Vu_SetMemValue (base, p_x, eccDp->Gx, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, p_y, eccDp->Gy, bitsize); - - Cy_Crypto_Core_EC_NistP_SetMode(bitsize); - Cy_Crypto_Core_EC_NistP_SetRedAlg(eccDp->algo); - - /* Load random data into VU */ - CY_CRYPTO_VU_ALLOC_MEM(base, p_d, bitsize); - Cy_Crypto_Core_Vu_SetMemValue(base, p_d, (uint8_t *)privateKey, bitsize); - - Cy_Crypto_Core_EC_NistP_PointMul(base, p_x, p_y, p_d, p_order, bitsize); - - Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)publicKey->pubkey.x, p_x, bitsize); - Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t *)publicKey->pubkey.y, p_y, bitsize); - - publicKey->type = PK_PUBLIC; - publicKey->curveID = curveID; - - CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(VR_P) | CY_CRYPTO_VU_REG_BIT(p_order) | CY_CRYPTO_VU_REG_BIT(VR_BARRETT) | - CY_CRYPTO_VU_REG_BIT(p_x) | CY_CRYPTO_VU_REG_BIT(p_y) | CY_CRYPTO_VU_REG_BIT(p_d)); - - return CY_CRYPTO_SUCCESS; + return (tmpResult); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_nist_p.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_nist_p.c index 17718cbbd6..e73f4ddf24 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_nist_p.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_ecc_nist_p.c @@ -52,34 +52,32 @@ /*************************************************************** * Global Variables ***************************************************************/ -static int eccMode; +static cy_en_crypto_ecc_curve_id_t eccMode; static cy_en_crypto_ecc_red_mul_algs_t mul_red_alg_select = CY_CRYPTO_NIST_P_BARRETT_RED_ALG; -/* Pre-computed coefficients for shift-multiply modular reduction for P256 and P384 */ -const uint8_t P256_ShMul_COEFF[] = { - 0x01u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, - 0x00u, 0x00u, 0x00u, 0x00u, 0xFFu, 0xFFu, 0xFFu, 0xFFu, - 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, - 0xFEu, 0xFFu, 0xFFu, 0xFFu -}; - -const uint8_t P384_ShMul_COEFF[] = { - 0x01u, 0x00u, 0x00u, 0x00u, 0xFFu, 0xFFu, 0xFFu, 0xFFu, - 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0x00u, 0x00u, 0x00u, 0x00u, - 0x01u -}; - - - /*************************************************************** * Collection of multiplication reduction algorithms -* Method 1 (Crypto_EC_CS_MUL_Red_Pxxx): curve specific -* reduction as proposed by NIST -* Method 2 (Crypto_EC_SM_MUL_Red_Pxxx): curve specific r -* eduction based on Mersenne prime reduction approach +* Method 1: (Crypto_EC_CS_MUL_Red_Pxxx): curve specific +* reduction as proposed by NIST +* Method 2: (Crypto_EC_SM_MUL_Red_Pxxx): curve specific r +* eduction based on Mersenne prime reduction approach * Method 3: generic Barrett reduction ***************************************************************/ +static void Cy_Crypto_Core_EC_CS_MUL_Red_P192(CRYPTO_Type *base, uint32_t z, uint32_t x); +static void Cy_Crypto_Core_EC_CS_MUL_Red_P224(CRYPTO_Type *base, uint32_t z, uint32_t x); +static void Cy_Crypto_Core_EC_CS_MUL_Red_P256(CRYPTO_Type *base, uint32_t z, uint32_t x); +static void Cy_Crypto_Core_EC_CS_MUL_Red_P384(CRYPTO_Type *base, uint32_t z, uint32_t x); +static void Cy_Crypto_Core_EC_CS_MUL_Red_P521(CRYPTO_Type *base, uint32_t z, uint32_t x); +static void Cy_Crypto_Core_EC_SM_MUL_Red_P192(CRYPTO_Type *base, uint32_t z, uint32_t x); +static void Cy_Crypto_Core_EC_SM_MUL_Red_P224(CRYPTO_Type *base, uint32_t z, uint32_t x); +static void Cy_Crypto_Core_EC_SM_MUL_Red_P256(CRYPTO_Type *base, uint32_t z, uint32_t x); +static void Cy_Crypto_Core_EC_SM_MUL_Red_P384(CRYPTO_Type *base, uint32_t z, uint32_t x); +static void Cy_Crypto_Core_EC_SM_MUL_Red_P521(CRYPTO_Type *base, uint32_t z, uint32_t x); + +static void Cy_Crypto_Core_EC_CS_MulRed(CRYPTO_Type *base, uint32_t z, uint32_t x, uint32_t size); +static void Cy_Crypto_Core_EC_SM_MulRed(CRYPTO_Type *base, uint32_t z, uint32_t x, uint32_t size); +static void Cy_Crypto_Core_EC_MulRed(CRYPTO_Type *base, uint32_t z, uint32_t x, uint32_t size); /*************************************************************** @@ -91,7 +89,7 @@ const uint8_t P384_ShMul_COEFF[] = { * Function Name: Cy_Crypto_Core_EC_CS_MUL_Red_P192 ****************************************************************************//** * -* Curve-specific multiplication modular reduction for P192 +* Curve-specific multiplication modular reduction for P192. * 0 <= a, b < P192 * a5..a0 * b5..b0 % P192 = t11..t0 % P192 * P192 = 2^192-2^64-1 @@ -108,52 +106,52 @@ const uint8_t P384_ShMul_COEFF[] = { * * \param z * Product = a*b [2*192 bits]. -* +* * \param x -* Result = x mod P = a*b mod P [192 bits] +* Result = x mod P = a*b mod P [192 bits]. * *******************************************************************************/ -void Cy_Crypto_Core_EC_CS_MUL_Red_P192(CRYPTO_Type *base, int z, int x) +static void Cy_Crypto_Core_EC_CS_MUL_Red_P192(CRYPTO_Type *base, uint32_t z, uint32_t x) { - int sh = 0; - int t1 = 2; /* 128 */ - int t2 = 3; /* 192 */ - int my_z = 4; - int my_x = 5; + uint32_t sh = 0u; + uint32_t t1 = 2u; /* 128 */ + uint32_t t2 = 3u; /* 192 */ + uint32_t my_z = 4u; + uint32_t my_x = 5u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, my_x, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, my_x, x); - CY_CRYPTO_VU_ALLOC_MEM (base, t1, 128); - CY_CRYPTO_VU_ALLOC_MEM (base, t2, 192); + CY_CRYPTO_VU_ALLOC_MEM (base, t1, 128u); + CY_CRYPTO_VU_ALLOC_MEM (base, t2, 192u); - CY_CRYPTO_VU_SET_REG (base, sh, 192, 1); - CY_CRYPTO_VU_LSR (base, my_z, my_x, sh); /* t11..t6 */ + CY_CRYPTO_VU_SET_REG (base, sh, 192u, 1u); + CY_CRYPTO_VU_LSR (base, my_z, my_x, sh); /* t11..t6 */ - CY_CRYPTO_VU_SET_REG (base, sh, 128, 1); - CY_CRYPTO_VU_LSR (base, t1, my_z, sh); /* t11..t10 */ - CY_CRYPTO_VU_SET_REG (base, sh, 64, 1); - CY_CRYPTO_VU_LSL (base, t2, my_z, sh); /* t9..t6 * 2^64 */ + CY_CRYPTO_VU_SET_REG (base, sh, 128u, 1u); + CY_CRYPTO_VU_LSR (base, t1, my_z, sh); /* t11..t10 */ + CY_CRYPTO_VU_SET_REG (base, sh, 64u, 1u); + CY_CRYPTO_VU_LSL (base, t2, my_z, sh); /* t9..t6 * 2^64 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, my_x); /* t11..t6 + t5..t0 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, my_x); /* t11..t6 + t5..t0 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); - CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* t9..t6 * 2^64 + t11..t6 + t5..t0 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* t9..t6 * 2^64 + t11..t6 + t5..t0 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); - CY_CRYPTO_VU_LSL (base, t2, t1, sh); /* t11..t10 * 2^64 */ - CY_CRYPTO_VU_OR (base, t1, t1, t2); /* t11..t10 * 2^64 + t11..t10 */ + CY_CRYPTO_VU_LSL (base, t2, t1, sh); /* t11..t10 * 2^64 */ + CY_CRYPTO_VU_OR (base, t1, t1, t2); /* t11..t10 * 2^64 + t11..t10 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* t11..t10 * 2^64 + t11..t10 + t9..t6 * 2^64 + t11..t6 + t5..t0 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* t11..t10 * 2^64 + t11..t10 + t9..t6 * 2^64 + t11..t6 + t5..t0 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); - CY_CRYPTO_VU_FREE_MEM (base, (1 << t1) | (1 << t2)); + CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t1) | CY_CRYPTO_VU_REG_BIT(t2)); CY_CRYPTO_VU_POP_REG (base); } @@ -174,57 +172,57 @@ void Cy_Crypto_Core_EC_CS_MUL_Red_P192(CRYPTO_Type *base, int z, int x) * * \param z * Result = x mod P = a*b mod P [224 bits]. -* +* * \param x * Product = a*b [2*224 bits]. * *******************************************************************************/ -void Cy_Crypto_Core_EC_CS_MUL_Red_P224(CRYPTO_Type *base, int z, int x) +static void Cy_Crypto_Core_EC_CS_MUL_Red_P224(CRYPTO_Type *base, uint32_t z, uint32_t x) { - int sh = 0; - int t1 = 1; /* 224 */ - int t2 = 2; /* 224 */ - int t3 = 3; /* 224 */ - int my_z = 4; - int my_x = 5; + uint32_t sh = 0u; + uint32_t t1 = 1u; /* 224 */ + uint32_t t2 = 2u; /* 224 */ + uint32_t t3 = 3u; /* 224 */ + uint32_t my_z = 4u; + uint32_t my_x = 5u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, my_x, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, my_x, x); - CY_CRYPTO_VU_ALLOC_MEM (base, t1, CY_CRYPTO_ECC_P224_SIZE); /* 224 */ - CY_CRYPTO_VU_ALLOC_MEM (base, t2, CY_CRYPTO_ECC_P224_SIZE); /* 224 */ - CY_CRYPTO_VU_ALLOC_MEM (base, t3, CY_CRYPTO_ECC_P224_SIZE); /* 224 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t1, CY_CRYPTO_ECC_P224_SIZE); /* 224 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t2, CY_CRYPTO_ECC_P224_SIZE); /* 224 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t3, CY_CRYPTO_ECC_P224_SIZE); /* 224 */ - CY_CRYPTO_VU_SET_REG (base, sh, CY_CRYPTO_ECC_P224_SIZE, 1); /* sh = 224 */ - CY_CRYPTO_VU_LSR (base, my_z, my_x, sh); /* z = t13..t7 */ + CY_CRYPTO_VU_SET_REG (base, sh, CY_CRYPTO_ECC_P224_SIZE, 1u); /* sh = 224 */ + CY_CRYPTO_VU_LSR (base, my_z, my_x, sh); /* z = t13..t7 */ - CY_CRYPTO_VU_SET_REG (base, sh, 128, 1); - CY_CRYPTO_VU_LSR (base, t1, my_z, sh); /* t1 = t13..t11 */ + CY_CRYPTO_VU_SET_REG (base, sh, 128u, 1u); + CY_CRYPTO_VU_LSR (base, t1, my_z, sh); /* t1 = t13..t11 */ - CY_CRYPTO_VU_SET_REG (base, sh, 96, 1); - CY_CRYPTO_VU_LSL (base, t2, t1, sh); /* t2 = t13..t11*2^96 */ + CY_CRYPTO_VU_SET_REG (base, sh, 96u, 1u); + CY_CRYPTO_VU_LSL (base, t2, t1, sh); /* t2 = t13..t11*2^96 */ - CY_CRYPTO_VU_SET_REG (base, sh, 96, 1); - CY_CRYPTO_VU_LSL (base, t3, my_z, sh); /* t3 = t10..t7*2^96 */ + CY_CRYPTO_VU_SET_REG (base, sh, 96u, 1u); + CY_CRYPTO_VU_LSL (base, t3, my_z, sh); /* t3 = t10..t7*2^96 */ - CY_CRYPTO_VU_ADD (base, t2, t2, my_x); /* t2 = t13..t11*2^96 + t6..t0 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, t2, VR_P); /* C = (t2 >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, t2, t2, VR_P); /* t2 = t2 - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_ADD (base, t2, t2, my_x); /* t2 = t13..t11*2^96 + t6..t0 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, t2, VR_P); /* C = (t2 >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, t2, t2, VR_P); /* t2 = t2 - p, if C==1 (Carry is set) */ - CY_CRYPTO_VU_SUB (base, t2, t2, my_z); /* t2 = (t13..t11*2^96 + t6..t0) - t13..t7 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, t2, t2, VR_P); /* t2 = t2 + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_SUB (base, t2, t2, my_z); /* t2 = (t13..t11*2^96 + t6..t0) - t13..t7 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, t2, t2, VR_P); /* t2 = t2 + p, if C==0 (Carry is clear) */ - CY_CRYPTO_VU_SUB (base, t2, t2, t1); /* t2 = (t13..t11*2^96 + t6..t0 - t13..t7) - t13..t11 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, t2, t2, VR_P); /* t2 = t2 + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_SUB (base, t2, t2, t1); /* t2 = (t13..t11*2^96 + t6..t0 - t13..t7) - t13..t11 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, t2, t2, VR_P); /* t2 = t2 + p, if C==0 (Carry is clear) */ - CY_CRYPTO_VU_ADD (base, my_z, t2, t3); /* z = (t13..t11*2^96 + t6..t0 - t13..t7 - t13..t11) + t10..t7*2^96 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_ADD (base, my_z, t2, t3); /* z = (t13..t11*2^96 + t6..t0 - t13..t7 - t13..t11) + t10..t7*2^96 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ - CY_CRYPTO_VU_FREE_MEM (base, (1 << t1) | (1 << t2) | (1 << t3)); + CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t1) | CY_CRYPTO_VU_REG_BIT(t2) | CY_CRYPTO_VU_REG_BIT(t3)); CY_CRYPTO_VU_POP_REG (base); } @@ -247,172 +245,172 @@ void Cy_Crypto_Core_EC_CS_MUL_Red_P224(CRYPTO_Type *base, int z, int x) * * \param z * Result = x mod P = a*b mod P [256 bits]. -* +* * \param x * Product = a*b [2*256 bits]. * *******************************************************************************/ -void Cy_Crypto_Core_EC_CS_MUL_Red_P256(CRYPTO_Type *base, int z, int x) +static void Cy_Crypto_Core_EC_CS_MUL_Red_P256(CRYPTO_Type *base, uint32_t z, uint32_t x) { - int sh = 0; /* Variable values */ - int sh32 = 1; - int sh96 = 2; - int sh192 = 3; - int sh224 = 4; - int t0 = 5; /* 256 */ - int t1 = 6; /* 256 */ - int t2 = 7; /* 256 */ - int t3 = 8; /* 32 */ - int t4 = 9; /* 96 */ - int my_z = 10; - int my_x = 11; + uint32_t sh = 0u; /* Variable values */ + uint32_t sh32 = 1u; + uint32_t sh96 = 2u; + uint32_t sh192 = 3u; + uint32_t sh224 = 4u; + uint32_t t0 = 5u; /* 256 */ + uint32_t t1 = 6u; /* 256 */ + uint32_t t2 = 7u; /* 256 */ + uint32_t t3 = 8u; /* 32 */ + uint32_t t4 = 9u; /* 96 */ + uint32_t my_z = 10u; + uint32_t my_x = 11u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, my_x, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, my_x, x); - CY_CRYPTO_VU_ALLOC_MEM (base, t0, CY_CRYPTO_ECC_P256_SIZE); /* 256 */ - CY_CRYPTO_VU_ALLOC_MEM (base, t1, CY_CRYPTO_ECC_P256_SIZE); /* 256 */ - CY_CRYPTO_VU_ALLOC_MEM (base, t2, CY_CRYPTO_ECC_P256_SIZE); /* 256 */ - CY_CRYPTO_VU_ALLOC_MEM (base, t3, 32); /* 32 */ - CY_CRYPTO_VU_ALLOC_MEM (base, t4, 96); /* 96 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t0, CY_CRYPTO_ECC_P256_SIZE); /* 256 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t1, CY_CRYPTO_ECC_P256_SIZE); /* 256 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t2, CY_CRYPTO_ECC_P256_SIZE); /* 256 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t3, 32u); /* 32 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t4, 96u); /* 96 */ - CY_CRYPTO_VU_SET_REG (base, sh, CY_CRYPTO_ECC_P256_SIZE, 1); /* sh = 256 */ - CY_CRYPTO_VU_SET_REG (base, sh32, 32, 1); /* sh = 32 */ - CY_CRYPTO_VU_SET_REG (base, sh96, 96, 1); /* sh = 96 */ - CY_CRYPTO_VU_SET_REG (base, sh192, 192, 1); /* sh = 192 */ - CY_CRYPTO_VU_SET_REG (base, sh224, 224, 1); /* sh = 224 */ + CY_CRYPTO_VU_SET_REG (base, sh, CY_CRYPTO_ECC_P256_SIZE, 1u); /* sh = 256 */ + CY_CRYPTO_VU_SET_REG (base, sh32, 32u, 1u); /* sh = 32 */ + CY_CRYPTO_VU_SET_REG (base, sh96, 96u, 1u); /* sh = 96 */ + CY_CRYPTO_VU_SET_REG (base, sh192, 192u, 1u); /* sh = 192 */ + CY_CRYPTO_VU_SET_REG (base, sh224, 224u, 1u); /* sh = 224 */ - CY_CRYPTO_VU_LSR (base, t0, my_x, sh); /* t0 = t15..t8 */ - CY_CRYPTO_VU_LSR (base, my_z, t0, sh96); /* z = t15..t11 */ - CY_CRYPTO_VU_LSR (base, t1, my_z, sh32); /* t1 = t15..t12 */ - CY_CRYPTO_VU_LSR (base, t3, my_z, sh32); /* t3 = t12 */ + CY_CRYPTO_VU_LSR (base, t0, my_x, sh); /* t0 = t15..t8 */ + CY_CRYPTO_VU_LSR (base, my_z, t0, sh96); /* z = t15..t11 */ + CY_CRYPTO_VU_LSR (base, t1, my_z, sh32); /* t1 = t15..t12 */ + CY_CRYPTO_VU_LSR (base, t3, my_z, sh32); /* t3 = t12 */ /* 2*S1 -- 2*t15..t11*2^96 */ - CY_CRYPTO_VU_LSL (base, my_z, my_z, sh96); /* z = t15..t11*2^96 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, my_z); /* z = 2*t15..t11*2^96 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSL (base, my_z, my_z, sh96); /* z = t15..t11*2^96 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, my_z); /* z = 2*t15..t11*2^96 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D3 (a) -- t12*2^224 */ - CY_CRYPTO_VU_LSL (base, t2, t3, sh224); /* t2 = t12*2^224 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t12*2^224 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSL (base, t2, t3, sh224); /* t2 = t12*2^224 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t12*2^224 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* 2*S2 -- 2*t15..t12*2^96 */ - CY_CRYPTO_VU_LSL (base, t2, t1, sh96); /* t2 = t15..t12*2^96 */ + CY_CRYPTO_VU_LSL (base, t2, t1, sh96); /* t2 = t15..t12*2^96 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t15..t12*2^96 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t15..t12*2^96 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + 2*t15..t12*2^96 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + 2*t15..t12*2^96 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D4 (c) -- t15..t14 */ - CY_CRYPTO_VU_LSR (base, t2, t0, sh192); /* t2 = t15..t14 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t15..t14 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSR (base, t2, t0, sh192); /* t2 = t15..t14 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t15..t14 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* S3 (a) -- t15..t14*2^192 */ - CY_CRYPTO_VU_LSL (base, t2, t2, sh192); /* t2 = t15..t14*2^192 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t15..t14*2^192 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSL (base, t2, t2, sh192); /* t2 = t15..t14*2^192 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t15..t14*2^192 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D2 (c) -- t15..t12 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t15..t12 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t15..t12 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* S4 (b) -- t13*2^192 */ - CY_CRYPTO_VU_LSR (base, t3, t1, sh32); /* t3 = t13 */ - CY_CRYPTO_VU_LSL (base, t2, t3, sh192); /* t2 = t13*2^192 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t13*2^192 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSR (base, t3, t1, sh32); /* t3 = t13 */ + CY_CRYPTO_VU_LSL (base, t2, t3, sh192); /* t2 = t13*2^192 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t13*2^192 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D4 (a) -- t13*2^224 */ - CY_CRYPTO_VU_LSL (base, t2, t2, sh32); /* t2 = t13*2^224 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t13*2^224 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSL (base, t2, t2, sh32); /* t2 = t13*2^224 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t13*2^224 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* D3 (c) -- t15..t13 */ - CY_CRYPTO_VU_LSR (base, t1, t1, sh32); /* t1 = t15..t13 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t15..t13 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSR (base, t1, t1, sh32); /* t1 = t15..t13 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t15..t13 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* S4 (c) -- t15..t13*2^96 */ - CY_CRYPTO_VU_LSL (base, t2, t1, sh96); /* t2 = t15..t13*2^96 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t15..t13*2^96 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSL (base, t2, t1, sh96); /* t2 = t15..t13*2^96 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t15..t13*2^96 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D2 (a) -- t11*2^224 */ - CY_CRYPTO_VU_LSR (base, t3, t0, sh96); /* t3 = t11 */ - CY_CRYPTO_VU_LSL (base, t2, t3, sh224); /* t2 = t11*2^224 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t11*2^224 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSR (base, t3, t0, sh96); /* t3 = t11 */ + CY_CRYPTO_VU_LSL (base, t2, t3, sh224); /* t2 = t11*2^224 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t11*2^224 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* D2 (b) -- t9*2^192 */ - CY_CRYPTO_VU_LSR (base, t3, t0, sh32); /* t3 = t9 */ - CY_CRYPTO_VU_LSL (base, t2, t3, sh192); /* t2 = t9*2^192 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t9*2^192 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSR (base, t3, t0, sh32); /* t3 = t9 */ + CY_CRYPTO_VU_LSL (base, t2, t3, sh192); /* t2 = t9*2^192 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t9*2^192 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* D1 (c) -- t13..t11 */ - CY_CRYPTO_VU_LSR (base, t4, t0, sh96); /* t4 = t13..t11 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t4); /* z = z - t13..t11 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSR (base, t4, t0, sh96); /* t4 = t13..t11 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t4); /* z = z - t13..t11 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* S4 (d) -- t11..t9 */ - CY_CRYPTO_VU_LSR (base, t4, t0, sh32); /* t4 = t11..t9 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t4); /* z = z + t11..t9 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSR (base, t4, t0, sh32); /* t4 = t11..t9 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t4); /* z = z + t11..t9 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D1 (a) -- t10*2^224 */ - CY_CRYPTO_VU_LSR (base, t3, t4, sh32); /* t3 = t10 */ - CY_CRYPTO_VU_LSL (base, t2, t3, sh224); /* t2 = t10*2^224 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t10*2^224 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSR (base, t3, t4, sh32); /* t3 = t10 */ + CY_CRYPTO_VU_LSL (base, t2, t3, sh224); /* t2 = t10*2^224 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t10*2^224 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* D4 (b) -- t11..t9*2^96 */ - CY_CRYPTO_VU_LSL (base, t2, t4, sh96); /* t2 = t11..t9*2^96 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t11..t9*2^96 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSL (base, t2, t4, sh96); /* t2 = t11..t9*2^96 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t11..t9*2^96 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ - CY_CRYPTO_VU_SET_REG (base, sh, 0, 1); /* sh = 0; */ + CY_CRYPTO_VU_SET_REG (base, sh, 0u, 1u); /* sh = 0; */ /* S3 (b) -- t10..t8 */ - CY_CRYPTO_VU_LSR (base, t4, t0, sh); /* t4 = t10..t8 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t4); /* z = z + t10..t8 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSR (base, t4, t0, sh); /* t4 = t10..t8 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t4); /* z = z + t10..t8 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D3 (b) -- t10..t8*2^96 */ - CY_CRYPTO_VU_LSL (base, t2, t4, sh96); /* t4 = t10..t8*2^96 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t10..t8*2^96 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSL (base, t2, t4, sh96); /* t4 = t10..t8*2^96 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t10..t8*2^96 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* S4 (a) -- t8*2^224 */ - CY_CRYPTO_VU_LSL (base, t2, t0, sh224); /* t2 = t8*2^224 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t8*2^224 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSL (base, t2, t0, sh224); /* t2 = t8*2^224 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t8*2^224 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D1 (b) -- t8*2^192 */ - CY_CRYPTO_VU_LSR (base, t2, t2, sh32); /* t2 = t8*2^192 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t8*2^192 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSR (base, t2, t2, sh32); /* t2 = t8*2^192 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t8*2^192 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* T -- t7..t0 */ - CY_CRYPTO_VU_LSR (base, t2, my_x, sh); /* t2 = t8*2^192 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t7..t0 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSR (base, t2, my_x, sh); /* t2 = t8*2^192 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t7..t0 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t0) | CY_CRYPTO_VU_REG_BIT(t1) | @@ -438,132 +436,132 @@ void Cy_Crypto_Core_EC_CS_MUL_Red_P256(CRYPTO_Type *base, int z, int x) * * \param z * Result = x mod P = a*b mod P [384 bits] -* +* * \param x * Product = a*b [2*384 bits] * *******************************************************************************/ -void Cy_Crypto_Core_EC_CS_MUL_Red_P384(CRYPTO_Type *base, int z, int x) +static void Cy_Crypto_Core_EC_CS_MUL_Red_P384(CRYPTO_Type *base, uint32_t z, uint32_t x) { - int sh32 = 0; - int sh64 = 1; - int sh96 = 2; - int sh128 = 3; - int sh256 = 4; - int sh384 = 5; - int t0 = 6; /* 384 */ - int t1 = 7; /* 384 */ - int t2 = 8; /* 32 */ - int my_z = 9; - int my_x = 10; + uint32_t sh32 = 0u; + uint32_t sh64 = 1u; + uint32_t sh96 = 2u; + uint32_t sh128 = 3u; + uint32_t sh256 = 4u; + uint32_t sh384 = 5u; + uint32_t t0 = 6u; /* 384 */ + uint32_t t1 = 7u; /* 384 */ + uint32_t t2 = 8u; /* 32 */ + uint32_t my_z = 9u; + uint32_t my_x = 10u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, my_x, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, my_x, x); - CY_CRYPTO_VU_ALLOC_MEM (base, t0, CY_CRYPTO_ECC_P384_SIZE); /* 384 */ - CY_CRYPTO_VU_ALLOC_MEM (base, t1, CY_CRYPTO_ECC_P384_SIZE); /* 384 */ - CY_CRYPTO_VU_ALLOC_MEM (base, t2, 32); /* 32 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t0, CY_CRYPTO_ECC_P384_SIZE); /* 384 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t1, CY_CRYPTO_ECC_P384_SIZE); /* 384 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t2, 32u); /* 32 */ - CY_CRYPTO_VU_SET_REG (base, sh32, 32, 1); /* sh32 = 32 */ - CY_CRYPTO_VU_SET_REG (base, sh64, 64, 1); /* sh64 = 64 */ - CY_CRYPTO_VU_SET_REG (base, sh96, 96, 1); /* sh96 = 96 */ - CY_CRYPTO_VU_SET_REG (base, sh128, 128, 1); /* sh128 = 128 */ - CY_CRYPTO_VU_SET_REG (base, sh256, 256, 1); /* sh256 = 256 */ - CY_CRYPTO_VU_SET_REG (base, sh384, CY_CRYPTO_ECC_P384_SIZE, 1); /* sh384 = 384 */ + CY_CRYPTO_VU_SET_REG (base, sh32, 32u, 1u); /* sh32 = 32 */ + CY_CRYPTO_VU_SET_REG (base, sh64, 64u, 1u); /* sh64 = 64 */ + CY_CRYPTO_VU_SET_REG (base, sh96, 96u, 1u); /* sh96 = 96 */ + CY_CRYPTO_VU_SET_REG (base, sh128, 128u, 1u); /* sh128 = 128 */ + CY_CRYPTO_VU_SET_REG (base, sh256, 256u, 1u); /* sh256 = 256 */ + CY_CRYPTO_VU_SET_REG (base, sh384, CY_CRYPTO_ECC_P384_SIZE, 1u); /* sh384 = 384 */ - CY_CRYPTO_VU_LSR (base, t0, my_x, sh384); /* t0 = t23..t12 */ + CY_CRYPTO_VU_LSR (base, t0, my_x, sh384); /* t0 = t23..t12 */ /* T + S2 -- t11..t0 + t23..t12 */ - CY_CRYPTO_VU_ADD (base, my_z, t0, my_x); /* z = t23..t12 + t11..t0 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_ADD (base, my_z, t0, my_x); /* z = t23..t12 + t11..t0 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* S6 (b) -- t_20 */ - CY_CRYPTO_VU_LSR (base, t2, t0, sh256); /* t2 = t20 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t20 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSR (base, t2, t0, sh256); /* t2 = t20 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t2); /* z = z + t20 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* S4 (b) -- t20*2^96 */ - CY_CRYPTO_VU_LSL (base, t1, t2, sh96); /* t1 = t20*2^96 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t20*2^96 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSL (base, t1, t2, sh96); /* t1 = t20*2^96 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t20*2^96 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* S5 -- t23..t20*2^128 */ - CY_CRYPTO_VU_LSR (base, t1, t0, sh256); /* t1 = t23..t20 */ - CY_CRYPTO_VU_LSL (base, t1, t1, sh128); /* t1 = t23..t20*2^128 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t23..t20*2^128 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSR (base, t1, t0, sh256); /* t1 = t23..t20 */ + CY_CRYPTO_VU_LSL (base, t1, t1, sh128); /* t1 = t23..t20*2^128 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t23..t20*2^128 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D2 -- t23..t20*2^32 */ - CY_CRYPTO_VU_LSR (base, t1, t1, sh96); /* t1 = t23..t20*2^32 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t23..t20*2^32 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSR (base, t1, t1, sh96); /* t1 = t23..t20*2^32 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t23..t20*2^32 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* S3 (b) -- t23..t21 */ - CY_CRYPTO_VU_LSR (base, t1, t1, sh64); /* t1 = t23..t21 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t23..t21 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSR (base, t1, t1, sh64); /* t1 = t23..t21 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t23..t21 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D1 (b) -- t23 */ - CY_CRYPTO_VU_LSR (base, t2, t1, sh64); /* t2 = t23 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t23 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSR (base, t2, t1, sh64); /* t2 = t23 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t2); /* z = z - t23 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* S6 (a) -- t23..t21*2^96 */ - CY_CRYPTO_VU_LSL (base, t1, t1, sh96); /* t1 = t23..t21*2^96 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t23..t21*2^96 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSL (base, t1, t1, sh96); /* t1 = t23..t21*2^96 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t23..t21*2^96 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* 2*S1 -- 2*t23..t21*2^128 */ - CY_CRYPTO_VU_LSL (base, t1, t1, sh32); /* t1 = t23..t21*2^128 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t23..t21*2^128 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t20..t12*2^128 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSL (base, t1, t1, sh32); /* t1 = t23..t21*2^128 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t23..t21*2^128 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t20..t12*2^128 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* S4 (c) -- t23*2^32 */ - CY_CRYPTO_VU_LSL (base, t1, t2, sh32); /* t1 = t23*2^32 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t23*2^32 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSL (base, t1, t2, sh32); /* t1 = t23*2^32 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t23*2^32 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* D3 (b) -- t23*2^96 */ - CY_CRYPTO_VU_LSL (base, t1, t1, sh64); /* t1 = t23*2^96 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t23*2^96 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSL (base, t1, t1, sh64); /* t1 = t23*2^96 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t23*2^96 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* D3 (a) -- t23*2^128 */ - CY_CRYPTO_VU_LSL (base, t1, t1, sh32); /* t1 = t23*2^128 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t23*2^128 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSL (base, t1, t1, sh32); /* t1 = t23*2^128 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t23*2^128 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* D1 (a) -- t22..t12*2^32 */ - CY_CRYPTO_VU_LSL (base, t1, t0, sh32); /* t1 = t22..t12*2^32 */ - CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t22..t12*2^32 */ - CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ + CY_CRYPTO_VU_LSL (base, t1, t0, sh32); /* t1 = t22..t12*2^32 */ + CY_CRYPTO_VU_SUB (base, my_z, my_z, t1); /* z = z - t22..t12*2^32 */ + CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, my_z, my_z, VR_P); /* z = z + p, if C==0 (Carry is clear) */ /* S3 (a) -- t20..t12*2^96 */ - CY_CRYPTO_VU_LSL (base, t1, t1, sh64); /* t1 = t20..t12*2^96 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t20..t12*2^96 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSL (base, t1, t1, sh64); /* t1 = t20..t12*2^96 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t20..t12*2^96 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ /* S4 (a) -- t19..t12*2^128 */ - CY_CRYPTO_VU_LSL (base, t1, t1, sh32); /* t1 = t19..t12*2^128 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t19..t12*2^128 */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_LSL (base, t1, t1, sh32); /* t1 = t19..t12*2^128 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, t1); /* z = z + t19..t12*2^128 */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* z = z - p, if C==1 (Carry is set) */ - CY_CRYPTO_VU_FREE_MEM (base, (1 << t0) | (1 << t1) | (1 << t2)); + CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t0) | CY_CRYPTO_VU_REG_BIT(t1) | CY_CRYPTO_VU_REG_BIT(t2)); CY_CRYPTO_VU_POP_REG (base); } @@ -585,34 +583,34 @@ void Cy_Crypto_Core_EC_CS_MUL_Red_P384(CRYPTO_Type *base, int z, int x) * * \param z * Result = x mod P = a*b mod P [521 bits] -* +* * \param x * Product = a*b [2*521 bits] * *******************************************************************************/ -void Cy_Crypto_Core_EC_CS_MUL_Red_P521(CRYPTO_Type *base, int z, int x) +static void Cy_Crypto_Core_EC_CS_MUL_Red_P521(CRYPTO_Type *base, uint32_t z, uint32_t x) { - int sh521 = 0; - int t0 = 1; - int my_z = 2; - int my_x = 3; + uint32_t sh521 = 0u; + uint32_t t0 = 1u; + uint32_t my_z = 2u; + uint32_t my_x = 3u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, my_x, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, my_x, x); - CY_CRYPTO_VU_ALLOC_MEM (base, t0, CY_CRYPTO_ECC_P521_SIZE); /* 521 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t0, CY_CRYPTO_ECC_P521_SIZE); /* 521 */ - CY_CRYPTO_VU_SET_REG (base, sh521, 521, 1); /* sh521 = 521 */ + CY_CRYPTO_VU_SET_REG (base, sh521, 521u, 1u); /* sh521 = 521 */ - CY_CRYPTO_VU_LSR (base, my_z, my_x, sh521); /* z = T1 */ + CY_CRYPTO_VU_LSR (base, my_z, my_x, sh521); /* z = T1 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, my_x); /* z = T1 + T0 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, my_x); /* z = T1 + T0 */ /* T0 + T1 mod p */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (t2 >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* t2 = t2 - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (t2 >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* t2 = t2 - p, if C==1 (Carry is set) */ CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t0)); @@ -630,7 +628,7 @@ void Cy_Crypto_Core_EC_CS_MUL_Red_P521(CRYPTO_Type *base, int z, int x) * * \param z * Result. -* +* * \param x * Product. * @@ -638,7 +636,7 @@ void Cy_Crypto_Core_EC_CS_MUL_Red_P521(CRYPTO_Type *base, int z, int x) * Size. * *******************************************************************************/ -void Cy_Crypto_Core_EC_CS_MulRed(CRYPTO_Type *base, int z, int x, int size) +static void Cy_Crypto_Core_EC_CS_MulRed(CRYPTO_Type *base, uint32_t z, uint32_t x, uint32_t size) { switch (eccMode) { @@ -680,57 +678,57 @@ void Cy_Crypto_Core_EC_CS_MulRed(CRYPTO_Type *base, int z, int x, int size) * * \param z * Result = x mod P = a*b mod P [192 bits]. -* +* * \param x * Product = a*b [2*192 bits]. * *******************************************************************************/ -void Cy_Crypto_Core_EC_SM_MUL_Red_P192(CRYPTO_Type *base, int z, int x) +static void Cy_Crypto_Core_EC_SM_MUL_Red_P192(CRYPTO_Type *base, uint32_t z, uint32_t x) { /* Setup */ - int partial = 0; - int hi = 1; - int sh64 = 2; - int sh192 = 3; - int my_z = 4; - int my_x = 5; + uint32_t partial = 0u; + uint32_t hi = 1u; + uint32_t sh64 = 2u; + uint32_t sh192 = 3u; + uint32_t my_z = 4u; + uint32_t my_x = 5u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, my_x, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, my_x, x); - CY_CRYPTO_VU_ALLOC_MEM (base, partial, CY_CRYPTO_ECC_P192_SIZE + 65); - CY_CRYPTO_VU_ALLOC_MEM (base, hi, CY_CRYPTO_ECC_P192_SIZE + 64); + CY_CRYPTO_VU_ALLOC_MEM (base, partial, CY_CRYPTO_ECC_P192_SIZE + 65u); + CY_CRYPTO_VU_ALLOC_MEM (base, hi, CY_CRYPTO_ECC_P192_SIZE + 64u); - CY_CRYPTO_VU_SET_REG (base, sh64, 64, 1); - CY_CRYPTO_VU_SET_REG (base, sh192, 192, 1); + CY_CRYPTO_VU_SET_REG (base, sh64, 64u, 1u); + CY_CRYPTO_VU_SET_REG (base, sh192, 192u, 1u); /* Step 2: 1st round of shift-multiply - * (Separate hi and lo (LSR hi>>CURVE_SIZE), multiply hi (LSL hi and add 1) and add shifted hi to lo) - * hi*(2^{64} + 1) + lo - */ - CY_CRYPTO_VU_LSR (base, hi, my_x, sh192); /* hi = prod >> CURVE_SIZE = prod[383:192] */ - CY_CRYPTO_VU_MOV (base, my_z, my_x); /* z == lo = prod[191:0] */ + * (Separate hi and lo (LSR hi>>CURVE_SIZE), multiply hi (LSL hi and add 1) and add shifted hi to lo) + * hi * (2^{64} + 1) + lo + */ + CY_CRYPTO_VU_LSR (base, hi, my_x, sh192); /* hi = prod >> CURVE_SIZE = prod[383:192] */ + CY_CRYPTO_VU_MOV (base, my_z, my_x); /* z == lo = prod[191:0] */ - CY_CRYPTO_VU_ADD (base, partial, hi, my_z); /* partial = (hi*1) + lo */ + CY_CRYPTO_VU_ADD (base, partial, hi, my_z); /* partial = (hi*1) + lo */ - CY_CRYPTO_VU_LSL (base, hi, hi, sh64); /* hi = hi << 64 = hi*2^{64} */ + CY_CRYPTO_VU_LSL (base, hi, hi, sh64); /* hi = hi << 64 = hi*2^{64} */ - CY_CRYPTO_VU_ADD (base, partial, partial, hi); /* partial = hi*(2^{64}+1) + lo */ + CY_CRYPTO_VU_ADD (base, partial, partial, hi); /* partial = hi*(2^{64}+1) + lo */ /* Step 3: 2nd round of shift-multiply */ - CY_CRYPTO_VU_LSR (base, hi, partial, sh192); /* hi = partial >> CURVE_SIZE = partial[383:192] */ + CY_CRYPTO_VU_LSR (base, hi, partial, sh192); /* hi = partial >> CURVE_SIZE = partial[383:192] */ - CY_CRYPTO_VU_ADD (base, my_z, hi, partial); /* z = (hi*1) + lo (Note: partial == lo, since it will be cut to CURVE_SIZE since z = CURVE_SIZE) */ + CY_CRYPTO_VU_ADD (base, my_z, hi, partial); /* z = (hi*1) + lo (Note: partial == lo, since it will be cut to CURVE_SIZE since z = CURVE_SIZE) */ - CY_CRYPTO_VU_LSL (base, hi, hi, sh64); /* hi = hi << 64 = hi*2^{64} */ + CY_CRYPTO_VU_LSL (base, hi, hi, sh64); /* hi = hi << 64 = hi*2^{64} */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, hi); /* z = hi*(2^{64}+1) + lo */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, hi); /* z = hi*(2^{64}+1) + lo */ /* Step 4: Final reduction (compare to P-192 and reduce if necessary, based on CARRY flag) */ - CY_CRYPTO_VU_CMP_SUB (base, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_CMP_SUB (base, my_z, VR_P); /* C = (z >= VR_P) */ CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(partial) | CY_CRYPTO_VU_REG_BIT(hi)); @@ -750,57 +748,57 @@ void Cy_Crypto_Core_EC_SM_MUL_Red_P192(CRYPTO_Type *base, int z, int x) * * \param z * Result = x mod P = a*b mod P [224 bits]. -* +* * \param x * Product = a*b [2*224 bits]. * *******************************************************************************/ -void Cy_Crypto_Core_EC_SM_MUL_Red_P224(CRYPTO_Type *base, int z, int x) +static void Cy_Crypto_Core_EC_SM_MUL_Red_P224(CRYPTO_Type *base, uint32_t z, uint32_t x) { /* Setup */ - int partial = 0; - int hi = 1; - int sh96 = 2; - int sh224 = 3; - int my_z = 4; - int my_x = 5; + uint32_t partial = 0u; + uint32_t hi = 1u; + uint32_t sh96 = 2u; + uint32_t sh224 = 3u; + uint32_t my_z = 4u; + uint32_t my_x = 5u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, my_x, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, my_x, x); - CY_CRYPTO_VU_ALLOC_MEM (base, partial, CY_CRYPTO_ECC_P224_SIZE + 97); - CY_CRYPTO_VU_ALLOC_MEM (base, hi, CY_CRYPTO_ECC_P224_SIZE + 96); + CY_CRYPTO_VU_ALLOC_MEM (base, partial, CY_CRYPTO_ECC_P224_SIZE + 97u); + CY_CRYPTO_VU_ALLOC_MEM (base, hi, CY_CRYPTO_ECC_P224_SIZE + 96u); - CY_CRYPTO_VU_SET_REG (base, sh96, 96, 1); - CY_CRYPTO_VU_SET_REG (base, sh224, 224, 1); + CY_CRYPTO_VU_SET_REG (base, sh96, 96u, 1u); + CY_CRYPTO_VU_SET_REG (base, sh224, 224u, 1u); /* Step 2: 1st round of shift-multiply - * (Separate hi and lo (LSR hi>>CURVE_SIZE), multiply hi (LSL hi<<96 and subtract 1) and add shifted hi to lo) - * hi*(2^{96} + 1) + lo - */ - CY_CRYPTO_VU_LSR (base, hi, my_x, sh224); /* hi = prod >> CURVE_SIZE = prod[447:224] */ - CY_CRYPTO_VU_MOV (base, my_z, my_x); /* z == lo = prod[223:0] */ + * (Separate hi and lo (LSR hi>>CURVE_SIZE), multiply hi (LSL hi<<96 and subtract 1) and add shifted hi to lo) + * hi * (2^{96} + 1) + lo + */ + CY_CRYPTO_VU_LSR (base, hi, my_x, sh224); /* hi = prod >> CURVE_SIZE = prod[447:224] */ + CY_CRYPTO_VU_MOV (base, my_z, my_x); /* z == lo = prod[223:0] */ - CY_CRYPTO_VU_SUB (base, partial, my_z, hi); /* partial = lo - (hi*1) */ + CY_CRYPTO_VU_SUB (base, partial, my_z, hi); /* partial = lo - (hi*1) */ - CY_CRYPTO_VU_LSL (base, hi, hi, sh96); /* hi = hi << 96 = hi*2^{96} */ + CY_CRYPTO_VU_LSL (base, hi, hi, sh96); /* hi = hi << 96 = hi*2^{96} */ - CY_CRYPTO_VU_ADD (base, partial, partial, hi); /* partial = hi*(2^{96}-1) + lo */ + CY_CRYPTO_VU_ADD (base, partial, partial, hi); /* partial = hi*(2^{96}-1) + lo */ /* Step 3: 2nd round of shift-multiply */ - CY_CRYPTO_VU_LSR (base, hi, partial, sh224); /* hi = partial>>CURVE_SIZE = partial[447:224] */ + CY_CRYPTO_VU_LSR (base, hi, partial, sh224); /* hi = partial>>CURVE_SIZE = partial[447:224] */ - CY_CRYPTO_VU_SUB (base, my_z, partial, hi); /* z = lo - (hi*1) (Note: partial == lo, since it will be cut to CURVE_SIZE since z = CURVE_SIZE) */ + CY_CRYPTO_VU_SUB (base, my_z, partial, hi); /* z = lo - (hi*1) (Note: partial == lo, since it will be cut to CURVE_SIZE since z = CURVE_SIZE) */ - CY_CRYPTO_VU_LSL (base, hi, hi, sh96); /* hi = hi<<96 = hi*2^{96} */ + CY_CRYPTO_VU_LSL (base, hi, hi, sh96); /* hi = hi<<96 = hi*2^{96} */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, hi); /* z = hi*(2^{96}-1) + lo */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, hi); /* z = hi*(2^{96}-1) + lo */ /* Step 4: Final reduction (compare to P-224 and reduce if necessary, based on CARRY flag) */ - CY_CRYPTO_VU_CMP_SUB (base, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_CMP_SUB (base, my_z, VR_P); /* C = (z >= VR_P) */ CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(partial) | CY_CRYPTO_VU_REG_BIT(hi)); @@ -808,61 +806,6 @@ void Cy_Crypto_Core_EC_SM_MUL_Red_P224(CRYPTO_Type *base, int z, int x) } -/******************************************************************************* -* Function Name: Cy_Crypto_Core_EC_P256_ShMulRed_Coeff -****************************************************************************//** -* -* Generate multiplier for shift-multiply multiplication reduction P256. -* Multiplier coeficient = (2^{224} - 2^{192} - 2^{96} + 1) -* Multiplier coefficient = fffffffe ffffffff ffffffff ffffffff 00000000 00000000 00000001 -* -* \param base -* The pointer to a Crypto instance. -* -* \param z -* Result = x mod P = a*b mod P [224 bits]. -* -* \param x -* Product = a*b [2*224 bits]. -* -* \note Complicated swapping of t and coeff registers is to ensure coeff only -* requires 224 bits, while t requires 225 bits. Hence, the externally used -* register coeff requires one less bit. -* -*******************************************************************************/ -void Cy_Crypto_Core_EC_P256_ShMulRed_Coeff(CRYPTO_Type *base, int coeff) -{ - int sh = 0; - int t = 1; - int my_coeff = 2; - - CY_CRYPTO_VU_PUSH_REG (base); - - CY_CRYPTO_VU_LD_REG (base, my_coeff, coeff); - - CY_CRYPTO_VU_SET_REG (base, sh, 224, 1u); /* sh = 224 */ - CY_CRYPTO_VU_ALLOC_MEM (base, t, 225u); /* t [225 bits] */ - - CY_CRYPTO_VU_SET_TO_ONE (base, t); /* t = 1 */ - CY_CRYPTO_VU_LSL (base, t, t, sh); /* t = 1<<224 */ - - CY_CRYPTO_VU_SET_REG (base, sh, 32, 1u); /* sh = 32 */ - CY_CRYPTO_VU_LSR (base, my_coeff, t, sh); /* coeff = 1<<192 */ - CY_CRYPTO_VU_SUB (base, t, t, my_coeff); /* t = 1<<224 - 1<<192 */ - - CY_CRYPTO_VU_SET_REG (base, sh, 96, 1u); /* sh = 96 */ - CY_CRYPTO_VU_LSR (base, my_coeff, my_coeff, sh); /* coeff = 1<<96 */ - CY_CRYPTO_VU_SUB (base, t, t, my_coeff); /* t = 1<<224 - 1<<192 - 1<<96 */ - - CY_CRYPTO_VU_LSR (base, my_coeff, my_coeff, sh); /* coeff = 1 */ - CY_CRYPTO_VU_ADD (base, my_coeff, my_coeff, t); /* coeff = 1<<224 - 1<<192 - 1<<96 + 1 */ - - CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t)); - CY_CRYPTO_VU_POP_REG (base); - -} - - /******************************************************************************* * Function Name: Cy_Crypto_Core_EC_SM_MUL_Red_P256 ****************************************************************************//** @@ -876,97 +819,103 @@ void Cy_Crypto_Core_EC_P256_ShMulRed_Coeff(CRYPTO_Type *base, int coeff) * * \param z * Result. -* +* * \param x * Product. * *******************************************************************************/ -void Cy_Crypto_Core_EC_SM_MUL_Red_P256(CRYPTO_Type *base, int z, int x) +static void Cy_Crypto_Core_EC_SM_MUL_Red_P256(CRYPTO_Type *base, uint32_t z, uint32_t x) { + /* Pre-computed coefficient for shift-multiply modular reduction for P256 */ + const uint8_t P256_ShMul_COEFF[] = { + 0x01u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, + 0x00u, 0x00u, 0x00u, 0x00u, 0xFFu, 0xFFu, 0xFFu, 0xFFu, + 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, + 0xFEu, 0xFFu, 0xFFu, 0xFFu + }; + /* Setup */ - int partial = 0; - int hi = 1; - int sh256 = 2; - int my_z = 3; - int my_x = 4; - int coeff = 5; + uint32_t partial = 0u; + uint32_t hi = 1u; + uint32_t sh256 = 2u; + uint32_t my_z = 3u; + uint32_t my_x = 4u; + uint32_t coeff = 5u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, my_x, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, my_x, x); - CY_CRYPTO_VU_ALLOC_MEM (base, coeff, 224u); - CY_CRYPTO_VU_ALLOC_MEM (base, partial, CY_CRYPTO_ECC_P256_SIZE + 224u); - CY_CRYPTO_VU_ALLOC_MEM (base, hi, CY_CRYPTO_ECC_P256_SIZE); + CY_CRYPTO_VU_ALLOC_MEM (base, coeff, 224u); + CY_CRYPTO_VU_ALLOC_MEM (base, partial, CY_CRYPTO_ECC_P256_SIZE + 224u); + CY_CRYPTO_VU_ALLOC_MEM (base, hi, CY_CRYPTO_ECC_P256_SIZE); - CY_CRYPTO_VU_SET_REG (base, sh256, 256, 1u); + CY_CRYPTO_VU_SET_REG (base, sh256, 256u, 1u); - /* Cy_Crypto_Core_EC_P256_ShMulRed_Coeff(coeff); */ - Cy_Crypto_Core_Vu_SetMemValue (base, coeff, P256_ShMul_COEFF, 224u); + Cy_Crypto_Core_Vu_SetMemValue (base, coeff, P256_ShMul_COEFF, 224u); /* Step 2: 1st round of shift-multiply - * (Separate hi and lo (LSR hi>>CURVE_SIZE), multiply hi*c and add hi*coeff + lo) - * hi*coeff + lo - */ - CY_CRYPTO_VU_LSR (base, hi, my_x, sh256); /* hi = prod >> CURVE_SIZE = prod[511:256] */ - CY_CRYPTO_VU_MOV (base, my_z, my_x); /* z == lo = prod[255:0] */ + * (Separate hi and lo (LSR hi>>CURVE_SIZE), multiply hi*c and add hi*coeff + lo) + * hi*coeff + lo + */ + CY_CRYPTO_VU_LSR (base, hi, my_x, sh256); /* hi = prod >> CURVE_SIZE = prod[511:256] */ + CY_CRYPTO_VU_MOV (base, my_z, my_x); /* z == lo = prod[255:0] */ - CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ - - CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* partial = hi*coeff + lo */ + CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ + CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* partial = hi*coeff + lo */ /* Step 3: 2nd round of shift-multiply */ - CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ - CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ - CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ - CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ + CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ + CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ + CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ + CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ /* Step 4: 3rd round of shift-multiply */ - CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ - CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ + CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ + CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ - CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ - CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ + CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ + CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ /* Step 5: 4th round of shift-multiply */ - CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ - CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ + CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ + CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ - CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ - CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ + CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ + CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ /* Step 6: 5th round of shift-multiply */ - CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ - CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ + CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ + CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ - CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ - CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ + CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ + CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ /* Step 7: 6th round of shift-multiply */ - CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ - CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ + CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ + CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ - CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ - CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ + CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ + CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ /* Step 8: 7th round of shift-multiply */ - CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ - CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ + CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ + CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ - CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ - CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ + CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ + CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* z = hi*coeff + lo */ /* Step 9: 8th round of shift-multiply */ - CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ - CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ + CY_CRYPTO_VU_LSR (base, hi, partial, sh256); /* hi = partial>>CURVE_SIZE = partial[511:256] */ + CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[255:0] */ - CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ - CY_CRYPTO_VU_ADD (base, my_z, partial, my_z); /* z = hi*coeff + lo */ + CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ + CY_CRYPTO_VU_ADD (base, my_z, partial, my_z); /* z = hi*coeff + lo */ /* Step 11: Final reduction (compare to P-256 and reduce if necessary, based on CARRY flag) */ - CY_CRYPTO_VU_CMP_SUB (base, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_CMP_SUB (base, my_z, VR_P); /* C = (z >= VR_P) */ CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(partial) | CY_CRYPTO_VU_REG_BIT(hi) | CY_CRYPTO_VU_REG_BIT(coeff)); @@ -974,55 +923,6 @@ void Cy_Crypto_Core_EC_SM_MUL_Red_P256(CRYPTO_Type *base, int z, int x) } -/******************************************************************************* -* Function Name: Cy_Crypto_Core_EC_P384_ShMulRed_Coeff -****************************************************************************//** -* -* Generate multiplier for shift-multiply multiplication reduction P384. -* Multiplier coeficient = (2^{128} + 2^{96} - 2^{32} + 1) -* Multiplier coefficient = 1 00000000 FFFFFFFF FFFFFFFF 00000000 -* -* \param base -* The pointer to a Crypto instance. -* -* \param coeff -* Coeffitient. -* -*******************************************************************************/ -void Cy_Crypto_Core_EC_P384_ShMulRed_Coeff(CRYPTO_Type *base, int coeff) -{ - - int sh = 0; - int t = 1; - int my_coeff = 2; - - CY_CRYPTO_VU_PUSH_REG (base); - - CY_CRYPTO_VU_LD_REG (base, my_coeff, coeff); - - CY_CRYPTO_VU_SET_REG (base, sh, 128, 1); /* sh = 128 */ - CY_CRYPTO_VU_ALLOC_MEM (base, t, 97); /* t [96 bits] */ - - CY_CRYPTO_VU_SET_TO_ONE (base, my_coeff); /* coeff = 1 */ - CY_CRYPTO_VU_LSL (base, my_coeff, my_coeff, sh); /* coeff = 1<<128 */ - - CY_CRYPTO_VU_SET_REG (base, sh, 32, 1); /* sh = 32 */ - CY_CRYPTO_VU_LSR (base, t, my_coeff, sh); /* t = 1<<96 */ - CY_CRYPTO_VU_ADD (base, my_coeff, my_coeff, t); /* coeff = 1<<128 + 1<<96 */ - - CY_CRYPTO_VU_SET_REG (base, sh, 64, 1); /* sh = 64 */ - CY_CRYPTO_VU_LSR (base, t, t, sh); /* t = 1<<32 */ - CY_CRYPTO_VU_SUB (base, my_coeff, my_coeff, t); /* coeff = 1<<128 + 1<<96 - 1<<32 */ - - CY_CRYPTO_VU_SET_REG (base, sh, 32, 1); /* sh = 32 */ - CY_CRYPTO_VU_LSR (base, t, t, sh); /* t = 1 */ - CY_CRYPTO_VU_ADD (base, my_coeff, my_coeff, t); /* coeff = 1<<128 + 1<<96 - 1<<32 + 1 */ - - CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t)); - CY_CRYPTO_VU_POP_REG (base); -} - - /******************************************************************************* * Function Name: Cy_Crypto_Core_EC_SM_MUL_Red_P384 ****************************************************************************//** @@ -1036,55 +936,62 @@ void Cy_Crypto_Core_EC_P384_ShMulRed_Coeff(CRYPTO_Type *base, int coeff) * * \param z * Result. -* +* * \param x * Product. * *******************************************************************************/ -void Cy_Crypto_Core_EC_SM_MUL_Red_P384(CRYPTO_Type *base, int z, int x) +static void Cy_Crypto_Core_EC_SM_MUL_Red_P384(CRYPTO_Type *base, uint32_t z, uint32_t x) { + /* Pre-computed coefficient for shift-multiply modular reduction for P384 */ + const uint8_t P384_ShMul_COEFF[] = { + 0x01u, 0x00u, 0x00u, 0x00u, 0xFFu, 0xFFu, 0xFFu, 0xFFu, + 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0x00u, 0x00u, 0x00u, 0x00u, + 0x01u + }; + /* Setup */ - int partial = 0; - int hi = 1; - int sh96 = 2; - int sh384 = 3; - int my_z = 4; - int my_x = 5; - int coeff = 6; + uint32_t partial = 0u; + uint32_t hi = 1u; + uint32_t sh96 = 2u; + uint32_t sh384 = 3u; + uint32_t my_z = 4u; + uint32_t my_x = 5u; + uint32_t coeff = 6u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, my_x, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, my_x, x); - CY_CRYPTO_VU_ALLOC_MEM (base, partial, CY_CRYPTO_ECC_P384_SIZE + 129u); - CY_CRYPTO_VU_ALLOC_MEM (base, hi, CY_CRYPTO_ECC_P384_SIZE + 96u); - CY_CRYPTO_VU_ALLOC_MEM (base, coeff, 129u); + CY_CRYPTO_VU_ALLOC_MEM (base, partial, CY_CRYPTO_ECC_P384_SIZE + 129u); + CY_CRYPTO_VU_ALLOC_MEM (base, hi, CY_CRYPTO_ECC_P384_SIZE + 96u); + CY_CRYPTO_VU_ALLOC_MEM (base, coeff, 129u); - CY_CRYPTO_VU_SET_REG (base, sh96, 96, 1u); - CY_CRYPTO_VU_SET_REG (base, sh384, 384, 1u); + CY_CRYPTO_VU_SET_REG (base, sh96, 96u, 1u); + CY_CRYPTO_VU_SET_REG (base, sh384, 384u, 1u); - Cy_Crypto_Core_Vu_SetMemValue (base, coeff, P384_ShMul_COEFF, 129u); + Cy_Crypto_Core_Vu_SetMemValue (base, coeff, P384_ShMul_COEFF, 129u); /* Step 2: 1st round of shift-multiply * (Separate hi and lo (LSR hi>>CURVE_SIZE), multiply hi*c and add hi*coeff + lo) * hi*coeff + lo */ - CY_CRYPTO_VU_LSR (base, hi, my_x, sh384); /* hi = prod >> CURVE_SIZE = prod[767:384] */ - CY_CRYPTO_VU_MOV (base, my_z, my_x); /* z == lo = prod[383:0] */ + CY_CRYPTO_VU_LSR (base, hi, my_x, sh384); /* hi = prod >> CURVE_SIZE = prod[767:384] */ + CY_CRYPTO_VU_MOV (base, my_z, my_x); /* z == lo = prod[383:0] */ - CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ - CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* partial = hi*coeff + lo */ + CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ + CY_CRYPTO_VU_ADD (base, partial, partial, my_z); /* partial = hi*coeff + lo */ /* Step 3: 2nd round of shift-multiply */ - CY_CRYPTO_VU_LSR (base, hi, partial, sh384); /* hi = partial>>CURVE_SIZE = partial[767:384] */ - CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[383:0] */ + CY_CRYPTO_VU_LSR (base, hi, partial, sh384); /* hi = partial>>CURVE_SIZE = partial[767:384] */ + CY_CRYPTO_VU_MOV (base, my_z, partial); /* z == lo = partial[383:0] */ - CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ - CY_CRYPTO_VU_ADD (base, my_z, partial, my_z); /* z = hi*coeff + lo */ + CY_CRYPTO_VU_UMUL (base, partial, hi, coeff); /* partial = hi*coeff */ + CY_CRYPTO_VU_ADD (base, my_z, partial, my_z); /* z = hi*coeff + lo */ /* Step 4: Final reduction (compare to P-384 and reduce if necessary, based on CARRY flag) */ - CY_CRYPTO_VU_CMP_SUB (base, my_z, VR_P); /* C = (z >= VR_P) */ + CY_CRYPTO_VU_CMP_SUB (base, my_z, VR_P); /* C = (z >= VR_P) */ CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(partial) | CY_CRYPTO_VU_REG_BIT(hi) | CY_CRYPTO_VU_REG_BIT(coeff)); @@ -1109,34 +1016,34 @@ void Cy_Crypto_Core_EC_SM_MUL_Red_P384(CRYPTO_Type *base, int z, int x) * * \param z * Result = x mod P = a*b mod P [521 bits]. -* +* * \param x * Product = a*b [2*521 bits]. * *******************************************************************************/ -void Cy_Crypto_Core_EC_SM_MUL_Red_P521(CRYPTO_Type *base, int z, int x) +static void Cy_Crypto_Core_EC_SM_MUL_Red_P521(CRYPTO_Type *base, uint32_t z, uint32_t x) { - int sh521 = 0; - int t0 = 1; - int my_z = 2; - int my_x = 3; + uint32_t sh521 = 0u; + uint32_t t0 = 1u; + uint32_t my_z = 2u; + uint32_t my_x = 3u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, my_x, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, my_x, x); - CY_CRYPTO_VU_ALLOC_MEM (base, t0, CY_CRYPTO_ECC_P521_SIZE); /* 521 */ + CY_CRYPTO_VU_ALLOC_MEM (base, t0, CY_CRYPTO_ECC_P521_SIZE); /* 521 */ - CY_CRYPTO_VU_SET_REG (base, sh521, 521, 1); /* sh521 = 521 */ + CY_CRYPTO_VU_SET_REG (base, sh521, 521u, 1u); /* sh521 = 521 */ - CY_CRYPTO_VU_LSR (base, my_z, my_x, sh521); /* z = T1 */ + CY_CRYPTO_VU_LSR (base, my_z, my_x, sh521); /* z = T1 */ - CY_CRYPTO_VU_ADD (base, my_z, my_z, my_x); /* z = T1 + T0 */ + CY_CRYPTO_VU_ADD (base, my_z, my_z, my_x); /* z = T1 + T0 */ /* T0 + T1 mod p */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (t2 >= VR_P) */ - CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* t2 = t2 - p, if C==1 (Carry is set) */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, my_z, VR_P); /* C = (t2 >= VR_P) */ + CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, my_z, my_z, VR_P); /* t2 = t2 - p, if C==1 (Carry is set) */ CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t0)); CY_CRYPTO_VU_POP_REG (base); @@ -1148,14 +1055,14 @@ void Cy_Crypto_Core_EC_SM_MUL_Red_P521(CRYPTO_Type *base, int z, int x) * Function Name: Cy_Crypto_Core_EC_SM_MulRed ****************************************************************************//** * -* +* * * \param base * The pointer to a Crypto instance. * * \param z * Result. -* +* * \param x * Product. * @@ -1163,7 +1070,7 @@ void Cy_Crypto_Core_EC_SM_MUL_Red_P521(CRYPTO_Type *base, int z, int x) * Size. * *******************************************************************************/ -void Cy_Crypto_Core_EC_SM_MulRed(CRYPTO_Type *base, int z, int x, int size) +static void Cy_Crypto_Core_EC_SM_MulRed(CRYPTO_Type *base, uint32_t z, uint32_t x, uint32_t size) { switch (eccMode) { case CY_CRYPTO_ECC_ECP_SECP192R1: @@ -1198,14 +1105,14 @@ void Cy_Crypto_Core_EC_SM_MulRed(CRYPTO_Type *base, int z, int x, int size) * * Curve-specific multiplication modular reduction for P224. * t[b-1:0] = z_double >> size -* t = t * VR_BARRETT -* t = t + ((z_double >> size) << size) - for leading '1' Barrett bit. -* t = t >> size -* t = t * mod - r2 (not reduced) -* u = z_double - t - r = r1 - r2 (not reduced) +* t = t * VR_BARRETT +* t = t + ((z_double >> size) << size) - for leading '1' Barrett bit. +* t = t >> size +* t = t * mod - r2 (not reduced) +* u = z_double - t - r = r1 - r2 (not reduced) * -* u = IF (u >= mod) u = u - mod - reduce r using mod -* u = IF (u >= mod) u = u - mod +* u = IF (u >= mod) u = u - mod - reduce r using mod +* u = IF (u >= mod) u = u - mod * * z = a_double % mod * @@ -1216,7 +1123,7 @@ void Cy_Crypto_Core_EC_SM_MulRed(CRYPTO_Type *base, int z, int x, int size) * * \param z * Register index for Barrett reduced value. -* +* * \param x * Register index for non reduced value. * @@ -1225,48 +1132,48 @@ void Cy_Crypto_Core_EC_SM_MulRed(CRYPTO_Type *base, int z, int x, int size) * *******************************************************************************/ void Cy_Crypto_Core_EC_Bar_MulRed(CRYPTO_Type *base, - int z, - int x, - int size) + uint32_t z, + uint32_t x, + uint32_t size) { - int sh = 0; - int t1 = 1; - int t1_plus2 = 1; - int t2_plus2 = 0; - int t_double = 2; - int z_double = 3; - int my_z = 4; + uint32_t sh = 0u; + uint32_t t1 = 1u; + uint32_t t1_plus2 = 1u; + uint32_t t2_plus2 = 0u; + uint32_t t_double = 2u; + uint32_t z_double = 3u; + uint32_t my_z = 4u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, my_z, z); - CY_CRYPTO_VU_LD_REG (base, z_double, x); + CY_CRYPTO_VU_LD_REG (base, my_z, z); + CY_CRYPTO_VU_LD_REG (base, z_double, x); - CY_CRYPTO_VU_ALLOC_MEM (base, t_double, 2u * size); - CY_CRYPTO_VU_ALLOC_MEM (base, t1, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t_double, 2u * size); + CY_CRYPTO_VU_ALLOC_MEM (base, t1, size); - CY_CRYPTO_VU_SET_REG (base, sh, size, 1u); /* sh = k (k \equiv size) */ - CY_CRYPTO_VU_LSR (base, my_z, z_double, sh); /* a/b^{k} (q1*b) */ + CY_CRYPTO_VU_SET_REG (base, sh, size, 1u); /* sh = k (k \equiv size) */ + CY_CRYPTO_VU_LSR (base, my_z, z_double, sh); /* a/b^{k} (q1*b) */ - CY_CRYPTO_VU_UMUL (base, t_double, my_z, VR_BARRETT); /* a/b^{k}*VR_BARRETT (q2*b) */ - CY_CRYPTO_VU_LSR (base, t1, t_double, sh); /* q2*b/b^{k} = q2/b^{k-1} */ + CY_CRYPTO_VU_UMUL (base, t_double, my_z, VR_BARRETT); /* a/b^{k}*VR_BARRETT (q2*b) */ + CY_CRYPTO_VU_LSR (base, t1, t_double, sh); /* q2*b/b^{k} = q2/b^{k-1} */ - CY_CRYPTO_VU_UMUL (base, t_double, t1, VR_P); + CY_CRYPTO_VU_UMUL (base, t_double, t1, VR_P); CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t1)); - CY_CRYPTO_VU_ALLOC_MEM (base, t1_plus2, size + 2u); - CY_CRYPTO_VU_ALLOC_MEM (base, t2_plus2, size + 2u); + CY_CRYPTO_VU_ALLOC_MEM (base, t1_plus2, size + 2u); + CY_CRYPTO_VU_ALLOC_MEM (base, t2_plus2, size + 2u); - CY_CRYPTO_VU_SUB (base, t2_plus2, z_double, t_double); + CY_CRYPTO_VU_SUB (base, t2_plus2, z_double, t_double); - CY_CRYPTO_VU_SUB (base, t1_plus2, t2_plus2, VR_P); - CY_CRYPTO_VU_COND_SWAP_REG (base, CY_CRYPTO_VU_COND_CC, t1_plus2, t2_plus2); + CY_CRYPTO_VU_SUB (base, t1_plus2, t2_plus2, VR_P); + CY_CRYPTO_VU_COND_SWAP_REG (base, CY_CRYPTO_VU_COND_CC, t1_plus2, t2_plus2); - CY_CRYPTO_VU_SUB (base, t2_plus2, t1_plus2, VR_P); - CY_CRYPTO_VU_COND_MOV (base, CY_CRYPTO_VU_COND_CC, my_z, t1_plus2); - CY_CRYPTO_VU_COND_MOV (base, CY_CRYPTO_VU_COND_CS, my_z, t2_plus2); + CY_CRYPTO_VU_SUB (base, t2_plus2, t1_plus2, VR_P); + CY_CRYPTO_VU_COND_MOV (base, CY_CRYPTO_VU_COND_CC, my_z, t1_plus2); + CY_CRYPTO_VU_COND_MOV (base, CY_CRYPTO_VU_COND_CS, my_z, t2_plus2); CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t2_plus2) | CY_CRYPTO_VU_REG_BIT(t1_plus2) | @@ -1291,7 +1198,7 @@ void Cy_Crypto_Core_EC_Bar_MulRed(CRYPTO_Type *base, * * \param z * Result = x mod P = a*b mod P [224 bits]. -* +* * \param x * Product = a*b [2*224 bits]. * @@ -1299,10 +1206,7 @@ void Cy_Crypto_Core_EC_Bar_MulRed(CRYPTO_Type *base, * Bit size. * *******************************************************************************/ -void Cy_Crypto_Core_EC_MulRed(CRYPTO_Type *base, - int z, - int x, - int size) +static void Cy_Crypto_Core_EC_MulRed(CRYPTO_Type *base, uint32_t z, uint32_t x, uint32_t size) { switch (mul_red_alg_select) { @@ -1334,7 +1238,7 @@ void Cy_Crypto_Core_EC_MulRed(CRYPTO_Type *base, * * \param z * Result = a * b % mod. Register index for product value. -* +* * \param a * Register index for multiplicand value. * @@ -1346,15 +1250,15 @@ void Cy_Crypto_Core_EC_MulRed(CRYPTO_Type *base, * *******************************************************************************/ void Cy_Crypto_Core_EC_MulMod( CRYPTO_Type *base, - int z, - int a, - int b, - int size) + uint32_t z, + uint32_t a, + uint32_t b, + uint32_t size) { - int ab_double = 0; - int my_z = 1; - int my_a = 2; - int my_b = 3; + uint32_t ab_double = 0u; + uint32_t my_z = 1u; + uint32_t my_a = 2u; + uint32_t my_b = 3u; CY_CRYPTO_VU_PUSH_REG (base); @@ -1362,12 +1266,12 @@ void Cy_Crypto_Core_EC_MulMod( CRYPTO_Type *base, CY_CRYPTO_VU_LD_REG(base, my_a, a); CY_CRYPTO_VU_LD_REG(base, my_b, b); - CY_CRYPTO_VU_ALLOC_MEM (base, ab_double, 2 * size); + CY_CRYPTO_VU_ALLOC_MEM (base, ab_double, 2u * size); - CY_CRYPTO_VU_UMUL (base, ab_double, my_a, my_b); + CY_CRYPTO_VU_UMUL (base, ab_double, my_a, my_b); /* Modular Reduction: Barrett reduction or curve-specific or shift-multiply */ - Cy_Crypto_Core_EC_MulRed(base, my_z, ab_double, size); + Cy_Crypto_Core_EC_MulRed(base, my_z, ab_double, size); CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(ab_double)); @@ -1387,7 +1291,7 @@ void Cy_Crypto_Core_EC_MulMod( CRYPTO_Type *base, * * \param z * Result = a + b % mod. Register index for sum value -* +* * \param a * Register index for augend a value. * @@ -1395,10 +1299,10 @@ void Cy_Crypto_Core_EC_MulMod( CRYPTO_Type *base, * Register index for addend b value. * *******************************************************************************/ -void Cy_Crypto_Core_EC_AddMod( CRYPTO_Type *base, int z, int a, int b) +void Cy_Crypto_Core_EC_AddMod( CRYPTO_Type *base, uint32_t z, uint32_t a, uint32_t b) { - CY_CRYPTO_VU_ADD (base, z, a, b); /* C = (sum >= 2^n) */ - CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, z, VR_P); /* C = (sum >= mod) */ + CY_CRYPTO_VU_ADD (base, z, a, b); /* C = (sum >= 2^n) */ + CY_CRYPTO_VU_COND_CMP_SUB (base, CY_CRYPTO_VU_COND_CC, z, VR_P); /* C = (sum >= mod) */ CY_CRYPTO_VU_COND_SUB (base, CY_CRYPTO_VU_COND_CS, z, z, VR_P); } @@ -1414,7 +1318,7 @@ void Cy_Crypto_Core_EC_AddMod( CRYPTO_Type *base, int z, int a, int b) * * \param z * Result = a - b % mod. Register index for difference value. -* +* * \param a * Register index for minuend a value. * @@ -1422,7 +1326,7 @@ void Cy_Crypto_Core_EC_AddMod( CRYPTO_Type *base, int z, int a, int b) * RRegister index for subtrahend b value. * *******************************************************************************/ -void Cy_Crypto_Core_EC_SubMod( CRYPTO_Type *base, int z, int a, int b) +void Cy_Crypto_Core_EC_SubMod( CRYPTO_Type *base, uint32_t z, uint32_t a, uint32_t b) { CY_CRYPTO_VU_SUB (base, z, a, b); /* C = (a >= b) */ CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_CC, z, z, VR_P); @@ -1442,12 +1346,12 @@ void Cy_Crypto_Core_EC_SubMod( CRYPTO_Type *base, int z, int a, int b) * * \param z * Result = a / 2 % mod.Register index for result value. -* +* * \param a * Register index for value to be halved. * *******************************************************************************/ -void Cy_Crypto_Core_EC_HalfMod( CRYPTO_Type *base, int z, int a) +void Cy_Crypto_Core_EC_HalfMod( CRYPTO_Type *base, uint32_t z, uint32_t a) { CY_CRYPTO_VU_TST (base, a); CY_CRYPTO_VU_COND_ADD (base, CY_CRYPTO_VU_COND_ODD, a, a, VR_P); @@ -1466,7 +1370,7 @@ void Cy_Crypto_Core_EC_HalfMod( CRYPTO_Type *base, int z, int a) * * \param z * Result = a * a % mod. Register index for product value. -* +* * \param a * Register index for multiplicand and multiplier value. * @@ -1475,9 +1379,9 @@ void Cy_Crypto_Core_EC_HalfMod( CRYPTO_Type *base, int z, int a) * *******************************************************************************/ void Cy_Crypto_Core_EC_SquareMod( CRYPTO_Type *base, - int z, - int a, - int size) + uint32_t z, + uint32_t a, + uint32_t size) { Cy_Crypto_Core_EC_MulMod( base, z, a, a, size); } @@ -1489,14 +1393,15 @@ void Cy_Crypto_Core_EC_SquareMod( CRYPTO_Type *base, * * Modular division in GF(VR_P). * This algorithm works when "dividend" and "divisor" are relatively prime, -* Reference: "From Euclid's GCD to Montgomery Multiplication to the Great Divide", S.C. Schantz +* Reference: "From Euclid's GCD to Montgomery Multiplication to the Great Divide", +* S.C. Schantz * * \param base * The pointer to a Crypto instance. * * \param z * Result = a / b % mod. Register index for quotient value. -* +* * \param a * Register index for dividend value. * @@ -1508,40 +1413,40 @@ void Cy_Crypto_Core_EC_SquareMod( CRYPTO_Type *base, * *******************************************************************************/ void Cy_Crypto_Core_EC_DivMod( CRYPTO_Type *base, - int z, - int a, - int b, - int size) + uint32_t z, + uint32_t a, + uint32_t b, + uint32_t size) { - int my_dividend = 7; - int my_divisor = 8; - int my_a = 9; - int my_b = 10; - int my_u = 11; - int my_v = 12; + uint32_t my_dividend = 7u; + uint32_t my_divisor = 8u; + uint32_t my_a = 9u; + uint32_t my_b = 10u; + uint32_t my_u = 11u; + uint32_t my_v = 12u; - uint16_t zero; - uint16_t carry; - uint16_t a_even; - uint16_t b_even; + uint32_t zero; + uint32_t carry; + uint32_t a_even; + uint32_t b_even; - volatile uint16_t status0; - volatile uint16_t status1; - volatile uint16_t status2; + uint32_t status0; + uint32_t status1; + uint32_t status2; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG(base, my_dividend, a); - CY_CRYPTO_VU_LD_REG(base, my_divisor, b); - CY_CRYPTO_VU_LD_REG(base, my_u, z); + CY_CRYPTO_VU_LD_REG(base, my_dividend, a); + CY_CRYPTO_VU_LD_REG(base, my_divisor, b); + CY_CRYPTO_VU_LD_REG(base, my_u, z); - CY_CRYPTO_VU_ALLOC_MEM (base, my_a, size); - CY_CRYPTO_VU_ALLOC_MEM (base, my_b, size); - CY_CRYPTO_VU_ALLOC_MEM (base, my_v, size); + CY_CRYPTO_VU_ALLOC_MEM (base, my_a, size); + CY_CRYPTO_VU_ALLOC_MEM (base, my_b, size); + CY_CRYPTO_VU_ALLOC_MEM (base, my_v, size); - CY_CRYPTO_VU_MOV (base, my_a, my_divisor); - CY_CRYPTO_VU_MOV (base, my_b, VR_P); - CY_CRYPTO_VU_MOV (base, my_u, my_dividend); + CY_CRYPTO_VU_MOV (base, my_a, my_divisor); + CY_CRYPTO_VU_MOV (base, my_b, VR_P); + CY_CRYPTO_VU_MOV (base, my_u, my_dividend); CY_CRYPTO_VU_SET_TO_ZERO (base, my_v); @@ -1558,41 +1463,41 @@ void Cy_Crypto_Core_EC_DivMod( CRYPTO_Type *base, Cy_Crypto_Core_WaitForReady(base); - zero = status0 & (1 << CY_CRYPTO_VU_STATUS_ZERO); /* a == b */ - carry = status0 & (1 << CY_CRYPTO_VU_STATUS_CARRY); /* a >= b */ - a_even = status1 & (1 << CY_CRYPTO_VU_STATUS_EVEN); - b_even = status2 & (1 << CY_CRYPTO_VU_STATUS_EVEN); + zero = status0 & CY_CRYPTO_VU_STATUS_ZERO_BIT; /* a == b */ + carry = status0 & CY_CRYPTO_VU_STATUS_CARRY_BIT; /* a >= b */ + a_even = status1 & CY_CRYPTO_VU_STATUS_EVEN_BIT; + b_even = status2 & CY_CRYPTO_VU_STATUS_EVEN_BIT; - if (zero) + if (0u != zero) { break; } - if (a_even) + if (0u != a_even) { - CY_CRYPTO_VU_LSR1 (base, my_a, my_a); - Cy_Crypto_Core_EC_HalfMod( base, my_u, my_u); + CY_CRYPTO_VU_LSR1 (base, my_a, my_a); + Cy_Crypto_Core_EC_HalfMod( base, my_u, my_u); } - else if (b_even) + else if (0u != b_even) { - CY_CRYPTO_VU_LSR1 (base, my_b, my_b); - Cy_Crypto_Core_EC_HalfMod( base, my_v, my_v); + CY_CRYPTO_VU_LSR1 (base, my_b, my_b); + Cy_Crypto_Core_EC_HalfMod( base, my_v, my_v); } - else if (carry) + else if (0u != carry) { /* (a >= b) */ - CY_CRYPTO_VU_SUB (base, my_a, my_a, my_b); - CY_CRYPTO_VU_LSR1 (base, my_a, my_a); + CY_CRYPTO_VU_SUB (base, my_a, my_a, my_b); + CY_CRYPTO_VU_LSR1 (base, my_a, my_a); - Cy_Crypto_Core_EC_SubMod( base, my_u, my_u, my_v); - Cy_Crypto_Core_EC_HalfMod( base, my_u, my_u); + Cy_Crypto_Core_EC_SubMod( base, my_u, my_u, my_v); + Cy_Crypto_Core_EC_HalfMod( base, my_u, my_u); } else { - CY_CRYPTO_VU_SUB (base, my_b, my_b, my_a); - CY_CRYPTO_VU_LSR1 (base, my_b, my_b); + CY_CRYPTO_VU_SUB (base, my_b, my_b, my_a); + CY_CRYPTO_VU_LSR1 (base, my_b, my_b); - Cy_Crypto_Core_EC_SubMod( base, my_v, my_v, my_u); - Cy_Crypto_Core_EC_HalfMod( base, my_v, my_v); + Cy_Crypto_Core_EC_SubMod( base, my_v, my_v, my_u); + Cy_Crypto_Core_EC_HalfMod( base, my_v, my_v); } } @@ -1613,7 +1518,7 @@ void Cy_Crypto_Core_EC_DivMod( CRYPTO_Type *base, * * \param s_x * Register index for affine X coordinate and Jacobian projective X coordinate. -* +* * \param s_y * Register index for affine Y coordinate and Jacobian projective Y coordinate. * @@ -1621,12 +1526,8 @@ void Cy_Crypto_Core_EC_DivMod( CRYPTO_Type *base, * Register index for Jacobian projective Z coordinate. * *******************************************************************************/ -void Cy_Crypto_Core_JacobianTransform(CRYPTO_Type *base, - int s_x, - int s_y, - int s_z) +void Cy_Crypto_Core_JacobianTransform(CRYPTO_Type *base, uint32_t s_x, uint32_t s_y, uint32_t s_z) { - CY_CRYPTO_VU_SET_TO_ONE (base, s_z); } @@ -1643,7 +1544,7 @@ void Cy_Crypto_Core_JacobianTransform(CRYPTO_Type *base, * * \param s_x * Register index for affine X coordinate and Jacobian projective X coordinate. -* +* * \param s_y * Register index for affine Y coordinate and Jacobian projective Y coordinate. * @@ -1654,38 +1555,34 @@ void Cy_Crypto_Core_JacobianTransform(CRYPTO_Type *base, * Bit size. * *******************************************************************************/ -void Cy_Crypto_Core_JacobianInvTransform(CRYPTO_Type *base, - int s_x, - int s_y, - int s_z, - int size) +void Cy_Crypto_Core_JacobianInvTransform(CRYPTO_Type *base, uint32_t s_x, uint32_t s_y, uint32_t s_z, uint32_t size) { - int t1 = 7; - int t2 = 8; - int t3 = 9; - int my_s_x = 10; - int my_s_y = 11; - int my_s_z = 12; + uint32_t t1 = 7u; + uint32_t t2 = 8u; + uint32_t t3 = 9u; + uint32_t my_s_x = 10u; + uint32_t my_s_y = 11u; + uint32_t my_s_z = 12u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG(base, my_s_x, s_x); - CY_CRYPTO_VU_LD_REG(base, my_s_y, s_y); - CY_CRYPTO_VU_LD_REG(base, my_s_z, s_z); + CY_CRYPTO_VU_LD_REG(base, my_s_x, s_x); + CY_CRYPTO_VU_LD_REG(base, my_s_y, s_y); + CY_CRYPTO_VU_LD_REG(base, my_s_z, s_z); - CY_CRYPTO_VU_ALLOC_MEM (base, t1, size); - CY_CRYPTO_VU_ALLOC_MEM (base, t2, size); - CY_CRYPTO_VU_ALLOC_MEM (base, t3, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t1, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t2, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t3, size); - CY_CRYPTO_VU_SET_TO_ONE (base, t1); /* t1 = 1 */ - Cy_Crypto_Core_EC_DivMod( base, t2, t1, my_s_z, size); /* t2 = 1/Z */ + CY_CRYPTO_VU_SET_TO_ONE (base, t1); /* t1 = 1 */ + Cy_Crypto_Core_EC_DivMod( base, t2, t1, my_s_z, size); /* t2 = 1/Z */ - Cy_Crypto_Core_EC_SquareMod( base, t1, t2, size); /* t1 = 1/Z^2 */ - Cy_Crypto_Core_EC_MulMod( base, my_s_x, my_s_x, t1, size); /* my_s_x = X/Z^2 */ + Cy_Crypto_Core_EC_SquareMod( base, t1, t2, size); /* t1 = 1/Z^2 */ + Cy_Crypto_Core_EC_MulMod( base, my_s_x, my_s_x, t1, size); /* my_s_x = X/Z^2 */ - Cy_Crypto_Core_EC_MulMod( base, t3, my_s_y, t1, size); /* t3 = Y/Z^2 */ - Cy_Crypto_Core_EC_MulMod( base, my_s_y, t3, t2, size); /* my_s_y = Y/Z^3 */ + Cy_Crypto_Core_EC_MulMod( base, t3, my_s_y, t1, size); /* t3 = Y/Z^2 */ + Cy_Crypto_Core_EC_MulMod( base, my_s_y, t3, t2, size); /* my_s_y = Y/Z^3 */ CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t1) | CY_CRYPTO_VU_REG_BIT(t2) | CY_CRYPTO_VU_REG_BIT(t3)); @@ -1694,7 +1591,7 @@ void Cy_Crypto_Core_JacobianInvTransform(CRYPTO_Type *base, /******************************************************************************* -* Function Name: Cy_Crypto_Core_JacobianInvTransform +* Function Name: Cy_Crypto_Core_JacobianEcAdd ****************************************************************************//** * * Elliptic curve point addition on mixed Jacobian projective (s) / affine (t) coordinates in GF(VR_P). @@ -1707,7 +1604,7 @@ void Cy_Crypto_Core_JacobianInvTransform(CRYPTO_Type *base, * * \param s_x * Register index for Jacobian projective X coordinate. -* +* * \param s_y * Register index for Jacobian projective Y coordinate. * @@ -1716,7 +1613,7 @@ void Cy_Crypto_Core_JacobianInvTransform(CRYPTO_Type *base, * * \param t_x * Register index for affine X coordinate. -* +* * \param t_y * Register index for affine Y coordinate. * @@ -1725,58 +1622,58 @@ void Cy_Crypto_Core_JacobianInvTransform(CRYPTO_Type *base, * *******************************************************************************/ void Cy_Crypto_Core_JacobianEcAdd(CRYPTO_Type *base, - int s_x, - int s_y, - int s_z, - int t_x, - int t_y, - int size + uint32_t s_x, + uint32_t s_y, + uint32_t s_z, + uint32_t t_x, + uint32_t t_y, + uint32_t size ) { - int t6 = 4; - int t7 = 5; - int t8 = 6; - int t9 = 7; - int my_s_x = 8; - int my_s_y = 9; - int my_s_z = 10; - int my_t_x = 11; - int my_t_y = 12; + uint32_t t6 = 4u; + uint32_t t7 = 5u; + uint32_t t8 = 6u; + uint32_t t9 = 7u; + uint32_t my_s_x = 8u; + uint32_t my_s_y = 9u; + uint32_t my_s_z = 10u; + uint32_t my_t_x = 11u; + uint32_t my_t_y = 12u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG(base, my_s_x, s_x); - CY_CRYPTO_VU_LD_REG(base, my_s_y, s_y); - CY_CRYPTO_VU_LD_REG(base, my_s_z, s_z); - CY_CRYPTO_VU_LD_REG(base, my_t_x, t_x); - CY_CRYPTO_VU_LD_REG(base, my_t_y, t_y); + CY_CRYPTO_VU_LD_REG(base, my_s_x, s_x); + CY_CRYPTO_VU_LD_REG(base, my_s_y, s_y); + CY_CRYPTO_VU_LD_REG(base, my_s_z, s_z); + CY_CRYPTO_VU_LD_REG(base, my_t_x, t_x); + CY_CRYPTO_VU_LD_REG(base, my_t_y, t_y); - CY_CRYPTO_VU_ALLOC_MEM (base, t6, size); - CY_CRYPTO_VU_ALLOC_MEM (base, t7, size); - CY_CRYPTO_VU_ALLOC_MEM (base, t8, size); - CY_CRYPTO_VU_ALLOC_MEM (base, t9, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t6, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t7, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t8, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t9, size); - Cy_Crypto_Core_EC_SquareMod( base, t6, my_s_z, size); /* t6 = ZZ */ - Cy_Crypto_Core_EC_MulMod( base, t8, my_t_x, t6, size); /* t8 = xZZ = B */ - Cy_Crypto_Core_EC_MulMod( base, t7, my_t_y, my_s_z, size); /* t7 = yZ */ - Cy_Crypto_Core_EC_SubMod( base, my_s_x, my_s_x, t8); /* my_s_x = X - B = E */ + Cy_Crypto_Core_EC_SquareMod( base, t6, my_s_z, size); /* t6 = ZZ */ + Cy_Crypto_Core_EC_MulMod( base, t8, my_t_x, t6, size); /* t8 = xZZ = B */ + Cy_Crypto_Core_EC_MulMod( base, t7, my_t_y, my_s_z, size); /* t7 = yZ */ + Cy_Crypto_Core_EC_SubMod( base, my_s_x, my_s_x, t8); /* my_s_x = X - B = E */ - Cy_Crypto_Core_EC_MulMod( base, my_s_z, my_s_x, my_s_z, size); /* my_s_z = E*Z = Z3 */ - Cy_Crypto_Core_EC_MulMod( base, t9, t7, t6, size); /* t9 = yZZZ = D */ - Cy_Crypto_Core_EC_SubMod( base, my_s_y, my_s_y, t9); /* my_s_y = Y - D = F */ - Cy_Crypto_Core_EC_SquareMod( base, t6, my_s_x, size); /* t6 = EE */ + Cy_Crypto_Core_EC_MulMod( base, my_s_z, my_s_x, my_s_z, size); /* my_s_z = E*Z = Z3 */ + Cy_Crypto_Core_EC_MulMod( base, t9, t7, t6, size); /* t9 = yZZZ = D */ + Cy_Crypto_Core_EC_SubMod( base, my_s_y, my_s_y, t9); /* my_s_y = Y - D = F */ + Cy_Crypto_Core_EC_SquareMod( base, t6, my_s_x, size); /* t6 = EE */ - Cy_Crypto_Core_EC_MulMod( base, t7, t8, t6, size); /* t7 = B*EE */ - Cy_Crypto_Core_EC_MulMod( base, t8, t6, my_s_x, size); /* t8 = EEE */ - Cy_Crypto_Core_EC_MulMod( base, t6, t9, t8, size); /* t6 = D*EEE */ - Cy_Crypto_Core_EC_SquareMod( base, my_s_x, my_s_y, size); /* my_s_x = FF */ - Cy_Crypto_Core_EC_SubMod( base, my_s_x, my_s_x, t8); /* my_s_x = FF - EEE */ - Cy_Crypto_Core_EC_AddMod( base, t9, t7, t7); /* t9 = 2*B*EE */ - Cy_Crypto_Core_EC_SubMod( base, my_s_x, my_s_x, t9); /* my_s_x = FF - EEE - 2*B*EE = X3 */ - Cy_Crypto_Core_EC_SubMod( base, t7, t7, my_s_x); /* t7 = B*EE - X3 */ - Cy_Crypto_Core_EC_MulMod( base, my_s_y, my_s_y, t7, size); /* my_s_y = F*(B*EE - X3) */ - Cy_Crypto_Core_EC_SubMod( base, my_s_y, my_s_y, t6); /* my_s_y = F*(3*B*EE - FF + EEE) - D*EEE = Y3 */ + Cy_Crypto_Core_EC_MulMod( base, t7, t8, t6, size); /* t7 = B*EE */ + Cy_Crypto_Core_EC_MulMod( base, t8, t6, my_s_x, size); /* t8 = EEE */ + Cy_Crypto_Core_EC_MulMod( base, t6, t9, t8, size); /* t6 = D*EEE */ + Cy_Crypto_Core_EC_SquareMod( base, my_s_x, my_s_y, size); /* my_s_x = FF */ + Cy_Crypto_Core_EC_SubMod( base, my_s_x, my_s_x, t8); /* my_s_x = FF - EEE */ + Cy_Crypto_Core_EC_AddMod( base, t9, t7, t7); /* t9 = 2*B*EE */ + Cy_Crypto_Core_EC_SubMod( base, my_s_x, my_s_x, t9); /* my_s_x = FF - EEE - 2*B*EE = X3 */ + Cy_Crypto_Core_EC_SubMod( base, t7, t7, my_s_x); /* t7 = B*EE - X3 */ + Cy_Crypto_Core_EC_MulMod( base, my_s_y, my_s_y, t7, size); /* my_s_y = F*(B*EE - X3) */ + Cy_Crypto_Core_EC_SubMod( base, my_s_y, my_s_y, t6); /* my_s_y = F*(3*B*EE - FF + EEE) - D*EEE = Y3 */ CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t6) | CY_CRYPTO_VU_REG_BIT(t7) | CY_CRYPTO_VU_REG_BIT(t8) | CY_CRYPTO_VU_REG_BIT(t9)); @@ -1796,7 +1693,7 @@ void Cy_Crypto_Core_JacobianEcAdd(CRYPTO_Type *base, * * \param s_x * Register index for Jacobian projective X coordinate. -* +* * \param s_y * Register index for Jacobian projective Y coordinate. * @@ -1808,80 +1705,58 @@ void Cy_Crypto_Core_JacobianEcAdd(CRYPTO_Type *base, * *******************************************************************************/ void Cy_Crypto_Core_JacobianEcDouble(CRYPTO_Type *base, - int s_x, - int s_y, - int s_z, - int size + uint32_t s_x, + uint32_t s_y, + uint32_t s_z, + uint32_t size ) /* 4M + 4S + 10A */ { - - int t1 = 1; - int t2 = 2; - int t3 = 3; - int t4 = 4; - int my_s_x = 5; - int my_s_y = 6; - int my_s_z = 7; + uint32_t t1 = 1u; + uint32_t t2 = 2u; + uint32_t t3 = 3u; + uint32_t t4 = 4u; + uint32_t my_s_x = 5u; + uint32_t my_s_y = 6u; + uint32_t my_s_z = 7u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG(base, my_s_x, s_x); - CY_CRYPTO_VU_LD_REG(base, my_s_y, s_y); - CY_CRYPTO_VU_LD_REG(base, my_s_z, s_z); + CY_CRYPTO_VU_LD_REG(base, my_s_x, s_x); + CY_CRYPTO_VU_LD_REG(base, my_s_y, s_y); + CY_CRYPTO_VU_LD_REG(base, my_s_z, s_z); - CY_CRYPTO_VU_ALLOC_MEM (base, t1, size); - CY_CRYPTO_VU_ALLOC_MEM (base, t2, size); - CY_CRYPTO_VU_ALLOC_MEM (base, t3, size); - CY_CRYPTO_VU_ALLOC_MEM (base, t4, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t1, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t2, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t3, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t4, size); - Cy_Crypto_Core_EC_SquareMod( base, t4, my_s_y, size); /* t4 = Y^2 */ + Cy_Crypto_Core_EC_SquareMod( base, t4, my_s_y, size); /* t4 = Y^2 */ + Cy_Crypto_Core_EC_SquareMod( base, t3, my_s_z, size); /* t3 = Z^2 */ + Cy_Crypto_Core_EC_MulMod( base, my_s_z, my_s_y, my_s_z, size); /* my_s_z = Y*Z */ - Cy_Crypto_Core_EC_SquareMod( base, t3, my_s_z, size); /* t3 = Z^2 */ + Cy_Crypto_Core_EC_MulMod( base, my_s_y, my_s_x, t4, size); /* my_s_y = X*Y^2 = A */ + Cy_Crypto_Core_EC_AddMod( base, my_s_x, my_s_x, t3); /* my_s_x = X + Z^2 */ + Cy_Crypto_Core_EC_AddMod( base, t3, t3, t3); /* t3 = 2*Z^2 */ + Cy_Crypto_Core_EC_SubMod( base, t3, my_s_x, t3); /* t3 = (X + Z^2) - 2*Z^2 = X - Z^2 */ + Cy_Crypto_Core_EC_MulMod( base, t1, my_s_x, t3, size); /* t1 = (X + Z^2) * (X - Z^2) = X^2 - Z^4 */ - Cy_Crypto_Core_EC_MulMod( base, my_s_z, my_s_y, my_s_z, size); /* my_s_z = Y*Z */ + Cy_Crypto_Core_EC_AddMod( base, t3, t1, t1); /* t3 = 2*(X^2 - Z^4) */ + Cy_Crypto_Core_EC_AddMod( base, t1, t1, t3); /* t1 = 3*(X^2 - Z^4) */ + Cy_Crypto_Core_EC_HalfMod( base, t1, t1); /* t1 = 3/2*(X^2 - Z^4) = B */ + Cy_Crypto_Core_EC_SquareMod( base, t3, t1, size); /* t3 = 9/4*(X^2 - Z^4) = B^2 */ + Cy_Crypto_Core_EC_SubMod( base, t3, t3, my_s_y); /* t3 = B^2 - A */ + Cy_Crypto_Core_EC_SubMod( base, my_s_x, t3, my_s_y); /* my_s_x = B^2 - 2*A */ + Cy_Crypto_Core_EC_SubMod( base, my_s_y, my_s_y, my_s_x); /* my_s_y = A - (B^2 - 2*A) = 3*A - B^2 */ + Cy_Crypto_Core_EC_MulMod( base, t2, t1, my_s_y, size); /* t2 = B*(3*A - B^2) */ - Cy_Crypto_Core_EC_MulMod( base, my_s_y, my_s_x, t4, size); /* my_s_y = X*Y^2 = A */ - - Cy_Crypto_Core_EC_AddMod( base, my_s_x, my_s_x, t3); /* my_s_x = X + Z^2 */ - - Cy_Crypto_Core_EC_AddMod( base, t3, t3, t3); /* t3 = 2*Z^2 */ - - Cy_Crypto_Core_EC_SubMod( base, t3, my_s_x, t3); /* t3 = (X + Z^2) - 2*Z^2 = X - Z^2 */ - - Cy_Crypto_Core_EC_MulMod( base, t1, my_s_x, t3, size); /* t1 = (X + Z^2) * (X - Z^2) = X^2 - Z^4 */ - - - Cy_Crypto_Core_EC_AddMod( base, t3, t1, t1); /* t3 = 2*(X^2 - Z^4) */ - - Cy_Crypto_Core_EC_AddMod( base, t1, t1, t3); /* t1 = 3*(X^2 - Z^4) */ - - Cy_Crypto_Core_EC_HalfMod( base, t1, t1); /* t1 = 3/2*(X^2 - Z^4) = B */ - - Cy_Crypto_Core_EC_SquareMod( base, t3, t1, size); /* t3 = 9/4*(X^2 - Z^4) = B^2 */ - - - Cy_Crypto_Core_EC_SubMod( base, t3, t3, my_s_y); /* t3 = B^2 - A */ - - Cy_Crypto_Core_EC_SubMod( base, my_s_x, t3, my_s_y); /* my_s_x = B^2 - 2*A */ - - Cy_Crypto_Core_EC_SubMod( base, my_s_y, my_s_y, my_s_x); /* my_s_y = A - (B^2 - 2*A) = 3*A - B^2 */ - - Cy_Crypto_Core_EC_MulMod( base, t2, t1, my_s_y, size); /* t2 = B*(3*A - B^2) */ - - - Cy_Crypto_Core_EC_SquareMod( base, t1, t4, size); /* t1 = Y^4 */ - - Cy_Crypto_Core_EC_SubMod( base, my_s_y, t2, t1); /* my_s_y = B*(3*A - B^2) - Y^4 */ - + Cy_Crypto_Core_EC_SquareMod( base, t1, t4, size); /* t1 = Y^4 */ + Cy_Crypto_Core_EC_SubMod( base, my_s_y, t2, t1); /* my_s_y = B*(3*A - B^2) - Y^4 */ CY_CRYPTO_VU_FREE_MEM (base, CY_CRYPTO_VU_REG_BIT(t1) | CY_CRYPTO_VU_REG_BIT(t2) | CY_CRYPTO_VU_REG_BIT(t3) | CY_CRYPTO_VU_REG_BIT(t4)); - CY_CRYPTO_VU_POP_REG (base); - - } @@ -1896,7 +1771,7 @@ void Cy_Crypto_Core_JacobianEcDouble(CRYPTO_Type *base, * * \param s_x * Register index for affine X coordinate. -* +* * \param s_y * Register index for affine Y coordinate. * @@ -1907,46 +1782,41 @@ void Cy_Crypto_Core_JacobianEcDouble(CRYPTO_Type *base, * Bit size. * *******************************************************************************/ -void Cy_Crypto_Core_JacobianEcScalarMul(CRYPTO_Type *base, - int s_x, - int s_y, - int d, - int size -) +void Cy_Crypto_Core_JacobianEcScalarMul(CRYPTO_Type *base, uint32_t s_x, uint32_t s_y, uint32_t d, uint32_t size) { - - int i; - uint16_t status; - uint16_t carry; + uint32_t i; + uint32_t status; + uint32_t carry; uint16_t clsame; - int clr = 5; - int t = 6; - int my_s_x = 7; - int my_s_y = 8; - int my_s_z = 9; - int my_t_x = 10; - int my_t_y = 11; - int my_d = 12; + uint32_t clr = 5u; + uint32_t t = 6u; + uint32_t my_s_x = 7u; + uint32_t my_s_y = 8u; + uint32_t my_s_z = 9u; + uint32_t my_t_x = 10u; + uint32_t my_t_y = 11u; + uint32_t my_d = 12u; CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG(base, my_s_x, s_x); - CY_CRYPTO_VU_LD_REG(base, my_s_y, s_y); - CY_CRYPTO_VU_LD_REG(base, my_d, d); + CY_CRYPTO_VU_LD_REG(base, my_s_x, s_x); + CY_CRYPTO_VU_LD_REG(base, my_s_y, s_y); + CY_CRYPTO_VU_LD_REG(base, my_d, d); - CY_CRYPTO_VU_ALLOC_MEM (base, clr, size); - CY_CRYPTO_VU_ALLOC_MEM (base, t, size); - CY_CRYPTO_VU_ALLOC_MEM (base, my_s_z, size); - CY_CRYPTO_VU_ALLOC_MEM (base, my_t_x, size); - CY_CRYPTO_VU_ALLOC_MEM (base, my_t_y, size); + CY_CRYPTO_VU_ALLOC_MEM (base, clr, size); + CY_CRYPTO_VU_ALLOC_MEM (base, t, size); + CY_CRYPTO_VU_ALLOC_MEM (base, my_s_z, size); + CY_CRYPTO_VU_ALLOC_MEM (base, my_t_x, size); + CY_CRYPTO_VU_ALLOC_MEM (base, my_t_y, size); /* my_t_x has the same initial value of my_s_x, but does not point to the * same address in memory as my_s_x, i.e. different value after point doubling - * my_t_x and my_t_y do not change from (original Jacobian projective coordinates of) original base point + * my_t_x and my_t_y do not change from (original Jacobian projective coordinates of) + * original base point */ - CY_CRYPTO_VU_MOV (base, my_t_x, my_s_x); - CY_CRYPTO_VU_MOV (base, my_t_y, my_s_y); + CY_CRYPTO_VU_MOV (base, my_t_x, my_s_x); + CY_CRYPTO_VU_MOV (base, my_t_y, my_s_y); /* Affine-to-Jacobian Transform. */ CY_CRYPTO_VU_SET_TO_ONE (base, my_s_z); @@ -1964,12 +1834,16 @@ void Cy_Crypto_Core_JacobianEcScalarMul(CRYPTO_Type *base, /* Binary left-to-right algorithm * Perform point addition and point doubling to implement scalar multiplication - * Scan the bits of the scalar from left to right; perform point doubling for each bit, and perform point addition when the bit is set. - * Carry set if current bit is equal to 1 (hence, perform point addition - point doubling is always performed) + * Scan the bits of the scalar from left to right; perform point doubling for each bit, + * and perform point addition when the bit is set. + * Carry set if current bit is equal to 1 (hence, perform point addition - point + * doubling is always performed) */ - for (i = 0; i < (size - clsame - 1); i++) + for (i = 0u; i < (size - clsame - 1u); i++) { - /* Carry set if current bit is equal to 1 (hence, perform point addition - point doubling is always performed) */ + /* Carry set if current bit is equal to 1 (hence, perform point addition - point + * doubling is always performed) + */ CY_CRYPTO_VU_LSL1 (base, my_d, my_d); status = Cy_Crypto_Core_Vu_StatusRead(base); @@ -1977,11 +1851,10 @@ void Cy_Crypto_Core_JacobianEcScalarMul(CRYPTO_Type *base, Cy_Crypto_Core_JacobianEcDouble (base, my_s_x, my_s_y, my_s_z, size); - if (carry) + if (carry != 0U) { Cy_Crypto_Core_JacobianEcAdd (base, my_s_x, my_s_y, my_s_z, my_t_x, my_t_y, size); } - } /* Inverse transform */ @@ -2009,7 +1882,7 @@ void Cy_Crypto_Core_JacobianEcScalarMul(CRYPTO_Type *base, * bitsize of the used NIST P curve. * *******************************************************************************/ -void Cy_Crypto_Core_EC_NistP_SetMode(int bitsize) +void Cy_Crypto_Core_EC_NistP_SetMode(uint32_t bitsize) { switch (bitsize) { @@ -2042,7 +1915,8 @@ void Cy_Crypto_Core_EC_NistP_SetMode(int bitsize) * Select which reduction algorithm has to be used. * * \param alg -* one of {CURVE_SPECIFIC_RED_ALG, SHIFT_MUL_RED_ALG, BARRETT_RED_ALG}. See \ref cy_en_crypto_ecc_red_mul_algs_t. +* one of {CURVE_SPECIFIC_RED_ALG, SHIFT_MUL_RED_ALG, BARRETT_RED_ALG}. +* See \ref cy_en_crypto_ecc_red_mul_algs_t. * *******************************************************************************/ void Cy_Crypto_Core_EC_NistP_SetRedAlg(cy_en_crypto_ecc_red_mul_algs_t alg) @@ -2062,13 +1936,13 @@ void Cy_Crypto_Core_EC_NistP_SetRedAlg(cy_en_crypto_ecc_red_mul_algs_t alg) * * \param p_x * Register index for affine X coordinate of base point. -* +* * \param p_y * Register index for affine Y coordinate of base point. * * \param p_d * Register index for multiplication value. -* +* * \param p_order * Register index for order value.. * @@ -2076,14 +1950,13 @@ void Cy_Crypto_Core_EC_NistP_SetRedAlg(cy_en_crypto_ecc_red_mul_algs_t alg) * Bit size of the used curve. * *******************************************************************************/ -void Cy_Crypto_Core_EC_NistP_PointMul(CRYPTO_Type *base, int p_x, int p_y, int p_d, int p_order, int bitsize) +void Cy_Crypto_Core_EC_NistP_PointMul(CRYPTO_Type *base, uint32_t p_x, uint32_t p_y, uint32_t p_d, uint32_t p_order, uint32_t bitsize) { Cy_Crypto_Core_JacobianEcScalarMul (base, p_x, p_y, p_d, bitsize); Cy_Crypto_Core_Vu_WaitForComplete(base); } - /******************************************************************************* * Function Name: Cy_Crypto_Core_EC_NistP_PointMultiplication ****************************************************************************//** @@ -2095,13 +1968,13 @@ void Cy_Crypto_Core_EC_NistP_PointMul(CRYPTO_Type *base, int p_x, int p_y, int p * * \param curveID * Register index for affine X coordinate of base point. -* +* * \param ecpGX * Register index for affine Y coordinate of base point. * * \param ecpGY * Register index for multiplication value. -* +* * \param ecpD * Register index for order value. * @@ -2116,37 +1989,39 @@ void Cy_Crypto_Core_EC_NistP_PointMul(CRYPTO_Type *base, int p_x, int p_y, int p *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_EC_NistP_PointMultiplication(CRYPTO_Type *base, cy_en_crypto_ecc_curve_id_t curveID, - uint8_t* ecpGX, - uint8_t* ecpGY, - uint8_t* ecpD, - uint8_t* ecpQX, - uint8_t* ecpQY) + const uint8_t *ecpGX, + const uint8_t *ecpGY, + const uint8_t *ecpD, + uint8_t *ecpQX, + uint8_t *ecpQY) { /* N.b. If using test vectors from "http://point-at-infinity.org/ecc/nisttv", - * the 'k' values on the website are in decimal form, while the (x,y) result coordinates are in hexadecimal form - * Input format for 'd' scalar multiplier in this test is in hexademical form. - * Hence, convert k_{dec} to d_{hex} for comparison of test values - */ + * the 'k' values on the website are in decimal form, while the (x,y) result + * coordinates are in hexadecimal form + * Input format for 'd' scalar multiplier in this test is in hexadecimal form. + * Hence, convert k_{dec} to d_{hex} for comparison of test values + */ + /* Setup additional registers */ - int VR_ORDER = 9; + uint32_t VR_ORDER = 9u; const uint8_t *p_polynomial = NULL; const uint8_t *p_barrett = NULL; - cy_stc_crypto_ecc_dp_type *eccDp = Cy_Crypto_Core_ECC_GetCurveParams(curveID); + cy_stc_crypto_ecc_dp_type *eccDp = Cy_Crypto_Core_ECC_GetCurveParams(curveID); cy_en_crypto_status_t myStatus = CY_CRYPTO_NOT_SUPPORTED; if (eccDp != NULL) { /* Setup curve specific parameters depending on mode */ - uint32_t size; + uint32_t bitsize; p_polynomial = eccDp->prime; p_barrett = eccDp->barrett_p; - size = eccDp->size; + bitsize = eccDp->size; - /* use barrett reduction algorithm for operations modulo n (order of the base point) */ + /* use Barrett reduction algorithm for operations modulo n (order of the base point) */ Cy_Crypto_Core_EC_NistP_SetRedAlg(eccDp->algo); Cy_Crypto_Core_EC_NistP_SetMode(eccDp->size); @@ -2155,28 +2030,28 @@ cy_en_crypto_status_t Cy_Crypto_Core_EC_NistP_PointMultiplication(CRYPTO_Type *b if ((NULL != ecpGX) && (NULL != ecpGY) && (NULL != ecpD) && (NULL != ecpQX) && (NULL != ecpQY)) { /* Public parameters and characteristics of elliptic curve */ - CY_CRYPTO_VU_ALLOC_MEM (base, VR_D, size); /* Scalar factor */ - CY_CRYPTO_VU_ALLOC_MEM (base, VR_S_X, size); - CY_CRYPTO_VU_ALLOC_MEM (base, VR_S_Y, size); - CY_CRYPTO_VU_ALLOC_MEM (base, VR_P, size); - CY_CRYPTO_VU_ALLOC_MEM (base, VR_BARRETT, size + 1u); - CY_CRYPTO_VU_ALLOC_MEM (base, VR_ORDER, size); + CY_CRYPTO_VU_ALLOC_MEM (base, VR_D, bitsize); /* Scalar factor */ + CY_CRYPTO_VU_ALLOC_MEM (base, VR_S_X, bitsize); + CY_CRYPTO_VU_ALLOC_MEM (base, VR_S_Y, bitsize); + CY_CRYPTO_VU_ALLOC_MEM (base, VR_P, bitsize); + CY_CRYPTO_VU_ALLOC_MEM (base, VR_BARRETT, bitsize + 1u); + CY_CRYPTO_VU_ALLOC_MEM (base, VR_ORDER, bitsize); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, p_polynomial, size); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_P, p_polynomial, bitsize); /* Preparation (either use precalculated or calculated). */ - Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, p_barrett, size + 1u); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_BARRETT, p_barrett, bitsize + 1u); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_S_X, ecpGX, size); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_S_Y, ecpGY, size); - Cy_Crypto_Core_Vu_SetMemValue (base, VR_D, ecpD, size); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_S_X, ecpGX, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_S_Y, ecpGY, bitsize); + Cy_Crypto_Core_Vu_SetMemValue (base, VR_D, ecpD, bitsize); /* ECC calculation: d * G mod p */ - Cy_Crypto_Core_EC_NistP_PointMul(base, VR_S_X, VR_S_Y, VR_D, VR_ORDER, size); + Cy_Crypto_Core_EC_NistP_PointMul(base, VR_S_X, VR_S_Y, VR_D, VR_ORDER, bitsize); /* Get result P = (X,Y) = d.G from EC scalar multiplication */ - Cy_Crypto_Core_Vu_GetMemValue (base, ecpQX, VR_S_X, size); - Cy_Crypto_Core_Vu_GetMemValue (base, ecpQY, VR_S_Y, size); + Cy_Crypto_Core_Vu_GetMemValue (base, ecpQX, VR_S_X, bitsize); + Cy_Crypto_Core_Vu_GetMemValue (base, ecpQY, VR_S_Y, bitsize); /* Free memory */ CY_CRYPTO_VU_FREE_MEM (base, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hmac_v1.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hmac_v1.c index c504700b53..d5a6d3c1ea 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hmac_v1.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hmac_v1.c @@ -65,7 +65,7 @@ static void Cy_Crypto_Core_V1_Hmac_Init(cy_stc_crypto_v1_hmac_state_t *hmacState uint8_t *opad, uint8_t *m0Key); -static void Cy_Crypto_Core_V1_Hmac_Calculate(CRYPTO_Type *base, +static cy_en_crypto_status_t Cy_Crypto_Core_V1_Hmac_Calculate(CRYPTO_Type *base, cy_stc_crypto_v1_hmac_state_t *hmacState, cy_stc_crypto_sha_state_t *hashState, uint8_t const *key, @@ -118,7 +118,7 @@ static void Cy_Crypto_Core_V1_Hmac_Init(cy_stc_crypto_v1_hmac_state_t *hmacState * Starts HMAC (Hash-based Message Authentication Code) calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hmacState * The pointer to the hmacState structure which stores internal variables @@ -144,7 +144,7 @@ static void Cy_Crypto_Core_V1_Hmac_Init(cy_stc_crypto_v1_hmac_state_t *hmacState * The pointer to the calculated HMAC. * *******************************************************************************/ -static void Cy_Crypto_Core_V1_Hmac_Calculate(CRYPTO_Type *base, +static cy_en_crypto_status_t Cy_Crypto_Core_V1_Hmac_Calculate(CRYPTO_Type *base, cy_stc_crypto_v1_hmac_state_t *hmacState, cy_stc_crypto_sha_state_t *hashState, uint8_t const *key, @@ -153,6 +153,8 @@ static void Cy_Crypto_Core_V1_Hmac_Calculate(CRYPTO_Type *base, uint32_t messageSize, uint8_t *hmac) { + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SUCCESS; + uint32_t i = 0uL; uint8_t *ipadPtrTmp = (uint8_t*)hmacState->ipad; uint8_t *opadPtrTmp = (uint8_t*)hmacState->opad; @@ -162,13 +164,22 @@ static void Cy_Crypto_Core_V1_Hmac_Calculate(CRYPTO_Type *base, if (keyLength > hashState->blockSize) { /* The key is larger than the block size. Do a hash on the key. */ - Cy_Crypto_Core_V1_Sha_Start (base, hashState); - Cy_Crypto_Core_V1_Sha_Update (base, hashState, key, keyLength); - Cy_Crypto_Core_V1_Sha_Finish (base, hashState, (uint8_t*)m0KeyPtrTmp/*, keyLength*/); + tmpResult = Cy_Crypto_Core_V1_Sha_Start(base, hashState); + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V1_Sha_Update(base, hashState, key, keyLength); + } + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V1_Sha_Finish(base, hashState, (uint8_t*)m0KeyPtrTmp); + } - /* Append zeros */ - Cy_Crypto_Core_V1_MemSet(base, (m0KeyPtrTmp + hashState->digestSize), 0x00u, - (uint16_t)(hashState->blockSize - hashState->digestSize)); + if (CY_CRYPTO_SUCCESS == tmpResult) + { + /* Append zeros */ + Cy_Crypto_Core_V1_MemSet(base, (m0KeyPtrTmp + hashState->digestSize), 0x00u, + (uint16_t)(hashState->blockSize - hashState->digestSize)); + } } else if (keyLength < hashState->blockSize) { @@ -181,31 +192,59 @@ static void Cy_Crypto_Core_V1_Hmac_Calculate(CRYPTO_Type *base, Cy_Crypto_Core_V1_MemCpy(base, m0KeyPtrTmp, key, (uint16_t)keyLength); } - /* Steps 4 and 7 according to FIPS 198-1 */ - while (i < hashState->blockSize) + if (CY_CRYPTO_SUCCESS == tmpResult) { - ipadPtrTmp[i] = CY_CRYPTO_HMAC_IPAD ^ m0KeyPtrTmp[i]; - opadPtrTmp[i] = CY_CRYPTO_HMAC_0PAD ^ m0KeyPtrTmp[i]; - i++; + /* Steps 4 and 7 according to FIPS 198-1 */ + while (i < hashState->blockSize) + { + ipadPtrTmp[i] = CY_CRYPTO_HMAC_IPAD ^ m0KeyPtrTmp[i]; + opadPtrTmp[i] = CY_CRYPTO_HMAC_0PAD ^ m0KeyPtrTmp[i]; + i++; + } + + /* Step 6 according to FIPS 198-1 */ + tmpResult = Cy_Crypto_Core_V1_Sha_Start(base, hashState); + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V1_Sha_Update(base, hashState, ipadPtrTmp, hashState->blockSize); + } + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + /* Append a message */ + tmpResult = Cy_Crypto_Core_V1_Sha_Update (base, hashState, message, messageSize); + } + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V1_Sha_Finish (base, hashState, ipadPtrTmp); + } + + /* Here is the ready part of HASH: Hash((Key^ipad)||text) */ + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + /* Steps 8, 9 according to FIPS 198-1 */ + tmpResult = Cy_Crypto_Core_V1_Sha_Start(base, hashState); + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V1_Sha_Update(base, hashState, opadPtrTmp, hashState->blockSize); + } + + /* Append HASH from Step 6 */ + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V1_Sha_Update(base, hashState, (uint8_t*)ipadPtrTmp, hashState->digestSize); + } + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V1_Sha_Finish(base, hashState, hmac); + } + } } - /* Step 6 according to FIPS 198-1 */ - Cy_Crypto_Core_V1_Sha_Start (base, hashState); - Cy_Crypto_Core_V1_Sha_Update(base, hashState, ipadPtrTmp, hashState->blockSize); - - /* Append a message */ - Cy_Crypto_Core_V1_Sha_Update (base, hashState, message, messageSize); - Cy_Crypto_Core_V1_Sha_Finish (base, hashState, ipadPtrTmp); - - /* Here is the ready part of HASH: Hash((Key^ipad)||text) */ - - /* Steps 8, 9 according to FIPS 198-1 */ - Cy_Crypto_Core_V1_Sha_Start (base, hashState); - Cy_Crypto_Core_V1_Sha_Update(base, hashState, opadPtrTmp, hashState->blockSize); - - /* Append HASH from Step 6 */ - Cy_Crypto_Core_V1_Sha_Update (base, hashState, (uint8_t*)ipadPtrTmp, hashState->digestSize); - Cy_Crypto_Core_V1_Sha_Finish (base, hashState, hmac); + return (tmpResult); } /******************************************************************************* @@ -215,7 +254,7 @@ static void Cy_Crypto_Core_V1_Hmac_Calculate(CRYPTO_Type *base, * Clears the used memory buffers. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hmacState * The pointer to the HMAC context. @@ -236,7 +275,7 @@ static void Cy_Crypto_Core_V1_Hmac_Free(CRYPTO_Type *base, cy_stc_crypto_v1_hmac * Performs HMAC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hmac * The pointer to the calculated HMAC. Must be 4-byte aligned. @@ -257,7 +296,7 @@ static void Cy_Crypto_Core_V1_Hmac_Free(CRYPTO_Type *base, cy_stc_crypto_v1_hmac * \ref cy_en_crypto_sha_mode_t * * \return -* A Crypto status \ref en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Hmac(CRYPTO_Type *base, @@ -268,25 +307,30 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Hmac(CRYPTO_Type *base, uint32_t keyLength, cy_en_crypto_sha_mode_t mode) { + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SUCCESS; + /* Allocating internal variables into the CRYPTO SRAM Buffer */ cy_stc_crypto_hmac_buffers_t *hmacBuffers = (cy_stc_crypto_hmac_buffers_t *)(REG_CRYPTO_MEM_BUFF(base)); cy_stc_crypto_v1_hmac_state_t *hmacStateTmp = &hmacBuffers->hmacState; - cy_stc_crypto_sha_state_t hashState; + cy_stc_crypto_sha_state_t hashStateLoc = { 0 }; uint8_t *ipadTmp = (uint8_t*)(&hmacBuffers->ipad); uint8_t *opadTmp = (uint8_t*)(&hmacBuffers->opad); uint8_t *m0KeyTmp = (uint8_t*)(&hmacBuffers->m0Key); - Cy_Crypto_Core_V1_Sha_Init (base, &hashState, mode, &hmacBuffers->shaBuffers); + tmpResult = Cy_Crypto_Core_V1_Sha_Init(base, &hashStateLoc, mode, &hmacBuffers->shaBuffers); - Cy_Crypto_Core_V1_Hmac_Init (hmacStateTmp, ipadTmp, opadTmp, m0KeyTmp); - Cy_Crypto_Core_V1_Hmac_Calculate (base, hmacStateTmp, &hashState, key, keyLength, message, messageSize, hmac); - Cy_Crypto_Core_V1_Hmac_Free (base, hmacStateTmp); + if (CY_CRYPTO_SUCCESS == tmpResult) + { + Cy_Crypto_Core_V1_Hmac_Init(hmacStateTmp, ipadTmp, opadTmp, m0KeyTmp); + tmpResult = Cy_Crypto_Core_V1_Hmac_Calculate (base, hmacStateTmp, &hashStateLoc, key, keyLength, message, messageSize, hmac); + Cy_Crypto_Core_V1_Hmac_Free(base, hmacStateTmp); + } - Cy_Crypto_Core_V1_Sha_Free (base, &hashState); + (void)Cy_Crypto_Core_V1_Sha_Free(base, &hashStateLoc); - return (CY_CRYPTO_SUCCESS); + return (tmpResult); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hmac_v2.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hmac_v2.c index 5800252bfe..d00d3a4100 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hmac_v2.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hmac_v2.c @@ -64,7 +64,7 @@ static void Cy_Crypto_Core_V2_Hmac_Init(cy_stc_crypto_v2_hmac_state_t *hmacState uint8_t *ipad, uint8_t *opad, uint8_t *m0Key); -static void Cy_Crypto_Core_V2_Hmac_Calculate(CRYPTO_Type *base, +static cy_en_crypto_status_t Cy_Crypto_Core_V2_Hmac_Calculate(CRYPTO_Type *base, cy_stc_crypto_v2_hmac_state_t *hmacState, cy_stc_crypto_sha_state_t *hashState, uint8_t const *key, @@ -116,7 +116,7 @@ static void Cy_Crypto_Core_V2_Hmac_Init(cy_stc_crypto_v2_hmac_state_t *hmacState * Starts HMAC (Hash-based Message Authentication Code) calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hmacState * The pointer to the hmacState structure which stores internal variables @@ -142,7 +142,7 @@ static void Cy_Crypto_Core_V2_Hmac_Init(cy_stc_crypto_v2_hmac_state_t *hmacState * The pointer to the calculated HMAC. * *******************************************************************************/ -static void Cy_Crypto_Core_V2_Hmac_Calculate(CRYPTO_Type *base, +static cy_en_crypto_status_t Cy_Crypto_Core_V2_Hmac_Calculate(CRYPTO_Type *base, cy_stc_crypto_v2_hmac_state_t *hmacState, cy_stc_crypto_sha_state_t *hashState, uint8_t const *key, @@ -151,6 +151,8 @@ static void Cy_Crypto_Core_V2_Hmac_Calculate(CRYPTO_Type *base, uint32_t messageSize, uint8_t *hmac) { + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SUCCESS; + uint32_t i = 0uL; uint32_t blockSizeTmp = hashState->blockSize; uint32_t digestSizeTmp = hashState->digestSize; @@ -164,9 +166,16 @@ static void Cy_Crypto_Core_V2_Hmac_Calculate(CRYPTO_Type *base, if (keyLength > blockSizeTmp) { /* The key is larger than the block size. Do a hash on the key. */ - Cy_Crypto_Core_V2_Sha_Start (base, hashState); - Cy_Crypto_Core_V2_Sha_Update (base, hashState, key, keyLength); - Cy_Crypto_Core_V2_Sha_Finish (base, hashState, m0KeyPtrTmp); + tmpResult = Cy_Crypto_Core_V2_Sha_Start (base, hashState); + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V2_Sha_Update (base, hashState, key, keyLength); + } + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V2_Sha_Finish (base, hashState, m0KeyPtrTmp); + } /* Append zeros */ Cy_Crypto_Core_V2_MemSet(base, (m0KeyPtrTmp + digestSizeTmp), 0x00u, (uint16_t)(blockSizeTmp - digestSizeTmp)); @@ -182,31 +191,59 @@ static void Cy_Crypto_Core_V2_Hmac_Calculate(CRYPTO_Type *base, Cy_Crypto_Core_V2_MemCpy(base, m0KeyPtrTmp, key, (uint16_t)keyLength); } - /* Steps 4 and 7 according to FIPS 198-1 */ - while (i < blockSizeTmp) + if (CY_CRYPTO_SUCCESS == tmpResult) { - ipadPtrTmp[i] = CY_CRYPTO_HMAC_IPAD ^ m0KeyPtrTmp[i]; - opadPtrTmp[i] = CY_CRYPTO_HMAC_0PAD ^ m0KeyPtrTmp[i]; - i++; + /* Steps 4 and 7 according to FIPS 198-1 */ + while (i < blockSizeTmp) + { + ipadPtrTmp[i] = CY_CRYPTO_HMAC_IPAD ^ m0KeyPtrTmp[i]; + opadPtrTmp[i] = CY_CRYPTO_HMAC_0PAD ^ m0KeyPtrTmp[i]; + i++; + } + + /* Step 6 according to FIPS 198-1 */ + tmpResult = Cy_Crypto_Core_V2_Sha_Start (base, hashState); + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V2_Sha_Update(base, hashState, ipadPtrTmp, blockSizeTmp); + } + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + /* Append a message */ + tmpResult = Cy_Crypto_Core_V2_Sha_Update(base, hashState, message, messageSize); + } + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V2_Sha_Finish(base, hashState, ipadPtrTmp); + } + + /* Here is the ready part of HASH: Hash((Key^ipad)||text) */ + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + /* Steps 8, 9 according to FIPS 198-1 */ + tmpResult = Cy_Crypto_Core_V2_Sha_Start(base, hashState); + + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V2_Sha_Update(base, hashState, opadPtrTmp, blockSizeTmp); + } + + /* Append HASH from Step 6 */ + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V2_Sha_Update(base, hashState, ipadPtrTmp, digestSizeTmp); + } + if (CY_CRYPTO_SUCCESS == tmpResult) + { + tmpResult = Cy_Crypto_Core_V2_Sha_Finish(base, hashState, hmac); + } + } } - /* Step 6 according to FIPS 198-1 */ - Cy_Crypto_Core_V2_Sha_Start (base, hashState); - Cy_Crypto_Core_V2_Sha_Update(base, hashState, ipadPtrTmp, blockSizeTmp); - - /* Append a message */ - Cy_Crypto_Core_V2_Sha_Update(base, hashState, message, messageSize); - Cy_Crypto_Core_V2_Sha_Finish(base, hashState, ipadPtrTmp); - - /* Here is the ready part of HASH: Hash((Key^ipad)||text) */ - - /* Steps 8, 9 according to FIPS 198-1 */ - Cy_Crypto_Core_V2_Sha_Start(base, hashState); - Cy_Crypto_Core_V2_Sha_Update(base, hashState, opadPtrTmp, blockSizeTmp); - - /* Append HASH from Step 6 */ - Cy_Crypto_Core_V2_Sha_Update(base, hashState, ipadPtrTmp, digestSizeTmp); - Cy_Crypto_Core_V2_Sha_Finish(base, hashState, hmac); + return (tmpResult); } /******************************************************************************* @@ -216,7 +253,7 @@ static void Cy_Crypto_Core_V2_Hmac_Calculate(CRYPTO_Type *base, * Clears the used memory buffers. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hmacState * The pointer to the HMAC context. @@ -235,7 +272,7 @@ static void Cy_Crypto_Core_V2_Hmac_Free(CRYPTO_Type *base, cy_stc_crypto_v2_hmac * Performs HMAC calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hmac * The pointer to the calculated HMAC. Must be 4-byte aligned. @@ -256,7 +293,7 @@ static void Cy_Crypto_Core_V2_Hmac_Free(CRYPTO_Type *base, cy_stc_crypto_v2_hmac * \ref cy_en_crypto_sha_mode_t * * \return -* A Crypto status \ref en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Hmac(CRYPTO_Type *base, @@ -267,27 +304,32 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Hmac(CRYPTO_Type *base, uint32_t keyLength, cy_en_crypto_sha_mode_t mode) { + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SUCCESS; + /* Allocating internal variables into the CRYPTO SRAM Buffer */ - cy_stc_crypto_v2_hmac_buffers_t hmacBuffersData; + cy_stc_crypto_v2_hmac_buffers_t hmacBuffersData = { 0 }; cy_stc_crypto_v2_hmac_buffers_t *hmacBuffers = &hmacBuffersData; cy_stc_crypto_v2_hmac_state_t *hmacStateTmp = &hmacBuffers->hmacState; - cy_stc_crypto_sha_state_t hashState; + cy_stc_crypto_sha_state_t hashStateLoc = { 0 }; uint8_t *ipadTmp = (uint8_t*)&hmacBuffers->ipad; uint8_t *opadTmp = (uint8_t*)&hmacBuffers->opad; uint8_t *m0KeyTmp = (uint8_t*)&hmacBuffers->m0Key; /* No any buffers needed for Crypto_ver2 IP block */ - Cy_Crypto_Core_V2_Sha_Init (base, &hashState, mode, NULL); + tmpResult = Cy_Crypto_Core_V2_Sha_Init(base, &hashStateLoc, mode, NULL); - Cy_Crypto_Core_V2_Hmac_Init (hmacStateTmp, ipadTmp, opadTmp, m0KeyTmp); - Cy_Crypto_Core_V2_Hmac_Calculate (base, hmacStateTmp, &hashState, key, keyLength, message, messageSize, hmac); - Cy_Crypto_Core_V2_Hmac_Free (base, hmacStateTmp); + if (CY_CRYPTO_SUCCESS == tmpResult) + { + Cy_Crypto_Core_V2_Hmac_Init(hmacStateTmp, ipadTmp, opadTmp, m0KeyTmp); + tmpResult = Cy_Crypto_Core_V2_Hmac_Calculate(base, hmacStateTmp, &hashStateLoc, key, keyLength, message, messageSize, hmac); + Cy_Crypto_Core_V2_Hmac_Free(base, hmacStateTmp); + } - Cy_Crypto_Core_V2_Sha_Free (base, &hashState); + (void)Cy_Crypto_Core_V2_Sha_Free(base, &hashStateLoc); - return (CY_CRYPTO_SUCCESS); + return (tmpResult); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hw.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hw.c index 7e4309d88d..f8fb5f5fbb 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hw.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hw.c @@ -104,6 +104,12 @@ const cy_stc_cryptoIP_t cy_cryptoIpBlockCfgPSoC6_02 = #define CY_CRYPTO_PWR_MODE_RETAINED (2UL) #define CY_CRYPTO_PWR_MODE_ENABLED (3UL) + +/** +* \addtogroup group_crypto_lld_hw_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_ClearVuRegisters ****************************************************************************//** @@ -111,7 +117,7 @@ const cy_stc_cryptoIP_t cy_cryptoIpBlockCfgPSoC6_02 = * The function to initialize the Crypto VU registers. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * *******************************************************************************/ void Cy_Crypto_Core_ClearVuRegisters(CRYPTO_Type *base) @@ -140,8 +146,6 @@ void Cy_Crypto_Core_ClearVuRegisters(CRYPTO_Type *base) * * The function to initialize the Crypto hardware. * -* This function is internal and should not to be called directly by user software -* *******************************************************************************/ void Cy_Crypto_Core_HwInit(void) { @@ -155,17 +159,17 @@ void Cy_Crypto_Core_HwInit(void) * The function to enable the Crypto hardware. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \return -* Crypto status \ref cy_en_crypto_status_t. +* Crypto status \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_Enable(CRYPTO_Type *base) { Cy_Crypto_Core_HwInit(); - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { /* Enable Crypto HW */ REG_CRYPTO_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_CTL_PWR_MODE, CY_CRYPTO_PWR_MODE_ENABLED) | @@ -232,7 +236,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_Enable(CRYPTO_Type *base) * The pointer to a variable to store gathered crypto library information. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_GetLibInfo(cy_en_crypto_lib_info_t *libInfo) @@ -249,15 +253,15 @@ cy_en_crypto_status_t Cy_Crypto_Core_GetLibInfo(cy_en_crypto_lib_info_t *libInfo * Disables the operation of the CRYPTO block. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_Disable(CRYPTO_Type *base) { - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { /* Disable Crypto HW */ REG_CRYPTO_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_CTL_PWR_MODE, CY_CRYPTO_PWR_MODE_OFF) | @@ -322,6 +326,7 @@ void Cy_Crypto_Core_InvertEndianness(void *inArrPtr, uint32_t byteSize) } } +/** \} group_crypto_lld_hw_functions */ #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hw_v1.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hw_v1.c index 94a661fcc7..b6b6946779 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hw_v1.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_hw_v1.c @@ -39,7 +39,7 @@ * Writes one 32-Bit data word into Crypto FIFO. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param data0 * The address of data to be placed into Crypto FIFO @@ -66,7 +66,7 @@ void Cy_Crypto_SetReg1Instr(CRYPTO_Type *base, uint32_t data0) * Writes two 32-Bit data words into Crypto FIFO. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param data0 * The address of data to be placed into Crypto FIFO @@ -99,7 +99,7 @@ void Cy_Crypto_SetReg2Instr(CRYPTO_Type *base, uint32_t data0, uint32_t data1) * Writes three 32-Bit data words into Crypto FIFO. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param data0 * The address of data to be placed into Crypto FIFO @@ -138,7 +138,7 @@ void Cy_Crypto_SetReg3Instr(CRYPTO_Type *base, uint32_t data0, uint32_t data1, u * Writes four 32-Bit data words into Crypto FIFO. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param data0 * The address of data to be placed into Crypto FIFO @@ -183,7 +183,7 @@ void Cy_Crypto_SetReg4Instr(CRYPTO_Type *base, uint32_t data0, uint32_t data1, u * Run the Crypto instruction without parameters. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param instr * The Opcode of the called instruction. @@ -207,7 +207,7 @@ void Cy_Crypto_Run0ParamInstr(CRYPTO_Type *base, uint8_t instr) * The parameter must be placed into register 0 * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param instr * The Opcode of the called instruction. @@ -236,7 +236,7 @@ void Cy_Crypto_Run1ParamInstr(CRYPTO_Type *base, uint8_t instr, uint32_t rdst0Sh * the first parameter must be placed into register 1. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param instr * The Opcode of the called instruction. @@ -273,7 +273,7 @@ void Cy_Crypto_Run2ParamInstr(CRYPTO_Type *base, * the second parameter must be placed into register 2. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param instr * The Opcode of the called instruction. @@ -316,7 +316,7 @@ void Cy_Crypto_Run3ParamInstr(CRYPTO_Type *base, * the third parameter must be placed into register 3. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param instr * The Opcode of the called instruction. diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_mem_v1.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_mem_v1.c index 07e1fb5b74..90c5e07ed4 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_mem_v1.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_mem_v1.c @@ -44,7 +44,7 @@ * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param src * The pointer to the source of MemCpy. @@ -85,7 +85,7 @@ void Cy_Crypto_Core_V1_MemCpy(CRYPTO_Type *base, void* dst, void const *src, uin * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dst * The pointer to the destination of MemSet. @@ -125,7 +125,7 @@ void Cy_Crypto_Core_V1_MemSet(CRYPTO_Type *base, void* dst, uint8_t data, uint16 * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param src0 * The pointer to the first source of MemCmp. @@ -171,7 +171,7 @@ uint32_t Cy_Crypto_Core_V1_MemCmp(CRYPTO_Type *base, void const *src0, void cons * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param src0 * The pointer to the first source of MemXor. diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_mem_v2.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_mem_v2.c index 5e241ca106..487f912de8 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_mem_v2.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_mem_v2.c @@ -42,7 +42,7 @@ * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param src * The pointer to the source of MemCpy. @@ -81,7 +81,7 @@ void Cy_Crypto_Core_V2_MemCpy(CRYPTO_Type *base, void* dst, void const *src, uin * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param dst * The pointer to the destination of MemSet. @@ -119,7 +119,7 @@ void Cy_Crypto_Core_V2_MemSet(CRYPTO_Type *base, void* dst, uint8_t data, uint16 * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param src0 * The pointer to the first source of MemCmp. @@ -166,7 +166,7 @@ uint32_t Cy_Crypto_Core_V2_MemCmp(CRYPTO_Type *base, void const *src0, void cons * There is no alignment restriction. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param src0 * The pointer to the first source of MemXor. diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_prng_v1.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_prng_v1.c index 12771a9af7..53a1a90ea1 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_prng_v1.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_prng_v1.c @@ -43,7 +43,7 @@ * Invoking this function causes a restart of the pseudo-random sequence. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param lfsr32InitState * A non-zero seed value for the first LFSR. @@ -55,7 +55,7 @@ * A non-zero seed value for the third LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Prng_Init(CRYPTO_Type *base, @@ -79,7 +79,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Prng_Init(CRYPTO_Type *base, * Generates a Pseudo Random Number. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param max * The maximum value of a random number. @@ -88,7 +88,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Prng_Init(CRYPTO_Type *base, * The pointer to a variable to store the generated pseudo random number. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Prng(CRYPTO_Type *base, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_prng_v2.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_prng_v2.c index 4873ecb714..867fcb0f46 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_prng_v2.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_prng_v2.c @@ -43,7 +43,7 @@ * Invoking this function causes a restart of the pseudo-random sequence. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param lfsr32InitState * A non-zero seed value for the first LFSR. @@ -55,7 +55,7 @@ * A non-zero seed value for the third LFSR. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Prng_Init(CRYPTO_Type *base, @@ -79,7 +79,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Prng_Init(CRYPTO_Type *base, * Generates a Pseudo Random Number. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param max * The maximum value of a random number. @@ -88,7 +88,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Prng_Init(CRYPTO_Type *base, * The pointer to a variable to store the generated pseudo random number. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Prng(CRYPTO_Type *base, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_rsa.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_rsa.c index 6bcf766be6..73578a6e85 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_rsa.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_rsa.c @@ -57,61 +57,10 @@ static void Cy_Crypto_Core_Rsa_expModByMont(CRYPTO_Type *base, #endif /* #if (CPUSS_CRYPTO_VU == 1) */ -/* Encodings for hash functions */ - -#if (CPUSS_CRYPTO_SHA1 == 1) -static const uint8_t sha1EncStr[CY_CRYPTO_SHA1_PADDING_SIZE] = -{ - 0x30u, 0x21u, 0x30u, 0x09u, 0x06u, 0x05u, 0x2Bu, 0x0Eu, - 0x03u, 0x02u, 0x1Au, 0x05u, 0x00u, 0x04u, 0x14u -}; -#endif /* #if (CPUSS_CRYPTO_SHA1 == 1) */ - -#if (CPUSS_CRYPTO_SHA256 == 1) -static const uint8_t sha224EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = -{ - 0x30u, 0x2Du, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, - 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x04u, 0x05u, - 0x00u, 0x04u, 0x1Cu -}; - -static const uint8_t sha256EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = -{ - 0x30u, 0x31u, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, - 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x01u, 0x05u, - 0x00u, 0x04u, 0x20u -}; -#endif /* #if (CPUSS_CRYPTO_SHA256 == 1) */ - -#if (CPUSS_CRYPTO_SHA512 == 1) -static const uint8_t sha384EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = -{ - 0x30u, 0x41u, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, - 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x02u, 0x05u, - 0x00u, 0x04u, 0x30u -}; - -static const uint8_t sha512EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = -{ - 0x30u, 0x51u, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, - 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x03u, 0x05u, - 0x00u, 0x04u, 0x40u -}; - -static const uint8_t sha512_224EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = -{ - 0x30u, 0x2Du, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, - 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x05u, 0x05u, - 0x00u, 0x04u, 0x1Cu -}; - -static const uint8_t sha512_256EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = -{ - 0x30u, 0x31u, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, - 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x06u, 0x05u, - 0x00u, 0x04u, 0x20u -}; -#endif /* #if (CPUSS_CRYPTO_SHA512 == 1) */ +/** +* \addtogroup group_crypto_lld_asymmetric_functions +* \{ +*/ /******************************************************************************* * Function Name: Cy_Crypto_Core_Rsa_Verify @@ -127,7 +76,7 @@ static const uint8_t sha512_256EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = * Returns the verification result \ref cy_en_crypto_rsa_ver_result_t. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param verResult * The pointer to the verification result \ref cy_en_crypto_rsa_ver_result_t. @@ -145,7 +94,7 @@ static const uint8_t sha512_256EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = * The length of the decrypted signature to be verified (in bytes) * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Verify(CRYPTO_Type *base, @@ -155,11 +104,67 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Verify(CRYPTO_Type *base, uint8_t const *decryptedSignature, uint32_t decryptedSignatureLength) { - cy_en_crypto_status_t myResult = CY_CRYPTO_SUCCESS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SUCCESS; + + /* Encodings for hash functions */ + + #if (CPUSS_CRYPTO_SHA1 == 1) + static const uint8_t sha1EncStr[CY_CRYPTO_SHA1_PADDING_SIZE] = + { + 0x30u, 0x21u, 0x30u, 0x09u, 0x06u, 0x05u, 0x2Bu, 0x0Eu, + 0x03u, 0x02u, 0x1Au, 0x05u, 0x00u, 0x04u, 0x14u + }; + #endif /* #if (CPUSS_CRYPTO_SHA1 == 1) */ + + #if (CPUSS_CRYPTO_SHA256 == 1) + static const uint8_t sha224EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = + { + 0x30u, 0x2Du, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, + 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x04u, 0x05u, + 0x00u, 0x04u, 0x1Cu + }; + + static const uint8_t sha256EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = + { + 0x30u, 0x31u, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, + 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x01u, 0x05u, + 0x00u, 0x04u, 0x20u + }; + #endif /* #if (CPUSS_CRYPTO_SHA256 == 1) */ + + #if (CPUSS_CRYPTO_SHA512 == 1) + static const uint8_t sha384EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = + { + 0x30u, 0x41u, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, + 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x02u, 0x05u, + 0x00u, 0x04u, 0x30u + }; + + static const uint8_t sha512EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = + { + 0x30u, 0x51u, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, + 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x03u, 0x05u, + 0x00u, 0x04u, 0x40u + }; + + static const uint8_t sha512_224EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = + { + 0x30u, 0x2Du, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, + 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x05u, 0x05u, + 0x00u, 0x04u, 0x1Cu + }; + + static const uint8_t sha512_256EncStr[CY_CRYPTO_SHA256_512_PADDING_SIZE] = + { + 0x30u, 0x31u, 0x30u, 0x0Du, 0x06u, 0x09u, 0x60u, 0x86u, + 0x48u, 0x01u, 0x65u, 0x03u, 0x04u, 0x02u, 0x06u, 0x05u, + 0x00u, 0x04u, 0x20u + }; + #endif /* #if (CPUSS_CRYPTO_SHA512 == 1) */ uint8_t const *encodingArr = NULL; uint32_t encodingArrSize = 0u; - uint32_t digestSize = 0u; + uint32_t locDigestSize = 0u; uint32_t i; uint32_t psLength; uint32_t cmpRes = 0u; @@ -172,7 +177,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Verify(CRYPTO_Type *base, case CY_CRYPTO_MODE_SHA1: encodingArr = sha1EncStr; encodingArrSize = sizeof(sha1EncStr); - digestSize = CY_CRYPTO_SHA1_DIGEST_SIZE; + locDigestSize = CY_CRYPTO_SHA1_DIGEST_SIZE; break; #endif /* #if (CPUSS_CRYPTO_SHA1 == 1) */ @@ -180,13 +185,13 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Verify(CRYPTO_Type *base, case CY_CRYPTO_MODE_SHA224: encodingArr = sha224EncStr; encodingArrSize = sizeof(sha224EncStr); - digestSize = CY_CRYPTO_SHA224_DIGEST_SIZE; + locDigestSize = CY_CRYPTO_SHA224_DIGEST_SIZE; break; case CY_CRYPTO_MODE_SHA256: encodingArr = sha256EncStr; encodingArrSize = sizeof(sha256EncStr); - digestSize = CY_CRYPTO_SHA256_DIGEST_SIZE; + locDigestSize = CY_CRYPTO_SHA256_DIGEST_SIZE; break; #endif /* #if (CPUSS_CRYPTO_SHA256 == 1) */ @@ -194,25 +199,25 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Verify(CRYPTO_Type *base, case CY_CRYPTO_MODE_SHA384: encodingArr = sha384EncStr; encodingArrSize = sizeof(sha384EncStr); - digestSize = CY_CRYPTO_SHA384_DIGEST_SIZE; + locDigestSize = CY_CRYPTO_SHA384_DIGEST_SIZE; break; case CY_CRYPTO_MODE_SHA512: encodingArr = sha512EncStr; encodingArrSize = sizeof(sha512EncStr); - digestSize = CY_CRYPTO_SHA512_DIGEST_SIZE; + locDigestSize = CY_CRYPTO_SHA512_DIGEST_SIZE; break; case CY_CRYPTO_MODE_SHA512_224: encodingArr = sha512_224EncStr; encodingArrSize = sizeof(sha512_224EncStr); - digestSize = CY_CRYPTO_SHA512_224_DIGEST_SIZE; + locDigestSize = CY_CRYPTO_SHA512_224_DIGEST_SIZE; break; case CY_CRYPTO_MODE_SHA512_256: encodingArr = sha512_256EncStr; encodingArrSize = sizeof(sha512_256EncStr); - digestSize = CY_CRYPTO_SHA512_256_DIGEST_SIZE; + locDigestSize = CY_CRYPTO_SHA512_256_DIGEST_SIZE; break; #endif /* #if (CPUSS_CRYPTO_SHA512 == 1) */ @@ -224,12 +229,12 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Verify(CRYPTO_Type *base, *verResult = CY_CRYPTO_RSA_VERIFY_FAIL; /* Check size of decrypted message */ - if (decryptedSignatureLength < (encodingArrSize + digestSize + 11u)) + if (decryptedSignatureLength < (encodingArrSize + locDigestSize + 11u)) { cmpRes = 1u; /* further checking is not needed */ } - psLength = decryptedSignatureLength - digestSize - encodingArrSize - 3u; + psLength = decryptedSignatureLength - locDigestSize - encodingArrSize - 3u; /* Check whether the begin of message is 0x00, 0x01 and after PS string (before T string) is 0x00 byte.*/ if ( (0u != cmpRes) || @@ -265,8 +270,8 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Verify(CRYPTO_Type *base, if (0u == cmpRes) { cmpRes = Cy_Crypto_Core_MemCmp(base, digest, - (decryptedSignature + (decryptedSignatureLength - digestSize)), - (uint16_t)digestSize); + (decryptedSignature + (decryptedSignatureLength - locDigestSize)), + (uint16_t)locDigestSize); } if (0u == cmpRes ) @@ -274,9 +279,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Verify(CRYPTO_Type *base, *verResult = CY_CRYPTO_RSA_VERIFY_SUCCESS; } - return (myResult); + return (tmpResult); } +/** \} group_crypto_lld_asymmetric_functions */ #if (CPUSS_CRYPTO_VU == 1) @@ -297,7 +303,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Verify(CRYPTO_Type *base, * where R = 1 << size. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param modDerReg * Register index for Montgomery coefficient value. @@ -306,17 +312,17 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Verify(CRYPTO_Type *base, * Register index for modulo value. * * \param size -* Size of modulo, in Bits. +* Modulo size in bits. * *******************************************************************************/ static void Cy_Crypto_Core_Rsa_MontCoeff(CRYPTO_Type *base, uint32_t modDerReg, uint32_t modReg, uint32_t size) { uint32_t myMod = 9u; uint32_t tmp = 10u; - uint32_t a = 11u; - uint32_t b = 12u; - uint32_t u = 13u; - uint32_t v = 14u; + uint32_t ra = 11u; + uint32_t rb = 12u; + uint32_t ru = 13u; + uint32_t rv = 14u; uint32_t status; uint32_t aZero; @@ -324,27 +330,27 @@ static void Cy_Crypto_Core_Rsa_MontCoeff(CRYPTO_Type *base, uint32_t modDerReg, CY_CRYPTO_VU_PUSH_REG (base); - CY_CRYPTO_VU_LD_REG (base, v, modDerReg); + CY_CRYPTO_VU_LD_REG (base, rv, modDerReg); CY_CRYPTO_VU_LD_REG (base, myMod, modReg); - CY_CRYPTO_VU_ALLOC_MEM (base, a, size); - CY_CRYPTO_VU_ALLOC_MEM (base, b, size); - CY_CRYPTO_VU_ALLOC_MEM (base, u, size); + CY_CRYPTO_VU_ALLOC_MEM (base, ra, size); + CY_CRYPTO_VU_ALLOC_MEM (base, rb, size); + CY_CRYPTO_VU_ALLOC_MEM (base, ru, size); - CY_CRYPTO_VU_SET_TO_ONE (base, u); - CY_CRYPTO_VU_SET_TO_ZERO (base, v); + CY_CRYPTO_VU_SET_TO_ONE (base, ru); + CY_CRYPTO_VU_SET_TO_ZERO (base, rv); - CY_CRYPTO_VU_SET_TO_ZERO (base, a); + CY_CRYPTO_VU_SET_TO_ZERO (base, ra); CY_CRYPTO_VU_SET_REG (base, tmp, (size - 1u), 1u); - CY_CRYPTO_VU_SET_BIT (base, a, tmp); - CY_CRYPTO_VU_MOV (base, b, myMod); + CY_CRYPTO_VU_SET_BIT (base, ra, tmp); + CY_CRYPTO_VU_MOV (base, rb, myMod); while (1) { Cy_Crypto_Core_WaitForReady(base); - CY_CRYPTO_VU_TST(base, a); + CY_CRYPTO_VU_TST(base, ra); status = Cy_Crypto_Core_Vu_StatusRead(base); aZero = status & CY_CRYPTO_VU_STATUS_ZERO_BIT; @@ -354,27 +360,27 @@ static void Cy_Crypto_Core_Rsa_MontCoeff(CRYPTO_Type *base, uint32_t modDerReg, break; } - CY_CRYPTO_VU_LSR1(base, a, a); + CY_CRYPTO_VU_LSR1(base, ra, ra); - CY_CRYPTO_VU_TST(base, u); + CY_CRYPTO_VU_TST(base, ru); status = Cy_Crypto_Core_Vu_StatusRead(base); uEven = status & CY_CRYPTO_VU_STATUS_EVEN_BIT; if (uEven != 0u) { - CY_CRYPTO_VU_LSR1(base, u, u); - CY_CRYPTO_VU_LSR1(base, v, v); + CY_CRYPTO_VU_LSR1(base, ru, ru); + CY_CRYPTO_VU_LSR1(base, rv, rv); } else { - CY_CRYPTO_VU_ADD(base, u, u, b); - CY_CRYPTO_VU_LSR1_WITH_CARRY(base, u, u); - CY_CRYPTO_VU_LSR1(base, v, v); - CY_CRYPTO_VU_SET_BIT(base, v, tmp); + CY_CRYPTO_VU_ADD(base, ru, ru, rb); + CY_CRYPTO_VU_LSR1_WITH_CARRY(base, ru, ru); + CY_CRYPTO_VU_LSR1(base, rv, rv); + CY_CRYPTO_VU_SET_BIT(base, rv, tmp); } } - CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(a) | CY_CRYPTO_VU_REG_BIT(b) | CY_CRYPTO_VU_REG_BIT(u)); + CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(ra) | CY_CRYPTO_VU_REG_BIT(rb) | CY_CRYPTO_VU_REG_BIT(ru)); CY_CRYPTO_VU_POP_REG(base); } @@ -392,7 +398,7 @@ static void Cy_Crypto_Core_Rsa_MontCoeff(CRYPTO_Type *base, uint32_t modDerReg, * barrett = (1 << (2 * size)) / mod NO!!! leading '1' Barrett bit. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param barrettUReg * Register index for Barrett reduction value. @@ -400,8 +406,8 @@ static void Cy_Crypto_Core_Rsa_MontCoeff(CRYPTO_Type *base, uint32_t modDerReg, * \param modReg * Register index for modulo value. * -* \param -* Size modulo size in Bits. +* \param size +* The modulo size in bits. * *******************************************************************************/ static void Cy_Crypto_Core_Rsa_BarrettGetU(CRYPTO_Type *base, uint32_t barrettUReg, uint32_t modReg, uint32_t size) @@ -447,7 +453,7 @@ static void Cy_Crypto_Core_Rsa_BarrettGetU(CRYPTO_Type *base, uint32_t barrettUR * z = (a << size) % mod * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param z * Register index for Montgomery representation value. @@ -521,7 +527,7 @@ static void Cy_Crypto_Core_Rsa_MontTransform(CRYPTO_Type *base, uint32_t z, uint * u = IF (u >= mod) u = u - mod * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param z * Register index for product value. @@ -561,7 +567,7 @@ static void Cy_Crypto_Core_Rsa_MontMul(CRYPTO_Type *base, CY_CRYPTO_VU_UMUL (base, tDouble, a, b); - /* Only lower 32 bits are needed */ + /* Only the lower 32 bits are needed. */ CY_CRYPTO_VU_UMUL (base, t, tDouble, montModDer); /* Clear the MSB bit (cut to size length) */ @@ -605,7 +611,7 @@ static void Cy_Crypto_Core_Rsa_MontMul(CRYPTO_Type *base, * calculation. Suitable for cases with short e. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param y * Register index for calculated value. @@ -619,8 +625,17 @@ static void Cy_Crypto_Core_Rsa_MontMul(CRYPTO_Type *base, * \param n * Register index for modulo value. * +* \param barretCoef +* Barrett coefficient. +* +* \param inverseModulo +* Binary inverse of the modulo. +* +* \param rBar +* Values of (2^moduloLength mod modulo). +* * \param size -* modulo size, in Bits +* The modulo size in bits. * *******************************************************************************/ static void Cy_Crypto_Core_Rsa_expModByMont(CRYPTO_Type *base, @@ -720,6 +735,11 @@ static void Cy_Crypto_Core_Rsa_expModByMont(CRYPTO_Type *base, CY_CRYPTO_VU_POP_REG(base); } +/** +* \addtogroup group_crypto_lld_asymmetric_functions +* \{ +*/ + /******************************************************************************* * Function Name: Cy_Crypto_Core_Rsa_Proc ****************************************************************************//** @@ -730,7 +750,7 @@ static void Cy_Crypto_Core_Rsa_expModByMont(CRYPTO_Type *base, * https://en.wikipedia.org/wiki/RSA_%28cryptosystem%29 * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param key * The pointer to the \ref cy_stc_crypto_rsa_pub_key_t structure that stores @@ -746,7 +766,7 @@ static void Cy_Crypto_Core_Rsa_expModByMont(CRYPTO_Type *base, * The pointer to processed message. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Proc(CRYPTO_Type *base, @@ -755,7 +775,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Proc(CRYPTO_Type *base, uint32_t messageSize, uint8_t *processedMessage) { - cy_en_crypto_status_t myResult = CY_CRYPTO_SUCCESS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SUCCESS; uint8_t *expPtr = key->pubExpPtr; uint32_t expBitLength = key->pubExpLength; @@ -834,7 +854,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Proc(CRYPTO_Type *base, Cy_Crypto_Core_Vu_WaitForComplete(base); - /* Copy the myResult to output buffer */ + /* Copy the tmpResult to output buffer */ Cy_Crypto_Core_Vu_GetMemValue(base, (uint8_t*)processedMessage, yReg, nBitLength); CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(yReg) | CY_CRYPTO_VU_REG_BIT(xReg) | @@ -842,7 +862,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Proc(CRYPTO_Type *base, CY_CRYPTO_VU_REG_BIT(inverseModuloReg) | CY_CRYPTO_VU_REG_BIT(barrettReg) | CY_CRYPTO_VU_REG_BIT(rBarReg)); - return (myResult); + return (tmpResult); } /******************************************************************************* @@ -856,20 +876,20 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Proc(CRYPTO_Type *base, * result of (2^moduloLength mod modulo) * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param key * The pointer to the \ref cy_stc_crypto_rsa_pub_key_t structure that stores a * public key. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Coef(CRYPTO_Type *base, cy_stc_crypto_rsa_pub_key_t const *key) { - cy_en_crypto_status_t myResult = CY_CRYPTO_SUCCESS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SUCCESS; uint8_t *nPtr = key->moduloPtr; uint32_t nBitLength = key->moduloLength; @@ -916,9 +936,11 @@ cy_en_crypto_status_t Cy_Crypto_Core_Rsa_Coef(CRYPTO_Type *base, CY_CRYPTO_VU_FREE_MEM(base, CY_CRYPTO_VU_REG_BIT(modReg) | CY_CRYPTO_VU_REG_BIT(inverseModuloReg) | CY_CRYPTO_VU_REG_BIT(barrettReg) | CY_CRYPTO_VU_REG_BIT(rBarReg)); - return (myResult); + return (tmpResult); } +/** \} group_crypto_lld_asymmetric_functions */ + #endif /* #if (CPUSS_CRYPTO_VU == 1) */ #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_sha_v1.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_sha_v1.c index 4cff247c87..6a185c0785 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_sha_v1.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_sha_v1.c @@ -39,15 +39,15 @@ typedef enum { #if (CPUSS_CRYPTO_SHA1 == 1) - CY_CRYPTO_V1_SHA_CTL_MODE_SHA1 = 0u, + CY_CRYPTO_V1_SHA_CTL_MODE_SHA1 = 0U, #endif /* #if (CPUSS_CRYPTO_SHA1 == 1) */ #if (CPUSS_CRYPTO_SHA256 == 1) - CY_CRYPTO_V1_SHA_CTL_MODE_SHA256 = 1u, + CY_CRYPTO_V1_SHA_CTL_MODE_SHA256 = 1U, #endif /* #if (CPUSS_CRYPTO_SHA256 == 1) */ #if (CPUSS_CRYPTO_SHA512 == 1) - CY_CRYPTO_V1_SHA_CTL_MODE_SHA512 = 2u, + CY_CRYPTO_V1_SHA_CTL_MODE_SHA512 = 2U, #endif /* #if (CPUSS_CRYPTO_SHA512 == 1) */ } cy_en_crypto_v1_sha_hw_mode_t; @@ -60,7 +60,7 @@ typedef enum * All addresses must be 4-Byte aligned! * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to a Hash State. @@ -99,7 +99,7 @@ void Cy_Crypto_Core_V1_Sha_ProcessBlock(CRYPTO_Type *base, * The function to initialize SHA operation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to a Hash State. @@ -109,10 +109,10 @@ void Cy_Crypto_Core_V1_Sha_ProcessBlock(CRYPTO_Type *base, * CY_CRYPTO_SHA512, CY_CRYPTO_SHA384, CY_CRYPTO_SHA512_224, CY_CRYPTO_SHA512_256 * * \param shaBuffers -* The pointer to memory buffers storage +* The pointer to the memory buffers storage. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, @@ -120,6 +120,8 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, cy_en_crypto_sha_mode_t mode, void *shaBuffers) { + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SUCCESS; + /* Initialization vectors for different modes of the SHA algorithm */ #if (CPUSS_CRYPTO_SHA1 == 1) static const uint32_t sha1InitHash[] = @@ -190,7 +192,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, #if (CPUSS_CRYPTO_SHA1 == 1) case CY_CRYPTO_MODE_SHA1: - Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00u, sizeof(cy_stc_crypto_v1_sha1_buffers_t)); + Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00U, sizeof(cy_stc_crypto_v1_sha1_buffers_t)); hashState->block = (uint8_t*)((cy_stc_crypto_v1_sha1_buffers_t*)shaBuffers)->block; hashState->hash = (uint8_t*)((cy_stc_crypto_v1_sha1_buffers_t*)shaBuffers)->hash; @@ -208,7 +210,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, #if (CPUSS_CRYPTO_SHA256 == 1) case CY_CRYPTO_MODE_SHA224: - Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00u, sizeof(cy_stc_crypto_v1_sha256_buffers_t)); + Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00U, sizeof(cy_stc_crypto_v1_sha256_buffers_t)); hashState->block = (uint8_t*)((cy_stc_crypto_v1_sha256_buffers_t*)shaBuffers)->block; hashState->hash = (uint8_t*)((cy_stc_crypto_v1_sha256_buffers_t*)shaBuffers)->hash; @@ -223,7 +225,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, break; case CY_CRYPTO_MODE_SHA256: - Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00u, sizeof(cy_stc_crypto_v1_sha256_buffers_t)); + Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00U, sizeof(cy_stc_crypto_v1_sha256_buffers_t)); hashState->block = (uint8_t*)((cy_stc_crypto_v1_sha256_buffers_t*)shaBuffers)->block; hashState->hash = (uint8_t*)((cy_stc_crypto_v1_sha256_buffers_t*)shaBuffers)->hash; @@ -241,7 +243,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, #if (CPUSS_CRYPTO_SHA512 == 1) case CY_CRYPTO_MODE_SHA384: - Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00u, sizeof(cy_stc_crypto_v1_sha512_buffers_t)); + Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00U, sizeof(cy_stc_crypto_v1_sha512_buffers_t)); hashState->block = (uint8_t*)((cy_stc_crypto_v1_sha512_buffers_t*)shaBuffers)->block; hashState->hash = (uint8_t*)((cy_stc_crypto_v1_sha512_buffers_t*)shaBuffers)->hash; @@ -255,7 +257,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, break; case CY_CRYPTO_MODE_SHA512: - Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00u, sizeof(cy_stc_crypto_v1_sha512_buffers_t)); + Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00U, sizeof(cy_stc_crypto_v1_sha512_buffers_t)); hashState->block = (uint8_t*)((cy_stc_crypto_v1_sha512_buffers_t*)shaBuffers)->block; hashState->hash = (uint8_t*)((cy_stc_crypto_v1_sha512_buffers_t*)shaBuffers)->hash; @@ -269,7 +271,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, break; case CY_CRYPTO_MODE_SHA512_224: - Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00u, sizeof(cy_stc_crypto_v1_sha512_buffers_t)); + Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00U, sizeof(cy_stc_crypto_v1_sha512_buffers_t)); hashState->block = (uint8_t*)((cy_stc_crypto_v1_sha512_buffers_t*)shaBuffers)->block; hashState->hash = (uint8_t*)((cy_stc_crypto_v1_sha512_buffers_t*)shaBuffers)->hash; @@ -283,7 +285,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, break; case CY_CRYPTO_MODE_SHA512_256: - Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00u, sizeof(cy_stc_crypto_v1_sha512_buffers_t)); + Cy_Crypto_Core_V1_MemSet(base, shaBuffers, 0x00U, sizeof(cy_stc_crypto_v1_sha512_buffers_t)); hashState->block = (uint8_t*)((cy_stc_crypto_v1_sha512_buffers_t*)shaBuffers)->block; hashState->hash = (uint8_t*)((cy_stc_crypto_v1_sha512_buffers_t*)shaBuffers)->hash; @@ -298,13 +300,14 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, #endif /* #if (CPUSS_CRYPTO_SHA512 == 1) */ default: + tmpResult = CY_CRYPTO_BAD_PARAMS; break; } /* Set the SHA mode */ REG_CRYPTO_SHA_CTL(base) = (uint32_t)(_VAL2FLD(CRYPTO_SHA_CTL_MODE, (uint32_t)shaHwMode)); - return (CY_CRYPTO_SUCCESS); + return (tmpResult); } /******************************************************************************* @@ -314,33 +317,33 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Init(CRYPTO_Type *base, * Initializes the initial hash vector. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Start(CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState) { - hashState->blockIdx = 0u; - hashState->messageSize = 0u; - - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; if (hashState != NULL) { - if (hashState->hashSize != 0) + hashState->blockIdx = 0U; + hashState->messageSize = 0U; + + if (hashState->hashSize != 0U) { Cy_Crypto_Core_V1_MemCpy(base, hashState->hash, hashState->initialHash, (uint16_t)hashState->hashSize); - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } } - return (myResult); + return (tmpResult); } /******************************************************************************* @@ -350,7 +353,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Start(CRYPTO_Type *base, cy_stc_cryp * Performs the SHA calculation on one message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. @@ -362,12 +365,12 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Start(CRYPTO_Type *base, cy_stc_cryp * The size of the message whose Hash is being computed. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \note * This function can be called several times only with message lengths dividable -* by block size. Only the last call to the function can process a message with -* the not dividable size. +* by the block size. Only the last call to the function can process a message with +* a not-dividable size. * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Update(CRYPTO_Type *base, @@ -375,13 +378,13 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Update(CRYPTO_Type *base, uint8_t const *message, uint32_t messageSize) { - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; if ((hashState != NULL) && (message != NULL)) { - if (hashState->blockSize != 0) + if (hashState->blockSize != 0U) { - if (messageSize > 0) + if (messageSize != 0U) { uint32_t blockSizeTmp = hashState->blockSize; hashState->messageSize += messageSize; @@ -394,28 +397,28 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Update(CRYPTO_Type *base, messageSize -= blockSizeTmp; } - /* Remaining block will be calculated in Finish function */ + /* The remaining block will be calculated in the Finish function. */ hashState->blockIdx = messageSize; /* Copy the end of the message to the block */ Cy_Crypto_Core_V1_MemCpy(base, hashState->block, message, (uint16_t)(messageSize & (blockSizeTmp - 1u))); } - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } } - return (myResult); + return (tmpResult); } /******************************************************************************* * Function Name: Cy_Crypto_Core_V1_Sha_Finish ****************************************************************************//** * -* Completes SHA calculation. +* Completes the SHA calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. @@ -424,14 +427,14 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Update(CRYPTO_Type *base, * The pointer to the calculated hash digest. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Finish(CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState, uint8_t *digest) { - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; if ((hashState != NULL) && (digest != NULL)) { @@ -439,7 +442,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Finish(CRYPTO_Type *base, uint8_t *blockTmp = hashState->block; uint32_t blockSizeTmp = hashState->blockSize; uint32_t blockIdxTmp = hashState->blockIdx; - uint64_t finalMessageSizeInBits = (uint64_t)hashState->messageSize * 8u; + uint64_t finalMessageSizeInBits = (uint64_t)hashState->messageSize * 8U; uint32_t size; if (CY_CRYPTO_SHA512_BLOCK_SIZE == blockSizeTmp) @@ -452,10 +455,10 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Finish(CRYPTO_Type *base, } /* Append 1 bit to the end of the message */ - blockTmp[blockIdxTmp] = 0x80u; + blockTmp[blockIdxTmp] = 0x80U; /* Clear the rest of the block */ - Cy_Crypto_Core_V1_MemSet(base, (void* )&blockTmp[blockIdxTmp + 1u], 0x00u, (uint16_t)(blockSizeTmp - blockIdxTmp - 1u)); + Cy_Crypto_Core_V1_MemSet(base, (void* )&blockTmp[blockIdxTmp + 1U], 0x00U, (uint16_t)(blockSizeTmp - blockIdxTmp - 1U)); if (blockIdxTmp >= size) { @@ -466,32 +469,32 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Finish(CRYPTO_Type *base, Cy_Crypto_Core_V1_MemSet(base, blockTmp, 0x00u, (uint16_t)blockSizeTmp); } - blockTmp[blockSizeTmp - 4u] = (uint8_t)((finalMessageSizeInBits) >> 24u); - blockTmp[blockSizeTmp - 3u] = (uint8_t)((finalMessageSizeInBits) >> 16u); - blockTmp[blockSizeTmp - 2u] = (uint8_t)((finalMessageSizeInBits) >> 8u); - blockTmp[blockSizeTmp - 1u] = (uint8_t)(finalMessageSizeInBits); + blockTmp[blockSizeTmp - 4U] = (uint8_t)((finalMessageSizeInBits) >> 24U); + blockTmp[blockSizeTmp - 3U] = (uint8_t)((finalMessageSizeInBits) >> 16U); + blockTmp[blockSizeTmp - 2U] = (uint8_t)((finalMessageSizeInBits) >> 8U); + blockTmp[blockSizeTmp - 1U] = (uint8_t)(finalMessageSizeInBits); /* Process the last block */ Cy_Crypto_Core_V1_Sha_ProcessBlock(base, hashState, (uint8_t*)blockTmp); /* Invert endians of the hash and copy it to digest, re-use the size variable */ - size = (uint32_t)(hashState->digestSize / 4u); + size = (uint32_t)(hashState->digestSize / 4U); - for(; size != 0u; size--) + for(; size != 0U; size--) { *(digest) = *(hashTmp+3); *(digest+1) = *(hashTmp+2); *(digest+2) = *(hashTmp+1); *(digest+3) = *(hashTmp); - digest += 4; - hashTmp += 4; + digest += 4U; + hashTmp += 4U; } - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } - return (myResult); + return (tmpResult); } /******************************************************************************* @@ -501,30 +504,30 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Finish(CRYPTO_Type *base, * Clears the used memory buffers. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Free(CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState) { - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; if (hashState != NULL) { /* Clears the memory buffer. */ - Cy_Crypto_Core_V1_MemSet(base, hashState->block, 0x00u, (uint16_t)hashState->blockSize); - Cy_Crypto_Core_V1_MemSet(base, hashState->hash, 0x00u, (uint16_t)hashState->hashSize); - Cy_Crypto_Core_V1_MemSet(base, hashState->roundMem, 0x00u, (uint16_t)hashState->roundMemSize); + Cy_Crypto_Core_V1_MemSet(base, hashState->block, 0x00U, (uint16_t)hashState->blockSize); + Cy_Crypto_Core_V1_MemSet(base, hashState->hash, 0x00U, (uint16_t)hashState->hashSize); + Cy_Crypto_Core_V1_MemSet(base, hashState->roundMem, 0x00U, (uint16_t)hashState->roundMemSize); - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } - return (myResult); + return (tmpResult); } @@ -535,7 +538,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Free(CRYPTO_Type *base, cy_stc_crypt * Performs the SHA Hash function. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param mode * \ref cy_en_crypto_sha_mode_t @@ -550,7 +553,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha_Free(CRYPTO_Type *base, cy_stc_crypt * The pointer to the hash digest. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha(CRYPTO_Type *base, @@ -559,31 +562,31 @@ cy_en_crypto_status_t Cy_Crypto_Core_V1_Sha(CRYPTO_Type *base, uint8_t *digest, cy_en_crypto_sha_mode_t mode) { - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; void *shaBuffers = (void *)REG_CRYPTO_MEM_BUFF(base); - cy_stc_crypto_sha_state_t myHashState; + cy_stc_crypto_sha_state_t myHashState = { 0 }; - myResult = Cy_Crypto_Core_V1_Sha_Init (base, &myHashState, mode, shaBuffers); + tmpResult = Cy_Crypto_Core_V1_Sha_Init (base, &myHashState, mode, shaBuffers); - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { - myResult = Cy_Crypto_Core_V1_Sha_Start (base, &myHashState); + tmpResult = Cy_Crypto_Core_V1_Sha_Start (base, &myHashState); } - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { - myResult = Cy_Crypto_Core_V1_Sha_Update (base, &myHashState, message, messageSize); + tmpResult = Cy_Crypto_Core_V1_Sha_Update (base, &myHashState, message, messageSize); } - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { - myResult = Cy_Crypto_Core_V1_Sha_Finish (base, &myHashState, digest); + tmpResult = Cy_Crypto_Core_V1_Sha_Finish (base, &myHashState, digest); } - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { - myResult = Cy_Crypto_Core_V1_Sha_Free (base, &myHashState); + tmpResult = Cy_Crypto_Core_V1_Sha_Free (base, &myHashState); } - return (myResult); + return (tmpResult); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_sha_v2.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_sha_v2.c index 4c32c915be..aced0299ef 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_sha_v2.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_sha_v2.c @@ -42,7 +42,7 @@ * The function to initialize SHA operation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to a Hash State. @@ -52,10 +52,10 @@ * CY_CRYPTO_SHA512, CY_CRYPTO_SHA384, CY_CRYPTO_SHA512_224, CY_CRYPTO_SHA512_256 * * \param shaBuffers -* The pointer to memory buffers storage +* The pointer to the memory buffers storage. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Init(CRYPTO_Type *base, @@ -63,6 +63,8 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Init(CRYPTO_Type *base, cy_en_crypto_sha_mode_t mode, void *shaBuffers) { + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SUCCESS; + /* Initialization vectors for different modes of the SHA algorithm */ #if (CPUSS_CRYPTO_SHA1 == 1) static const uint8_t sha1InitHash[] = @@ -149,7 +151,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Init(CRYPTO_Type *base, CY_ASSERT_L1(hashState != NULL); - Cy_Crypto_Core_V2_MemSet(base, hashState, 0x00u, sizeof(cy_stc_crypto_sha_state_t)); + Cy_Crypto_Core_V2_MemSet(base, hashState, 0x00U, sizeof(cy_stc_crypto_sha_state_t)); switch (mode) { @@ -209,10 +211,11 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Init(CRYPTO_Type *base, break; #endif /* #if (CPUSS_CRYPTO_SHA512 == 1) */ default: + tmpResult = CY_CRYPTO_BAD_PARAMS; break; } - return (CY_CRYPTO_SUCCESS); + return (tmpResult); } /******************************************************************************* @@ -222,39 +225,39 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Init(CRYPTO_Type *base, * Initializes the initial hash vector. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Start(CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState) { - hashState->blockIdx = 0u; - hashState->messageSize = 0u; - - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; if (hashState != NULL) { - if (hashState->hashSize != 0) + hashState->blockIdx = 0U; + hashState->messageSize = 0U; + + if (hashState->hashSize != 0U) { Cy_Crypto_Core_V2_RBClear(base); Cy_Crypto_Core_V2_Sync(base); Cy_Crypto_Core_V2_FFStart(base, CY_CRYPTO_V2_RB_FF_LOAD0, hashState->initialHash, hashState->hashSize); - Cy_Crypto_Core_V2_RBXor(base, 0u, hashState->hashSize); + Cy_Crypto_Core_V2_RBXor(base, 0U, hashState->hashSize); Cy_Crypto_Core_V2_Sync(base); Cy_Crypto_Core_V2_RBSwap(base); - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } } - return (myResult); + return (tmpResult); } /******************************************************************************* @@ -264,7 +267,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Start(CRYPTO_Type *base, cy_stc_cryp * Performs the SHA calculation on one message. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. @@ -276,12 +279,12 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Start(CRYPTO_Type *base, cy_stc_cryp * The size of the message whose Hash is being computed. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * \note * This function can be called several times only with message lengths dividable -* by block size. Only the last call to the function can process a message with -* the not dividable size. +* by the block size. Only the last call to the function can process a message with +* a not-dividable size. * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Update(CRYPTO_Type *base, @@ -289,13 +292,13 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Update(CRYPTO_Type *base, uint8_t const *message, uint32_t messageSize) { - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; if ((hashState != NULL) && (message != NULL)) { - if (hashState->blockSize != 0) + if (hashState->blockSize != 0U) { - if (messageSize > 0) + if (messageSize != 0U) { hashState->messageSize += messageSize; @@ -303,7 +306,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Update(CRYPTO_Type *base, while (messageSize >= hashState->blockSize) { - Cy_Crypto_Core_V2_RBXor(base, 0u, hashState->blockSize); + Cy_Crypto_Core_V2_RBXor(base, 0U, hashState->blockSize); messageSize -= hashState->blockSize; @@ -314,11 +317,11 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Update(CRYPTO_Type *base, hashState->blockIdx = messageSize; } - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } } - return (myResult); + return (tmpResult); } /******************************************************************************* @@ -328,7 +331,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Update(CRYPTO_Type *base, * Completes SHA calculation. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. @@ -337,21 +340,21 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Update(CRYPTO_Type *base, * The pointer to the calculated hash digest. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Finish(CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState, uint8_t *digest) { - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; if ((hashState != NULL) && (digest != NULL)) { uint32_t myBlockSize = hashState->blockSize; uint32_t myBlockIdx = hashState->blockIdx; - uint64_t finalMessageSizeInBits = (uint64_t)hashState->messageSize * 8u; + uint64_t finalMessageSizeInBits = (uint64_t)hashState->messageSize * 8U; uint32_t size; if (CY_CRYPTO_SHA512_BLOCK_SIZE == myBlockSize) @@ -364,13 +367,13 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Finish(CRYPTO_Type *base, } /* Load the end of the message (tail that less then block size) to the register buffer */ - Cy_Crypto_Core_V2_RBXor(base, 0u, myBlockIdx); + Cy_Crypto_Core_V2_RBXor(base, 0U, myBlockIdx); /* Sync until XOR operation is completed */ Cy_Crypto_Core_V2_Sync(base); /* Append 1 bit to the end of the message */ - Cy_Crypto_Core_V2_RBSetByte(base, myBlockIdx, 0x80u); + Cy_Crypto_Core_V2_RBSetByte(base, myBlockIdx, 0x80U); if (myBlockIdx >= size) { @@ -381,12 +384,12 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Finish(CRYPTO_Type *base, /* Append message size into last of the block */ /* In case of u32SizeInByte * 8 > u32Max */ - Cy_Crypto_Core_V2_RBSetByte(base, myBlockSize - 5u, (uint8_t)(finalMessageSizeInBits >> 32u)); + Cy_Crypto_Core_V2_RBSetByte(base, myBlockSize - 5U, (uint8_t)(finalMessageSizeInBits >> 32U)); - Cy_Crypto_Core_V2_RBSetByte(base, myBlockSize - 4u, (uint8_t)(finalMessageSizeInBits >> 24u)); - Cy_Crypto_Core_V2_RBSetByte(base, myBlockSize - 3u, (uint8_t)(finalMessageSizeInBits >> 16u)); - Cy_Crypto_Core_V2_RBSetByte(base, myBlockSize - 2u, (uint8_t)(finalMessageSizeInBits >> 8u)); - Cy_Crypto_Core_V2_RBSetByte(base, myBlockSize - 1u, (uint8_t)(finalMessageSizeInBits)); + Cy_Crypto_Core_V2_RBSetByte(base, myBlockSize - 4U, (uint8_t)(finalMessageSizeInBits >> 24U)); + Cy_Crypto_Core_V2_RBSetByte(base, myBlockSize - 3U, (uint8_t)(finalMessageSizeInBits >> 16U)); + Cy_Crypto_Core_V2_RBSetByte(base, myBlockSize - 2U, (uint8_t)(finalMessageSizeInBits >> 8U)); + Cy_Crypto_Core_V2_RBSetByte(base, myBlockSize - 1U, (uint8_t)(finalMessageSizeInBits)); Cy_Crypto_Core_V2_Run(base, hashState->mode); Cy_Crypto_Core_V2_Sync(base); @@ -394,14 +397,14 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Finish(CRYPTO_Type *base, /* Write digest. */ Cy_Crypto_Core_V2_FFStart(base, CY_CRYPTO_V2_RB_FF_STORE, digest, hashState->digestSize); Cy_Crypto_Core_V2_RBSwap(base); - Cy_Crypto_Core_V2_RBStore(base, 0u, hashState->digestSize); + Cy_Crypto_Core_V2_RBStore(base, 0U, hashState->digestSize); Cy_Crypto_Core_V2_FFStoreSync(base); - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } - return (myResult); + return (tmpResult); } /******************************************************************************* @@ -411,31 +414,31 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Finish(CRYPTO_Type *base, * Clears the used memory buffers. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param hashState * The pointer to the SHA context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Free(CRYPTO_Type *base, cy_stc_crypto_sha_state_t *hashState) { - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; if (hashState != NULL) { - Cy_Crypto_Core_V2_MemSet(base, hashState, 0x00u, sizeof(cy_stc_crypto_sha_state_t)); + Cy_Crypto_Core_V2_MemSet(base, hashState, 0x00U, sizeof(cy_stc_crypto_sha_state_t)); /* Clears the memory buffer. */ Cy_Crypto_Core_V2_RBClear(base); Cy_Crypto_Core_V2_Sync(base); - myResult = CY_CRYPTO_SUCCESS; + tmpResult = CY_CRYPTO_SUCCESS; } - return (myResult); + return (tmpResult); } /******************************************************************************* @@ -445,7 +448,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Free(CRYPTO_Type *base, cy_stc_crypt * Performs the SHA Hash function. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param mode * \ref cy_en_crypto_sha_mode_t @@ -460,7 +463,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha_Free(CRYPTO_Type *base, cy_stc_crypt * The pointer to the hash digest. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha(CRYPTO_Type *base, @@ -469,32 +472,32 @@ cy_en_crypto_status_t Cy_Crypto_Core_V2_Sha(CRYPTO_Type *base, uint8_t *digest, cy_en_crypto_sha_mode_t mode) { - cy_en_crypto_status_t myResult = CY_CRYPTO_BAD_PARAMS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_BAD_PARAMS; /* Allocate space for the structure which stores the SHA context */ - cy_stc_crypto_sha_state_t hashState; + cy_stc_crypto_sha_state_t hashState = { 0 }; - /* No any buffers needed for Crypto_ver2 IP block */ - myResult = Cy_Crypto_Core_V2_Sha_Init (base, &hashState, mode, NULL); + /* No buffers are needed for the Crypto_ver2 IP block. */ + tmpResult = Cy_Crypto_Core_V2_Sha_Init (base, &hashState, mode, NULL); - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { - myResult = Cy_Crypto_Core_V2_Sha_Start (base, &hashState); + tmpResult = Cy_Crypto_Core_V2_Sha_Start (base, &hashState); } - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { - myResult = Cy_Crypto_Core_V2_Sha_Update (base, &hashState, message, messageSize); + tmpResult = Cy_Crypto_Core_V2_Sha_Update (base, &hashState, message, messageSize); } - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { - myResult = Cy_Crypto_Core_V2_Sha_Finish (base, &hashState, digest); + tmpResult = Cy_Crypto_Core_V2_Sha_Finish (base, &hashState, digest); } - if (CY_CRYPTO_SUCCESS == myResult) + if (CY_CRYPTO_SUCCESS == tmpResult) { - myResult = Cy_Crypto_Core_V2_Sha_Free (base, &hashState); + tmpResult = Cy_Crypto_Core_V2_Sha_Free (base, &hashState); } - return (myResult); + return (tmpResult); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_trng_v1.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_trng_v1.c index 3a43c91bb2..5275864895 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_trng_v1.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_trng_v1.c @@ -41,10 +41,10 @@ static void Cy_Crypto_Core_V1_Trng_Init(CRYPTO_Type *base); * Function Name: Cy_Crypto_Core_V1_Trng_Init ****************************************************************************//** * -* Initializes the TRND parameters. +* Initializes the TRNG parameters. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * *******************************************************************************/ static void Cy_Crypto_Core_V1_Trng_Init(CRYPTO_Type *base) @@ -57,15 +57,15 @@ static void Cy_Crypto_Core_V1_Trng_Init(CRYPTO_Type *base) REG_CRYPTO_TR_MON_AP_CTL(base) = CY_CRYPTO_V1_TR_AC_CUTOFF; } + /******************************************************************************* * Function Name: Cy_Crypto_Core_V1_Trng ****************************************************************************//** * -* Generates a True Random Number and returns it in the -* cfContext->trngNumPtr. +* Generates a True Random Number. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param GAROPol * The polynomial for the programmable Galois ring oscillator. @@ -80,7 +80,7 @@ static void Cy_Crypto_Core_V1_Trng_Init(CRYPTO_Type *base) * The pointer to a generated true random number. Must be 4-byte aligned. * * \return -* A Crypto status \ref en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V1_Trng(CRYPTO_Type *base, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_trng_v2.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_trng_v2.c index e6d184a225..3c83ff2fae 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_trng_v2.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_trng_v2.c @@ -40,10 +40,10 @@ static void Cy_Crypto_Core_V2_Trng_Init(CRYPTO_Type *base); * Function Name: Cy_Crypto_Core_V2_Trng_Init ****************************************************************************//** * -* Initializes the TRND parameters. +* Initializes the TRNG parameters. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * *******************************************************************************/ static void Cy_Crypto_Core_V2_Trng_Init(CRYPTO_Type *base) @@ -56,15 +56,15 @@ static void Cy_Crypto_Core_V2_Trng_Init(CRYPTO_Type *base) REG_CRYPTO_TR_MON_AP_CTL(base) = CY_CRYPTO_V2_TR_AC_CUTOFF; } + /******************************************************************************* * Function Name: Cy_Crypto_Core_V2_Trng ****************************************************************************//** * -* Generates a True Random Number and returns it in the -* cfContext->trngNumPtr. +* Generates a True Random Number. * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param GAROPol * The polynomial for the programmable Galois ring oscillator. @@ -79,7 +79,7 @@ static void Cy_Crypto_Core_V2_Trng_Init(CRYPTO_Type *base) * The pointer to a generated true random number. Must be 4-byte aligned. * * \return -* A Crypto status \ref en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ cy_en_crypto_status_t Cy_Crypto_Core_V2_Trng(CRYPTO_Type *base, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_vu.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_vu.c index ec5df3c749..f1750927c1 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_vu.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_core_vu.c @@ -46,7 +46,7 @@ void Cy_Crypto_Core_Vu_SetMemValue(CRYPTO_Type *base, uint32_t dstReg, uint8_t c Cy_Crypto_Core_Vu_WaitForComplete(base); - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { CY_CRYPTO_VU_SAVE_REG(base, CY_CRYPTO_VU_HW_REG0, ®0_data); CY_CRYPTO_VU_SAVE_REG(base, CY_CRYPTO_VU_HW_REG1, ®1_data); @@ -61,10 +61,10 @@ void Cy_Crypto_Core_Vu_SetMemValue(CRYPTO_Type *base, uint32_t dstReg, uint8_t c CY_ASSERT_L1(size <= Cy_Crypto_Core_Vu_RegBitSizeRead(base, dstReg)); - CY_ASSERT_L1(((uint32_t)Cy_Crypto_Core_Vu_RegMemPointer(base, dstReg) + byteSize - 1) < ((uint32_t)REG_CRYPTO_MEM_BUFF(base) + CY_CRYPTO_MEM_BUFF_SIZE) ); + CY_ASSERT_L1( (((uint32_t)Cy_Crypto_Core_Vu_RegMemPointer(base, dstReg) + byteSize) - 1u) < ((uint32_t)REG_CRYPTO_MEM_BUFF(base) + CY_CRYPTO_MEM_BUFF_SIZE)); Cy_Crypto_Core_MemCpy(base, (void*)Cy_Crypto_Core_Vu_RegMemPointer(base, dstReg), (const void*)src, byteSize); - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { CY_CRYPTO_VU_RESTORE_REG(base, CY_CRYPTO_VU_HW_REG0, reg0_data); CY_CRYPTO_VU_RESTORE_REG(base, CY_CRYPTO_VU_HW_REG1, reg1_data); @@ -78,7 +78,7 @@ void Cy_Crypto_Core_Vu_GetMemValue(CRYPTO_Type *base, uint8_t *dst, uint32_t src Cy_Crypto_Core_Vu_WaitForComplete(base); - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { CY_CRYPTO_VU_SAVE_REG(base, CY_CRYPTO_VU_HW_REG0, ®0_data); CY_CRYPTO_VU_SAVE_REG(base, CY_CRYPTO_VU_HW_REG1, ®1_data); @@ -92,11 +92,11 @@ void Cy_Crypto_Core_Vu_GetMemValue(CRYPTO_Type *base, uint8_t *dst, uint32_t src } CY_ASSERT_L1(size <= Cy_Crypto_Core_Vu_RegBitSizeRead(base, srcReg)); - CY_ASSERT_L1(((uint32_t)Cy_Crypto_Core_Vu_RegMemPointer(base, srcReg) + byteSize - 1) < ((uint32_t)REG_CRYPTO_MEM_BUFF(base) + CY_CRYPTO_MEM_BUFF_SIZE) ); + CY_ASSERT_L1((((uint32_t)Cy_Crypto_Core_Vu_RegMemPointer(base, srcReg) + byteSize) - 1u) < ((uint32_t)REG_CRYPTO_MEM_BUFF(base) + CY_CRYPTO_MEM_BUFF_SIZE) ); Cy_Crypto_Core_MemCpy(base, (void*)dst, (void*)Cy_Crypto_Core_Vu_RegMemPointer(base, srcReg), byteSize); - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { CY_CRYPTO_VU_RESTORE_REG(base, CY_CRYPTO_VU_HW_REG0, reg0_data); CY_CRYPTO_VU_RESTORE_REG(base, CY_CRYPTO_VU_HW_REG1, reg1_data); @@ -129,7 +129,7 @@ cy_en_crypto_status_t Cy_Crypto_Core_Cleanup(CRYPTO_Type *base) /* AES */ REG_CRYPTO_AES_CTL(base) = 0u; - if (cy_device->cryptoVersion == 1u) + if (CY_CRYPTO_HW_V1) { REG_CRYPTO_CRC_LFSR_CTL(base) = 0u; REG_CRYPTO_SHA_CTL(base) = 0u; @@ -145,69 +145,69 @@ cy_en_crypto_status_t Cy_Crypto_Core_Cleanup(CRYPTO_Type *base) Cy_Crypto_Core_V2_RBClear(base); } - Cy_Crypto_Core_MemSet(base, (void *)REG_CRYPTO_MEM_BUFF(base), 0u, CY_CRYPTO_MEM_BUFF_SIZE); + Cy_Crypto_Core_MemSet(base, (void *)REG_CRYPTO_MEM_BUFF(base), 0u, (uint16_t)CY_CRYPTO_MEM_BUFF_SIZE); return (CY_CRYPTO_SUCCESS); } bool Cy_Crypto_Core_Vu_IsRegZero(CRYPTO_Type *base, uint32_t srcReg) { - bool result; - uint16_t status; + bool tmpResult; + uint32_t status; CY_CRYPTO_VU_TST(base, srcReg); status = Cy_Crypto_Core_Vu_StatusRead(base); - if (status & CY_CRYPTO_VU_STATUS_ZERO_BIT) + if (0u != (status & CY_CRYPTO_VU_STATUS_ZERO_BIT)) { - result = true; + tmpResult = true; } else { - result = false; + tmpResult = false; } - return result; + return tmpResult; } bool Cy_Crypto_Core_Vu_IsRegEqual(CRYPTO_Type *base, uint32_t srcReg0, uint32_t srcReg1) { - bool result; - uint16_t status; + bool tmpResult; + uint32_t status; CY_CRYPTO_VU_CMP_SUB (base, srcReg1, srcReg0); /* C = (a >= b) */ status = Cy_Crypto_Core_Vu_StatusRead(base); - if (status & CY_CRYPTO_VU_STATUS_ZERO_BIT) + if (0u != (status & CY_CRYPTO_VU_STATUS_ZERO_BIT)) { - result = true; + tmpResult = true; } else { - result = false; + tmpResult = false; } - return result; + return tmpResult; } bool Cy_Crypto_Core_Vu_IsRegLess(CRYPTO_Type *base, uint32_t srcReg0, uint32_t srcReg1) { - bool result; - uint16_t status; + bool tmpResult; + uint32_t status; CY_CRYPTO_VU_CMP_SUB (base, srcReg1, srcReg0); /* C = (a >= b) */ status = Cy_Crypto_Core_Vu_StatusRead(base); - if (status & CY_CRYPTO_VU_STATUS_CARRY_BIT) + if (0u != (status & CY_CRYPTO_VU_STATUS_CARRY_BIT)) { - result = true; + tmpResult = true; } else { - result = false; + tmpResult = false; } - return result; + return tmpResult; } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_server.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_server.c index e3da49876d..fda6402e14 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_server.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6pdl/drivers/source/cy_crypto_server.c @@ -46,7 +46,7 @@ #if defined(CY_IP_MXCRYPTO) -/* The pointer to the CRYPTO instance address. */ +/* The pointer to the CRYPTO instance. */ #define CY_CRYPTO_BASE ((CRYPTO_Type *)cy_device->cryptoBase) typedef struct @@ -724,19 +724,19 @@ void Cy_Crypto_Server_GetDataHandler(void) * This function is internal and should not to be called directly by user software * * \param base -* The pointer to the CRYPTO instance address. +* The pointer to the CRYPTO instance. * * \param cryptoContext * The pointer to cy_stc_crypto_context_t structure which stores * the Crypto driver context. * * \return -* A Crypto status \ref cy_en_crypto_status_t. +* \ref cy_en_crypto_status_t * *******************************************************************************/ static cy_en_crypto_status_t Cy_Crypto_Core_CheckHwForErrors(cy_stc_crypto_context_t *cryptoContext) { - cy_en_crypto_status_t myResult = CY_CRYPTO_SUCCESS; + cy_en_crypto_status_t tmpResult = CY_CRYPTO_SUCCESS; uint32_t myErrorStatus0; uint32_t myErrorStatus1; @@ -750,7 +750,7 @@ static cy_en_crypto_status_t Cy_Crypto_Core_CheckHwForErrors(cy_stc_crypto_conte if (_FLD2VAL(CRYPTO_ERROR_STATUS1_VALID, myErrorStatus1) == 1u) { - myResult = CY_CRYPTO_HW_ERROR; + tmpResult = CY_CRYPTO_HW_ERROR; cy_crypto_serverContext->isHwErrorOccured = true; } @@ -763,7 +763,7 @@ static cy_en_crypto_status_t Cy_Crypto_Core_CheckHwForErrors(cy_stc_crypto_conte if (_FLD2VAL(CRYPTO_ERROR_STATUS1_VALID, myErrorStatus1) == 1u) { - myResult = CY_CRYPTO_HW_ERROR; + tmpResult = CY_CRYPTO_HW_ERROR; } cy_crypto_serverContext->isHwErrorOccured = false; @@ -772,7 +772,7 @@ static cy_en_crypto_status_t Cy_Crypto_Core_CheckHwForErrors(cy_stc_crypto_conte cryptoContext->hwErrorStatus.errorStatus0 = myErrorStatus0; cryptoContext->hwErrorStatus.errorStatus1 = myErrorStatus1; - return (myResult); + return (tmpResult); } #endif /* CY_IP_MXCRYPTO */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/pwmout_api.c b/targets/TARGET_Cypress/TARGET_PSOC6/pwmout_api.c index 1f39903179..915d267df9 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/pwmout_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/pwmout_api.c @@ -73,7 +73,7 @@ static void pwm_start_32b(pwmout_t *obj, uint32_t new_period, uint32_t new_width Cy_TCPWM_PWM_SetPeriod0(obj->base, obj->counter_id, obj->period - 1); Cy_TCPWM_PWM_SetCompare0(obj->base, obj->counter_id, obj->pulse_width); Cy_TCPWM_PWM_Enable(obj->base, obj->counter_id); - Cy_TCPWM_TriggerStart(obj->base, 1UL << obj->counter_id); + Cy_TCPWM_TriggerReloadOrIndex(obj->base, 1UL << obj->counter_id); } static void pwm_start_16b(pwmout_t *obj, uint32_t period, uint32_t width) @@ -101,7 +101,7 @@ static void pwm_start_16b(pwmout_t *obj, uint32_t period, uint32_t width) Cy_TCPWM_PWM_SetPrescaler(obj->base, obj->counter_id, prescaler); Cy_TCPWM_PWM_SetCompare0(obj->base, obj->counter_id, width); Cy_TCPWM_PWM_Enable(obj->base, obj->counter_id); - Cy_TCPWM_TriggerStart(obj->base, 1UL << obj->counter_id); + Cy_TCPWM_TriggerReloadOrIndex(obj->base, 1UL << obj->counter_id); } static void pwm_start(pwmout_t *obj, uint32_t new_period, uint32_t new_pulse_width) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/serial_api.c b/targets/TARGET_Cypress/TARGET_PSOC6/serial_api.c index dc01883ce8..9f7c686ec1 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/serial_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/serial_api.c @@ -383,13 +383,16 @@ static void serial_init_peripheral(serial_obj_t *obj) } +/* + * Callback function to handle into and out of deep sleep state transitions. + */ #if DEVICE_SLEEP && DEVICE_LPTICKER && SERIAL_PM_CALLBACK_ENABLED -static cy_en_syspm_status_t serial_pm_callback(cy_stc_syspm_callback_params_t *params) +static cy_en_syspm_status_t serial_pm_callback(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode) { - serial_obj_t *obj = (serial_obj_t *)params->context; + serial_obj_t *obj = (serial_obj_t *) callbackParams->context; cy_en_syspm_status_t status = CY_SYSPM_FAIL; - switch (params->mode) { + switch (mode) { case CY_SYSPM_CHECK_READY: /* If all data elements are transmitted from the TX FIFO and * shifter and the RX FIFO is empty: the UART is ready to enter @@ -432,7 +435,7 @@ static cy_en_syspm_status_t serial_pm_callback(cy_stc_syspm_callback_params_t *p return status; } -#endif /* (DEVICE_SLEEP && DEVICE_LPTICKER && SERIAL_PM_CALLBACK_ENABLED) */ +#endif /* DEVICE_SLEEP && DEVICE_LPTICKER && SERIAL_PM_CALLBACK_ENABLED */ void serial_init(serial_t *obj_in, PinName tx, PinName rx) @@ -492,16 +495,16 @@ void serial_init(serial_t *obj_in, PinName tx, PinName rx) #if DEVICE_SLEEP && DEVICE_LPTICKER && SERIAL_PM_CALLBACK_ENABLED /* Register callback once */ obj->pm_callback_handler.callback = serial_pm_callback; - obj->pm_callback_handler.type = CY_SYSPM_DEEPSLEEP; + obj->pm_callback_handler.type = CY_SYSPM_DEEPSLEEP; obj->pm_callback_handler.skipMode = 0; obj->pm_callback_handler.callbackParams = &obj->pm_callback_params; - obj->pm_callback_params.base = obj->base; + obj->pm_callback_params.base = obj->base; obj->pm_callback_params.context = obj; if (!Cy_SysPm_RegisterCallback(&obj->pm_callback_handler)) { error("PM callback registration failed!"); } -#endif /* (DEVICE_SLEEP && DEVICE_LPTICKER && SERIAL_PM_CALLBACK_ENABLED) */ +#endif /* DEVICE_SLEEP && DEVICE_LPTICKER && SERIAL_PM_CALLBACK_ENABLED */ } /* Configure hardware resources */ @@ -666,9 +669,10 @@ void serial_set_flow_control(serial_t *obj_in, FlowControl type, PinName rxflow, { serial_obj_t *obj = OBJ_P(obj_in); - /* Do not perform pins reservation second time for the same pins */ - if ((obj->pin_rts == rxflow) && (obj->pin_cts == txflow)) + /* Do not perform pins reservation second time for the same pins */ + if ((obj->pin_rts == rxflow) && (obj->pin_cts == txflow)) { return; + } Cy_SCB_UART_Disable(obj->base, NULL); diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/spi_api.c b/targets/TARGET_Cypress/TARGET_PSOC6/spi_api.c index fb4a50bbfa..8bb5b4336d 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/spi_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/spi_api.c @@ -237,16 +237,16 @@ static void spi_init_peripheral(spi_obj_t *obj) /* Callback function to handle into and out of deep sleep state transitions. * */ -#if DEVICE_SLEEP && DEVICE_LOWPOWERTIMER -static cy_en_syspm_status_t spi_pm_callback(cy_stc_syspm_callback_params_t *callback_params) +#if DEVICE_SLEEP && DEVICE_LPTICKER +static cy_en_syspm_status_t spi_pm_callback(cy_stc_syspm_callback_params_t *callback_params, cy_en_syspm_callback_mode_t mode) { cy_stc_syspm_callback_params_t params = *callback_params; spi_obj_t *obj = (spi_obj_t *)params.context; params.context = &obj->context; - return Cy_SCB_SPI_DeepSleepCallback(¶ms); + return Cy_SCB_SPI_DeepSleepCallback(¶ms, mode); } -#endif /* DEVICE_SLEEP && DEVICE_LOWPOWERTIMER */ +#endif /* DEVICE_SLEEP && DEVICE_LPTICKER */ void spi_init(spi_t *obj_in, PinName mosi, PinName miso, PinName sclk, PinName ssel) @@ -314,7 +314,7 @@ void spi_init(spi_t *obj_in, PinName mosi, PinName miso, PinName sclk, PinName s obj->div_num = _FLD2VAL(CY_PERI_CLOCK_CTL_DIV_SEL, map); obj->div_type = (cy_en_divider_types_t) _FLD2VAL(CY_PERI_CLOCK_CTL_TYPE_SEL, map); } else { -#if DEVICE_SLEEP && DEVICE_LOWPOWERTIMER +#if DEVICE_SLEEP && DEVICE_LPTICKER /* Register callback once */ obj->pm_callback_handler.callback = spi_pm_callback; obj->pm_callback_handler.type = CY_SYSPM_DEEPSLEEP; @@ -326,7 +326,7 @@ void spi_init(spi_t *obj_in, PinName mosi, PinName miso, PinName sclk, PinName s if (!Cy_SysPm_RegisterCallback(&obj->pm_callback_handler)) { error("PM callback registration failed!"); } -#endif /* DEVICE_SLEEP && DEVICE_LOWPOWERTIMER */ +#endif /* DEVICE_SLEEP && DEVICE_LPTICKER */ } /* Configure hardware resources */ diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/trng_api.c b/targets/TARGET_Cypress/TARGET_PSOC6/trng_api.c index 49bb1ae26a..92f751670d 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/trng_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/trng_api.c @@ -24,8 +24,8 @@ #include "cy_crypto_core_trng.h" /* Initialization polynomial values fro True Random Generator */ -#define GARO31_INITSTATE (0x04c11db7u) -#define FIRO31_INITSTATE (0x04c11db7u) +#define GARO31_INITSTATE (0x04c11db7UL) +#define FIRO31_INITSTATE (0x04c11db7UL) #define MAX_TRNG_BIT_SIZE (32UL) @@ -47,7 +47,7 @@ void trng_free(trng_t *obj) int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length) { int ret = 0; - *output_length = 0; + *output_length = 0U; /* temporary random data buffer */ uint32_t random; @@ -59,13 +59,13 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l if (Cy_Crypto_Core_Trng(CRYPTO, GARO31_INITSTATE, FIRO31_INITSTATE, MAX_TRNG_BIT_SIZE, &random) != CY_CRYPTO_SUCCESS) { ret = -1; } else { - for (uint8_t i = 0; (i < 4) && (*output_length < length) ; i++) { + for (uint8_t i = 0; (i < 4U) && (*output_length < length) ; i++) { *output++ = ((uint8_t *)&random)[i]; - *output_length += 1; + *output_length += 1U; } } } - random = 0uL; + random = 0UL; return (ret); } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_CY8C63XX/TARGET_MCU_PSOC6_M4/hex/psoc63_m0_ble_controller_1.01.hex b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_CY8C63XX/TARGET_MCU_PSOC6_M4/hex/psoc63_m0_ble_controller_1.01.hex deleted file mode 100644 index 3942055ebc..0000000000 --- a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_CY8C63XX/TARGET_MCU_PSOC6_M4/hex/psoc63_m0_ble_controller_1.01.hex +++ /dev/null @@ -1,1655 +0,0 @@ -:020000041000EA -:4000000000000108310100100D00000095010010000000000000000000000000000000000000000000000000000000009101001000000000000000009101001091010010DC -:400040009101001061080010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001089 -:400080009101001091010010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001020 -:4000C00010B5064C2378002B07D1054B002B02D0044800E000BF0123237010BD2819000800000000C0510010084B10B5002B03D00749084800E000BF07480368002B00D11A -:4001000010BD064B002BFBD09847F9E7000000002C190008C051001094020008000000007047EFF3108072B6704780F310887047FFF7F6FF72B6104C104DAC4209DA2168F0 -:400140006268A368043B02DBC858D050FAE70C34F3E70B490B4A0020521A02DD043A8850FCDC094809490860BFF34F8F00F0FCF800F01EF8FEE70000E4950110FC950110BB -:40018000281900089C2800080000000808ED00E0FEE7FEE700B504207146084202D0EFF3098001E0EFF30880043001F067FEFEE7002110B5080000F063FA002000F0C2FAAB -:4001C00000F0DEF962B60B4B5B689B0301D501F0F7FD002000F09CFDFA20400001F006FE054800F031F905F0BBF8002001F0AEFDF9E7C0460000264000000810F8B5E023D7 -:40020000504C9B00E2580F231340D022990092000919885807224C4D0240032A05D0042A05D0002A0FD0494811E028680FE0C022920089581F220A40112A01D0132A04D198 -:400240008020000203E0424801E0FA20C001002B27D1B223B1210322DB00C900E658635867581B0F3F0F1340174205D0354F7958090F0A40012A01D1F20701D4032B3AD1B4 -:40028000B023344ADB00E658A158E758C904C90C02F0B8FBB603F901B60BC90F7043013127E0012B27D1C823C0210322DB00C900E658635867583F0F174205D0214F7958EF -:4002C000090F0A40012A01D1F20703D49B009B0F032B10D1C0227F23D200A758A1583B401F27A658090A3940584302F08BFB310C394002F087FBE0239B00E3589B069B0F81 -:40030000D840154B68601C691969240A090E013102F078FBE1B2A860013102F073FB0F4BE860286104000E49C01802F06BFBFA210C4B28758900E01802F064FBA861C0030A -:40034000E861F8BD00002640C000000800366E0100127A0084050000000021403F420F0040420F00E7030000B021E02010B530241F4BC9005A588000520052085A501A5814 -:40038000A2431A50802252045A501A491A4A80209950A021043289019950FF21174AC005995081315A5892009208024380205A505A580006024301205A505A5882435A505B -:4003C00000F06CFBFFF71AFF00F056FA00F05EFA01F0EAF9B0235B055A78002A02D05B78212B03D10022064BDA605A6010BDC0460000264001000200840500008C0500008A -:40040000E0002340024BD86F032318407047C0460400214010B5FFF784FE074A074BD16F0B4007490B43D367102306490A681A42FCD0FFF77AFE10BD04002140FCFF00004B -:400440000100FA058800214070B50F4C0600FFF768FEE36F0500DB439B0701D1FFF7DAFFB0230A4A9B00D650E26F094B09491340094A1343E36710230A681A42FCD02800DF -:40048000FFF753FE70BDC0460400214000002140FCFF0000880021400300FA05436870B50400012B02D1007B06F07CF92500A2682B1B01359A4203D9E87B06F073F9F6E758 -:4004C00070BD000010B5034A0349002000F0C4FA10BDC046B96700109D04001007B50022030000911000110000F03AFA07BD10B500F0ACFA10BD10B500F0CAFA10BD10B541 -:400500000400007B00F0F2F8606010BD10B50400007B216900F0B4F8606010BD10B5037B0169180000F0CCF810BD10B50400C06800F008F9606010BD10B5C06800F016F93D -:4005400010BD10B50400C06800F022F9606010BD10B5C06800F036F910BD10B504000C23C05E00F055F8606010BD10B50C23C05E00F06EF810BD10B5C06800F035F910BD5F -:4005800010B500221849042000F0F4FD01221749042000F0EFFD02221549042000F0EAFD03221449042000F0E5FD04221249100000F0E0FD05221149042000F0DBFD062283 -:4005C0000F49042000F0D6FD07220E49042000F0D1FD08220C49042000F0CCFD09220B49042000F0C7FD10BDFF0400100D0500101D0500102B05001039050010430500108D -:40060000510500105B0500106B0500107705001070B507260512EDB206400D2D11D801F094FC0A4901224B5D1C003441144003D1B24013434B5501E00124644201F089FC05 -:4006400001E001246442200070BDC0464419000870B50412E4B20D2C0FD80725054001F074FC064901220B5D1E002E41164202D0AA4093430B5501F06CFC70BD44190008B7 -:40068000F8B50C00050001F060FC0C2301225D431300A3401A00094E71198F683A4008D13B43AD598B60631C4B60AB4202D94A6000E0FF2401F04DFC2000F8BDE0000008FD -:4006C00070B50C00050001F040FC01210C23A1406B43054AD3189A680A4201D08A439A6001F037FC70BDC046E0000008F0B50C2485B0019001F029FC019B114D5C432B19CA -:400700005B68029003932E1971680198FFF7B8FF0700FF280DD173682A59934201D9002373602A1953680399994202D001335360E9E7029801F00DFC380005B0F0BDC04627 -:40074000E000000810B5040007280AD801F0FDFB054B0E331A5D002A01D101321A5501F0F8FB0120404210BD4419000810B5040007280AD801F0E9FB044B0E331A5D012A8E -:4007800001D100221A5501F0E4FB10BD4419000870B505001F280ED801F0D7FB084B30335C5D002C02D101225A5501E00124644201F0CFFB01E001246442200070BDC04614 -:4007C000E000000810B504001F280AD801F0BDFB044B30331A5D012A01D100221A5501F0B8FB10BDE000000870B5B024C025144B144A15496405ED00E35CA25C615C665D5A -:400800003F251F242A400C4024039201224311002B407F2219430B003240520413430B4A1C0A110050310B701B0C8B7000234C7011005031595CC1540133062BF8D170BD5A -:40084000040600000506000003060000E000000810B50248B03000F0ABFC10BDDC19000810B50248583000F0A3FC10BDDC19000810B5FFF7F5FF10BD10B5034A8021603271 -:40088000042000F019FB10BDDC1A000870B501F05CFB0500094800F0DFFB094C200000F00DFC2000343000F009FC2000683000F005FC280001F04DFB70BDC046DC19000897 -:4008C000404500108A22044952000B6853430022CB181A717047C046CC1B00088A230A495B000A6809485A438A18926810B5920082180868D26A4343CB18002119718A42FF -:4009000000D0904710BDC046CC1B0008CC1D00088A21084A490013684B43D3181B79002BF9D101211533FF334343D318197110607047C046CC1B00088A20074A074940005C -:40094000D36C4343CB181B79002BF9D1D06CD36C59424B41D3647047CC1D0008CC1B0008F0B585B0039300238A2714001E00029001917F000A9A96424FD2FFF7DDFF03004B -:400980007B432D490090CA18D46000220431944206D00198855CD018081805740132F6E7019A350012190192721CFF32944622499B1B0A98AA1B0C00A8420BD9654507D045 -:4009C000039A1E48545DEA18821814750135F0E780225200009B00987B43E418029B2261A360FFF795FF164B134ADB6C7B43D3181E79009BF6B27B43D2180832114B002E8F -:400A000000D1114B0221032000F086FB0028EAD17342734104002E00ACE7002CADD1002B07D0029B064A9B00D318DB6A002B00D0984705B0F0BDC046CC1B0008D01B000839 -:400A4000CC1D0008DD080010C508001010B5022000F004FC10BD000070B5040015000200022000F087FB0849022000F097FB074AA400136D14190133E5621365012B01D1B3 -:400A8000FFF7E4FF70BDC046C5080010CC1D000810B5022000F0C8FB10BD0000F0B5962191B0002001F002FA01F0D8F9002801D101F0C6F9012001F077F8E8217E4C7F4BC1 -:400AC000626C89011A400A436264626C0193120AD2B23A2A04D1636C794A13400B4363643422002103A803F00DFD03AA0021754800F002FF3422002103A803F003FD03AA9F -:400B00000121704800F0F8FE0822042623686E4D134323602369334207D1002D04D0012001F07EF9013DF5E701E0002D00D1FEE7A02603220127654CF600A35903AD934305 -:400B40003B43A351D2196249280003F0D2FC280001F06AFB5F4901980B685F4A03400B608021136949041B021B0A0B4313611369019902200B401361E0230F219B00E2588E -:400B80008A433A43E250E25821318A438021E250E25809060A43E250002100F075FB0021032000F071FB0021042000F06DFB0321002000F069FB0321380000F065FB444B34 -:400BC0000522191D280003F094FC2900380000F091FB002800D0FEE74049380000F0DCFB002800D0FEE73E4B3E4AE1580A403A43E250E1583C4A0A408021E250E258090666 -:400C00000A43E250A259394B1340A351A259384B13408022920113438022A351A35912021343A351244B1A68324B1340224A136001F092F9C0235B00E3583B4204D12E4AC4 -:400C4000A3585B005B08A3506421002001F02EF9C0230021294A1B01D15080210901535801981B4C0340802080010343535080232349DB00D150D35823002A000C3343CBE4 -:400C800043C243CB43C243CB43C229000D4800F0ADFE23002A00303313CB13C213CB13C213CB13C22900174800F0A0FE164A174B1A6011B0F0BDC04600002740FF00FFFFFD -:400CC000FFC5FFDF0000324020A1070000002640EC45001090002140000021401027000004050000FEFCFFFFFFFF00FFFFF0FFFFFF8FFFFFFFFCFFFF0C0500000000014026 -:400D000000FF00800003324001001180000E1F4110B5054801F07EF90122044B1A70002801D101F083F910BD38010008201E0008030010B5FF24800882009B1ADB009C402D -:400D40009940E243214007282DD8174B01F050FE04090E13181D2227186A02401143196221E0586A0240114359621CE0986A02401143996217E0D86A02401143D96212E061 -:400D8000186B0240114319630DE0586B02401143596308E0986B02401143996303E0D86B02401143D96310BD00002140064B10309A68064B9A4203D183009858995002E027 -:400DC000034B8000C058704700ED00E00000000800000010F7B5051E01913DD00023C05E002802DBA978FFF7A3FF6A680023E85E9201002812DB1A4B81088900C918FF23A7 -:400E000003271C00C0250740FF00BC401A40BA40AD004E59A64332434A5113E003250F2381B20B402940A940FC352F002A408F408A40083B9B080B4C9B001B19DE69BE43D0 -:400E40003243DA61074B00259A68074B9A4204D10199FFF7ABFF00E0044D2800FEBDC04600E100E000ED00E000000008010056000369002B03DA89B24160002000E001486C -:400E80007047C04601008A000368002B01DB034803E089B2C26081600020704701008A000369002B03DAC36800200B6000E001487047C04601008A0070B5040010000F2C9B -:400EC0002BD8002A07D1002927D1154B6401E418144B1C6022E000291FD01F260E401CD1104D0F4B6401E4186960AA60CA0831002C6003F007FB31002000FFF7B9FF3100F7 -:400F00002A1D2868FFF7C0FF011E04D12868FFF7AFFF011E02D0044900E00449080070BD00002340241E000801018A0003018A00194BF7B51A680193D76804003B680E007C -:400F4000834223D90025A94202D100F0FEFF0500019B18680368002B01DB104C10E063095A01A41A012279689B00CB181968A2400C0014400CD10A431A600021FFF778FF05 -:400F8000002E07D1280000F0E4FF03E0044C01E0044CF2E72000FEBD241E00080301880004018A0002018800194BF7B51A680193D76804003B680E00834223D90025A9423D -:400FC00002D100F0C2FF0500019B18680368002B01DB104C10E063095A01A41A0122A24079689B00CB18196811420DD00024914319600021FFF73CFF002E07D1280000F013 -:40100000A8FF03E0044C01E0044CF2E72000FEBD241E00080301880004018A00020188000A4B1B68DA68136883420DD9430999005B01C31A0120984052688B581840431E54 -:401040009841034BC01800E002487047241E00080001880004018A00024B1A68002A00D118607047301E0008F0B52C246043104C1E0024681F0A2018FF2426403C400D4F7F -:4010800006607601F61906610B4E1B0C44606401A4191E04836033434461A3600023059DC261016283619D4201D02B888381F0BD301E00080000234000102340F0B50389D4 -:4010C00085B002AD2B800368066A1933AB704368476A0095826AC16A040003930369C068FFF7C2FF00213B000A0000913000FFF7BBFF216B2800FFF76DFE0023EA5E002AB1 -:4011000005DB1F231A401E3B9340024A136005B0F0BDC04600E100E0F7B52C25124C6843276801933C182669002E08D04D4379198869002805D13568002D02DA03E00B4820 -:4011400011E00B480FE06768012425004B689D4013882D041D431560F2608C61BC40019BA4B24B62B460FEBD301E000804028A0007028A002C235843064B1B681818C369B6 -:40118000934204D9036A9200D150002000E002487047C046301E00080A028A00034B1A682C235843101881627047C046301E000873B5002642690400D56801962B0CB34295 -:4011C0001CD01B040069136013680369B34215DA01A9FFF765FEB0420CD10198E26903681E0C0378934205D2226A9B009B58002B00D0984731002069FFF73AFEADB2002D63 -:401200000ED063691D6000251B68636AAB4202D09847656203E0A36A002B00D09847A56163691B6873BD00000A4B1A682C23584310180C23C25E002A09DB1F231A401E3B23 -:401240009340054AD367BFF34F8FBFF36F8F00207047C046301E000804E100E0084B1A682C23584310180C23C25E002A05DB1F231A401E3B9340034A136000207047C04635 -:40128000301E000800E100E0042819D804290FD94B1EFF3B132B13D81F231940094B8000C018C02304229B00C1504033C25005E00723D0301940034B8000C150002000E051 -:4012C000014870470000264001004A00084B8200D218D0239B00D05807231840042806D1C0239B00D0581F231840E1331843704700002640F0B5012819D1C022224BD2009E -:401300009A58002A0CDB8A78901E0E280FD84C78601E11280BD8C8780D7800282FD101E01A4830E07026152D01D9AE4201D2184829E00E79022E14D0F82124024901F8271E -:401340000C4021007F2412047F033A4011432C4021438024C022C006240520400143D2009950C020C0248005360706403200E4001D590849002029400A431A5103E0382628 -:40138000122DD4D9D1E7F0BD0000264003004A0001004A00FFFFFFCFF8B50D00012819D1C02180240D4BC9005A582406C826224307001C005A50F600A3593B4206D1002D30 -:4013C0000AD0012000F02CFD013DF5E70020002D03D101E0024800E00248F8BD0000264001004A0002004A00494BF7B51C789C46002C05D0474B484CE358002B00DB82E017 -:40140000464B984200D980E09A427ED8444B99427BD80123644663703F4B424CFF280BD8A3260F25F6009F592840AF43384398511859A843083D1FE03B4E0F25B04204D882 -:401440001E592840AE43304317E01E59AE433500060A35431D51354DA84206D8FF261D59000130400F3EB54306E0F02500022D011E5928402E4D354028431851FF2A10D825 -:40148000A326FF27F6009D5912013A400F3FBD432A439A511A5927481040E022D20210430AE0F027204D3F03AA4207D81D592148120417402840384318511EE01859164EDD -:4014C000009010020740019700981A4F154D3840019F074315481F517459824205D8F020120500040240144804E0F020120600050240124820400243725162465160054AE5 -:401500000020995002E00E4800E00E48FEBDC046341E00081C050000000026400F060000FFFFFF0014050000FF040000FF050000FFF0FFFFFFFFF0FFFFFF0FFFFFFFFFF08D -:4015400003004A0001004A00A423F0B500251F4ADB008446D0582B000002020A85B00292039363461A484570AB421BD1029A039B1A43AA4226D0029C039D029E039F0A00D8 -:4015800063464068614601F0D3FBEB0762081A4300900191009801996B088018594132003B000BE0029A039B44680800290001F0BFFB2B00620880185941220001F098FB3B -:4015C000029003910298039905B0F0BD00002640341E0008174B70B5C318DA179B185340042B22DD8023144E144D1B027459A405A40D984209D9124B0521C01801F002FAF8 -:40160000201AC343DB17184009E00E4B0521181A01F0F8F90C4B0019984200D90B4873599B0A9B020343735101E000242000201A70BDC0460080FFFF000026403C0500005F -:401640000280FFFF02800000FE030000FF0300001E4A0300904238D010D840282ED005D8002831D010282DD119482EE0802827D08021100049008B4227D023E0154A904296 -:4016800014D008D8A022120690421DD0124AA020934211D016E0114A904209D0104A904208D0104A90420DD10F480EE0A42003E00E480AE00E4808E0C00306E00D4804E0A5 -:4016C0000D4802E00D4800E0002070470600520001005000010000F0090000A0040000F0050000F0030000F00100520002005200030052000200500005005200FF00520092 -:40170000F0230F4A1B06C318934201D8580A15E0EC230C4A1B06C318934203D8580A80235B0207E0EA231B06C018904204D88023400A9B02184301E0012040427047C04608 -:40174000FFFF0F00FF7F000010B50400FFF7D8FF0022431C02D0E40562426241100010BD0B4B10B51B69002B10DB0A4B0A4C1868FFF76EFF0121094B094A995099580029D9 -:40178000FCD1064909590029F8D100E0054810BD00002340401E00088C040000000025400C0400000200500010B5022202490020FFF7E0FC10BDC0469503000810B5FFF74B -:4017C000CFFF10BD70B50400FFF7BEFF002824D0FEF714FDE022124B52051A605C600024FA219C60DC600F4B0F4A1D691B692D0E013555431B0ADBB201335D430B4B8900C2 -:40180000186801F0FFF80100280001F0FBF8084BC118200002F08CFE00E0064870BDC046401E00080000214060F59000C4000008980800000600520070B505000C00FFF76E -:4018400083FF002828D0002C26D0FEF7D7FCC022124BD2041A608322FA2152005A609D60DC600F4B0F4A1C691B69240E013454431B0ADBB201335C430B4B8900186801F0B9 -:40188000C1F80100200001F0BDF8E1239B00C118002002F04DFE00E0044870BD401E000800002140808D5B00C4000008060052000F4B30B5C0180F4BC009C01800011F23D2 -:4018C000032909D81D00C9008D4013408B400468AC432343036009E01D000439C9008D4013408B404468AC432343436030BDC0460000CEBF00100304F7B504000E001500E1 -:4019000000286ED0002A6CD0012312688B40002A01D1436000E08360B30001930F231900B0008140A26A8A4369680B4083401343A3622A7A31002000FFF7BAFF03207100C2 -:4019400088400322636A83431800EB6813408B400343636201231F00B7400097FF43BC462F6962461F40B740A0691031104038436F69A0611F40B740E06A10403843E0620D -:40198000A86903221840B0400600E869276B10408A408840009930430A4397436A6A384356000222206304201640AA6A616B92000240286A324303401A43EB6AD800182322 -:4019C0000340FF2013432A6B019D520102401343FE2292002A40934081430B436363002000E00148FEBDC04601005A0000281BD0002919D00D4B0E4AC318DB099B180A682C -:401A00001B010260CA6882620A69C2624A6902638A6842624A6882618A694263CA6900201A600A6A5A6000E0024870470000CEBF0010030401005A0010B50F24022006495C -:401A4000064BCA58A2430243CA50F02212028B58A34303438B5010BD0000214004F0000010B50F2403200649064BCA58A2430243CA50F02212028B58A34303438B5010BD7F -:401A80000000214004F000000449054A054B88580340C020C00103438B5070470000214004F00000FF8FFFFF0449054A054B885803408020C00103438B50704700002140BF -:401AC00004F00000FF8FFFFFF8B50500072700F03CFA1C4C060063693B409D422DD0022D0FD18021184A490493690B439361FFF7A3FF03226369BB4313436361FFF7C4FFD8 -:401B000009E003226369C820BB431343636100F087F9FFF7C9FF072362699A432B4013436361052D09D1C82000F07AF9FFF798FF054A064B91690B409361300000F009FA66 -:401B4000F8BDC0460000264000F02540FFFFFFFE031E03D1084B5869C00F0CE00020012B09D1054918008A69920F1A4201D18869C00F01231840704700002640072370B53A -:401B8000084CA2691A4090420BD0A5699D4303402B43A361002904D0904202D9C82000F03FF970BD00002640F7B5060000F0CDF9B022E8211F27244D244C01902B595205F9 -:401BC000C900525C3B409B1A5A1E9341B34236D0002E13D180211E4A490493690B439361FFF72AFF0B222B59BB4313432B51FFF74BFFB023E8225B05D2000CE00B222B59C5 -:401C00000920BB4313432B5100F00AF9FFF74CFFB022104B5205D35C2959DAB21F23994313400B432B51012E09D1092000F0F8F8FFF716FF064A084B91690B4093610198E9 -:401C400000F087F9F7BDC046000026401CFF000000F0254041070000FFFFFFFE70B5050000F073F92C1E20D0124B19681F2901D900241AE0EC68002C17D02C68002C14D038 -:401C80005E6800243200002A04D0AA42F0D014005269F8E7002E01D15D6000E0656100222C61012401316A61196000F052F9200070BDC046501E0008F0B5060085B00D0012 -:401CC000204F042901D001291AD100207C68002C35D01D4B984232D02379B3420ED1A368002B01D02B4209D1E36801A85A689B6842608360057023689847BC606469E6E758 -:401D0000BC68022902D1002C00D024690020002C15D00D4B984212D02379B3420DD1A368002B01D02B4208D1E36801A85A689B68426083600570236898472469E7E705B0CA -:401D4000F0BDC046501E0008FF00420070B5194C06002368002B0AD100F0F7F823680500002B10D004210020FFF7A6FF0BE001210020FFF7A1FF0028EED002210020FFF79C -:401D80009BFF0D4C14E004210C4A13698B431361012E01D030BF00E020BF280000F0D9F823680024A34203D008212000FFF784FF200070BD501E0008FF00420000ED00E072 -:401DC00010B5E82400F0C1F8064B07495A68A4010A4022435A605A68114059605B6800F0B8F810BD00002640FF00FC0F70B5802504002D02AC4206D9064B186800F09CF86D -:401E0000054BE418F6E7054B1868604300F094F870BDC046DC0000080080FFFFD800000810B5034B1B78584300F086F810BDC046D40000080122014B9A6070470000254032 -:401E400080220020034B12069A649B6C834200DA0148704700002740030046008022054B120198585B68DBB2002B02D08023DB021843704700002640FEE7000002680A4B08 -:401E800010B51A6042685A6082689A60C268DA6002691A6142695A6182699A61C269DA61FFF7EAFF10BDC04678050008F0B51922002800D14B32E82403258A429241194ED8 -:401EC000640033595242AB43134333513359164F3B403351154B5C68AC4322435A605A6817405F60002808D00023102913D921338B429B415B4201330DE003001D290AD96D -:401F000001233A2907D9DB18572904D976338B4240410422131A0F21054A1068884303431360F0BD00002140FFFCFFFFFC00214000002540000000000230800803D001309E -:401F40000238FCD1C046C0467047EFF3108072B6704780F310887047094B042803D11A68104318600BE0C022000692041040902204499200885004211A688A431A6070471C -:401F800010E000E000002140F8B50778012F06D0082F34D11C4B1868FFF7DBFF31E00320FFF73EF8194B984229D000F0CFF8012825D0022003F0D8F90600FFF7C6FF124D59 -:401FC000286003F0D5F9040006281AD0022E0AD1033CB4433000E4B204F026FE002C0BD100280ED008E0380004F01EFE022C03D0002801D1FFF7AAFE2868FFF7AAFF04480B -:4020000000E00020F8BDC0467C1E000801018800FF004200002803D0024B5860002000E0014870477C1E00080100160000B58BB000212822684602F065FA6A46154B1648F7 -:402040009381FB2313835383F83B1377013353770C33D3770132D3776A460232D3776A465B3353846B4601220733DA77FFF7F6FD03F05AF903F060F903F05AF906A803F0FD -:40208000A7F9002804D1054B6846019303F074F90BB000BD901300004C01000898050008014B024AD050704778F0010000003C4010B50BF0EFFA10BDF8B58023FA250C0037 -:4020C00001271B0218430D4E0004F061AD00326C0A4B01203A4205D1002D0CD0013DFFF79FFEF4E7002D06D01A6C10431864DB6A0020238000E00248F8BDC04600003C4007 -:402100000400160070B5FA2401260D4B000418400C4D0143E961A4002B6C0A4A0120334205D1002C0AD0013CFFF77AFEF4E7002C04D0136C18431064002000E0024870BD34 -:402140000000FF7F00003C400400160010B500242000FFF7BBF8032804D00134052CF7D1002000E0012010BDA023034ADB00D058012318407047C0460000264030B524259E -:402180009DB02A00002101A802F0BCF9154B164C0493164B2A0000210AA808930993069402F0B0F9124B2A000D93124B00211193114B13A812930F9402F0A4F90F4B01A9D9 -:4021C00016930F4B0F481A931894FFF70FFC0AA90D48FFF70BFC13A90C48FFF707FC1DB030BDC046666666660000FFFF1C1C1C1C66E6EE661C1A1A1A1A1A000066E6666601 -:402200001A1A001C00013240800132400002324010200349034A8B5803438B507047C04600003C4070F00100F0B585B00090002800D147E1BE4F7B689B0301D5FFF7C0FD6B -:402240000122BC4BBC4C1D001959114204D0BB495B58134200D037E1FFF790FFB84AB94BEA508022009BD2021B781343B64AAB50B64AB74BEA50B74B5A6801231A4200D078 -:4022800024E1B54A116F08220A4008D1B34BB44918681300884202D900F0B4FB431E2A68002B03D0AF485B03034300E0AE4B13432B607B699F499E4E01275B000DD53900DF -:4022C0000320FFF75BFC73699B0F3B420AD08022B369D2051343B36104E00320A34A8B5803438B502B5940200193019AA04BA14E13432B51FFF794FD0123AA598D4F1A42F5 -:4023000008D1BB514020FFF78BFD03234020BB51FFF786FDFA27019A974B984E1A4016430192FF002E51964A964BD3581022134207D1002F00D1CBE00120013FFFF770FDCD -:40234000F1E7002F00D1C3E008218F4A0120AB580B43AB50FFF7FCFB002802D18B4E019B1E438B4B1E4001231E432E511E00894C724BEB58334207D1002C00D1A8E0012097 -:40238000013CFFF74DFDF3E7002C00D1A0E00B27C02181484901FFF7B5FE041E05D102AB991D7D48FFF788FE0400013F002F00D196E0002C25D1C02202AB9E1D33885201AA -:4023C0009342E5D131007548FFF776FE041E18D180233288DB001A4200D083E00B27019380216E48C900FFF78DFE041E04D131006A48FFF761FE0400013F002F70D0002CB3 -:4024000068D0B0256D056B78002B44D06B78212B41D0634FEB5B002B3DD0002C00D0FEE002AB9E1D31005F48FFF746FE041E00D0F5E0C021E85B3488084060398C43400898 -:40244000594920430140F020EA5BC000EB5BD201024011439B05554A9B0F1140DB02194350483180FFF74EFE041E00D0D7E031004F48FFF721FE041E00D0D0E0C022EB5B04 -:4024800031889B069B0F9B019143194348483180FFF738FE0400002C00D0C0E0009B454859781D78444B49001943FFF72BFE041E04D142494248FFF725FE04006801FFF7D6 -:4024C000AFFCACE03F4CAAE03F4CA8E03F4CA6E03F4CA4E03388019A934200D080E701E03B4C8EE731003B48FFF7E6FD041E00D087E732883F2310009843009B36499F78F9 -:40250000DB78012F0ED10222012B04D89FB2D21B92B2019201E0170001947022104330802E4A66E0002B5BD0019401275BE0C0460000264000003C40A0F00100B4F00100AC -:4025400006000001A4F00100A8F0010001000100ACF00100FC003C4000F03D40C800000800093D00041A0080040A0080C4F0010030000300B0F00100EFFFFEFF20000200CA -:40258000000032401040000068F0010028000200FFFFFBFFF07E0E00021E0000031E000016180000071E00007FF8FFFFFFE7FFFF061E0000081E000001100000376800007B -:4025C0000F1E000001001600030016000200160004001600091E0000C00000080048E80101201F0001907F2082436F38024332800C4ADA400A6031880B4839433180FFF750 -:4026000081FD009B0400DB78DF1B03231F40019B9B001F43054BBFB23780EF50F1E6200005B0F0BD0024F400091E000064F00100014B18687047C046C0000008024B58690F -:402640004000C00F7047C046000026400120024B1B68DB0D984370470000264010B50A00002808D0FA23FF33994204D8034901F040FF002000E0024810BDC04607080016C4 -:4026800001001600F0B57D4C7D4BA54407900C000492994200D8ECE08B187A4A93420ED9794A914200D8E4E0784A934207D9784A914200D8DDE0774A934200D9D9E0FFF718 -:4026C000BDFF0523019300280BD0734B5D6907231D40EBB20193022D03D10520FFF7F4F90195FFF7B3FF01230393002810D06B4B694AD158E823B022DB005205D25C1F2307 -:402700000B40934204D10120FFF74EFA00230393F0231B06E3185D0A06936D0200210320FEF706FC0028F9D1070008AB5B1B0293049BBB4273D980239B00EB180593002615 -:402740002B00069A9A4214D8049ABA4211D9079A0299D25DCA54002E08D18021490559180978521A511E8A41160000E00126013705E0802252059A1812780299CA54059A64 -:4027800001339A42DDD10024A6423FD08023C8265B05ED182800FFF715F804000120FFF73FFBA423A422DB032340D203934203D1013E002EEED128E0394B9C4204D1FEF71E -:4027C000FDFF384B0400F8E70120002C1ED1C82608A92800FFF730F804000120FFF720FBA423A422DB032340D203934203D1013E002EEDD109E02A4B01209C4206D1FEF780 -:40280000DDFF284B04009842F9D00120264A029B944663440293002C02D1059D88E70024002801D0FFF706FB00210320FEF7BCFB0028F9D1FFF702FF002805D0019B022B9B -:4028400002D11800FFF740F9FFF700FF002805D0039B002B02D11800FFF7A6F9134B9C4207D0134B9C4204D00020844202D0114800E0114889239B009D44F0BDDCFDFFFFEA -:40288000FFFFFF0F00001010FFFFFF1300800014FF070016000A0016000026401CFF0000010050000200500000FEFFFF0200520006005200130016000100160010B50A0031 -:4028C000002807D0FA23FF33994203D80249FFF7D9FE00E0014810BD0708001601001600002070470020704710B5FFF799FA10BD10B5FDF7FCFD074B1B681B6800229A5E9D -:40290000002A05DB1F231A401E3B9340024A136010BDC046801E000800E100E010B5FDF7EAFD094B1B681B6800229A5E002A09DB1F231A401E3B9340044AD367BFF34F8FCA -:40294000BFF36F8F10BDC046801E000804E100E0A023034ADB00D058032318407047C04600002640024B034AD058C00F7047C0461C0500000000264010B5FEF7E5FD10BD77 -:4029800010B5FEF731FD10BD10B5FEF723FE10BD10B5FFF7F3FB0220FFF782FB094C0A4923681868FEF716FA23681B6800229A5E002A05DB1F231A401E3B9340034A13600A -:4029C00010BDC046801E0008B120001000E100E00420704710B5FFF7B8FA10BD10B5FFF7B8FA10BD10B50021FFF7C8F810BD000002B4714649084900095C49008E4402BCBF -:402A00007047C046002243088B4274D303098B425FD3030A8B4244D3030B8B4228D3030C8B420DD3FF22090212BA030C8B4202D31212090265D0030B8B4219D300E0090A03 -:402A4000C30B8B4201D3CB03C01A5241830B8B4201D38B03C01A5241430B8B4201D34B03C01A5241030B8B4201D30B03C01A5241C30A8B4201D3CB02C01A5241830A8B42AC -:402A800001D38B02C01A5241430A8B4201D34B02C01A5241030A8B4201D30B02C01A5241CDD2C3098B4201D3CB01C01A524183098B4201D38B01C01A524143098B4201D320 -:402AC0004B01C01A524103098B4201D30B01C01A5241C3088B4201D3CB00C01A524183088B4201D38B00C01A524143088B4201D34B00C01A5241411A00D20146524110462E -:402B00007047FFE701B5002000F0F0F802BDC0460029F7D076E7704703460B437FD4002243088B4274D303098B425FD3030A8B4244D3030B8B4228D3030C8B420DD3FF2267 -:402B4000090212BA030C8B4202D31212090265D0030B8B4219D300E0090AC30B8B4201D3CB03C01A5241830B8B4201D38B03C01A5241430B8B4201D34B03C01A5241030B23 -:402B80008B4201D30B03C01A5241C30A8B4201D3CB02C01A5241830A8B4201D38B02C01A5241430A8B4201D34B02C01A5241030A8B4201D30B02C01A5241CDD2C3098B4221 -:402BC00001D3CB01C01A524183098B4201D38B01C01A524143098B4201D34B01C01A524103098B4201D30B01C01A5241C3088B4201D3CB00C01A524183088B4201D38B007B -:402C0000C01A524143088B4201D34B00C01A5241411A00D201465241104670475DE0CA0F00D04942031000D34042534000229C4603098B422DD3030A8B4212D3FC228901BF -:402C400012BA030A8B420CD3890192118B4208D3890192118B4204D389013AD0921100E08909C3098B4201D3CB01C01A524183098B4201D38B01C01A524143098B4201D3C7 -:402C80004B01C01A524103098B4201D30B01C01A5241C3088B4201D3CB00C01A524183088B4201D38B00C01A5241D9D243088B4201D34B00C01A5241411A00D20146634601 -:402CC00052415B10104601D34042002B00D54942704763465B1000D3404201B5002000F005F802BD0029F8D016E770477047C046002B11D1002A0FD1002900D1002802D090 -:402D00000021C943081C07B4024802A14018029003BDC046D9FFFFFF03B4684601B5029800F050F8019B9E4602B00CBC7047C046F0B54F464646C0B41604360C99463300C8 -:402D400005042C0C070C150C63437E436F4365431C0CAD1964199C46A64203D980235B02984647446346250CEF191D044B464A4343432D0C240464199918C91920000CBCA3 -:402D800090469946F0BDC04670B500220C4B04000D0001F05DFA002804D12000290001F0B5F970BD064B00222000290000F05AFE01F0ACF980231B069C466044F1E7C046E0 -:402DC0000000E041F0B54D46564644465F46F0B4924683B004000D0099468B422FD82CD04946504601F05CFA29000600200001F057FA331A9846203B9B4600D574E053461A -:402E00005A4693401F005346424693401E00AF4229D826D05B46A41BBD41002B00DA79E0002200230092019301235A4693400193012342469340009319E08242D0D900221A -:402E40000023009201930C9B002B01D01C605D600098019903B03CBC90469946A246AB46F0BDA342D6D900220023009201934346002BE8D0FB0772081A4346467B080EE0D4 -:402E8000AB4201D1A2420CD8A41A9D41012024196D410021013E24184D41002E06D0AB42EED9013E24196D41002EF8D15B460098019900196941002B22DB2B005A46D34044 -:402EC0002A004446E2401C005B461500002B2CDB26009E40330026004746BE403200801A994100900191AEE7424620239B1A5246DA40414613004A468A4017001F4382E7AB -:402F0000424620239B1A2A0046469A402300F3401343D5E74246202300219B1A0022009101920122DA40019282E74246202326009B1ADE402F00B446974066463B003343D8 -:402F4000C9E7C046F0B556464D4644465F46F0B41D000E034C00CB0F87B0070092468146360B640D98466AD06D4B9C4235D08022430F12041343F6001E43C3009946694B51 -:402F800000279C460023644402932B0368001B0BED0F51469B46400D009500D178E0604B98426CD05B46DA004B0F802109040B4313439B465346D9005A4B9C4600236044E4 -:402FC0004246201A6A40924601901F430F2F00D9B0E05548BF00C0598746374300D088E0002399460233082700260293CDE74346B34649460093029B009A9246022B00D07A -:40300000BFE1002153460122002689461A40444B002136030C0D2405360B2643434C1B0526401E437600D207760816434846310007B03CBC90469946A246AB46F0BD330077 -:4030400003434FD0002E00D1BCE1300001F00AF903000B3B1C2B00DDADE11D220100D31A08393A008F408E40DA40B9461643304B00279C46002360444442029385E753460E -:403080005A4613432CD1002300219B46023397E70B4320D05B46002B00D19EE1584601F0E1F803000B3B1C2B00DD8FE102005946083A91408B461D21CB1A5146D9400B0043 -:4030C00059460B4351469B469140194B9C4660444042002374E7002300219B4601336FE703236DE70023994601330427002602934BE703230C27029347E70122D51A382DA6 -:4031000000DCB0E153461A4000210023002689467EE700238026994600223603004B77E7FF07000001FCFFFF40510010FFFF0F80F30300005E4500D972E100D16DE1019B36 -:403140004D46013B01930023340002935B461E020B0E1E430B020393330C994633041B0C494620000093FFF74DFC009B370043430600494620009846FFF7CAFC2C0C090439 -:403180000C43A04509D9E419731EA74200D95CE1A04500D859E1023EE4194346E41A49462000FFF72FFC0300009A80465343494620009B46FFF7ACFC2A040904120C0A4314 -:4031C00093450DD94346D219013B974200D93AE1934500D837E102235B429C46D219E0445B46D21A4346360433439B460399180C0B0C1D00059309045B46090C0C001B04F8 -:403200001B0C4443049159436B4368431B190D0CEB189C4203D980246402A44660441C0C09041B04090C20185D18824200D2DEE000D1D7E0161A029B9C465D1BAC459B41CE -:403240005B42F61AB74200D106E149463000FFF7D9FB009B04004343494630009846FFF757FC2E0C09040E43B04509D9F619631EB74200D9F3E0B04500D8F0E0023CF619CE -:403280004346F31A494618000293FFF7BBFB009B06004343494602989846FFF739FC2D0409042D0C0D43A84509D9ED19731EAF4200D9D6E0A84500D8D3E0023EED192404A4 -:4032C000210043463143049E059A3000ED1A0B040C0C1B0C58436643534354439A19030C9B189E4203D980225202944664441A0C00041B04000C14191B18A54250D34DD0F4 -:4033000001231943964A019B94466344002B00DCF3E64A0709D00F220A40042A05D00A1D8A42894149428B4411005A46D20108D55A468C4B1A4093468022D2009446019B7C -:403340006344894A934200DD5BE65A46C908500708435602514601225B058146360B5B0D0A4055E680231B031E4211D05A461A420ED15E461E433603360B2A0089467B4B4B -:4033800046E6032B00D1E1E0012BBBD11A40BBE61E433603360B4246744B39E6002BB1D07D194A1EAF4252D91100A542A8D1039A9A42A5D1A6E703003E00283B9E400023D5 -:4033C000994654E600F04EFF203041E603005246283B9A400021934677E6504600F042FF20305EE6029B0026AB4200D323E7039E0299B44661448846B045B6415B467642FB -:40340000F619B218013B0291974213D290424FD800D18EE0161A9B460DE7894500D28EE674084B46F60735005B081D434B46DB0702938BE69742EDD10399029CA142E5D9E8 -:403440003E1A9B46F7E69846CAE61E00A5E6AC423ED874D0110053E70121494252E71C000EE71E002BE71F2D3CDC20230A0058465B1B9840EA4099400243481E81415E4694 -:403480001143EE404B0709D00F230B40042B05D00B00191D99429B415B42F61833023CD55346012200211A40002601238946AFE502235B429C46039CE344A446029B634479 -:4034C0009846A045B6417642F6190293B218B1E603988A1E41008142B6417642F619AD19039161E71F225242D31A5A46DA401300202D29D040225846551BA8400143481ED7 -:40350000814107200B4318400026002809D00F2200261A401900042ABBD10B0070077602360BDB0803439946012253461A4000236EE502998D42BBD89B4600267BE6039882 -:403540009842C5D3110032E70020D7E780265B4636031E433603360B009A8946034B57E5FF030000FFFFFFFEFE070000FF070000F0B55F4656464D464446F0B40D039946E5 -:403580004E002B0B87B00700924680469B46760DCC0F002E69D06D4B9E4235D05B468022DD001204430F13432B439B46C3009846674B00279C460023664401934A461503D6 -:4035C0005000D20F53462D0B400D914600D176E05E4A90426CD080225B0F120413435C4AED0094461D4353460022DB00604449463618701C6140029017430F2F00D9AFE0AD -:403600005448BF00C759BF465B461F4300D088E000239B469846023308270193CEE74946022A6AD0032A00D109E2012A00D0BBE111400022002300259046CCB200212D036B -:403640000A0D12052D0B1543434A1B0515401D436D00E4076D0825434046290007B03CBC90469946A246AB46F0BD034352D05B46002B00D18AE1584600F0F4FD03000B3B24 -:403680001C2B00DD7BE11D22D31A3A0001005D46DA4008398D4013008F402B439B46B8462E4B00279C46002360444642019385E752462A432CD100250023022297E75246D4 -:4036C0002A4321D0002D00D154E1280000F0CAFD03000B3B1C2B00DD46E11D21CB1A51460200D9405346083A954093400D431B4A944660444042002279E7012400220C40A4 -:40370000124B0025904699E70025002301226EE703226CE700239B4698460133042701934CE703230C27019348E700238025984600242D03054B81E75D464346019A6FE786 -:403740005D4643462100019A6AE7C046FF07000001FCFFFF80510010FFFF0F80F30300004246120C91461A0C9446424617044A461B041B0C5A43604690464A464243100071 -:40378000039262461C003F0C7A437C4342440192220C9246019A5244904506D98246802040028046C24450460390100C049048462404240C1204121905922A0C2D042D0C38 -:4037C00068432C00824648467C4350438146200C8046574357444744BA4503D9802040028046C144380C3F04B84648442404240C01900498A044404404905846000C814646 -:4038000058460404200C8246070048465F434C464343604660436446834650464443380C8446E4186444A34203D980235B029C46E34448463F04230C3F0C2404E41957463D -:4038400068436F4384464D46504655434243380C814662444A445B44944503D9802040028446654403983F04834604983F0C8446E344C345804140428246100484460198EA -:40388000674484466744A344BC46A345A4419946D44464428742BF41D4458041E144A04699459B417F424042C8440743120CBA18A045A4415F423B0064422343D71843467A -:4038C0007D19DB0D6D021D435B465A02059B1A43531E9A415B46DB0D1A4343465B021343EA0107D501225C0813402343EA07029E13436D08574AB218002A4BDD580709D0BB -:403900000F201840042805D0181D98429B415B42ED180300E80104D54F4A15408022D200B2184E48824200DDE7E60124DB08680718436D02530580462D0B5B0D0C407DE6CF -:40394000802259461203114208D0154206D115432D0398462D0B4C46414B6FE65D4615432D032D0B3E4B69E603005546283B9D400023BCE6504600F075FC2030A8E60300D1 -:40398000283B9F400023BB46984689E600F06AFC203073E60124A61A382E07DD00220C4000230025904649E6029EA3E71F2E20DC20222C001800921BF040944093400443A7 -:4039C000581E83411C43F540630709D00F232340042B05D023001C1D9C4292415242AD182B021FD5012400220C4001230025904624E61F202C004042821AD440202E1CD003 -:403A00004022961BB5402B43581E83410720234318400025002809D00F2200251A401C00042AD8D1230068076D022D0B0124DB08034398460C40002300E60025E3E78022DD -:403A40000124120315432D0398462D0B0C40044BF4E5C046FF030000FFFFFFFEFE070000FF070000F0B557464E464546E0B40E001100F20F9246C500420F18033703740020 -:403A8000400A4E0F7F0A3043CF4E17435A00640D520DDB0FC900B24200D1E5E001267340A61AB446534500D1AFE0002E00DC0DE1002A3AD103000B4300D0E4E06B0709D09C -:403AC0000F232B40042B05D02B1DAB42AD416D427F191D003B0200D488E0BB4B01349C4200D110E13A00B94B51461A4001235007ED08520264050543120B640D0B400021AC -:403B0000280012030D0D120B64052D0515436208AF4CDB072C401443640064081C4321001CBC90469946A246F0BDA74B9C42C5D080231B0418436346382B00DDFDE01F2B10 -:403B400000DD30E1624620239B1A02009A40664690460A009940F24046464B1E99413243114363460200DA40691A8D429B410D00BA1A5B42D71A3B0235D57A02530A98464C -:403B80004346002B00D1C4E0404600F06BFB0300083B1F2B00DDC5E020222900D21A4746D1409F400A009D403A439C4200DDC0E01C1B631C1F2B00DDE4E02021140028003D -:403BC000C91AD8408C408D400443DA40681E854117002543002471E7424663461A4300D14CE2674645466B0700D069E7012351467807ED08FA080B40054373498C4238D0DC -:403C000012036405120B640D79E7002E00DC9AE0002A47D06C4A944200D14FE78022120410436246382A00DC08E10143481E81410022C9B24919D219A942BF410D007F42D7 -:403C4000BF183A0200D442E15F4A0134944200D14EE101205D4A69083A4028400843D507054357089A4629E706000E4300D017E714E72900114300D1F9E1802109030A436B -:403C80001203120B3BE701235B429846C4446346002B72D1691A8D429B413F1A5B42FF1A0D0068E702000A4300D107E7012252429046C4446246002A00D0E6E06918A942E2 -:403CC000B6413F187642F7190D00BAE7002E00D080E0621C5205520D012A00DCF9E06A1A91464D45B6413A1A7642921B9046120200D499E04D1BA9428941C71B49427A1A9C -:403D000090469A463CE752460123002513400022F5E6280000F0A6FA20300300083B1F2B00DC39E72A002838824000259C4200DC3EE7264FE41A1740C0E60143481E8141B9 -:403D40000022C9B210E7002E00D0F1E0621C94465205520D012A00DCA0E01B4A944500D1C5E06918A94292413F185242D2194908D5070D4357086446A0E6134B9C4200D06A -:403D8000D9E69BE611001F3CE1400C00202B00D180E04021CB1A9A4015436A1E95410027254300241FE763460200203BDA406346202B71D0402366469B1B98400143481E83 -:403DC000814111430022CFE6FF070000FFFF7FFFFFFF0F80002C48D0CA4CA24200D1A2E07442A1468024240427434C46382C00DDDBE01F2C00DD44E14E462024A41B3E00B3 -:403E0000A640A246B0464C462E00E640B4464646644626435446A5406C1EA54134002C434D46EF400D1B28E04A4643464D461A4300D0A5E6002300240025DEE61F2A5ADCA8 -:403E400066462022921B060096409146B04662460E00D640424616434A4691404A1E9141020060463143C240E4E63C002C435AD0F443A146002C52D14D1BA9428941C71B8D -:403E800049427F1A14009A4675E69E4A944200D0C7E613E600227FE700208FE7002C00D0C8E03B002B4300D10FE103000B4300D104E66918A9429B413F185B42DF193B02B2 -:403EC00000D41AE1904B0D001F406446F6E59A4689E63A002A43002C5CD1002A75D102000A4300D1CAE007000D009A46E6E564460022002581E662460600203AD6406246C1 -:403F0000B046202A00D1B7E040226646921B904001434246481E8141114300228AE6794CA24200D061E707000D0014009A46C5E5002C41D13C002C4378D0F443A146002C86 -:403F400020D0704CA24271D04C46382C00DDB2E01F2C00DDBCE02026341BA2463C005646B4404E46A0462C00F440A446444666463443A4465446A54064466E1EB541254390 -:403F80004C46E7406D188D4289413F184942CF19140056E6002A2FD102000A4300D184E007000D009A46574C88E53D436F1EBD41ECB200270D1B60E7524CA24236D07442E1 -:403FC00080263604A1463743BEE702000A4300D174E56A1A90464545B6413A1A7642921B9446120200D4F7E54D1BA9428941C71B49427F1A9A4661E502000A433AD0ED0899 -:404000007C072C438025FA082D032A4208D0C7082F4205D145072C003A009A46C9080C43670FD200E5001743364C47E507000D00140043E53A002A4343D002000A4319D034 -:40404000ED087C072C438025FA082D032A4207D0C6082E4204D147073C003200C9080C43D700620FE50017439A46264C26E50022002544E5234C21E5002049E700230025EF -:40408000BBE54C463E00203CE6404C46B446202C31D040244E46A61BB7403D436C1EA54164462C4300270D1BE7E6802200231203144C0025A1E53D436F1EBD410027EDB2AA -:4040C00060E707000D000F4CF8E407000D00F5E44E463C00203EF440A0464C46202C0ED040244E46A41BA7403D436F1EBD4144460027254346E70027CFE70D0073E50027E5 -:40410000F2E7C046FF070000FFFF7FFF0B0330B5134D1A0B4B005B0DC90F0024AB4211DD104CA34210DC8024640322430E4CE41A1F2C0CDD0D48C31ADA4013005C420029CD -:4041400000D11C00200030BD094BCC18FAE7E040084CA44663449A4013000343EEE7C046FE0300001D0400003304000013040000FFFFFF7FEDFBFFFF70B5051E28D000F017 -:4041800071F8154B154A1B1AD21A1F2A16DD2C00134A0025D21A94405A052403240B520D002124030B0D240B1B0523430D4C1205234013435B002800590870BD0B212C0051 -:4041C000081AC440954024035A05240B520DE7E700220024E4E7C0461E0400003304000013040000FFFF0F808446101C62468C46191C634600E0C0461FB500F001F90028B4 -:4042000001D40021C8421FBD10B500F055F84042013010BD10B500F0F3F8002801DB002010BD012010BDC04610B500F0E9F8002801DD002010BD012010BDC04610B500F069 -:404240007BF8002801DC002010BD012010BDC04610B500F071F8002801DA002010BD012010BDC0461C2101231B04984201D3000C10391B0A984201D3000A08391B09984244 -:4042800001D30009043902A2105C40187047C0460403020201010101000000000000000010B5002903D1FFF7DDFF203002E0081CFFF7D8FF10BDC046F0B55F4656464D46AD -:4042C0004446F0B41F035C00DB0F9A46194B0E034D00C90F8046360B6D0D8B4691463F0B640D9D4219D0134B9C421BD00123A54206D018003CBC90469946A246AB46F0BDAF -:40430000BE42F6D1C845F4D1D34510D0002DF0D1304303005A1E9341EBE7310001230143E7D1E0E73A430123002AE2D1DEE70023DFE7C046FF070000F0B55F4644465646AA -:404340004D46F0B41F033C0B2C4F0E034D00A3465C008446360B6D0DC90F9046640DDB0FBD422BD0254FBC422ED0002D0ED130430700814678427841002C17D15F463A4391 -:4043800014D14B460020002B0AD006E0002C02D15846024301D099421AD00123484218433CBC90469946A246AB46F0BD0028F2D058425841012240421043F1E7370007435A -:4043C000D0D002204042EBE75F461743CDD0F8E7A542E2DC05DB5E45DFD808D000205E45DED248424841012340421843D8E7C445D3D80020C445F4D3D2E7C046FF070000C6 -:40440000F0B55F464D4644465646F0B41C03240BA4462F4C0F034D005E00C90F80463F0B6D0D8B469146760DDB0FA54220D0284CA64222D0002D12D1384344424441002E05 -:4044400020D0002C0DD05C42634101245B421C4320003CBC90469946A246AB46F0BD002E17D05B4519D05B465C4201231C43EFE7390002240143EBD1D9E761460224114317 -:40448000E6D1D7E761460A43DBD100240028DFD0E9E761460A43E4D1E5E7B54203DD01225C421443D4E7B542CDDB6745DBD809D000246745CCD259464C4261410124494239 -:4044C0000C43C5E7C845CED80024C845F3D3BFE7FF07000030B50024A24208D0035D651C0C5DA34201D0181B02E02C00F4E7002030BD002310B59A4203D0CC5CC454013372 -:40450000F9E710BD03008218934202D019700133FAE77047F8B5C046F8BC08BC9E467047F8B5C046F8BC08BC9E4670470000000001B40248844601BC604700BF990200081A -:4045400003000000010000000100000000000000050360000400000001000000000000000100000006046000080000004C1B00086108001008000000010000000200000063 -:4045800002000000080800030900000001000000000000000300000009090003080000006C1B0008710800100A0000000100000004000000040000000A0A000C0B00000066 -:4045C0000100000000000000050000000B0B000C100000008C1B0008510800100A0029000300000003001800030000001920010219010200000000000C00000000000000B3 -:4046000000000000006800000000000000000000000000000000121200000000000000000000000000000000000000BA0000000000000000000000000000000000001D1DFA -:40464000000000000D0000000800000000020000000000000000000000000000000000000000000000000000000000000B0000000000000064000000000000002002000092 -:404680007C01000031010000090901120C00FF0380ABCDABCD80409C1B04041BFFFFFFFF000000000410080007070400F216FBE0FBE01F60427EF56D720096BE209000000F -:4046C00010502604060037D7F401FA00960064004B0032001E00140003040506020D1100F1D9001055D90010A7DF0010A5DA001057DB001053DF00106BDF00102DE000101A -:40470000D1DB001039DC001015DE001043DE00107BE0001041DF00100FE000100FE000100FE00010E9DE001091DE0010D5DE001075150110811501104D2501103526011082 -:4047400041260110A1DA0010EFD90010EBDF001055DB00108FDB001063DF001085DF001079E0001035DC001091DC00102FDE001069DE0010E7E000104BDF001079E000100F -:4047800079E0001079E0001039DF001079E0001079E0001079E0001079E0001079E0001079E0001079E00010DFF50010E7F50010E3F50010DDF50010BBF50010B7F500100A -:4047C000D5F50010D3F50010AFF50010B3F50010EBF50010D7F50010D1F50010EFF50010EFF50010ADF50010DBF50010CD0C011081100110450E0110F10B011001FF001072 -:40480000B5FB001085060110C901011021F7001085F70010D9110110110A01106101011035FB001011060110F15B0010C10A011079120110051601105117011025180110C4 -:4048400041140110D51201108D150110B5130110DF130110EF130110F1130110F51301100FE00010E1130110EB130110E91301107D29011035230110E928011099280110D6 -:40488000352901104D26011059250110F1250110B526011025BE0010572301104D2301105323011051230110552301104F2301100FE000100FE000100FE00010F9AC00109A -:4048C000453C0110273C0110273C0110273C01105D3C01103D7B0110273C01102D7B0110457B0110357B0110DF400110D74001104140011039400110373C01101F3C011034 -:40490000153C01103B3C011031400110614001102F3C011059400110B9400110273C0110694001105140011049400110273C0110653C01106D3C0110753C01102B3C0110A5 -:404940002B3C0110453C0110273C0110273C0110273C01105D3C01103D7B0110273C01102D7B0110457B0110357B0110DF400110D74001104140011039400110373C0110A7 -:404980001F3C0110153C01103B3C011031400110614001102F3C011059400110B9400110273C0110694001105140011049400110273C0110653C01106D3C0110753C011031 -:4049C0002B3C01102B3C0110696401105D640110756401102B3C01102B3C0110096101104561011015610110396101102D61011021610110516101105D610110516401104F -:404A0000B5660110B9660110C56601109D660110A96601102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C011082 -:404A40002B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C01102B3C011069610110A7570110BC -:404A8000555601105556011055560110D957011069570110555601104D5701101958011063570110F3570110E9570110D75501105556011055560110555601105B55011014 -:404AC0003757011081550110B9570110DF560110EF56011069560110555601102F580110A556011097560110555601102357011067580110555601105556011055560110FA -:404B0000F9630110ED63011005640110ED5601108756011055600110916001106160011085600110796001106D6001109D600110A9600110E1630110F1650110FD6501103C -:404B400009660110D9650110E5650110555601105556011055560110555601105556011055560110555601105556011055560110555601105556011055560110555601107F -:404B8000555601105556011055560110555601105556011055560110555601105556011055560110555601105556011055560110B5600110D75A0110055A0110055A0110DD -:404BC000055A01101B5B0110815A0110055A0110C95A0110C95A0110735A0110315B01101F5B0110815901107D590110615A01101559011007590110075901101959011072 -:404C0000FB5A0110355A0110495A0110095A0110055A0110655B0110215A01100D5A0110055A0110655A0110815B01107D5B0110055A0110055A01102563011019630110E5 -:404C400031630110A95B0110035901109D5F0110A55F0110B15F0110BD5F0110A55F0110A55F0110C95F0110D55F01100D630110FD6401100965011015650110E56401109E -:404C8000F1640110055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110FE -:404CC000055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110055A0110E15F011008000000060F0020200107021900000007070E0562 -:404D0000020220001C1202000103000E030600040040270700000707010200020307030400000000000000000000000000000000000000000000000000080000A757011057 -:404D4000555601105556011055560110D957011069570110555601104D5701101958011063570110F3570110E9570110D75501105556011055560110555601105B55011051 -:404D80003757011081550110B9570110DF560110EF56011069560110555601102F580110A55601109756011055560110235701106758011055560110555601105556011037 -:404DC000D75A0110055A0110055A0110055A01101B5B0110815A0110055A0110C95A0110C95A0110735A0110315B01101F5B0110815901107D590110615A011015590110B3 -:404E0000075901100759011019590110FB5A0110355A0110495A0110095A0110055A0110655B0110215A01100D5A0110055A0110655A0110815B01107D5B0110055A011014 -:404E4000055A011008000000060F0020200107021900000007070E05020220001C1202000103000E032000800000C00000000004000000A822000000000000040000F7FF90 -:404E8000FF7F0000003000000000000000000000000000000000000000000000000000000000000000000000355E0110ED5F0110555F0110955E0110FB5F01107D5F011022 -:404EC000655E011009600110615F0110935E01100D600110795F01107D5E0110FB5F0110715F0110675E0110FB5F0110695F0110AB5E011019600110855F0110B15E01101F -:404F0000296001108D5F011055560110055A01102B3C011055560110055A01102B3C011055560110055A01102B3C011055560110055A01102B3C011055560110055A01101E -:404F40002B3C011055560110055A01102B3C011055560110055A01102B3C011055560110055A01102B3C0110BF5E011041600110955F011055560110055A01102B3C011044 -:404F800055560110055A01102B3C011055560110055A01102B3C011055560110055A01102B3C011055560110055A01102B3C01107961011055630110FD6201107761011054 -:404FC00049630110F56201109F610110A163011005630110756101103D630110ED62011055560110055A01102B3C011055560110055A01102B3C011055560110055A011081 -:405000002B3C011055560110055A01102B3C011055560110055A01102B3C0110A16401105D65011000000000AF64011071650110BD270110BD6401109B650110ED2701105F -:405040008164011021650110412401108F6401103F6501105D24011030303031423830303031303230333034303530363037303830393041304230433044304530463130A4 -:40508000313131323133313431353136313731383139314131423143314431453146323032313232323332343235323632373238323932413242324332443245324633307A -:4050C000333133323333333433353336333733383339334133423343334433454142000026002B00300036003C0043004B0055005F006A00770086009600A800BD00D400CC -:40510000EE000B012B014F017801A601DA01130254029D02EE024A03B1032404A5043605D9058F065C0742084409650AAA0B160DAF0E79107C12BD1445171C1A4B1DDE20A6 -:40514000343100100230001008310010F82F0010083100101231001008310010F82F0010023000100230001012310010F82F0010EE2F0010EE2F0010EE2F001064330010A0 -:405180006037001020360010203600101E36001038370010383700102A3700101E360010383700102A370010383700101E3600104037001040370010403700104039001054 -:4051C00000000000F8B5074600256846058078683C1D2D492E46002807D06268002A06D0800702D1207A800701D00D4649E0FDF7CFFBFDF793FBFDF7EBFB00F029F9002855 -:405200003DD1788C0006C00F00F0A2F905460004000C34D11D49084600F0A4FE0004000C2DD12289A17A2068194C002806D02060A280E68021810021FFF764F9684601F0DA -:405240001BFC054613486B460078E2888000001DC1B21B88A088D418A04206D3C01A801A80B201F09BF9044600E00B4C00F044FD002C04D100F07CFB08490120087000F03D -:40528000F5F82846F8BD00000100160025540010901E0008CC1E0008FFFF00006401000810B503480078012801D101F013F810BD6401000810B5FDF74BFB032801D100F086 -:4052C000FFFD00F0FDF901F059FC00F07DFE02490020087010BD00006401000800487047901E000870B5044600208A0703D08A07920F891A091D084B89B2DA889E885518D8 -:40530000B54206D81D68AA182260DA885118D98070BD024870BD0000901E000803001600004870479C1E000810B501F033FB10BD10B501F039FB10BD10B501F03DFB10BD54 -:405340000549002806D0054981800521017000214170817008467047010016008203000010B5FFF79DFF10BD10B501F02DFB10BD10B501F03BFB10BD38B505460020694608 -:405380000880002D09D0284601F03CFC0446684601F066FB002C02D015E00C4838BD01F01DFB2846FFF70EFF04000CD1284601F0B1FB040007D1FDF7CBFA032803D100F058 -:4053C00055FD00F093FD204638BD00000100160038B50446002069460880002C08D06189090A05D1617A102902D8E179102901D90A4838BDA0816946204601F0CFFB054626 -:405400006946A08909884018A081002D04D1102221460348FFF76DF8284638BD010016009C1E00087047000010B5084900200978002909D005F052FE044605F015FD201ACD -:4054400080B281004018C00810BD00006C01000810B5FCF793FE442202490348FFF749F8002010BD84460010AC1E000810B5FDF73FFA10BD10B519461046044C01F0C4F9CB -:40548000002800D00024204610BD0000FFFF000010B501F0E5F910BD10B501F0CBF910BD010010B5044806D0044A01201070002007F064FD002010BDFFFF00006C01000848 -:4054C00070B50024034D20462C7007F085FD2C70204670BD6C01000801480078704700006C01000870B5591C89B24C080B4D64000021451906E028685054000A5618891C6C -:40550000707089B2A142F6D3D80705D0D0182038D15CC47FD454C17770BD000000103C4030B50A4C002100195B1E07E054186478555C240225430560891C89B29942F5DBDB -:40554000994201D1515C016030BD000000103C40F8B50746FF2000F0F3F9164EFF2070701548164900684018406B0024410F301D0125022901D0457000E0447005700D4882 -:40558000801C4470384612F03DFB070010D112F07BFB3070012000F0D3F912F07FFB68460470447012F0E4FE6846457012F0E0FE3846F8BD6D0100086801000840F03D40C6 -:4055C000F0B50021094D5B1E08E0441924685718260A7E705454001D891C89B29942F4DB994202D1401900685054F0BD00103C4070B500210A4E5B1E09E0541864782502AE -:40560000545C2C4385192C60001D891C89B29942F3DB994202D1515C8019016070BD000000103C40F0B50599091FCFB200217E1E0AE054186478555C24022543144C0419D6 -:405640002560001D891C89B2B142F2DBFC0710D01C78515C24020E4A0C4381180C609C785D782102001D294384182160001DD9780BE059781A7809021143054A84182160B9 -:40568000D978001D9B780902194380180160F0BD00103C4038B509480024447012F0FEFA69460C704C70684612F062FE012069464870684612F05CFE002038BD6F010008AA -:4056C00010B501F08BF90A480078012805D1FCF73DFD012809D012F02FFF05490020891E0870062000F02CF910BD12F00FFFF4E76F01000810B50B46062816D006DC01281B -:405700000FD0032801D1FFF7C5FF10BD0B2811D0112813D01228F8D11146184612F018FA10BD0020FFF714FF10BD1146184612F09DFD10BD04480078107010BD1146184663 -:4057400012F016FA10BD000071010008F8B5184D184E28688019846AE00719D001F07AF90127012811D1002001F046FA052000F0E7F81149FF204870881C4078002804D10B -:4057800028688019416B39434163286880198762E0050CD50848801C0078052802D1042000F0CEF8FF202968013089198862F8BD6801000840F03D406D01000805490028B2 -:4057C00005D005494A784270097801700021084670470000010016007101000838B504000C4816D06178012913D801F0F7F8607812F074FD207000280AD1694608706846BD -:4058000000F090F869460878012801D104202070002038BD0100160010B5094900280CD00278082A09D24278042A06D205494A700078087012F032FA0021084610BD000022 -:40584000010016007101000810B504460448032C05D801F0C3F8204612F04CFD002010BDFFFF160010B50400054808D06178012905D801F0B3F8204612F07AFD002010BD9C -:405880000100160010B5FCF761FC0122084992040028084B086804D0C018016A1143016210BDC018016A9143016212F04FF910BD6801000880F03D400949087805280ED15F -:4058C0004A780848084900684018002A03D1416B490849004163C16A01221143C16270476F0100086801000840F03D4001480078704700006F01000802484078022800D09F -:40590000012070476D010008012807D0032807D0042803D0052803D0FF207047012070470220704710B5040002D012F065F9207010BD000001494870704700006F01000808 -:4059400010B50446FCF7EAFF062C01D9FF2C01D102480470FCF7CCFF10BD00006F01000801494870704700006D010008002070471CB5002469460C70022001902346054AE1 -:40598000054800F0F5F904480068401C00D1034C20461CBDE559001074010008FFFF00003EB50F4A01460D4800230124126800290BD0012908D1684600930481438169469A -:4059C000104600F0D0F980B23EBD68460093048143816946104600F0C1F9F4E7FFFF00007401000810B50089002100280BD0012802D0052807D103E000200DF061FD02E02A -:405A0000084600F0F5F8002010BD000010B50248006800F041FC10BD74010008FFB581B01F00154606463CD000F0D8FFFCF776FF2F49304B4878401CC0B2044606E02201A6 -:405A4000D218127A202A2AD0641CE4B2202CF6D3002406E02201D218127A202A1FD0641CE4B28442F6D32024202C1AD03470029821490202120A200602432001C618726042 -:405A80001F501B4869180078009120280CD0FFF7CBFC0746BD4223D3281AF0601BE04C70E2E7164805B0F0BD13484042854207D9FFF7F6FC014611488142F3D0009807E084 -:405AC000A8B2FFF7EDFC01460C488142EAD00020F060074804703472FCF70AFF0020E1E7FFF7EEFC781B012100F01EF9DCE7000078010008F01E0008C063FFFFFFFF000083 -:405B000070B5074CA5780E2D07D2FFF787FF002802D1A178491CA17070BD024870BD000078010008FFFF0000F8B520280BD2234D07017C19207A202805D000F04FFFE06877 -:405B4000002802D031E00120F8BDFCF7E7FEFFF76BFC012100F0E8F80020184EE060FFF7AFFCFCF7C5FE00F0ADF80546202819D0FCF7D4FE280186191148F168814205D90F -:405B80000646FFF78DFC0021304604E088B2FFF787FC0021F06800F0C7F8FCF7A9FE0948057002E00749202008702020034920720020C8516060E060F8BD0000F01E000858 -:405BC000409C00007801000810B5074CA178002908D0FFF7A9FF002802D1A078401EA070002010BD014810BD78010008FFFF0000F0B500258BB02E46089500F0EFFE00235F -:405C00006A4618462C49040161180C7A202C02D0C96800291DD000211154401CC0B22028F0D300240993099800280FD06846005D00283BD020482101081806684168089119 -:405C400000210160202241600272C160002D04D028E0012111540B46DFE700F033F80546202819D0144829010818C7681348874207D90021074600F057F8FCF74FFE3846A8 -:405C800006E00021384600F04FF8FCF747FEB8B2FFF706FCFCF72CFE094805700998002808D00125002E01D00898B047641CE4B2202CB8D30BB0F0BDF01E0008409C000007 -:405CC0007801000830B50023DB432020094C00210A011219157A202D06D0D268002A03D09A4201D808461346491CC9B22029EFD330BD0000F01E000830B50020084C05463A -:405D00002023020111190B72A550401C4D60C0B2CD602028F5D303480370457030BD0000F01E00087801000830B50B4D00231A015219147A202C0AD0D468002901D02418C6 -:405D400004E0844201D9241A00E00024D4605B1CDBB2202BEBD330BDF01E000810B50EC900F0B2FA10BD10B50EC900F0E9FA10BD38B50024E443054600290AD0052000909D -:405D80004B68097804A000F043FA2860401C00D00024204638BD00007461736B000000000EB5002005216A46009011815081034869460068FFF7D7FF0EBD000074010008D6 -:405DC00010B51D481D4C0178491E0170FF206070FCF7C8FD002825D0FCF72AFC01460020FCF7CAFDFCF7D0FD411C14DB80B2012811D862881248824208D0124B0021601C97 -:405E0000FFF77EFE002802D10220207010BD0D2010F086FE10BDFF20F530FCF765FD00F065F810BD0548084B02220021401CFFF767FE0028EBD110BD7A0100087C010008F0 -:405E4000FFFF0000855E0010C15D001010B503480078042801D100F049F810BD7C01000801480078704700007C010008044800210170FF214170FF21F53141807047000090 -:405E80007C01000806490878401E087005480178012901D003210170FF214170704700007A0100087C01000801494880704700007C01000801490870704700007C01000886 -:405EC00010B5054C6078FF2803D000F007F8FF2060700020207010BD7C01000810B502484078FFF771FE10BD7C01000810B5FF22043280210820FCF743FD0B4C6078FF28EE -:405F000001D0FFF7EBFF0848084B04220021401CFFF7F6FD002803D00D2010F001FE10BD0120207010BD00007C010008C15D0010C0080A21484380B20849C82801D2084848 -:405F400009E002461923C83A5B019A4201D2400801E0FF20F5304880704700007C010008FFFF000010B50F4A002313600E4A13600E4B18600E4801600E49012008600E49FA -:405F80000860282090600E490C4808600D49143008603C38506000F0C5F800F0F5F9002010BD00009801000880010008AC010008B00100089C0100088C010008182100087D -:405FC00090010008A401000800207047014610B50020002910D0094B1A689C685118A14209D25868196080188A0704D08A07920F891A091D196010BD002010BD8001000861 -:40600000F8B50024164E671E321F3D463168136806E01422624310328A58521C1BD0641C9C42F6D36A1C14D02C461422544322460C3288500C214843FFF7C8FF31680028FC -:4060400008510AD031680020103408517068401C70602846F8BD2546E4E73846F8BD000090010008F3B50026F64381B000281FDB2149096888421BD80299002918D01E4F63 -:40608000142204463F1D54432546396810354859401C0DD0FAF72FFAFCF740FC38682F1F4159C359994205DBFAF721FAFCF720FC3046FEBD214608310091465801590C20F9 -:4060C000704308180C220299FEF713FA0A48761C001D0068C159B14200D100260649009A091D865008684159491C4151FAF7FFF9FCF7FEFB0020FEBD8C010008002803DB64 -:4061000007490968884202D90020C043704704491422091D0968504310300858704700008C010008F0B500200D4A451E0346171F50600FE014260146714314680E1DA35119 -:406140000C461668083433511668083435511468401C635039688842ECD30020F0BD000090010008F3B50026F64381B0002845DB26490968884241D8029900293ED0234FAD -:40618000142204463F1D54432546396810354859401C33D0FAF7AFF9FCF7C0FB3868415900292DD0211D009146580C21005971430F46C1190C220298FEF79BF913480021D1 -:4061C000001D0068761C00590C34C0190160416081600E48001D00680159B14200D100260A49009A091D865008684159491E4151FAF77DF9FCF77CFB0020FEBD3046FEBD4B -:40620000FAF775F9FCF774FBF8E700008C010008FEB504460D4600201E49089E0860471E009001900290002C11D0486885420ED2002A0CD0002E0AD0642E08D808460C30BE -:4062400001681C2068430C18207A002801D03846FEBD0120226020721846FFF7D1FE6060401C13D06681A6810A4827610C3067610179A94200D205710021684601810A464D -:406280002846029B00F05CF82846FEBD00202072DDE700009801000810B5002810DB0949496888420CD807491C220C310968504308184068FFF722FF002801D0002010BD32 -:4062C000012010BD9801000838B50124009400F03DF838BDFEB50027184EFF433D4600240EE01C20316860430818017A002906D04068FFF703FF002801D0254603E0641CBF -:406300003079A042EDDA681C16D01C2130684D434419FAF7F0F8FCF701FB69466068FFF721FF0546FAF7E3F8FCF7E2FA002DD5D1216868468847D1E7FEBD0000A4010008AB -:4063400038B50024009400F001F838BD1FB500220C49541E0A60002811DB496888420ED808491C220C31096850430818406801A9FFF778FE401C02D0002004B010BD20461B -:40638000FBE7000098010008F0B50021114A4D1E174611710C3F0B46BD6016E008461C2460431668041D355114680646235014680836A3551468361DA353044616680A3432 -:4063C000335318301468491C255078688142E5D30020F0BDA401000838B500210091002811DB0F49097888420DDA0D4D04010C3529680859002807D0201D0818694600F0DA -:4064000073F9002801D0002038BDFCF787FA28680F34015D491E0155FCF76AFA009838BDB4010008F7B582B0002502986E1E06602F48D21C024017462E4A2C4610460C38C8 -:406440000178106805E02301C358002B0FD0641CE4B28C42F7D3711C29D03401211D40180191039900F02EF9002820D101E02646F1E72048016820460C300F521D480399A6 -:40648000026820460E3011541A480399026820460F30115403993846484300F0A1F8154900280968085102D00024009011E001251AE01048016801980818009900F02FF9B7 -:4064C000002801D0012502E00098C0190090641CE4B203988442ECD3002D05D10298054906600879401C0871284605B0F0BD0000FCFF0000C0010008F8B50D4600216A4658 -:406500008C461180002839DB23490978884235DA214B04010C3319680A59002A2ED020460C300B5A801C0E5C184670438018954224D3854222D2002006E007465F43BF182F -:40654000AF4206D0401CC0B2B042F6D36046002814D0114E271DC8190C366A46294600F008F900280AD168460088012808D030682946C01900F0D3F8002803D00120F8BD9D -:406580000020F8BDFCF7CAF930680F34015D491C0155FCF7ADF9F3E7B4010008F8B50F46002400F031F8002817D10C4900220B460C334A600EE021011D680E466A501D6804 -:4065C0000C36AA53B61C1D680F31AA551D68641C6A54E4B2BC42EED31A71F8BDB401000800280BD0C01C074A81085068890053884118994203D8936851601818704700201A -:4066000070470000B4010008F8B5064600200F4D009029700C0121466846FEF763FE00280CD129460C3100980860301B001F84B221466846FEF756FE002801D00448F8BD27 -:406640006C800098A8600020F8BD0000B4010008FFFF0000F8B5002827DB19490978884223DA174C05010C342168485900281CD028460C30085A009028460E300E5C401C88 -:406680000E5420682F1DC01900F064F800280CD12068002445590EE0094829460C300068C01900F03CF8002801D00120F8BD00982D18641CE4B2B442EED30020F8BD000093 -:4066C000B401000830B50D4604000BD0A800FFF787FF6060002805D000202570C0436080002030BD012030BD70B50D46040005D0002D03D00220205E002801DA012070BDF0 -:40670000FCF70CF90221615E60688900405828606088401E6080FCF7EBF8002070BD70B50D46040007D0002D05D002212078615E401E814201DB012070BDFCF7EFF86088E9 -:40674000401C00B26080616880000D50FCF7D0F8002070BD10B5040009D0227800216068FDF7D0FE0020C0436080002010BD012010BDF0B500231D46002802D00224045F0A -:406780000AE00120F0BD46689F00F6598E4201D1012503E05B1CDBB29C42F4DA15700020F0BD000001B503480122436811466846984708BD4821000810B50021052010F0E4 -:4067C0005DFA10BD70B50546FCF7A8F80D4C218A002914D0638A8B4209D100206082208201202070A3682A46E068984707E0E0680121C018F9F772FE608A401C6082FCF732 -:4068000077F870BD4821000810B50023084A00280BD0002909D001241470141D0BC413825382F9F74FFE012010BD1370F5E700004821000807B509480378012B01D0002059 -:406840000EBD02230370C16002820021418201216846F9F743FE01200EBD00004821000804480021C160018241820121017008467047000048210008FEB5114C114F089EDB -:40688000099D00280BD0002909D0002A07D0002E05D0002D03D0002B01D01B2B01D93C460CE00096019508F03FFC042802D0052803D003E0034C133400E000242046FEBDA4 -:4068C000FFFF160001001600FEB50E4C0E4F089E099D00280BD0002909D0002A07D0002D05D0002E03D0002B01D01B2B01D93C4606E00096019508F060FC042800D1002489 -:406900002046FEBDFFFF160001001600F0B589B015460F460646144C00F060F8002E20D0002F1ED0002D1CD0102239466846FDF7E0FD1022314604A8FDF7DBFD1021684605 -:4069400010F0DAFB102104A810F0D6FB2B46102204A9684608F000FC1021284610F0CCFB0024204609B0F0BD0100160010B50FF04FFD0AF0A7FC0EF089FC10BD10B50FF074 -:4069800049FE0BF0DBFC10BD10B508F007FE0FF097FB10BD10B50DF089F80FF049FD0AF02BFD0EF07DFC10BD10B50DF07FF80FF043FE0BF0D1FC10BD10B50DF077F808F0AC -:4069C00019FE0FF08DFB10BD10B5022801D100F089FAFEF78BFFFEF797FF10BD10B500F07DFBFEF783FFFEF78FFF10BD10B5FEF77DFF012801D1FEF77FFF10BD10B501886E -:406A00008A0703D08A07920F891A091D0379827B1031534359438BB241888C0703D08C07A40F091B091D447910316143C918438989B2DC0703D092015118103189B29A07B6 -:406A400005D5C0794422504340180C3081B2084610BD000001488078704700009C2100080100034803D00348008808800020704701001600C801000810B504000C4815D030 -:406A8000FEF74EFC817B44238A01C179594351181C312180827B9B005A43891880312180407AC000083008182080002010BD00000100160000B501464A7809781202114337 -:406AC000124A11488BB091421BD111490978002917D1FEF725FC0146102206A8FDF709FDFEF7FCFB01680191808869468881FFF775FF6846FEF766FB002802D1684600F016 -:406B000009F80BB000BD000002001600030C00006401000870B5184D00280BD0FEF700FC0446807A800701D4FFF72EFFA07AC00703D004E01048801E70BDFFF717FFA07A26 -:406B4000000701D4FFF71AFF204610F0EFFB002810D110F071FB00280CD100F0D1FD002808D110F05DF8002804D10DF05DFB002800D10025284670BD0300160010B5064C11 -:406B800010F066FC002804D110F094FC002800D10024204610BD0000FFFF160070B5044640890D46002681070BD0C00709D020881B38E12804D26088FB2801D81B2800D2FB -:406BC0000B4E2046FFF71AFF2880617A5322C900083140182880A17BD20051430922D20189184018034928800880304670BD000001001600C8010008014988707047000054 -:406C00009C2100080021002807D04268002A04D0034A80891288904200D2024908467047C80100080100160070B50546FEF75EFE074CFF280AD0FEF7E9FE012806D10020EA -:406C4000012D04D103494978002900D1204670BD020016005C21000870B5054613480E460078A84201D8002404E01148016AD02068430C18002C13D0228B50060AD5D2072B -:406C8000D20FA078022106F05DFA208B40218843208305E0D207D20FA078012106F052FA3146284604F050FC70BD0000CC1E00085C210008F8B50546002004460B4E0090C2 -:406CC0000FE022466946284601F008FD0098002801D010F001FBA878214603F0A0FF641CE4B2B08AA042ECD8F8BD0000F0210008FFB50446C034A068002103468C468E46B6 -:406D00002033997887B0002915D05E78F200511D06920591415C0091911D0291415CD51D0495475D151D0395455D82580192109A002A07D03CE00A99FF2008700899002070 -:406D400008605EE0002908D0DA78002A05D1002D03D0491E029AC9B281540098854227D3002925D1019810F0B7FAA268059900235354A26802995354A26804995354A268EF -:406D800003995354A26806995350A06820304178491C8907890F4170A16820318878401E0006000E887027D02148864601208446A0686346014620318A78002B0AD04E7804 -:406DC000F1004B1DC35C0093CB1DC75C0B1DC55C40580190002A28D0009885421FD20199401B4A190899C0B20A60B8420CD2099A2918C9B210700BE00A99FF200870089947 -:406E00000B600B480BB0F0BDE819C1B2099807700A980670F000A268001D115405E00A98FF2101700899002008607046EAE70000FFFF0000064A02235188891C89B2518047 -:406E4000814201D8102900D95380508870470000CC0100080148407870470000CC010008F8B517460D460446FBF758FDC034A16820318878042827D0E8780202A87810436A -:406E80000A78521C9207920F0A70A16820318A78521C8A70A1682022525CD6008D51A168721D8854A2680021331DD154F21DA168B8428F540CD33946FBF72AFEC0B20029A1 -:406EC00007D0401CC0B204E0FBF712FD0448F8BD0120A168B61D8855FBF70AFD0020F8BDFFFF0000FEB575480478FEF7FFFC012831D1FBF72DFD724D032831D1A87B012806 -:406F000029D800F033FF012803D100F003FF012808D0A87B002818D06849002020390A782B6A10E0A87B0028E2D10EE0824201D8002102E0D021414359188031C97801294C -:406F400009D0401CC0B28242F0D8FEF789FF032802D3FEF7CBFFAFE0FEF782FF0128FAD05848007800285FD004F052F900285BD00CF0C8F9002857D0FEF748FD002853D018 -:406F800004F08CF800284FD111F084F801284BD06878C00703D000F0F1FE012844D0287E002841D16878484F002803D1FEF794FA002860D06878000706D504F06FF8064623 -:406FC00000F0E4F8304377D16A7801A9684608F03DF90646B4426FD83C48864206D3FEF77BFA002868D06878002865D104F010F9002861D03648006A80B2029068784007C3 -:4070000003D56846008805F02BFA03F007FE6846008803F041FE03F027FF2E490988814203D10120FEF78CFC46E0FBF7D3FC054603F01AFF69468988401A301AA0420ADB09 -:407040000CF060F9012806D1FEF7E0FC012802D1387003F09BFE2846FBF7C0FC3878012803D01B4902980862DBE70120FEF762FC00F0E4FD1BE004F0CBF800281CD0102489 -:4070800003F0F2FE214603F017FD03F005FEFEF7BDFC002810D00120387003F077FE0020FEF748FC00F0CAFD38780128B9D1FEF7E9FB00203870FEBD0748FEBDEC1E0008B7 -:4070C0005C2100086D010008CC010008FF7F000040123C40E6010008FFFF000010B517480078002825D01648046AFEF7FFFB032821D004281FD005281AD103F061FE00F082 -:40710000B1FD03F0EFFE8007800F022810D10D48418800290CD08321095D002908D101210170207E0221C207D20FA07806F00AF810BD0024D9E700F095FD10BDCC1E000871 -:407140005C210008DC010008F8B50646002406F0DBF90546304606F00FFA03460A480021868A0DE001228A401046174628401F40002803D0002F01D1224394B2491CC9B257 -:407180008E42EFD82046F8BDF0210008F8B500252C460A4F0A4E0CE0D020396A604308180079002803D02046FFF7CEFF0543641CE4B23078A042EFD82846F8BD5C210008D9 -:4071C000CC1E000808B50020694648706846FEF705FB69460020085608BD70B50D4601F0BBFF04000BD02079002808D0FFF7F6FBE178A0782A4605F0E9FA002070BD02201A -:4072000070BD00000148007F70470000CC1E00088030C078002800D00120704700B500F001F800BD10B5094BD0225043196A85300A5C074C521CD2B20A54648A196AA24269 -:4072400001D300220A54196A085C10BD5C210008F021000870B50D4601F07EFF04000BD002F0F3FD002807D021462A460A310620FEF740FA002070BD022070BD70B50D4647 -:4072800001F06AFF040007D002F0DFFD002803D0207B2870002070BD022070BDF8B50F4606460146384606F025F9044614480078B04201D8002504E01248016AD020704380 -:4072C0000D18002D12D0284601F084FF032C0ED0002C0BD000220121304602F091F9284603F0C8FA0221284603F0DEFAF8BD3146384606F0C7F90146304606F05FFDEEE76B -:40730000CC1E00085C210008F7B52B4F0446F8682A4D0078297F884201D30720FEBD07F0CDFE002801D00C20FEBD2078611C05F06DFCFF2822D1F868297F007888421DD287 -:4073400005F0B6FC0646FF2816D02178621C03F083FB1B4821780068426B601C904705462078611C02F0B2FEFF2802D0314602F033FE002D04D01CE007251AE01F2518E02D -:407380000298002815D1F86841680078C200101A401C08180622611CFDF7ABF8F868217842680078C300181A1154F8680178491C01702846FEBD0000CC010008CC1E0008EC -:4073C000EC01000810B507F079FE002801D00C2010BD05F0EBFB05480068006B804702F011FE002000F0A2F9002010BDEC01000870B50D46044610210FF07EFE102160180C -:4074000006460FF079FE334610221946204607F0A3FE102130460FF06FFE0220287020460CF028FE70BD0000F8B504464078217802028006870FE0781143A67809050002BE -:40744000090D0643084601F087FE00210546F2B2002816D0002C10D0022F0ED0032F0CD0002A0AD00279092A07D0002A05D0134A8223527D1B5C9A4207D8288900210CF049 -:40748000E8FC20460FF028FF0D49002914D10D48224600682946436930469847084988420AD1284680308178F2B2491C8170FF232146284600F02FFAF8BD0000AC1E0008C5 -:4074C000FFFF0000FC01000800207047F8B5434D0646E8680078002805D007F0EFFD002803D00C20F8BD0220F8BD3078711C05F08DFB0446FF280ED005F024FA3848317891 -:407500000068826B701C90470746204602F0A0FD002F02D060E01F275EE0E968087800285AD0421EA24246D0C200101A4968821FC01F8A18085C114602F0C8FDFF2802D0E5 -:40754000214602F049FDE86842680078C100081A801F1118E000061B701C009010180622FCF7C7FFE86842680078C100081AC01F115C9155E868426800981218204603F08D -:407580006BFAE8680078401EC0B205F0DBF9E86841680078C200101A801F081806220021FCF7B0FFE868002142680078C300181AC01F11540CE04868E1000C1B611C4018B9 -:4075C00006220021FCF79EFFE968002049680855E8680178491E01703846F8BDCC010008EC01000810B500F05BFA0CF01DFE002010BD000010B5014605220A48FCF779FF97 -:407600000849052208463438FCF773FF01F000F9044880224438C17B1143C17300F088FA10BD0000A021000810B5044600786178E2780843A1781143084321790843617917 -:40764000084305D007F024FD002803D00C2010BD122010BD204605F0D1FB002010BD000010B50078002105F02FF8024902200876002010BD5C21000810B502788178407804 -:40768000002305F037F8024901200876002010BD5C21000810B50C4605F08AFC064A117E012900D1002000211176022121700CF03DFA002010BD00005C210008024A936853 -:4076C0000360D06808607047CC01000870B505460024800708D50948807A400604D500F06FFA002800D10224680705D500F086FA002801D104200443204670BDAC1E00089E -:4077000010B5FBF765F905F041FF074807F034FE012000F033F8040001D105F01DF909F041FD204610BD0000B81E000870B50024104D114E002811D0304608210C30FDF745 -:40774000D1FD0404240C13D1287FC100091AF068001DFDF7C7FD0404240C09D1F06800210170297F4068CA00521A0021FCF7CAFE204670BDCC1E0008CC010008F1B54D4874 -:407780009F22817A82B0114000248172FDF7C8FD0746807AC00706D0474802990068C268384690470446B87A800708D5002C7CD1424802990068C26A384690470446002CE8 -:4077C00073D1787A102809D83A492031009108770298FFF7ABFF040002D066E0384C64E038480025457045734571C5750576457645758570C5708571C573042144300173E1 -:407800001F21C1809B21417245732E4EFF2020363073757300F09CFB07F0CEF802F0F6FA30462030C5700298012814D100980178D02041433046FDF755FD0004000C08D131 -:407840000098007841012048FDF74CFD0404240C01D01B48FEBD002507E02846029902F04FFA040005D16D1CEDB200980078A842F3D8144900204431C87288724439887335 -:40788000401E4883FF200877B87A0121000700280848C27A01DA0A4301E052085200C272032030757075F175B1750849002008702046FEBDAC1E0008FC010008EC010008FA -:4078C000FFFF00005C210008D00100087A01000870B505460E46084605F016FE0446304605F04AFE0121A9400A46224001400A4301D0012070BD002070BD10B5044608467D -:4079000005F03AFE0121A140014201D0012010BD002010BD7047FEB51C4616460F46054602F0A8FFA878FFF779FC02460190334639460094284600F00DF8002808D1A87853 -:407940000199FFF789F9FF2C02D138460FF0C4FCFEBD0000FFB50D4685B004468178164610460E9F05F07AFE00280ED0FF2F27D0C8200159F800031D0A58C01DCB5C085C65 -:407980005278834216D9012716E02648D022016AA078504385300A5C002A01D1224A927C521E0A54FF2F02D128460FF095FC012009B0F0BD9006870F69460898088108E0E4 -:4079C0006878A9788006870FE8780002014368460181204602F044FA0390002806D032462946204600F0C3FD0398E1E7384600F0F4FE074604A800903B4602AA21460196F9 -:407A0000284600F02FFC094BB200A178D218FF208854684600893B46C2B2A078314605F047FBE1E75C210008F0210008C5210008F8B518480026009027E000253046FFF718 -:407A400083FB07001ED01448D022016A3046504385300C5C12E0601CFBF75AF8CCB23846E040C007C00F07D02146304603F0CCF821463046FFF712FC6D1CEDB20748818A82 -:407A8000A942E8D8761C0098F6B20078B042D4D8F8BD0000CC1E00085C210008F021000810B5FEF729F90020FFF768FE04F054FFFAF74EFF032803D1FEF7D8F9FEF716FA47 -:407AC0000FF0C6FC09F06EFB002010BDF8B5002400F04CF90125012800D1012406F0F0FE012801D1022004430F4E1049002004270A78336A0FE0D021414359180979002943 -:407B000007D001290BD002290BD0082181402143CCB2401CC0B28242EDD87470F8BD2C43F7E73C43F5E700005C210008CC1E0008F8B5FF2069461E4E0870F07B0024C009D1 -:407B400035D01C4D15E0D020316A60430F188320C05D01280BD102236A46FF21384602F0DAF901280ED04420C05D01280AD0641CE4B22878A042E6D8F07B4006400EF0730D -:407B8000002410E04520C05D00280FD10121384600F0D4FC0AE0D020316A6043081800F092FC641CE4B22878A042F4D80020F8BD5C210008CC1E000810B5FFF787FF10BD53 -:407BC000F8B500252C460B4E0EE049682C20604308180122694607F005FE0006000E01D0054D05E0641CE4B2B1680878A042ECD82846F8BDCC010008FFFF0000F8B5002535 -:407C00002C460C4E0FE04068E100091B401801226946FFF779FB69460870002801D0064D05E0641CE4B2F0680178A142EBD82846F8BD0000CC010008FFFF000010B5084C54 -:407C4000FDF754FE052809D02078012806D1FDF74DFE052802D020780028F1D110BD0000CC01000810B5FDF741FE012803D0FDF73DFE0228F7D110BDF8B504468079254681 -:407C8000603517460E46002806D0687FFDF79CFF0020A071FF206877A671002E09D0687FFF2806D12046A178024B3A467D30FDF727FFF8BD7992001010B5827904468A431E -:407CC00082716034607FFF2803D0FDF77DFFFF20607710BD30B50D4C022061690C4B8AB29978002901D0022906D11D785B78EB18282B01D9032002E0032900D10120510516 -:407D0000490DC0020143616130BD0000C0113C40BA21000800B500F031F8002807D0012805D0032801D0042801D0002000BD012000BD000002460448806901040020C90C12 -:407D4000114200D00120704700103C40014600B50020C90701D000F009F800BD014600B50020C90701D000F001F800BD0248006AC005C00F7047000000103C4004488069EE -:407D800080B2410501D5042070474007800F704700103C4038B50446000610D5FFF7EEFF01280CD1684603F033F86846007800F0E3FB012002F0E8FD0220FFF7FDFE034860 -:407DC000006801692046884738BD0000EC01000810B5034A0178117004F084FF002010BDBA21000870B50446FFF7C0FF002801D00C2070BDA27B01212848002A827801D025 -:407E00000A4301E05208520082706279012A0AD0C17849084900C1702079214E012806D0042804D00AE0C2780A43C270F4E70622E11D301DFCF75DFBA079B072194D28681E -:407E40000168204688472079012808D06188208806F0A2FB2080207904280CD013E02868C168E01D88470021E01D04F0A3FF0120C002208007E02868C168E01D8847002129 -:407E8000E01D04F097FF2079B070204604F038FFB07A05F0EBF8002070BD00005C210008BA210008EC01000808B50178FFF75EFF814201D10C2008BD002927D00720694640 -:407EC0000870FFF75BFF012801D0042808D11A49887A091D02F0FAF8FF2801D00B2008BDFFF718FF01280BD10121684600F092F8012801D0092008BD6846007804F09EF870 -:407F0000FFF7E8FE04F030FF012011E0FFF702FF012806D1684602F07BFF6846007800F087FB04F017FFFFF721FF0028FBD10220FFF742FE002008BDBA21000810B5034A41 -:407F40000178517004F0EEFF002010BDBA21000838B5002168460FF035F9002801D01F2038BD01210098C90201804180002505714571857107214173857304F0C1FE009CCF -:407F8000202200212046FCF7BDFA25702A460021601CFCF7B7FA204604F0A4FE204604F0C1FF00980FF098F90B2200210248FCF7A9FA002038BD0000BA21000810B5044695 -:407FC0000748844209D8204601F0C6F8002804D00089A04201D1012010BD002010BD0000FF0E0000074A9179491C8906890E917138220A4092014907090E114308430249E5 -:40800000084070475C210008FF0E0000C006C00E70470000F3B5174B0E4618781649401C164AC4B281B000200978126A10E0A14200D80024A14201D8002502E0D025654368 -:4080400055192F79002F07D0401C641CC0B2E4B28142ECD80020FEBD1C700021204601F04FFE2E712046FFF7BDFF2881019804700120FEBDE0010008CC1E00085C210008A4 -:4080800010B507F0D9F80222002100F003F804F08BFB10BD10B5094B40074907000F090F185A595A40185043C0086421FAF730FD002800D1012080B210BD0000C846001033 -:4080C000F7B54120405C88B015460C46002802D02878042802D200200BB0F0BD6946087200262046FFF794F8012800D00126204603A93C300191009023460327217F38333B -:408100003246606A07F058F902A8089900900B46019120463A4603A9283006F0E5FF06006846007A287002D1204600F0C1FA204601F0D2FD3046CFE7FFB587B00C460546AF -:408140001078694608724120005D1746002829D000262046FFF75CF8012800D00126204603A93C30019100902346217F38333246606A07F021F902A80090291D019120463D -:408180002B1D03A928300A9A06F0AEFF05006846007A388005D1204601F09EFD204600F087FA28460BB0F0BDFFB50C464020415C25468035107889B0164600290BD06946DF -:4081C0000873C0B2002814D000272046FFF720F8012810D010E0002100910190A078099B129A0C9903F038F80120E87100200DB0F0BD1F20FBE7012703200890204604A964 -:408200003C30019100902346617F38333A46206A07F0D2F8A0780C9902F066FF0F4A0999801803AA01900B4600920291204604A92830089A06F0A5FF02466846007B30701E -:408240000120E8710C99064DA3788900491912985854204601F04AFD1046C8E700103C40C5210008FFB506464020405C89B015460C46002810D0084601F0F2FD01280BD0F7 -:40828000288869468883002813D000272046FEF7BFFF01280FD00FE02878002100910190A078331DFF22139902F0D6FF00200DB0F0BD0220FBE70127204603A93C3001916D -:4082C00000902346617F38333A46206A07F074F8A078139902F008FF00900C4A009912988918029007AA009201912046331D03A928300C9A06F045FF02466846808B28809C -:40830000204601F0F3FC1046D1E7000000103C4070B5054680350446E9784030002908D0012905D10179042902D14078002808D070BD01790C29F8D00D29F9D1287800287E -:40834000F6D0A078FEF700FF2979C840C007C00FEED0A07802F058FC2979A078FEF79EFF70BD000010B518490446484028D0002101231A468A40904221D0491C2029F8D3BB -:4083800000212046C840C243520618D0400616D0491C1929F5D3A0B2210C020AC3B2884201D193420BD01F21204600F01BFA182805D8A00E062100F015FA022801D2002049 -:4083C00010BD012010BD0000D6BE898E70B50D460446FEF71DFF01280AD0E87AA97A00020143A07802F0E0FE012808D0002070BD00222421204606F03CF8242070BD28218F -:408400005A200155204600F037FD282070BD000008490978814201D8002004E00649D022096A504308188030C079012800D0002070470000CC1E00085C210008014610B558 -:40844000002049070FD5094A0021146A084A137807E0D0224A43A2181279022A04D0491CC9B28B42F5D810BD012010BD5C210008CC1E0008014610B5002049070FD5094ACF -:408480000021146A084A137807E0D0224A43A2181279022A04D0491CC9B28B42F5D810BD012010BD5C210008CC1E000810B5044601468034E06A002804D089780EF02AFF71 -:4084C0000020E06210BD38B50546002000902846FEF79EFE01282BD1284601F0B6FC002826D028792C46C01E4034030002F0FCF90705051B1B051B201B00284601F0B6FC10 -:40850000012810D0284605F09BF900280BD0284605F0A0F9012806D0A97868460EF068FE002803D105E06079002801D10120607138BD2846009905F0EDFD38BD4030417172 -:40854000704740308171704770B50546403528790C46052904D0002C05D1801E022802D8022006F003F82C7170BD017170479200101880304161704770B53C2502F0AAF8CA -:40858000040004D020460021473002F007FD0023FF222946204600F05BFD002C02D0A07802F00EF870BD000010B50B490978814201D8002404E00949D022096A50430C18A7 -:4085C00020217F200155002C05D020890BF0B4FC204600F06DF810BDCC1E00085C21000870B505460F480078A84201D8002404E00D48016AD02068430C18002C11D02079C2 -:4086000007280ED1204600F0BAF8204605F0E0FF0A21484302462046044B29467F30FDF76FFA70BDCC1E00085C2100089DA0001010B502F04FF8002802D0807801F0C0FF2B -:4086400010BD38B5044600206946087001236A46FF21204601F018FC054601236A46FF21204601F058FC2843012812D0214640318A79002A02D1087901280CD048790128A8 -:408680000DD0022A0FD0E079400602D5204605F04BFF002038BD204601F0C2FEF9E72046FFF711FFF5E7204600F028F8F1E7000010B50446408A00280DD00748F521807AD8 -:4086C0000840C00607D5204605F082FF82B2618AA07803F0BFFF10BDAC1E000810B50023054C0B60A48A944205D992001018803042690A60436110BDF0210008FEB506469F -:40870000002000900190A8208559B17868460EF06FFD002801D00720FEBD0098374660370290344678884034608238882082E08BA082304605F035FFA88CE18B884207D158 -:40874000288A3988884203D1688A7988884203D0F07920210843F071688A7880288A3880A88CE083FEF766FBA083E08BFEF772FBE0763046029905F009FD0198FEBD38B52E -:40878000044600200090A07900280FD14420005D052801D00E2809D1A17868460EF028FD002803D12046009905F034FE38BD10B501F054FE002010BD70B50C4605460146D0 -:4087C000204605F025F8002805D0A17828460EF095FD232070BD0D2070BD002800D102207047704770B500231A46491E0CE00446D440E507ED0F541C0646E640F407E40F89 -:40880000A54200D05B1C521C8A42F0D3D8B270BD30B50021124C0A46A05C002308E0C50701D0491CC9B201290AD840085B1CDBB20028F4D1012903D8521CD2B2052AEBD3F5 -:4088400002290BD207488118C87B0122082B03D29A400243D0B200E01043C87330BD0000A02100085C2100087FB504468034E16A05460E46183108226846FBF73AFE314672 -:408880002031082202A8FBF734FE102168460EF033FCE06A102108300EF02EFCE06A2B46083028331022694606F056FC7FBD10B504460821FFF700FA10212046FFF7FCF92B -:4088C0002079052822D0062820D008281DD1218900200BF07DFA072020712046FEF798FC012819D00E212046FFF72EFE002180200155204601F06EFE2046FFF7D7FD204668 -:40890000FFF7D6FE2046FFF79CFE10BD2089012200210BF041FADEE70521E4E7FFB581B01F4604460821FFF7C7F910212046FFF7C3F92079082803D0092804D0042503E068 -:408940000425012601E009250026204601F074FA00212046FFF7F8FD25712046FFF7A6FD0398002E02D0012808D00BE001280AD12089002202990BF00FFA04E02189029889 -:408980000BF026FA0127002180200155012F07D0204601F01FFE2046FFF753FE05B0F0BD5A2102980855204605F090FD054605480121428A2046FFF75FF9002DEED109202A -:4089C0002071EBE7AC1E000870B50C460546FEF71FFC012809D108212846FFF76DF90023012221462846FFF799FF70BD10B5044601F022FA2046FFF759FD00212046FFF759 -:408A0000A3FD10BD70B505461A24FEF701FC012809D108212846FFF74FF90023012221462846FFF77BFF70BD38B5044600200090A17868460EF0DCFB002801D00D2038BDFB -:408A40002046009D01F0A4FB2946204605F05CFC05480821428A2046FFF70EF906212046FFF772FD002038BDAC1E0008F8B50446002000900E46A17868460EF0B9FB002827 -:408A800001D00D20F8BD204604213830009D0EF010F9AC200059082118300EF00AF9012E02D1204601F074FB2946204605F0B0FB05480821428A2046FFF7DEF8022120469B -:408AC000FFF742FD0020F8BDAC1E000810B50446FFF7CAFE03212046FFF736FD204601F0C9FE10BD10B50021FFF7C0FF10BD000038B5044600200090A17868460EF078FBA8 -:408B0000002811D12046009A01F096F91146204605F005FC05480821428A2046FFF7ACF807212046FFF710FD38BD0000AC1E000838B5044600200090A17868460EF058FB5F -:408B4000002810D12046009905F0B5FC06480821428A2046FFF790F804212046FFF7F4FC204601F087FE38BDAC1E000810B5FFF79EFE10BDF8B50446002000900E46A178D4 -:408B800068460EF035FB002801D00D20F8BDAC20005908212030009D0EF08BF8204604213C300EF086F8002E02D1204601F0F0FA2946204605F053FB0E480821428A2046C4 -:408BC000FFF75AF8204601F08AFD00280AD0204600F026F8002803D009212046FFF7B4FC0020F8BD08212046FFF7AEFC204601F041FEF5E7AC1E000810B54421095C0829A0 -:408C000006D0092908D00A2901D100F09BF810BD0B21FFF799FC10BD00F002F810BD000070B504460079052805D0062803D0082811D00C2070BD03220621204605F019FCB3 -:408C40000F480821428A2046FFF716F811212046FFF77AFC12E006215A200155204605F035FC05466220025B0A20424301212046FFF702F8002D01D109202071002070BD6E -:408C8000AC1E000838B5044600200090A17868460EF0AEFA002801D00D2038BD2046009D00F074FA08202071204601F071FA2946204605F034FB0021412001550F21204630 -:408CC000FFF742FC204601F0D5FD002038BD10B5024601F0B1F810211046FFF735FC10BD10B50446FEF794FA012809D04420005D112805D100231A4606212046FFF70EFE6A -:408D000010BD10B5FFF7D3FD10BD000038B5044600200090A17868460EF06AFA00280DD12046009905F0C7FB05480821428A2046FEF7A2FF0D212046FFF706FC38BD000083 -:408D4000AC1E000838B5044600200090A17868460EF04EFA002801D00D2038BD2046009905F09EFB05480821428A2046FEF784FF0C212046FFF7E8FB002038BDAC1E000812 -:408D8000007870477CB536490978814201D8002404E03449D022096A50430C18002C5DD0204601F052F8002858D0207903280CD005280CD06220015BA07804F0D7F82646FE -:408DC0004036B079012805D030E0042000E0062020712BE00021204604F069FD25468035A86A002804D0A1780EF094FA0020A8620020B071E87801280CD02046C030417B6A -:408E00007D22114041732046FFF71BFC2079072805D007E02046C030417B7E22F1E72046FFF746FC0221204601F03EFD0E48407BC00713D02079042810D120896946088079 -:408E40006034207A88702089000AC870A07A08716089000A487168460BF028FA7CBD0000CC1E00085C210008A021000810B55A22115400F05DF810BD10B50446FF21FEF782 -:408E80001BFF09202071A07804F0B2F810BD000010B512490978814201D8002404E01049D022096A50430C18002C15D0204600F0DDFF002810D10B480068C169204688473B -:408EC000E07EC00608D4BC20005D012804D10648006801682046884710BD0000CC1E00085C210008FC0100080802000810B504468079002809D022215A200155FF212046EA -:408F0000FEF7DAFE204600F013F810BD10B5037902464032002B03D09176092B02D003E0002100E02221917600F002F810BD0000FEB5044600890027009027812079254662 -:408F4000803500282FD001282DD002282BD0002005F00CFB0AE002AA01A9204604F044FC002808D1A17801980EF0C8F9204604F067FC0028EFD0FF212046FEF79DFE204642 -:408F8000FDF798FE3049AF70887B002804D0401E0006000E887306D1F9F7C0FC2A4840304770F9F7A5FC26466036B07FFCF70CFEA86A002803D0A1780EF0ACF9AF62E86A1C -:408FC000002803D0A1780EF0A5F9EF6225464035A97E002934D0009800F0B6F8F07FFCF7F3FD2046FFF74CF8A07802F0C1F8204602F0ACFEA0780AF0E1F8E87B02F0B8FB5C -:40900000A87BFF26FF2805D0104909680A6C00219047AE73EE73A07801F0D2FA0B20FEF7CBFD01F02DF9F9F793FC032807D10648807B002803D1FF20F530FCF735FFFEBD71 -:409040001F21A976C7E700005C210008EC010008FFB583B01E461746054606F0D7F804006AD020460C303146009001F079FF2046062200211830FBF745FA2046062200218A -:409080001230FBF73FFA2D48224600683946836A284698470190049820702846FEF7B8F8012148402E4640366070002D11D028896080F07920710498002811D16879607120 -:4090C000F08BE08028466030018821814088608109E01B488069C005C00F2071002060800498022824D02846062248300099FBF700FAFF2F11D0114801210068026C38463E -:40910000904710482C220068416838465043021D8A180A30085C114601E02079009903F075FD0546FF2801D003F034F8B773F573204601990AF0CFFD07B0F0BDEC0100084F -:4091400000103C40D40100080A4610B5014600200AF00AFF10BD000000B50146FEF756FF084A1278824201D8002004E0064AD023126A58431018002802D002898A4200D0D4 -:40918000002000BDCC1E00085C21000838B504468034E16A002907D1817868460EF03AF8002801D10098E062E06A38BD10B5014600F056FE012803D08878FEF733F810BD01 -:4091C0000348026A8878D02148438430105C10BD5C21000870B5054604468035A879012811D10948A178026AD02048438430165C3046FEF76DFB002805D10220A871A07894 -:40920000314603F0BFF970BD5C2100080EB500220A216B460292198100905A811046029B00990EF04CF90EBD70B5104DA87A00281AD00F4C217FFF2916D0608B01F036F89D -:40924000012811D10020A872401E6083FF20207701F0EAFD044601F021FF010002D0204600F0D8FBFEF7E4FB70BD0000A02100085C2100087047000070B5104AC0B2117803 -:40928000491E11700E490978814201D8002404E00C49D022096A50430C18A07900280BD025466035687FFF2806D02046FFF71EFE0020A071FF20687770BD00007A01000882 -:4092C000CC1E00085C2100087047490510B5490F0B0001F009FB060704080C0C0F073E21FFF7C4FD10BD0821FFF710FE10BDFFF71FFE10BDFFF7FAFD10BD0000F8B52B48F7 -:40930000002500904DE0A84201D8002604E02848016AD02068430E18F9F700FB30464030C48A078B0021C1820183F9F7E1FA304600F08BFD012831D1A00702D52846FFF783 -:4093400021FDE00602D52846FFF7A2FDA00602D52846FFF75BFF600609D5F9F7DFFA1449002040314870F9F7C3FA00F005FF200602D5284600F020F8600702D5284600F071 -:4093800043FCE00703D021463046FFF79EFFF80704D00849B0780968496988476D1C0098EDB20078A842AED8F8BD0000CC1E00085C2100080802000805490978814201D8B5 -:4093C000002070470349D022096A504308187047CC1E00085C21000810B50446054800680168204688470448006801692046884710BD0000FC01000808020008F8B5054673 -:40940000FF20694608702888FFF7A6FE040035D000F01BFD002831D0207909282ED002236A460021204600F076FD012828D02046FDF7EEFE0646E07920210843E07120468C -:4094400004F052FA002823D0294601F005FA02236A46FF21204600F017FD01281AD04620005D00281BD02325E079DF210840E0712946204604F08FFB2846F8BD0220F8BD63 -:4094800068460078012801D02A20F8BD2320F8BD0720F8BD02204034A0710020F8BD002E05D02046FFF72AF90500DDD1E4E70C20F8BD000070B50E460C2501F0EDF80400D8 -:4094C00013D00025228929460A480AF073F80123FF2202212046FFF7BBFDA07801F0F2FB2046FFF725FD022000E000203070284670BD00000E200000F8B5044601F0CCF86C -:40950000002801D00C20F8BD6079A11D00F0DEFDFF2801D00B20F8BD02216846FEF77AFD012859D13248017868460078814201D8002504E02F49D022096A50430D18002D07 -:409540004AD000212846FEF7FFFF2E46002040367071B0712848002100684268284690470620FEF729FB2F46208A60373880E289A189A87809F0A4FCF083608A78800420E7 -:40958000F0760320B0831B4806228778A11D2430FAF7AFFF2079012820D06079F0710121A01D03F007FCFB20074012488770217E012918D0C278FB210A40C2700F482146FF -:4095C0000068826828469047A978204603F0C2F82846FFF7ECF8F8BD0920F8BD0020F07104200743E1E7C17804221143C170E5E7CC1E00085C21000808020008EC010008E0 -:4096000070B5164602461B480D460078D0211A4B5143904201D8002401E0186A4418002C26D0204600F01CFC012809D1186A8431405C1146FEF74CF9002801D104F07AFE5E -:409640000E483146006882692046904700280CD0204680308178A94201D3491B00E000218170208929460AF0F4FB204601F002F970BD0000CC1E00085C210008FC01000869 -:4096800070B505460088FFF767FD040014D000F0DCFB002810D02079092822D0A97825464035A976204604F011FF0646A879012804D06220025B02E0022070BD6A8A0A20C3 -:4096C000424301212046FEF7D7FA01F055FB8021204602F059FD01F06BFB002E01D109202071002070BD0EB5002218216B460292198100905A810120029B00990DF0DFFE10 -:409700000EBD0000F8B5194E0025B07A002824D101F0C4FC26E001F0BBFC1549401801680068CCB287B22146384600F0BFFD012814D010480121478304774577B1720E49AE -:409740000978A14201D8002003E0006AD0214C430019002801D001F08DF8F8BD01F09EFC6D1CEDB20028D6D1F8BD0000A021000800103C405C210008CC1E000810B5044670 -:40978000C0060FD50C4900200B6A0C490A7807E0D021414359180979022909D0401CC0B28242F5D806480068C1692046884710BD00F050F8F6E700005C210008CC1E00081E -:4097C000EC01000810B50088FFF7C6FC040007D04420005D082805D00B2803D00C2010BD022010BD2046FFF71BFA002803D009212046FEF7A9FE002010BD70B50546008863 -:40980000FFF7AAFC040008D0264640363079082805D00B2803D00C2070BD022070BDAC20005910220830A91CFAF763FE2046FFF71BF83079082804D02046FFF783FA0028AF -:4098400003D00A212046FEF77FFE204601F012F8002070BD70B51E491E4D0978814201D8002403E0D0212A6A414354182179022904D0002901D003F0BBFB70BD01228321A4 -:409880000A5501F03FFC032020710820FEF794F900212046FEF758FE0121204601F004F8204647300121064601F078FB0A480068416A304688470246012300212046FFF736 -:4098C000C7FBA078FFF788FDA87B401CA87370BDCC1E00085C210008EC01000810B50C46002121700088FFF737FC03000BD000F0ACFA002807D00948F521807A0840C00684 -:4099000003D4112010BD022010BD022020705A8A188900210AF044FB002010BDAC1E000870B50088FFF718FC040008D000F08DFA002804D0E079C10903D0002070BD0220A8 -:4099400070BDC1068025002908DA2843E07108480221428A2046FEF78FF9EEE7204600F053FC0028ECD1E1792943E17170BD0000AC1E0008F8B50F46002569460D702E4628 -:409980000088FFF7E9FB040010D000F05EFA00280CD0E079410638D4E17E4A0708D48A074021002A1BDA0843E0712EE00220F8BD05F02CFC067021894180E1898180A17EC3 -:4099C0004170218A0546C180022038702978104809F002FF28460AF087FA0020F8BD0843E07102236A460C21204600F04DFA00280BD102236A46FF21204600F08CFA0028CC -:409A000003D1204604F090FD05462846F8BD00001D0400003EB500220F236C460292238100910190628169460EC900200DF047FD3EBD0000F8B50F46054600F04BFE04003A -:409A400052D0032020710026832006552046E6703146473001F0A2FA05F0EEFB25464035EA8B6179FEF716FB1030FF2281B249321346204604F094FD0920FEF79DF8A07884 -:409A800001F05CFB0021204600F00EFF00212046FEF75AFD6E710023AE713A4619462046FFF7D6FA1248002100684268204690471048817B491C8173A078FFF78DFC00F0DD -:409AC000EBFD040007D00B480021243003F072F9204600F0C3FCF8F73BFF032803D14034E08BFCF725FAF8BD284603F081FAF8BD080200085C210008F8B50446FF206946AD -:409B0000087000262088FFF727FB05001AD0FDF77FFB002812D02948807AC00710D0284600F093F900280DD0287903280CD004280AD0072808D0092836D103E00C20F8BDAE -:409B40001120F8BD0220F8BD4420405D01282BD02846FFF71BFB070028D00822211DFAF7C8FC3846A1782030017261881022090A417221460C311838FAF7BBFC02236A46C1 -:409B8000FF21284600F0C7F9012811D002236A460521284600F078F9012809D0284600F03FFC06463046F8BD0D20F8BD0720F8BD01212846FEF7C8FCF4E70000AC1E0008CD -:409BC00010B50E4AC0B21178491E11700C490978814201D8002404E00A49D022096A50430C18208B102108432083A07803F000FA08212046FFF78AF910BD00007A01000855 -:409C0000CC1E00085C21000810B517490978814201D8002404E01549D022096A50430C18002C1AD020464030417902290BD1002141718320005D012810D02046C030417B4E -:409C40007D2211404173207E0021C207D20FA07803F078FA2046FEF7F4FC10BD2046C030417B7E22EDE70000CC1E00085C21000870B505460E460088FFF76EFA04000BD0BC -:409C800000F0E3F8002807D01248F521807A0840C00603D4112070BD022070BD6020005B5E21095B401C48430004C10C6888884201D2122070BD60822079072802D1204699 -:409CC000FEF7F6FC02203070208900210AF090F9002070BDAC1E0008416A491C416204D1017F491C4906490E01777047016A491C016204D1417F491C4906490E41777047CB -:409D0000F3B506463D4881B00078B04201D8002404E03B48016AD02070430C18002C05D0FBF7FEFA807AC00702D00EE00220FEBD2546C0352F68F8F7F1FDD02200212046E3 -:409D4000FAF7E0FB2F60F8F7D3FD2E480299006882682046904705004DD1A6700026E676267131462046FEF7EFFB204600F064F8204603F05FFD244F6782862006551F48F0 -:409D8000F5212038807A084000D00120A07526830298002805D020462021C030FBF7A2FA85B2C020005920220021FAF7ABFB4C20A664065320464030C671FF21C1738173FA -:409DC0000122603042750275C27582754276027603228276C27606774277002022186032401CC0B251770328F8D305484030C07820736034E780E8B2FEBD0000CC1E000857 -:409E00005C210008FC010008FFFF000010B50020074B084AFF2119541418401CC0B221740428F8D31F2119541018017410BD0000A02100085C2100080021416201770162FA -:409E4000417740300170417070470079002805D0012803D0022801D0012070470020704780308079002800D00120704740300079002807D0012805D0052803D00E2801D05F -:409E80000120704700207047F0B5002405461470C07E0126C006002803DA0124142900D116702846FFF7E2FF002803D00124052900D11670E87E470708D480070ED5012469 -:409EC0000C290BD11670E87E400707D5E87E800704D4012B01D10C2905D001248320405D012802D008E00024F8E7A879800703D50124082900D11670012B02D1092900D1FB -:409F000000242046F0BD10B5807803F035FB002800D0012010BDFFB581B0019F04980026403714460D46022810D17879012803D1012D00D120700126B879022800D10126B7 -:409F4000019803F087FC012800D1012600232370797980208122022908D1012D02D0002D02D002E0227000E020700126B979012908D10126002D02D0012D02D002E02270E9 -:409F800000E020700198A030017F032902D0042908D003E0162D11D101262670007F022804D00BE0162D09D1002607E00126182D03D0162D01D0172D00D12270049802282E -:409FC00006D12078C00702D00120207000E02370304605B0F0BD000010B5084A1278824201D8002004E0064AD023126A584310184030C173084602F0CDF810BDCC1E000831 -:40A000005C210008F8B500240F4D104E17E0A04201D8002103E0D020316A604309180846FFF713FF002808D00F464037F87BFF2803D001F09DFBFF20F873641CE4B22878B3 -:40A04000A042E4D8F8BD0000CC1E00085C210008F8B5064600240F4D18E0A04201D8002104E00D48016AD020604309180846FFF7ECFE002808D00F464037F87BB04203D13E -:40A0800001F076FBFF20F873641CE4B22878A042E3D8F8BDCC1E00085C21000810B50449C0B20A78521E0A70FEF77EFA10BD00007A01000810B50449C0B20A78521E0A7098 -:40A0C000FEF78EFA10BD00007A010008F3B50024C70781B0134EFF0F1FE0A04201D8002504E01148016AD02060430D182846FFF7ACFE00280FD02946062248310298FAF76A -:40A10000E9F9002807D14035E879C007C00F874201D12046FEBD641CE4B23078A042DCD8FF20FEBDCC1E00085C21000830B50446FF281BD000210E4B0E4D14E0884201D8C3 -:40A14000002203E0D0202A6A484312181046FFF77CFE002805D04032907BA04201D1012030BD491CC9B218788842E7D8002030BDCC1E00085C21000810B500F055FE0446D0 -:40A1800000F08CFF010002D02046FFF743FC10BD70B5054604468035A879002827D1FF20E075174BA078D0225043196A85300A5CD026521CD2B20A54A078196A7043114E35 -:40A1C0008530768AB24201D300220A54A078D02250430246196A85328E5C84300E54A1783046FDF775FB002802D00120A87170BD0220A871A078314602F0C4F970BD000049 -:40A200005C210008F02100087CB50446FF206A46002110700191014602232046FFF77BFE01280FD002236A4608212046FFF72CFE012807D0A17801A80CF0DAFF002809D09E -:40A2400007207CBD68460078002801D023207CBD2A207CBD2046019DFCF7DAFF00280BD02946204604F016F804480221428A2046FDF702FD00207CBD11207CBDAC1E00088D -:40A2800070B50024074E084D07E0D020316A60430818FEF7D6F9641CE4B22878A042F4D8002070BD5C210008CC1E0008F0B50F46810785B0890F0291000A6946888055484A -:40A2C0000078B84201D8002404E05348016AD02078430C18002C26D000F0DAFE06466846808800280BD00298012840D002283ED0032809D04120005D01286ED085E047481F -:40A3000030180068608180E000200290A17802A80CF046FF002807D04120005D012877D12046FFF7D9FC73E06846029D82882946304602F095FF394830180068608120468A -:40A34000FDF7E6FF01AA21462846FDF7B9FE002807D0384600F0C0FCA17828460CF0B0FF28E0EF772946204603F094FC4DE00020009020890390A17868460CF0FFFE0028B7 -:40A3800002D0002005B0F0BD6846009D8288291D304602F065FF2148301800686081384600F09AFC2046FDF7B3FF8020005D00280FD106E03D205A2108552046FEF75CFD04 -:40A3C00026E001AA21462846029BFDF7B5FE002804D028460CF06AFFECE713E00298FEF700FA01460398287003980901000A0843687068468088A870000AE8702846FFF795 -:40A4000072F905E02046FFF767FC384600F064FC0120B7E7CC1E00085C21000800103C4070B501790546032904D0042904D0072908D109E0052400E006240121FEF716FB45 -:40A44000002805D00D2070BD0824FEF7EDFAF7E7284600F00FFA2C71002070BDF0B587B0054604F0D3FE044604F0C9FE019004F0BCFE009004F0CEFE029004F0DDFE0690D7 -:40A480000098207000982F46000A607000984037000C0590A07000982E46000EE070F87E20710198607101986036000AA07101984149000C0490E071387F2072B88B0522E1 -:40A4C000000A6072B87FA072F88B000AE072307820733088000A6073B078A0737088000AE073204610300391FAF703F80020E870A878039902F0C8FD0020687106980299B5 -:40A500004001084300216175A075000AE07504E0F98B288849004018288000F0A5FC2988042200F05FFE0128F2D023481038417C027C090211433182C17C827C0902114389 -:40A540007182007DB0820298307600983081059870810198B0810498F0811848298801601821204602F0A6F87088F98BC000F8F7CFFA124980B28860012183204155A878C6 -:40A5800000F07EFBB188A87802F0F8FBF98BA878042208F02BFAF8F71DFA0446A87808F0E7FC06494031086200F07CFB2046F8F715FA07B0F0BD00006C21000800123C4046 -:40A5C00010B50021FFF79CFB002801D0002010BD012010BDFEB50546803001908079002839D0AE780096D021294C4E433746206A8437C05D0099FDF780F9012828D0226A66 -:40A600002046D15D491CCCB22249498AA14200D80024019B002199713346FF218533D154026A8636D1550021006A0B4681550A46009802F0C7FAE97DFF2904D0284603F0EB -:40A6400064F8FF20E87503F075FE0026114F1AE0019803218171FEBD00200090224669462846FEF73BF80099002904D0FF231A462846FDF750F9641C788AE4B2A04200D8C0 -:40A680000024761CF6B2788AB042E5D8FEBD00005C210008F021000800B5022000F002F800BD000030B5044608480021036A0848027807E0D020484318180579A54204D012 -:40A6C000491CC9B28A42F5D8002030BD5C210008CC1E000800B50120FFF7E4FF00BD10B5044604F093FD218901808034E16A4160E16A2831816009F085FB10BDF7B50746CF -:40A700000C460879897882B0092807D0F9772046FFF7A6FB4D4E012806D00FE038460CF0EDFD022005B0F0BDA178D0204843326A8430105CFDF7CCF8012824D0A078FDF7FC -:40A7400067FE01281FD03D780121384603F0CCFC2046FEF72BFD0190A17802F07FFF002818D0204681213A4AC0300C2D3ED023DC26464036002D26D0012D27D0062D33D07D -:40A780000B2D4BD128E06846027C21463846FEF713F8C7E7A078D0225043316A85300A5C002A01D12B4A927C521E0A54A17838460CF0A4FD0720B5E7122D24D0142D25D07E -:40A7C000162D2BD104E00122B27101E002227271427B0A43427321E02046FCF719FD01281CD10020307019E00120FBE7E07E400704D4528A04212046FDF73EFAE07E022176 -:40A800000843E0760AE0528A102104E0E07EC00604D5528A40212046FDF72EFA009504AA21463846019BFDF7BFFC69460A7CA0780323019902F03CFCA0780199FCF70CFA8B -:40A84000A17838460CF05AFD00206BE75C210008AC1E0008F02100088A8802804A884280CA8882800A89C2808A890281498941817047000010B50246803293790021002BC3 -:40A8800003D19278002A00D00121064A927A002A00D000210279092A00D10121807802F085FC10BDA021000870B50C460546FCF7AFFC00280BD1012C06D92879092806D06D -:40A8C0002846FFF720FB0446002C02D004E0012402E0287EC007FAD1287E2146C207D20FA87802F02FFC70BD30B47446641E2578641CAB4200D21D46635D5B00E31830BCEC -:40A90000184700000B4B01280BD002280BD004280BD008280CD10748803002630548A83005E0202002E0382000E05020C01801607047000000103C400149886070470000A8 -:40A9400000103C4010B50446FF20F130012C04D0022C05D0042C08D105E0FF20D53004E0FF20D93001E0FF20DD30002202F074FD03490869034A80B2A0431080086110BD63 -:40A9800000103C40E2010008034A1169034B89B2814319801161704700103C40E2010008034A1169034B89B2014319801161704700103C40E2010008F8B5244F14243A680C -:40A9C000054665432C46936813341B5DF1269B0036019B191E4E9B1900931E68B6B2760876001E602C2306465E43002909D190685168035D301D08181649FF22C96902F027 -:40AA000007FB3868A91D80688022035D40181149896A02F0FDFA38680E498068096A035D4019202202F0F4FA38680A4980680C35035D4019496A402202F0EAFA3868012187 -:40AA40004068805B084300990860F8BDD401000800103C40F0210008F8B505460120A84086B214460F46012231467C2002F0F4FC3A463146782002F0EFFC607826780002EC -:40AA80000643E078A27800020243607923790002034307480C2180694D430649401944182660001D44182260001D40180360F8BDF021000800103C40401880B270470000EA -:40AAC00030B5124BCC061B7849095B0701255B0F640E0902ED02012B10D0022B0ED0032B01D0042B09D18007800FD2072843120E0243144306482143816230BD044321439D -:40AB0000D001084303492843886030BDF021000800F13D4080143C4010B5234A12785207520F012A29D0022A27D0032A01D0042A22D1421C13461C78007822465C782402D5 -:40AB400022439C78DB78240422431B061A431202164C0243A260481C024613780978184653781B0218439378D2781B0418431206104300020843E06010BD4278037812020B -:40AB800013430B4A1361C37880781B021843506148780B78000203439361C878897800020143D16110BD0000F021000800F13D4000143C400B4A12785207520F012A09D061 -:40ABC000022A07D0032A01D0042A02D1064A106051607047054A83B21360000C5060916070470000F021000800F13D4000143C40044A002180180268491C89B21029FAD3A2 -:40AC00007047000000103C4010B50C4602F08CFC01494018046010BD00103C40704770B50C46054600F018F821462846FFF7ECFF70BD0000002310B5F121064A09011846D3 -:40AC40008C182360091D401CC0B289B21028F7D310BD000000103C4070B50C46054602F069FC0549054A097D694309190902214389B28018016070BDF021000800103C40A4 -:40AC800010B504490863FF20012220211D3002F0E3FB10BD80103C400149086070470000C0103C4000B50549012088600449442008600420FFF774FE00BD000040123C40AD -:40ACC00000103C400349086302494520803908607047000080103C40054AD1687C2389B2994380000843D06002494D200860704740123C4000103C4070470000054B19688B -:40AD00000722920289B2002801D0114300E0914319607047001F3C4010B5094800784007400F012808D0022806D0032801D0042801D10DF067FA10BD02495420086010BD11 -:40AD4000F021000800103C4010B5094800784007400F012808D0022806D0032801D0042801D10DF057FA10BD02495320086010BDF021000800103C4000B503490888488003 -:40AD8000FFF702FE00BD0000E201000810B5F7F7A7FD012802D10320FAF756FD0120FBF72BFF02495020086010BD000000103C4000B502484088FFF7F3FD00BDE20100082D -:40ADC00010B5FAF779FD10BD03490868012280B2D203104308607047001F3C40884201D8081A03E00022D243101A401880B27047884201D9401A00E0081A044980B28842D4 -:40AE000003D901210904081A80B27047FF7F000000210170704710B50B4602460021F820FAF760FB10BD00000148006BC0B2704780103C4010B50A490978814201D8002443 -:40AE400004E00849D022096A50430C18F7F766FDC0342068C48BF7F74BFD204610BD0000CC1E00085C2100080148806880B27047C0103C400148406880B2704740503D4038 -:40AE800000280DD00C4A90690870000A4870D0698870000AC870106A0871000A48717047064A10680870000A487050688870000AC8709068F0E7000040103C40C0113C4048 -:40AEC00000B5024A00F004F800BD0000FF7F000000B51346FFF782FF984201D8022800D2002000BD0148006980B27047001A3C400148406A80B2704700103C40014840698E -:40AF000080B2704740103C400148006880B2704700503D400148C06B80B2704700103C40F8B50646002402F0EFFA0546304602F023FB064609480021878A0BE001208840A0 -:40AF4000034602462B403240134301D02043C4B2491CC9B28F42F1D82046F8BDF0210008002910D00B4B196B8AB2596B9B6B89B20270120A42708170090A9BB2C17003715B -:40AF8000190A41717047044B996A8AB2D96A1B6B89B2EDE700123C4040103C40012905D0054989690904C90F017070470249403189688907C90FF7E700103C40FFB581B095 -:40AFC00000242D4B2D4D0B9E002805D0022803D003283ED006281DD1A86B2F4684B2A004850E2007000F012802D0252D1AD916E00C2D14D106230021F820FAF773FA0623DB -:40B000000021F820029AFAF76DFA002E01D0B86B1DE0002304980480184605B0F0BDFFF7D3FEF9E706230021F820FAF75BFA062DEFD30A98002806D0AD1F0246ABB200214B -:40B04000F820FAF74FFAB86B002E80B2E1D03080DFE7A86B84B2A004800E0C28DFD106230021F820FAF73EFA06230021F820029AFAF738FAA86BCCE7FFFF0000C0103C40B9 -:40B08000024800684005C00F70470000001F3C400148C06870470000F02100080248806A8006800E7047000000543D40084910B58000084B4218D9687C2489B2A1430843D9 -:40B0C000D8600548101800688006800E10BD00003044010040123C4000103C400148406880B27047001A3C4010B5054B1A8A9C8A5443444398684A432018801810BD0000F4 -:40B10000F021000870B50B4908630B49D024444325460B6AFF2285355A5523460D6A8433EA54096A002286340A550123114601F049FD70BD80103C405C21000870B50B4A6C -:40B14000D02141430D46146AFF23853563550C46156A84342B55126A00238631535400220123114601F02EFD70BD00005C21000870B50B4AD02141430D46146AFF238535E8 -:40B1800063550C46156A84342B55126A00238631535402F0C3F90349C98D02F07BF870BD5C210008AC1E000870B50D460B490978814201D8002404E00949D022096A50435D -:40B1C0000C18F7F7ABFBC0342068C48BF7F790FB02222946204600F005F870BDCC1E00085C21000810B50023884201D8081A03E00024E443201A4018044980B2884201D83A -:40B20000824200D90123184610BD0000FF7F0000024840680006C00F70470000C0103C4070B55478157824022543D47888232602947834435679127936023243002900D02C -:40B2400098230449086303488038181805604460826070BD80103C40FFB581B015460E4607460A9CFFF740FF002C0AD022460B9B049902F021F90549B0004018C55505B066 -:40B28000F0BD0B9A049902F0FDF8F4E7C5210008F8B59C469308394D002403E0A600AF598751641C9C42F9D39207920F4B1C002A06D0012A15D0022A27D0032A39D13EE05F -:40B2C0001D7809782A465D782D022A439D78DB782D042A431B061A4312020A43A100425027E0A600AD590C78CB7822464C781B06240222438C78240422431A431202EBB24E -:40B300001A438251C978301812E0A200AB584C780D7824062D042C431D042D0E2D022C43DBB21C438450CB788C7819022143101841606046012801D1FFF7EEFCF8BDA40087 -:40B340002A59097815022D0E09062D04294315042D0E2D022943D2B2114301511A461B78194653781B0219439378D2781B041943120611430902090A2018D9E750F13D400C -:40B3800070B50C4D2A785407640F012C08D0022C06D0032C01D0042C01D100F00FF870BD02460B46044CA888082121620021FAF71FF970BDF021000880143C40F0B52B4A11 -:40B3C00008232A4E503A5363546B9C435463820703D000238F08BF001DE08C08002203E09300C558F550521CA242F9D3A30014E0C218521C144625782A4665782D022A43D8 -:40B40000A578E4782D042A4324062243C45C12022243F2501B1D9F42EAD88A0724D089070022890F012904D0022904D0032917D107E0C25C14E0C018417800780A0202437D -:40B440000EE0C01801460A7810464A78120210438A78C97812041043090608430202120A0248103818180261F0BD000050F13D4070B51A4909784907490F012921D0022911 -:40B480001FD0032901D004291AD10446FFF75CFC134D00216018401C02461378184653781B0218439378D2781B04184312061043625C000210434A191061091D1029E9D3EB -:40B4C00070BD212504466D01FFF73EFC1023224600212846FAF78CF870BD0000F021000800F13D40154909784907490F012918D0022916D0032901D0042911D1411C0A463B -:40B5000013780078194653781B0219439378D2781B0419431206114309020143084801627047417802780902064B0A439A63C178807809020843D86370470000F021000805 -:40B5400000F13D4040143C4008B5094A127D4243521812020A4380210A4369460A8001F0E9FF69460988034A8018016008BD0000F021000800103C40FEB5044600266846DD -:40B580000680868006810125A078FBF7DDFD0746A078FFF7C5FC0743A078FFF787FD0743A07802AB01AA694600F020FA3146264660363177002F55D12079092852D06846F3 -:40B5C000808800284ED0204602F03AF9002849D0684681882046C030002909D00168CA79022A05D0CA7AD30902D05206520ECA720068817A002905D0C17AC90902D1217EAF -:40B60000890600D50025214640318A79012A06D04979022903D0BC21095D02290CD1718BC08BFFF7DBFB69468988C91C884202D30D49884200D9002568468088002811D066 -:40B64000012D0FD10421204600F0B0FD01203077684681880422204600F0CAFD208B082188432083FEBD0000FF7F0000F8B5044680782521C001C9024018394940184069BB -:40B6800086B2F7F74BF9FFF7C3FD002864D0207E000761D420466030017F01295CD146210B5D00252146C0312A46012B07D1438B0868C08B834251D0401C83424ED0294888 -:40B6C00003689BB200938368FFF7CEFB5F06264B03D5009D2D1AED18ADB20F687988814201D2401A05E0814209D93F888F4206D2081AC01882B21D48824200D900221B4848 -:40B70000854229D8D00700D0521C50083146F7F7FFF907464800301A4004010C0A2901D9012300E00223581C704340000A30A84212D81021204600F039FDF81881B210226A -:40B74000204600F055FD204600F08EFC00F01EFC208B082108432083F7F7CAF8F8BD000000103C4000503D4000000100FF7F0000FF2806D0034B196A012289B28240914376 -:40B7800019627047801F3C4030B513490A680146C0310B689A80037902464032022B13D00B6800241B88958B6D00EB181B190C689BB223809279012A05D160304088096847 -:40B7C00000011818888330BD044B5B6A93830B6803249B88E7E7000080503D4040123C40F0B585B0002704460546C03403972068252201880291A978D202C90189182E466D -:40B8000040360191B17901297ED044494A68828088682168802208822068022781880291C17A1143C17203F007FDF28B6979FCF731FC0146284660300090C18203F0FCFCF0 -:40B84000B18BC9198AB26979FCF724FCB179344A012921685FD00B8AD31A1B18D833CB8103992F4B0918F07E5843081821688881B08B410002980818C01987B22068591EAA -:40B88000078020680290C089884210D9491CF7F73FF90299381A088027682149F889F7F737F9F9812068022901D20221C181B07901282BD1009920684988028809015118B1 -:40B8C000818300980321C08A09030005000D8843A035297D8907C90F09030143687D8007C00F42030A430F4901984018C26221688989C16320680B49028A0198403140185F -:40B9000042602168C98900E002E0C16005B0F0BD8089039087E7CB891B18A0E780503D407102000000103C40F8B52F4DAA6AEB6B92B29CB28378E606F60EB34214D12A4E7F -:40B94000034689074036C03300290EDA002160300177186801884180F06819680880A00602D41968A009C881F8BD1968CC8B641CCC83696A1C68A183E96A1C685704A18007 -:40B9800011061C68890FE17191041C68890EA1711968FF0FCC7AD20B3C43CC7219688A728321095C002910D11968002A07D10A884A80F1681A681180696B1A68D181296BBA -:40B9C0001A681182A96B1A68918119688A7A002A06D000224A830022042100F0BFFCF8BD4A8B521CF6E7000000503D4010B52524C001E4020019044C001944690C80816928 -:40BA00001180C069188010BD00103C402522C001D2028018024A8018406908807047000000103C403EB5044600F06EFD684606F0D5F9684600780022022836D26846817864 -:40BA40001B4803781B48994201D3002103E0D025036A6943591821604078430706D4800707D514482030007E800702D060318A8015E00A4660326846D388808883420DD9E2 -:40BA800083235B5C002B07D1C0310968C9890C2902D8012800D9401E908000E093800298002801D000F0F8FC3EBD22603EBD0000CC1E00085C21000802488068C006C00ED4 -:40BAC0007047000000503D4008B5034680786946FFF79CFFFFF7C8F9C0331968801C0988401A01210904401880B24910884207D2694609884900F7F70BF8401CC0B208BD10 -:40BB0000012008BD2522C001D2028018024A8018806908807047000000103C40F8B5054604464034A0792F462E466037C03601282AD13068798BC08BFFF750F92D49884244 -:40BB400005D2032803D24021284600F01DFBA079012819D13168788BC98B884214D18320405D0028284613D0FFF70EFE2021284600F00AFB284600F03DF9284600F0CEFA33 -:40BB8000E08A82210843E082607902280ED019E0FFF726FE4021284600F0F6FAF6F7D8FE0328E7D1E08BFAF7C3F9E3E73168788BC98B884206D1284600F006F9E08A042123 -:40BBC0000843E082BC20405D022811D13168788BC98B88420CD108480068416A284688471021284600F0D0FA208B012108432083F8BD0000FFFF000008020008F3B506460F -:40BC00000446C036306881B0818B0088FFF7E6F821792546204F4035032919D91921C902884215D9FFF720F93168898BFFF748F9717900290CD1002820D081004018C20831 -:40BC40002046A178154B7E30F9F75AFF012070718320005D00281DD1207903281AD90E4B0299703330685943AF238289DB00C91A8A420FD9A979012909D103E0E88A38430F -:40BC8000E882E3E76034C08B618B884202D0E88A3843E882FEBD000001020000C19B0010F8B582782523D201DB02D51876220446125AC03420684A43C1898918C1812068D0 -:40BCC00081898918818126682721F0890901884211D94F1C3946F6F71BFF3188081A308026683946F089F6F713FFF1812068022901D20221C1812068024980896918C863A4 -:40BD0000F8BD000000103C402521C001C90242180D4800211018016041608160C160016141618161C161016241628162C162016341638163C16304484030101801604160EA -:40BD40008160C1607047000000103C40F8B50446FFF712F88320A178005D06F039F91649086882B28868254680B246060023C035002E1CDAC006A478C00EA04217D1FFF7BE -:40BD800073F8101A01221204801880B201280ED90124CC60C8688007FCD56846FFF742FE0098002801D000F015F92C7100E02B71FEF7FEFFF8BD000000503D4010B500F04D -:40BDC000A3FB06F06DF910BD81782522C901D20289186030064A038A89180B62428A4A628A6A808A92B2120A120210438862704700103C4081782522C901D20289185E2219 -:40BE0000135A074A89184B610246603213888B615288CA61C0300068808B48637047000000103C4081782522C901D20289180A4A8918CA6A032392B21B039A43A030837D63 -:40BE4000C07D9B07DB0F1B038007C00F134340031843C8627047000000103C40F0B581782522C901D2028B1801466031244A0C899A1814604C8954608C89946004464034AD -:40BE8000E67ECD8936023543D560E48B54610C8894614C88D4610C8A14624C8A54620D7E46792D028C8A760335432543ACB294628324134E245C40360025C030002C0CD03E -:40BEC000D56200689B19808818600E4B0A2018628888106355639563F0BDCC8A03272405240D3F03BC43D4620468A489D4630468278A9C1967600768FF89E760E1E70000D2 -:40BF000000103C4000543D4030B581782522C901D2028C181C4962181368014660310B8153684B8193688B81D368DDB2CD811D0A03464033DD7615699D835569DD839369EB -:40BF40009BB20B80D5694D80156A0D82556A4D82926A92B2D5B28D82D504ED0E520B0D764271002B01D000220A770749403161180A68C03003689A804A6803681A82C9685B -:40BF80000068C18130BD000000103C4008B510490122086883B2886840060FD5FEF764FF181A01231B04C01880B201280ED90120C860C8688007FCD5002A07D06846FFF709 -:40BFC00031FD0098002801D000F004F808BD000000503D4070B581782522C901D2028B18144A9168490604D50121D160D1688907FCD50146C0310C46096809881160642170 -:40C000000D4D095A5B191963014680310B46C97800290CD000215160DB7881785B014024234319439160807806F0A2F870BD2168C989F0E700503D4000103C40044A1168AC -:40C04000FF23F13389B29943000101431160704740503D4003490869012280B21203104308617047001E3C40FEB5044680786946254648708035E8780870062027468870D6 -:40C08000C03738680088088102A9684606F08CF8002838D10520694688701E480126807A800603D5286B017E807A01E01B210846EA78002A00D102262246A032137D012B31 -:40C0C00022D089003C313B68527D9C890919012A1DD080003C30FF302D300F4F08183946F6F716FD801985B26846858060003946F6F70EFD401CA84201D96946888001A937 -:40C10000684606F051F8FEBDC9007031DBE7C0007030E0E7AC1E0008710200001CB581786A4651708321095C1170042191704030C08B908001A9684606F036F81CBD10B5EF -:40C1400086B081786C466175014680310A46C97821750821A17500212181A1725E231B5AA3810223E381D278A274012222700191C02109580988218280786075214605A833 -:40C1800006F012F806B010BD10B5807805F0F8FF10BD0000FF2806D0034B196A012282400A4390B218627047801F3C40C030026810290ED09179D18201680A884A800168FC -:40C1C000CA8B0A830168CA894A820068818981827047518AD18101688A8A8A8101684A880A8001688A7D8A710068018BC1837047F7B5064680780D46252288B0C101D2027D -:40C200008918039106AB05AA01A9FFF7EFFB3446C034374620686037798BC08BFEF7DEFD03462068798BC08B401980B2FEF7D6FD01460A98082828D1304640308279012A25 -:40C2400023D1444A914220D993421ED2002B1CD02268B97E927F891AC9B20091C08B029068466A1A8088049050430299F6F73AFD00994018401C85B202984200681A4243AF -:40C28000049840004843101803E0684680884000684321680A8810180880206800908179387E684308182521F6F732FC009881710A98082809D02068C18B4919C183803647 -:40C2C000F078254E00280DD033E03079032803D12068418B491941832A460821304600F03DF8ECE72168F88ACA8968431218CA8121688A891018888125682721E889090187 -:40C30000884211D94F1C3946F6F702FC2988081A288025683946E889F6F7FAFBE9812068022901D20221C1812068818903988019C1632068C17980798A07D20FC9079200CC -:40C34000090F1143000208430399891988630BB0F0BD0000FF7F000000103C40FEB50F460446002069460880888016460881A07801AB02AAFFF73AFB254620460123C0354E -:40C3800040302179042F02D003294AD053E0092902D0032908D030E0217EC9062DD4C18A01221943920226E029688A7A012A1AD18A8B002A10D1A2782526D201F602961960 -:40C3C000264A926862273F5B3F01BA1892B28A832249C03971184A63C18A02221143C1822179032909D12968498B062905D3C18AFF22194301321143C1822046FFF78EFB2A -:40C40000684601882046FFF7F9FB8320005D002806D168460089002802D02046FFF7ACF8FEBD2968498B062905D3C18AFF22194301321143C182002708E02868C18B491C3C -:40C44000C1832046FFF76AFB7F1CBFB2B742F4D3684601882046FFF7D1FBFEBDC0103C40F1B50B4F0025386A84B20A48406986B202E0A01984B20125012221460098FEF747 -:40C48000B1FE0128F5D0002D00D03C62F8BD000040123C40C0133C40F8B5002405F0F0FC0546174E174F27E0E80722D03078A04201D8002003E0D020396A60430818FFF710 -:40C4C00003FB01463078A04201D8002003E0D0203A6A604310180822FFF78AFE3078A04201D8002003E0D020396A60430818FFF7BBFD6D08641CE4B2002DD5D1F8BD00000D -:40C50000CC1E00085C210008FEB5684605F0E6FC68460078002830D00024184D184E29E0C00722D02878A04201D8002003E0D020316A60430818FFF7C7FA01462878A04221 -:40C5400001D8002003E0D020326A604310180822FFF74EFE2878A04201D8002003E0D020316A60430818FFF77FFD01984008641CE4B2019001980028D2D1FEBDCC1E000865 -:40C580005C21000810B50C4600F0C8FF06494018016889B20A091201FF21224301310A43C9008A43026010BD00103C4070B526490446097800204907490F40250346012963 -:40C5C0000FD002290DD0032901D0042924D100201E4E0146012C24D0032C1ED0052C25D122E000211A4E0A46012C08D0032C02D0052C09D106E0B56002210A2204E00421BE -:40C600000C2201E004210D223461306AC0B204460C42FAD03262336170BDB56202200A2104E004200C2101E004200D21F462726B14460442FBD07163706B0821884370635F -:40C64000F362D0B270BD0000F021000800F13D4080143C40F8B505460D48164600780F46A84201D8002404E00A48016AD02068430C187F20005DF9F7A7FABA1B0A20424351 -:40C680002046054B29467F30F9F73AFAF8BD0000CC1E00085C210008B5A00010044A106303488030816102494B2080390860704780103C40024610B50B460F20002180018A -:40C6C000F8F796FF10BD000013B50C46002269460F20F9F70FF869460978E0030843034980B208630249472008601CBD40113C4000103C407FB50E4604461D46002202A943 -:40C700000E20F8F7F7FF1048F10100780F4A4007400F03280BD0042809D0A00208436946097A084380B21063A009906307E0E80301436846007A014388B21063946304490C -:40C74000462008607FBD0000F021000840113C4000103C40017E012901D9012101764279C9B253000B430179CA001A4310210A4303498A6002880A604088486070470000DA -:40C7800040103C4006490978814201D8002004E00449D022096A50430818603043837047CC1E00085C2100080349884200D908460249486270470000FF0F000040113C4090 -:40C7C0000148806B80B27047C0103C402521C001C902401807494118086A1070000A5070486A9070000AD070886AC0B21071000A5071704700103C4070B50E4D14462A78D6 -:40C800005207520F012A09D0022A07D0032A01D0042A02D1224600F00FF870BD02460B46E8880021F8F7CCFE012CF6D1FEF774FA70BD0000F0210008F8B594461B4F8207B2 -:40C8400005D01A4F0023103F8E08B60015E08C08002303E09D007E5946515B1CA342F9D3A3000CE0DA191469C454240AC5186C70240A220AAC70EA701B1D9E42F2D88A07B9 -:40C880000DD00A4A103A9A18146900228907890F03E09D184455240A521C9142F9D86046012801D1FEF738FAF8BD000050F13D4010B5114909784907490F01290FD002295C -:40C8C0000DD0032901D0042908D10C49496A0170090A4170090A8170090AC17010BD084A11680170090A417051688170090AC170FEF712FA10BD0000F021000800F13D40C3 -:40C9000080143C400148806B80B27047C0103C4010B50A49F1240A681421414393681331595C24018B001B19102906D251682C225043085A02495918086010BDD401000873 -:40C9400000103C400121814010B589B200227C2000F082FD10BD0000FEB5FF210120FDF7F1FF3F210220FDF7EDFF1F210420FDF7E9FFFF210820FDF7E5FF3020FEF704F873 -:40C980007D48802101607D4C20784007400F032801D0042803D10BF03BFD0BF01FFC7748774E00784007400F022806D0032804D0042802D0012807D00BE00321316003281A -:40C9C00005D0042803D004E00020306001E00BF02FFC002211460320F8F78CFE69486A49028D4A61428D8A61828DCA610546624F00242035803709E03C636248818E62480A -:40CA000001632046FEF7B4FB641CE4B22878A042F2D85D480621C03881635A4C5A48218F816320460C30029000F0B0F9062268460299F7F75EFD69464879C02108436946D0 -:40CA40004871684600F0DAF900F0B0F8FFF702FB4A4800784007400F032829D0042827D0E08FB8634748444940304088C0314860E08D0121C903084343490862434901205A -:40CA8000086141498031C8683F2280B212029043072212021043C8603F20FDF781FF374C20784007400F022804D0012802D008E04820D6E7FEF748F9354907208861FEF72D -:40CAC0002BF9E020FEF794F8E820FEF791F8F020FEF78EF80020FBF7D3FA2C490020486110228A618915F96227494031C86022485B21016020784007400F032801D00428A7 -:40CB000001D10BF095FB20784007400F022806D0032804D0042802D001280AD00BE01D4830601D490869012280B252031043086101E01A4830601448C038416B0122114303 -:40CB400089B24163816B114389B2816314494015086014482978006805F0FEF906F00CFB00231846FFF7D0F85B1CDBB2042BF8D30D4900204870FEBD00103C40F021000844 -:40CB8000001F3C40AC1E0008C0113C40001A3C4080143C4003200000001E3C40E023000040503D40D00100089C21000804480021C1638163024974204039086070470000BE -:40CBC00040103C4070B51E4614460D4600F0A6FC0C49411808680122D20280B2012E09D0904300090001FF22284301329043002C04D005E01043044A1040F2E710221043AF -:40CC0000086070BD00103C40FFF90000F3B5254A84B0926900924A780B78120213430393CA788B78120213434A790979FF20120211438C461C499E46CA6B92B20292896B27 -:40CC4000742289B20191184940390A60174900220F7F24E00121144B9140009C403BE3181C6889B2A5B21C681B68A4B2039E9BB26E407546654064462E435C4026430CD129 -:40CC8000029B194209D00199D140CB070499DB0F8B4202D1104606B0F0BD521CD2B29742D8D8F8E7F021000840103C40CC1E000830B50A49FF20C96B094A8CB200210125B2 -:40CCC000137F05E02A468A40224204D0491CC9B28B42F7D830BD084630BD000040103C40CC1E000810B50446E020FDF781FF20782246401CC3B20021E020F8F711FC10BDAB -:40CD000042790021012A02D901214171090342790A430179042914D049001143827B032A01D8D2001143427B52010A43817909021143012252031143054A91610088D0615C -:40CD4000704711460122920211430222E5E7000000103C4000B50120FDF716FE01494120086000BD00103C4000B50120FDF718FE01494020086000BD00103C40024A1063EA -:40CD800001488030C160704780103C404178027809020A4306490A60C2788378120213434B604279007912021043886070470000C0113C404278130202781A4301290CD0D5 -:40CDC0000C498A62C278837812021343CB6242790079120210430863704707490A63C2788378120213434B6342790079120210438863704740103C4000123C404178027895 -:40CE000009020A4306498A61C278837812021343CB61427900791202104308627047000040103C404178027809020A4306494A60C2788378120213438B60427900791202B7 -:40CE40001043C86070470000001F3C40F0B50021FF2501350E4E0F4C15E0F1238A001B01D21893191A6892B2D7070AD0520852001A60884201D12A4300E0AA4301273A43AA -:40CE80001A60491CC9B2E27A8A42E6D8F0BD000000103C407C21000810B500222021302000F0DAFA05494320086001F009FDC007FBD10220FDF768FD10BD000000103C40A1 -:40CEC00030B591B0054640216846FDF7A4FF0A4C0849A1630220FDF763FD6A782021302000F0BAFA4220206001F0EAFCC007FBD011B030BDFFFF000000103C40017942792B -:40CF0000490011438279D2000A43FF2101310A4303490A6302888A624088C8627047000000103C4010B50446E820FDF761FE20782246401CC3B20021E820F8F7F1FA10BD2C -:40CF40004178027809020A430749CA63C17882780902054B0A4340331A60417900790902084358607047000000123C40024A1063014880304160704780103C40094810B529 -:40CF800081420DD8C8000521F5F7C2FD064989680818064980B2486003497220C039086010BD0000409C0000C0103C40001A3C4010B5074948200860064C206B4006FCD405 -:40CFC000002211461020F8F795FB606B80B210BD00103C4040113C400349732008600349042048637047000000103C4000113C4010B500F093FA0121490200F04BF910BD04 -:40D0000010B500F08BFA0121890200F043F910BDF0B515460F4604461E46FF2A04D000222946184600F0D6F86078237800020343E078A17800020143607922790002024336 -:40D040000C207043C419084827183B60241D23181960241D20180260FF2D04D001222946304600F0B7F8F0BD00103C40012808D8044A916901235B0299434002084380B2AD -:40D080009061704700103C40084A106348780B78000203439360C8788B7800020343D36048790979000201431161704780103C40F8B51C4615460E46074600F041FAA9009E -:40D0C000044A2143801801600349B0004018C455F8BD000000103C40D92100080149C86070470000C0103C40044A916B8905890D8002084380B290637047000080103C403D -:40D1000010B50E490B68142141439A681331515CF122890012018918094A89180A6892B2D40709D0520852000A605A682C235843105A01221043086010BD0000D401000852 -:40D1400000103C4038B5174B1B78834201D8002304E0154BD0241B6A60431B182024012906D0022904D0002A05D0002903D005E0188B204301E0188BA0431883187E8006A6 -:40D180000ED58320C05C00280AD198786946FEF7B9FC68460088002802D01846FEF766FA38BD0000CC1E00085C21000810B50C4600F0B4F90649401801688AB240218A43E4 -:40D1C000A10111430122D2029143016010BD000000103C40F12380001B01C018054BC3181868002A80B201D0084300E0884318607047000000103C4070470000F0B5174BE5 -:40D200008C07C318002C03D000209508AD0014E09408002003E01D6886008D51401CA042F9D3A0000BE01C680C54240A0E187470240AB470240AF470001D8542F3D89407BC -:40D240000AD01C6800239207920F03E0C5184C55240A5B1C9A42F9D8F0BD000000103C40134610B50A4A12785207520F012A09D0022A07D0032A01D0042A02D11A46FFF7F5 -:40D28000BDFF10BD0A460021F8F72CF910BD0000F0210008034A8018026892B20A4302607047000000103C40F0B5264BC518880703D000239708BF001DE09408002003E083 -:40D2C0008300CE58EE50401CA042F9D3A30014E0C818401C044626783046667836023043A678E4783604304324062043CC5C00022043E8501B1D9F42EAD8900721D092070E -:40D300000020920F012A04D0022A04D0032A17D107E0C85C14E0C81841780278080210430EE0C81801460A7810464A78120210438A78C97812041043090608430002000A81 -:40D34000E850F0BD00103C40F0B5424C00198C0704D000249D08AD00AC461DE09D08002403E0A6008F598751641CAC42F9D3AC0014E00D196D1C2E4637783D4677783F02B3 -:40D380003D43B778F6783F043D43360635430E5D2D0235430551241DA445EAD89B079B0F551C002B22D0012B31D0022B40D0032B1BD112780B5D1206134309198A784978E2 -:40D3C000120409020A43134303512B78EA7819466B7812061B021943AB781B04194311430902090A0019401C0160F0BD2B462D78127829465D782D0229439D78DB782D0492 -:40D4000029431B061943090211430151F0BD1678D578334656782D06360233439678095D360433432B431B020B430351D178D9E755780B5D2D062B431578091949782D04D1 -:40D4400009020D432B430351D178927809021143C8E7000000103C4070B5094BC5182868002384B2080003D104E040085B1C9BB2C607FAD08C439A40224390B2286070BDFB -:40D4800000103C40134610B50A4A12785207520F012A09D0022A07D0032A01D0042A02D11A46FFF701FF10BD0A460021F8F7A0F810BD0000F021000838B514460C4A1278FC -:40D4C0005207520F012A0BD0022A09D0032A01D0042A04D11B1F9BB22246FFF735FF38BD00930A4623460021F8F79CF838BD0000F0210008034A80008018405C8007800F43 -:40D5000070470000D921000800B500F00DF802494018006880B200BD00103C40014900014018704708420100014900014018704704420100A121000149024018704700009F -:40D54000034A928A424350180249800040187047F021000800410100054B02469B8AFF208B4203D9880003494018805C70470000F0210008C521000800B5FFF7DBFF024905 -:40D580004018006880B200BD00103C40F0B5304902460B680020002B14D10A6052070D26520F0024B601012A0DD0092503276D02FF020423022A1BD0032A2FD0042A2DD090 -:40D5C00012200C60F0BD112292018A80CA80032252028A600122D202CA6040220A8205224A828A82CC610C624C628E618C62F0BD8D80CD8001225203CF608A6012110A82E8 -:40D600004B828B82D2008E61CA61832252010A62432292014A628922520116E08D80CD800522D202CF608A60FF2201320A824B8229228B82D2028A61064ACA61054AC0323A -:40D640000A62054A4A62044AC0328A62F0BD0000F0210008C0480100404A010010B503460C460846FFF788FF02462046FFF74CFF012199400A4001400A4301D0002010BD12 -:40D68000012010BD0A4600B501461046FFF764FF00BD000010B50F4801680F480818846AFF2102310C4202D0F8F750F80DE0406B400F022801D1A00607D5FAF72BF9074867 -:40D6C0000069012180B201F071FA20460AF0E0FA10BD00006801000840F03D4000103C40F8B50446002000900E461546A178684609F07EFD002801D00720F8BD2B46324611 -:40D700002046009900F0A8FEF8BD38B50546002000900C46A978684609F06AFD002804D1009928464C7000F0F2FE38BDF8B5044600206A46107005460846FBF721FB0600AD -:40D7400004D0012806D0162E3AD10DE001236A46002102E001236A4619462046FCF7DBFB0546012804D02BE001236A461621F4E78320005D012811D1CD20005DC0070DD02F -:40D7800068460078C1090DD1C00701D0232200E02A2231462046FFF7A3FF11E068460078C0090DD068460078C10720464030002901D0232100E02A2181762046FBF75CFB8D -:40D7C0002846F8BD10B582790A4201D0FAF774FA10BD10B5044680780021FFF7CFFA01212046FDF761F810BD8030C368002B0AD00B60817A11700169C160C17A81720021D3 -:40D80000016108467047014870470000FFFF00008030C368002B04D00369002B04D004487047C160827201E00161C27200207047FFFF000000218030C160016170470000CF -:40D840008030C068002801D00020704700487047FFFF000070B505468035E8680024002806D0FBF78DFA002801D0012800D101242869002806D0FBF783FA002801D00128BB -:40D8800000D10124204670BD70B50446C0790E461546C1090AD04006400EE07101F0B6FC067021894180856006F0F1FA70BD70B50446C0790D46810601D43A2D13D13A2D7F -:40D8C00002D0DF210840E07101F0A0FC0570218941805E21095B818060342188C1806188018106F0CBF970BD38B54621095C04468034002910D1A16A00290DD18178684622 -:40D9000009F088FC002807D100980021A062C181A06A4185A06A4180A06A38BD01480078704700003C22000810B50446FCF798FA01280AD10648A178026AD020484384305B -:40D94000105CF9F7C5FF012801D000F0F3FC10BD5C21000870B50C460546F9F759FC012838D02879032803D0042801D0072830D1E079A67900020643A8783146FDF714FCFA -:40D9800001282DD0284660304683A17809020182627811430182217909024182E27811434182617981823246611C284600F09DFB02212846FAF7C2FD2846C030417B822282 -:40D9C00011434173287E0221C207D20FA878FFF7B9FB70BD01222421284600F04AFD70BD28215A2041552846FBF746FA70BD704770B50C460546FAF7E9FC00284FD120217D -:40DA00002846FAF759F9F4F789FF284661784030C176E17809028183A278114381836179C38B0A022179114320228B4203D0EB791343EB71C183E1792E460B02A179603611 -:40DA4000194333888B4203D0EB791343EB713180617A0B02217A1943738843828B4203D0EB791343EB717180C18B70888000F5F74FF8401E318880B2814200D93080012134 -:40DA80002846FAF75EFDC035687B822108436873E07AA17A000201437183F4F729FF70BD70470000F8B50D4606460027F9F7B0FB012845D0264CA07AC00707D04420805DAE -:40DAC000002806D0102803D01F212CE01A212AE001273046FBF75AFB002823D0344680340822691CE06AF6F704FDE06A697A20300172A97A4172E06A2946183008220B314A -:40DB0000F6F7F7FC29463046042213313830F6F7F0FC39463046FBF72DF8002810D1002F0FD012E007210322304600F0A2FC628A08213046FAF7A0F811213046FAF704FD61 -:40DB4000F8BD06213046FAF710FD01202070F8BDAC1E0008704770B50446403000790D46022813D126468036F06A08222030691CF6F7BFFC29462046042209313C30F6F7FC -:40DB8000B8FC2046FAF7A2FF0120307070BD10B5FBF732F810BD70B50E4605462021FAF78BF82C468034A06A002804D0A97809F0B1FB0020A06231462846FFF778FE00211E -:40DBC0002846FAF7BEFC2846FAF73BFD002070BD38B504460020009020790D46032803D0042801D007281CD12046F9F711FB012818D0A178684609F0FBFA002811D10C48B8 -:40DC00006A78807A00991040F5221040A075E07E08221043E076204600F05CFB2046FAF710FD38BD08222421204600F022FC38BDAC1E00087047000070B50D460446022126 -:40DC4000FAF73AF82046F9F7E3FA012805D009222421204600F00DFC70BD0C486978807A6A1C0840F5210840A075E07E08210843E076E079EF210840E07100212046FFF73D -:40DC800003FE2046FAF7DDFC70BD0000AC1E000870470000F3B581B004460298FBF770F805462046FCF7D1F800287DD0192D04D32046029900F0ABF976E0264640363079F1 -:40DCC000002700900300FCF70FFE0E1C1C1C08081C1C1C0808080808081C0298354A01780020135C8B4201D1012702E0401C0728F7D38320005D002801D1072901D0002F0F -:40DD000003D00098022816D02EE0A078FFF770F9002301223D212046FAF700FE3D20B0762046FFF756FDA178029809F0C9FA2046FBF7FEF8FEBDFFF7F1FD002814D1042D1E -:40DD400012D00D2D10D0112D0ED0152D0CD0072D0AD0092D08D0202217480299F6F7C9FB012000F003FC1FE020460299FFF7DEFC012819D0A8000F4D029908352A582046AE -:40DD80009047A178029809F09BFAFFF7C7FD0228D0D109480849007880002A5820469047002000F0E3FBFEBDA178029809F088FAFEBD0000D84600101C22000870B50D46EF -:40DDC00011490978814201D8002404E00F49D022096A50430C18002C15D0204600218030C1718079032802D12046FCF7F3FB2046FFF79AFD192D04D20549A80009582046AC -:40DE00008847FCF73DFA70BDCC1E00085C2100084447001010B50446403000790E2805D12046FAF72FFF01208034207010BD10B50446F9F7EDF9012802D1002040342070EA -:40DE400010BD10B5044640300179062905D00F2902D12046FAF73BFF10BD2046FAF748FE01208034207010BD70B50446054640342079072805D12846FBF7DEFF2846FAF738 -:40DE800031FE20790F2801D10020607070BD000038B5044600220E4800920D46807AF5210840C0060FD52046FBF7E0FF01280AD0A178684609F09CF9002803D12046009954 -:40DEC00000F0B4FA38BD2946204600F0A0F838BDAC1E000810B504461021F9F7EDFE2046FAF7E6FB10BD000070B5054610480C46807A400704D409782846FFF706FC70BD04 -:40DF00006078032803D1A1782846FAF75DFD6078122803D110212846F9F7CEFE60781628EDD10448A1780068C2682846904770BDAC1E00080802000810B5FAF7D1FE10BD84 -:40DF400010B54978FAF740FD10BD10B5FAF7C8FE10BD10B54421095C032901D1FAF7E8FD10BD012140304170704710B54421095C042904D00C2901D1FAF7C8FE10BDFAF7A1 -:40DF8000F5FD10BD10B50446F9F742F9014620464030012900D1417000790D2802D12046FAF7AFFE10BD70B502790D460446052A03D0062A01D0082A01D1FAF717FD687824 -:40DFC0005A21085509212046FAF7CFFAFCF7D4FE80212046FEF7D8F8FCF7EAFEA078FFF70FF82046FCF746FC70BD10B50446FF21F9F762FE16215A2001552046FAF798FF42 -:40E00000A078FEF7F5FF2046FCF734FC10BD70B50C460546FBF724FF002802D02078E87570BD21782846FFF770FB70BD70B5054648780C46032802D12846FAF7E3FC60786B -:40E04000122806D110212846F9F736FE2846FAF72FFB0748214600684268284690476078162804D10348006881682846884770BDFC01000808020008704770B50D460446B5 -:40E080000421F9F719FE6878A076E8780002E081A9780843E081687900022082297908432082E07E04210843E076800704D4204600F03AFA072815D0E079410612D5BF2112 -:40E0C0000840E07101F0A2F80021017021894180E1898180A17E4170218AC18005F004FFFCF7CEF870BD7047704770B50446C07815460A4600280AD00020E070C1B2A0783D -:40E10000FDF78EF8A0782946FEF7C8FA70BD0120F3E70000F8B5064601200C46087005221949601CF6F7E5F9B078FCF783FE0546B0786946FDF7E6FC684600880A214843CB -:40E14000114942191039887B002802D0401E4300C018101835460C30603568834A7C0B7C12021A432A82CA7C8B7C12021A436A82097DA982A071000AE07108223146204694 -:40E18000FCF7BCFAF8BD00006C2100087CB505468030866A0C46A878FCF74CFE014628465C30009001AB3246284600F031FAA878FCF740FE69468988FCF710FE69462846F4 -:40E1C0008988603041830021217029464031CA7E62700A7FA2708A8B120AE2708A7F2271C98B0C22090A61710178A1710188090AE1718178217240886946000A6072888885 -:40E20000A072000AE07229462046FCF777FA7CBD70B5054603200C4608702E4680360822601CF16AF6F765F9F06A08222030017A6172407AA072F16A204618310B30F6F70B -:40E2400058F929462046042238311330F6F751F9172229462046FCF751FA002070BD70B50546042008700C46AC20415908222031601CF6F73EF92946204604223C31093056 -:40E28000F6F737F90D2229462046FCF737FA002070BD000070B505460C46C07910210843E8710820207002460021601CF6F72AF90748F522817A11406170C07A0922C007A0 -:40E2C000C00FA07029462046FCF718FA002070BDAC1E000870B5054609200C46087008220021601CF6F70EF9A87D607005480922C07A2946C007C00FA0702046FCF7FEF91C -:40E30000002070BDAC1E00080B4610B501460A20187001221846FCF7F1F9002010BD0B4610B501460B20187001221846FCF7E6F9002010BDFEB50020694608720546334F4B -:40E3400060E03348016AD02068430E183046FFF777FA002854D18720805D002850D101AA69463046FFF740FA002849D100980478002C09D0012C16D00C2C23D0092C21D000 -:40E3800069460A79314629E0012302AA00213046FBF7C1FD012804D030460099FFF7F6FE2EE00C221FE0012302AA19463046FBF7B2FD012804D030460099FFF7ABFE1FE073 -:40E3C000082210E0012302AA21463046FBF75CFD00286846027906D131460098FCF78EF9022C05D00CE031460098FAF7E5F907E0B0780121FEF7DAFE09213046FAF7B5F851 -:40E400006D1CEDB23878A8429BD8FEBDCC1E00085C21000810B50B46122119708178D977014601221846FCF769F910BD10B50B46132119708178D9770649896AC90603D16F -:40E44000018B402211430183014601221846FCF755F910BD00113C4010B50C461121217062700146A37003222046FCF747F9002010BD38B50446002000900D46A1786846C1 -:40E4800008F0B6FE002801D0072038BD00980D210170457002222146FCF730F9002038BD0B4610B501460520187001221846FCF725F9002010BD0B4610B50146062018705F -:40E4C00001221846FCF71AF9002010BD38B5044600200090A178684608F08AFE002801D01F2038BD009D022028705A20005D6870A078E877208B1021084320832046FFF7AA -:40E5000068F9022221462846FCF7F8F838BD10B50B46072119708178D977014602221846FCF7ECF8002010BDF8B50546002000900D4EA9783488684608F05AFE002801D035 -:40E540000720F8BD00980C210170717941708470210AC170F2880271110A417106222946FCF7CCF80020F8BDAC1E0008094A1178002906D0012909D0022908D1002807D00E -:40E5800001E0012804D00021002900D0107070470121F9E73C22000800B500F016F800BD704770B50546FFF79FF9044602884188A87804F085FCA084E0886082A088208235 -:40E5C0006088E0812088A08170BD4018400870470246603000885E21895A401C4843C10800D101214008528A00E0401A8242FCD9704710B56021095A80780A01511A10311A -:40E600008CB2FCF717FC2146FCF756FA10BD0000FFB581B0054604464035288A69460A9F08801E46A078FDF76DFA694609880A20491C41431048807B002802D0401E420087 -:40E640008018081881B20298FCF736FA3080A07804F024FC06468320005D012804D1E98BA078042204F0C2F9A078314604F05CFD388005B0F0BD00005C210008F8B51546E8 -:40E680000E46074600F00EFA0446012804D02A463146384600F0B6F92046F8BD014600B50020890701D500F00BF900BD014600B50020890701D500F003F900BDF0B593B015 -:40E6C0000020FF210391059007901290012612A92F2005F008FD002804D000F097FD0446002600E0129CFEF76BF881040507890E40060891C00F891F2D0F06900491202949 -:40E7000031D2062D2FD800F0DBF8C0072BD03E2020700220A0700120E07003210420624F062D2DD0022D2ED0042D2ED025715E48417949084900417106986071A01D06216C -:40E74000FCF769FBFCF79CFC070006D0574A611D1268A01D126A904703900498012DC0B2029020D044E0002E02D0204605F0C2FC00F04CFD402102A8FCF74DFB13B0F0BDB4 -:40E7800002202071D3E72171D1E720717879C007CDD0002E02D0204605F0ACFC002600F035FD0446C3E70398FF280BD040482C220068416803985043095A4120884301D16A -:40E7C000012007903B48407E012804D10799002901D1012F02D0002F06D007E00120059020730D270B2006E00128F7D00020029020730D270220A0700898062824D0049812 -:40E800002746C1B20D373846FCF705FB0598012817D12948006B03A9C007C00FFCF730FBA07C8009012806D13946062203A8F5F751FE002805D10020203FF8770290022087 -:40E84000A07002980D30C7B2FEF75CF8694688806A4601A90620F6F74DFF69460878E0557F1E16486770407801280BD12A46A01D069900F017F9012811D02A46A01D0699EA -:40E8800000F0C0F8002E04D02046059905F018FC74E7054801224179114341716EE7204605F028FC6AE700005C210008EC010008D4010008A021000800103C407D2200089E -:40E8C0000248806B0004000E7047000000103C4010B50446000701D5FFF7F0FEE00601D5FFF7ECFE0248006881692046884710BDEC01000810B502460178FFF7E1FF814270 -:40E9000001D10C2010BD0D485378002443705470002908D000F06EF81046FEF7D1FA0420F9F74AF907E01046FEF7B6FA0520F9F743F903480476002010BD00007D22000801 -:40E940007C210008F8B50446FFF7BAFF002801D00C20F8BD6079164DFD2702260128E8781DD03840E87013480068416820468847A0790128A87814D03840A8702046FEF7D2 -:40E98000BDFA0B48218862882030914203D1017E0122114301762179012904D006E03043E0E73043E9E7017E314301760020F8BD5C210008EC01000838B5002001460090BE -:40E9C000684608F0FFFB002801D01F2038BD009C002161712171A1711021218020466180FEF78CFA204608F077FC00F003F8002038BD000002480021017007218170704706 -:40EA00007D220008F7B50C2082B0254D0F46002400902878E040C0072DD02148E10040380E18062230460299F5F754FD00280AD1B079B84207D1F079002801D0062802D167 -:40EA4000049804280BD02878E040C00713D0641CE4B2082CDDD300980C2803D00BE00420F07119E0A878401CC0B2A870082801D10020A870C4B20A48E10040380E180622D8 -:40EA800030460299F5F735FDB7710498F07128780121A14008432870002005B0F0BD00007D220008F7B5164E00243546403529780120A040014217D0E0008719B979019818 -:40EAC000814211D1062238460099F5F703FD00280AD1F879022810D004280ED001280CD0002807D0062805D0641CE4B2082CDED30020FEBD02980428FAD00120FEBD000075 -:40EB00003D22000801484078704700007D22000870B5064614460D46500702D5A8B2FAF72DFE200702D5B0B2FAF7E8FBA00702D5280CFFF7CDFEE00702D0300CF9F72AF99E -:40EB400070BD70B5044660C8F8F7C8FA2089C01F0300FBF7C9FE0C071A121E212412122712171312F3F7F4FE032801D1F7F76EF9294630466289FFF7CBFF70BD284604F054 -:40EB800063FD70BDFAF750FB70BD2846F8F74CFC70BDF8F74DFF70BDFAF76CFB70BDFAF793FB70BDE8B2FAF7ADFD70BDF3B5002189B0069105910C460391009101910291C7 -:40EBC000F74989688EB230400490B00618D5FCF74BF9F44908800120F6F7B2FEF24900200870F3F77DFE012802D10020F6F72CFE2020FBF7A1FE0420F7F75CF901200590EA -:40EC0000EA487107009024D5E5484030006987B20498400718D5F80613D5E5480021026A009800780BE0884201D8002502E0D0234B43D5182B79022B29D0491CC9B288426B -:40EC4000F1D8B80880000390394600220420FBF759FE300775D5D748406B80B20190D0488030806A87B2049800076BD5019804218843384367D0D048C06BC006C00E02906A -:40EC8000009801780298814211D8002515E02846FDF7E4F82846FCF777FD2846FDF74FFA40212846FDF770FAFDF770F9C9E7C048D022016A029850430D18002F05D02846C2 -:40ECC0004030C18A3C433943C18201988207B84801463C31403006910090002A3DDA2879002803D1C420405D002833D102212846FCF71AFE2846FDF7B7F907A90298FCF738 -:40ED000001FFA878012103F0A1F9002817D1FDF755F8002813D14620405D012807D1C0217A204959405BC98B401E884207D08320405D002808D16846808B002804D0012081 -:40ED400006E0ABE099E095E00698FCF76BFE0020009908700120F6F703FEF80657D52879002803D1C420405D00284DD104212846FCF7DAFDF3F7ECFD03280CD1C0204059BB -:40ED8000807A002810D18320405D00280CD101212846FCF785FFC0204059807A002803D18320405D00280DD000980078012809D0002810D17E480021C06B807803F046F9F9 -:40EDC000002808D02846FDF74FF90698FCF72AFE0099002008707648C06B002809D001216A465172017B1172FDF7F4F802A8F6F739FD28460A3009F015FA2846C0300179CC -:40EE0000002901D1012101710220F6F7A9FDF80705D07805400F022801D1F6F7A1FD28464030018B06912946C031CA88C08A824201D00443C880087B002805D1A035287F49 -:40EE4000012801D010208443600609D500984078002802D04020844302E0009801214170394600220820FBF74DFD544901980840504948633F2000028443019840070DD5EE -:40EE8000F6F71EFBF6F78CFF4A4904204863FCF7BFF9012802D10220F6F762FDB00719D53F48806B85B20498800709D50399280408430390FFF704FDC00701D00120059023 -:40EEC00081210398490488430390294600220220FBF718FDF0073AD03148006A85B20498C0072CD02804044329208001054206D033492846096849698847012864D005203E -:40EF000040068443A8071AD50220F6F729FD284F2037B87AC00712D0787B00280FD0387BF97A88420BD2274800688168387B14225043801D0818FDF775FF00207873812074 -:40EF400040048443294600220120FBF7DBFCF00605D50120F6F7F4FC1020FBF7EDFC700602D54020FBF7E8FC039806992043084301D00120059007206946088103980090B6 -:40EF80000194049848810598002807D069460EC90A98002850D0002008F04CFA0BB0F0BD00103C40E6010008CC010008CC1E00085C21000800113C4000503D40FBFF00006A -:40EFC000EC010008D4010008FBF784FB074600218030C170384640300090807BFF2808D138464830FBF7BCFF384600214730FBF7D5FF00983946C0794831FBF767F8FF2846 -:40F0000005D0292080058443FDF7AEFE7AE73846FCF77AFF3846FCF7E3FB3846FCF71EFF3846FDF78CF840213846FDF7ADF8FCF7ADFFFDF78FFE65E7002008F040FAADE7DE -:40F04000F0B587B0054605A81E461746019100900C9C04AB06AA02A903A800F0CFF92846FCF706FA21463046FCF78AF96846017A0398FBF79FFD05A904A8FBF74DFD68467A -:40F08000027E21463846FBF71BFD07B0F0BD000070B50948C4782046F8F758FE06462046FFF7FCFA05462046F9F7C8F9014630462843084370BD00005C21000870B5094885 -:40F0C00084782046F8F74AFE06462046FFF7EEFA05462046F9F7CEF9014630462843084370BD00005C210008F8B5069E1F463478042C17D3231FDDB23B460095FFF7A0FF62 -:40F100003819001FFCF7EEF90520FDF74FFA0446012229460798FDF76FFB3570E00701D00020F8BD1F20F8BDF8B51C46009301271346069E079D3A46FFF782FF2846FCF761 -:40F14000D1F90520FDF732FA0546012221463046FDF752FB2846F8BDF8B51D4616460F460024FCF785F931463846FCF709F90320FDF71CFA012231462846FDF73DFB2046CA -:40F18000F8BDF8B5069D089E2C780094FFF758FF0120FDF70BFA07463046FDF789FB0023224631460798FCF773F8241D2C70780701D41F20F8BD0020F8BDF8B51C4600932F -:40F1C00001271346079E069D3A46FFF739FF0120FDF7ECF90746002221462846FDF70CFB3046FDF765FB3846F8BD10B500F02CF90446F9F7B7F80128F8D1204610BD10B5B5 -:40F2000000F022F90002000A10BD0000004870478422000808B500F017F96B4600210090585CC006C00E421F0B2A04D9491CC9B20429F5D3EFE708BD08B56A4600210B203A -:40F24000F6F758FA6846007808BD0000FEB5064601200290042017460D46444C0090FBF703FE28802146FBF727FC3080F8070BD0FBF73EFE019028880199FBF721FEA04221 -:40F2800002D2044601983080B8070BD5FBF742FE019028880199FBF713FEA04202D204460198308078070AD5FBF728FE074628883946FBF705FEA04201D204463780F6F765 -:40F2C0000BF900280AD0FBF709FF074628883946FBF784FDA04201D2044637802448807B00283BD0FBF710FE074628883946FBF7E7FD0546A04231D2FCF7DEFB1D4909789A -:40F30000814201D8002004E01949D022096A504308180190F7F77CFF002817D101983D21C0300068C089F3F7F3FB401DC0B200900A280BD90A21F3F7EBFB0091854204D39A -:40F34000391A281A8FB285B200E0002537802C460198F7F75DFF002800D102900098FDF7BDFE0298FDF7C0FE2046FEBDFFFF00005C210008CC1E000810B50E4C0C492346DE -:40F380000833A160002142189278002A00D05A54491CC9B20429F6D3FF21A0689A314843A06000F051F8F8F7DDFF0128F9D110BD040302015C21000870B5059C049D207046 -:40F3C000060A6670060CA670000EE0704806D101400E0843207104221946601DF5F789F82046042229460930F5F783F870BD00000149086070470000E8010008F8B5079C76 -:40F400000E46E178069D09020160A77839430902016067783943090201602778394301602079611D4006400E30702079C009107004221846F5F75DF821460422093128469F -:40F44000F5F757F8F8BD000010B5FBF70DFD094A916848400849096848408108C3084409414063405940C30F59404008C9070843906010BD5C210008E8010008F3B5074669 -:40F4800081B00E4800240E4E0E4D10E031682C234A6821465943535CDB0706D01B315118029801F02BFB002805D0641CE4B2E97AA142EBD8FEBD3C70FEBD0000FFFF000054 -:40F4C000D40100087C210008FFB585B00C4600200090A004850E0E99684601810026FFF711FB6106C90F27073F0F0191012805D13A460798FFF7C2F8012849D069462F200E -:40F5000004F0F1FD002843D1009C3E2020700599022001290CD0A070A81FC6B20120E0703B00FBF7E1F907080A0C120E121012000B20A070F2E7002008E0012006E00320D7 -:40F5400004E0042002E0022000E0FF20207101986071A01D06220799F4F7CBFF0598012818D0267320460D30AA1F0899F4F7C1FFED1DEDB203AA02A90620F6F7BBF86846D7 -:40F58000007B60556D1E65702046059904F098FD09B0F0BD01202073E4E700000249014808607047A8470010EC010008704700207047FF2070470120704710B5400606D580 -:40F5C000FF210020FAF736FA0220F8F7F5FA10BD7047704770470020704770477047002070470020704700207047002070470020704700000249014808607047EC4700104A -:40F60000EC01000870B512248AB00D46064600292FD000200290039004900590102202A92846F4F757FF002823D00821684607F040FB6946487940214006400E08436946FC -:40F64000487103226C46C91C02A8F4F752FF0322E11CF01CF4F74DFF06AA294602A8F7F755F90404240C04D1032206A93046F4F740FF20460AB070BDF0B50546FF2129704E -:40F680000022144C144B072011462468DB7A0FE02C2766684F43F65DF60707D014274F43A6681337F75D0126BE403243491CC9B28B42EDD8D143002207E0CC0702D02A7060 -:40F6C0000020F0BD4908521CD2B29342F9D90029F3D1F0BDD40100087C21000870B50546FF210D4A297014680C4A0A480021D37A0CE02C2266684A43B25AD60704D052077A -:40F7000002D52970002070BD491CC9B28B42F0D870BD0000FFFF0000D40100087C210008F8B50C460546FF206946087068798009012807D022782946684601F063FA68463D -:40F740000078F8BD2946684601F092FA68460178FF29F4D00A4E2C22306851434068091D411806222846F4F7C4FE30682C2241686846007850430A30085C801C2070DEE79C -:40F78000D40100083EB50446FF206946087213480068C007C00F19D001216846FBF7E0FB684640798009012813D02278694602A801F028FA6846017AFF2907D008482C2240 -:40F7C0000068514340680A31405C20706846007A3EBD694602A801F04BFAF7E7001F3C40D4010008F0B589B01646044600256A461570FF201075CC48072700680278CB483D -:40F800000790C07A82426FD2204606F0C7FB07006AD10C27F7F7E2F8FBF732FC002804D0C248203840784007F2D1A27A211D684601F0E8F9BE490746884220D1684606902A -:40F8400000208446FF206946087007990727CB7AB5490020096807910EE007992C2249684243895CC907C90F614503D106990027087012E0401CC0B28342EED80DE0002E61 -:40F880000BD1A9486A46006881681078142250431330085C6A46107501252846384303D105A8FFF7E9FE0746002FB1D16846017D9D48142300688268684600785843133044 -:40F8C0001154012E11D098482C230068002241686846007858430A52934800684168684600785843801C0AE01AE18F482C220068062341686846007850430A5A1A400A52B4 -:40F900000020019002900390049087482C230068A27A41686846007858430A300A54824800684168684600785843002A03D00A5A10231A430A527C482C22006841686846FF -:40F94000007850430B300818214610220B31F4F7D0FD75482C22006841686846007850431B300818214610221B31F4F7C2FD6E482C2200684168684600785043001D0818BA -:40F980000622211DF4F7B5FD6748142200688168684600785043081806220021F4F7B2FD6148142200688168684600785043801D081806220021F4F7A5FD5B481422006895 -:40F9C00081686846007850430C30081806220021F4F798FD012E33D0534C2C22206841686846007850431B300818102201A9F4F771FD0223002820686946406809780FD00B -:40FA00002C225143425A1A43425220686946426808782C214843801C115A012319430EE02C225143425A9A43425220686946426808782C214843801C115A4908490011527D -:40FA4000394C2C22206841686846007850430B300818102201A9F4F73DFD0028206822D06946097842682C204143505A04231843505221682C234A6869460978594380235A -:40FA8000184350526946226808782C21414353680B315918142392685843801D1018FFF7B1FD074608E04168684600782C2250430A5A84239A430A5220682C2142686846CC -:40FAC00000784843011D0A305118105CFDF79EF80823FF28206869464068097804D02C225143425A1A4303E02C225143425A9A43425220682C2241686846007801235043BD -:40FB00000A5A1A430A52684600210078FAF754FF38462843304303D120680178491C0170384609B0F0BD0000D40100087C210008FFFF000038B50A461B4909784907490FE8 -:40FB4000022903D0032901D004292AD11749897A490626D50146684601F054F80006000E1FD1134C2C222068082341686846007850430A5A1A430A5268460078FAF7D6FAB9 -:40FB800000280AD020682C22416868460078012350430A5A9B021A430A5268460078FDF7AFFA002038BD0000F0210008AC1E0008D4010008F1B584B000260396FAF78AFD7C -:40FBC0000446FBF75DFA002830D0049880057DD5FF2069460870002101A8FBF7C1F96946487A8009012824D0022836D001273A4601A9684601F006F805000AD0012047405E -:40FC00003A4601A9684600F0FDFFB6490546884225D0B5482C2200684168684600785043085CC04380071AD4AE4D1AE0012005B0F0BD01A96846FFF721FC050011D101201B -:40FC40000390A9482C22006841686846007850430A30095C4720015503E00027C7E747200755F8F78BF8002D57D1012823D0042821D00220F8F75EF801281CD19A4D2C2160 -:40FC800028684268684600784843011D0A305118105CFCF7BBFFFF283FD028682C22416868460078082350430A5A1A430A5268460078FDF725FA039800281CD08A4D1422CC -:40FCC0002868816868460078504300E032E00818062201A9F4F70DFC286814228168684600785043024613328B5C08187F492022096AFDF78DF9684600784E2108557A4952 -:40FD00002C22096850434968001D0918204606224830F4F7EEFB012675E0754880694007800F012803D100217248FDF743F8FDF71BF868E00498400665D5FF2668466E49B4 -:40FD40000670684F0868012280B2920310430860002101A8FBF704F9FBF792F925464035AE73012600284ED06846407A8009012828D0002201A9684600F044FF002806D0E0 -:40FD8000012201A9684600F03DFFB8420AD056492C2309684A68694609785943515CC943890701D5002812D05448807AC0072AD00020FDF71DF94E4880694007800F0128C3 -:40FDC0001AD01DE001A9684600F052FFEAE768460078A87344492C230968584303464A680A33D25CEA714968001D0918204606224830F4F77EFB06E000213E48FCF7DAFF16 -:40FE0000FCF7B2FF0026049800053CD5FF2568460570344E002101A8FBF7A2F8002201A9684600F0EFFE002806D0012201A9684600F0E8FEB04221D02B492C2309684A68B8 -:40FE4000694609785943515CC943890716D428488169006A89B2C0050CD44807800F012803D100212348FCF7A5FF0020FDF7C0F8FCF77AFF4034A5730020D8E6002804D043 -:40FE80004034A57301263046D1E6174D2C222868022341686846007850430A5A9A430A522868142281686846007850431330085C00221946FDF78EF96846214600784031F3 -:40FEC00088732A682C256843054653680A355B5DCB715168001D0918204606224830F4F708FBCFE7FFFF0000D4010008F021000800103C40F0010008001F3C407C210008E6 -:40FF0000F0B500278BB004463E46FAF7E3FB08907A4D60057ED500200690059009A9039004900191009007AB03AA05A90320FBF745F86946898B4906CA0F002816D16846B9 -:40FF4000407C03A98009012802A815D000F05AFE6B4988420AD029682C234A686946097A5943515CC943890700D465486946497E8909012904D011E0FFF780FA0127F5E7A3 -:40FF8000002873D128682C2241686846007A50430B30091805A800F0B1FD0126002865D10120F7F7C7FE01281BD169460A7A28682C214A434068131DC1180A32805CFCF725 -:40FFC00025FEFF2852D028682C2241686846007A082350430A5A1A430A526846007AFDF78FF83800474F1AD02868142281686846007A50430818062203A9F4F77AFA286863 -:020000041001E9 -:40000000142281686846007A5043024613328B5C081800E02AE02022396AFCF7F9FF002E24D028682C2241686846007A402350430A5A1A430A522868142281686846007ADD -:4000400050430C300818062205A9F4F752FA2868142281686846007A5043024613328B5C0C3008184022796AFCF7D2FFE00606D525490868012280B2D20310430860E004D9 -:400080002AD500206946087209A90191009007AB03AA05A90320FAF791FF00281CD16846808B03A94006C20F6846407C8009012802A804D000F0A6FD002803D00CE0FFF7D8 -:4000C000DDF9F9E728682C2241686846007A5043085CC04380070ED509208001044201D1200508D508984030817B0020F9F7A2FC0220F7F761FD0BB0F0BD0000D401000806 -:40010000FFFF0000F0210008001F3C4070B50C24F6F764FCFAF7B4FF002803D00E484078400717D1FAF786FD0C4D002128680A4C01702034E27A2C214A4340680021F4F70C -:40014000E1F9E27A14204243286800218068F4F7D9F90024204670BD5C210008D4010008F8B5144800784007400F022803D0032801D004281DD11048807A400619D500244D -:400180000E4F08250E4E11E038682C21426820464843115A0B4BA94311523A681940526811522046FCF7ACFF641CE4B2F07AA042EAD8F8BDF0210008AC1E0008D401000813 -:4001C0007C210008FFFB0000F0B504468BB0AD48002607903546600605D4A00603D4E00501D4A00528D5FFF711F809A90191009008AB03AA05A90020FAF7E0FE0790600624 -:4002000001D4A006EED5002069460872FF2000900798002810D1088C41060007000F01906846407CCA0F8009012803A902A804D000F0E8FC002804D000E1FFF71FF9012659 -:40024000F8E76846407E904F8009012810D1019801280DD138682C2241686846007A50430B30091805A800F049FC01250028E3D186488078F8F7FEF801281CD169460A7A9B -:4002800038682C214A434068131DC1180A32805CFCF7BCFC0090FF28CED038682C2241686846007A082350430A5A1A430A526846007AFCF725FF019801283DD1002D3BD01A -:4002C0003868002E05D081686846007A1422504305E041686846007A2C225043001D0818062203A9F4F7F6F80006000E01D1002E24D168463A68007A2C23434351680B3361 -:40030000C9181423926858430C301018FFF77AF909903868142281686846007A504302461332801D8B5C081859498022896AFCF76FFE099800287DD1002E3CD03868142241 -:4003400081686846007A50430818062203A9F4F7D0F83868142281686846007A5043024613328B5C08184A492022096AFCF750FE0098FF281FD0386842686846017A2C202E -:400380004143505A430702D5019B012B01D1002D03D001235B021843505238682C2241686846007A202350430A5A1A430A526846007AFCF7A5FE002D40D038682C22416892 -:4003C0006846007A402350430A5A1A430A523868142281686846007A50430C300818062205A9F4F786F83868142281686846007A5043024613320C308B5C08182449402294 -:40040000496AFCF705FE21482030807A400715D50098FF2812D038682C2142686846007A4843115A4B0703D501235B0219431152684600E002E0007AFCF762FE200606D531 -:4004400014490868012280B2D20310430860E00501D4A00510D5002069460872079800280AD1088C4006C20F487C03A98009012802A803D000F0C6FB0BB0F0BDFEF7FEFF46 -:40048000FAE70000FFFF0000D40100085C210008F0210008001F3C4010B5054A01781175411C034806220E30F4F723F8002010BDA0210008F8B515461E46024600206B46E5 -:4004C0001870684600F09EFB0406240E02D002242046F8BD0948002E006881686846007802D01422504302E014225043801D091806222846F3F7FDFFEAE70000D4010008CA -:400500000148C07A704700007C210008F8B50646002768463C4D0770286802240078002818D0304605F03EFD040013D10C24F6F755FAFAF7A5FD002803D0344840784007CD -:4005400008D13278711C684600F05CFB0406240E02D002242046F8BD28682C2241686846007850430F5268460078FCF7D1F9296808780028EED06A461278431E93422AD042 -:400580004B682C2148432C3819182C20424398182C22F3F7AEFF2968142288680978142351436A461278143941185A4380181A46F3F79FFF28682C224168007850432C38BF -:4005C00008180021F3F79EFF2868142281680078504314380DE048682C214A4380180A460021F3F78FFF286814228168684600785043081814220021F3F784FF28680178E0 -:40060000491E0170A6E70000D40100085C21000838B50A46174909784907490F022903D0032901D0042922D11349897A49061ED50146684600F0E6FA0006000E17D10F4B56 -:4006400069461868097842682C204143505A0824A043505219682C234A68694609785943074B1840505269460878FCF749FD002038BD0000F0210008AC1E0008D401000816 -:40068000FFFB0000F0B58BB00446FF206946087200200A90A00605D4600603D4200601D4A0057DD5FEF7B2FD08A909900191009007AB03AA05A90020FAF780FC01908E4E4F -:4006C000A00601D460066CD50198002869D10025694600950D72888B4006C20F487C03A98009012802A804D000F08CFA070009D013E0FEF7C3FE070001D001250DE0012020 -:400700000A900AE030682C2241686846007A5043085CC043800700D4784F6846407E800901281BD16846808B0007000F012815D130682C2241686846007A50430B300918D4 -:4007400005A800F0DBF9002804D00225384304D0012703E001210091F8E70027002F7AD167488078FDF7A2FF01281ED130682C2142686846007A4843011D0A305118105C95 -:40078000FCF744FAFF2866D030682C2241686846007A082350430A5A1A430A52684601E0A5E06EE0007AFCF7ABFC30682C2142686846007A4843115A4B0707D501235B0247 -:4007C000194311526846007AFCF79AFC00984D4F002824D030686946097A40682C225143425A40231A434252306869468268087A142148430C301018062205A9F3F779FEE7 -:40080000306869468268087A1421484301461331535C0C3010184022796AFCF7F9FB0A98002818D03068142281686846007A50430818062203A9F3F75CFE30681422816868 -:400840006846007A5043024613328B5C08182022396AFCF7DDFB002D13D06846818B0807000F012805D12848407E012801D1022D10D06846008C009003AA0020099BFEF72A -:4008800023FEA00533D50020694608720198002807D015E06846008C009005AB03AA0120EDE7888B4006C20F487C03A98009012802A81ED000F0A6F96846007AFF2816D0D0 -:4008C00030682C2142686846007A4843115ACB439B070CD50A4B20339B7A9B0707D501235B02194311526846007AFCF709FC0BB0F0BDFEF7C3FDDFE7D4010008FFFF000061 -:400900005C210008F0210008A021000870B5054605F05AFB04000DD107484078400709D1F6F75CF8FAF7ACFB01462878884201D0FAF7E4F9204670BD5C21000870B50646DA -:4009400005F048FB040010D1094D287EF5F73CF900280AD132887D20EA82C00042432846044B00211830F5F7CBF8204670BD0000A02100085D0B011038B505460020694681 -:400980000C240870FAF77CFB002803D01E484078400708D12A78691C684600F033F90406240E02D00224204638BDE8790223174A002810684168684600780ED02C2568433E -:4009C0000D5A9D430D521068142281686846007850431330085C002211E02C256843851C4D5DED07DFD00D5A1D430D521068142281686846007850431330085C01220221FA -:400A0000FCF7E8FBCFE700005C210008D4010008F8B50024264E054600291AD00C213046F4F760FC0004000C40D1E9792C2041433068001DF4F756FC0004000C36D1E9797D -:400A40001420414330680830F4F74CFC0004000C2CD118484022817A002711438172E879154D2C21E87230680770EA7A40684A433946F3F747FDEA7A1420424330680021EE -:400A80008068F3F73FFDFF2007E014223168624313328968641C8854E4B2E97AA142F4D8E1200649AF728000C8820020F8BD0000D4010008AC1E00087C210008A021000847 -:400AC00070B5FF2815D00B4A0446126853682C2254431A5BD5070CD055070AD5002903D0012189020A4301E003490A401A53FCF707FB70BDD4010008FFFB000070B5164C4A -:400B000088B00E46050023D0002E21D0002000900190029003906879400619D5102269463046F3F7D7FC0006000E11D00322E91C6846F3F7DEFC04AA31466846F5F7E6FE4F -:400B4000032204A92846F3F7C5FC002800D10024204608B070BD0000FFFF0000F8B51E491F4B0878401E08701C480021C28A7D20C000424319481830F4F7C2FF0024194DBE -:400B800023E0194B20461A682C26516870430E5CF60718D00B30091820461423584392680746861D9019FEF72DFD0006000E0AD10D48133700680D498068896AC35D8019B3 -:400BC0008022FCF725FA641CE4B2E87AA042D8D801206873F8BD00007A010008A02100085D0B01107C210008D4010008F021000810B5014606220248F3F77BFC10BD00007A -:400C0000F0010008F7B582B016490091FF20029900240870144E154F1FE030682C21254640684D43291D401806220399F3F752FC002810D13068294640680A31425C049982 -:400C40008A4208D1405DC00705D0029804700020009005B0F0BD641CE4B2F87AA042DCD80098F6E7FFFF0000D40100087C210008F3B581B0FF200199114F08700024114D77 -:400C8000114E17E02868062281681420604308180299F3F71FFC00280AD1286841682C206043085CC00703D001980027047004E0641CE4B2F07AA042E4D83846FEBD00000E -:400CC000FFFF0000D40100087C210008FEB50446002069460190087007460646014606225448F3F70FFC5348FCF72AF96079524D022801D003287DD1A279E11D6846FFF7AC -:400D000081FF0606360E23D14C482C230168684600784A684343D25C120619D5142289685043801D0818FCF77DF84448142200688168684600785043024613328B5C801D55 -:400D40000818892180224901FCF762F9012001902079012801D0042815D168460078FF2811D036492C22096842434B681B329A1889681423584308181146FEF743FC0606FB -:400D8000360E0BD000260198002842D0A87A01210843A87268460078287345E0274F2C2238684168684600785043085CC043800702D5E01DFCF7C4F83868142281686846E8 -:400DC0000078504309180622E01DF3F792FB386814228168684600785043024613328B5C081817492022096AFCF712F938684168684600E014E000782C2250430A5A012360 -:400E00005B021A430A5268460078FCF779F90127B9E76079022801D0032801D1801E6071A87A40084000A872002F01D00120A0713046FEBDF00100087C210008D401000867 -:400E4000F0210008F3B587B00C46FF206946087000250595019508728548039060792F46022801D0032800D10127207E022801D0032800D10125FAF703F9002810D02079FD -:400E80007C4E012819D06279002F01D0921ED2B2A11D6846FFF7B6FE0390002816D0BEE0002F02D06079801E6071002D02D06079801E6071002009B0F0BD002DEFD002A846 -:400EC000FEF70CFC039000287ED0A8E06A482C230168684600784A6843431B33D31889681422504308181946FEF78CFB0799039040310491002836D0002D66D05E482C22F0 -:400F000000684168684600785043085C40075CD506220021A01DF3F7F5FA04986179C1710121A01DFBF746FF534D1422286881686846007850431330085CFBF787FF2868B7 -:400F40002C22416868460078032350430A5A1B021A430A5268460078FCF7D2F8B07A04210843B07279E04448142200688168684600785043024613328B5C08183F4920223F -:400F8000096AFCF745F806220021A01DF3F7BAFA04986179C1710121A01DFBF70BFF0120019035482C220068FF23416868460078013350430A5A1A430A5268460078FCF794 -:400FC0009FF82D48006801E01AE028E0816868460078142250431330085CFBF737FF002D1DD025482C2100684268684600784843115A4B0713D501235B0219431152A9E7E7 -:401000001D482C220068012341686846007A50430A5A5B021A430A526846007A9CE7B07AFB210840B072002D17D00598002814D1207E801E20766846007AFF280DD00E4925 -:401040002C2209685043496801230A5A5B029A430A526846007AFCF753F8002F05D00198002802D16079801E6071039823E70000FFFF00007C210008D4010008F0210008CB -:40108000FEB5054640790027424E022801D0032845D16846FEF722FB07063F0E12D13E4C6846226800782C21414353680B315918142392685843801D1018FEF7A3FA0706E6 -:4010C0003F0E05D06879022827D0032825D026E020681422816868460078504302461332801D8B5C08182D498022896AFBF790FF0120687120682C224168684600780123C6 -:4011000050430A5A5B021A430A5268460078FBF7F7FFB07A022108431CE0801E687101204002002401900FE01B482C22006862434168019B885A98438852C00702D02046E9 -:40114000FBF7DEFF641CE4B2F07AA042ECD8B07AFD210840B0720F49A8792039104A03280BD0022812D001280CD0002050768878FD22104088703846FEBD01205076A879F7 -:40118000801EA871887802221043F3E701205076F1E700007C210008D4010008F0210008A021000810B509490748096888420AD10748084BC28A7D20C0004243044800214B -:4011C0001830F4F79DFC10BDEC470010EC010008A02100085D0B0110F7B515460C46F9F74FFF0746FF2C3DD0002F3BD014212646687C4E432C2180094C4301281AD11C4893 -:40120000214600680A314268525C0099921C4031CA714168201D0918284606220C30F3F768F91348062200688068811928461830F3F75FF90098F5F7EBFF002815D0042031 -:401240000C49897A01420DD0094800684168095D490707D58068B61D8119284606221230F3F747F9F807C00FFEBD0120E8E70000D40100087C21000810B510490A781049B7 -:40128000824201D8002003E0D0230A6A58431018002812D00A6B138802468032146B23800B6B146B5B88A3810B6B126B19881289914202D05A8800F009FB10BDCC1E0008C9 -:4012C0005C210008024901484860704750480010F8010008F7B50D463449334F897A84B03E4689065DD52C468034216B0A8B2946C0310091824204D3886820308078002820 -:401300004FD0002A02D12A48006B828828460699F5F7A6FD0646B84208D12889002102F098FD069805F0D8FF00263AE00027FF2069460197087200988068203081780129F2 -:4013400003D1A178002900D0C170A078401CA070A878FCF711F90407240FA878FCF7D4F80007000F04430F2C00D00127002416E00120009002AB03AA01A92846F5F7B8FC2B -:4013800000280AD10199002907D06846037AFF2B03D0027B2846F6F7BEFA641CE4B2BC42E6D3304607B0F0BDFFFF0000AC1E00085C21000870B50446C034217B0546002969 -:4013C0000CD0284600F0CAFA072807D0207B152802D1284600F018F80020207370BD704700487047FFFF000070470120704770470020704700207047024901484860704755 -:4014000030480010F801000870B50646FDF7FEFE04463089354620808035286B4089E080286BC08A2081286B00896080286B808AA0803046F7F705F9204604F027FF70BDED -:40144000FEB5044600790D46C01E05280DD848482E78807A20278006002807DB31462046FCF753F9E07E3843E076FEBD40212046FCF7A8F9A8786946000288806978084346 -:401480006946888029790A026946CA80E9780A436946CA80A9790A0269460A8069790A4369460A80297A0A0269464A80E97925460A4369464A808035296BC88069460888CD -:4014C000296B88806946C888296B488269464888296B0882204600F099FA2046F5F798FE00281ED1FDF7A8FE5E210A5B6179F6F7D1FD22460146A032507D0128286B408988 -:4015000026D080003C3083B2107D0128286B008B21D080003C3082B2103189B22046FDF73FF86420015BA078FBF728FC142E15D00F49A07D897AEF2239400843E17E384346 -:4015400011403943E176A0752046FFF75DFFFEBDC0007030D7E7C0007030DCE71521CC200155A07D3843A0752046FFF723FFFEBDAC1E0008014A526812691047F801000876 -:40158000014A526812691047F8010008F3B585B0FF206A460024107301941472184A2046927A920628D5059EC036B26820329578002917D1002D14D0009003AB02AA01A9B4 -:4015C0000598F5F795FB07466846037BFF2B06D00199002903D0027A0598F6F79CF9002F00D00124B0682030C178002904D0002D02D00124491EC170204607B0F0BD0000E0 -:40160000AC1E000870B504464878142801D015283BD1E07EEF21084020210843E076A07DDF210840A07540212046FCF7CBF82046F5F7EEFD002820D1FDF7FEFD5E210A5B9B -:401640006179F6F727FD22460546A032517D204680300129016B498918D089003C318BB2006B117D008B012913D080003C3082B21035A9B22046FCF793FF6420015BA0785F -:40168000FBF77CFB2046FFF7BFFE70BDC9007031E5E7C0007030EAE710B5044604F036FE00280CD106490A6B928822800A6BD28862800A6B1289A280096B4989E18010BD01 -:4016C0005C21000810B5044604F026FE002806D103490A6B12882280096B4988618010BD5C21000870B5054604F01CFE002817D12888F7F731FD040013D0F8F7A6FB0028D1 -:401700000FD0207909280ED02046F8F7AFFB01280BD0F5F763F9AA886988204600F0D6F870BD022070BD0C2070BD2A2070BD000010B5044604F0FCFD002806D10349228853 -:401740000B6B1A80096B62884A8010BD5C210008F3B5064631480025807A83B080065AD53746C0373868344680340090206B0290B8680190F1F7D2F8D02200213046F2F7A7 -:40178000C1FE029820630198B86000983860F1F7AFF8049801280FD130462421C830F3F7A1FD05042D0C36D130461A21B030F3F799FD05042D0C2ED11A220021206BF2F791 -:4017C000A1FE3046049900F05DF81549226B086B80881080086B226B00895080226B1B209080226BD080226B1081226B50810A6B236BD2889A81096B226B4989D181FF21B5 -:40180000226B49311182226B5182226B9182226BD182216B0883284605B0F0BDAC1E00085C21000810B504460020002906D00C211248F3F757FD0004000C1DD10F491B226A -:4018400030390B6B1A80FF220B6B49325A800B6B22889A8022880B6BD2007032DA800B6B62881A816288096BD20070324A81044920238A7A1A438A7210BD00008C210008D4 -:40188000AC1E000870B50546C03500290FD1A86820308678002408E0A868E1004058002801D005F019FD641CE4B2B442F4D324220021A868F2F726FEA868FF2120300170A9 -:4018C000A86800212030417070BD000070B5064604468036306B03898B4206D1838A934203D11D4B1B78002B07D0E37E9D0606D5A57DAD0603D41A2070BD002070BDDB067A -:4019000028D483891546AB4200D91D460180306B82812046F5F77CFC00280ED1FDF78CFC5E210A5B6179F6F7B5FB316B1030CB8981B22A462046FCF733FE6420015BA078FF -:40194000FBF71CFAE07E10210843E0761420C0342073D2E7232070BDF801000838B50546002000900C46A978684605F041FC002807D0142C03D1E87EEF210840E8760720B9 -:4019800038BD0098092204702C468034216B89784170216B4988090A8170216B897BC170216BC989090A0171216B09784171216B0988090A8171216B097BC171216B898951 -:4019C000090A01722946F8F799FE38BD70B504460088F7F7C1FB014680310B46096B2289CD89AA4203D1E5884E88B54206D0CA811A6BE1885180044A01211170A28861883A -:401A0000FFF764FF70BD0000F801000830B50024002835D0014680310A6BD3881588AB4200D32B4615899D4201D0138101240A6B538A9589AB4200D32B46958A9D4201D0DC -:401A4000938201240A6B958853889D4200D22B4655899D4201D053810124096B0A8ACB899A4200D31A46CB8A934201D0CA820124B421095C012200F007F802490020087010 -:401A8000204630BDF80100088030006B0129838A09D099080F39038989B28B4200D21946002A03D005E0D9080E39F4E7028B8A4200D901837047000070B504461B3CE12CD4 -:401AC0001CD2104C246BA588854217D30E4DA94214D8FF204930814210D3E6888E420DD3FB2A0BD81B2A09D32189914206D3AB4204D8834202D36089984201D2122070BDCA -:401B0000002070BD5C21000848080000F0B5314A0446314B002110465D5C491CC9B2A542FAD1A3009E462D4B491EDB7DCDB29C462A4C00216B003434E45A284B4E003433EC -:401B40009E5B254B5B5C9F00244BDF59BF897F00F619B6B2B44202D90020614625E0B24200D932460E46491CC9B2AE42E5D11CE01A4B4D0034335B5B1E1B052E09D2164D90 -:401B8000164E6D5CAF00F559AD896D005B199BB206E0124F75467F59FF89FF1CBE4217D39A4200D91A46491CC9B28C45E0D8094988420CD1101B04280AD9084A71465158CD -:401BC000C01E897C80B2002901D1401E80B2F0BD0020F0BDFFFF000000020008B4220008F7B50546002082B0164604460090F9F73BF90346002015E081006A581278002AED -:401C00000ED0062A0CD0464A670010556958098ACA1A012109045118424A641CD153E4B2401CC0B2697D8142E6D8012021E0014611E03C4B94467246DA53019B6246DA8352 -:401C4000374A575C5318BC46203BDF7F57546746491EDF77C9B2002909D0324B4F00DA5BFB18203B0193DB8B9E467245E1D3401CC0B2A042DBD300200399641EA446294CC5 -:401C8000086015E026494200095CA35A8F00EF591219FF895288DB19DB1C93420AD9039A136801228A4013430399401CC0B20B606045E7DB0399096800290BD0184A125C35 -:401CC0000120904001430398016001200090009805B0F0BD124801788A00A858807C3070B170002801D00128F1D1AA5821889289638852008A1892B2934204D9511A05E01F -:401D0000491EB180E3E7591A042905D9C91E89B2B1800028F4D0DAE70020B080D7E7000000020008E822000870B50A46034641780024007800F010FA264DFF2847D09E78C5 -:401D400025493300F8F7D0FD09060A0F13171B1F242943008000085800781CE0800008584068106034E08000085800890EE080000858807A0FE080000858808906E080001B -:401D80000858C08902E080000858008A10801FE080000858807C10701AE080000B581B7813700B585B6853600B581B8913810B589B7A93720B589B8993810B58DB89D381A9 -:401DC0000B581B8A13820858807C907400E02C46204670BD01001600B4220008F8B50446002020606060254EA060F07D002809D001280CD0224669463046FFF7F1FE012834 -:401E00001AD031E005202070FF20A070F8BD307E2070317DA170002801D00128F6D1317D8900715889894900C91E89B2A1800028ECD1491EA180F8BD0127104867701C30C5 -:401E4000009905F0B1FB054680003058807C2070B17D2846A94207D9FFF758FEA080A5700098AF40B843A06020783076A0783075A178A088890071580881F8BDB422000835 -:401E8000F8B5154F05460026387D344600901EE0E80716D0009880003858018AA0003858008AF8F79BFF0121C903884201D3002807D1094821461C3005F0EAFB0120A0402D -:401EC0000643641C787D6D08E4B2A04201D3002DDED13046F8BD0000B4220008F8B505460020287068602872F8F7BEFF0746F8F7C1FFFF213931884201D2022600E003266C -:401F0000002420E0A00010580178002919D0062917D0008A0121C01B0904401880B24910884201D8B0420CD801202870917DA14203D96968A040014369602146054805F0F7 -:401F4000A7FB641CE4B2034A1C3A507DA042D9D8F8BD0000D022000870B51C4DFF222A7505222A7600266975EE75A975334606E014225A4312189C005B1C2A51DBB28B4219 -:401F8000F6D30C4603E0A200641CAE50E4B2052CF9D314224A4310180A4601460B481C3005F09BFA00280FD100240AE0A000285821460670012000F00BF8002804D1641C21 -:401FC000E4B2A97DA142F1D870BD0000B4220008F3B583B0002668461A4C0671607D0D4600282BD069464D70039808702946039800F0B2F80746FF281ED0024601A968466A -:4020000000F060F9B8002258711E51602258090C118122589672225891812258D18121582A460E8220580521817420461C30039905F07EFA05B0F0BD0348FBE70248401CEE -:40204000F8E70000B422000801001600F8B50F4606460024F8F708FF0546F8F70BFFFF213931884201D2BF1C00E0FF1C0B48B2008258F9B2107800280ED006280CD0108A27 -:402080000122401B1204801882B20120C003824201D88A4200D801242046F8BDB4220008F8B52B4D0024E87D022801D20020F8BDF8F7DAFE264F264B002134370126360463 -:4020C0005D7D11E08B00D2581378002B0AD0062B08D0204B1955128A6300121A9219641CFA52E4B2491CC9B2194A8D42EAD8012117E008460AE07B53164BF2831A18203A61 -:402100001D5CD67F1E54401ED577C0B2002806D04500EE19203E7A5BF38B9A42EBD3491CC9B2A142E5D30B49388809787B888A0007498A58D2898218D21C9A4206D80A7DBB -:4021400092008958C989C91C8842AFD80120F8BDB422000800020008022804D20348807D401E884200DAFF2108467047B422000810B50146014805F0FBF910BDD022000854 -:402180000A4610B50146024805F066FA10BD0000D02200080A4610B50146024805F04CFA10BD0000D0220008F3B500980C46417800250078FFF7D0FF06463F48FF2E78D0C0 -:4021C00000993E4F89783E4A0B00F8F78DFB09060F161D242D34393E72002178062968D232462146009800F06DF863E0216891425FD8B000385841605CE02188914258D882 -:40220000B0003858018155E02178022951D2B000385881724EE021881922D201914248D8B0003858818145E02188914241D8B0003858C1813EE0B10079582088088239E04C -:402240002178052935D2B0002FE02178062930D2616891422DD8218991422AD8A17A022927D2A3891921C9018B4222D8E18991421FD8A17C05291CD232462146009800F0DD -:4022800021F8B0003A58616851603A58218911813A58A17A91723A58A18991813A58E189D1813A58218A1182A17C3858817401E0FFE705462846FCBD01001600B42200080F -:4022C000FF18000010B51A4B92009A58097814781170002C0BD0002917D1D87D401EC0B2D875012811D1194600204B7D1DE0012901D0022909D1D97D491CC9B2D975012904 -:4023000003D1417819750078187610BD82008A581278002A07D0062A05D082008A58927C0A76087510BD401CC0B28342EED810BDB4220008A03001777047000002490148E8 -:402340000860704798480010080200087047704770477047704770470249014808607047704800100802000870B5224DA030447E6E7D002334404476067E2D7D2E400676EB -:40238000857E2C400C70047EC57E2C4014700D780224032D00D30C701578032D00D31470447E0025012C02D0022C04D00CE0047E012C03D008E0047E022C05D10C78167869 -:4023C000B44201D00D701570047D0E78344200D00D70447D1678344200D015700978002901D0012381751178002901D00123C175184670BD7C2100081CB50400684681701A -:4024000008D020896A4610802046A030417D1171007DD0702146C031487B820701D57D2202E0C20702D07E221040487303496846096888472046F6F704F91CBD54020008A6 -:4024400010B541780078491EC9B2FAF73DF9024904200876002010BD5C21000810B5C1780278491ECBB281784078FAF743F9024903200876002010BD5C210008F0B587B08A -:402480000026694600960E740E75054605AA04A9FFF76AFF2C46A0340746012814D1A07D022602282AD000200290E07D022827D0002001902846FCF79CF80090A878009B7B -:4024C000019A0299FAF75EF91F48807A800604D5A17D00222846FFF7D7FA03966846007C009E00906846007D019000200290A97802A804F07DFE002818D103E00120D3E7C1 -:402500000120D6E702981823019A0099037041708270C670310A017105222946F8F7EEF880212846F5F7C8FB03982077002F08D1607F002805D10320607700212846FFF7FC -:402540005BFF07B0F0BD0000AC1E0008014A12689269104708020008F8B50F460546F4F757FE214EF17AC907C90F12D02C467978A0342176B97801276176677700280DD0D0 -:402580002846FFF77BFFC035687B822108436873F8BD39462846FBF73AFDF8BDB07A800604D5002201212846FFF76EFA00200090A978684604F01CFE0028E4D10098172248 -:4025C00002700A4A2946537D4370127D82700322F8F794F8728A80212846F5F74DFB042020776777CFE70000AC1E00087C21000870B506460E480C46C07AC007C00F30469E -:402600000DD0F4F705FE00280CD035466078A0352876A07868763046FFF730FF70BDFBF7F6FC70BD172224213046FBF722FF70BDAC1E0008014A1268D269104708020008C7 -:40264000014A1268126A10470802000870B517490978814201D8002504E01549D022096A50430D18002D1FD02C46A034207F02281AD1E07D60750E48A17D21752030027D69 -:40268000E276407DA07609482038807A800603D501222846FFF7F8F9002020770320607700212846FFF7A8FE70BD0000CC1E00085C210008FEB50C460746F4F7A9FD0128EA -:4026C0001DD080213846F5F7F7FA2E48A578017D407D667805400E402079E1780002014330463C462843A0340191002804D0B878F8F75AFD012808D0002E0FD00FE0182208 -:4027000024213846FBF7B5FEFEBD28215A20C155002020773846F6F7AFFBFEBD667D002D00D1257D207D28420ED0607D30420BD000200090607F00281BD1032060770021C6 -:402740003846FFF759FE14E0022D17D00021022E16D0002202200090B878019BFAF712F80948807A800604D5002229463846FFF78BF9E675A57500982077FEBD0121E6E731 -:402780000122E7E77C210008AC1E000870B50C46F6F7E2FC0546002060702070002D0BD02846F7F752FB002806D0A035687D6070287D2070002070BD022070BD10B501785C -:4027C0004478CA078378084903D14A7D224009D08A750078800703D4087D184002D0C875002010BD112010BD7C210008F8B50746FF2168460170FE783D793888F6F7ACFC1F -:4028000004000FD0F7F721FB00280BD0B9782148CA0709D0B422175D89070AD4067D2E4005D008E01E20F8BD477D3740F4D11120F8BDB520065D2546A035687D304209D07D -:40284000287D384206D00320687700212046FFF7D3FD14E002236A4618212046F7F75BFB01280ED002236A46FF212046F7F70CFB012806D0AF76EE76204600F07FF800209C -:40288000F8BD68460078002801D02320F8BD2A20F8BD00007C21000870B50E4605468021FAF790FF2C460020A03420770C48017DE176407DA0760B48807A800604D5217D80 -:4028C00001222846FFF7E0F82846F4F7A1FC002805D10320607731462846FFF78DFD70BD7C210008AC1E000870B505468021FAF769FF2C460021A03421770C49087DE076E9 -:40290000487DA0760A48807A800604D5217D01222846FFF7B9F8607F002803D100212846FFF76AFD0320607770BD00007C210008AC1E000810B50F490978814201D800207C -:4029400004E00D49D022096A5043081800280FD00949A03020318A7D037D9A4203D1CB7D447DA34204D08276C97DC1760121017710BD0000CC1E00085C210008F8B5054647 -:402980002C460020A0346077207F012801D1022060772846F4F73CFC134F00281AD0032600200090A978684604F022FC002810D1009816220270A27E4270E27E82702946AA -:4029C0000322F7F79BFE7A8A80212846F5F754F92677F8BDB87A04268006E1D5A17E00222846FFF751F8DBE7AC1E0008F7B54804040C82B0384801900178029816468142F6 -:402A000005D919200002844201D8082E01D9334C52E0029F0620474331483D182879012801D0022802D1029800F0C8FB2C48C4536E71C45B408B84421ED22146F0F768F861 -:402A4000002919D10094019800240078019011E006202146414322480E183079012801D0022804D170880099F0F752F87180641C0198E4B2A042EBD8029800F033F8174999 -:402A8000044688421DD0164E6C80F15B708B814206D2F0F73DF8002902D1029800F000FC718BF05BF0F734F8002908D0022028710B48017F491C0177204605B0F0BD012096 -:402AC000F5E72879002803D06888801C80B200E00A2068800320EAE7CC1E0008FFFF0000F2220008F0B50646AFB00020039001200690E0480090E048089030460622DF49B6 -:402B00005043002501904018029050E028460621DA4A4843811804910979012901D0022943D1B54241D0039F14214F430BACE5550199105A515A00F0A3F93F1904467860ED -:402B400001282AD0049802994079497905914118A14204D90020B860F860069015E00499201A49880919081A04912146EFF7D0FFB96004990598081A2146EFF7C9FFF96036 -:402B80000098844201D2A0B20090F868A04201D9012000E00020387403E00020B860F86006900398401CC0B203906D1CEDB208980078A842AAD8069800280ED00398002801 -:402BC0000ED000200490AD490198085A01900020044605900546039045E00020C04343E1A64806760199415A418300203CE1284606214843A14907904018069000790128A7 -:402C000001D002282DD1B5422BD01420214641430BA80F18B8680099EFF77AFFB960F8680099EFF775FFF9600698069940884979A70042181FA9CA510099EFF769FF27A872 -:402C4000C1518E490798095A019800F019F901901FA8C0590099EFF75BFF1FA8641CC151E4B26D1CEDB208980078A842BFD8601E054681B20A901FA800F0FAFAA9B227A869 -:402C800000F0F6FA002729E00898002500780790B80006901DE0062029464143774808180179012901D0022911D1B5420FD04188407908180099EFF72BFF0A4606981FA994 -:402CC0000858824203D106982BA90D5004E06D1CEDB20798A842DED87F1CFFB2A742D3D3002559E0AE002BA806968059062148436249401840880099EFF70AFF1FA88059EE -:402D00000F4686B209902146681CEFF701FF880008902BA907900858062148435749401840880099EFF7F4FE07981FAA105A012C82B223D9B94201D3B1420ED9BA4201D326 -:402D4000B2420AD9914214D3B24201D2B94201D8012000E00020002810D08F420ED196420CD10A98854209D0069923AA0998505010E0B942EED8B242ECD3E9E7089827A906 -:402D800009580198401E08180199EFF7C1FE069823AA11506D1CEDB2A542A3D300205BE000991FAA8900555823AA535800202E461F469D424DD0002122E0142251430BAA09 -:402DC00089188A680020B24205D3BA4203D8AA4200D915460120C968B14206D3B94204D8994200D20B46012007E0002805D18A4214D99642F7D88F42F5D36146491CC9B2E4 -:402E00008C46A142D9D3002823D0AB4210D30399581B884207D8002905D01AE0964218D98F42E0D315E003905819400804900EE0019803991818401B88420AD903900198ED -:402E40005919081840080199EFF762FE0491012005900098401CC0B20090A042A0D30598002800D1B9E6049802994880029840882FB0F0BDFFFF0000CC1E0008F2220008D4 -:402E800010B50C46002807D0002C05D0EFF740FE20460C00FAD110BD002010BD014606225143064A04488A181179012901D0022900D1508870470000FFFF0000F222000875 -:402EC000FEB5284B1B780293834209D91923DB01994205D89A4203D8062901D3062A01D22148FEBD914201D10846FEBD49040E0C51041E4A0F0C117F002905D0012906D1B0 -:402F00001146097E814202D1F0198008FEBD3D4624E001200024019016E0204606214843124942181279012A0CD1085A29460090EFF7EEFD002905D028460099EFF7E8FD1C -:402F4000002909D1641CE4B20298A042E5D80198002801D06808FEBD6D1EADB2B542D8D2D2E70000CC1E0008FFFF0000F2220008FEB5062107466A4E4F43BC1921790129E8 -:402F800006D0022904D0F7F76FFF6188401860E0337E0121062283426ED1624B00241D780BE0062363439B191B79012B01D0022B01D1844203D1641CE4B2A542F1D8A542B5 -:402FC00003D1F7F751FF0A3043E06846447101718271694601A8FEF7A7FE06204443A019418868460088411A68460180F7F73CFF0546684601882846F7F7FAFE04466846C2 -:40300000018803222846F8F7EDF8002823D06846018801222846F8F7E5F8002812D0778B20463946EFF774FD7819401A01E0708B001984B2032221462846F8F7D3F80028B7 -:40304000F5D16BE0768B20463146EFF761FD4819801984B262E0718B2046EFF759FD481901E0708B001984B2032221462846F8F7B9F80028F5D151E0684643710171827101 -:40308000694601A8FEF750FE684661880088091868460180F7F7E8FE0546684601882846F7F7A6FE02902079022817D0768B6846018803222846F8F795F800281FD0684668 -:4030C000018801222846F8F78DF800280298314610D0EFF71DFDA819401A02E0F65BE6E7A01984B2032221462846F8F77BF80028F6D113E0EFF70CFDA8190818A9E731460A -:403100000298EFF705FD481900E0A01984B2032221462846F8F766F80028F6D12046FEBDF2220008CC1E000810B50B460621104C484302191179012906D0022904D0205A36 -:403140004008F3F777FE10BD0A498B4206D15188022903D3C8031904401807E0215A50880818C01A801EEFF7D3FCC803000C10BDF2220008FFFF0000F0B500200E4A84469E -:40318000014606460A4B0B4CFF20157809E006270A467A43A352121953801671491C5071C9B28D42F3D82076638326776046F0BDFFFF0000F2220008CC1E0008F8B50146E0 -:4031C0000020009026480078844688421AD9084606225043234F8646C0190279002A11D000220271204B7246BB52FF2643804671387F1C46401E3877387E354688422CD18A -:40320000002019E01948009027E0062201465143CA191279012A02D0022A06D00AE0795AA14207D20C46064604E0795A994201D20B460546401CC0B28445E6D8FF2E01D0A2 -:40324000304602E0FF2D03D0284600F029F804E0FF2038760020C04378830098F8BD0000CC1E0008F2220008FFFF000001001600F0B58C4600230FE00022C91A491E08E05C -:403280009600371884597D68AC4201DD85517C60521C9142F4DC5B1C61466345ECDBF0BDFEB5064615480621374606764F43C15B41830146002479181148009100780190C1 -:4032C00016E006200D49604345182879012801D002280AD1B44208D06888C95B421800984088101AEFF7FEFC6980641C0198E4B2A042E6D8009800214180FEBDF22200088D -:40330000CC1E00080348C078002801D000207047012070478025000810B5012200F046F810BD000010B5054802780121002A017002D10120F2F734FB002010BD0C02000888 -:4033400070B5144D297803200129287002D10120F2F726FBEDF7CFF8EFF7E0FA00246C60FF22813221460C48F1F7CCF8F02200210A48F1F7C7F80948F030C47004704470B4 -:40338000C47304734473EDF7B2F8EFF7B1FA002070BD00000C020008102300089024000810B5002200F002F810BD0000F8B515460C460646EDF79FF8EFF7B0FA264A1078E8 -:4033C000012808D01078022805D0EDF790F8EFF78FFA1120F8BD0C20464320483018C1788378994205D3EDF782F8EFF781FA1220F8BD46780C277E43416867687118266851 -:40340000A4684F600E608C60C178431C491CC1704178491CC9B219708078814201D1002018705068401C50601078012805D0EDF75EF8EFF75DFA0020F8BD02201070EDF7D6 -:4034400056F8EFF755FA002D03D00020F2F7A8FAF1E70120FAE700000C0200088025000810B51248002101704160FF2281321048F1F748F8F02200210E48F1F743F80D48DA -:4034800018220021F030F1F73DF80A482021F03081701421817306494160064901610649816006494161F2F761FA10BD0C020008102300089024000843EB0010456C0110C7 -:4034C000F8B50025164C01262F462078002815D0012813D0022802D003281CD11AE000F021F8EDF708F8EFF719FA6068002800D12670ECF7FCFFEFF7FBF90CE0ECF7FBFF7F -:40350000EFF70CFA2078002802D020780128F0D10125EEE72770002DD7D00020F8BD00000C020008FEB5214D214E0027FF24ECF7E2FFEFF7F3F900200C2141438919C97816 -:40354000002901D0044602E0401C0228F4D3FF2C2AD00C204443A41921780C2260685143081801460EC9029301920091076047608760E078401EE0702078401CC0B2207038 -:40358000A178884200D127706868002802D06868401E6860ECF7ABFFEFF7AAF9A1680029C4D068468847C1E7FEBD00000C0200088025000810B5830A082B04D03F2B05D0E9 -:4035C00004F078F810BD00F025F910BD01F0A8FB10BD10B50C460146207800F02BFE0028204603D003F0DFFA002010BD00F082FD1F2010BD38B504460020009069460520FF -:4036000000F071FD00280AD101200099052C07D010220A708C704870FF20FFF7DAFF38BD1A220A708870F6E710B5820A082A04D03F2A05D004F0F0F810BD00F015FA10BD8F -:4036400001F072FB10BD0000F8B5044640782578000205430020694608702846FFF7E4FF01282BD16946A0780978884226D022498D420CD0891D8D4209D0C91C8D4206D0E0 -:40368000C91C8D4203D01C4925318D4204D11221284600F0A1F80CE00022022805D32079E178000201430A05120D12212846FFF781FF204603F0C8FD1220F8BDA80A0F4E59 -:4036C00008280ED03F282A46314610D0E01C04F0EDF8204603F0B8FD3146284600F010F8F8BD2A463146E01C00F0CEF9F1E7E01C01F070FBEDE700000D2000009825000889 -:40370000F8B50D4604460020694608702E48871D844212D0BC4210D0F81C84420DD0C01C84420AD028481830844206D0401C844203D025482530844201D101200870A00A3F -:4037400008280ED03F280A46294620460FD004F0FFF806466846007800280BD001281FD116E00A462946204600F0C2F9F1E701F051FCEEE70022002D05D0687829780002FF -:4037800001430A05120D31462046FFF713FF07E0BC4201D13A2E05D03146204600F01CF83046F8BD68782978000201430805000DF5F7D2FC05460021204600F00DF83A21F5 -:4037C0002846FAF774F8EBE70D2000000148007B70470000A0210008F8B5054600200E4600906946082000F07EFC002801D00720F8BD009C0F202070A670FFF7E7FFE0700C -:403800002571280A6071042060702146FF20FFF7E0FEF8BDF7B584B00546002002900420694608718649874B681A0C22EE1806278D423BD010DC8449681A8D4230D006DC79 -:40384000002E28D0012E28D0052E13D128E006282AD009280ED120E0172829D006DC012824D0022819D0162804D11FE019281FD01A281DD07549284609688847694609794C -:40388000401869460871724928460968884769460979401805E0781C03E06846027107E005206946087103E00B20FAE7684607716846007902A9001D00F015FC002802D0E6 -:4038C000072007B0F0BD029C29462046059A00F001F90420694608715949491C681A8D420AD005DC5B48281806D005280BD103E0072801D0152806D10699A171069968462B -:40390000090AE17107710598002821D14C49491F681A8D425AD009DC4F4F002E20D0012E2FD0052E44D00D2E06D148E003285CD0072866D01B286FD0484B01AA1B682146C5 -:4039400028469847464B01AA1B682146284698476846007960702146FF20FFF73AFEB0E769460979387D6118887069460979000A6118C87069460879801CC0B20871797D55 -:403980005BE06946087908222018801C0021F0F7B9FDB87AF52108406946097961188870F87A6946C0070979C00F6118C87023E0F3F708FC05E069460879401C1FE0F3F779 -:4039C00021FC6946097961188870F4E7684600792118891C0698F3F700FC002801D06071B6E769460879401D09E06946087908212018801C03F05DF9694608790830087170 -:403A0000A6E76946087914492018801C08221831F0F76FFDF0E7FFE7124A694612680698904760716946087809796118887069460879401CC0B20871497820188170BAE726 -:403A40001A200000FEDFFFFF0F2000004C0200083C020008EBDFFFFFAC1E0008480200083802000858020008064AC0B21378834206D3401E1269C0B2105C087001207047E4 -:403A8000002070471402000830B4074BD2B21C78944206D39B689200D218403AD26B30BC104730BC704700001402000807484E21017007494160FF3139318160FF313931A5 -:403AC000C160FF313931016170470000140200084449001070B504460E2016460D462070FFF774FEA070E570280A2071667170BDF8B50D4D16460F46C1B22A780120914206 -:403B000010D88C00E868314620184038C26B38469047002806D16868314620184038C26B38469047F8BD000014020008F8B5054600260D4F69460620009600F0D4FA002802 -:403B400001D00720F8BD009C324639462046FFF7C1FFA571280AE071062060702146FF20FFF737FDF8BD00001F20000070B50446054640220021F0F7C5FC40222349284695 -:403B8000F0F7B7FC2249F522887A20341040C0060028207802DA3022104301E0CF2210402070887AC2070720002A2A7F01D0024301E0D208D2002A778A7A93060122002B96 -:403BC0000ADA6378C0252B436370A37808251343A370E3782B43E3708B7A5B060AD5A378F8252B43A370E3780343E370E07904231843E071C87AC00706D0E078F021084362 -:403C0000E07020791043207170BD0000654E0010AC1E000810B50022F3F776FB10BD10B5F3F7D0FB10BD002070470120704710B5F3F74AFC10BD0020704710B5F3F746FC66 -:403C400010BD0000044A0178D180407800020143D180002070470000A021000810B5F3F7E3FC10BD10B5F3F7FBFC10BD10B5F3F703FD10BD10B5F3F70DFD10BD38B5044669 -:403C80000020009069460E2000F02DFA002801D0072038BD00993E200870032088702078C870A07808716088000A487120798871A088000AC871A0790872E088000A4872F9 -:403CC000207A88722089000AC8720A2048700320FFF77FFC38BDF8B50546002000906946232000F000FA002801D00720F8BD009C3E2020700A2100F09DFA014601200029B2 -:403D000046D001260A20A07007462878E070A978217169880622090A61716878A0712879E0712046294608300C31F0F7E2FB0C20002E0ED0204629460E3006221231F0F790 -:403D4000D8FB20462946143006221831F0F7D1FB1820AA7921188A70EA88801C120ACA702A7A21188A702A89801C120ACA70AA7A21188A706A89801C120ACA70221869796D -:403D80009170401C607021463846FFF722FCF8BD0026A0700127B8E7F8B5044600200E46009015466946082000F09DF9002801D00020F8BD0099082008708E70CC70200A0D -:403DC00008714D7104204870FF20FFF702FCF8BD38B50C460021054600916946072000F082F9002801D0002038BD0099302008708D70CC70200A087103204870FF20FFF730 -:403E0000E8FB38BD38B50546002000906946112000F069F9002801D0002038BD009C3E2020700520A0702878E07028880822000A2071601D6968F0F75CFBA9680D200A7812 -:403E400062734978A173607021460520FFF7C1FB38BD38B5054600200C4600906946092000F041F9002801D0002038BD00991320087001208870CD70280A08714C71200A1F -:403E8000887105204870FF20FFF7A3FB38BD38B50546002000906946102000F024F9002801D0072038BD009C3E2020700420A0702878E070A87820716888000A60712878D1 -:403EC00000280BD0A01D08220021F0F71BFB0C20607021460420FFF77CFB38BDA01D0822A968F0F706FBF2E738B504460020009069460C2000F0F7F8002801D0002038BD69 -:403F000000990C20087020788870A078C8706088000A08716078487120798871A088000AC871A0790872E088000A487208204870FF20FFF74EFB38BD38B504460020009092 -:403F40006946062000F0CFF8002801D0072038BD0099572008708C70200AC87002204870FF20FFF736FB38BDF8B5064600200C46009015466946082000F0B5F8002801D0E2 -:403F80000020F8BD0099052008708E70CC70200A08714D7104204870FF20FFF71AFBF8BDFEB507460020009010480E46019015466946082000F097F8002801D00720FEBD27 -:403FC000009C324620460199FFF784FDA771380AE0710620002E03D1290A25726172082060702146FF20FFF7F4FAFEBD7B0C0000F8B5054600200E4600900C4F69460620F6 -:4040000000F071F8002801D00720F8BD009C324639462046FFF75EFDA571280AE071062060702146FF20FFF7D4FAF8BD7C0C000010B5F5F7E3F910BD10B5F5F73BFA10BDE5 -:4040400010B5F5F759FA10BD10B5F5F7BBFB10BD10B5F5F7D2FB10BD10B5F5F761FC10BD10B5F3F7C7FA10BD10B501220A70F5F743FD10BDF8B505460020074600900D4E2D -:404080006946142000F02FF8002801D00720F8BD009C3A4631462046FFF71CFD1022A01DA918F0F726FA142060702146FF20FFF790FAF8BD1720000010B5F3F799F910BD6E -:4040C00010B50029014601D00B2000E00220FFF780FA002010BD10B5FAF70CFC10BD10B5FAF730FC10BD0A4610B5C1B2104603F02BF810BD10B503F0C3F810BDF8B50546FD -:40410000C078AE78154C00020643A07C27468000C03FC019403004222946F0F7EAF9A07C238A8100C81940302A1D102B15D07D50A17C00234900C91980310E80A17C0B55CF -:40414000A17C491CC9B2A174102900D3A374218A491C2182114602F017FDF8BD9C2600083EB5134C0025E07C21460555E07CC0398000085803F09AF8E07C401CC0B2E074AF -:40418000102800D3E574208A401E20820948807A00280CD00095019511206A4602951081558129460A460020029B03F088F93EBD9C260008A021000870B5184C0025207AD2 -:4041C000002825D1F1F764F915488574C574058225726572A572A5821DE0A07A00280DD0401EA0720D4A0006410DC03A8818515C4068022907D0042907D101E01920F0E77C -:4042000003F03EF801E0FFF7ABFFE07A401EE072E07A0128E1D80348057070BD702700089C2600082802000810B5FFF7C5FF002010BD00001C4B13285A7A31D00EDC0E2803 -:404240002ED006DC052820D0082827D00C2829D11DE00F2824D0102824D11FE03E280AD004DC1A2817D030281CD112E0572814D0FF2817D114E0500614D5491E0120884023 -:40428000D98880B201420BD10CE0012006E0802004E0202002E0022000E00420024201D00120704700207047A021000838B505460020009069460920FFF715FF002801D03D -:4042C000072038BD009CFF2020700320A0702878E07028880422000A2071601DA91CF0F708F9072060702146FF20FFF772F9002038BD03B583B0002069460090888001AAA9 -:4043000004A91220F1F7F6F969460320FFF7EBFE00280ED10099FF2008700620887068468088C870000A087103204870FF20FFF750F905B000BD03B583B00020694600905B -:40434000888001AA04A91120F1F7D4F969460320FFF7C9FE00280ED10099FF2008700720887068468088C870000A087103204870FF20FFF72EF905B000BD000038B50446E1 -:4043800000200C4900900878401E087069460520FFF7A9FE00280CD10099FF20087002208870200ECC70087103204870FF20FFF710F938BD2802000810B50B4C617E0029BB -:4043C0000BD00A49884209D1F2F7D8FB607E022801D1F0F76FFF0020607610BD02F0F4FB607E00F031FF10BD5C210008C0FD0000FEB5044600200290607F0F46401CC6B298 -:4044000002A9301DFFF76FFE002801D00720FEBD029D21463931E81D019100902246637F1E3229392046F2F727FA0C49884204D12846FFF75FFE1220FEBD002208492846C0 -:40444000FFF748FB607FA871361D6E70022038702946FF20FFF7BDF80020FEBD01001600A9FD0000FEB5044600200290607F0F46401DC6B202A9301DFFF735FE002801D06D -:404480000720FEBD029D2246A91D481D019100902146637F1E3210312046F2F715FA0C49884204D12846FFF725FE1220FEBD002208492846FFF70EFB607FA872361D6E701C -:4044C000022038702946FF20FFF783F80020FEBD01001600A8FD0000F8B5044600200E46009069462420FFF7FEFD002801D00720F8BD009D002225492846FFF7EBFA2146CB -:404500002046AA1D20311030F2F700FA002804D02846FFF7EFFD1220F8BD2178A97521882846090AE97521681C30090C29762168090E69762179A976A188090AE976616843 -:40454000090C29776168090E6977217AA9772189090AE977A168090C0171A168090E4171217B001D8170A189090AC170E168090C0171E168090E41712420687002203070B4 -:404580002946FF20FFF725F80020F8BDADFD00000120704738B500200D46009069461020FFF7A1FD002801D0072038BD009C00220B492046FFF78EFAA11D0020F6F760FC6E -:4045C00021460C310120F6F75BFC10206070022028702146FF20FEF7FCFF002038BD0000A1FD00007CB500200D46009069460620FFF779FD002801D007207CBD009C002243 -:404600000B492046FFF766FA01A8F1F7D7F868460079A07168464079E07106206070022028702146FF20FEF7D4FF00207CBD0000A2FD000010B5012008700024034803F064 -:40464000BFFA002800D00C24204610BDF342011010B5012008700024034803F097FA002800D00C24204610BD37430110F3B5044683B000200190207D002601461131CAB20B -:40468000332802D9122005B0F0BD01A9101DFFF72AFD002801D00720F5E7019D002232492846FFF717FA2068FAF7A2FE277DAF710520009009E080194019801C394602F016 -:4046C000F8FA0836083FF6B2FFB20098082FF2D880194019801C394602F0EBFA217D009822790818C1B268188270A288091D120AC2706268C9B2120C02716268120E427186 -:40470000227A681882702289091D120AC270A268C9B2120C0271A268120E4271227B68188270A289091D120AC270E268C9B2120C0271E268120E4271227C68188270228A7C -:40474000091D120AC2702269120C02712269120E427169700498022101702946FF20FEF738FF00208FE70000ACFD0000FEB50F460546FF2069460871002000902888F4F764 -:40478000EBFC060027D0F5F760FB002823D069460720FFF7A8FC002801D00720FEBD009C00220E492046FFF795F92878A07128880223000AE07101AAFF213046F5F7ABFBB5 -:4047C000207207206070022038702146FF20FEF700FF0020FEBD0220FEBD0000AAFD000010B500240C708179002904D0012905D01224204610BDF8F7C9FAFAE7F8F7FEFA4F -:40480000F7E70000F8B505460F460088F4F7A4FC04006FD0F5F719FB00286BD00020009069460620FFF75FFC002801D00720F8BD009EF6F7A1FA2046F2F7EAFC00283FD156 -:40484000FAF7FAFC5E210A5B6179F3F723FC2246A0320146537D2848012B837A05D09B060DD5B0231B595B890AE09B0603D5B0231B595B8900E01B23DB00703302E01B23D3 -:404880009B003C33127D807A9BB2012A05D080060DD5B0200059008B0AE0800603D5B0200059008B00E01B20C000703002E01B2080003C3082B2103189B22046F9F770FE08 -:4048C00068886034E080F6F773FA00220B493046FFF700F92978B17129880620090AF1717070022038703146FF20FEF772FE0020F8BDFFE70220FBE7AC1E0008B0FD0000AD -:4049000010B500240C70F0F787FF0349884200D11224204610BD000001001600F8B504460E460088F4F718FC05002AD0F5F78DFA002826D0A178A878FDF72CFC002801D08E -:404940001220F8BD0020009069460620FFF7CBFB002801D00720F8BD009D00220A492846FFF7B8F82078A87120882946000AE8710620687002203070FF20FEF72AFE0020CD -:40498000F8BD0220F8BD0000B2FD0000F8B504460F460088F4F7E0FB050043D0F5F755FA00283FD00020009069460620FFF79BFB002801D00720F8BD2879009E09280CD066 -:4049C0002389E288A1886088FDF776F8002806D03046FFF78FFB1220F8BD0C220FE0E87E810604D5A97D890601D41A2207E0C00604D42046FCF7EAFF024600E023220A4923 -:404A00003046FFF767F82178B17121880620090AF1717070022038703146FF20FEF7D9FD0020F8BD0220F8BDB1FD0000024600200870024912784A7370470000A021000855 -:404A4000F8B504460F460088F4F786FB060026D0F5F7FBF9002822D00020009069460620FFF741FB002801D00720F8BDA178B078009DF8F7C1FB00220A492846FFF72AF8F0 -:404A80002078A87120882946000AE8710620687002203870FF20FEF79CFD0020F8BD0220F8BD0000ABFD0000F3B5044683B000200090054621786A46517101202056032617 -:404AC0001071002809D0042807D0821D05D0921D03D0121D01D0143007D101290FD001A8F0F7C0FE2949884200D112256946301DFFF7F9FA002830D0072005B0F0BD608806 -:404B0000FF2811D0F4F728FB070000D10225F5F79CF9002806D0002DE8D1EDF7FFFE6078387317E00225E1E7EDF7F8FE0020184B184A08E0D027196A4743C91901D0677874 -:404B40000F73401CC0B211788142F3D8104861784030C170EDF7CCFEC8E7009E2A460E493046FEF7B7FF2078B071A078F07160880221000A307207207070049801703146A5 -:404B8000FF20FEF726FD2846B7E70000010016005C210008CC1E0008A5FD000010B5044602200870F7F7D8FE207800F04DFB10BD7CB505460020184C009020780E461228C2 -:404BC00007D22979154B01A82A68F0F727FF002801D00C207CBD20786946401C20700620FFF781FA002801D007207CBD009C00220B492046FEF76EFF2879A071684600795E -:404C0000E07106206070022030702146FF20FEF7E0FC00207CBD0000280200087D430110C1FD0000F8B505460020154C009020780E4600280FD06878F0F776FF002802D1C7 -:404C40002078401E207069460520FFF74CFA002803D00720F8BD0C20F8BD009C002209492046FEF737FF2878A07105206070022030702146FF20FEF7ACFC0020F8BD0000E5 -:404C800028020008C2FD000038B500200D46009069461020FFF727FA002801D0072038BD009C00221C492046FEF714FF1B48016B0978A171016B0988090AE171016B897846 -:404CC0002172016B4988090A6172016B0979A172016B8988090AE172016B89792173016BC988090A6173016B097AA173016B0989090AE173016B897A2174006B214640896D -:404D0000000A60741020607002202870FF20FEF760FC002038BD0000A7FD00005C21000810B502F0C7FC10BD10B5264B0022C41A98423CD01FDC244BC41A98423CD011DCAF -:404D4000224C031BA0422AD007DC214BC01822D0012822D0C92832D12EE0012B2CD0022B2DD129E02300F5F7BFFD092A271618272A2A181E2A002300F5F7B6FD18211B1ED7 -:404D80001E0D1D151E13212121212121212121212113170F132104220EE002220CE007220AE0012208E0032206E0052204E0152202E0302200E00A220A70012010BD002036 -:404DC00010BD0000ACFD0000A3FD0000A0FD00009A03FFFF10B53D4BD41A9A425AD01CDC3B4BD41A9A4240D00FDC3A4C131BA2422FD005DC384BD31825D0012B20D125E0E4 -:404E0000012B29D0022B1BD12CE0641F2300F5F76BFD062F3217383B3E17092C52D007DC2300F5F761FD080D40430D0D461C490D152C23D0162C30D0172C31D0182C3ED0CB -:404E400000F0B2FF10BD00F022FD10BD00F040FC10BD00F053FC10BD00F026FD10BD00F02AFB10BD00F0B0FC10BD00F0FEFA10BD00F04CFB10BD00F010FB10BD00F051FBFB -:404E800010BD00F039FA10BD00F016FA10BD00F0E5FA10BD00F031FB10BD00F045FB10BD00F053FB10BD00F08FFA10BD00F03CFA10BD00F0E5FA10BD00F0F4FA10BD00F06B -:404EC00019FB10BD00F046FB10BD0000ABFD0000A0FD000049FD00009A03FFFF3EB50020009001900290012008700D4602A90C20FFF7F9F8002801D007203EBD029C002262 -:404F000010492046FEF7E6FD01A96846F2F7D6FB0098A071010AE171010C2172000E60720198A072010AE172010C2173000E60730C206070022028702146FF20FEF749FB42 -:404F400000203EBDB3FD0000F7B582B006460027012000971070154669460620FFF7C3F8002802D0072005B0F0BD009CF00701D01220F8E73A4620460399FEF7ABFD084895 -:404F800030180068A071000AE07106206070022028702146FF20FEF71CFB0020E3E7000000103C4010B50A4600880249FFF7CCFF10BD000067FC0000FEB5064600270120FD -:404FC000009708700D4669460820FFF78CF8002801D00720FEBD009C3A460D492046FEF779FD01AA31460520F0F784FB0198A071010AE171010C2172000E607208206070B4 -:40500000022028702146FF20FEF7E3FA0020FEBD49FD000070B5674B0E460024C11A664D984270D020DC654BC11A984257D013DC634BC11A984238D007DC6249411825D088 -:40504000012928D0E3296ED12AE0012932D056293BD0572967D13DE00B00F5F745FC08A6454A4F555F656AA60C240B00F5F73CFC1A9D6B70752B2B7A267F93989D9D9D9DC7 -:405080009D9D9D9D9D9D9D5184898E9D1146304600F09AF816E011463046FFF783FF70BD11463046FFF788FF70BD1146304600F0BFF870BD3046F7F769FE04E011463046D1 -:4050C0006A682EE00446204670BD11463046FFF787FBF7E711463046FFF75CFAF2E711463046FFF77FFAEDE711463046FFF7B0FAE8E711463046FFF79DFAE3E711463046A1 -:40510000FFF7D2FCDEE719E011463046FFF7F8FBD8E711463046FFF741FDD3E71146AA6830469047CEE740E011463046FFF79AF9C8E711463046FFF75BF9C3E7114630469F -:40514000FFF714FBBEE711463046FFF779FCB9E711463046FFF78AFAB4E711463046FFF7BBF9AFE711463046FFF74CFBAAE711463046FFF7D3FBA5E711463046FFF718FD2E -:40518000A0E711463046FFF74DFD9BE711463046FFF74CFC96E711463046FFF79FFE91E71146304600F01EF88CE7314600F01EFE88E70000AAFD000028020008A2FD0000C9 -:4051C0004AFD00009A03FFFF0188CA0701D012207047034A40888918086000207047000000103C40F8B5064600200090012008700D4669460C20FEF776FF002801D007203E -:40520000F8BD009C002209492046FEF763FC3078F2F75CFAA07105206070022028702146FF20FEF7D6F90020F8BD0000B4FD00000EB5017800914068019002AA69460420F3 -:40524000F0F758FA00200EBD38B505460020009069460520FEF747FF002801D0072038BD009C002207492046FEF734FC064821464576A57105206070FF20FEF7AAF9002013 -:4052800038BD0000C0FD00005C21000803480249416081607047000091450110280200080348024941600349816070478D49011028020008894C011070B50D4604460146AC -:4052C00010222846EFF715F92146284610310D221030EFF70EF9214628461D3104223930EFF707F92120225C214628466A7722311E30EFF7FEF870BD70B50D4604460146E8 -:4053000010222846EFF7F5F82146284610310D221030EFF7EEF8627F214628466A771E311E30EFF7E6F870BD70B50C46054601461022A018EFF7DDF829462046103110228E -:405340002030EFF7D6F82022A818C1780902216083781943090221604078014308022060A95C0843242120606818C2781202626083781A4312026260407802431002606057 -:40538000695C0843282160606818C2781202A26083781A431202A260407802431002A060695C08432C21A0606818C2781202E26083781A431202E260407802431002E0601D -:4053C000695C0843E06070BD10B5C27812020A6083781A4312020A6043781A4312020A6003781A430A6002790A75037A1B024B60C47923431B024B60827913431A024A6044 -:4054000043791A434A60037B1B028B60C47A23431B028B60827A13431A028A60437A1A438A60037C1B02CB60C47B23431B02CB60827B13431A02CA60437B1A43CA60037D09 -:405440001B020B61C47C23431B020B61827C13431A020A61407C02430A6110BD427812020A80007802430A80704770B50C460546014606222046EFF73CF8A879A07170BDFA -:40548000427812020A8003781A430A80C27812024A80807802434A80704702780A70407848707047427812020A8003781A430A80807888707047427812020A8003781A43B0 -:4054C0000A80C27812024A8083781A434A80427912028A8003791A438A80C2791202CA8083791A43CA80427A12020A81007A02430A817047007808707047427812020A8095 -:4055000003781A430A8080788870704702780A7042784A70C27812024A80807802434A807047007808707047C27812020A6083781A4312020A6043781A4312020A600378DE -:405540001A430A6000790871704702780A7040784870704700780870704710B50B460178401C197001460622581CEEF7C2FF10BD034610B5084608221946EEF7BAFF10BDDF -:40558000427812020A8003781A430A80C27812024A8083781A434A80427912028A8003791A438A80C2791202CA8083791A43CA80427A12020A81037A1A430A81C27A1202EF -:4055C0004A81837A1A434A81427B12028A81007B02438A81704770B5054640780C46000208802978062208432080E87800026080A978084360802879207168796071A91D6D -:40560000A01DEEF776FF287B2076A87B0002A081697B0843A081287C0002E081E97B0843E081A87C00022082697C08432082287D00026082E97C08436082A87D0002A0826F -:40564000697D0843A082287E0002E082E97D0843E08270BD7047427812020A8003781A430A8080788870704770B50D460446014610222846EEF73DFF214610221031A81811 -:40568000EEF737FF70BD034610B5084640221946EEF72FFF10BD427812020A80007802430A80704710B50B4641780A021A800178801C0A431A8001461022981CEEF719FFB4 -:4056C00010BD427812020A80007802430A807047427812020A80007802430A807047427812020A80007802430A8070477047427812020A80007802430A80704700780870DE -:405700007047427812020A80007802430A807047427812020A8003781A430A80807888707047007808707047427812020A80007802430A80704710B50B460178401C19708A -:4057400001460622581CEEF7D4FE10BD10B502780B460A701F2A03D8411C581CEEF7C9FE10BD00780870704770B5054640780C46000208802978062208432080E878000289 -:405780006080A978084360802879207168796071A879A071E91DE01DEEF7ABFE687B6073A87BA07370BD0022835C0B70521C491CD2B2082AF8D37047034610B508460522F3 -:4057C0001946EEF796FE10BD034610B5084606221946EEF78EFE10BD034610B5084606221946EEF786FE10BD02780A7040784870704702780A71827812020A8043781A430A -:405800000A80027912024A80C3781A434A8042794A7180798871704710B502780B460A701F2A03D8411C581CEEF763FE10BD70B5054640780C4600020880297808220843D8 -:405840002080A91C201DEEF754FEE87A102200026080A97A08436080294620460C310C30EEF747FE70BD02780A7042784A70807888707047427812020A8003781A430A801D -:40588000C27812024A80807802434A807047427812020A8003781A430A80C27812024A80807802434A80704702780A70027912024A60C3781A4312024A6083781A43120293 -:4058C0004A60407802434A60704710B504460088F2F774FB00280AD0A07815280FD008DC05280CD013280AD0142806D107E0022010BD1A2803D03B2801D0122010BD002028 -:4059000010BD012070470078012801D912207047002070470020704710B50446012008702088F2F74BFB002822D06188A08881421CD8114A891F914218D2511D884215D86A -:4059400021890D4B0A460A3A1B1F9A420ED2E288FF23F4339A4209D8521C4243C9005000814203D9A0896189884203D2122010BD022010BD002010BD7B0C00000020704795 -:4059800010B501220A700179037E0A46194303292FD8002A02D1417903292AD8018842888A4226D8154B091F994222D2042A20D38289C1898A421CD8114B921F9A4218D249 -:4059C0005A1D914215D8428A0D4C13460A3B241FA3420ED2038AFF24F434A34209D85B1C4B43D20059008A4203D9C18A808A814201D2122010BD002010BD0000FD3F00001C -:405A00007B0C0000002070470020704710B50088F2F7D4FA002801D0002010BD022010BD10B50088F2F7CAFA002801D0002010BD022010BD10B50088F2F7C0FA002801D0A0 -:405A4000002010BD022010BD10B501220A700088F2F7B4FA002801D0002010BD022010BD002070470078272801D912207047002070470078012801D9122070470020704781 -:405A800010B501790388428804291BD801290AD0934217D80124A403A24213D8202B11D3827B032A0ED8012901D0042902D18179032907D84179032904D8407B410701D0FA -:405AC000C00800D0122010BD00781F2801D9122070470020704741780A09817812011143C2780A430179114342790A438179C0791143084300D01220704701794A090AD1FA -:405B0000027843781A438378C07803431A430A4301D0002070471220704700207047017840780143012901D91220704700207047017901290FD8018842888A420BD8084B2F -:405B4000091F994207D2042A05D34179032902D88079032801D912207047002070470000FD3F000010B501220A700088F2F726FA002801D0002010BD022010BD00207047EA -:405B80000178272902D88078072801D9122070470020704710B50088F2F710FA002801D0002010BD022010BD0120704710B50088F2F704FA002801D0002010BD022010BD8B -:405BC00010B504460088F2F7F9F9002804D0A078012803D9122010BD022010BD002010BD0020704710B504460088F2F7E7F9002804D06088002803D0002010BD022010BD4D -:405C0000122010BDF8B50E460021054600910120307069460820FEF766FA002801D00720F8BD2868009C056800220A492046FDF751FFA571280AE071280C2072280E607286 -:405C400008206070022030702146FF20FDF7C1FC0020F8BD26FD000010B50020F1F7C2FC002010BDC27812020A6083781A4312020A6043781A4312020A6003781A430A605D -:405C800002790A71407948717047C27812020A6083781A4312020A6043781A4312020A6003781A430A60007908717047C27812020A6083781A4312020A6043781A431202FC -:405CC0000A60007802430A60704710B5C27812020A6083781A4312020A6043781A4312020A6003781A430A6002790A71182A01D918220A71002205E083188C185B79521CE2 -:405D00002372D2B20B799342F6D810BDC27812020A6083781A4312020A6043781A4312020A6003781A430A60C27912024A6083791A4312024A6043791A4312024A60007990 -:405D400002434A60704700003EB500200290012008700D4602A90820FEF7C5F9002801D007203EBD6846029CEFF7EAFA00220D492046FDF7AFFE68460078A0716846407819 -:405D8000E07168468088207268468078607208206070022028702146FF20FDF71AFC00203EBD00002FFD00000F4B00B5D2181300F4F79AFD0B070A0D090916101309070A2D -:405DC0000900FFF762FF00BDFFF77FFF00BDFFF749FF00BDFFF76AFF00BDFFF797FF00BD0078087000BD0000E002FFFF10B50C4601460F4B0020C9180B00F4F775FD0D0C2E -:405E00000D0C080C1717171717170C12170011462046FFF7F7FE10BD11462046FFF71CFF10BD11462046FFF78FFF10BD012010BDDD02FFFF70B5054600780C468872691CD4 -:405E40000622201DEEF755FB2046E91D10221B30EEF74FFB29462046173110220B30EEF748FB70BD704710B50B460178401C197001460622581CEEF73CFB10BD10B50B4684 -:405E80000178401C197001460622581CEEF731FB10BD704710B50B460178401C197001460622581CEEF725FB10BD007808707047427812020A80007802430A80704770B5C1 -:405EC000054600780C460870691C0622601CEEF710FBE879E07170BD7047002070470000F8B50D46114914781646411808D0104807460E37007D012908D002290BD10CE0C0 -:405F0000FAF7FEFA29198870641C03E02A19921C012305E0E4B23470F8BD2A19921C00233946FAF7C7FA6871A41DF3E7D6DFFFFFA02100080649401805D0012805D0022819 -:405F400003D00020704701207047062070470000D6DFFFFF10B50022F9F744FCC0B210BD10B5FAF7D3F810BD10B5FAF795FA10BD10B5FAF791FA10BD0020704710B5FAF7BE -:405F8000C5FA10BD10B5FAF7C1FC10BD10B5FAF7D5FC10BD10B5FAF7EFFC10BD10B500F025F810BD014A12681269104734020008014A1268D269104734020008014A126885 -:405FC000926A104734020008014A1268D26C104734020008014A1268926D104734020008014AD2685268104734020008807A012801D912207047002070470078012801D913 -:40600000122070470020704700207047002801D000207047122070470078012801D91220704700207047000000880449401E884201D312207047002070470000B8A10000EB -:406040000178012902D8C079012801D91220704700207047014A12681268104734020008014A12689269104734020008014A1268D26B104734020008014A1268126B10474E -:4060800034020008014A1268526A104734020008014A1268D268104734020008014A1268926C104734020008014A1268526D104734020008014AD2681268104734020008F3 -:4060C00004480349016004494160044981607047084F001034020008D95E0110DB5E011006480549016006494160064981600249C031C16070470000A84E00103402000828 -:40610000E15E0110355F0110014A12689268104734020008014A1268126A104734020008014A1268526C104734020008014A1268926B104734020008014A1268D26A104779 -:4061400034020008014A12685269104734020008014A1268126D104734020008014A1268D26D104734020008014AD268926810473402000870477047427812020A80037805 -:406180001A430A80C27812024A8083781A434A80427912028A80007902438A807047427812020A8003781A430A80C27812024A80807802434A8070470749401805D0012830 -:4061C00005D00D2805D0002070470220704704207047082070470000DEDFFFFF0020704770470000FEB50D4627491646147840180022002802D00C2844D115E06B461A71C1 -:4062000001A96846FBF75EFA6B461988281981701988A41C090AC170E0B25A8829188A705A88120ACA702BE069460A7202A96846FBF732FA6946898828198170694689884D -:40624000A41C090AC170E0B269462A18C98891706946C988801C090AD170C0B269462A180988917069460988801C090AD170C0B2694649882A18917069464988090AD17027 -:40628000801CC4B23470FEBDDDDFFFFF38B504460020009069460F20FDF725FF002801D0072038BD00993E200870072088702078C8702088000A0871A07848716088000A75 -:4062C00088712079C871A088000A0872A0794872E088000A8872207AC8722089000A08730B2048700720FDF774F938BD10B5FBF7D3F910BD10B5FBF7E5F910BD10B5FBF71D -:40630000F1F910BD10B5FBF713FA10BD014A1268926A104744020008014A12681269104744020008014A12685268104744020008014A1268D269104744020008002801D008 -:406340000020704712207047002801D0002070471220704710B504460088F1F72FFE002816D0618808461B38E1280FD2A0880A4A90420BD8FF224932904207D3074A126B2F -:406380009388994202D8D188884203D9122010BD022010BD002010BD480800005C21000810B50021002815D0028813461B3BE12B0FD24088084B98420BD8FF2349339842F5 -:4063C00007D3064B1B6B9C88A24202D8DA88904200D91221084610BD480800005C210008014A1268526A104744020008014A1268D268104744020008014A1268126810477A -:4064000044020008014A1268926910474402000804480349016004494160044981607047804F001044020008E1610110DD6101100448034901600449416004498160704742 -:40644000B04F001044020008E5610110B9610110014A1268D26A104744020008014A12685269104744020008014A12689268104744020008014A1268126A10474402000828 -:4064800002780A7042784A7080788870704702780A7042784A7082788A70C078C8707047427812020A80007802430A80704702780A7042784A708078887070474278120217 -:4064C0000A8003781A430A8082788A70C278CA7002790A7182791202CA8040790243CA8070470000014A1268926A104750020008014A1268526B104750020008014A126890 -:406500005268104750020008014A12681269104750020008014A1268D2691047500200080178272907D84178012901D0022902D18078012801D912207047002070470178C0 -:40654000272907D8C178012901D0022902D18078072801D9122070470020704710B50088F1F72CFD002801D0002010BD022010BD017803290FD84278032A0CD8807803284C -:4065800009D8CB0701D1002A05D0890701D4002801D0002070471220704710B504460088F1F70CFD00280BD0A078032812D8E17803290FD82279032A0CD8C30702D003E0EA -:4065C000022010BD002905D0800701D4002A01D0002010BD122010BD014A1268526A104750020008014A1268126B104750020008014A12681268104750020008014A126891 -:40660000D268104750020008014A1268926910475002000804480349016004494160044981607047E04F00105002000835660110D166011000207047044803490160044988 -:4066400041600449816070471C50001050020008596601108D27011038B504460020009069460A20FDF73FFD002801D0072038BD00993E2008700C208870A078C8702078A9 -:4066800008712088000A4871E07888712079C871062048700C20FCF79CFF38BD014A1268D26A104750020008014A1268926B10475002000800207047014A12685269104773 -:4066C00050020008014A1268126A1047500200080020704710B50B48017A01290ED0C17A00290CD001210172407A064BC000C03BC1184A884968185CEEF7CEFE10BD0021D2 -:40670000017210BD7027000870B503461448C47A192C0BD3022B05D0042B02D10846FDF7E9FC70BD0846FDF71BFD70BD847AE5000B4CC03C6355837ADB001B195960817AC2 -:40674000C90009194A80C17A491CC172817A491CC9B281721929E8D30021817270BD00007027000810B50F4CE17A002918D0617A2246C900C03A515C022904D0042904D1A6 -:40678000FDF7B8FC01E0FDF7EBFCE07A401EE072607A401CC0B26072192801D30020607210BD000070270008F7B5A14C84B02046E030039009380090401E0E46C0340190A0 -:4067C000E07B354601281CD0A07B012836D0A18A4A19082A02D90822511A8DB2002D0CD0002833D0A18A206A4018401E2A460499EDF77FFEA08A4019A082207C012829D085 -:406800002FE0A08A618A42198A4204D280B28019A08207B0F0BD081A0021A18280B26182E173002807D004992A1A091815460498EDF75FFEAEB2002EC2D1EAE7618AA28AD5 -:40684000891A8DB2B542C9D93546C7E7A18A01980818CBE700F068F90028DAD000202074E073608A002802D0A18A8142D1D3A08A0028CED000200290A07D01280CD0022850 -:4068800065D00220FCF7B6FE012020740021E173A1736182A1821DE0A08A03281CD9A07B002824D100270098F0F704F9002801D10420A0823A460120039900F00EF90128D7 -:4068C0000BD00420FCF796FE012020740021A173A1826182FCF78EFE9EE00120A073A28A012A04D9521E206A0099EDF702FE216A8F78381D6082502F10D9487802020878D1 -:40690000012110430022FCF755FEA07B012802D1216A00F0F8F80020A07331E0A28A82427AD3121A1206120EA28206D00918491E0198EDF7DEFD01200290FA1C216A0120C4 -:40694000069B00F079F80020A073608260E0A08A052861D33648D130C1798279080210430205A07B120D002815D10220039900F0B4F8012807D00520FCF73CFE009820620F -:406980000120E07348E00120A073A28A206A521E0099EDF7AEFD216A264AC8788F7800020743781D80B26082127DBA4213D20820FCF720FE012020740027A7826782E77391 -:4069C000FCF718FEA07B012803D10220216A00F09AF8A77320E0A28A82421DD3121A1206120EA28206D00918491E0198EDF781FD01200290E07B002806D13F1DBAB2216A0C -:406A00000220069B00F018F80020A0736082E0730298012800D12DE7B54200D3F9E60498721B16464119EDF764FDB6B2C8E60000B0260008AC1E00083EB5044600200D4640 -:406A4000009001900290012C14D0022C11D108206946088100954A81002B69460EC90BD0002000F0E7FC002803D02946204600F04AF83EBD1220EBE7002000F020FDF2E7FC -:406A800070B5047800250E2C03D10179C57809020D43FFF767FE0E2C02D12846FDF78CFC024800210172FFF715FE70BD7027000810B5FFF729FEFFF70DFE10BDF8B5154633 -:406AC00007465C1B2046069EEDF713FDA81982B221463846FFF7ECFFF8BD10B50B46012802D002280BD103E0084600F013FB03E01146184600F066FB0006000E01D0002030 -:406B000010BD012010BD10B5012805D0022802D1084600F0E1FB10BD084600F095FB10BD10B5FCF767FD10BDFCB514A00068009013A0144E0068019031460020C0316C46CA -:406B4000012711E03318C0339A7D255CAA4209D001AD2D5CAA4205D000228A829A7D012A00D18F82401C80B28A8A8242EAD890B2042801D00020FCBD0120FCBD01030C00ED -:406B800001091000B026000808B50B46C17882780902891889B20091014604220220FFF78DFF002008BD3EB54178002217236C46029223810090891C61810120029B0099CE -:406BC00000F07DFC00203EBD06480021017241728172C17201748182016241828173C1737047000070270008002210B511461046FCF7E0FC10BD0EB50021019102911921C7 -:406C00006B461981009001205881002A69460EC902D000F00FFC0EBD012000F050FC0EBD10B5FFF7D1FF034B034A04490448EEF721FC10BDF76B0110A9670110396A011039 -:406C4000E96B011010B50189032913D0172907D018290BD0192902D10068FFF711FF10BD428901680420FFF723FF10BD0068FDF745FA10BD03C800F015F810BD3EB500227F -:406C800003236C460292238101910090628169460EC9012000F0CEFB002801D000203EBD01203EBD10B5052802D10020EFF78AFD10BDF8B50E460546F8F7C6FB0023009061 -:406CC0006C46AB20E15C002900D1E0545B1CDBB2042BF7D32A463146204600F001F8F8BDF7B58AB03A480890001D054606900898019038480F460168069800910291039002 -:406D0000012600241835042233A10898EDF7F1FB0099069880310A7902704979417006980422801C0A99EDF7E4FB8E206946087530460899303048702819049001A800F0C4 -:406D40004FF8002021186A5C002A01D130226A54401CC0B21428F5D31434761CF6B2E4B2032EE5D9281D029000200390019568460475174E0024082F1DD9082730190490BF -:406D800001A800F02DF8002030222118735C002B00D17254401CC0B21428F6D36946097D3120685469461434087DE4B2401CC0B2087500212954BC42E0D3002004E00C996F -:406DC000325C0A54401CC0B2B842F8D30DB0F0BD942700085C0200083030303000000000F0B5BD4E07463446C56885B04034BB482060BB486060B948C043A060B848C04327 -:406E0000E060B8482061387C362801D8402104E0762801D8802100E0C021019104280AD23968042208180021EDF76CFB3A7C3968802088541CE088280DD279680422081816 -:406E4000001F0021EDF75EFB3A7C796880208918203908770CE0B9680422081888380021EDF750FB3A7CB96880208918A039087600200090387C694640098870387CC0004B -:406E8000C8700198800903900020D2E00020844602988001864660467146800009183A7CC9B28A421AD3042901D23A6806E0882902D2091F7A6801E0BA68883951180A7894 -:406EC000120232504B781A43120232508B781A4312023250C9780A43325016E0019A083A8A4201DB00210FE06A4611780902315052781143090231506A469278114309022D -:406F000031506A46D278114331506046401CC0B284461028BFD32068286060686860A068A860E068E86020692861002084460007000F86466046102817D37046C01E000778 -:406F4000800E3158704608300007800E305841407046801C0007800E32587046800033585A4051401F22D14131506046142809D26968AA6808461040EA688A431043E0614C -:406F800059481EE0282807D2A96868684840E9684840E061554814E03C280BD2A868EA680346696810430840194611400843E0614F4806E0A96868684840E9684840E06161 -:406FC0004C48A061E0692969A269411828681B23D8411018091870468000305808186061E8682861A868E86068680221C841A86028686860606928606046401CC0B28446D2 -:40700000502894D320682968401820606068696840186060A068A9684018A060E068E9684018E06020692969401820610298401CC0B203990290884200D227E7F968207800 -:40704000C8702088F968000A88702068F968000C48702068F968000E0870F9682079C871A088F968000A88716068F968000C48716068F968000E0871F968207AC872208976 -:40708000F968000A8872A068F968000C4872A068F968000E0872F968207BC873A089F968000A8873E068F968000C4873E068F968000E0873F968207CC874208AF968000A95 -:4070C00088742069F968000C48742069F968000E087405B0F0BD0000F02700080123456789ABCDEFF0E1D2C39979825AA1EBD96EDCBC1B8FD6C162CA30B500224B1E4C083D -:4071000005E0815CC55C8554C1545B1E521C9442F7DC30BD10B5044608484068EFF75CF92060002807D00649087B002801D0401E0873002010BD034810BD0000600200082D -:40714000A0210008FFFF000070B50A4D0446302905D8E868EFF740F92060002805D1A868EFF73AF92060002801D0002070BD024870BD000060020008FFFF000010B5044682 -:4071800005480068EFF728F92060002801D0002010BD024810BD000060020008FFFF000010B50446880005490858EFF715F92060002801D0002010BD014810BD70280008D9 -:4071C000FFFF000010B504460846F0F71FFF064980000858EFF700F92060002801D0002010BD024810BD000050280008FFFF000010B50446880005490858EFF7EDF8206096 -:40720000002801D0002010BD014810BD60280008FFFF000010B50446880005490858EFF7DBF82060002801D0002010BD014810BD80280008FFFF000010B5FCF711F9FCF7E7 -:4072400071F8002010BD0000014610B509484068EFF752F9002801D0074810BD0749087B401CC0B20873042801D904200873002010BD000060020008FFFF0000A02100088E -:4072800070B5084C05460146E068EFF735F9002806D02946A068EFF72FF9002800D0024870BD000060020008FFFF0000014610B502480068EFF720F910BD00006002000819 -:4072C0000246880010B5034908581146EFF714F910BD00007028000810B504464078217800020843F0F792FE0349800008582146EFF702F910BD00005028000802468800E1 -:4073000010B5034908581146EFF7F6F810BD0000602800080246880010B5034908581146EFF7EAF810BD000080280008F8B5040076D03C4E20783075A078F07520797075BE -:407340006079B0753546A07B20352870EBF740FBC0B2022801D0032805D1707D042802D12079401E707500242EE081070DD08107890F401A0C3082B22B48A700717D381860 -:40738000EFF750F800284BD101E00830F3E726482022103038180221EFF744F800283FD121482022203038180221EFF73BF8002836D11D484022303038180221EFF732F84B -:4073C00000282DD1641CE4B22878A042307DCCD881070BD08107890F401A0C3082B2B17D1248EFF71FF800281AD101E00830F5E70E4850220421001DEFF714F800280FD1A0 -:407400000A48482201210830EFF70CF8002807D10648302208210C30EFF704F8002800D00348F8BDAC1E00085028000860020008FFFF00001FB50446EBF770FA01A9204639 -:40744000FBF76AFF0446EBF753FA204604B010BDF8B5154CA068EFF7FDF8E068EFF7FAF86068EFF7F7F82068EFF7F4F800240F4F0F4E14E0A5007859EFF7ECF80B481030A3 -:407480004059EFF7E7F8094820304059EFF7E2F8064830304059EFF7DDF8641CE4B23078A042E7D80020F8BD6002000850280008CC1E000810B5FBF743FF002010BD1FB5A8 -:4074C0000446EBF72BFA01A92046FBF769FF0446EBF70EFA204604B010BDF8B5054600202870F02316466B800246034607E00C245C439F0064187F195B1CDBB27C60B342DD -:40750000F5D3344604E0A1004919641CE4B24A60052CF8D3002408E022460121284600F007F8002803D1641CE4B2B442F4D3F8BD70B50B460546002411461846FAF70CFE5A -:40754000FF2810D0800040194268FF2111704268002151704268917042681181426851814068416000E0014C204670BD0100160010B50C4B89001C7800220818002C01D059 -:4075800041680A8144686189002901D0491E618140688178002902D0491E817000E042701A7010BD70020008F0B500230746FF209C461C461E4D1A4621E0CE071CD09E00C4 -:4075C000F6197668B6467678A64201D934461846002C11D176463678AE420DD8AE4208D105460120A840104301229A400243D2B200E00022184635465B1CDBB2490800293E -:40760000DBD1002C10D1002A0ED0D30708D08B00DB195B681B89634502D3D8B284460846491CC9B25208F0D1024A01211170F0BDFFFF00007002000803460020052906D254 -:40764000002B04D08900C91849680A70704701487047000001001600034610B5002005290ED2002B0CD08900C9184B685C78944208D25A70802A02D1496806228A7010BDDD -:40768000024810BD0148FE3010BD0000010016000246890089184A68002053891B1D53814A6813895B1C138149684A68521C4A6070470000F7B5054682B000205249534A20 -:4076C00000900427681AAE188D421BD00ADC002E1AD04E2E1AD04F2E18D0F5208000301A15D10DE001280BD0032807D0072803D0474940180BD107E00A2708E00B2706E06E -:407700000C2704E0442702E0072700E006276946381DFCF7E8FC002802D0072005B0F0BD009C294667702046039AFCF7D3F90398002864D1344B2A465B1CE81A049F049D04 -:4077400034493F0AEDB29A4238D008DC002E23D0F5208000301A3CD0012850D14CE002280BD0062804D02A49491C401847D11BE0A11D0020F3F784FB41E0087DA071000A08 -:40778000E071087D2072487D6072000AA072487D21460931E0722CE0214608310498EFF76DFD06E060712AE0214608310498EFF751FDA571E771002821D0F3E7251DA01DCD -:4077C00008220021ECF79EFEA87960210843A87115E00879A0710889E071000A2072487960720888A072000AE072C88821460A312073000AC87002E0A01DFCF7B7F92146B3 -:40780000FF20FBF7E6FE89E702100000D3F3FFFFFDFBFFFFAC1E000830B51E4B0224C21A984235D015DC1C4B0325C21A984225D008DC1A4A801826D0172826D0184A8018E6 -:407840001AD11DE02A2A1ED0602A19D0782A13D11BE0144BD01A9A4210D007DC124810180CD001280AD0022806D107E0042805D001229202801A08D0002030BD002000E082 -:407880000820087002E00D7000E00C70012030BD0420F6E77C0C0000030C0000FAFBFFFF05F8FFFF890300007BFCFFFF10B5224C131BA2423CD016DC204C131BA24228D01F -:4078C00008DC1F4BD2182DD0172A2ED01D4BD21808D121E02A2B22D0602B1DD0782B01D1FDF7EFFE10BD184C1A1BA34211D007DC164A9A180DD0012A0BD0022AF2D108E0F8 -:40790000042A06D001239B02D21AEBD1FDF7F9FE10BDFDF79FFE10BDFDF72AFE10BDFDF7F7FE10BDFDF797FE10BDFDF7FDFE10BDFDF7A0FF10BD00007C0C0000030C00001C -:40794000FAFBFFFF05F8FFFF890300007BFCFFFF70B50C460146304E01208B1B0546B1424ED01DDC2D4E8B1BB14238D00CDC2C4BC91839D017293DD02A4BC91803D111468D -:40798000204600F055F870BD2A2B23D0602B3DD0782BF8D115701146204600F091F870BD214D591BAB4213D007DC204959180FD001290DD00229F2D10AE0042908D001236D -:4079C0009B02C91AEBD11146204600F088F870BD002070BD1146204600F085F870BD1146204600F088F870BD15701146204600F05BF870BD15701146204600F078F870BD72 -:407A000015701146204600F082F870BD1146204600F036F870BD00007C0C0000030C0000FAFBFFFF05F8FFFF890300007BFCFFFF10B5104B0422597A3024114059720E4AFE -:407A40000168114001600D4A416811404160026850080843810A2140C00D422420400143587A120989242240104301435972002010BD0000A021000890880002008000205B -:407A8000084AFB23517A1940517201230168DB0519400160507A490D042319400843507200207047A021000870B50C460546FDF70CFF002803D121462846F1F7E1FD70BD76 -:407AC00070B50C460021217005462146FEF762F8002803D121462846F1F700FF70BD10B5FEF764F810BD10B5FEF76AF810BD10B5F1F740FF10BD70B50C460546FEF770F8D3 -:407B0000002803D121462846EFF76CFD70BD70B50C460021217005462146FEF763F8002803D121462846F2F7A3F870BD10B5F0F74FF910BD10B5F0F7B7F910BD10B5F0F7B5 -:407B400051F910BD10B5F0F7F9F910BD7047000010B50C460088044948430449EAF7D8FFBD21081A208010BD4B2800001027000010B50C460088AE214843034940180A2171 -:407B8000EBF7B0F8208010BD91FCFFFF70B5094C054621780648002909D1074A0321074800F0C2F9002802D102212170656070BD02001600740200086D7D011004080000E7 -:407BC00070B50A4C05462178074800290AD10F21074A0902074800F041FA002802D101212170656070BD00000200160074020008A17C01103B08000001484078704700006E -:407C000074020008F8B506461920694608702020487001248C700220C8706846EAF704FB002805D01449884202D013481230F8BD022000F0FFF8114F2F253D630A20EAF7BC -:407C400053FE304600F08EFC0D4E304600F018F9802188430146304600F026F900F076FC00F040FA3D6307488460012000F0D8F900F07EF9F8BD00000300160040F03D4096 -:407C80000E1E000040003C4010B5EAF76DFA10BD10B5400701D500F08BF910BD7047000010B5034A0321034800F03EF910BD0000B97C01100408000010B5034A08210348DB -:407CC00000F01CF910BD0000D17C01100608000010B5034A0821034800F026F910BD0000E97C01100608000010B5034A0721034800F01AF910BD0000017D01103C08000038 -:407D000010B5034A0221034800F0A8F910BD0000197D01103A08000010B50249024800F063F910BD2D7D01101B0A000010B5C80704D00549054800F057F910BD00210846AA -:407D4000FFF7EAFF10BD0000517D01101A0A000010B5054CC9B26268002A01D00020904700206060207010BD7402000810B5034A0821034800F0C2F810BD0000857D01103C -:407D80000608000010B5034A0821034800F0CCF810BD00009D7D011006080000032110B58902034B0A46034800F090F810BD0000B97D01103D08000010B5034A01210348C8 -:407DC00000F04CF910BD0000D17D01103A08000010B50249024800F007F910BDE57D01101B0A000010B5880704D50549054800F0FBF810BD00210846FFF7DEFF10BD0000AA -:407E0000097E01101A0A000010B5054C090A6268002A01D00120904700206060207010BD7402000802480168490049080160704700003C4070B50446002500F091F80128CE -:407E400002D1002000F0ECF80B4A11680B48012301433F20400381431B039943012C08D960033F24640300194003400B0843184301461160284670BD00003C40040A00806D -:407E80000121C9030843074A0004D061054840300168C907FCD00168012319430160D06A80B2704700003C404004400808430649C861054840300168C907FCD001680122BB -:407EC000114301607047000000003C4070B5094C054626780648002E08D1032020706360218162810449284600F07EF870BD00000200160090280008A980011030B5084B4F -:407F000004461D780548002D07D1022018705A6059810449204600F067F830BD0200160090280008A980011010B5074B1C78002C01D0064810BD01241C705A60598104497C -:407F400000F052F810BD00009028000802001600A980011001490120087070477C02000802480068C007C00F7047000000013C4000B50023FFF7F4FF012801D0084B0CE052 -:407F800008490C20086188610748012101700021064A4160116051609160184600BD00000200160000013C407C020008902800080A48C16901610A480A0701D5416802E053 -:407FC0004A0700D50168074A0123137088B25268090C002A00D010477047000000013C4040013C407C02000810B50A4A034614780020012C01D0084810BD022414705160A5 -:4080000006494B60054A403A116808231943116010BD00007C0200080200160040013C400D490A68D207D20F824205D001220028086802D0104308607047022318430860E2 -:408040000868C007FCD10869104308610248C038016811430160704700013C4010B50A4B090401431C780020012C01D0074810BD02241C705A60064A1160054940390A689C -:4080800004231A430A6010BD7C0200080200160040013C4003480078012801D001207047002070477C020008F0B50D4C012622465389277800259E405268012F0AD0022FB8 -:4080C0000BD0032F05D12689B1431943FFF7C6FF2570F0BD0E43B1B2F8E7B143F6E700009028000810B517493820886116484860144A1648C03210611648154A4260174B31 -:40810000154A9A61164A0260144B164A803B9A63154A13680124640223431360134A022313630269082492B222430424CC601A4319030A4381158A4341210A43026100F0B7 -:4081400017F810BDC0103C4037D70000308A000058480000001E3C40FF0F000040123C400524000020FF000040503D40C0F03D4070B51849002548681C2210434860154886 -:408180004038416A826AC9B2D2B2C06A51180002000E4018001DC10700D0401C01264408B6020A2C12D90A212046EAF7B1FCC0B2072800D907200A214143A14204D2611AB6 -:4081C000CDB21F2D00D31F2544012C4302483443846370BDC0F03D4080103C4010B5FFF7BFFE012802D10020FFF71AFF044C2046FFF746FE8104890C2046FFF755FE10BDB2 -:40820000021E00000248416B022291434163704740F03D400248416B022211434163704740F03D40014909680180704780F03D4010B50C4C2F202063FFF754FF9A20E0629E -:40824000FFF78EFE002809D107480068002802DB0220FFF7EFFD0120FFF7E2FEFFF788FE10BD000040F03D4000003C40F0B58C4600881749884202D11648006880B28104D8 -:408280000C0D0004800F10D0012810D0862600202F230246262C10D30F4FD018400841007D5AA54205D140B207E05726EFE77026EDE7991A012905DC50B22030801B614643 -:4082C0000870F0BDA54201D20246E6E70346E4E7FFFF000080F03D40E05000100449002802D0012008567047002008567047000084020008F1B51B4FFD6A1A484030406B17 -:40830000C0072DD0386BC0072AD0FFF7C3FE012826D0102128468843F86200211248FFF763FE124C20690007FCD5104840304068060C08206061FFF70DFE0320400386434F -:40834000009800224003304381B20748FFF786FE20694007FCD504206061FFF7FBFDFD62F8BD000040F03D400F1E000000013C40F8B52449496BC90743D022494039096BA9 -:40838000C9073ED04178002912D01F4D1F492C1D002282560527FF43931D0026BA4214D00CDC0E331ED0042B17D0082B0AD10FE0154D1649083D2C1D491EE9E7002A01D035 -:4083C000042A14D00E70042714E00F70032711E00B22D2430A7002270CE00F22D2430A70012707E01322D2430A70002702E004220A70052700214156084600F01BF82F6063 -:408400002660F8BD80F03D40B8113C408502000810B5FFF7A5FD012802D10020FFF700FE03492F2008630220FFF704FD10BD000040F03D40F8B5314C0646E56AFFF72AFE57 -:40844000012859D01021284688432146C8622B484030006A2A4C2B4F00072BD52A48A178042E02D0042913D043E0042941D0A188802291430722120211430022FFF7EEFD38 -:4084800038694007FCD504207861FFF763FD1CE0A1880F22D20191430322520289180022FFF7DCFD38694007FCD504207861FFF751FD0FE0A078042E02D0042807D018E0A8 -:4084C000042816D00720EAF78DFAB02103E00320EAF788FA98210C4800220930FFF7BEFD38694007FCD50420786104498862FFF731FD0248A670C562F8BD000040F03D408E -:408500008402000800013C40071E000070B5084980200860074C0025E562FFF779FFFFF75DFE262020636563FFF77CFC70BD000000103C4040F03D4010B503490020C8624F -:40854000E9F766FE10BD000040F03D4010B50348FFF796FC0249888010BD0000071E00008402000810B5044600F0D4FC204600F035F900F015F80849012000F0E5FB074CED -:40858000FF214131204601F025F865218901204601F020F810BD000088090000021E0000F8B5002469462046009400F0F9FF00980321C008C000084381B20090002001F0F3 -:4085C00009F80126760269463046009400F0E8FF009902200143009189B2304600F0FAFF4C494D4800F0F6FF4B4D6946ED1E2846009400F0D5FF3F210098C9018843FF214D -:408600008131084381B20090284600F0E3FF424F6946843F3846009400F0C2FF00980125284381B20090384600F0D4FF3A486946801F009400F0B4FF03210098890288432E -:4086400081B200903448801F00F0C4FF6946B81C009400F0A5FF0098A84381B20090B81C00F0B8FF6946B81C009400F099FF0098284381B20090B81C00F0ACFF2648012199 -:40868000001F00F0A7FF00946946244800F088FF0098C007F8D0FF200021013000F09AFF1D480021813800F095FF69463046009400F076FF00980221884381B2009030461E -:4086C00000F088FF69460020009400F069FF00980721C008C000084381B20090002000F079FF0F4E45218901304600F073FF65218901304600F06EFF69463846009400F0B1 -:408700004FFF009938462943009189B200F062FFF8BD0000665E000088080000110A0000021E000038B50B21002000F053FF012464020721204600F04DFF1421224800F0A8 -:4087400049FF214D2049AD1C0939284600F042FFE91F284600F03EFF1B481C49483000F039FF19480121343000F034FF164801213D3000F02FFF21200121800100F02AFF13 -:40878000114813494A3000F025FF0021114D00916946284600F004FF00994907F8D50021204600F017FF0F21002000F013FF0A4C45218901204600F00DFF652189012046A3 -:4087C00000F008FF38BD00000408000042020000BD6E0000110A0000021E0000F1B58AB00A98012842D110216846E9F737FF00283CD168460088A249884237D16A46518873 -:4088000048409188D288514048406A46118948405189484091894840D189814226D1FFF781FF68464188974800F0D4FE684681889448401E00F0CEFE6846C1889148801E91 -:4088400000F0C8FE684601898E48C01E00F0C2FE684641898B48001F00F0BCFE684681898320400100F0B6FE0BB0F0BD8648069086480990EAF734F8012810D04120C001E7 -:408880000790834869465A380882012065244002E4014882401088827D4D662015E0EAF721F8002803D07A4D7A4C2D1D02E0F925794CED0079480790794869460882FF2062 -:4088C000C3304882C82088827020C8827548066A00273007002811DA08A97348089700F05FFE0F210898C901884307210902084381B208906C4800F06DFE02E00720EAF752 -:4089000071F8694808A90930089700F049FE0898782188433821084381B208906248093000F058FEC820E9F7DFFF2946204600F0EBFC544D6C466D1EA11C284600F030FE48 -:4089400068464088810602D1401C69464880E9F7C9FF002808D16846408880090A2803D98320800069464880300712D54E4E08A93046089700F014FE0F210898C90188431D -:4089800003214902084381B20890304600F022FE02E00320EAF726F8434E08A909363046089700F0FDFD0898782188431821084381B20890304600F00DFEC820E9F794FF09 -:4089C0000699079800F0A0FC211D284600F0E8FD68468288900602D1521C6846828004A8099900F063F8A11D264C204600F0D8FD02A9284600F0D4FD02A9A61E0231304607 -:408A000000F0CEFDE71E03A9384600F0C9FD68464188204600F0DEFD68468188284600F0D9FD6846C188304600F0D4FD68460189384600F0CFFD68464189201F00F0CAFDF5 -:408A400068468189601F00F0C5FD0A98012800D00AE70B486A461080518848409188D288514048406A46118948405189484091894840D08110216846E9F720FFF4E6000022 -:408A800082030000651000008202000082040000C6070000D4300000952E0000841C0000DC05000080F03D40071E0000F3B581B00024054669462046009400F071FD0098A4 -:408AC0000321C008C000084381B20090002000F081FD012069464002009400F061FD00980721C008C000084381B200900120400200F070FD834F69463846009400F050FD54 -:408B000000980126304381B20090384600F062FD69463846009400F043FD00980221084381B20090384600F055FD69463846009400F036FD00980421084381B200903846CC -:408B400000F048FD69463846009400F029FD00981021084381B20090384600F03BFD6946B81C009400F01CFD00980627B84381B200906448801C00F02DFD62486946801C72 -:408B8000009400F00DFD0098B843384381B200905C48801C00F01EFD5A4F694648373846009400F0FDFC00980221084381B20090384600F00FFD69463846009400F0F0FC59 -:408BC00000984021084381B20090384600F002FD69463846009400F0E3FC00987102084381B20090384600F0F5FC464F694634373846009400F0D4FC0098304381B20090AA -:408C0000384600F0E7FC3F4F69463D373846009400F0C6FC0098304381B20090384600F0D9FC7F1E69463846009400F0B9FC0098304381B20090384600F0CCFC3148FF21BD -:408C4000CA31623000F0C6FC2E480299643000F0C1FC2C4829885D3000F0BCFC294869885E3000F0B7FC2748A9885F3000F0B2FC2448E988603000F0ADFC224822494A3054 -:408C800000F0A8FC214D00946946284600F088FC00994907F8D51B480221633000F09AFC00946946284600F07BFC00998907F8D501256D0269462846009400F071FC0098EF -:408CC000C108C900009189B2284600F083FC69460020009400F064FC00980721C008C000084381B20090002000F074FC084C45218901204600F06EFC65218901204600F046 -:408D000069FCFEBD04080000BD6E0000110A0000021E000010B50A4A02280AD0012807D1084808188001C01C81B2104600F052FC10BD7D200001081A80013D30F4E7000099 -:408D40004E0800002FF8FFFFF3B5002583B000287DD0FF240026163401A92046019600F01FFC0198022180088000084381B20190204600F02FFC614F01A93846019600F00B -:408D80000FFC032101980903884381B20190384600F020FC01A92046019600F001FC0198302188431021084381B20190204600F011FC534E002402200499FFF7ABFF002096 -:408DC000019001A9304600F0EBFB01984006F8D54B486946083000F0E3FB68460088641C2D180A2CE7D3E9F77BFD07006AD00A212846E9F78DFE6946088068460188FF20E3 -:408E0000143000F0E7FB0020FF241634019001A9204600F0C5FB019830218843084381B20190204600F0D6FB00252C4602200499FFF770FF0020019001A9304600F0B0FB2C -:408E400001984006F8D52E486946083000E037E000F0A6FB68460088641C2D180A2CE5D3002F3DD00A212846E9F752FE6946088068460188FF20153000F0ACFBFF240025C2 -:408E8000163401A92046019500F08AFB019902208143019189B2204600F09CFB01A92046019500F07DFB019930208143019189B2204600F08FFB65218901124800F08AFBCB -:408EC00005B0F0BD2846EBF757F90F4A0F4BEAF74FFB00220E4BEAF735F8E9F755FF8AE72846EBF749F9084A084BEAF741FB0022074BEAF727F8E9F747FFB7E703020000D3 -:408F00001D0A0000021E00009A9999999999244000005940F8B5E9F7E3FCE94D0746002469462846009400F03BFB03210098890388430121C903084381B20090284600F0FF -:408F400049FB6E1C69463046009400F029FB032500986D03A843284381B20090304600F039FB69463046009400F01AFB00981C2188430421084381B20090304600F02AFB57 -:408F800069463046009400F00BFB0098022180088000084381B20090304600F01BFBC84E694609363046009400F0FAFA0098A84381B20090304600F00DFBB021701C00F0C2 -:408FC00009FBBF4865218901001F00F003FBFF25173569462846009400F0E2FA00981021084381B20090284600F0F4FAB54DFF202946313000F0EEFAFF202946323000F090 -:40900000E9FAFF208021333000F0E4FAB1218900012000F0DFFAAC49052000F0DBFA8125ED00AA4E002F7DD0C1218900022000F0D1FA3146032000F0CDFA3C210B2000F020 -:40904000C9FA2946072000F0C5FAA0490820FF3900F0C0FA39210C2000F0BCFA00210A2000F0B8FA40210D2000F0B4FAFF207021133000F0AFFAFF262D211636C901304625 -:4090800000F0A8FAFF27FF2134370902384600F0A1FA8F498F4800F09DFA8E488E49401C00F098FA8B488D49801C00F093FA272181200901800000F08DFA41208849C000FA -:4090C00000F088FA83488749001D00F083FAFF25804801352946401D00F07CFA03203A21400200F077FA78497F480E3100F072FA7D487E49401C00F06DFA7B480621801C7C -:4091000000F068FA78480321401D00F063FA61207749000100F05EFA7348FF21103000F059FA00E0B5E07048C821083000F052FA6D480121093000F04DFA6B483C21113045 -:4091400000F048FA684801210C3000F043FA664868490D3000F03EFA634867490E3000F039FA41206946C000009400F019FA0721009889028843E900084381B2009041202D -:40918000C00000F027FA5D49384600F023FA69463046009400F004FA0F21009809028843084381B20090304600F014FA0421880200F010FA1021524800F00CFA50480E21B5 -:4091C000401C00F007FA4E4840210F3000F002FA4B488021103000F0FDF949488621113000F0F8F93B486946401C009400F0D8F90098382188432021084381B200903548E1 -:40920000401C00F0E7F9812069468000009400F0C7F903210098090388436901084381B200908120800000F0D5F9812069468000009400F0B5F903210098890288430843A5 -:4092400081B200908120800000F0C4F921486946001D009400F0A4F90721009809028843284381B200901B48001D00F0B3F919486946001D009400F093F900980121000927 -:409280000001084381B200901248001D00F0A2F9F8BD2946022000F09DF93146032000F099F93B210B2000F095F90E4907200A3900F090F91349082000F08CF93321CAE679 -:4092C000061E0000808000000DB00000013E000030480000010200009426000043430000D4D20000190800000106000036790000FF0D00008CC800004698000034CA0000DA -:4093000001100000023A0000F3B581B0002469462046009400F044F900980321C008C000084381B20090002000F054F901277F0269463846009400F033F900980625C0084D -:40934000C000284381B20090384600F043F969468E48009400F024F900980126304381B200908A4800F036F969468848009400F017F900980221084381B20090834800F0B2 -:4093800029F969468148009400F00AF900980421084381B200907D4800F01CF969467B48009400F0FDF800981021084381B20090764800F00FF975486946801C009400F0F3 -:4093C000EFF80098A84381B200907048801C00F001F96E486946801C009400F0E1F80098A843284381B200906848801C00F0F2F8664D694648352846009400F0D1F800989B -:409400000221084381B20090284600F0E3F869462846009400F0C4F800984021084381B20090284600F0D6F869462846009400F0B7F80098384381B20090284600F0CAF8EC -:40944000BD1D69462846009400F0AAF80098304381B20090284600F0BDF84C48632149017E3000F0B7F849480521343000F0B2F8474E69463046009400F092F80098032106 -:4094800080088000084381B20090304600F0A2F83E484049623000F09DF83C480299643000F098F8394801995E3000F093F8374800215D3000F08EF8344800215F3000F05A -:4094C00089F832480021603000F084F82F4832494A3000F07FF800946946304800F060F800984006F8D529480221633000F072F800942A4869460C3800F052F80098800700 -:40950000F7D569463846009400F04AF80098C008C00081B20090384600F05CF869460020009400F03DF800980721C008C000084381B20090002000F04DF8154F45217F1F2C -:409540008901384600F046F865218901384600F041F869463046009400F022F80098022180088000084381B20090304600F032F869462846009400F013F800984108490004 -:40958000009189B2284600F025F8FEBD04080000071E0000C9050000BD6E00001D0A000010B50C4601210903FF22411A0232914208D201460548FEF777FC0121C802FEF7D9 -:4095C00073FC0348FEF75CFC208010BD01080000080A000010B5FEF767FC10BDE897FE7F010000000000001000000008C000000004960110C0000008B804000028190008A5 -:40960000740F000000127A0000127A0000093D0000093D0000093D0004000000A00F00000000D0070700000002000000030000000F00000000000000000000000300000015 -:409640000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000019000050A0000000E4450010A5 -:40968000DC450010404600100000614002FF0000891F00100100000006000000841E00080000000000000000000000000000000000000000000000000000000020000000B8 -:4096C00000FFF40100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076 -:40970000000000000000000000000000000000000001000000000000000000000000000000000000FF0000000000000000000000A84700100000000000000000000000002A -:4097400050480010000000000000000098480010000000000000000021000000C04800103C4D0010C04D0010444E0010000000009145011091450110084F0010D95E011043 -:40978000DB5E0110744F0010804F0010E1610110DD610110E04F001035660110D1660110585000100000000000000000000000000000000000000000000000000000000020 -:4097C00000000000000000000000000000000000E9000010C100001000000000F7B50D00019000F04BF9060003281FD12D4B1B69002B19DB002000F051F92B4FB84213D034 -:4098000000232A4A1900012000F020F9041E0BD1002000F043F9264BB84203D09C4203D00134F5E79C4201D1224D39E000F02EF9214A04000121214800F010F900282DD19C -:40984000019B002B16D1ADB2ED0001D11C4D18E03E221C4B06211A601B4A1C4B1A60A3221B4BD20099501B4A9D50995899580029FCDAEBE7114A1369002BFCDB00F016F94A -:409880000500032E03D0200000F0D8F808E00121002000F0EBF80028F9D1F4E7054DF0E72800FEBDC00023400101880048010008F049020005005200401E00080000234090 -:4098C00001005000040126401E1F000008012640000026401C05000010B54378FF2B0DD100F0D4F8064BDB685A68012311681943116011681942FCD100F0A0F810BDC04679 -:409900008000234070B52B490A682A4B002AFBDA0221DA680A43DA60DA68D2071BD5264D264CD9682A69266889B2360A36060E43FF21120209040A4032439026DA602969FD -:409940001F4A360111403143296121680A40324322602A692268002204241A495A605A680A6922430A61012801D030BF00E020BF1A68104D002AFBDAEA68D20712D5FF24EA -:409980000D4E0F4A3069E9682402090A1040214001430A4831610668E9683240090C0C40224302600221DA688A43DA6000225A6070BDC046E000234000002140900021408E -:4099C000FF00FFFF00ED00E00421134A13690B431361012801D030BF00E020BF0F4A1368002BFCDA0E4B19691A00002910D10D490D4B196006210D4B19600D4B3831196008 -:409A00000C4B0631196019680029FCDA0A4B13610022024B5A60704700ED00E0E0002340FC0025401E1F00000801264018052640040126401C052640AAAAAAAA01B40248BD -:409A4000844601BC604700BF531F001001B40248844601BC604700BF1911001001B40248844601BC604700BF890E001001B40248844601BC604700BFA90F001001B402480B -:409A8000844601BC604700BF0504001001B40248844601BC604700BF4B1F001001B40248844601BC604700BF2110001001B40248844601BC604700BF611700100000000099 -:409AC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066 -:409B00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025 -:409B400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E5 -:409B800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A5 -:409BC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065 -:0200000490303A -:02000000C887AF -:0200000490501A -:0C0000000005E20721002101E296E987DB -:00000001FF \ No newline at end of file diff --git a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_CY8C63XX/TARGET_MCU_PSOC6_M4/hex/psoc63_m0_default_1.02.hex b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_CY8C63XX/TARGET_MCU_PSOC6_M4/hex/psoc63_m0_default_1.02.hex deleted file mode 100644 index 6bc67c2194..0000000000 --- a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_CY8C63XX/TARGET_MCU_PSOC6_M4/hex/psoc63_m0_default_1.02.hex +++ /dev/null @@ -1,146 +0,0 @@ -:020000041000EA -:4000000000000108310100100D00000095010010000000000000000000000000000000000000000000000000000000009101001000000000000000009101001091010010DC -:4000400091010010F10700109101001091010010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001091010010FA -:400080009101001091010010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001020 -:4000C00010B5064C2378002B07D1054B002B02D0044800E000BF0123237010BD7804000800000000E01F0010084B10B5002B03D00749084800E000BF07480368002B00D1F1 -:4001000010BD064B002BFBD09847F9E7000000007C040008E01F001044010008000000007047EFF3108072B6704780F310887047FFF7F6FF72B6104C104DAC4209DA216818 -:400140006268A368043B02DBC858D050FAE70C34F3E70B490B4A0020521A02DD043A8850FCDC094809490860BFF34F8F00F0ECF800F01EF8FEE70000E41F0010FC1F0010B9 -:4001800078040008480700080000000808ED00E0FEE7FEE700B504207146084202D0EFF3098001E0EFF30880043001F08FFAFEE710B500F0A5F962B6064B5B689B0301D5D5 -:4001C00001F046FA044800F02FF9002001F0DCF9FBE7C0460000264000000810F8B5E023504C9B00E2580F231340D022990092000919885807224C4D0240032A05D0042A25 -:4002000005D0002A0FD0494811E028680FE0C022920089581F220A40112A01D0132A04D18020000203E0424801E0FA20C001002B27D1B223B1210322DB00C900E65863588A -:4002400067581B0F3F0F1340174205D0354F7958090F0A40012A01D1F20701D4032B3AD1B023344ADB00E658A158E758C904C90C01F05EFDB603F901B60BC90F704301314A -:4002800027E0012B27D1C823C0210322DB00C900E658635867583F0F174205D0214F7958090F0A40012A01D1F20703D49B009B0F032B10D1C0227F23D200A758A1583B40BD -:4002C0001F27A658090A3940584301F031FD310C394001F02DFDE0239B00E3589B069B0FD840154B68601C691969240A090E013101F01EFDE1B2A860013101F019FD0F4B87 -:40030000E860286104000E49C01801F011FDFA210C4B28758900E01801F00AFDA861C003E861F8BD00002640C000000800366E0100127A0084050000000021403F420F008F -:4003400040420F00E7030000B021E02010B530241F4BC9005A588000520052085A501A58A2431A50802252045A501A491A4A80209950A021043289019950FF21174AC005FA -:40038000995081315A5892009208024380205A505A580006024301205A505A5882435A5000F054FAFFF71AFF00F02AFA00F032FA00F0B8FEB0235B055A78002A02D05B7855 -:4003C000212B03D10022064BDA605A6010BDC0460000264001000200840500008C050000E0002340024BD86F032318407047C0460400214010B5FFF794FE074A074BD16F79 -:400400000B4007490B43D367102306490A681A42FCD0FFF78AFE10BD04002140FCFF00000100FA058800214070B50F4C0600FFF778FEE36F0500DB439B0701D1FFF7DAFF3F -:40044000B0230A4A9B00D650E26F094B09491340094A1343E36710230A681A42FCD02800FFF763FE70BDC0460400214000002140FCFF0000880021400300FA0510B5040063 -:40048000007B00F0F3F8606010BD10B50400007B216900F0B5F8606010BD10B5037B0169180000F0CDF810BD10B50400C06800F009F9606010BD10B5C06800F017F910BDF0 -:4004C00010B50400C06800F023F9606010BD10B5C06800F037F910BD10B504000C23C05E00F056F8606010BD10B50C23C05E00F06FF810BD10B5C06800F036F910BD0000A8 -:4005000010B500221849042000F0A4FC01221749042000F09FFC02221549042000F09AFC03221449042000F095FC04221249100000F090FC05221149042000F08BFC0622E9 -:400540000F49042000F086FC07220E49042000F081FC08220C49042000F07CFC09220B49042000F077FC10BD7D0400108B0400109B040010A9040010B7040010C104001062 -:40058000CF040010D9040010E9040010F504001070B507260512EDB206400D2D11D801F0FCF80A4901224B5D1C003441144003D1B24013434B5501E00124644201F0F1F8CA -:4005C00001E001246442200070BDC0469404000870B50412E4B20D2C0FD80725054001F0DCF8064901220B5D1E002E41164202D0AA4093430B5501F0D4F870BD94040008FA -:40060000F8B50C00050001F0C8F80C2301225D431300A3401A00094E71198F683A4008D13B43AD598B60631C4B60AB4202D94A6000E0FF2401F0B5F82000F8BDE0000008B5 -:4006400070B50C00050001F0A8F801210C23A1406B43054AD3189A680A4201D08A439A6001F09FF870BDC046E0000008F0B50C2485B0019001F091F8019B114D5C432B191E -:400680005B68029003932E1971680198FFF7B8FF0700FF280DD173682A59934201D9002373602A1953680399994202D001335360E9E7029801F075F8380005B0F0BDC04644 -:4006C000E000000810B5040007280AD801F065F8054B0E331A5D002A01D101321A5501F060F80120404210BD9404000810B5040007280AD801F051F8044B0E331A5D012AA5 -:4007000001D100221A5501F04CF810BD9404000870B505001F280ED801F03FF8084B30335C5D002C02D101225A5501E00124644201F037F801E001246442200070BDC0462A -:40074000E000000810B504001F280AD801F025F8044B30331A5D012A01D100221A5501F020F810BDE000000870B5B024C025144B144A15496405ED00E35CA25C615C665D10 -:400780003F251F242A400C4024039201224311002B407F2219430B003240520413430B4A1C0A110050310B701B0C8B7000234C7011005031595CC1540133062BF8D170BDDB -:4007C000040600000506000003060000E000000810B50248583000F051FB10BD2C05000810B50248B03000F049FB10BD2C05000810B5024800F042FB10BDC0462C050008A9 -:4008000010B5034A80216032042000F001FA10BD2C06000870B500F0C0FF0500094800F08BFA094C200000F0B9FA2000343000F0B5FA2000683000F0B1FA280000F0B1FF68 -:4008400070BDC0462C050008A81E0010F0B5962191B0002000F052FF00F028FF002801D100F016FF012000F0EFFDE821724C734B626C89011A400A436264626C0193120A5D -:40088000D2B23A2A04D1636C6D4A13400B4363643422002103A801F0E0FA03AA0021694800F06EFC3422002103A801F0D6FA03AA0121644800F064FC082204262368624D8B -:4008C000134323602369334207D1002D04D0012000F0D4FE013DF5E701E0002D00D1FEE7A02603220127594CF600A35903AD93433B43A351D2195649280001F0A5FA280078 -:4009000000F0F2FF534901980B68534A03400B608021136949041B021B0A0B4313611369019902200B401361E0230F219B00E2588A433A43E250E25821318A438021E250CE -:40094000E25809060A43E250002100F0D3FA0021032000F0CFFA0021042000F0CBFA0321002000F0C7FA0321380000F0C3FA384B0522191D280001F067FA2900380000F031 -:40098000DBFA002800D0FEE73449380000F026FB002800D0FEE7324B324AE1580A403A43E250E158304A0A408021E250E25809060A43E250A2592D4B1340A351A2592C4BF3 -:4009C00013408022920113438022A351A35912021343A351184B1A68264B1340164A136000F0E2FEC0235B00E3583B4204D1224AA3585B005B08A3506421002000F07EFEE9 -:400A000024220021280001F028FA29000D4800F031FC2A000E4B0C3313CB13C213CB13C213CB13C22900154800F024FC144A154B1A6011B0F0BDC04600002740FF00FFFFF8 -:400A4000FFC5FFDF0000324020A1070000002640441F001090002140000021401027000004050000FEFCFFFFFFFF00FFFFF0FFFFFF8FFFFFFFFCFFFF0C0500000003324042 -:400A800001001180000E1F41030010B5FF24800882009B1ADB009C409940E243214007282DD8174B01F03AF904090E13181D2227186A02401143196221E0586A0240114324 -:400AC00059621CE0986A02401143996217E0D86A02401143D96212E0186B0240114319630DE0586B02401143596308E0986B02401143996303E0D86B02401143D96310BDD7 -:400B000000002140064B10309A68064B9A4203D183009858995002E0034B8000C058704700ED00E00000000800000010F7B5051E01913DD00023C05E002802DBA978FFF735 -:400B4000A3FF6A680023E85E9201002812DB1A4B81088900C918FF2303271C00C0250740FF00BC401A40BA40AD004E59A64332434A5113E003250F2381B20B402940A9404B -:400B8000FC352F002A408F408A40083B9B080B4C9B001B19DE69BE433243DA61074B00259A68074B9A4204D10199FFF7ABFF00E0044D2800FEBDC04600E100E000ED00E070 -:400BC00000000008010056000369002B03DA89B24160002000E001487047C04601008A000368002B01DB034803E089B2C26081600020704701008A000369002B03DAC368D6 -:400C000000200B6000E001487047C04601008A0070B5040010000F2C2BD8002A07D1002927D1154B6401E418144B1C6022E000291FD01F260E401CD1104D0F4B6401E418D0 -:400C40006960AA60CA0831002C6001F006F931002000FFF7B9FF31002A1D2868FFF7C0FF011E04D12868FFF7AFFF011E02D0044900E00449080070BD000023401C07000810 -:400C800001018A0003018A00194BF7B51A680193D76804003B680E00834223D90025A94202D100F07AFD0500019B18680368002B01DB104C10E063095A01A41A0122A2408C -:400CC00079689B00CB18196811420DD00024914319600021FFF778FF002E07D1280000F060FD03E0044C01E0044CF2E72000FEBD1C0700080301880004018A000201880081 -:400D00000A4B1B68DA68136883420DD9430999005B01C31A0120984052688B581840431E9841034BC01800E0024870471C0700080001880004018A00024B1A68002A00D119 -:400D40001860704728070008F0B52C246043104C1E0024681F0A2018FF2426403C400D4F06607601F61906610B4E1B0C44606401A4191E04836033434461A3600023059D2C -:400D8000C261016283619D4201D02B888381F0BD280700080000234000102340F0B5038985B002AD2B800368066A1933AB704368476A0095826AC16A040003930369C06870 -:400DC000FFF7C2FF00213B000A0000913000FFF7BBFF216B2800FFF7A9FE0023EA5E002A05DB1F231A401E3B9340024A136005B0F0BDC04600E100E0F7B52C25124C6843E9 -:400E0000276801933C182669002E08D04D4379198869002805D13568002D02DA03E00B4811E00B480FE06768012425004B689D4013882D041D431560F2608C61BC40019B65 -:400E4000A4B24B62B460FEBD2807000804028A0007028A002C235843064B1B681818C369934204D9036A9200D150002000E002487047C046280700080A028A0073B5002638 -:400E800042690400D56801962B0CB3421CD01B040069136013680369B34215DA01A9FFF7ABFEB0420CD10198E26903681E0C0378934205D2226A9B009B58002B00D0984725 -:400EC00031002069FFF780FEADB2002D0ED063691D6000251B68636AAB4202D09847656203E0A36A002B00D09847A56163691B6873BD0000042819D804290FD94B1EFF3B13 -:400F0000132B13D81F231940094B8000C018C02304229B00C1504033C25005E00723D0301940034B8000C150002000E0014870470000264001004A00F0B5012819D1C02275 -:400F4000224BD2009A58002A0CDB8A78901E0E280FD84C78601E11280BD8C8780D7800282FD101E01A4830E07026152D01D9AE4201D2184829E00E79022E14D0F82124020C -:400F80004901F8270C4021007F2412047F033A4011432C4021438024C022C006240520400143D2009950C020C0248005360706403200E4001D590849002029400A431A51C4 -:400FC00003E03826122DD4D9D1E7F0BD0000264003004A0001004A00FFFFFFCFF8B50D00012819D1C02180240D4BC9005A582406C826224307001C005A50F600A3593B42B7 -:4010000006D1002D0AD0012000F038FB013DF5E70020002D03D101E0024800E00248F8BD0000264001004A0002004A001E4A0300904238D010D840282ED005D8002831D0B3 -:4010400010282DD119482EE0802827D08021100049008B4227D023E0154A904214D008D8A022120690421DD0124AA020934211D016E0114A904209D0104A904208D0104AB1 -:4010800090420DD10F480EE0A42003E00E480AE00E4808E0C00306E00D4804E00D4802E00D4800E0002070470600520001005000010000F0090000A0040000F0050000F0C5 -:4010C000030000F00100520002005200030052000200500005005200FF0052000B4B10B51B69002B10DB0A4B0A4C1868FFF79EFF0121094B094A995099580029FCD10649AC -:4011000009590029F8D100E0054810BD000023402C0700088C040000000025400C0400000200500010B5022202490020FFF792FE10BDC046990100080F4B30B5C0180F4BAC -:40114000C009C01800011F23032909D81D00C9008D4013408B400468AC432343036009E01D000439C9008D4013408B404468AC432343436030BDC0460000CEBF0010030457 -:40118000F7B504000E00150000286ED0002A6CD0012312688B40002A01D1436000E08360B30001930F231900B0008140A26A8A4369680B4083401343A3622A7A31002000BA -:4011C000FFF7BAFF0320710088400322636A83431800EB6813408B400343636201231F00B7400097FF43BC462F6962461F40B740A0691031104038436F69A0611F40B740A9 -:40120000E06A10403843E062A86903221840B0400600E869276B10408A408840009930430A4397436A6A384356000222206304201640AA6A616B92000240286A3243034017 -:401240001A43EB6AD80018230340FF2013432A6B019D520102401343FE2292002A40934081430B436363002000E00148FEBDC04601005A0000281BD0002919D00D4B0E4AD2 -:40128000C318DB099B180A681B010260CA6882620A69C2624A6902638A6842624A6882618A694263CA6900201A600A6A5A6000E0024870470000CEBF0010030401005A0069 -:4012C0000120024B1B68DB0D984370470000264010B50F2402200649064BCA58A2430243CA50F02212028B58A34303438B5010BD0000214004F0000010B50F240320064961 -:40130000064BCA58A2430243CA50F02212028B58A34303438B5010BD0000214004F000000449054A054B88580340C020C00103438B5070470000214004F00000FF8FFFFF5B -:401340000449054A054B885803408020C00103438B5070470000214004F00000FF8FFFFF70B50400002000F037FA00280BD1802324065B041C4023000E490F4A8D692A401B -:4013800013438B6115E0002C01D10C4A00E00C4A01210C48FFF724FC002809D1094A1369002BFCDB074B0020DB681B0EA02B00D0054870BD00F02540FFFFFFFE0100003099 -:4013C00001010030000023400400420010B5002000F002FAB0235B055A78002A03D05A780123222A01D843424341180010BD0000031E03D1084B5869C00F0CE00020012B26 -:4014000009D1054918008A69920F1A4201D18869C00F01231840704700002640072370B5084CA2691A4090420BD0A5699D4303402B43A361002904D0904202D9C82000F077 -:401440001DF970BD00002640F8B50500FFF7BEFF002844D000F0A1F9B02306005B05002D15D1E8220120D2009C5CFFF779FFE4B2071E30D1FFF72CFF1F201A491A4A8B5823 -:401480008343143803438B50FFF74AFF0FE01F20164A14499C5C144AE4B28B588343143803438B50023800F0E9F8FFF749FF1F230C480D491C40425800279A4314434450B3 -:4014C000012D08D1092000F0D9F8FFF715FF0020FFF746FF0700300000F063F900E0044F3800F8BD000026401CFF00004107000003004200F0B5060085B00D00204F04295C -:4015000001D001291AD100207C68002C35D01D4B984232D02379B3420ED1A368002B01D02B4209D1E36801A85A689B6842608360057023689847BC606469E6E7BC6802296C -:4015400002D1002C00D024690020002C15D00D4B984212D02379B3420DD1A368002B01D02B4208D1E36801A85A689B68426083600570236898472469E7E705B0F0BDC0462E -:401580003C070008FF004200F0B52B4C85B023680700002B0AD100F000F923680190002B10D004210120FFF7A5FF0BE001210800FFF7A0FF0028EED002210120FFF79AFF63 -:4015C0001E4C35E0B0256D056B78002B02D06B78212B03D1380000F057FC1EE0184E194BF3580293E823DB00EB5CDBB20393FFF767FE3100144A00280AD01F2302981840AF -:4016000003000398834203D0104BEB58B35001E000238B50380000F03FFC019800F0C1F823680024A34203D008210120FFF762FF200005B0F0BDC0463C070008FF00420033 -:40164000000026401CFF0000307F00001018000010B5E82400F0A1F8064B07495A68A4010A4022435A605A68114059605B6800F098F810BD00002640FF00FC0F10B5034BE8 -:401680001B78584300F080F810BDC046D400000880220020034B12069A649B6C834200DA0148704700002740030046008022054B120198585B68DBB2002B02D08023DB02A7 -:4016C0001843704700002640FEE7000002680A4B10B51A6042685A6082689A60C268DA6002691A6142695A6182699A61C269DA61FFF7EAFF10BDC04658040008F0B5192255 -:40170000002800D14B32E82403258A429241194E640033595242AB43134333513359164F3B403351154B5C68AC4322435A605A6817405F60002808D00023102913D9213317 -:401740008B429B415B4201330DE003001D290AD901233A2907D9DB18572904D976338B4240410422131A0F21054A1068884303431360F0BD00002140FFFCFFFFFC002140F6 -:4017800000002540000000000230800803D001300238FCD1C046C0467047EFF3108072B6704780F310887047094B042803D11A68104318600BE0C02200069204104090221D -:4017C00004499200885004211A688A431A60704710E000E000002140034B8002C0180F23006818407047C04600402440F8B58023FA250C0001271B0218430D4E0004F06196 -:40180000AD00326C0A4B01203A4205D1002D0CD0013DFFF733FFF4E7002D06D01A6C10431864DB6A0020238000E00248F8BDC04600003C400400160070B5FA2401260D4BAE -:40184000000418400C4D0143E961A4002B6C0A4A0120334205D1002C0AD0013CFFF70EFFF4E7002C04D0136C18431064002000E0024870BD0000FF7F00003C400400160030 -:40188000F0B5154B9DB001A90A00180070C870C270C870C270C870C20AAC1A0020002432E0CAE0C0E0CAE0C0E0CAE0C013AD2A004833C1CBC1C2C1CBC1C2C1CBC1C20748C7 -:4018C000FFF7D8FC21000648FFF7D4FC29000548FFF7D0FC1DB0F0BD741F0010000132408001324000023240F0B585B00090002800D159E1C54F7B689B0301D5FFF7A8FE16 -:40190000C34CC44DC44BEA58002A06D0013C002C03D00120FFF7B2FEF3E70122BF4C2959114205D0BE49BB484158114200D03DE1EB58B84E002B00D038E1FFF7A1FFB94AA7 -:40194000B94BF2508022009BD2021B781343B74AB350B74AB74BF250B74B5A6801231A4200D025E1B54A116F08220A4008D1B44BB44918681300884202D900F0D9F9431EA1 -:401980002A68002B03D0B0485B03034300E0AF4B13432B607B699F499C4E01275B000DD539000320FFF73AFD73699B0F3B420AD08022B369D2051343B36104E00320A44ACB -:4019C0008B5803438B502B5940200193019AA14BA14E13432B51FFF751FE0123AA598D4F1A4208D1BB514020FFF748FE03234020BB51FFF743FEFA27019A984B984E1A4056 -:401A000016430192FF002E51964A974BD3581022134207D1002F00D1CCE00120013FFFF72DFEF1E7002F00D1C4E008218F4A0120AB580B43AB50FFF7DBFC002802D18C4E35 -:401A4000019B1E438B4B1E4001231E432E511E00894C734BEB58334207D1002C00D1A9E00120013CFFF70AFEF3E7002C00D1A1E00B27C02181484901FFF7DEFE041E05D1C6 -:401A800002AB991D7D48FFF7B1FE0400013F002F00D136E1002C26D1C02202AB9E1D338852019342E5D131007548FFF79FFE041E19D180233288DB001A4200D081E00B2774 -:401AC000019380216E48C900FFF7B6FE041E04D131006B48FFF78AFE0400013F002F00D10FE1002C68D0B0256D056B78002B44D06B78212B41D0634FEB5B002B3DD0002C92 -:401B000000D000E102AB9E1D31005F48FFF76EFE041E00D0F7E0C021E85B3488084060398C434008594920430140F020EA5BC000EB5BD201024011439B05554A9B0F11406D -:401B4000DB02194350483180FFF776FE041E00D0D9E031004F48FFF749FE041E00D0D2E0C022EB5B31889B069B0F9B019143194348483180FFF760FE0400002C00D0C2E0F6 -:401B8000009B454859781D78444B49001943FFF753FE041E04D142494248FFF74DFE04006801FFF76BFDAEE03F4CACE03F4CAAE03F4CA8E03F4CA6E03388019A934200D02B -:401BC0007FE731003C48FFF711FE041E00D08AE732883F2310009843009B38499F78DB78012F0ED10222012B04D89FB2D21B92B2019201E017000194702210433080304AE9 -:401C000069E0002B5ED0019401275EE000002640F17E0E0000003C406CF00100A0F00100B4F0010006000001A4F00100A8F0010001000100ACF00100FC003C4000F03D405C -:401C4000C800000800093D00041A0080040A0080C4F0010030000300B0F00100EFFFFEFF20000200000032401040000068F0010028000200FFFFFBFFF07E0E00021E0000B3 -:401C8000031E000016180000071E00007FF5FFFFFFE7FFFF061E0000081E000001100000376800000F1E000001001600030016000200160004001600091E0000C0000008E2 -:401CC0000048E80101201F0001907F2082436F38024332800D4ADA400A6031880C4839433180FFF7A9FD009B0400DB78DF1B03231F40019B9B001F43064BBFB23780EF506D -:401D0000F1E6054CEFE6200005B0F0BD0024F400091E000064F001000400160002B4714649084900095C49008E4402BC7047C046002243088B4274D303098B425FD3030ADB -:401D40008B4244D3030B8B4228D3030C8B420DD3FF22090212BA030C8B4202D31212090265D0030B8B4219D300E0090AC30B8B4201D3CB03C01A5241830B8B4201D38B03BF -:401D8000C01A5241430B8B4201D34B03C01A5241030B8B4201D30B03C01A5241C30A8B4201D3CB02C01A5241830A8B4201D38B02C01A5241430A8B4201D34B02C01A52416A -:401DC000030A8B4201D30B02C01A5241CDD2C3098B4201D3CB01C01A524183098B4201D38B01C01A524143098B4201D34B01C01A524103098B4201D30B01C01A5241C308B9 -:401E00008B4201D3CB00C01A524183088B4201D38B00C01A524143088B4201D34B00C01A5241411A00D20146524110467047FFE701B5002000F006F802BDC0460029F7D08E -:401E400076E770477047C046002310B59A4203D0CC5CC4540133F9E710BD03008218934202D019700133FAE770470000F8B5C046F8BC08BC9E467047F8B5C046F8BC08BC4F -:401E80009E4670470000000001B40248844601BC604700BF9D02000801B40248844601BC604700BF610300080300000001000000010000000000000005036000040000002B -:401EC00001000000000000000100000006046000080000009C060008F10700100800000001000000020000000200000008080003090000000100000000000000030000008F -:401F00000909000308000000BC060008D10700100A0000000100000004000000040000000A0A000C0B0000000100000000000000050000000B0B000C10000000DC06000872 -:401F4000E1070010192001021901020000000000000000000000000000000000000000BA0000000000000000000000000000000000001D1D0000000000000000000000001D -:401F800066666666000000000000FFFF000000001C1C1C1C1C1C1C1C00000000000000000000000066E6EE66000000000000FFFF000000001C1A1A1A1A1A0000000000006F -:401FC000000000000000000066E66666000000000000FFFF000000001A1A001C00000000000000000000001000000008C000000004200010C0000008980300007804000888 -:40200000D002000000127A0000127A0000093D0000093D0000093D0004000000A00F00000000D0070700000002000000030000000F0000000000000000000000030000003C -:402040000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000019000050A000000002FF000053 -:40208000E9000010C10000100000000080B2C00017D00C4A1368002BFCDA3E220A4B06211A600A4A0A4B1A60A3220A4BD2009950094A985000209958024948609958002904 -:4020C000FCDA7047E0002340040126401E1F000008012640000026401C05000010B54378FF2B0DD100F022F9064BDB685A68012311681943116011681942FCD100F00EF987 -:4021000010BDC04680002340F7B50F00019000F03DF9050003281FD1274B1B69002B19DB002000F02BF9254EB04213D00023244A1900012000F01AF9041E0BD1002000F0EA -:402140001DF9204BB04203D09C4203D00134F5E79C4201D11C4E2CE000F0E8F81B4B1C4A0400D358002B06DA1A4A01211A4800F0F5F8002801D0144E0EE03800FFF786FF9A -:40218000019B002B07D0144A1369002BFCDB00F0DDF8060000E0114E032D03D0200000F0BDF806E00121002000F0C8F80028F9D1F4E73000FEBDC046C00023400101880090 -:4021C00038010008F0490200050052001C050000000026402C070008000023400100500070B52B490A682A4B002AFBDA0221DA680A43DA60DA68D2071BD5264D264CD968FA -:402200002A69266889B2360A36060E43FF21120209040A4032439026DA6029691F4A360111403143296121680A40324322602A692268002204241A495A605A680A6922431C -:402240000A61012801D030BF00E020BF1A68104D002AFBDAEA68D20712D5FF240D4E0F4A3069E9682402090A1040214001430A4831610668E9683240090C0C40224302602F -:402280000221DA688A43DA6000225A6070BDC046E00023400000214090002140FF00FFFF00ED00E00421134A13690B431361012801D030BF00E020BF0F4A1368002BFCDA07 -:4022C0000E4B19691A00002910D10D490D4B196006210D4B19600D4B383119600C4B0631196019680029FCDA0A4B13610022024B5A60704700ED00E0E0002340FC002540E5 -:402300001E1F00000801264018052640040126401C052640AAAAAAAA0000000001B40248844601BC604700BFA317001001B40248844601BC604700BF9B17001001B4024871 -:40234000844601BC604700BF890C001001B40248844601BC604700BFDD10001001B40248844601BC604700BFE10B001001B40248844601BC604700BFF90D001001B40248F9 -:40238000844601BC604700BF010D001001B40248844601BC604700BFE50300100000000000000000000000000000000000000000000000000000000000000000000000002E -:4023C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DD -:00000001FF \ No newline at end of file diff --git a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_CY8C63XX/TARGET_MCU_PSOC6_M4/hex/psoc63_m0_default_1.03.hex b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_CY8C63XX/TARGET_MCU_PSOC6_M4/hex/psoc63_m0_default_1.03.hex new file mode 100644 index 0000000000..026caf8e8f --- /dev/null +++ b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_CY8C63XX/TARGET_MCU_PSOC6_M4/hex/psoc63_m0_default_1.03.hex @@ -0,0 +1,146 @@ +:020000041000EA +:4000000000000108310100100D00000095010010000000000000000000000000000000000000000000000000000000009101001000000000000000009101001091010010DC +:4000400091010010B5070010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001036 +:400080009101001091010010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001091010010910100109101001020 +:4000C00010B5064C2378002B07D1054B002B02D0044800E000BF0123237010BD7804000800000000B01F0010084B10B5002B03D00749084800E000BF07480368002B00D121 +:4001000010BD064B002BFBD09847F9E7000000007C040008B01F001044010008000000007047EFF3108072B6704780F310887047FFF7F6FF72B6104C104DAC4209DA216848 +:400140006268A368043B02DBC858D050FAE70C34F3E70B490B4A0020521A02DD043A8850FCDC094809490860BFF34F8F00F0ECF800F01EF8FEE70000B41F0010CC1F001019 +:4001800078040008380700080000000808ED00E0FEE7FEE700B504207146084202D0EFF3098001E0EFF30880043001F071FAFEE710B500F0A5F962B6064B5B689B0301D503 +:4001C00001F028FA044800F02FF9002001F0BEF9FBE7C0460000264000000810F8B5E023504C9B00E2580F231340D022990092000919885807224C4D0240032A05D0042A61 +:4002000005D0002A0FD0494811E028680FE0C022920089581F220A40112A01D0132A04D18020000203E0424801E0FA20C001002B27D1B223B1210322DB00C900E65863588A +:4002400067581B0F3F0F1340174205D0354F7958090F0A40012A01D1F20701D4032B3AD1B023344ADB00E658A158E758C904C90C01F03EFDB603F901B60BC90F704301316A +:4002800027E0012B27D1C823C0210322DB00C900E658635867583F0F174205D0214F7958090F0A40012A01D1F20703D49B009B0F032B10D1C0227F23D200A758A1583B40BD +:4002C0001F27A658090A3940584301F011FD310C394001F00DFDE0239B00E3589B069B0FD840154B68601C691969240A090E013101F0FEFCE1B2A860013101F0F9FC0F4B09 +:40030000E860286104000E49C01801F0F1FCFA210C4B28758900E01801F0EAFCA861C003E861F8BD00002640C000000800366E0100127A0084050000000021403F420F00D1 +:4003400040420F00E7030000B021E02010B530241F4BC9005A588000520052085A501A58A2431A50802252045A501A491A4A80209950A021043289019950FF21174AC005FA +:40038000995081315A5892009208024380205A505A580006024301205A505A5882435A5000F036FAFFF71AFF00F00CFA00F014FA00F09AFEB0235B055A78002A02D05B78CD +:4003C000212B03D10022064BDA605A6010BDC0460000264001000200840500008C050000E0002340024BD86F032318407047C0460400214010B5FFF794FE074A074BD16F79 +:400400000B4007490B43D367102306490A681A42FCD0FFF78AFE10BD04002140FCFF00000100FA058800214070B50F4C0600FFF778FEE36F0500DB439B0701D1FFF7DAFF3F +:40044000B0230A4A9B00D650E26F094B09491340094A1343E36710230A681A42FCD02800FFF763FE70BDC0460400214000002140FCFF0000880021400300FA0510B5040063 +:40048000007B00F0D5F8606010BD10B50400007B216900F097F8606010BD10B5037B0169180000F0AFF810BD10B50400C06800F0EBF8606010BD10B5C06800F0F9F810BD88 +:4004C00010B50400C06800F005F9606010BD10B5C06800F019F910BD10B504000C23C05E00F056F8606010BD10B50C23C05E00F067F810BD10B5C06800F018F910BD00000A +:4005000010B500221849042000F086FC01221749042000F081FC02221549042000F07CFC03221449042000F077FC04221249100000F072FC05221149042000F06DFC06229D +:400540000F49042000F068FC07220E49042000F063FC08220C49042000F05EFC09220B49042000F059FC10BD7D0400108B0400109B040010A9040010B7040010C1040010DA +:40058000CF040010D9040010E9040010F504001070B507250412E4B205400D2C09D801F0DCF8064B1C5D2C41E407E41701F0D9F801E001246442200070BDC046681E0010D0 +:4005C00070470000F8B50C00050001F0C6F80C2301225D431300A3401A00094E71198F683A4008D13B43AD598B60631C4B60AB4202D94A6000E0FF2401F0B3F82000F8BD2B +:40060000E000000870B50C00050001F0A6F801210C23A1406B43054AD3189A680A4201D08A439A6001F09DF870BDC046E0000008F0B50C2485B0019001F08FF8019B114D5F +:400640005C432B195B68029003932E1971680198FFF7B8FF0700FF280DD173682A59934201D9002373602A1953680399994202D001335360E9E7029801F073F8380005B056 +:40068000F0BDC046E000000810B50400072809D801F063F8054B1A5D002A01D101321A5501F05FF80120404210BDC0469404000810B50400072809D801F04FF8044B1A5DE0 +:4006C000012A01D100221A5501F04BF810BDC0469404000870B505001F280ED801F03DF8084B30335C5D002C02D101225A5501E00124644201F035F801E001246442200072 +:4007000070BDC046E000000810B504001F280AD801F023F8044B30331A5D012A01D100221A5501F01EF810BDE000000870B5B024C025144B144A15496405ED00E35CA25CA1 +:40074000615C665D3F251F242A400C4024039201224311002B407F2219430B003240520413430B4A1C0A110050310B701B0C8B7000234C7011005031595CC1540133062B91 +:40078000F8D170BD040600000506000003060000E000000810B50248583000F051FB10BD1C05000810B50248B03000F049FB10BD1C05000810B5024800F042FB10BDC0464C +:4007C0001C05000810B5034A80216032042000F001FA10BD1C06000870B500F0BEFF0500094800F08BFA094C200000F0B9FA2000343000F0B5FA2000683000F0B1FA280032 +:4008000000F0AFFF70BDC0461C050008781E0010F0B5962191B0002000F052FF00F028FF002801D100F016FF012000F0EFFDE821724C734B626C89011A400A436264626CEF +:400840000193120AD2B23A2A04D1636C6D4A13400B4363643422002103A801F0DEFA03AA0021694800F06EFC3422002103A801F0D4FA03AA0121644800F064FC0822042659 +:400880002368624D134323602369334207D1002D04D0012000F0D4FE013DF5E701E0002D00D1FEE7A02603220127594CF600A35903AD93433B43A351D2195649280001F045 +:4008C000A3FA280000F0F0FF534901980B68534A03400B608021136949041B021B0A0B4313611369019902200B401361E0230F219B00E2588A433A43E250E25821318A431F +:400900008021E250E25809060A43E250002100F0D3FA0021032000F0CFFA0021042000F0CBFA0321002000F0C7FA0321380000F0C3FA384B0522191D280001F065FA2900C8 +:40094000380000F0DBFA002800D0FEE73449380000F026FB002800D0FEE7324B324AE1580A403A43E250E158304A0A408021E250E25809060A43E250A2592D4B1340A3517D +:40098000A2592C4B13408022920113438022A351A35912021343A351184B1A68264B1340164A136000F0E0FEC0235B00E3583B4204D1224AA3585B005B08A3506421002025 +:4009C00000F07EFE24220021280001F026FA29000D4800F031FC2A000E4B0C3313CB13C213CB13C213CB13C22900154800F024FC144A154B1A6011B0F0BDC04600002740CC +:400A0000FF00FFFFFFC5FFDF0000324020A1070000002640141F001090002140000021401027000004050000FEFCFFFFFFFF00FFFFF0FFFFFF8FFFFFFFFCFFFF0C0500002A +:400A40000003324001001180000E1F41030010B5FF24800882009B1ADB009C409940E243214007282DD8174B01F038F904090E13181D2227186A02401143196221E0586A87 +:400A80000240114359621CE0986A02401143996217E0D86A02401143D96212E0186B0240114319630DE0586B02401143596308E0986B02401143996303E0D86B024011438A +:400AC000D96310BD00002140064B10309A68064B9A4203D183009858995002E0034B8000C058704700ED00E00000000800000010F7B5051E01913DD00023C05E002802DB84 +:400B0000A978FFF7A3FF6A680023E85E9201002812DB1A4B81088900C918FF2303271C00C0250740FF00BC401A40BA40AD004E59A64332434A5113E003250F2381B20B40C6 +:400B40002940A940FC352F002A408F408A40083B9B080B4C9B001B19DE69BE433243DA61074B00259A68074B9A4204D10199FFF7ABFF00E0044D2800FEBDC04600E100E02B +:400B800000ED00E000000008010056000369002B03DA89B24160002000E001487047C04601008A000368002B01DB034803E089B2C26081600020704701008A000369002B51 +:400BC00003DAC36800200B6000E001487047C04601008A0070B5040010000F2C2BD8002A07D1002927D1154B6401E418144B1C6022E000291FD01F260E401CD1104D0F4B6A +:400C00006401E4186960AA60CA0831002C6001F004F931002000FFF7B9FF31002A1D2868FFF7C0FF011E04D12868FFF7AFFF011E02D0044900E00449080070BD000023401C +:400C40000C07000801018A0003018A00194BF7B51A680193D76804003B680E00834223D90025A94202D100F078FD0500019B18680368002B01DB104C10E063095A01A41AB8 +:400C80000122A24079689B00CB18196811420DD00024914319600021FFF778FF002E07D1280000F05EFD03E0044C01E0044CF2E72000FEBD0C0700080301880004018A0059 +:400CC000020188000A4B1B68DA68136883420DD9430999005B01C31A0120984052688B581840431E9841034BC01800E0024870470C0700080001880004018A00024B1A68DA +:400D0000002A00D11860704718070008F0B52C246043104C1E0024681F0A2018FF2426403C400D4F06607601F61906610B4E1B0C44606401A4191E04836033434461A36046 +:400D40000023059DC261016283619D4201D02B888381F0BD180700080000234000102340F0B5038985B002AD2B800368066A1933AB704368476A0095826AC16A040003938F +:400D80000369C068FFF7C2FF00213B000A0000913000FFF7BBFF216B2800FFF7A9FE0023EA5E002A05DB1F231A401E3B9340024A136005B0F0BDC04600E100E0F7B52C259E +:400DC000124C6843276801933C182669002E08D04D4379198869002805D13568002D02DA03E00B4811E00B480FE06768012425004B689D4013882D041D431560F2608C6135 +:400E0000BC40019BA4B24B62B460FEBD1807000804028A0007028A002C235843064B1B681818C369934204D9036A9200D150002000E002487047C046180700080A028A004E +:400E400073B5002642690400D56801962B0CB3421CD01B040069136013680369B34215DA01A9FFF7ABFEB0420CD10198E26903681E0C0378934205D2226A9B009B58002BC6 +:400E800000D0984731002069FFF780FEADB2002D0ED063691D6000251B68636AAB4202D09847656203E0A36A002B00D09847A56163691B6873BD0000042819D804290FD947 +:400EC0004B1EFF3B132B13D81F231940094B8000C018C02304229B00C1504033C25005E00723D0301940034B8000C150002000E0014870470000264001004A00F0B50128DF +:400F000019D1C022224BD2009A58002A0CDB8A78901E0E280FD84C78601E11280BD8C8780D7800282FD101E01A4830E07026152D01D9AE4201D2184829E00E79022E14D0BF +:400F4000F82124024901F8270C4021007F2412047F033A4011432C4021438024C022C006240520400143D2009950C020C0248005360706403200E4001D590849002029407D +:400F80000A431A5103E03826122DD4D9D1E7F0BD0000264003004A0001004A00FFFFFFCFF8B50D00012819D1C02180240D4BC9005A582406C826224307001C005A50F600B8 +:400FC000A3593B4206D1002D0AD0012000F038FB013DF5E70020002D03D101E0024800E00248F8BD0000264001004A0002004A001E4A0300904238D010D840282ED005D8A4 +:40100000002831D010282DD119482EE0802827D08021100049008B4227D023E0154A904214D008D8A022120690421DD0124AA020934211D016E0114A904209D0104A9042FA +:4010400008D0104A90420DD10F480EE0A42003E00E480AE00E4808E0C00306E00D4804E00D4802E00D4800E0002070470600520001005000010000F0090000A0040000F0C8 +:40108000050000F0030000F00100520002005200030052000200500005005200FF0052000B4B10B51B69002B10DB0A4B0A4C1868FFF79EFF0121094B094A99509958002913 +:4010C000FCD1064909590029F8D100E0054810BD000023401C0700088C040000000025400C0400000200500010B5022202490020FFF792FE10BDC046990100080F4B30B513 +:40110000C0180F4BC009C01800011F23032909D81D00C9008D4013408B400468AC432343036009E01D000439C9008D4013408B404468AC432343436030BDC0460000CEBF7C +:4011400000100304F7B504000E00150000286ED0002A6CD0012312688B40002A01D1436000E08360B30001930F231900B0008140A26A8A4369680B4083401343A3622A7A34 +:4011800031002000FFF7BAFF0320710088400322636A83431800EB6813408B400343636201231F00B7400097FF43BC462F6962461F40B740A0691031104038436F69A061EE +:4011C0001F40B740E06A10403843E062A86903221840B0400600E869276B10408A408840009930430A4397436A6A384356000222206304201640AA6A616B92000240286ABA +:40120000324303401A43EB6AD80018230340FF2013432A6B019D520102401343FE2292002A40934081430B436363002000E00148FEBDC04601005A0000281BD0002919D00A +:401240000D4B0E4AC318DB099B180A681B010260CA6882620A69C2624A6902638A6842624A6882618A694263CA6900201A600A6A5A6000E0024870470000CEBF0010030454 +:4012800001005A000120024B1B68DB0D984370470000264010B50F2402200649064BCA58A2430243CA50F02212028B58A34303438B5010BD0000214004F0000010B50F24B8 +:4012C00003200649064BCA58A2430243CA50F02212028B58A34303438B5010BD0000214004F000000449054A054B88580340C020C00103438B5070470000214004F00000B6 +:40130000FF8FFFFF0449054A054B885803408020C00103438B5070470000214004F00000FF8FFFFF70B50400002000F035FA00280BD1802324065B041C4023000E490F4A31 +:401340008D692A4013438B6115E0002C01D10C4A00E00C4A01210C48FFF724FC002809D1094A1369002BFCDB074B0020DB681B0EA02B00D0054870BD00F02540FFFFFFFEAA +:401380000100003001010030000023400400420010B5002000F000FAB0235B055A78002A03D05A780123222A01D843424341180010BD0000031E03D1084B5869C00F0CE083 +:4013C0000020012B09D1054918008A69920F1A4201D18869C00F01231840704700002640072370B5084CA2691A4090420BD0A5699D4303402B43A361002904D0904202D944 +:40140000C82000F01DF970BD00002640F8B50500FFF7BEFF002844D000F09FF9B02306005B05002D15D1E8220120D2009C5CFFF779FFE4B2071E30D1FFF72CFF1F201A49D4 +:401440001A4A8B588343143803438B50FFF74AFF0FE01F20164A14499C5C144AE4B28B588343143803438B50023800F0E9F8FFF749FF1F230C480D491C40425800279A4397 +:4014800014434450012D08D1092000F0D9F8FFF715FF0020FFF746FF0700300000F061F900E0044F3800F8BD000026401CFF00004107000003004200F0B5060085B00D004F +:4014C000204F042901D001291AD100207C68002C35D01D4B984232D02379B3420ED1A368002B01D02B4209D1E36801A85A689B6842608360057023689847BC606469E6E760 +:40150000BC68022902D1002C00D024690020002C15D00D4B984212D02379B3420DD1A368002B01D02B4208D1E36801A85A689B68426083600570236898472469E7E705B0D2 +:40154000F0BDC0462C070008FF004200F0B52B4C85B023680700002B0AD100F0FEF823680190002B10D004210120FFF7A5FF0BE001210800FFF7A0FF0028EED00221012092 +:40158000FFF79AFF1E4C35E0B0256D056B78002B02D06B78212B03D1380000F05DFC1EE0184E194BF3580293E823DB00EB5CDBB20393FFF767FE3100144A00280AD01F234C +:4015C0000298184003000398834203D0104BEB58B35001E000238B50380000F035FC019800F0BFF823680024A34203D008210120FFF762FF200005B0F0BDC0462C070008DF +:40160000FF004200000026401CFF0000307F00001018000010B5E82400F09FF8064B07495A68A4010A4022435A605A68114059605B6800F096F810BD00002640FF00FC0FFE +:4016400010B5034B1B78584300F07EF810BDC046D400000880220020034B12069A649B6C834200DA0148704700002740030046008022054B120198585B68DBB2002B02D056 +:401680008023DB021843704700002640FEE7000002680A4B10B51A6042685A6082689A60C268DA6002691A6142695A6182699A61C269DA61FFF7EAFF10BDC04658040008F5 +:4016C000F0B51922002800D14B32E82403258A429241194E640033595242AB43134333513359164F3B403351154B5C68AC4322435A605A6817405F60002808D000231029B8 +:4017000013D921338B429B415B4201330DE003001D290AD901233A2907D9DB18572904D976338B4240410422131A0F21054A1068884303431360F0BD00002140FFFCFFFF53 +:40174000FC002140000025400230800803D001300238FCD1C046C0467047EFF3108072B6704780F310887047094B042803D11A68104318600BE0C022000692041040902200 +:4017800004499200885004211A688A431A60704710E000E000002140034B8002C0180F23006818407047C04600402440F8B58023FA250C0001271B0218430D4E0004F061D6 +:4017C000AD00326C0A4B01203A4205D1002D0CD0013DFFF735FFF4E7002D06D01A6C10431864DB6A0020238000E00248F8BDC04600003C400400160070B5FA2401260D4BED +:40180000000418400C4D0143E961A4002B6C0A4A0120334205D1002C0AD0013CFFF710FFF4E7002C04D0136C18431064002000E0024870BD0000FF7F00003C40040016006E +:40184000F0B5154B9DB001A90A00180070C870C270C870C270C870C20AAC1A0020002432E0CAE0C0E0CAE0C0E0CAE0C013AD2A004833C1CBC1C2C1CBC1C2C1CBC1C2074807 +:40188000FFF7DAFC21000648FFF7D6FC29000548FFF7D2FC1DB0F0BD441F0010000132408001324000023240F0B585B00090002800D159E1C54F7B689B0301D5FFF7AAFE7E +:4018C000C34CC44DC44BEA58002A06D0013C002C03D00120FFF7B4FEF3E70122BF4C2959114205D0BE49BB484158114200D03DE1EB58B84E002B00D038E1FFF7A1FFB94AE6 +:40190000B94BF2508022009BD2021B781343B74AB350B74AB74BF250B74B5A6801231A4200D025E1B54A116F08220A4008D1B44BB44918681300884202D900F0D9F9431EE1 +:401940002A68002B03D0B0485B03034300E0AF4B13432B607B699F499C4E01275B000DD539000320FFF73CFD73699B0F3B420AD08022B369D2051343B36104E00320A44A09 +:401980008B5803438B502B5940200193019AA14BA14E13432B51FFF753FE0123AA598D4F1A4208D1BB514020FFF74AFE03234020BB51FFF745FEFA27019A984B984E1A4090 +:4019C00016430192FF002E51964A974BD3581022134207D1002F00D1CCE00120013FFFF72FFEF1E7002F00D1C4E008218F4A0120AB580B43AB50FFF7DDFC002802D18C4E72 +:401A0000019B1E438B4B1E4001231E432E511E00894C734BEB58334207D1002C00D1A9E00120013CFFF70CFEF3E7002C00D1A1E00B27C02181484901FFF7DEFE041E05D104 +:401A400002AB991D7D48FFF7B1FE0400013F002F00D136E1002C26D1C02202AB9E1D338852019342E5D131007548FFF79FFE041E19D180233288DB001A4200D081E00B27B4 +:401A8000019380216E48C900FFF7B6FE041E04D131006B48FFF78AFE0400013F002F00D10FE1002C68D0B0256D056B78002B44D06B78212B41D0634FEB5B002B3DD0002CD2 +:401AC00000D000E102AB9E1D31005F48FFF76EFE041E00D0F7E0C021E85B3488084060398C434008594920430140F020EA5BC000EB5BD201024011439B05554A9B0F1140AE +:401B0000DB02194350483180FFF776FE041E00D0D9E031004F48FFF749FE041E00D0D2E0C022EB5B31889B069B0F9B019143194348483180FFF760FE0400002C00D0C2E036 +:401B4000009B454859781D78444B49001943FFF753FE041E04D142494248FFF74DFE04006801FFF76DFDAEE03F4CACE03F4CAAE03F4CA8E03F4CA6E03388019A934200D069 +:401B80007FE731003C48FFF711FE041E00D08AE732883F2310009843009B38499F78DB78012F0ED10222012B04D89FB2D21B92B2019201E017000194702210433080304A29 +:401BC00069E0002B5ED0019401275EE000002640F17E0E0000003C406CF00100A0F00100B4F0010006000001A4F00100A8F0010001000100ACF00100FC003C4000F03D409D +:401C0000C800000800093D00041A0080040A0080C4F0010030000300B0F00100EFFFFEFF20000200000032401040000068F0010028000200FFFFFBFFF07E0E00021E0000F3 +:401C4000031E000016180000071E00007FF5FFFFFFE7FFFF061E0000081E000001100000376800000F1E000001001600030016000200160004001600091E0000C000000822 +:401C80000048E80101201F0001907F2082436F38024332800D4ADA400A6031880C4839433180FFF7A9FD009B0400DB78DF1B03231F40019B9B001F43064BBFB23780EF50AD +:401CC000F1E6054CEFE6200005B0F0BD0024F400091E000064F001000400160002B4714649084900095C49008E4402BC7047C046002243088B4274D303098B425FD3030A1C +:401D00008B4244D3030B8B4228D3030C8B420DD3FF22090212BA030C8B4202D31212090265D0030B8B4219D300E0090AC30B8B4201D3CB03C01A5241830B8B4201D38B03FF +:401D4000C01A5241430B8B4201D34B03C01A5241030B8B4201D30B03C01A5241C30A8B4201D3CB02C01A5241830A8B4201D38B02C01A5241430A8B4201D34B02C01A5241AA +:401D8000030A8B4201D30B02C01A5241CDD2C3098B4201D3CB01C01A524183098B4201D38B01C01A524143098B4201D34B01C01A524103098B4201D30B01C01A5241C308F9 +:401DC0008B4201D3CB00C01A524183088B4201D38B00C01A524143088B4201D34B00C01A5241411A00D20146524110467047FFE701B5002000F006F802BDC0460029F7D0CF +:401E000076E770477047C046002310B59A4203D0CC5CC4540133F9E710BD03008218934202D019700133FAE770470000F8B5C046F8BC08BC9E467047F8B5C046F8BC08BC8F +:401E40009E4670470000000001B40248844601BC604700BF6103000801B40248844601BC604700BF9D020008000000000000000000000000000000000300000001000000D8 +:401E80000100000000000000050360000400000001000000000000000100000006046000080000008C060008B50700100800000001000000020000000200000008080003BB +:401EC000090000000100000000000000030000000909000308000000AC060008950700100A0000000100000004000000040000000A0A000C0B000000010000000000000013 +:401F0000050000000B0B000C10000000CC060008A5070010192001021901020000000000000000000000000000000000000000BA00000000000000000000000000000000C2 +:401F400000001D1D00000000000000000000000066666666000000000000FFFF000000001C1C1C1C1C1C1C1C00000000000000000000000066E6EE66000000000000FFFF13 +:401F8000000000001C1A1A1A1A1A000000000000000000000000000066E66666000000000000FFFF000000001A1A001C00000000000000000000001000000008C000000045 +:401FC000D41F0010C00000089803000078040008C002000000127A0000127A0000093D0000093D0000093D0004000000A00F00000000D007070000000200000003000000B5 +:402000000F0000000000000000000000030000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000008B +:402040000000000019000050A000000002FF0000E9000010C10000100000000080B2C00017D00C4A1368002BFCDA3E220A4B06211A600A4A0A4B1A60A3220A4BD200995093 +:40208000094A9850002099580249486099580029FCDA7047E0002340040126401E1F000008012640000026401C05000010B54378FF2B0DD100F042F9064BDB685A6801232C +:4020C00011681943116011681942FCD100F01EF910BDC04680002340F7B50F00019000F01DF9050003281FD1274B1B69002B19DB002000F01BF9254EB04213D00023244AB8 +:402100001900012000F022F9041E0BD1002000F00DF9204BB04203D09C4203D00134F5E79C4201D11C4E2CE000F008F91B4B1C4A0400D358002B06DA1A4A01211A4800F05F +:402140000DF9002801D0144E0EE03800FFF786FF019B002B07D0144A1369002BFCDB00F0CDF8060000E0114E032D03D0200000F0CDF806E00121002000F0B8F80028F9D157 +:40218000F4E73000FEBDC046C00023400101880038010008F0490200050052001C050000000026401C070008000023400100500070B52B490A682A4B002AFBDA0221DA6889 +:4021C0000A43DA60DA68D2071BD5264D264CD9682A69266889B2360A36060E43FF21120209040A4032439026DA6029691F4A360111403143296121680A40324322602A6930 +:402200002268002204241A495A605A680A6922430A61012801D030BF00E020BF1A68104D002AFBDAEA68D20712D5FF240D4E0F4A3069E9682402090A1040214001430A48CF +:4022400031610668E9683240090C0C40224302600221DA688A43DA6000225A6070BDC046E00023400000214090002140FF00FFFF00ED00E00421134A13690B4313610128B0 +:4022800001D030BF00E020BF0F4A1368002BFCDA0E4B19691A00002910D10D490D4B196006210D4B19600D4B383119600C4B0631196019680029FCDA0A4B13610022024BB3 +:4022C0005A60704700ED00E0E0002340FC0025401E1F00000801264018052640040126401C052640AAAAAAAA0000000001B40248844601BC604700BF4D0C001001B40248DF +:40230000844601BC604700BFA110001001B40248844601BC604700BF6317001001B40248844601BC604700BFE503001001B40248844601BC604700BFC50C001001B40248C9 +:40234000844601BC604700BF5B17001001B40248844601BC604700BFBD0D001001B40248844601BC604700BFA50B001000000000000000000000000000000000000000007C +:40238000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001D +:4023C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DD +:00000001FF \ No newline at end of file diff --git a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_FUTURE_SEQUANA/PinNames.h b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_FUTURE_SEQUANA/PinNames.h index 10a8f6dd41..a3b6d064d8 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_FUTURE_SEQUANA/PinNames.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_FUTURE_SEQUANA/PinNames.h @@ -187,7 +187,7 @@ typedef enum { D2 = P10_6, D3 = P12_6, D4 = P12_7, - D5 = P6_2, + D5 = P5_5, D6 = P6_3, D7 = P7_2, D8 = P7_1, diff --git a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_FUTURE_SEQUANA_M0_PSA/spm_hal_api.c b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_FUTURE_SEQUANA_M0_PSA/spm_hal_api.c index 4d0352cc98..a6f6fff74e 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_FUTURE_SEQUANA_M0_PSA/spm_hal_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/TARGET_FUTURE_SEQUANA_M0_PSA/spm_hal_api.c @@ -32,7 +32,7 @@ void spm_hal_start_nspe(void) { - Cy_SysEnableCM4(CY_CORTEX_M4_APPL_ADDR); + Cy_SysEnableCM4(PSA_NON_SECURE_ROM_START); } void spm_hal_memory_protection_init(void) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/objects.h b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/objects.h index 0ba07af1f7..d7d88e26f8 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/objects.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/objects.h @@ -53,16 +53,8 @@ struct port_s { uint32_t mask; PinDirection direction; PinMode mode; -// __IO uint32_t *reg_in; -// __IO uint32_t *reg_out; }; -// struct analogin_s { -// ADCName adc; -// PinName pin; -// uint32_t channel; -// }; - #if DEVICE_SERIAL #include "cy_scb_uart.h" @@ -107,6 +99,7 @@ struct spi_s { uint32_t div_num; cy_en_divider_types_t div_type; uint32_t clk_frequency; + uint32_t clk_delay; cy_en_scb_spi_mode_t ms_mode; cy_en_scb_spi_sclk_mode_t clk_mode; uint8_t data_bits; diff --git a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/pinmap.c b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/pinmap.c index 23fe537aa7..8f637b70cf 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/pinmap.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/pinmap.c @@ -26,20 +26,21 @@ void pin_function(PinName pin, int function) if (pin != NC) { GPIO_PRT_Type *port = Cy_GPIO_PortToAddr(CY_PORT(pin)); uint32_t mode = gpio_get_cy_drive_mode(CY_PIN_DIRECTION(function), CY_PIN_MODE(function)); + uint32_t state = Cy_GPIO_ReadOut(port, CY_PIN(pin)); - Cy_GPIO_Pin_FastInit(port, CY_PIN(pin), mode, 1, CY_PIN_HSIOM(function)); // Force output to enable pulls. switch (mode) { case CY_GPIO_DM_PULLUP: - Cy_GPIO_Write(port, CY_PIN(pin), 1); + state = 1; break; case CY_GPIO_DM_PULLDOWN: - Cy_GPIO_Write(port, CY_PIN(pin), 0); + state = 0; break; default: /* do nothing */ break; } + Cy_GPIO_Pin_FastInit(port, CY_PIN(pin), mode, state, CY_PIN_HSIOM(function)); } } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/port_api.c b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/port_api.c index 5e124dd5b4..9fce69a494 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/port_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/port_api.c @@ -105,8 +105,8 @@ void port_write(port_t *obj, int value) for (pin = 0; pin < 8; ++pin) { if (obj->mask & (1 << pin)) { Cy_GPIO_Write(obj->port, pin, value & 0x1); - value >>= 1; } + value >>= 1; } } } diff --git a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/spi_api.c b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/spi_api.c index 45f71cc148..9ae3e9ac1f 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/spi_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6_FUTURE/spi_api.c @@ -87,10 +87,10 @@ static IRQn_Type spi_irq_allocate_channel(spi_obj_t *obj) #endif // M0 } -static void spi_irq_release_channel(IRQn_Type channel, uint32_t spi_id) +static void spi_irq_release_channel(spi_obj_t *obj) { #if defined (TARGET_MCU_PSOC6_M0) - cy_m0_nvic_release_channel(channel, CY_SERIAL_IRQN_ID + spi_id); + cy_m0_nvic_release_channel(obj->irqn, CY_SERIAL_IRQN_ID + obj->spi_id); #endif //M0 } @@ -130,6 +130,14 @@ static int allocate_divider(spi_obj_t *obj) return (obj->div_num == CY_INVALID_DIVIDER)? -1 : 0; } +static void free_divider(spi_obj_t *obj) +{ + if (obj->div_num != CY_INVALID_DIVIDER) { + cy_clk_free_divider(obj->div_type, obj->div_num); + obj->div_num = CY_INVALID_DIVIDER; + } +} + /* * Initializes spi clock for the required speed @@ -149,6 +157,8 @@ static cy_en_sysclk_status_t spi_init_clock(spi_obj_t *obj, uint32_t frequency) // Set up proper frequency; round up the divider so the frequency is not higher than specified. div_value = (CY_CLK_PERICLK_FREQ_HZ + frequency *(SPI_OVERSAMPLE - 1)) / frequency / SPI_OVERSAMPLE; obj->clk_frequency = CY_CLK_PERICLK_FREQ_HZ / div_value / SPI_OVERSAMPLE; + // Delay (in us) required for serialized read operation == 1.5 clocks, min 1us. + obj->clk_delay = (1500000UL - 1 + obj->clk_frequency) / obj->clk_frequency; Cy_SysClk_PeriphDisableDivider(obj->div_type, obj->div_num); if (Cy_SysClk_PeriphSetDivider(obj->div_type, obj->div_num, div_value) != CY_SYSCLK_SUCCESS) { obj->div_num = CY_INVALID_DIVIDER; @@ -166,40 +176,20 @@ static cy_en_sysclk_status_t spi_init_clock(spi_obj_t *obj, uint32_t frequency) } /* - * Initializes i/o pins for spi. + * Sets up i/o connections for spi. */ -static void spi_init_pins(spi_obj_t *obj) +static void spi_set_pins(spi_obj_t *obj) { - bool conflict = false; - conflict = cy_reserve_io_pin(obj->pin_sclk); - if (!conflict) { - pin_function(obj->pin_sclk, pinmap_function(obj->pin_sclk, PinMap_SPI_SCLK)); - } if (obj->pin_mosi != NC) { - if (!cy_reserve_io_pin(obj->pin_mosi)) { - pin_function(obj->pin_mosi, pinmap_function(obj->pin_mosi, PinMap_SPI_MOSI)); - } else { - conflict = true; - } + pin_function(obj->pin_mosi, pinmap_function(obj->pin_mosi, PinMap_SPI_MOSI)); } if (obj->pin_miso != NC) { - if (!cy_reserve_io_pin(obj->pin_miso)) { - pin_function(obj->pin_miso, pinmap_function(obj->pin_miso, PinMap_SPI_MISO)); - } else { - conflict = true; - } + pin_function(obj->pin_miso, pinmap_function(obj->pin_miso, PinMap_SPI_MISO)); } if (obj->pin_ssel != NC) { - if (!cy_reserve_io_pin(obj->pin_ssel)) { - pin_function(obj->pin_ssel, pinmap_function(obj->pin_ssel, PinMap_SPI_SSEL)); - } else { - conflict = true; - } + pin_function(obj->pin_ssel, pinmap_function(obj->pin_ssel, PinMap_SPI_SSEL)); } - if (conflict) { - error("SPI pin reservation conflict."); - } - + pin_function(obj->pin_sclk, pinmap_function(obj->pin_sclk, PinMap_SPI_SCLK)); // Pin configuration in PinMap defaults to Master mode; revert for Slave. if (obj->ms_mode == CY_SCB_SPI_SLAVE) { pin_mode(obj->pin_sclk, PullNone); @@ -209,6 +199,55 @@ static void spi_init_pins(spi_obj_t *obj) } } +/* + * Sets i/o output pins into safe mode while re-configuring peripheral. + */ +static void spi_default_pins(spi_obj_t *obj) +{ + + if (obj->ms_mode == CY_SCB_SPI_MASTER) { + pin_function(obj->pin_sclk, CY_PIN_FUNCTION(HSIOM_SEL_GPIO, 0, PullDown, PIN_OUTPUT)); + if (obj->pin_mosi != NC) { + pin_function(obj->pin_mosi, CY_PIN_FUNCTION(HSIOM_SEL_GPIO, 0, PullUp, PIN_OUTPUT)); + } + if (obj->pin_ssel != NC) { + pin_function(obj->pin_ssel, CY_PIN_FUNCTION(HSIOM_SEL_GPIO, 0, PullUp, PIN_OUTPUT)); + } + } else { + if (obj->pin_miso != NC) { + pin_function(obj->pin_miso, CY_PIN_FUNCTION(HSIOM_SEL_GPIO, 0, PullUp, PIN_OUTPUT)); + } + } +} + +/* + * Initializes i/o pins for spi. + */ +static void spi_init_pins(spi_obj_t *obj) +{ + bool conflict = false; + conflict = cy_reserve_io_pin(obj->pin_sclk); + if (obj->pin_mosi != NC) { + if (cy_reserve_io_pin(obj->pin_mosi)) { + conflict = true; + } + } + if (obj->pin_miso != NC) { + if (cy_reserve_io_pin(obj->pin_miso)) { + conflict = true; + } + } + if (obj->pin_ssel != NC) { + if (cy_reserve_io_pin(obj->pin_ssel)) { + conflict = true; + } + } + if (conflict) { + error("SPI pin reservation conflict."); + } + spi_set_pins(obj); +} + /* * Initializes and enables SPI/SCB. */ @@ -282,8 +321,8 @@ void spi_init(spi_t *obj_in, PinName mosi, PinName miso, PinName sclk, PinName s obj->rx_buffer_size = 0; #endif // DEVICE_SPI_ASYNCH spi_init_clock(obj, SPI_DEFAULT_SPEED); - spi_init_pins(obj); spi_init_peripheral(obj); + spi_init_pins(obj); #if DEVICE_SLEEP && DEVICE_LOWPOWERTIMER obj->pm_callback_handler.callback = spi_pm_callback; obj->pm_callback_handler.type = CY_SYSPM_DEEPSLEEP; @@ -300,27 +339,73 @@ void spi_init(spi_t *obj_in, PinName mosi, PinName miso, PinName sclk, PinName s } } + +void spi_free(spi_t *obj_in) +{ + spi_obj_t *obj = OBJ_P(obj_in); + + spi_default_pins(obj); + Cy_SCB_SPI_Disable(obj->base, &obj->context); + Cy_SCB_SPI_DeInit (obj->base); + +#if DEVICE_SLEEP && DEVICE_LOWPOWERTIMER + Cy_SysPm_UnregisterCallback(&obj->pm_callback_handler); +#endif // DEVICE_SLEEP && DEVICE_LOWPOWERTIMER + +#if DEVICE_SPI_ASYNCH + if (obj->irqn != unconnected_IRQn) { + NVIC_DisableIRQ(obj->irqn); + spi_irq_release_channel(obj); + + obj->irqn = unconnected_IRQn; + } +#endif // DEVICE_SPI_ASYNCH + + if (obj->pin_sclk != NC) { + cy_free_io_pin(obj->pin_sclk); + obj->pin_sclk = NC; + } + if (obj->pin_mosi != NC) { + cy_free_io_pin(obj->pin_mosi); + obj->pin_mosi = NC; + } + if (obj->pin_miso != NC) { + cy_free_io_pin(obj->pin_miso); + obj->pin_miso = NC; + } + if (obj->pin_ssel != NC) { + cy_free_io_pin(obj->pin_ssel); + obj->pin_ssel = NC; + } + + free_divider(obj); +} + + void spi_format(spi_t *obj_in, int bits, int mode, int slave) { spi_obj_t *obj = OBJ_P(obj_in); cy_en_scb_spi_mode_t new_mode = slave? CY_SCB_SPI_SLAVE : CY_SCB_SPI_MASTER; if ((bits < 4) || (bits > 16)) return; + spi_default_pins(obj); Cy_SCB_SPI_Disable(obj->base, &obj->context); obj->data_bits = bits; obj->clk_mode = (cy_en_scb_spi_sclk_mode_t)(mode & 0x3); if (obj->ms_mode != new_mode) { obj->ms_mode = new_mode; - spi_init_pins(obj); } spi_init_peripheral(obj); + spi_set_pins(obj); } void spi_frequency(spi_t *obj_in, int hz) { spi_obj_t *obj = OBJ_P(obj_in); + spi_default_pins(obj); Cy_SCB_SPI_Disable(obj->base, &obj->context); spi_init_clock(obj, hz); Cy_SCB_SPI_Enable(obj->base); + spi_set_pins(obj); } int spi_master_write(spi_t *obj_in, int value) @@ -335,6 +420,10 @@ int spi_master_write(spi_t *obj_in, int value) while (!Cy_SCB_SPI_IsTxComplete(obj->base)) { // wait for the transmission to complete } + // Wait until RX FIFO is filled from the serial register. + while (Cy_SCB_SPI_GetNumInRxFifo(obj->base) == 0) { + /* busy loop */ + } return Cy_SCB_SPI_Read(obj->base); } else { return (int)CY_SCB_SPI_RX_NO_DATA; @@ -387,6 +476,9 @@ int spi_master_block_write(spi_t *obj_in, const char *tx_buffer, int tx_length, ++rx_count; } } + // Delay at least 1.5 clock cycle, so that FIFO is filled with the last char + // and SCLK returns to idle state. + Cy_SysLib_DelayUs(obj->clk_delay); // Read any remaining bytes from the fifo. while (rx_count < rx_length) { *rx_buffer++ = (char)Cy_SCB_SPI_Read(obj->base); diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/MK64FN1M0xxx12.sct b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/MK64FN1M0xxx12.sct index 72a6efafe2..76653b8e6f 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/MK64FN1M0xxx12.sct +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/MK64FN1M0xxx12.sct @@ -126,11 +126,13 @@ LR_IROM1 m_interrupts_start m_text_start+m_text_size-m_interrupts_start { ; lo RW_m_data m_data_start m_data_size { ; RW data .ANY (+RW +ZI) } - RW_m_data_2 m_data_2_start m_data_2_size-Stack_Size-Heap_Size { ; RW data + RW_m_data_2 m_data_2_start m_data_2_size { ; RW data .ANY (+RW +ZI) } RW_IRAM1 ImageLimit(RW_m_data_2) { ; Heap region growing up } + ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (m_data_2_start + m_data_2_size - Stack_Size - AlignExpr(ImageLimit(RW_IRAM1), 16)) { + } ARM_LIB_STACK m_data_2_start+m_data_2_size EMPTY -Stack_Size { ; Stack region growing down } } diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/sys.cpp b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/sys.cpp new file mode 100644 index 0000000000..604ba18369 --- /dev/null +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/sys.cpp @@ -0,0 +1,86 @@ + /* + * Copyright (c) 2019-2019 ARM Limited. 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 + * + * 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. + * + * Setup a fixed single stack/heap memory model, + * between the top of the RW/ZI region and the stackpointer + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) +#include +#endif + +#include +#include + +extern char Image$$ARM_LIB_STACK$$ZI$$Limit[]; +extern char Image$$ARM_LIB_HEAP$$Base[]; +extern char Image$$ARM_LIB_HEAP$$ZI$$Limit[]; +extern __value_in_regs struct __initial_stackheap _mbed_user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) { + + struct __initial_stackheap r; + r.heap_base = (uint32_t)Image$$ARM_LIB_HEAP$$Base; + r.heap_limit = (uint32_t)Image$$ARM_LIB_HEAP$$ZI$$Limit; + return r; +} + +#if !defined(MBED_CONF_RTOS_PRESENT) || !MBED_CONF_RTOS_PRESENT + +/* The single region memory model would check stack collision at run time, verifying that + * the heap pointer is underneath the stack pointer. With two-region memory model/RTOS-less or + * multiple threads(stacks)/RTOS, the check gets meaningless and we must disable it. */ +#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) +__asm(".global __use_two_region_memory\n\t"); +__asm(".global __use_no_semihosting\n\t"); +#else +#pragma import(__use_two_region_memory) +#endif + +/* Fix __user_setup_stackheap and ARM_LIB_STACK/ARM_LIB_HEAP cannot co-exist in RTOS-less build + * + * According AN241 (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0241b/index.html), + * __rt_entry has the following call sequence: + * 1. _platform_pre_stackheap_init + * 2. __user_setup_stackheap or setup the Stack Pointer (SP) by another method + * 3. _platform_post_stackheap_init + * 4. __rt_lib_init + * 5. _platform_post_lib_init + * 6. main() + * 7. exit() + * + * Per our check, when __user_setup_stackheap and ARM_LIB_STACK/ARM_LIB_HEAP co-exist, neither + * does __user_setup_stackheap get called and nor is ARM_LIB_HEAP used to get heap base/limit, + * which are required to pass to __rt_lib_init later. To fix the issue, by subclass'ing + * __rt_lib_init, heap base/limit are replaced with Image$$ARM_LIB_HEAP$$ZI$$Base/Limit if + * ARM_LIB_HEAP region is defined in scatter file. + * + * The overriding __rt_lib_init is needed only for rtos-less code. For rtos code, __rt_entry is + * overridden and the overriding __rt_lib_init here gets meaningless. + */ +extern __value_in_regs struct __argc_argv $Super$$__rt_lib_init(unsigned heapbase, unsigned heaptop); + +__value_in_regs struct __argc_argv $Sub$$__rt_lib_init (unsigned heapbase, unsigned heaptop) +{ + return $Super$$__rt_lib_init((unsigned) Image$$ARM_LIB_HEAP$$Base, (unsigned) Image$$ARM_LIB_HEAP$$ZI$$Limit); +} + +#endif + +#ifdef __cplusplus +} +#endif diff --git a/targets/TARGET_Freescale/mbed_rtx.h b/targets/TARGET_Freescale/mbed_rtx.h index 507c042e2e..172dce07a6 100644 --- a/targets/TARGET_Freescale/mbed_rtx.h +++ b/targets/TARGET_Freescale/mbed_rtx.h @@ -17,6 +17,8 @@ #ifndef MBED_MBED_RTX_H #define MBED_MBED_RTX_H +#include + #if defined(TARGET_K20D50M) #ifndef INITIAL_SP @@ -87,6 +89,16 @@ #ifndef INITIAL_SP #define INITIAL_SP (0x20030000UL) +#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) +extern uint32_t Image$$ARM_LIB_HEAP$$ZI$$Base[]; +extern uint32_t Image$$ARM_LIB_HEAP$$ZI$$Length[]; +extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Base[]; +extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Length[]; +#define HEAP_START ((unsigned char*) Image$$ARM_LIB_HEAP$$ZI$$Base) +#define HEAP_SIZE ((uint32_t) Image$$ARM_LIB_HEAP$$ZI$$Length) +#define ISR_STACK_START ((unsigned char*)Image$$ARM_LIB_STACK$$ZI$$Base) +#define ISR_STACK_SIZE ((uint32_t)Image$$ARM_LIB_STACK$$ZI$$Length) +#endif #endif #elif defined(TARGET_SDT64B) diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/README.md b/targets/TARGET_NORDIC/TARGET_NRF5x/README.md index bea26442f8..7e093ea90e 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/README.md +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/README.md @@ -153,6 +153,16 @@ The assert handler is defined in mbed-os/features/FEATURE_BLE/targets/TARGET_NOR * It is not possible to do an asynchronous write from flash and receive non-asynchronously at the same time since the non-asynchronous receive buffer is being used as the temporary transmission buffer. * The driver will flush the DMA buffer after a configurable timeout. During this process the UART will be halted and therefor unable to receive data. Hardware flow control should be enabled to avoid missing any data during this window. +#### Serial Wire Output (SWO) + +On the nRF52832 pin 18 (p18 or p0_18) is the SWO pin and a GPIO pin. On the nRF52_DK and DELTA_DFBM_NQ620 targets p18 is also mapped to LED2, so the ITM has been removed from these targets to avoid contention. If you need SWO capability instead of LED2, add the ITM through ```mbed_app.json```: +``` + "target_overrides": { + "*": { + "target.device_has_add": ["ITM"] + } + } +``` ## SoftDevice diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.c b/targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.cpp similarity index 76% rename from targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.c rename to targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.cpp index 57c960924b..eed2603836 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.c +++ b/targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.cpp @@ -23,29 +23,43 @@ #include "nu_modutil.h" #include "nu_bitutil.h" #include "crypto-misc.h" +#include "platform/SingletonPtr.h" +#include "platform/PlatformMutex.h" #if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT) -/* NOTE: There's inconsistency in cryptography related naming, Crpt or Crypto. For example, cryptography IRQ - * handler could be CRPT_IRQHandler or CRYPTO_IRQHandler. To override default cryptography IRQ handler, see - * device/startup_{CHIP}.c for its name or call NVIC_SetVector regardless of its name. */ -void CRPT_IRQHandler(); +/* Consideration for choosing proper synchronization mechanism + * + * 1. We choose mutex to synchronize access to crypto non-SHA AC. We can guarantee: + * (1) No deadlock + * We just lock mutex for a short sequence of operations rather than the whole lifetime + * of crypto context. + * (2) No priority inversion + * Mutex supports priority inheritance and it is enabled. + * 2. We choose atomic flag to synchronize access to crypto SHA AC. We can guarantee: + * (1) No deadlock + * With SHA AC not supporting context save & restore, we provide SHA S/W fallback when + * SHA AC is not available. + * (2) No biting CPU + * Same reason as above. + */ + +/* Mutex for crypto AES AC management */ +static SingletonPtr crypto_aes_mutex; + +/* Mutex for crypto DES AC management */ +static SingletonPtr crypto_des_mutex; + +/* Mutex for crypto ECC AC management */ +static SingletonPtr crypto_ecc_mutex; + +/* Atomic flag for crypto SHA AC management */ +static core_util_atomic_flag crypto_sha_atomic_flag = CORE_UTIL_ATOMIC_FLAG_INIT; -/* Track if AES H/W is available */ -static uint16_t crypto_aes_avail = 1; -/* Track if DES H/W is available */ -static uint16_t crypto_des_avail = 1; -/* Track if SHA H/W is available */ -static uint16_t crypto_sha_avail = 1; -/* Track if ECC H/W is available */ -static uint16_t crypto_ecc_avail = 1; /* Crypto (AES, DES, SHA, etc.) init counter. Crypto's keeps active as it is non-zero. */ static uint16_t crypto_init_counter = 0U; -static bool crypto_submodule_acquire(uint16_t *submodule_avail); -static void crypto_submodule_release(uint16_t *submodule_avail); - /* Crypto done flags */ #define CRYPTO_DONE_OK BIT0 /* Done with OK */ #define CRYPTO_DONE_ERR BIT1 /* Done with error */ @@ -81,8 +95,7 @@ void crypto_init(void) * NOTE: We must call secure version (from non-secure domain) because SYS/CLK regions are secure. */ CLK_EnableModuleClock_S(CRPT_MODULE); - - NVIC_SetVector(CRPT_IRQn, (uint32_t) CRPT_IRQHandler); + NVIC_EnableIRQ(CRPT_IRQn); } core_util_critical_section_exit(); @@ -131,44 +144,52 @@ void crypto_zeroize32(uint32_t *v, size_t n) } } -bool crypto_aes_acquire(void) +void crypto_aes_acquire(void) { - return crypto_submodule_acquire(&crypto_aes_avail); + /* Don't check return code of Mutex::lock(void) + * + * This function treats RTOS errors as fatal system errors, so it can only return osOK. + * Use of the return value is deprecated, as the return is expected to become void in + * the future. + */ + crypto_aes_mutex->lock(); } void crypto_aes_release(void) { - crypto_submodule_release(&crypto_aes_avail); + crypto_aes_mutex->unlock(); } -bool crypto_des_acquire(void) +void crypto_des_acquire(void) { - return crypto_submodule_acquire(&crypto_des_avail); + /* Don't check return code of Mutex::lock(void) */ + crypto_des_mutex->lock(); } void crypto_des_release(void) { - crypto_submodule_release(&crypto_des_avail); + crypto_des_mutex->unlock(); } -bool crypto_sha_acquire(void) +void crypto_ecc_acquire(void) { - return crypto_submodule_acquire(&crypto_sha_avail); -} - -void crypto_sha_release(void) -{ - crypto_submodule_release(&crypto_sha_avail); -} - -bool crypto_ecc_acquire(void) -{ - return crypto_submodule_acquire(&crypto_ecc_avail); + /* Don't check return code of Mutex::lock(void) */ + crypto_ecc_mutex->lock(); } void crypto_ecc_release(void) { - crypto_submodule_release(&crypto_ecc_avail); + crypto_ecc_mutex->unlock(); +} + +bool crypto_sha_try_acquire(void) +{ + return !core_util_atomic_flag_test_and_set(&crypto_sha_atomic_flag); +} + +void crypto_sha_release(void) +{ + core_util_atomic_flag_clear(&crypto_sha_atomic_flag); } void crypto_prng_prestart(void) @@ -252,18 +273,6 @@ bool crypto_dma_buffs_overlap(const void *in_buff, size_t in_buff_size, const vo return overlap; } -static bool crypto_submodule_acquire(uint16_t *submodule_avail) -{ - uint16_t expectedCurrentValue = 1; - return core_util_atomic_cas_u16(submodule_avail, &expectedCurrentValue, 0); -} - -static void crypto_submodule_release(uint16_t *submodule_avail) -{ - uint16_t expectedCurrentValue = 0; - while (! core_util_atomic_cas_u16(submodule_avail, &expectedCurrentValue, 1)); -} - static void crypto_submodule_prestart(volatile uint16_t *submodule_done) { *submodule_done = 0; @@ -296,8 +305,13 @@ static bool crypto_submodule_wait(volatile uint16_t *submodule_done) return false; } -/* Crypto interrupt handler */ -void CRPT_IRQHandler() +/* Crypto interrupt handler + * + * There's inconsistency in cryptography related naming, Crpt or Crypto. For example, + * cryptography IRQ handler could be CRPT_IRQHandler or CRYPTO_IRQHandler. To override + * default cryptography IRQ handler, see device/startup_{CHIP}.c for its correct name + * or call NVIC_SetVector() in crypto_init() regardless of its name. */ +extern "C" void CRPT_IRQHandler() { uint32_t intsts; diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.h b/targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.h index c675cd76e3..a29e790c17 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.h +++ b/targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.h @@ -66,26 +66,33 @@ void crypto_uninit(void); void crypto_zeroize(void *v, size_t n); void crypto_zeroize32(uint32_t *v, size_t n); -/* Acquire/release ownership of AES H/W */ -/* NOTE: If "acquire" succeeds, "release" must be done to pair it. */ -bool crypto_aes_acquire(void); +/* Acquire/release ownership of crypto sub-module + * + * \note "acquire" is blocking until ownership is acquired + * + * \note "acquire"/"release" must be paired. + * + * \note Recursive "acquire" is allowed because the underlying synchronization + * primitive mutex supports it. + */ +void crypto_aes_acquire(void); void crypto_aes_release(void); - -/* Acquire/release ownership of DES H/W */ -/* NOTE: If "acquire" succeeds, "release" must be done to pair it. */ -bool crypto_des_acquire(void); +void crypto_des_acquire(void); void crypto_des_release(void); - -/* Acquire/release ownership of SHA H/W */ -/* NOTE: If "acquire" succeeds, "release" must be done to pair it. */ -bool crypto_sha_acquire(void); -void crypto_sha_release(void); - -/* Acquire/release ownership of ECC H/W */ -/* NOTE: If "acquire" succeeds, "release" must be done to pair it. */ -bool crypto_ecc_acquire(void); +void crypto_ecc_acquire(void); void crypto_ecc_release(void); +/* Acquire/release ownership of crypto sub-module + * + * \return false if crytpo sub-module is held by another thread or + * another mbedtls context. + * true if successful + * + * \note Successful "try_acquire" and "release" must be paired. + */ +bool crypto_sha_try_acquire(void); +void crypto_sha_release(void); + /* Flow control between crypto/xxx start and crypto/xxx ISR * * crypto_xxx_prestart/crypto_xxx_wait encapsulate control flow between crypto/xxx start and crypto/xxx ISR. diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.cpp b/targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.cpp index 13000985af..18f517a844 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.cpp +++ b/targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.cpp @@ -19,10 +19,6 @@ #include "mbed_assert.h" #include "mbed_critical.h" #include "mbed_error.h" -#if MBED_CONF_RTOS_PRESENT -#include "cmsis_os2.h" -#endif -#include #include #include "nu_modutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.cpp b/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.cpp index f771a3e510..e4fd9143c3 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.cpp +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.cpp @@ -19,10 +19,6 @@ #include "mbed_assert.h" #include "mbed_critical.h" #include "mbed_error.h" -#if MBED_CONF_RTOS_PRESENT -#include "cmsis_os2.h" -#endif -#include #include #include "nu_modutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_RDA/TARGET_UNO_91H/device/RDA5991H.h b/targets/TARGET_RDA/TARGET_UNO_91H/device/RDA5991H.h index 5427afc6a2..288faada83 100644 --- a/targets/TARGET_RDA/TARGET_UNO_91H/device/RDA5991H.h +++ b/targets/TARGET_RDA/TARGET_UNO_91H/device/RDA5991H.h @@ -1,27 +1,17 @@ -/****************************************************************************** - * @file RDA5991H.h - * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File for - * RDA RDA5991H Device Series - * @version: V1.09 - * @date: 07. June 2018 +/* Copyright (c) 2019 Unisoc Communications Inc. * - * @note - * Copyright (C) 2009 ARM Limited. All rights reserved. + * 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 * - * @par - * ARM Limited (ARM) is supplying this software for use with Cortex-M - * processor based microcontrollers. This file can be freely distributed - * within development tools that are supporting such ARM based processors. + * http://www.apache.org/licenses/LICENSE-2.0 * - * @par - * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED - * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. - * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR - * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. - * - ******************************************************************************/ - + * 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. + */ #ifndef __RDA5991H_H__ #define __RDA5991H_H__ diff --git a/targets/TARGET_RDA/TARGET_UNO_91H/trng_api.c b/targets/TARGET_RDA/TARGET_UNO_91H/trng_api.c index 810531b86b..295db4a6bf 100644 --- a/targets/TARGET_RDA/TARGET_UNO_91H/trng_api.c +++ b/targets/TARGET_RDA/TARGET_UNO_91H/trng_api.c @@ -118,4 +118,14 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l return ret; } +int rda_trng_get_bytes(unsigned char *output, size_t len) +{ + size_t temp; + trng_t trng_obj; + trng_init(&trng_obj); + int ret = trng_get_bytes(&trng_obj, output, len, &temp); + trng_free(&trng_obj); + return ret; +} + #endif diff --git a/targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_conf.h b/targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_conf.h index 55aad36197..3bfc9a065b 100644 --- a/targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_conf.h +++ b/targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_conf.h @@ -164,8 +164,14 @@ extern "C" { /* 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 */ + +#ifdef MBED_CONF_STM32_EMAC_ETH_RXBUFNB +#define ETH_RXBUFNB MBED_CONF_STM32_EMAC_ETH_RXBUFNB /* Rx buffers of size ETH_RX_BUF_SIZE */ +#endif + +#ifdef MBED_CONF_STM32_EMAC_ETH_TXBUFNB +#define ETH_TXBUFNB MBED_CONF_STM32_EMAC_ETH_TXBUFNB /* Tx buffers of size ETH_TX_BUF_SIZE */ +#endif /* Section 2: PHY configuration section */ diff --git a/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_conf.h b/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_conf.h index 23c209ca62..2ca8e308ee 100644 --- a/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_conf.h +++ b/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_conf.h @@ -175,8 +175,14 @@ /* 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 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +#ifdef MBED_CONF_STM32_EMAC_ETH_RXBUFNB +#define ETH_RXBUFNB MBED_CONF_STM32_EMAC_ETH_RXBUFNB /* Rx buffers of size ETH_RX_BUF_SIZE */ +#endif + +#ifdef MBED_CONF_STM32_EMAC_ETH_TXBUFNB +#define ETH_TXBUFNB MBED_CONF_STM32_EMAC_ETH_TXBUFNB /* Tx buffers of size ETH_TX_BUF_SIZE */ +#endif /* Section 2: PHY configuration section */ diff --git a/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_conf.h b/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_conf.h index 44179a7e50..5d7d9caec6 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_conf.h +++ b/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_conf.h @@ -183,8 +183,14 @@ /* 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 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +#ifdef MBED_CONF_STM32_EMAC_ETH_RXBUFNB +#define ETH_RXBUFNB MBED_CONF_STM32_EMAC_ETH_RXBUFNB /* Rx buffers of size ETH_RX_BUF_SIZE */ +#endif + +#ifdef MBED_CONF_STM32_EMAC_ETH_TXBUFNB +#define ETH_TXBUFNB MBED_CONF_STM32_EMAC_ETH_TXBUFNB /* Tx buffers of size ETH_TX_BUF_SIZE */ +#endif /* Section 2: PHY configuration section */ diff --git a/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_conf.h b/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_conf.h index f484b45c73..c3c9080c3f 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_conf.h +++ b/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_conf.h @@ -189,9 +189,14 @@ /* 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 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ +#ifdef MBED_CONF_STM32_EMAC_ETH_RXBUFNB +#define ETH_RXBUFNB MBED_CONF_STM32_EMAC_ETH_RXBUFNB /* Rx buffers of size ETH_RX_BUF_SIZE */ +#endif + +#ifdef MBED_CONF_STM32_EMAC_ETH_TXBUFNB +#define ETH_TXBUFNB MBED_CONF_STM32_EMAC_ETH_TXBUFNB /* Tx buffers of size ETH_TX_BUF_SIZE */ +#endif /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/PeripheralNames.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/PeripheralNames.h new file mode 100644 index 0000000000..1985df72fd --- /dev/null +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/PeripheralNames.h @@ -0,0 +1,96 @@ +/* mbed Microcontroller Library + +* SPDX-License-Identifier: BSD-3-Clause + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * 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. 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 MBED_PERIPHERALNAMES_H +#define MBED_PERIPHERALNAMES_H + +#include "cmsis.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + ADC_1 = (int)ADC1_BASE, + ADC_2 = (int)ADC2_BASE, + ADC_3 = (int)ADC3_BASE +} ADCName; + +typedef enum { + DAC_1 = (int)DAC_BASE +} DACName; + +typedef enum { + UART_1 = (int)USART1_BASE, + UART_2 = (int)USART2_BASE, + UART_3 = (int)USART3_BASE, + UART_4 = (int)UART4_BASE, + UART_5 = (int)UART5_BASE, + LPUART_1 = (int)LPUART1_BASE +} UARTName; + +typedef enum { + SPI_1 = (int)SPI1_BASE, + SPI_2 = (int)SPI2_BASE, + SPI_3 = (int)SPI3_BASE +} SPIName; + +typedef enum { + I2C_1 = (int)I2C1_BASE, + I2C_2 = (int)I2C2_BASE, + I2C_3 = (int)I2C3_BASE +} I2CName; + +typedef enum { + PWM_1 = (int)TIM1_BASE, + PWM_2 = (int)TIM2_BASE, + PWM_3 = (int)TIM3_BASE, + PWM_4 = (int)TIM4_BASE, + PWM_5 = (int)TIM5_BASE, + PWM_8 = (int)TIM8_BASE, + PWM_15 = (int)TIM15_BASE, + PWM_16 = (int)TIM16_BASE, + PWM_17 = (int)TIM17_BASE +} PWMName; + +typedef enum { + CAN_1 = (int)CAN1_BASE +} CANName; + +typedef enum { + QSPI_1 = (int)QSPI_R_BASE, +} QSPIName; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/PeripheralPins.c b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/PeripheralPins.c new file mode 100644 index 0000000000..0b79f9eed3 --- /dev/null +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/PeripheralPins.c @@ -0,0 +1,370 @@ +/* mbed Microcontroller Library + +* SPDX-License-Identifier: BSD-3-Clause + ******************************************************************************* + * Copyright (c) 2018, STMicroelectronics + * 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. 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. + ******************************************************************************* + */ + +#include "PeripheralPins.h" +#include "mbed_toolchain.h" + +//============================================================================== +// Notes +// +// - The pins mentioned Px_y_ALTz are alternative possibilities which use other +// HW peripheral instances. You can use them the same way as any other "normal" +// pin (i.e. PwmOut pwm(PA_7_ALT0);). These pins are not displayed on the board +// pinout image on mbed.org. +// +// - The pins which are connected to other components present on the board have +// the comment "Connected to xxx". The pin function may not work properly in this +// case. These pins may not be displayed on the board pinout image on mbed.org. +// Please read the board reference manual and schematic for more information. +// +// - Warning: pins connected to the default STDIO_UART_TX and STDIO_UART_RX pins are commented +// See https://os.mbed.com/teams/ST/wiki/STDIO for more information. +// +//============================================================================== + + +//*** ADC *** + +MBED_WEAK const PinMap PinMap_ADC[] = { + {PA_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + {PA_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + {PA_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + {PA_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + {PA_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + {PA_2_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + {PA_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + {PA_3_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + {PA_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + {PA_4_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + {PA_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + {PA_5_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + {PA_6, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + {PA_6_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + {PA_7, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + {PA_7_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + {PB_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + {PB_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + {PB_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 16, 0)}, // ADC1_IN16 + {PB_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 16, 0)}, // ADC2_IN16 + {PC_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + {PC_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + {PC_0_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + {PC_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + {PC_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + {PC_1_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + {PC_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + {PC_2_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + {PC_2_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + {PC_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + {PC_3_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + {PC_3_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 + {PC_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + {PC_4_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + {PC_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + {PC_5_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_ADC_Internal[] = { + {ADC_TEMP, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 17, 0)}, + {ADC_VREF, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 0, 0)}, + {ADC_VBAT, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 18, 0)}, + {NC, NC, 0} +}; + +//*** DAC *** + +MBED_WEAK const PinMap PinMap_DAC[] = { + {PA_4, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC1_OUT1 // + {PA_5, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_OUT2 // + {NC, NC, 0} +}; + +//*** I2C *** + +MBED_WEAK const PinMap PinMap_I2C_SDA[] = { + {PB_7, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_11, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PB_14, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PC_1, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_I2C_SCL[] = { + {PB_6, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_10, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PB_13, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PC_0, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {NC, NC, 0} +}; + +//*** PWM *** + +// TIM5 cannot be used because already used by the us_ticker +MBED_WEAK const PinMap PinMap_PWM[] = { + {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 +// {PA_0, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 +// {PA_1, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + {PA_1_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 1)}, // TIM15_CH1N + {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 +// {PA_2, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + {PA_2_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 0)}, // TIM15_CH1 + {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 +// {PA_3, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + {PA_3_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 2, 0)}, // TIM15_CH2 + {PA_5, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_5_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + {PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PA_6_ALT0, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 0)}, // TIM16_CH1 + {PA_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PA_7_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PA_7_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + {PA_7_ALT2, PWM_17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM17, 1, 0)}, // TIM17_CH1 + {PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PB_0, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PB_0_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PB_0_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + {PB_1, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PB_1_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PB_1_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 +// {PB_6, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 +// {PB_6, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 1)}, // TIM16_CH1N +// {PB_7, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 +// {PB_7, PWM_17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM17, 1, 1)}, // TIM17_CH1N + {PB_8, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PB_8_ALT0, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 0)}, // TIM16_CH1 + {PB_9, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9_ALT0, PWM_17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM17, 1, 0)}, // TIM17_CH1 + {PB_10, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PB_11, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PB_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PB_13_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 1)}, // TIM15_CH1N + {PB_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PB_14_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + {PB_14_ALT1, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 0)}, // TIM15_CH1 + {PB_15, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PB_15_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {PB_15_ALT1, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 2, 0)}, // TIM15_CH2 + {PC_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PC_6_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + {PC_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PC_7_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + {PC_8, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PC_8_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 + {PC_9, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PC_9_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + {PD_12, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PD_13, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PD_14, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PD_15, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PE_0, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 0)}, // TIM16_CH1 + {PE_1, PWM_17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM17, 1, 0)}, // TIM17_CH1 + {PE_3, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PE_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PE_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PE_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PE_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PE_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PE_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PE_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PE_12, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PE_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PE_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {NC, NC, 0} +}; + +//*** SERIAL *** + +MBED_WEAK const PinMap PinMap_UART_TX[] = { + {PA_0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PB_11, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, + {PC_1, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, + {PC_4, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PC_10_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_12, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {PD_5, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PD_8, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_UART_RX[] = { + {PA_1, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PA_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_7, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_10, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, + {PB_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PC_0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, + {PC_5, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PC_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PC_11_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PD_2, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {PD_6, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PD_9, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_UART_RTS[] = { + {PA_1, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_12, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_15, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PB_1, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PB_3, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_4, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {PB_12, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, + {PB_14, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PD_2, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PD_4, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PD_12, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_UART_CTS[] = { + {PA_0, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_6, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PA_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_4, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_5, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {PB_7, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PB_13, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PB_13_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, + {PD_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PD_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NC, 0} +}; + +//*** SPI *** + +MBED_WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_5_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, + {PB_15, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PC_3, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PC_12, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, + {PD_4, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PE_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_4_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, + {PB_14, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PC_2, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PC_11, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, + {PD_3, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PE_14, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_3_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, + {PB_10, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PB_13, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PC_10, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, + {PD_1, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PE_13, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PA_4_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, + {PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PA_15_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, + {PB_9, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PD_0, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PE_12, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {NC, NC, 0} +}; + +//*** CAN *** + +MBED_WEAK const PinMap PinMap_CAN_RD[] = { + {PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {PB_8, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {PD_0, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_CAN_TD[] = { + {PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {PB_9, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {PD_1, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {NC, NC, 0} +}; + +//*** QUADSPI *** + +MBED_WEAK const PinMap PinMap_QSPI_DATA[] = { + {PA_6, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO3 + {PA_7, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO2 + {PB_0, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO1 + {PB_1, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO0 + {PE_12, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO0 + {PE_13, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO1 + {PE_14, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO2 + {PE_15, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO3 + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_QSPI_SCLK[] = { + {PB_10, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_CLK + {PE_10, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_CLK + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_QSPI_SSEL[] = { + {PB_11, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_NCS + {PE_11, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_NCS + {NC, NC, 0} +}; diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/PinNames.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/PinNames.h new file mode 100644 index 0000000000..c9f7aca3a5 --- /dev/null +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/PinNames.h @@ -0,0 +1,323 @@ +/* mbed Microcontroller Library + +* SPDX-License-Identifier: BSD-3-Clause + ******************************************************************************* + * Copyright (c) 2018, STMicroelectronics + * 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. 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 MBED_PINNAMES_H +#define MBED_PINNAMES_H + +#include "cmsis.h" +#include "PinNamesTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + ALT0 = 0x100, + ALT1 = 0x200, + ALT2 = 0x300, + ALT3 = 0x400 +} ALTx; + +typedef enum { + PA_0 = 0x00, + PA_0_ALT0 = PA_0 | ALT0, + PA_1 = 0x01, + PA_1_ALT0 = PA_1 | ALT0, + PA_2 = 0x02, + PA_2_ALT0 = PA_2 | ALT0, + PA_3 = 0x03, + PA_3_ALT0 = PA_3 | ALT0, + PA_4 = 0x04, + PA_4_ALT0 = PA_4 | ALT0, + PA_5 = 0x05, + PA_5_ALT0 = PA_5 | ALT0, + PA_6 = 0x06, + PA_6_ALT0 = PA_6 | ALT0, + PA_7 = 0x07, + PA_7_ALT0 = PA_7 | ALT0, + PA_7_ALT1 = PA_7 | ALT1, + PA_7_ALT2 = PA_7 | ALT2, + PA_8 = 0x08, + PA_9 = 0x09, + PA_10 = 0x0A, + PA_11 = 0x0B, + PA_12 = 0x0C, + PA_13 = 0x0D, + PA_14 = 0x0E, + PA_15 = 0x0F, + PA_15_ALT0 = PA_15 | ALT0, + + PB_0 = 0x10, + PB_0_ALT0 = PB_0 | ALT0, + PB_0_ALT1 = PB_0 | ALT1, + PB_1 = 0x11, + PB_1_ALT0 = PB_1 | ALT0, + PB_1_ALT1 = PB_1 | ALT1, + PB_2 = 0x12, + PB_3 = 0x13, + PB_3_ALT0 = PB_3 | ALT0, + PB_4 = 0x14, + PB_4_ALT0 = PB_4 | ALT0, + PB_5 = 0x15, + PB_5_ALT0 = PB_5 | ALT0, + PB_6 = 0x16, + PB_6_ALT0 = PB_6 | ALT0, + PB_7 = 0x17, + PB_7_ALT0 = PB_7 | ALT0, + PB_8 = 0x18, + PB_8_ALT0 = PB_8 | ALT0, + PB_9 = 0x19, + PB_9_ALT0 = PB_9 | ALT0, + PB_10 = 0x1A, + PB_11 = 0x1B, + PB_12 = 0x1C, + PB_13 = 0x1D, + PB_13_ALT0 = PB_13 | ALT0, + PB_14 = 0x1E, + PB_14_ALT0 = PB_14 | ALT0, + PB_14_ALT1 = PB_14 | ALT1, + PB_15 = 0x1F, + PB_15_ALT0 = PB_15 | ALT0, + PB_15_ALT1 = PB_15 | ALT1, + + PC_0 = 0x20, + PC_0_ALT0 = PC_0 | ALT0, + PC_0_ALT1 = PC_0 | ALT1, + PC_1 = 0x21, + PC_1_ALT0 = PC_1 | ALT0, + PC_1_ALT1 = PC_1 | ALT1, + PC_2 = 0x22, + PC_2_ALT0 = PC_2 | ALT0, + PC_2_ALT1 = PC_2 | ALT1, + PC_3 = 0x23, + PC_3_ALT0 = PC_3 | ALT0, + PC_3_ALT1 = PC_3 | ALT1, + PC_4 = 0x24, + PC_4_ALT0 = PC_4 | ALT0, + PC_5 = 0x25, + PC_5_ALT0 = PC_5 | ALT0, + PC_6 = 0x26, + PC_6_ALT0 = PC_6 | ALT0, + PC_7 = 0x27, + PC_7_ALT0 = PC_7 | ALT0, + PC_8 = 0x28, + PC_8_ALT0 = PC_8 | ALT0, + PC_9 = 0x29, + PC_9_ALT0 = PC_9 | ALT0, + PC_10 = 0x2A, + PC_10_ALT0 = PC_10 | ALT0, + PC_11 = 0x2B, + PC_11_ALT0 = PC_11 | ALT0, + PC_12 = 0x2C, + PC_13 = 0x2D, + PC_14 = 0x2E, + PC_15 = 0x2F, + + PD_0 = 0x30, + PD_1 = 0x31, + PD_2 = 0x32, + PD_3 = 0x33, + PD_4 = 0x34, + PD_5 = 0x35, + PD_6 = 0x36, + PD_7 = 0x37, + PD_8 = 0x38, + PD_9 = 0x39, + PD_10 = 0x3A, + PD_11 = 0x3B, + PD_12 = 0x3C, + PD_13 = 0x3D, + PD_14 = 0x3E, + PD_15 = 0x3F, + + PE_0 = 0x40, + PE_1 = 0x41, + PE_2 = 0x42, + PE_3 = 0x43, + PE_4 = 0x44, + PE_5 = 0x45, + PE_6 = 0x46, + PE_7 = 0x47, + PE_8 = 0x48, + PE_9 = 0x49, + PE_10 = 0x4A, + PE_11 = 0x4B, + PE_12 = 0x4C, + PE_13 = 0x4D, + PE_14 = 0x4E, + PE_15 = 0x4F, + + PH_0 = 0x70, + PH_1 = 0x71, + + // ADC internal channels + ADC_TEMP = 0xF0, + ADC_VREF = 0xF1, + ADC_VBAT = 0xF2, + + // Not connected + NC = (int)0xFFFFFFFF, + + // STDIO for console print +#ifdef MBED_CONF_TARGET_STDIO_UART_TX + STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX, +#else + STDIO_UART_TX = PA_9, +#endif +#ifdef MBED_CONF_TARGET_STDIO_UART_RX + STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX, +#else + STDIO_UART_RX = PA_10, +#endif + + // Generic signals namings + LED1 = PE_2, // Red LED (LD1) + LED2 = PE_3, // Blue LED (LD2) + LED3 = PE_4, // Green LED (LD3) + + LED_RED = LED1, + LED_BLUE = LED2, + LED_GREEN = LED3, + + USER_BUTTON = PD_4, + BUTTON1 = USER_BUTTON, + + USBTX = STDIO_UART_TX, + USBRX = STDIO_UART_RX, + + UART1_TX = PA_2, + UART1_RX = PA_3, + UART1_CTS = PA_0, + UART1_RTS = PA_1, + + SERIAL_TX = UART1_TX, + SERIAL_RX = UART1_RX, + SERIAL_CTS = UART1_CTS, + SERIAL_RTS = UART1_RTS, + + UART2_TX = PC_4, + UART2_RX = PC_5, + + I2C0_SCL = PB_6, + I2C0_SDA = PB_7, + + I2C1_SCL = PC_0, + I2C1_SDA = PC_1, + + SPI0_MOSI = PB_5, + SPI0_MISO = PA_6, + SPI0_SCK = PA_5, + SPI0_CS = PA_15, + + SPI1_MOSI = PB_15, + SPI1_MISO = PB_14, + SPI1_SCK = PD_3, + SPI1_CS = PB_9, + + SPI2_MOSI = PC_12, + SPI2_MISO = PC_11, + SPI2_SCK = PC_10, + SPI2_CS = PA_4, + + //Default SPI + SPI_MOSI = SPI0_MOSI, + SPI_MISO = SPI0_MISO, + SPI_SCK = SPI0_SCK, + /**************** + //IMPORTANT NOTE: The default CS for SPI is marked as the CS line for the SPI Flash + //on the MCB reference hardware. Please change as appropriate. + ****************/ + SPI_CS = PD_2, + + CAN1_RX = PD_0, //Test point on MCB + CAN1_TX = PD_1, //Test point on MCB + + /**** OSCILLATOR pins ****/ + RCC_OSC32_IN = PC_14, + RCC_OSC32_OUT = PC_15, + RCC_OSC_IN = PH_0, + RCC_OSC_OUT = PH_1, + + /**** DEBUG pins ****/ + SYS_JTCK_SWCLK = PA_14, + SYS_JTDI = PA_15, + SYS_JTDO_SWO = PB_3, + SYS_JTMS_SWDIO = PA_13, + SYS_JTRST = PB_4, + SYS_PVD_IN = PB_7, + SYS_TRACECLK = PE_2, + SYS_TRACED0 = PE_3, + SYS_TRACED1 = PE_4, + SYS_TRACED2 = PE_5, + SYS_TRACED3 = PE_6, + SYS_WKUP1 = PA_0, + SYS_WKUP2 = PC_13, + SYS_WKUP3 = PE_6, + SYS_WKUP4 = PA_2, + SYS_WKUP5 = PC_5, + + //MTB aliases + TX1 = PA_2, + RX1 = PA_3, + SDA1 = PB_7, + SCL1 = PB_6, + MOSI1 = PB_5, + MISO1 = PA_6, + SCK1 = PA_5, + GP0 = PD_4, + GP1 = PC_10, + AIN0 = PA_0, //CTS + AIN1 = PA_1, // RTS + AIN2 = PB_0, + + GP2 = PE_5, //SD card CS + GP3 = PE_6, + SCK2 = PD_3, + MISO2 = PB_14, + MOSI2 = PB_15, + SCL2 = PC_1, + SDA2 = PC_0, + RX2 = PC_5, + TX2 = PC_4, + GP4 = PE_9, + GP5 = PE_10, //A0 for LCD on MTB + GP6 = PE_13, //RESET for LCD on MTB + GP7 = PE_14, //LCD CS + GP8 = PE_15 + +} PinName; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/system_clock.c b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/system_clock.c new file mode 100644 index 0000000000..39c066d940 --- /dev/null +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_MTB_STM_L475/system_clock.c @@ -0,0 +1,372 @@ +/* mbed Microcontroller Library +* Copyright (c) 2006-2019 ARM Limited + +* 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 +* +* 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. +*/ + +/** + * This file configures the system clock as follows: + *----------------------------------------------------------------------------- + * System clock source | 1- USE_PLL_HSE_EXTC (external 8 MHz clock) + * | 2- USE_PLL_HSE_XTAL (external 8 MHz xtal) + * | 3- USE_PLL_HSI (internal 16 MHz) + * | 4- USE_PLL_MSI (internal 100kHz to 48 MHz) + *----------------------------------------------------------------------------- + * SYSCLK(MHz) | 80 + * AHBCLK (MHz) | 80 + * APB1CLK (MHz) | 80 + * APB2CLK (MHz) | 80 + * USB capable | YES + *----------------------------------------------------------------------------- +**/ + +#include "stm32l4xx.h" +#include "nvic_addr.h" +#include "mbed_error.h" + +/*!< 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. */ + + +// clock source is selected with CLOCK_SOURCE in json config +#define USE_PLL_HSE_EXTC 0x8 // Use external clock (ST Link MCO - not enabled by default) +#define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default) +#define USE_PLL_HSI 0x2 // Use HSI internal clock +#define USE_PLL_MSI 0x1 // Use MSI internal clock + +#define DEBUG_MCO (0) // Output the MCO on PA8 for debugging (0=OFF, 1=SYSCLK, 2=HSE, 3=HSI, 4=MSI) + +#if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) +uint8_t SetSysClock_PLL_HSE(uint8_t bypass); +#endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ + +#if ((CLOCK_SOURCE) & USE_PLL_HSI) +uint8_t SetSysClock_PLL_HSI(void); +#endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ + +#if ((CLOCK_SOURCE) & USE_PLL_MSI) +uint8_t SetSysClock_PLL_MSI(void); +#endif /* ((CLOCK_SOURCE) & USE_PLL_MSI) */ + + +/** + * @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 = 0x00000000; + + /* Reset HSEON, CSSON , HSION, and PLLON bits */ + RCC->CR &= (uint32_t)0xEAF6FFFF; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x00001000; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Disable all interrupts */ + RCC->CIER = 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 = NVIC_FLASH_VECTOR_ADDRESS; /* Vector Table Relocation in Internal FLASH */ +#endif + +} + + +/** + * @brief Configures the System clock source, PLL Multiplier and Divider factors, + * AHB/APBx prescalers and Flash settings + * @note This function should be called only once the RCC clock configuration + * is reset to the default reset state (done in SystemInit() function). + * @param None + * @retval None + */ + +void SetSysClock(void) +{ +#if ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) + /* 1- Try to start with HSE and external clock */ + if (SetSysClock_PLL_HSE(1) == 0) +#endif + { +#if ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) + /* 2- If fail try to start with HSE and external xtal */ + if (SetSysClock_PLL_HSE(0) == 0) +#endif + { +#if ((CLOCK_SOURCE) & USE_PLL_HSI) + /* 3- If fail start with HSI clock */ + if (SetSysClock_PLL_HSI() == 0) +#endif + { +#if ((CLOCK_SOURCE) & USE_PLL_MSI) + /* 4- If fail start with MSI clock */ + if (SetSysClock_PLL_MSI() == 0) +#endif + { + { + error("SetSysClock failed\n"); + } + } + } + } + } + + // Output clock on MCO1 pin(PA8) for debugging purpose +#if DEBUG_MCO == 1 + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_SYSCLK, RCC_MCODIV_1); +#endif +} + +#if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) +/******************************************************************************/ +/* PLL (clocked by HSE) used as System clock source */ +/******************************************************************************/ +uint8_t SetSysClock_PLL_HSE(uint8_t bypass) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit = {0}; + + // Used to gain time after DeepSleep in case HSI is used + if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET) { + return 0; + } + + // Select MSI as system clock source to allow modification of the PLL configuration + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0); + + // Enable HSE oscillator and activate PLL with HSE as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI; + if (bypass == 0) { + RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External 8 MHz xtal on OSC_IN/OSC_OUT + } else { + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External 8 MHz clock on OSC_IN + } + RCC_OscInitStruct.HSIState = RCC_HSI_OFF; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; // 8 MHz + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLM = 1; // VCO input clock = 8 MHz (8 MHz / 1) + RCC_OscInitStruct.PLL.PLLN = 20; // VCO output clock = 160 MHz (8 MHz * 20) + RCC_OscInitStruct.PLL.PLLP = 7; // PLLSAI3 clock = 22 MHz (160 MHz / 7) + RCC_OscInitStruct.PLL.PLLQ = 2; + RCC_OscInitStruct.PLL.PLLR = 2; // PLL clock = 80 MHz (160 MHz / 2) + + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + // Select PLL clock 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; // 80 MHz or 48 MHz + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 80 MHz or 48 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; // 80 MHz or 48 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 80 MHz or 48 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) { + return 0; // FAIL + } + + RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; + RCC_PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSE; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1M = 1; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1N = 12; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV7; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK; + if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) { + return 0; // FAIL + } + + // Disable MSI Oscillator + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; + RCC_OscInitStruct.MSIState = RCC_MSI_OFF; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // No PLL update + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + // Output clock on MCO1 pin(PA8) for debugging purpose +#if DEBUG_MCO == 2 + if (bypass == 0) { + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz + } else { + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz + } +#endif + + return 1; // OK +} +#endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ + +#if ((CLOCK_SOURCE) & USE_PLL_HSI) +/******************************************************************************/ +/* PLL (clocked by HSI) used as System clock source */ +/******************************************************************************/ +uint8_t SetSysClock_PLL_HSI(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit = {0}; + + // Select MSI as system clock source to allow modification of the PLL configuration + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0); + + // Enable HSI oscillator and activate PLL with HSI as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_OFF; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; // 16 MHz + RCC_OscInitStruct.PLL.PLLM = 2; // VCO input clock = 8 MHz (16 MHz / 2) + RCC_OscInitStruct.PLL.PLLN = 20; // VCO output clock = 160 MHz (8 MHz * 20) + RCC_OscInitStruct.PLL.PLLP = 7; // PLLSAI3 clock = 22 MHz (160 MHz / 7) + RCC_OscInitStruct.PLL.PLLQ = 2; + RCC_OscInitStruct.PLL.PLLR = 2; // PLL clock = 80 MHz (160 MHz / 2) + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + // 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; // 80 MHz + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 80 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; // 80 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 80 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) { + return 0; // FAIL + } + + RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; + RCC_PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSI; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1M = 2; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1N = 12; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV7; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK; + if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) { + return 0; // FAIL + } + + // Disable MSI Oscillator + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; + RCC_OscInitStruct.MSIState = RCC_MSI_OFF; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // No PLL update + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + // Output clock on MCO1 pin(PA8) for debugging purpose +#if DEBUG_MCO == 3 + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz +#endif + + return 1; // OK +} +#endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ + +#if ((CLOCK_SOURCE) & USE_PLL_MSI) +/******************************************************************************/ +/* PLL (clocked by MSI) used as System clock source */ +/******************************************************************************/ +uint8_t SetSysClock_PLL_MSI(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + +#if MBED_CONF_TARGET_LSE_AVAILABLE + // Enable LSE Oscillator to automatically calibrate the MSI clock + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // No PLL update + RCC_OscInitStruct.LSEState = RCC_LSE_ON; // External 32.768 kHz clock on OSC_IN/OSC_OUT + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + /* Enable the CSS interrupt in case LSE signal is corrupted or not present */ + HAL_RCCEx_DisableLSECSS(); +#endif /* MBED_CONF_TARGET_LSE_AVAILABLE */ + + /* Enable MSI Oscillator and activate PLL with MSI as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.MSIState = RCC_MSI_ON; + RCC_OscInitStruct.HSEState = RCC_HSE_OFF; + RCC_OscInitStruct.HSIState = RCC_HSI_OFF; + + RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT; + RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11; /* 48 MHz */ + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI; + RCC_OscInitStruct.PLL.PLLM = 6; /* 8 MHz */ + RCC_OscInitStruct.PLL.PLLN = 40; /* 320 MHz */ + RCC_OscInitStruct.PLL.PLLP = 7; /* 45 MHz */ + RCC_OscInitStruct.PLL.PLLQ = 4; /* 80 MHz */ + RCC_OscInitStruct.PLL.PLLR = 4; /* 80 MHz */ + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + +#if MBED_CONF_TARGET_LSE_AVAILABLE + /* Enable MSI Auto-calibration through LSE */ + HAL_RCCEx_EnableMSIPLLMode(); +#endif /* MBED_CONF_TARGET_LSE_AVAILABLE */ + + /* Select MSI output as USB clock source */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_MSI; /* 48 MHz */ + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); + // 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; /* 80 MHz */ + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; /* 80 MHz */ + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; /* 80 MHz */ + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; /* 80 MHz */ + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) { + return 0; // FAIL + } + + // Output clock on MCO1 pin(PA8) for debugging purpose +#if DEBUG_MCO == 4 + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_MSI, RCC_MCODIV_2); // 2 MHz +#endif + + return 1; // OK +} +#endif /* ((CLOCK_SOURCE) & USE_PLL_MSI) */ diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/PeripheralNames.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/PeripheralNames.h new file mode 100644 index 0000000000..7d462c0ffe --- /dev/null +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/PeripheralNames.h @@ -0,0 +1,96 @@ +/* mbed Microcontroller Library + * + * SPDX-License-Identifier: BSD-3-Clause + ********************************************************1*********************** + * Copyright (c) 2015, STMicroelectronics + * 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. 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 MBED_PERIPHERALNAMES_H +#define MBED_PERIPHERALNAMES_H + +#include "cmsis.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + ADC_1 = (int)ADC1_BASE, + ADC_2 = (int)ADC2_BASE, + ADC_3 = (int)ADC3_BASE +} ADCName; + +typedef enum { + DAC_1 = (int)DAC_BASE +} DACName; + +typedef enum { + UART_1 = (int)USART1_BASE, + UART_2 = (int)USART2_BASE, + UART_3 = (int)USART3_BASE, + UART_4 = (int)UART4_BASE, + UART_5 = (int)UART5_BASE, + LPUART_1 = (int)LPUART1_BASE +} UARTName; + +typedef enum { + SPI_1 = (int)SPI1_BASE, + SPI_2 = (int)SPI2_BASE, + SPI_3 = (int)SPI3_BASE +} SPIName; + +typedef enum { + I2C_1 = (int)I2C1_BASE, + I2C_2 = (int)I2C2_BASE, + I2C_3 = (int)I2C3_BASE +} I2CName; + +typedef enum { + PWM_1 = (int)TIM1_BASE, + PWM_2 = (int)TIM2_BASE, + PWM_3 = (int)TIM3_BASE, + PWM_4 = (int)TIM4_BASE, + PWM_5 = (int)TIM5_BASE, + PWM_8 = (int)TIM8_BASE, + PWM_15 = (int)TIM15_BASE, + PWM_16 = (int)TIM16_BASE, + PWM_17 = (int)TIM17_BASE +} PWMName; + +typedef enum { + CAN_1 = (int)CAN1_BASE +} CANName; + +typedef enum { + QSPI_1 = (int)QSPI_R_BASE, +} QSPIName; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/PeripheralPins.c b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/PeripheralPins.c new file mode 100644 index 0000000000..982c0e2afa --- /dev/null +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/PeripheralPins.c @@ -0,0 +1,382 @@ +/* mbed Microcontroller Library + * + * SPDX-License-Identifier: BSD-3-Clause + ******************************************************************************* + * Copyright (c) 2018, STMicroelectronics + * 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. 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. + ******************************************************************************* + */ + +#include "PeripheralPins.h" +#include "mbed_toolchain.h" + +//============================================================================== +// Notes +// +// - The pins mentioned Px_y_ALTz are alternative possibilities which use other +// HW peripheral instances. You can use them the same way as any other "normal" +// pin (i.e. PwmOut pwm(PA_7_ALT0);). These pins are not displayed on the board +// pinout image on mbed.org. +// +// - The pins which are other components present on the board have +// the comment "Connected to xxx". The pin function may not work properly in this +// case. These pins may not be displayed on the board pinout image on mbed.org. +// Please read the board reference manual and schematic for more information. +// +// - Warning: pins the default STDIO_UART_TX and STDIO_UART_RX pins are commented +// See https://os.mbed.com/teams/ST/wiki/STDIO for more information. +// +//============================================================================== + + +//*** ADC *** + +MBED_WEAK const PinMap PinMap_ADC[] = { + {PA_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 // rhomb.io AD0 + {PA_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 // rhomb.io AD0 + {PA_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 // rhomb.io AD1 + {PA_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 // rhomb.io AD1 + {PA_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 // rhomb.io UART-A_TXD + {PA_2_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 // rhomb.io UART-A_TXD + {PA_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 // rhomb.io UART-A_RXD + {PA_3_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 // rhomb.io UART-A_RXD + {PA_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 // rhomb.io AD2 + {PA_4_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 // rhomb.io AD2 + {PA_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 // rhomb.io SPIA_CLK + {PA_5_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 // rhomb.io SPIA_CLK + {PA_6, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 // rhomb.io SPIA_MISO + {PA_6_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 // rhomb.io SPIA_MISO + {PA_7, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 // rhomb.io SPIA_MOSI + {PA_7_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 // rhomb.io SPIA_MOSI + {PB_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 // rhomb.io AD3 + {PB_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 // rhomb.io AD3 + {PB_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 16, 0)}, // ADC1_IN16 // rhomb.io NMI + {PB_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 16, 0)}, // ADC2_IN16 // rhomb.io NMI + {PC_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 // rhomb.io AD5 + {PC_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 // rhomb.io AD5 + {PC_0_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 // rhomb.io AD5 + {PC_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 // rhomb.io AD4 + {PC_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 // rhomb.io AD4 + {PC_1_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 // rhomb.io AD4 + {PC_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 // rhomb.io CAPT1 (R19 must be populated) + {PC_2_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 // rhomb.io CAPT1 (R19 must be populated) + {PC_2_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 // rhomb.io CAPT1 (R19 must be populated) + {PC_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 // rhomb.io CAPT0 (R18 must be populated) + {PC_3_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 // rhomb.io CAPT0 (R18 must be populated) + {PC_3_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 // rhomb.io CAPT0 (R18 must be populated) + {PC_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 // rhomb.io AD8 + {PC_4_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 // rhomb.io AD8 + {PC_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 // rhomb.io AD7 + {PC_5_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 // rhomb.io AD7 + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_ADC_Internal[] = { + {ADC_TEMP, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, + {ADC_VREF, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, + {ADC_VBAT, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, + {NC, NC, 0} +}; + +//*** DAC *** + +MBED_WEAK const PinMap PinMap_DAC[] = { + {PA_4, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC1_OUT1 // rhomb.io AD2 + {PA_5, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_OUT2 // rhomb.io SPIA_CLK + {NC, NC, 0} +}; + +//*** I2C *** + +MBED_WEAK const PinMap PinMap_I2C_SDA[] = { + {PB_7, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // rhomb.io INT1 + {PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // rhomb.io I2C-A_SDA // Connected to ATECC608A + {PB_11, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // rhomb.io QSPI_CS0 / + {PB_14, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // rhomb.io SPI-A_CS1 + {PC_1, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // rhomb.io AD4 + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_I2C_SCL[] = { + {PB_6, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // rhomb.io SPI-A_CS0 + {PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // rhomb.io I2C-A_SCL // Connected to ATECC608A + {PB_10, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // rhomb.io IO2 + {PB_13, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // rhomb.io SPI-A_CS2 + {PC_0, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // rhomb.io AD5 + {NC, NC, 0} +}; + +//*** PWM *** + +// TIM5 cannot be used because already used by the us_ticker +MBED_WEAK const PinMap PinMap_PWM[] = { + {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // rhomb.io AD0 +// {PA_0, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 // rhomb.io AD0 + {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // rhomb.io AD1 +// {PA_1, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 // rhomb.io AD1 + {PA_1_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 1)}, // TIM15_CH1N // rhomb.io AD1 + {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // rhomb.io UART-A_TXD +// {PA_2, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 // rhomb.io UART-A_TXD + {PA_2_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 0)}, // TIM15_CH1 // rhomb.io UART-A_TXD + {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 // rhomb.io UART-A_RXD +// {PA_3, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 // rhomb.io UART-A_RXD + {PA_3_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 2, 0)}, // TIM15_CH2 // rhomb.io UART-A_RXD + {PA_5, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // rhomb.io SPI-A_CLK + {PA_5_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N // rhomb.io SPI-A_CLK + {PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 // rhomb.io SPI-A_MISO + {PA_6_ALT0, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 0)}, // TIM16_CH1 // rhomb.io SPI-A_MISO + {PA_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // rhomb.io SPI-A_MOSI + {PA_7_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // rhomb.io SPI-A_MOSI + {PA_7_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N // rhomb.io SPI-A_MOSI + {PA_7_ALT2, PWM_17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM17, 1, 0)}, // TIM17_CH1 // rhomb.io SPI-A_MOSI + {PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 // rhomb.io IO3 + {PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 // rhomb.io IO4 + {PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 // rhomb.io OTG_ID + {PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 // rhomb.io OTG_N + {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // rhomb.io INT2 + {PB_0, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N // rhomb.io AD3 + {PB_0_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 // rhomb.io AD3 + {PB_0_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N // rhomb.io AD3 + {PB_1, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N // rhomb.io NMI + {PB_1_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 // rhomb.io NMI + {PB_1_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N // rhomb.io NMI + {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // rhomb.io INT0 + {PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 // rhomb.io IO1 + {PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // rhomb.io IO0 + {PB_6, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 // rhomb.io SPI-A_CS0 + {PB_6_ALT0, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 1)}, // TIM16_CH1N // rhomb.io SPI-A_CS0 + {PB_7, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 // rhomb.io INT1 + {PB_7_ALT0, PWM_17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM17, 1, 1)}, // TIM17_CH1N // rhomb.io INT1 + {PB_8, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 // rhomb.io I2C-A_SCL + {PB_8_ALT0, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 0)}, // TIM16_CH1 // rhomb.io I2C-A_SCL + {PB_9, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 // rhomb.io I2C-A_SDA + {PB_9_ALT0, PWM_17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM17, 1, 0)}, // TIM17_CH1 // rhomb.io I2C-A_SDA + {PB_10, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // rhomb.io IO2 + {PB_11, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 // rhomb.io QSPI_CS0 + {PB_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // rhomb.io SPI-A_CS2 + {PB_13_ALT0, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 1)}, // TIM15_CH1N // rhomb.io SPI-A_CS2 + {PB_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N // rhomb.io SPI-A_CS1 + {PB_14_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N // rhomb.io SPI-A_CS1 + {PB_14_ALT1, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 1, 0)}, // TIM15_CH1 // rhomb.io SPI-A_CS1 + {PB_15, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N // rhomb.io IO7 + {PB_15_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N // rhomb.io IO7 + {PB_15_ALT1, PWM_15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM15, 2, 0)}, // TIM15_CH2 // rhomb.io IO7 + {PC_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 // rhomb.io PWM3 + {PC_6_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 // rhomb.io PWM3 + {PC_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // rhomb.io PWM0 + {PC_7_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 // rhomb.io PWM0 + {PC_8, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 // rhomb.io SDIO_DATA0 + {PC_8_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 // rhomb.io SDIO_DATA0 + {PC_9, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 // rhomb.io SDIO_DATA1 + {PC_9_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 // rhomb.io SDIO_DATA1 + {PD_12, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 // rhomb.io IO12 + {PD_13, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 // rhomb.io IO13 + {PD_14, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 // rhomb.io PWM2 + {PD_15, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 // rhomb.io SDIO_CDN + {PE_0, PWM_16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM16, 1, 0)}, // TIM16_CH1 // rhomb.io RESET_OUT + {PE_1, PWM_17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM17, 1, 0)}, // TIM17_CH1 // rhomb.io USB_SWITCH + {PE_3, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 // rhomb.io SAI-A_SDO + {PE_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // rhomb.io SAI-A_LRCLK + {PE_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 // rhomb.io SAI-A_BCLK + {PE_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 // rhomb.io SAI-A_SDI + {PE_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // rhomb.io IO5 + {PE_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 // rhomb.io PWM1 + {PE_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N // rhomb.io QSPI_CLK + {PE_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 // rhomb.io QSPI_MEM_CS + {PE_12, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N // rhomb.io QSPI_IO0 + {PE_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 // rhomb.io QSPI_IO1 + {PE_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 // rhomb.io QSPI_IO2 + {NC, NC, 0} +}; + +//*** SERIAL *** + +MBED_WEAK const PinMap PinMap_UART_TX[] = { + {PA_0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // rhomb.io AD0 + {PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // rhomb.io UART-A_TXD + {PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // rhomb.io IO4 + {PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // rhomb.io SPI-A_CS0 + {PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io IO2 + {PB_11, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // rhomb.io QSPI_CS0 + {PC_1, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // rhomb.io AD4 + {PC_4, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io COMP-A_N + {PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io SDIO_DATA2 + {PC_10_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // rhomb.io SDIO_DATA2 + {PC_12, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, // rhomb.io SDIO_CLK + {PD_5, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // rhomb.io UART-B_TXD + {PD_8, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io UART-C_TXD + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_UART_RX[] = { + {PA_1, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // rhomb.io AD1 + {PA_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // rhomb.io UART-A_RXD + {PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // rhomb.io OTG_ID + {PB_7, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // rhomb.io INT1 + {PB_10, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // rhomb.io IO2 + {PB_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io SPI_CS0 + {PC_0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // rhomb.io AD5 + {PC_5, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io COMP-A_P + {PC_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io SDIO_DATA3 + {PC_11_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // rhomb.io SDIO_DATA3 + {PD_2, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, // rhomb.io SDIO_CMD + {PD_6, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // rhomb.io UART-B_RXD + {PD_9, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io UART-C_RXD + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_UART_RTS[] = { + {PA_1, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // rhomb.io AD1 + {PA_12, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // rhomb.io OTG_P + {PA_15, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // rhomb.io INT2 + {PB_1, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io NMI + {PB_3, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // rhomb.io INT0 + {PB_4, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, // rhomb.io IO1 + {PB_12, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // rhomb.io 1WIRE // Connected to DS28E05X + {PB_14, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io SPI-A_CS1 + {PD_2, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io SDIO_CMD + {PD_4, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // rhomb.io UART-A_RTS + {PD_12, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io IO12 + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_UART_CTS[] = { + {PA_0, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // rhomb.io AD0 + {PA_6, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io SPI-A_MISO + {PA_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // rhomb.io OTG_N + {PB_4, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // rhomb.io IO1 + {PB_5, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, // rhomb.io IO0 + {PB_7, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // rhomb.io INT1 + {PB_13, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io SPI-A_CS2 + {PB_13_ALT0, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // rhomb.io SPI-A_CS2 + {PD_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // rhomb.io UART-A_CTS + {PD_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // rhomb.io IO11 + {NC, NC, 0} +}; + +//*** SPI *** + +MBED_WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io SPI-A_MOSI + {PB_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io IO0 + {PB_5_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // rhomb.io IO0 + {PB_15, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io IO7 + {PC_3, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io IO14 + {PC_12, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // rhomb.io SDIO_CLK + {PD_4, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io UART-A_RTS + {PE_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io QSPI_IO3 + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io SPI-A_MISO + {PB_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io IO1 + {PB_4_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // rhomb.io IO1 + {PB_14, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io SPI-A_CS1 + {PC_2, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io IO15 + {PC_11, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // rhomb.io SDIO_DATA3 + {PD_3, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io UART-A_CTS + {PE_14, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io QSPI_IO2 + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io SPI-A_CLK + {PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io INT0 + {PB_3_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // rhomb.io INT0 + {PB_10, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io IO2 + {PB_13, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io SPI-A_CS2 + {PC_10, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // rhomb.io SDIO_DATA2 + {PD_1, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io CAN-A_TX + {PE_13, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io QSPI_IO1 + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io AD2 + {PA_4_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // rhomb.io AD2 + {PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io INT2 + {PA_15_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // rhomb.io INT2 + {PB_9, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io I2C-A_SDA + {PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io 1WIRE // Connected to DS28E05X + {PD_0, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // rhomb.io CAN-A_RX + {PE_12, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // rhomb.io QSPI_IO0 + {NC, NC, 0} +}; + +//*** CAN *** + +MBED_WEAK const PinMap PinMap_CAN_RD[] = { + {PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // rhomb.io OTG_N + {PB_8, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // rhomb.io I2C-A_SCL + {PD_0, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // rhomb.io CAN-A_RX + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_CAN_TD[] = { + {PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // rhomb.io OTG_P + {PB_9, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // rhomb.io I2C-A_SDA + {PD_1, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // rhomb.io CAN-A_TX + {NC, NC, 0} +}; + +//*** QUADSPI *** + +MBED_WEAK const PinMap PinMap_QSPI_DATA0[] = { + {PB_1, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO0 // rhomb.io NMI + {PE_12, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO0 // rhomb.io QSPI_IO0 // Connected to W25Q128JVPIQ + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_QSPI_DATA1[] = { + {PB_0, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO1 // rhomb.io AD3 + {PE_13, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO1 // rhomb.io QSPI_IO1 // Connected to W25Q128JVPIQ + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_QSPI_DATA2[] = { + {PA_7, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO2 // rhomb.io SPI_A_MOSI + {PE_14, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO2 // rhomb.io QSPI_IO2 // Connected to W25Q128JVPIQ + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_QSPI_DATA3[] = { + {PA_6, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO3 // rhomb.io SPI_A_MISO + {PE_15, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO3 // rhomb.io QSPI_IO3 // Connected to W25Q128JVPIQ + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_QSPI_SCLK[] = { + {PB_10, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_CLK // rhomb.io IO2 + {PE_10, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_CLK // rhomb.io QSPI_CLK // Connected to W25Q128JVPIQ + {NC, NC, 0} +}; + +MBED_WEAK const PinMap PinMap_QSPI_SSEL[] = { + {PB_11, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_NCS // rhomb.io QSPI_CS0 + {PE_11, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_NCS // rhomb.io QSPI_MEM_CS // Connected to W25Q128JVPIQ + {NC, NC, 0} +}; diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/PinNames.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/PinNames.h new file mode 100644 index 0000000000..f7266a20da --- /dev/null +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/PinNames.h @@ -0,0 +1,351 @@ +/* mbed Microcontroller Library + * + * SPDX-License-Identifier: BSD-3-Clause + ******************************************************************************* + * Copyright (c) 2018, STMicroelectronics + * 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. 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 MBED_PINNAMES_H +#define MBED_PINNAMES_H + +#include "cmsis.h" +#include "PinNamesTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + ALT0 = 0x100, + ALT1 = 0x200, + ALT2 = 0x300, + ALT3 = 0x400 +} ALTx; + +typedef enum { + PA_0 = 0x00, + PA_0_ALT0 = PA_0 | ALT0, + PA_1 = 0x01, + PA_1_ALT0 = PA_1 | ALT0, + PA_2 = 0x02, + PA_2_ALT0 = PA_2 | ALT0, + PA_3 = 0x03, + PA_3_ALT0 = PA_3 | ALT0, + PA_4 = 0x04, + PA_4_ALT0 = PA_4 | ALT0, + PA_5 = 0x05, + PA_5_ALT0 = PA_5 | ALT0, + PA_6 = 0x06, + PA_6_ALT0 = PA_6 | ALT0, + PA_7 = 0x07, + PA_7_ALT0 = PA_7 | ALT0, + PA_7_ALT1 = PA_7 | ALT1, + PA_7_ALT2 = PA_7 | ALT2, + PA_8 = 0x08, + PA_9 = 0x09, + PA_10 = 0x0A, + PA_11 = 0x0B, + PA_12 = 0x0C, + PA_13 = 0x0D, + PA_14 = 0x0E, + PA_15 = 0x0F, + PA_15_ALT0 = PA_15 | ALT0, + + PB_0 = 0x10, + PB_0_ALT0 = PB_0 | ALT0, + PB_0_ALT1 = PB_0 | ALT1, + PB_1 = 0x11, + PB_1_ALT0 = PB_1 | ALT0, + PB_1_ALT1 = PB_1 | ALT1, + PB_2 = 0x12, + PB_3 = 0x13, + PB_3_ALT0 = PB_3 | ALT0, + PB_4 = 0x14, + PB_4_ALT0 = PB_4 | ALT0, + PB_5 = 0x15, + PB_5_ALT0 = PB_5 | ALT0, + PB_6 = 0x16, + PB_6_ALT0 = PB_6 | ALT0, + PB_7 = 0x17, + PB_7_ALT0 = PB_7 | ALT0, + PB_8 = 0x18, + PB_8_ALT0 = PB_8 | ALT0, + PB_9 = 0x19, + PB_9_ALT0 = PB_9 | ALT0, + PB_10 = 0x1A, + PB_11 = 0x1B, + PB_12 = 0x1C, + PB_13 = 0x1D, + PB_13_ALT0 = PB_13 | ALT0, + PB_14 = 0x1E, + PB_14_ALT0 = PB_14 | ALT0, + PB_14_ALT1 = PB_14 | ALT1, + PB_15 = 0x1F, + PB_15_ALT0 = PB_15 | ALT0, + PB_15_ALT1 = PB_15 | ALT1, + + PC_0 = 0x20, + PC_0_ALT0 = PC_0 | ALT0, + PC_0_ALT1 = PC_0 | ALT1, + PC_1 = 0x21, + PC_1_ALT0 = PC_1 | ALT0, + PC_1_ALT1 = PC_1 | ALT1, + PC_2 = 0x22, + PC_2_ALT0 = PC_2 | ALT0, + PC_2_ALT1 = PC_2 | ALT1, + PC_3 = 0x23, + PC_3_ALT0 = PC_3 | ALT0, + PC_3_ALT1 = PC_3 | ALT1, + PC_4 = 0x24, + PC_4_ALT0 = PC_4 | ALT0, + PC_5 = 0x25, + PC_5_ALT0 = PC_5 | ALT0, + PC_6 = 0x26, + PC_6_ALT0 = PC_6 | ALT0, + PC_7 = 0x27, + PC_7_ALT0 = PC_7 | ALT0, + PC_8 = 0x28, + PC_8_ALT0 = PC_8 | ALT0, + PC_9 = 0x29, + PC_9_ALT0 = PC_9 | ALT0, + PC_10 = 0x2A, + PC_10_ALT0 = PC_10 | ALT0, + PC_11 = 0x2B, + PC_11_ALT0 = PC_11 | ALT0, + PC_12 = 0x2C, + PC_13 = 0x2D, + PC_14 = 0x2E, + PC_15 = 0x2F, + + PD_0 = 0x30, + PD_1 = 0x31, + PD_2 = 0x32, + PD_3 = 0x33, + PD_4 = 0x34, + PD_5 = 0x35, + PD_6 = 0x36, + PD_7 = 0x37, + PD_8 = 0x38, + PD_9 = 0x39, + PD_10 = 0x3A, + PD_11 = 0x3B, + PD_12 = 0x3C, + PD_13 = 0x3D, + PD_14 = 0x3E, + PD_15 = 0x3F, + + PE_0 = 0x40, + PE_1 = 0x41, + PE_2 = 0x42, + PE_3 = 0x43, + PE_4 = 0x44, + PE_5 = 0x45, + PE_6 = 0x46, + PE_7 = 0x47, + PE_8 = 0x48, + PE_9 = 0x49, + PE_10 = 0x4A, + PE_11 = 0x4B, + PE_12 = 0x4C, + PE_13 = 0x4D, + PE_14 = 0x4E, + PE_15 = 0x4F, + + PH_0 = 0x70, + PH_1 = 0x71, + + // ADC internal channels + ADC_TEMP = 0xF0, + ADC_VREF = 0xF1, + ADC_VBAT = 0xF2, + + // STDIO for console print + STDIO_UART_TX = PC_4, + STDIO_UART_RX = PC_5, + + // Generic signals namings + LED1 = PC_7, // LED Green + LED2 = PC_7, // LED Green + + USER_BUTTON = PB_1, + // Standardized button names + BUTTON1 = USER_BUTTON, + + SERIAL_TX = STDIO_UART_TX, + SERIAL_RX = STDIO_UART_RX, + USBTX = STDIO_UART_TX, + USBRX = STDIO_UART_RX, + + I2C_SCL = PB_8, + I2C_SDA = PB_9, + SPI_MOSI = PA_7, + SPI_MISO = PA_6, + SPI_SCK = PA_5, + SPI_CS = PB_6, + PWM_OUT = PC_7, + + /**** USB pins ****/ + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, + USB_OTG_FS_ID = PA_10, + + /**** OSCILLATOR pins ****/ + RCC_OSC32_IN = PC_14, + RCC_OSC32_OUT = PC_15, + RCC_OSC_IN = PH_0, + RCC_OSC_OUT = PH_1, + + /**** DEBUG pins ****/ + SYS_JTCK_SWCLK = PA_14, + SYS_JTDI = PA_15, + SYS_JTDO_SWO = PB_3, + SYS_JTMS_SWDIO = PA_13, + SYS_JTRST = PB_4, + + /**** QSPI FLASH pins ****/ + QSPI_FLASH1_IO0 = PE_12, + QSPI_FLASH1_IO1 = PE_13, + QSPI_FLASH1_IO2 = PE_14, + QSPI_FLASH1_IO3 = PE_15, + QSPI_FLASH1_SCK = PE_10, + QSPI_FLASH1_CSN = PE_11, + + // rhomb.io system namings //......................... + NMI = PB_1, + INT0 = PB_3, + INT1 = PB_7, + INT2 = PA_15, + + IO0 = PB_5, + IO1 = PB_4, + IO2 = PB_10, + IO3 = PA_8, + IO4 = PA_9, + IO5 = PE_8, + IO6 = PE_7, + IO7 = PB_15, + + IO8 = PC_13, + IO9 = PD_7, + IO10 = PD_10, + IO11 = PD_11, + IO12 = PD_12, + IO13 = PD_13, + IO14 = PC_3, + IO15 = PC_2, + + PWM0 = PC_7, + PWM1 = PE_9, + PWM2 = PD_14, + PWM3 = PC_6, + PWM4 = PB_2, + + UART_A_RXD = PA_3, + UART_A_TXD = PA_2, + UART_A_CTS = PD_3, + UART_A_RTS = PD_4, + + UART_B_RXD = PD_6, + UART_B_TXD = PD_5, + + UART_C_RXD = PD_9, + UART_C_TXD = PD_8, + + I2C_A_SDA = PB_9, + I2C_A_SCL = PB_8, + I2C_B_SDA = PB_14, // R14 must be populated/closed (default is open) + I2C_B_SCL = PB_13, // R15 must be populated/closed (default is open) + + SPI_A_MOSI = PA_7, + SPI_A_MISO = PA_6, + SPI_A_CLK = PA_5, + SPI_A_CS0 = PB_6, + SPI_A_CS1 = PB_14, + SPI_A_CS2 = PB_13, + + QSPI_IO0 = PE_12, + QSPI_IO1 = PE_13, + QSPI_IO2 = PE_14, + QSPI_IO3 = PE_15, + QSPI_CLK = PE_10, + QSPI_CS0 = PB_11, + QSPI_MEM_CS = PE_11, + + _1WIRE = PB_12, + CAN_A_RX = PD_0, + CAN_A_TX = PD_1, + + SDIO_DATAO = PC_8, + SDIO_DATA1 = PC_9, + SDIO_DATA2 = PC_10, + SDIO_DATA3 = PC_11, + SDIO_CLK = PC_12, + SDIO_CMD = PD_2, + SDIO_CDN = PD_15, + + SAI_A_BCLK = PE_5, + SAI_A_LRCLK = PE_4, + SAI_A_SDI = PE_6, + SAI_A_SDO = PE_3, + SAI_A_MCLK = PE_2, + + OTG_P = PA_12, + OTG_N = PA_11, + OTG_ID = PA_10, + + AD0 = PA_0, + AD1 = PA_1, + AD2 = PA_4, + AD3 = PB_0, + AD4 = PC_1, + AD5 = PC_0, + // AD6 not used + AD7 = PC_5, + AD8 = PC_4, + + COMP_A_P = PC_5, + COMP_A_N = PC_4, + + CAPT0 = PC_3, // R18 must be populated/closed (default is open) + CAPT1 = PC_2, // R19 must be populated/closed (default is open) + + SWDIO = PA_13, + SWCLK = PA_14, + + RSTOUT = PE_0, + + // Not connected + NC = (int)0xFFFFFFFF + +} PinName; + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/system_clock.c b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/system_clock.c new file mode 100644 index 0000000000..c5daf4963e --- /dev/null +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_RHOMBIO_L476DMW1K/system_clock.c @@ -0,0 +1,372 @@ +/* mbed Microcontroller Library +* Copyright (c) 2006-2019 ARM Limited +* +* 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 +* +* 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. +*/ + +/** + * This file configures the system clock as follows: + *----------------------------------------------------------------------------- + * System clock source | 1- USE_PLL_HSE_EXTC (external 8 MHz clock) + * | 2- USE_PLL_HSE_XTAL (external 8 MHz xtal) + * | 3- USE_PLL_HSI (internal 16 MHz) + * | 4- USE_PLL_MSI (internal 100kHz to 48 MHz) + *----------------------------------------------------------------------------- + * SYSCLK(MHz) | 80 + * AHBCLK (MHz) | 80 + * APB1CLK (MHz) | 80 + * APB2CLK (MHz) | 80 + * USB capable | YES + *----------------------------------------------------------------------------- +**/ + +#include "stm32l4xx.h" +#include "nvic_addr.h" +#include "mbed_error.h" + +/*!< 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. */ + + +// clock source is selected with CLOCK_SOURCE in json config +#define USE_PLL_HSE_EXTC 0x8 // Use external clock (ST Link MCO - not enabled by default) +#define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default) +#define USE_PLL_HSI 0x2 // Use HSI internal clock +#define USE_PLL_MSI 0x1 // Use MSI internal clock + +#define DEBUG_MCO (0) // Output the MCO on PA8 for debugging (0=OFF, 1=SYSCLK, 2=HSE, 3=HSI, 4=MSI) + +#if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) +uint8_t SetSysClock_PLL_HSE(uint8_t bypass); +#endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ + +#if ((CLOCK_SOURCE) & USE_PLL_HSI) +uint8_t SetSysClock_PLL_HSI(void); +#endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ + +#if ((CLOCK_SOURCE) & USE_PLL_MSI) +uint8_t SetSysClock_PLL_MSI(void); +#endif /* ((CLOCK_SOURCE) & USE_PLL_MSI) */ + + +/** + * @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 = 0x00000000; + + /* Reset HSEON, CSSON , HSION, and PLLON bits */ + RCC->CR &= (uint32_t)0xEAF6FFFF; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x00001000; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Disable all interrupts */ + RCC->CIER = 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 = NVIC_FLASH_VECTOR_ADDRESS; /* Vector Table Relocation in Internal FLASH */ +#endif + +} + + +/** + * @brief Configures the System clock source, PLL Multiplier and Divider factors, + * AHB/APBx prescalers and Flash settings + * @note This function should be called only once the RCC clock configuration + * is reset to the default reset state (done in SystemInit() function). + * @param None + * @retval None + */ + +void SetSysClock(void) +{ +#if ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) + /* 1- Try to start with HSE and external clock */ + if (SetSysClock_PLL_HSE(1) == 0) +#endif + { +#if ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) + /* 2- If fail try to start with HSE and external xtal */ + if (SetSysClock_PLL_HSE(0) == 0) +#endif + { +#if ((CLOCK_SOURCE) & USE_PLL_HSI) + /* 3- If fail start with HSI clock */ + if (SetSysClock_PLL_HSI() == 0) +#endif + { +#if ((CLOCK_SOURCE) & USE_PLL_MSI) + /* 4- If fail start with MSI clock */ + if (SetSysClock_PLL_MSI() == 0) +#endif + { + { + error("SetSysClock failed\n"); + } + } + } + } + } + + // Output clock on MCO1 pin(PA8) for debugging purpose +#if DEBUG_MCO == 1 + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_SYSCLK, RCC_MCODIV_1); +#endif +} + +#if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) +/******************************************************************************/ +/* PLL (clocked by HSE) used as System clock source */ +/******************************************************************************/ +uint8_t SetSysClock_PLL_HSE(uint8_t bypass) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit = {0}; + + // Used to gain time after DeepSleep in case HSI is used + if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET) { + return 0; + } + + // Select MSI as system clock source to allow modification of the PLL configuration + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0); + + // Enable HSE oscillator and activate PLL with HSE as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI; + if (bypass == 0) { + RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External 8 MHz xtal on OSC_IN/OSC_OUT + } else { + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External 8 MHz clock on OSC_IN + } + RCC_OscInitStruct.HSIState = RCC_HSI_OFF; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; // 8 MHz + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLM = 1; // VCO input clock = 8 MHz (8 MHz / 1) + RCC_OscInitStruct.PLL.PLLN = 20; // VCO output clock = 160 MHz (8 MHz * 20) + RCC_OscInitStruct.PLL.PLLP = 7; // PLLSAI3 clock = 22 MHz (160 MHz / 7) + RCC_OscInitStruct.PLL.PLLQ = 2; + RCC_OscInitStruct.PLL.PLLR = 2; // PLL clock = 80 MHz (160 MHz / 2) + + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + // Select PLL clock 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; // 80 MHz or 48 MHz + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 80 MHz or 48 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; // 80 MHz or 48 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 80 MHz or 48 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) { + return 0; // FAIL + } + + RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; + RCC_PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSE; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1M = 1; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1N = 12; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV7; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK; + if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) { + return 0; // FAIL + } + + // Disable MSI Oscillator + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; + RCC_OscInitStruct.MSIState = RCC_MSI_OFF; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // No PLL update + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + // Output clock on MCO1 pin(PA8) for debugging purpose +#if DEBUG_MCO == 2 + if (bypass == 0) { + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz + } else { + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz + } +#endif + + return 1; // OK +} +#endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ + +#if ((CLOCK_SOURCE) & USE_PLL_HSI) +/******************************************************************************/ +/* PLL (clocked by HSI) used as System clock source */ +/******************************************************************************/ +uint8_t SetSysClock_PLL_HSI(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit = {0}; + + // Select MSI as system clock source to allow modification of the PLL configuration + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0); + + // Enable HSI oscillator and activate PLL with HSI as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_OFF; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; // 16 MHz + RCC_OscInitStruct.PLL.PLLM = 2; // VCO input clock = 8 MHz (16 MHz / 2) + RCC_OscInitStruct.PLL.PLLN = 20; // VCO output clock = 160 MHz (8 MHz * 20) + RCC_OscInitStruct.PLL.PLLP = 7; // PLLSAI3 clock = 22 MHz (160 MHz / 7) + RCC_OscInitStruct.PLL.PLLQ = 2; + RCC_OscInitStruct.PLL.PLLR = 2; // PLL clock = 80 MHz (160 MHz / 2) + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + // 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; // 80 MHz + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 80 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; // 80 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 80 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) { + return 0; // FAIL + } + + RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; + RCC_PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSI; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1M = 2; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1N = 12; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV7; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2; + RCC_PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK; + if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) { + return 0; // FAIL + } + + // Disable MSI Oscillator + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; + RCC_OscInitStruct.MSIState = RCC_MSI_OFF; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // No PLL update + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + // Output clock on MCO1 pin(PA8) for debugging purpose +#if DEBUG_MCO == 3 + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz +#endif + + return 1; // OK +} +#endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ + +#if ((CLOCK_SOURCE) & USE_PLL_MSI) +/******************************************************************************/ +/* PLL (clocked by MSI) used as System clock source */ +/******************************************************************************/ +uint8_t SetSysClock_PLL_MSI(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + +#if MBED_CONF_TARGET_LSE_AVAILABLE + // Enable LSE Oscillator to automatically calibrate the MSI clock + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // No PLL update + RCC_OscInitStruct.LSEState = RCC_LSE_ON; // External 32.768 kHz clock on OSC_IN/OSC_OUT + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + /* Enable the CSS interrupt in case LSE signal is corrupted or not present */ + HAL_RCCEx_DisableLSECSS(); +#endif /* MBED_CONF_TARGET_LSE_AVAILABLE */ + + /* Enable MSI Oscillator and activate PLL with MSI as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.MSIState = RCC_MSI_ON; + RCC_OscInitStruct.HSEState = RCC_HSE_OFF; + RCC_OscInitStruct.HSIState = RCC_HSI_OFF; + + RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT; + RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11; /* 48 MHz */ + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI; + RCC_OscInitStruct.PLL.PLLM = 6; /* 8 MHz */ + RCC_OscInitStruct.PLL.PLLN = 40; /* 320 MHz */ + RCC_OscInitStruct.PLL.PLLP = 7; /* 45 MHz */ + RCC_OscInitStruct.PLL.PLLQ = 4; /* 80 MHz */ + RCC_OscInitStruct.PLL.PLLR = 4; /* 80 MHz */ + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + +#if MBED_CONF_TARGET_LSE_AVAILABLE + /* Enable MSI Auto-calibration through LSE */ + HAL_RCCEx_EnableMSIPLLMode(); +#endif /* MBED_CONF_TARGET_LSE_AVAILABLE */ + + /* Select MSI output as USB clock source */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_MSI; /* 48 MHz */ + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); + // 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; /* 80 MHz */ + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; /* 80 MHz */ + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; /* 80 MHz */ + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; /* 80 MHz */ + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) { + return 0; // FAIL + } + + // Output clock on MCO1 pin(PA8) for debugging purpose +#if DEBUG_MCO == 4 + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_MSI, RCC_MCODIV_2); // 2 MHz +#endif + + return 1; // OK +} +#endif /* ((CLOCK_SOURCE) & USE_PLL_MSI) */ \ No newline at end of file diff --git a/targets/TARGET_STM/lp_ticker.c b/targets/TARGET_STM/lp_ticker.c index d8704faa56..fa16a27f6e 100644 --- a/targets/TARGET_STM/lp_ticker.c +++ b/targets/TARGET_STM/lp_ticker.c @@ -59,16 +59,19 @@ const ticker_info_t *lp_ticker_get_info() volatile uint8_t lp_Fired = 0; +static int LPTICKER_inited = 0; + static void LPTIM1_IRQHandler(void); static void (*irq_handler)(void); void lp_ticker_init(void) { /* Check if LPTIM is already configured */ - if (__HAL_RCC_LPTIM1_IS_CLK_ENABLED()) { + if (LPTICKER_inited) { lp_ticker_disable_interrupt(); return; } + LPTICKER_inited = 1; RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInitStruct = {0}; RCC_OscInitTypeDef RCC_OscInitStruct = {0}; diff --git a/targets/TARGET_STM/pinmap.c b/targets/TARGET_STM/pinmap.c index 5c92ad19bd..5076ef45ba 100644 --- a/targets/TARGET_STM/pinmap.c +++ b/targets/TARGET_STM/pinmap.c @@ -79,7 +79,13 @@ void pin_function(PinName pin, int data) #if defined (TARGET_STM32F1) if (mode == STM_PIN_OUTPUT) { #endif + +#if defined (LL_GPIO_SPEED_FREQ_VERY_HIGH) + LL_GPIO_SetPinSpeed(gpio, ll_pin, LL_GPIO_SPEED_FREQ_VERY_HIGH); +#else LL_GPIO_SetPinSpeed(gpio, ll_pin, LL_GPIO_SPEED_FREQ_HIGH); +#endif + #if defined (TARGET_STM32F1) } #endif diff --git a/targets/targets.json b/targets/targets.json index 3ac3789b38..832cfa4355 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -3914,6 +3914,35 @@ "device_name": "STM32L475VG", "bootloader_supported": true }, + "MTB_STM_L475": { + "inherits": ["FAMILY_STM32"], + "core": "Cortex-M4F", + "extra_labels_add": ["STM32L4", "STM32L475xG", "STM32L475VG"], + "config": { + "clock_source": { + "help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (8MHz) | USE_PLL_HSI | USE_PLL_MSI", + "value": "USE_PLL_HSE_XTAL", + "macro_name": "CLOCK_SOURCE" + }, + "lpticker_lptim": { + "help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer", + "value": 0 + } + }, + "detect_code": ["0468"], + "macros_add": ["USBHOST_OTHER", "TWO_RAM_REGIONS"], + "device_has_add": [ + "ANALOGOUT", + "CAN", + "SERIAL_FC", + "TRNG", + "FLASH", + "MPU" + ], + "release_versions": ["5"], + "device_name": "STM32L475VG", + "bootloader_supported": true + }, "DISCO_L476VG": { "components_add": ["QSPIF", "FLASHIAP"], "inherits": ["FAMILY_STM32"], @@ -3949,6 +3978,41 @@ "device_name": "STM32L476VG", "bootloader_supported": true }, + "RHOMBIO_L476DMW1K": { + "components_add": ["FLASHIAP"], + "inherits": ["FAMILY_STM32"], + "core": "Cortex-M4F", + "extra_labels_add": ["STM32L4", "STM32L476xG", "STM32L476VG"], + "config": { + "clock_source": { + "help": "Mask value : USE_PLL_HSE_EXTC (need HW patch) | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI | USE_PLL_MSI", + "value": "USE_PLL_MSI", + "macro_name": "CLOCK_SOURCE" + }, + "lpticker_lptim": { + "help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer", + "value": 1 + } + }, + "overrides": { "lpticker_delay_ticks": 4 }, + "detect_code": ["1500"], + "macros_add": [ + "MBED_TICKLESS", + "USBHOST_OTHER", + "TWO_RAM_REGIONS" + ], + "device_has_add": [ + "ANALOGOUT", + "CAN", + "SERIAL_FC", + "TRNG", + "FLASH", + "MPU" + ], + "release_versions": ["2", "5"], + "device_name": "STM32L476VG", + "bootloader_supported": true + }, "MTS_MDOT_F405RG": { "inherits": ["FAMILY_STM32"], "core": "Cortex-M4F", @@ -6780,7 +6844,8 @@ "device_name": "nRF52832_xxAA", "macros_add": [ "WSF_MAX_HANDLERS=10" - ] + ], + "device_has_remove": ["ITM"] }, "SDT52832B": { "inherits": ["MCU_NRF52832"], @@ -6824,7 +6889,8 @@ "supported_form_factors": ["ARDUINO"], "inherits": ["MCU_NRF52832"], "release_versions": ["5"], - "device_name": "nRF52832_xxAA" + "device_name": "nRF52832_xxAA", + "device_has_remove": ["ITM"] }, "MCU_NRF52840": { "inherits": ["Target"], @@ -7954,7 +8020,7 @@ "device_has_remove": ["TRNG", "CRC"], "macros_add": ["CY8C6347BZI_BLD53"], "detect_code": ["6000"], - "hex_filename": "psoc63_m0_default_1.02.hex", + "hex_filename": "psoc63_m0_default_1.03.hex", "post_binary_hook": { "function": "PSOC6Code.complete" }, @@ -8054,7 +8120,7 @@ "inherits": ["Target"], "core": "Cortex-M4F", "public": true, - "extra_labels": ["RDA", "UNO_91H", "FLASH_CMSIS_ALGO"], + "extra_labels": ["RDA", "UNO_91H", "FLASH_CMSIS_ALGO", "RDA_EMAC"], "supported_toolchains": ["ARM", "GCC_ARM", "IAR"], "macros": ["TWO_RAM_REGIONS", "CMSIS_NVIC_VIRTUAL", "CMSIS_NVIC_VIRTUAL_HEADER_FILE=\"RDA5981_nvic_virtual.h\""], "device_has": [ @@ -8063,6 +8129,7 @@ "PORTOUT", "PORTINOUT", "INTERRUPTIN", + "EMAC", "SERIAL", "STDIO_MESSAGES", "PWMOUT", @@ -8076,7 +8143,10 @@ }, "UNO_91H": { "inherits": ["RDA5981X"], - "detect_code": ["8001"] + "detect_code": ["8001"], + "overrides": { + "network-default-interface-type" : "WIFI" + } }, "GD32_Target": { "inherits": ["Target"], diff --git a/tools/arm_pack_manager/__init__.py b/tools/arm_pack_manager/__init__.py index e33b3495d1..a16977245d 100644 --- a/tools/arm_pack_manager/__init__.py +++ b/tools/arm_pack_manager/__init__.py @@ -1,3 +1,21 @@ +""" +Copyright (c) 2016-2019 ARM Limited. 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 + +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. +""" + try: from urllib2 import urlopen, URLError except ImportError: diff --git a/tools/arm_pack_manager/pack_manager.py b/tools/arm_pack_manager/pack_manager.py index edc492803b..6c946d87fe 100644 --- a/tools/arm_pack_manager/pack_manager.py +++ b/tools/arm_pack_manager/pack_manager.py @@ -1,3 +1,20 @@ +""" +Copyright (c) 2016-2019 ARM Limited. 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 + +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. +""" from __future__ import print_function, division, absolute_import import argparse from os.path import basename diff --git a/tools/build.py b/tools/build.py index 40b0a52771..c7962c5d2b 100644 --- a/tools/build.py +++ b/tools/build.py @@ -43,6 +43,7 @@ from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, CLI_COLOR_MAP from tools.notifier.term import TerminalNotifier from tools.utils import argparse_filestring_type, args_error, argparse_many from tools.utils import argparse_filestring_type, argparse_dir_not_parent +from tools.paths import is_relative_to_root if __name__ == '__main__': start = time() @@ -188,19 +189,11 @@ if __name__ == '__main__': mcu = TARGET_MAP[target] profile = extract_profile(parser, options, toolchain) - if mcu.is_PSA_secure_target: - lib_build_res = build_library( - ROOT, options.build_dir, mcu, toolchain, - jobs=options.jobs, - clean=options.clean, - archive=(not options.no_archive), - macros=options.macros, - name=options.artifact_name, - build_profile=profile, - ignore=options.ignore, - notify=notifier, - ) - elif options.source_dir: + if mcu.is_PSA_secure_target and \ + not is_relative_to_root(options.source_dir): + options.source_dir = ROOT + + if options.source_dir: lib_build_res = build_library( options.source_dir, options.build_dir, mcu, toolchain, jobs=options.jobs, diff --git a/tools/check_release.py b/tools/check_release.py index 4d940fbb2d..e64e6d2a4f 100644 --- a/tools/check_release.py +++ b/tools/check_release.py @@ -1,3 +1,21 @@ +""" +Copyright (c) 2016-2019 ARM Limited. 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 + +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. +""" + # Script to check a new mbed 2 release by compiling a set of specified test apps # for all currently supported platforms. Each test app must include an mbed library. # This can either be the pre-compiled version 'mbed' or the source version 'mbed-dev'. diff --git a/tools/dev/intel_hex_utils.py b/tools/dev/intel_hex_utils.py index c60e9c4e74..75ec2bfbc4 100644 --- a/tools/dev/intel_hex_utils.py +++ b/tools/dev/intel_hex_utils.py @@ -1,3 +1,21 @@ +""" +Copyright (c) 2014-2019 ARM Limited. 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 + +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. +""" + from intelhex import IntelHex from cStringIO import StringIO diff --git a/tools/device_management.py b/tools/device_management.py index 74a6c22edc..2ad7d26416 100644 --- a/tools/device_management.py +++ b/tools/device_management.py @@ -23,7 +23,6 @@ import logging import sys import argparse from os.path import join, abspath, dirname, basename -from os import getenv from manifesttool import create, parse, verify, cert, init, update from manifesttool.argparser import MainArgumentParser @@ -31,9 +30,6 @@ from mbed_cloud import AccountManagementAPI, CertificatesAPI import colorama colorama.init() -from utils import (generate_update_filename) - - LOG = logging.getLogger(__name__) LOG_FORMAT = '[%(levelname)s] %(asctime)s - %(name)s - %(message)s' @@ -43,6 +39,7 @@ sys.path.insert(0, ROOT) from tools.config import Config from tools.options import extract_mcus +from tools.utils import generate_update_filename class MbedExtendedArgs(MainArgumentParser): @@ -91,24 +88,30 @@ def wrap_payload(func): def wrap_init(func): def inner(options): - if getattr(options, 'api_key', None): - api_key = options.api_key - else: - api_key = getenv("MBED_CLOUD_SDK_API_KEY") - if getattr(options, 'server_address', None): - host_addr = options.server_address - else: - host_addr = getenv("MBED_CLOUD_SDK_HOST", - "https://api.us-east-1.mbedcloud.com/") - config = { - "api_key": api_key, - "host": host_addr, - } - accounts = AccountManagementAPI(config) - certs = CertificatesAPI(config) - api_key = accounts.list_api_keys(filter={ - 'key': api_key - }).next() + config = {} + if getattr(options, 'api_key'): + config["api_key"] = options.api_key + if getattr(options, 'server_address'): + config["host"] = options.server_address + + try: + accounts = AccountManagementAPI(config) + certs = CertificatesAPI(config) + except Exception as e: + LOG.error( + 'Missing api key. Set it with ' + '"mbed config -G CLOUD_SDK_API_KEY "' + ) + exit(1) + + # Get the currently in-use API key (may come from environment or + # configuration files, which is handled by the cloud SDK) + api_key_value = accounts.config.get("api_key") + api_key = accounts.list_api_keys( + filter={ + "key": api_key_value + } + ).next() certificates_owned = list(certs.list_certificates()) dev_cert_info = None for certif in certificates_owned: diff --git a/tools/export/cmake/__init__.py b/tools/export/cmake/__init__.py index 5cf7caa95d..67216544e1 100644 --- a/tools/export/cmake/__init__.py +++ b/tools/export/cmake/__init__.py @@ -44,7 +44,8 @@ class CMake(Exporter): "MCU_NRF51Code.binary_hook", "TEENSY3_1Code.binary_hook", "LPCTargetCode.lpc_patch", - "LPC4088Code.binary_hook" + "LPC4088Code.binary_hook", + "PSOC6Code.complete" ]) @classmethod @@ -83,7 +84,7 @@ class CMake(Exporter): 'include_paths': includes, 'library_paths': sorted([re.sub(r'^[.]/', '', l) for l in self.resources.lib_dirs]), 'linker_script': self.resources.linker_script, - 'hex_files': self.resources.hex_files, + 'hex_files': self.hex_files, 'ar': basename(self.toolchain.ar), 'cc': basename(self.toolchain.cc[0]), 'cc_flags': " ".join(flag for flag in self.toolchain.cc[1:] if not flag == "-c"), diff --git a/tools/export/exporters.py b/tools/export/exporters.py index 61e91f48a0..43504c6c13 100644 --- a/tools/export/exporters.py +++ b/tools/export/exporters.py @@ -1,4 +1,21 @@ -"""Just a template for subclassing""" +""" +Copyright (c) 2016-2019 ARM Limited. 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 + +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. +""" + import os from abc import abstractmethod, ABCMeta import logging @@ -12,6 +29,7 @@ from tools.targets import TARGET_MAP from tools.utils import mkdir from tools.resources import FileType +"""Just a template for subclassing""" class TargetNotSupportedException(Exception): """Indicates that an IDE does not support a particular MCU""" @@ -123,6 +141,15 @@ class Exporter(object): return [l for l in self.resources.get_file_names(FileType.LIB) if l.endswith(self.toolchain.LIBRARY_EXT)] + @property + def hex_files(self): + """Returns a list of hex files to include in the exported project""" + hex_files = self.resources.hex_files + if hasattr(self.toolchain.target, 'hex_filename'): + hex_filename = self.toolchain.target.hex_filename + hex_files = [f for f in hex_files if basename(f) == hex_filename] + return hex_files + def toolchain_flags(self, toolchain): """Returns a dictionary of toolchain flags. Keys of the dictionary are: diff --git a/tools/export/iar/iar_definitions.json b/tools/export/iar/iar_definitions.json index f5e588be61..5ef5b21a90 100644 --- a/tools/export/iar/iar_definitions.json +++ b/tools/export/iar/iar_definitions.json @@ -96,9 +96,6 @@ "LPC54628J512ET180": { "OGChipSelectEditMenu": "LPC54618J512\tNXP LPC54618J512" }, - "MIMXRT1052": { - "OGChipSelectEditMenu": "MIMXRT1052xxx6B\tNXP MIMXRT1052xxx6B" - }, "STM32F072RB": { "OGChipSelectEditMenu": "STM32F072RB\tST STM32F072RB" }, diff --git a/tools/export/makefile/__init__.py b/tools/export/makefile/__init__.py index c4d7412a0a..830c2cb252 100644 --- a/tools/export/makefile/__init__.py +++ b/tools/export/makefile/__init__.py @@ -84,11 +84,6 @@ class Makefile(Exporter): sys_libs = [self.prepare_sys_lib(lib) for lib in self.toolchain.sys_libs] - hex_files = self.resources.hex_files - if hasattr(self.toolchain.target, 'hex_filename'): - hex_filename = self.toolchain.target.hex_filename - hex_files = list(f for f in hex_files if basename(f) == hex_filename) - ctx = { 'name': self.project_name, 'to_be_compiled': to_be_compiled, @@ -98,7 +93,7 @@ class Makefile(Exporter): 'linker_script': self.resources.linker_script, 'libraries': libraries, 'ld_sys_libs': sys_libs, - 'hex_files': hex_files, + 'hex_files': self.hex_files, 'vpath': (["../../.."] if (basename(dirname(dirname(self.export_dir))) == "projectfiles") diff --git a/tools/export/mcuxpresso/__init__.py b/tools/export/mcuxpresso/__init__.py index 52e1f77c94..54a2db4313 100644 --- a/tools/export/mcuxpresso/__init__.py +++ b/tools/export/mcuxpresso/__init__.py @@ -1,6 +1,6 @@ """ mbed SDK -Copyright (c) 2011-2016 ARM Limited +Copyright (c) 2011-2019 ARM Limited Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -28,9 +28,10 @@ from builtins import str import copy import tempfile import shutil +import re from subprocess import Popen, PIPE -from os import getcwd, remove +from os import getcwd, remove, listdir from os.path import splitext, basename, exists from random import randint @@ -54,10 +55,19 @@ class MCUXpresso(GNUARMEclipse): MBED_CONFIG_HEADER_SUPPORTED = True + @staticmethod + def is_target_name_in_dir(path, target_name): + # toos/export/mcuxpresso/ has entries with + # both lower and upper case. Handle these inconsistencies. + for entry in listdir(path): + if(re.match(entry, target_name + '_cproject.tmpl', re.IGNORECASE)): + return True + return False + @classmethod def is_target_supported(cls, target_name): # target is supported when *_cproject.tmpl template file exists - if exists(cls.TEMPLATE_DIR + '/mcuxpresso/' + target_name + '_cproject.tmpl'): + if MCUXpresso.is_target_name_in_dir(cls.TEMPLATE_DIR + '/mcuxpresso/', target_name): target = TARGET_MAP[target_name] return apply_supported_whitelist( cls.TOOLCHAIN, POST_BINARY_WHITELIST, target) diff --git a/tools/export/vscode/__init__.py b/tools/export/vscode/__init__.py index 9cfa1f4836..5765adbb95 100644 --- a/tools/export/vscode/__init__.py +++ b/tools/export/vscode/__init__.py @@ -59,24 +59,37 @@ class VSCode(Makefile): continue if directory == ".": - all_directories.append("${workspaceRoot}/*") + all_directories.append("${workspaceFolder}/*") else: - all_directories.append(directory.replace("./", "${workspaceRoot}/") + "/*") + all_directories.append(directory.replace("./", "${workspaceFolder}/") + "/*") cpp_props = { "configurations": [ { "name": "Windows", - "includePath": [x.replace("/", "\\") for x in all_directories], + "forcedInclude": [ + "${workspaceFolder}/mbed_config.h" + ], + "compilerPath": self.toolchain.cppc[0], + "intelliSenseMode": "gcc-x64", + "includePath": all_directories, "defines": [symbol for symbol in self.toolchain.get_symbols()] }, { "name": "Mac", + "forcedInclude": [ + "${workspaceFolder}/mbed_config.h" + ], + "compilerPath": self.toolchain.cppc[0], "includePath": all_directories, "defines": [symbol for symbol in self.toolchain.get_symbols()] }, { "name": "Linux", + "forcedInclude": [ + "${workspaceFolder}/mbed_config.h" + ], + "compilerPath": self.toolchain.cppc[0], "includePath": all_directories, "defines": [symbol for symbol in self.toolchain.get_symbols()] } diff --git a/tools/host_tests/midi.py b/tools/host_tests/midi.py index 67f34ea6f8..3df89070b2 100644 --- a/tools/host_tests/midi.py +++ b/tools/host_tests/midi.py @@ -1,3 +1,21 @@ +""" +Copyright (c) 2016 ARM Limited. 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 + +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. +""" + from __future__ import print_function import sys import re @@ -69,4 +87,4 @@ try: test_midi_out_loopback(output_port,input_port) except KeyboardInterrupt: - pass \ No newline at end of file + pass diff --git a/tools/importer/importer.py b/tools/importer/importer.py index b093309e1d..f57de43af8 100644 --- a/tools/importer/importer.py +++ b/tools/importer/importer.py @@ -1,3 +1,21 @@ +""" +Copyright (c) 2017-2019 ARM Limited. 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 + +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. +""" + import os import json import sys diff --git a/tools/make.py b/tools/make.py index 606ed257f0..17802b5bb1 100644 --- a/tools/make.py +++ b/tools/make.py @@ -34,6 +34,7 @@ from tools.paths import MBED_LIBRARIES from tools.paths import RPC_LIBRARY from tools.paths import USB_LIBRARIES from tools.paths import DSP_LIBRARIES +from tools.paths import is_relative_to_root from tools.tests import TESTS, Test, TEST_MAP from tools.tests import TEST_MBED_LIB from tools.tests import test_known, test_name_known @@ -307,8 +308,9 @@ if __name__ == '__main__': args_error(parser, "argument -t/--tool is required") toolchain = options.tool[0] - if Target.get_target(mcu).is_PSA_secure_target: - options.source_dir = ROOT + if Target.get_target(mcu).is_PSA_secure_target and \ + not is_relative_to_root(options.source_dir): + options.source_dir = ROOT if (options.program is None) and (not options.source_dir): args_error(parser, "one of -p, -n, or --source is required") diff --git a/tools/memap.py b/tools/memap.py index 3691f89ce8..f6c4c4a81b 100644 --- a/tools/memap.py +++ b/tools/memap.py @@ -1,6 +1,22 @@ #!/usr/bin/env python -"""Memory Map File Analyser for ARM mbed""" +""" +Copyright (c) 2016-2019 ARM Limited. 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 + +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. +""" from __future__ import print_function, division, absolute_import from abc import abstractmethod, ABCMeta diff --git a/tools/misc/find_c_includes.py b/tools/misc/find_c_includes.py index e24c6d13c8..292412f7d2 100644 --- a/tools/misc/find_c_includes.py +++ b/tools/misc/find_c_includes.py @@ -1,5 +1,23 @@ #!/usr/bin/env python +""" +Copyright (c) 2016-2019 ARM Limited. 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 + +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. +""" + import os import re diff --git a/tools/misc/remove-device-h.py b/tools/misc/remove-device-h.py index 6e71ecb2f4..a7834f3856 100644 --- a/tools/misc/remove-device-h.py +++ b/tools/misc/remove-device-h.py @@ -1,3 +1,21 @@ +""" +Copyright (c) 2016-2019 ARM Limited. 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 + +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. +""" + import json import os import stat diff --git a/tools/paths.py b/tools/paths.py index c8e745b00b..d29eb15d96 100644 --- a/tools/paths.py +++ b/tools/paths.py @@ -14,7 +14,7 @@ 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. """ -from os.path import join +from os.path import join, commonprefix, realpath from os import getenv # Conventions about the directory structure @@ -85,3 +85,11 @@ CPPUTEST_TESTRUNNER_SCR = join(TEST_DIR, "utest", "testrunner") CPPUTEST_TESTRUNNER_INC = join(TEST_DIR, "utest", "testrunner") CPPUTEST_LIBRARY = join(BUILD_DIR, "cpputest") + + +def is_relative_to_root(dirs): + if not isinstance(dirs, list): + dirs = [dirs] + dirs = [realpath(d) for d in dirs] + out = commonprefix(dirs + [ROOT]) + return out == ROOT diff --git a/tools/project.py b/tools/project.py index 550c2eec3e..8002d41704 100644 --- a/tools/project.py +++ b/tools/project.py @@ -1,6 +1,21 @@ -""" The CLI entry point for exporting projects from the mbed tools to any of the -supported IDEs or project structures. """ +Copyright (c) 2016-2019 ARM Limited. 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 + +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 +""" + from __future__ import print_function, absolute_import from builtins import str @@ -39,6 +54,10 @@ from tools.utils import NotSupportedException from tools.options import extract_profile, list_profiles, extract_mcus from tools.notifier.term import TerminalNotifier +""" The CLI entry point for exporting projects from the mbed tools to any of the +supported IDEs or project structures. +""" + EXPORTER_ALIASES = { u'gcc_arm': u'make_gcc_arm', u'uvision': u'uvision5', diff --git a/tools/resources/__init__.py b/tools/resources/__init__.py index d1b948999d..5da087fa7d 100644 --- a/tools/resources/__init__.py +++ b/tools/resources/__init__.py @@ -38,7 +38,7 @@ from collections import namedtuple, defaultdict from copy import copy from itertools import chain from os import walk, sep -from os.path import (join, splitext, dirname, relpath, basename, split, normcase, +from os.path import (join, splitext, dirname, relpath, basename, split, normpath, abspath, exists) from .ignore import MbedIgnoreSet, IGNORE_FILENAME @@ -148,6 +148,11 @@ class Resources(object): self._ignoreset = MbedIgnoreSet() + # make sure mbed-os root is added as include directory + script_dir = dirname(abspath(__file__)) + mbed_os_root_dir = normpath(join(script_dir, '..', '..')) + self.add_file_ref(FileType.INC_DIR, mbed_os_root_dir, mbed_os_root_dir) + def ignore_dir(self, directory): if self._collect_ignores: self.ignored_dirs.append(directory) @@ -413,6 +418,7 @@ class Resources(object): ".h": FileType.HEADER, ".hh": FileType.HEADER, ".hpp": FileType.HEADER, + ".inc": FileType.HEADER, ".o": FileType.OBJECT, ".hex": FileType.HEX, ".bin": FileType.BIN, diff --git a/tools/targets/REALTEK_RTL8195AM.py b/tools/targets/REALTEK_RTL8195AM.py index 3dc1577e4e..a4eb02510f 100644 --- a/tools/targets/REALTEK_RTL8195AM.py +++ b/tools/targets/REALTEK_RTL8195AM.py @@ -147,7 +147,7 @@ def create_daplink(image_bin, ram1_bin, ram2_bin): RAM2_HEADER['tag'] = format_number(TAG, 8) RAM2_HEADER['ver'] = format_number(VER, 8) - RAM2_HEADER['timestamp'] = format_number(epoch_timestamp(), 16) + RAM2_HEADER['timestamp'] = format_number(int(os.environ.get('DAPLINK_TIMESTAMP', epoch_timestamp())), 16) RAM2_HEADER['size'] = format_number(os.stat(ram2_bin).st_size + 72, 8) RAM2_HEADER['hash'] = format_string(sha256_checksum(ram2_bin)) RAM2_HEADER['campaign'] = format_string(CAMPAIGN) diff --git a/tools/targets/__init__.py b/tools/targets/__init__.py index b083f74dd7..567c6380cc 100644 --- a/tools/targets/__init__.py +++ b/tools/targets/__init__.py @@ -427,7 +427,7 @@ class LPC4088Code(object): # Pad the fist part (internal flash) with 0xFF to 512k data = partf.read() outbin.write(data) - outbin.write('\xFF' * (512*1024 - len(data))) + outbin.write(b'\xFF' * (512*1024 - len(data))) partf.close() # Read and append the second part (external flash) in chunks of fixed # size @@ -470,7 +470,7 @@ class MTSCode(object): part = open(loader, 'rb') data = part.read() outbin.write(data) - outbin.write('\xFF' * (64*1024 - len(data))) + outbin.write(b'\xFF' * (64*1024 - len(data))) part.close() part = open(binf, 'rb') data = part.read() diff --git a/tools/test.py b/tools/test.py index 84bfd6bbbe..3e0996a2b1 100644 --- a/tools/test.py +++ b/tools/test.py @@ -45,6 +45,8 @@ from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS, TOOLCHAIN_CLASSES from tools.settings import CLI_COLOR_MAP from tools.settings import ROOT from tools.targets import Target +from tools.paths import is_relative_to_root + if __name__ == '__main__': try: # Parse Options @@ -211,7 +213,7 @@ if __name__ == '__main__': if not options.build_dir: args_error(parser, "argument --build is required") - if mcu_secured: + if mcu_secured and not is_relative_to_root(options.source_dir): base_source_paths = ROOT else: base_source_paths = options.source_dir diff --git a/tools/test/__init__.py b/tools/test/__init__.py index e69de29bb2..0119582f3f 100644 --- a/tools/test/__init__.py +++ b/tools/test/__init__.py @@ -0,0 +1,17 @@ +""" +Copyright (c) 2016-2019 ARM Limited. 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 + +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 +""" diff --git a/tools/test/examples/examples.py b/tools/test/examples/examples.py index 3fbeaa3acc..d3d698152d 100644 --- a/tools/test/examples/examples.py +++ b/tools/test/examples/examples.py @@ -1,4 +1,20 @@ -""" import and bulid a bunch of example programs """ +""" +Copyright (c) 2017-2019 ARM Limited. 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 + +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 +""" from argparse import ArgumentParser import os @@ -8,6 +24,8 @@ import sys import subprocess import json +""" import and bulid a bunch of example programs """ + ROOT = abspath(dirname(dirname(dirname(dirname(__file__))))) sys.path.insert(0, ROOT) diff --git a/tools/test/examples/examples_lib.py b/tools/test/examples/examples_lib.py index 308fb87c75..89e488a8a5 100644 --- a/tools/test/examples/examples_lib.py +++ b/tools/test/examples/examples_lib.py @@ -1,9 +1,20 @@ -""" Import and bulid a bunch of example programs +""" +Copyright (c) 2017-2019 ARM Limited. All rights reserved. - This library includes functions that are shared between the examples.py and - the update.py modules. +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 + +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 +""" import os from os.path import dirname, abspath, basename import os.path @@ -11,6 +22,13 @@ import sys import subprocess from shutil import rmtree +""" Import and bulid a bunch of example programs + + This library includes functions that are shared between the examples.py and + the update.py modules. + + """ + ROOT = abspath(dirname(dirname(dirname(dirname(__file__))))) sys.path.insert(0, ROOT) @@ -425,4 +443,4 @@ def update_mbedos_version(config, tag, examples): return result return 0 - \ No newline at end of file + diff --git a/tools/test/memap/parse_test.py b/tools/test/memap/parse_test.py index 6ed7ecd7e5..e3bb7ed5ec 100644 --- a/tools/test/memap/parse_test.py +++ b/tools/test/memap/parse_test.py @@ -1,3 +1,21 @@ +""" +Copyright (c) 2018-2019 ARM Limited. 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 + +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 +""" + import sys from io import open from os import sep diff --git a/tools/test/pylint.py b/tools/test/pylint.py index 9fc43ae18b..dc986eaab3 100644 --- a/tools/test/pylint.py +++ b/tools/test/pylint.py @@ -1,9 +1,27 @@ -"""A test that all code scores above a 9.25 in pylint""" +""" +Copyright (c) 2016-2019 ARM Limited. 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 + +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 +""" import subprocess import re import os.path +"""A test that all code scores above a 9.25 in pylint""" + SCORE_REGEXP = re.compile( r'^Your\ code\ has\ been\ rated\ at\ (\-?[0-9\.]+)/10') diff --git a/tools/test/spm/__init__.py b/tools/test/spm/__init__.py index e69de29bb2..982d7317e5 100644 --- a/tools/test/spm/__init__.py +++ b/tools/test/spm/__init__.py @@ -0,0 +1,17 @@ +""" +Copyright (c) 2019 ARM Limited. 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 + +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 +""" diff --git a/tools/test/toolchains/api_test.py b/tools/test/toolchains/api_test.py index f48ea1dc0d..fded2c672e 100644 --- a/tools/test/toolchains/api_test.py +++ b/tools/test/toolchains/api_test.py @@ -1,4 +1,21 @@ -"""Tests for the toolchain sub-system""" +""" +Copyright (c) 2017-2019 ARM Limited. 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 + +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 +""" + import sys import os from string import printable @@ -7,6 +24,8 @@ from mock import MagicMock, patch from hypothesis import given, settings, HealthCheck from hypothesis.strategies import text, lists, fixed_dictionaries, booleans +"""Tests for the toolchain sub-system""" + ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..")) sys.path.insert(0, ROOT) diff --git a/tools/test/toolchains/arm_support_test.py b/tools/test/toolchains/arm_support_test.py index b32bd7ab82..e0f5aa6b64 100644 --- a/tools/test/toolchains/arm_support_test.py +++ b/tools/test/toolchains/arm_support_test.py @@ -1,4 +1,21 @@ -"""Tests for the arm toolchain supported checks""" +""" +Copyright (c) 2016-2019 ARM Limited. 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 + +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 +""" + import sys import os from string import printable @@ -7,6 +24,8 @@ from mock import MagicMock, patch from hypothesis import given, settings from hypothesis.strategies import text, lists, sampled_from +"""Tests for the arm toolchain supported checks""" + ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..")) sys.path.insert(0, ROOT) diff --git a/tools/test_configs/__init__.py b/tools/test_configs/__init__.py index e397374339..5d40db4066 100644 --- a/tools/test_configs/__init__.py +++ b/tools/test_configs/__init__.py @@ -1,3 +1,21 @@ +""" +Copyright (c) 2018-2019 ARM Limited. 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 + +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 +""" + from os.path import dirname, abspath, join, exists from tools.utils import json_file_to_dict diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index 6595538f8d..cc1b6e21a9 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -571,7 +571,7 @@ class mbedToolchain: def compile_output(self, output=[]): _rc = output[0] - _stderr = output[1].decode("utf-8") + _stderr = output[1] command = output[2] # Parse output for Warnings and Errors diff --git a/tools/toolchains/arm.py b/tools/toolchains/arm.py index dd87038aa0..874f488dc0 100644 --- a/tools/toolchains/arm.py +++ b/tools/toolchains/arm.py @@ -481,14 +481,13 @@ class ARMC6(ARM_STD): def get_compile_options(self, defines, includes, for_asm=False): opts = ['-D%s' % d for d in defines] opts.extend(["-I%s" % i for i in includes if i]) + config_header = self.get_config_header() + if config_header: + opts.extend(self.get_config_option(config_header)) if for_asm: return ["--cpreproc", "--cpreproc_opts=%s" % ",".join(self.flags['common'] + opts)] - else: - config_header = self.get_config_header() - if config_header: - opts.extend(self.get_config_option(config_header)) - return opts + return opts @hook_tool def assemble(self, source, object, includes): diff --git a/tools/utils.py b/tools/utils.py index ad5db06fdf..37d6c885f7 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -495,10 +495,12 @@ def argparse_profile_filestring_type(string): absolute path or a file name (expanded to mbed-os/tools/profiles/.json) of a existing file""" fpath = join(dirname(__file__), "profiles/{}.json".format(string)) - if exists(string): - return string - elif exists(fpath): + + # default profiles are searched first, local ones next. + if exists(fpath): return fpath + elif exists(string): + return string else: raise argparse.ArgumentTypeError( "{0} does not exist in the filesystem.".format(string))