Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed X_NUCLEO_IDB0XA1 BLE_API
Fork of BlueNRG-MS-Stack-Updater by
BlueNRG-MS Stack Updater
This program allows to update BlueNRG-MS (X-NUCLEO-IDB05A1) stack image.
It programs BlueNRG-MS with the latest version of stack image provided through a C array: img73.c
The target firmware version is 7.3 (BLE 4.2 compliance). If the update is successful, LED1 blinks slowly; on error, LED1 blinks fast.
Tested platforms
Note
This application should not be used to update the stack image of BlueNRG (X-NUCLEO-IDB04A1) component which is considered deprecated.
main.cpp@1:d4887d7f5e85, 2016-06-17 (annotated)
- Committer:
- avilei
- Date:
- Fri Jun 17 16:50:10 2016 +0000
- Revision:
- 1:d4887d7f5e85
- Parent:
- 0:872cf47093cf
- Child:
- 3:623d051e9eb6
Increase LED blinking speed on error
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| avilei | 0:872cf47093cf | 1 | /* mbed Microcontroller Library |
| avilei | 0:872cf47093cf | 2 | * Copyright (c) 2006-2015 ARM Limited |
| avilei | 0:872cf47093cf | 3 | * |
| avilei | 0:872cf47093cf | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| avilei | 0:872cf47093cf | 5 | * you may not use this file except in compliance with the License. |
| avilei | 0:872cf47093cf | 6 | * You may obtain a copy of the License at |
| avilei | 0:872cf47093cf | 7 | * |
| avilei | 0:872cf47093cf | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| avilei | 0:872cf47093cf | 9 | * |
| avilei | 0:872cf47093cf | 10 | * Unless required by applicable law or agreed to in writing, software |
| avilei | 0:872cf47093cf | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| avilei | 0:872cf47093cf | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| avilei | 0:872cf47093cf | 13 | * See the License for the specific language governing permissions and |
| avilei | 0:872cf47093cf | 14 | * limitations under the License. |
| avilei | 0:872cf47093cf | 15 | */ |
| avilei | 0:872cf47093cf | 16 | |
| avilei | 0:872cf47093cf | 17 | #include "mbed.h" |
| avilei | 0:872cf47093cf | 18 | #include "BlueNRGDevice.h" |
| avilei | 0:872cf47093cf | 19 | |
| avilei | 0:872cf47093cf | 20 | #define BLUENRG_MS_HW_VERSION (0x31) |
| avilei | 0:872cf47093cf | 21 | |
| avilei | 0:872cf47093cf | 22 | #include "img72a.c" |
| avilei | 0:872cf47093cf | 23 | |
| avilei | 0:872cf47093cf | 24 | DigitalOut led1(LED1); |
| avilei | 0:872cf47093cf | 25 | |
| avilei | 0:872cf47093cf | 26 | |
| avilei | 0:872cf47093cf | 27 | void error_loop(void) |
| avilei | 0:872cf47093cf | 28 | { |
| avilei | 0:872cf47093cf | 29 | // Blink fast to signal error condition |
| avilei | 0:872cf47093cf | 30 | while (1) { |
| avilei | 0:872cf47093cf | 31 | led1 = !led1; |
| avilei | 1:d4887d7f5e85 | 32 | wait_ms(80); |
| avilei | 0:872cf47093cf | 33 | } |
| avilei | 0:872cf47093cf | 34 | } |
| avilei | 0:872cf47093cf | 35 | |
| avilei | 0:872cf47093cf | 36 | |
| avilei | 0:872cf47093cf | 37 | int main(void) |
| avilei | 0:872cf47093cf | 38 | { |
| avilei | 0:872cf47093cf | 39 | uint8_t hw_version; |
| avilei | 0:872cf47093cf | 40 | uint8_t get_hw_version_status; |
| avilei | 0:872cf47093cf | 41 | int update_status; |
| avilei | 0:872cf47093cf | 42 | BlueNRGDevice* bleDevice; |
| avilei | 0:872cf47093cf | 43 | |
| avilei | 0:872cf47093cf | 44 | // Keep LED1 turned on to show that update is in progress |
| avilei | 0:872cf47093cf | 45 | led1 = 1; |
| avilei | 0:872cf47093cf | 46 | |
| avilei | 0:872cf47093cf | 47 | bleDevice = (BlueNRGDevice*) createBLEInstance(); |
| avilei | 0:872cf47093cf | 48 | get_hw_version_status = bleDevice->getUpdaterHardwareVersion(&hw_version); |
| avilei | 0:872cf47093cf | 49 | |
| avilei | 0:872cf47093cf | 50 | if (get_hw_version_status != BLE_STATUS_SUCCESS) { |
| avilei | 0:872cf47093cf | 51 | printf("ERROR: Unable to get HW version\n\r"); |
| avilei | 0:872cf47093cf | 52 | error_loop(); |
| avilei | 0:872cf47093cf | 53 | } |
| avilei | 0:872cf47093cf | 54 | |
| avilei | 0:872cf47093cf | 55 | if ( (hw_version < BLUENRG_MS_HW_VERSION) || (hw_version > BLUENRG_MS_HW_VERSION) ) { |
| avilei | 0:872cf47093cf | 56 | printf("Sorry, you're HW version is not supported\n\r"); |
| avilei | 0:872cf47093cf | 57 | error_loop(); |
| avilei | 0:872cf47093cf | 58 | } |
| avilei | 0:872cf47093cf | 59 | |
| avilei | 0:872cf47093cf | 60 | printf("Start updating BlueNRG-MS firmware...\n\r"); |
| avilei | 0:872cf47093cf | 61 | |
| avilei | 0:872cf47093cf | 62 | update_status = bleDevice->updateFirmware(fw_image, sizeof(fw_image)); |
| avilei | 0:872cf47093cf | 63 | |
| avilei | 0:872cf47093cf | 64 | if (update_status != BLE_STATUS_SUCCESS) { |
| avilei | 0:872cf47093cf | 65 | printf("ERROR: Unable to update firmware\n\r"); |
| avilei | 0:872cf47093cf | 66 | error_loop(); |
| avilei | 0:872cf47093cf | 67 | } |
| avilei | 0:872cf47093cf | 68 | |
| avilei | 0:872cf47093cf | 69 | printf("Firmware updated successfully!\n\r"); |
| avilei | 0:872cf47093cf | 70 | // Blink slowly to signal successful firmware update |
| avilei | 0:872cf47093cf | 71 | while (1) { |
| avilei | 0:872cf47093cf | 72 | led1 = !led1; |
| avilei | 0:872cf47093cf | 73 | wait(1); |
| avilei | 0:872cf47093cf | 74 | } |
| avilei | 0:872cf47093cf | 75 | } |
