From 086e0c239d3c82c94863b387865e70327640d205 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 8 Apr 2014 15:31:16 +0100 Subject: [PATCH 1/8] Added NET_1 and NET_2 (TCP / UDP client) automated tests to test suite --- .../tests/net/helloworld/tcpclient/main.cpp | 56 ++++++++++++++----- .../tests/net/helloworld/udpclient/main.cpp | 48 +++++++++++----- workspace_tools/tests.py | 10 +++- 3 files changed, 84 insertions(+), 30 deletions(-) diff --git a/libraries/tests/net/helloworld/tcpclient/main.cpp b/libraries/tests/net/helloworld/tcpclient/main.cpp index 5c5f7c79e3..8be303513b 100644 --- a/libraries/tests/net/helloworld/tcpclient/main.cpp +++ b/libraries/tests/net/helloworld/tcpclient/main.cpp @@ -1,31 +1,61 @@ +#include #include "mbed.h" #include "EthernetInterface.h" +#include "test_env.h" + +namespace { + const char *HTTP_SERVER_NAME = "mbed.org"; + const int HTTP_SERVER_PORT = 80; + const int RECV_BUFFER_SIZE = 512; + + // Test related data + const char *HTTP_OK_STR = "200 OK"; + const char *HTTP_HELLO_STR = "Hello world!"; +} + +bool find_substring(const char *first, const char *last, const char *s_first, const char *s_last) { + const char *f = std::search(first, last, s_first, s_last); + return (f != last); +} int main() { EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); - printf("IP Address is %s\n", eth.getIPAddress()); - + printf("TCP client IP Address is %s\n", eth.getIPAddress()); + TCPSocketConnection sock; - sock.connect("mbed.org", 80); - + sock.connect(HTTP_SERVER_NAME, HTTP_SERVER_PORT); + char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n"; sock.send_all(http_cmd, sizeof(http_cmd)); - - char buffer[300]; - int ret; + + char buffer[RECV_BUFFER_SIZE] = {0}; + bool result = true; while (true) { - ret = sock.receive(buffer, sizeof(buffer)-1); + const int ret = sock.receive(buffer, sizeof(buffer) - 1); if (ret <= 0) break; buffer[ret] = '\0'; - printf("Received %d chars from server:\n%s\n", ret, buffer); + + // Find 200 OK HTTP status in reply + bool found_200_ok = find_substring(buffer, buffer + ret, HTTP_OK_STR, HTTP_OK_STR + strlen(HTTP_OK_STR)); + result = result && found_200_ok; + + // Find Hello World! in reply + bool found_hello = find_substring(buffer, buffer + ret, HTTP_HELLO_STR, HTTP_HELLO_STR + strlen(HTTP_HELLO_STR)); + result = result && found_hello; + + // Print results + printf("HTTP: Received %d chars from server\r\n", ret); + printf("HTTP: Received 200 OK status ... %s\r\n", found_200_ok ? "[OK]" : "[FAIL]"); + printf("HTTP: Received '%s' status ... %s\r\n", HTTP_HELLO_STR, found_hello ? "[OK]" : "[FAIL]"); + printf("HTTP: Received massage:\r\n\r\n"); + printf("%s", buffer); } - + sock.close(); - eth.disconnect(); - - while(1) {} + notify_completion(result); + return 0; } diff --git a/libraries/tests/net/helloworld/udpclient/main.cpp b/libraries/tests/net/helloworld/udpclient/main.cpp index a6d3c822ad..0cc446d31e 100644 --- a/libraries/tests/net/helloworld/udpclient/main.cpp +++ b/libraries/tests/net/helloworld/udpclient/main.cpp @@ -1,28 +1,48 @@ #include "mbed.h" #include "EthernetInterface.h" - +#include "test_env.h" + +namespace { + const char *HTTP_SERVER_NAME = "utcnist.colorado.edu"; + const int HTTP_SERVER_PORT = 37; +} + int main() { + bool result = false; EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); - + printf("UDP client IP Address is %s\n", eth.getIPAddress()); + UDPSocket sock; sock.init(); - + Endpoint nist; - nist.set_address("utcnist.colorado.edu", 37); - + nist.set_address(HTTP_SERVER_NAME, HTTP_SERVER_PORT); + char out_buffer[] = "plop"; // Does not matter sock.sendTo(nist, out_buffer, sizeof(out_buffer)); - - char in_buffer[4]; - int n = sock.receiveFrom(nist, in_buffer, sizeof(in_buffer)); - - unsigned int timeRes = ntohl( *((unsigned int*)in_buffer)); - printf("Received %d bytes from server %s on port %d: %u seconds since 1/01/1900 00:00 GMT\n", n, nist.get_address(), nist.get_port(), timeRes); - + + union { + char in_buffer_tab[4]; + unsigned int in_buffer_uint; + }; + + const int n = sock.receiveFrom(nist, in_buffer_tab, sizeof(in_buffer_tab)); + if (n > 0) { + const unsigned int timeRes = ntohl(in_buffer_uint); + const float years = timeRes / 60.0 / 60.0 / 24.0 / 365; + printf("UDP: Received %d bytes from server %s on port %d\r\n", n, nist.get_address(), nist.get_port()); + printf("UDP: %u seconds since 01/01/1900 00:00 GMT ... %s\r\n", timeRes, timeRes > 0 ? "[OK]" : "[FAIL]"); + printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > 114.0 ? "[OK]" : "[FAIL]"); + result = true; + + if (years < 114.0) { + result = false; + } + } sock.close(); - eth.disconnect(); - while(1) {} + notify_completion(result); + return 0; } diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index aec4ba51c7..54659a8695 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -323,7 +323,7 @@ TESTS = [ "source_dir": join(TEST_DIR, "mbed", "hello"), "dependencies": [MBED_LIBRARIES], "automated": True, - "host_test": "hello_auto", + "host_test": "hello_auto", }, { "id": "MBED_11", "description": "Ticker Int", @@ -572,12 +572,16 @@ TESTS = [ { "id": "NET_1", "description": "TCP client hello world", "source_dir": join(TEST_DIR, "net", "helloworld", "tcpclient"), - "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], + "duration": 15, + "automated": True, }, { "id": "NET_2", "description": "UDP client hello world", "source_dir": join(TEST_DIR, "net", "helloworld", "udpclient"), - "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], + "duration": 15, + "automated": True, }, { "id": "NET_3", "description": "TCP echo server", From 136b042f0271180f8e8371dab452658c7347d4d8 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 8 Apr 2014 16:01:00 +0100 Subject: [PATCH 2/8] Added new functionality: now you can use -P switch to test MUT's peripherals only --- workspace_tools/singletest.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/workspace_tools/singletest.py b/workspace_tools/singletest.py index 311136b059..e147adf9f9 100644 --- a/workspace_tools/singletest.py +++ b/workspace_tools/singletest.py @@ -472,6 +472,12 @@ if __name__ == '__main__': action="store_true", help='Prints information about all tests and exits') + parser.add_option('-P', '--only-peripheral', + dest='test_only_peripheral', + default=False, + action="store_true", + help='Test only peripheral declared for MUT and skip common tests') + parser.add_option('-v', '--verbose', dest='verbose', default=False, @@ -527,6 +533,11 @@ if __name__ == '__main__': if test_ids and test_id not in test_ids: continue + if opts.test_only_peripheral and not test.peripherals: + if opts.verbose: + print "TargetTest::%s::NotPeripheralTestSkipped(%s)" % (target, ",".join(test.peripherals)) + continue + if test.automated and test.is_supported(target, toolchain): if not is_peripherals_available(target, test.peripherals): if opts.verbose: From d113ee74720ba367de7c9cce5a9341275cf839cb Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 8 Apr 2014 16:01:57 +0100 Subject: [PATCH 3/8] Added 'ethernet' peripheral dependency to all NET_x tests --- workspace_tools/tests.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 54659a8695..e7ef598596 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -575,6 +575,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], "duration": 15, "automated": True, + "peripherals": ["ethernet"], }, { "id": "NET_2", "description": "UDP client hello world", @@ -582,6 +583,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], "duration": 15, "automated": True, + "peripherals": ["ethernet"], }, { "id": "NET_3", "description": "TCP echo server", @@ -589,7 +591,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], "automated": True, "host_test" : "tcpecho_server_auto", - "peripherals": ["ethernet"] + "peripherals": ["ethernet"], }, { "id": "NET_4", "description": "TCP echo client", @@ -634,26 +636,31 @@ TESTS = [ "id": "NET_9", "description": "Multicast Send", "source_dir": join(TEST_DIR, "net", "helloworld", "multicast_send"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "peripherals": ["ethernet"], }, { "id": "NET_10", "description": "Multicast Receive", "source_dir": join(TEST_DIR, "net", "helloworld", "multicast_receive"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "peripherals": ["ethernet"], }, { "id": "NET_11", "description": "Broadcast Send", "source_dir": join(TEST_DIR, "net", "helloworld", "broadcast_send"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "peripherals": ["ethernet"], }, { "id": "NET_12", "description": "Broadcast Receive", "source_dir": join(TEST_DIR, "net", "helloworld", "broadcast_receive"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "peripherals": ["ethernet"], }, { "id": "NET_13", "description": "TCP client echo loop", "source_dir": join(TEST_DIR, "net", "echo", "tcp_client_loop"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "peripherals": ["ethernet"], }, # u-blox tests From 72c1b9c12a5406b62308334c76c3c905c75b42ba Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 9 Apr 2014 11:32:44 +0100 Subject: [PATCH 4/8] Added EXAMPLE_1 /dev/null redirection host test to automation suite --- libraries/tests/mbed/dev_null/main.cpp | 17 ++++------ workspace_tools/host_tests/dev_null_auto.py | 37 +++++++++++++++++++++ workspace_tools/tests.py | 4 ++- 3 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 workspace_tools/host_tests/dev_null_auto.py diff --git a/libraries/tests/mbed/dev_null/main.cpp b/libraries/tests/mbed/dev_null/main.cpp index eeaf5ecba2..ee43645da3 100644 --- a/libraries/tests/mbed/dev_null/main.cpp +++ b/libraries/tests/mbed/dev_null/main.cpp @@ -1,9 +1,10 @@ #include "mbed.h" +#include "test_env.h" class DevNull : public Stream { public: - DevNull(const char *name=NULL) : Stream(name) {} + DevNull(const char *name = NULL) : Stream(name) {} protected: virtual int _getc() {return 0;} @@ -13,14 +14,10 @@ protected: DevNull null("null"); int main() { - printf("re-routing stdout to /null\n"); - + printf("MBED: re-routing stdout to /null\n"); freopen("/null", "w", stdout); - printf("printf redirected to /null\n"); - - DigitalOut led(LED1); - while (true) { - led = !led; - wait(1); - } + printf("MBED: printf redirected to /null\n"); // This shouldn't appear + // If failure message can be seen test should fail :) + notify_completion(false); // This is 'false' on purpose + return 0; } diff --git a/workspace_tools/host_tests/dev_null_auto.py b/workspace_tools/host_tests/dev_null_auto.py new file mode 100644 index 0000000000..64d37b5eae --- /dev/null +++ b/workspace_tools/host_tests/dev_null_auto.py @@ -0,0 +1,37 @@ +""" +mbed SDK +Copyright (c) 2011-2013 ARM Limited + +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 host_test import Test, DefaultTest +from sys import stdout + +class DevNullTest(DefaultTest): + + def print_result(self, result): + print "\n{%s}\n{end}" % result + + def run(self): + test_result = True + c = self.mbed.serial.read(512) + print "Received %d bytes" % len(c) + if "{failure}" not in c: + self.print_result('success') + else: + self.print_result('failure') + stdout.flush() + +if __name__ == '__main__': + DevNullTest().run() diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index e7ef598596..9f42c58643 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -767,7 +767,9 @@ TESTS = [ { "id": "EXAMPLE_1", "description": "/dev/null", "source_dir": join(TEST_DIR, "mbed", "dev_null"), - "dependencies": [MBED_LIBRARIES], + "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], + "automated": True, + "host_test" : "dev_null_auto", }, { "id": "EXAMPLE_2", "description": "FS + RTOS", From d053a335ab7d29c7af8ff428b363e64baeec23e9 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 9 Apr 2014 11:33:57 +0100 Subject: [PATCH 5/8] Added 75% treshhold for test groups progress bars. In -r option --- workspace_tools/singletest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/workspace_tools/singletest.py b/workspace_tools/singletest.py index e147adf9f9..a94ef4d62d 100644 --- a/workspace_tools/singletest.py +++ b/workspace_tools/singletest.py @@ -426,6 +426,8 @@ def get_result_summary_table(): percent_progress = round(100.0 * counter_dict_test_id_types[unique_id] / float(counter_dict_test_id_types_all[unique_id]), 2) step = int(percent_progress / 2) str_progress = '#' * step + '.' * int(50 - step) + c = '!' if str_progress[38] == '.' else '|' + str_progress = str_progress[:38] + c + str_progress[38:] row = [unique_id, counter_dict_test_id_types[unique_id], counter_dict_test_id_types_all[unique_id], From 001b2fa959640eaa41f79e0ce5b1a0a88cd5bd52 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 9 Apr 2014 13:00:45 +0100 Subject: [PATCH 6/8] Small testing script refactoring --- workspace_tools/singletest.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/workspace_tools/singletest.py b/workspace_tools/singletest.py index a94ef4d62d..2376142fe9 100644 --- a/workspace_tools/singletest.py +++ b/workspace_tools/singletest.py @@ -424,10 +424,7 @@ def get_result_summary_table(): for unique_id in unique_test_id: # print "\t\t%s: %d / %d" % (unique_id, counter_dict_test_id_types[unique_id], counter_dict_test_id_types_all[unique_id]) percent_progress = round(100.0 * counter_dict_test_id_types[unique_id] / float(counter_dict_test_id_types_all[unique_id]), 2) - step = int(percent_progress / 2) - str_progress = '#' * step + '.' * int(50 - step) - c = '!' if str_progress[38] == '.' else '|' - str_progress = str_progress[:38] + c + str_progress[38:] + str_progress = progress_bar(percent_progress, 75) row = [unique_id, counter_dict_test_id_types[unique_id], counter_dict_test_id_types_all[unique_id], @@ -437,6 +434,17 @@ def get_result_summary_table(): print pt +def progress_bar(percent_progress, saturation=0): + """ This function creates progress bar with optional simple saturation mark""" + step = int(percent_progress / 2) # Scale by to (scale: 1 - 50) + str_progress = '#' * step + '.' * int(50 - step) + c = '!' if str_progress[38] == '.' else '|' + if (saturation > 0): + saturation = saturation / 2 + str_progress = str_progress[:saturation] + c + str_progress[saturation:] + return str_progress + + if __name__ == '__main__': # Command line options parser = optparse.OptionParser() @@ -487,7 +495,7 @@ if __name__ == '__main__': help='Verbose mode (pronts some extra information)') parser.description = """This script allows you to run mbed defined test cases for particular MCU(s) and corresponding toolchain(s).""" - parser.epilog = """Example: singletest.py -i test_spec.json [-M muts_all.json]""" + parser.epilog = """Example: singletest.py -i test_spec.json -M muts_all.json""" (opts, args) = parser.parse_args() From 93d3a4f6f831ee70e3e18051665f6cf6aeb5794f Mon Sep 17 00:00:00 2001 From: bcostm Date: Fri, 11 Apr 2014 08:47:56 +0200 Subject: [PATCH 7/8] [NUCLEO_F302R8] Implement analogout_free function This code was missing + make some typo corrections. --- .../TARGET_NUCLEO_F302R8/analogout_api.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogout_api.c index cd768bc739..cb34f694e6 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogout_api.c @@ -33,7 +33,7 @@ #include "pinmap.h" #include "error.h" -#define RANGE_12BIT (0xFFF) +#define DAC_RANGE (0xFFF) // 12 bits static const PinMap PinMap_DAC[] = { {PA_4, DAC_1, STM_PIN_DATA(GPIO_Mode_AN, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)}, // DAC_OUT1 @@ -56,7 +56,7 @@ void analogout_init(dac_t *obj, PinName pin) { // Configure GPIO pinmap_pinout(pin, PinMap_DAC); - // Save the channel for the write and read functions + // Save the channel for future use obj->channel = pin; // Enable DAC clock @@ -71,6 +71,12 @@ void analogout_init(dac_t *obj, PinName pin) { } void analogout_free(dac_t *obj) { + DAC_TypeDef *dac = (DAC_TypeDef *)(obj->dac); + // Disable DAC + DAC_DeInit(dac); + RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, DISABLE); + // Configure GPIO + pin_function(obj->channel, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF)); } static inline void dac_write(dac_t *obj, uint16_t value) { @@ -87,15 +93,15 @@ void analogout_write(dac_t *obj, float value) { if (value < 0.0f) { dac_write(obj, 0); // Min value } else if (value > 1.0f) { - dac_write(obj, (uint16_t)RANGE_12BIT); // Max value + dac_write(obj, (uint16_t)DAC_RANGE); // Max value } else { - dac_write(obj, (uint16_t)(value * (float)RANGE_12BIT)); + dac_write(obj, (uint16_t)(value * (float)DAC_RANGE)); } } void analogout_write_u16(dac_t *obj, uint16_t value) { - if (value > (uint16_t)RANGE_12BIT) { - dac_write(obj, (uint16_t)RANGE_12BIT); // Max value + if (value > (uint16_t)DAC_RANGE) { + dac_write(obj, (uint16_t)DAC_RANGE); // Max value } else { dac_write(obj, value); } @@ -103,7 +109,7 @@ void analogout_write_u16(dac_t *obj, uint16_t value) { float analogout_read(dac_t *obj) { uint32_t value = dac_read(obj); - return (float)value * (1.0f / (float)RANGE_12BIT); + return (float)((float)value * (1.0f / (float)DAC_RANGE)); } uint16_t analogout_read_u16(dac_t *obj) { From 90e883a43da46f86596b88b526e4e957c4a9d211 Mon Sep 17 00:00:00 2001 From: bcostm Date: Fri, 18 Apr 2014 16:18:45 +0200 Subject: [PATCH 8/8] [NUCLEO_F302R8] Move SetSysClock() in mbed_sdk_init() + minor modifications --- .../TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.c | 6 ------ .../TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.h | 1 + .../hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c | 2 +- .../hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_irq_api.c | 1 - .../targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c | 2 +- .../hal/TARGET_STM/TARGET_NUCLEO_F302R8/mbed_overrides.c | 7 +++++-- .../hal/TARGET_STM/TARGET_NUCLEO_F302R8/pwmout_api.c | 4 ++++ .../targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/rtc_api.c | 4 ++++ .../hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c | 5 +++++ .../targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/sleep.c | 8 +++++--- 10 files changed, 26 insertions(+), 14 deletions(-) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.c index fb191f7aa8..c072384964 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.c @@ -153,8 +153,6 @@ __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9} * @{ */ -void SetSysClock(void); - #if (USE_PLL_HSE_XTAL != 0) || (USE_PLL_HSE_EXTC != 0) uint8_t SetSysClock_PLL_HSE(uint8_t bypass); #endif @@ -208,10 +206,6 @@ void SystemInit(void) /* Disable all interrupts */ RCC->CIR = 0x00000000; - /* Configure the System clock source, PLL Multiplier and Divider factors, - AHB/APBx prescalers and Flash settings */ - SetSysClock(); - /* 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 */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.h index e624e7e476..dc47b3b53f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.h @@ -65,6 +65,7 @@ extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Cloc extern void SystemInit(void); extern void SystemCoreClockUpdate(void); +extern void SetSysClock(void); /** * @} diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c index 1733895d99..f0467de01f 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c @@ -26,10 +26,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "analogin_api.h" -#include "wait_api.h" #if DEVICE_ANALOGIN +#include "wait_api.h" #include "cmsis.h" #include "pinmap.h" #include "error.h" diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_irq_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_irq_api.c index f729c93d81..9bdac95a88 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_irq_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_irq_api.c @@ -29,7 +29,6 @@ */ #include #include "cmsis.h" - #include "gpio_irq_api.h" #include "pinmap.h" #include "error.h" diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c index c6e24a6e91..7a2c93962d 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c @@ -100,7 +100,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { void i2c_frequency(i2c_t *obj, int hz) { I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c); I2C_InitTypeDef I2C_InitStructure; - uint32_t tim; + uint32_t tim = 0; // Disable the Fast Mode Plus capability RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); // Enable SYSCFG clock diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/mbed_overrides.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/mbed_overrides.c index c0218bb69c..699c5ad678 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/mbed_overrides.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/mbed_overrides.c @@ -25,11 +25,14 @@ * 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. */ - -extern void SystemCoreClockUpdate(void); +#include "cmsis.h" // This function is called after RAM initialization and before main. void mbed_sdk_init() { + /* Configure the System clock source, PLL Multiplier and Divider factors, + AHB/APBx prescalers and Flash settings */ + SetSysClock(); + // Update the SystemCoreClock variable. SystemCoreClockUpdate(); } diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pwmout_api.c index 1d83cdb6e2..a371e8ee15 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pwmout_api.c @@ -29,6 +29,8 @@ */ #include "pwmout_api.h" +#if DEVICE_PWMOUT + #include "cmsis.h" #include "pinmap.h" #include "error.h" @@ -275,3 +277,5 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) { float value = (float)us / (float)obj->period; pwmout_write(obj, value); } + +#endif diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/rtc_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/rtc_api.c index 76720b00f4..3964ac58d3 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/rtc_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/rtc_api.c @@ -29,6 +29,8 @@ */ #include "rtc_api.h" +#if DEVICE_RTC + static int rtc_inited = 0; void rtc_init(void) { @@ -136,3 +138,5 @@ void rtc_write(time_t t) { RTC_SetTime(RTC_Format_BIN, &timeStruct); PWR_BackupAccessCmd(DISABLE); // Disable access to RTC } + +#endif diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c index b7a8181240..89907255f5 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c @@ -28,6 +28,9 @@ ******************************************************************************* */ #include "serial_api.h" + +#if DEVICE_SERIAL + #include "cmsis.h" #include "pinmap.h" #include "error.h" @@ -309,3 +312,5 @@ void serial_break_clear(serial_t *obj) { USART_RequestCmd(usart, USART_Request_SBKRQ, DISABLE); USART_ClearFlag(usart, USART_FLAG_SBK); } + +#endif diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/sleep.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/sleep.c index 2ce5b2ecf9..4d08154151 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/sleep.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/sleep.c @@ -28,10 +28,10 @@ ******************************************************************************* */ #include "sleep_api.h" -#include "cmsis.h" -// This function is in the system_stm32f30x.c file -extern void SetSysClock(void); +#if DEVICE_SLEEP + +#include "cmsis.h" // MCU SLEEP mode void sleep(void) { @@ -53,3 +53,5 @@ void deepsleep(void) { // After wake-up from STOP reconfigure the PLL SetSysClock(); } + +#endif