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: sdp_k1_sdram
main.cpp@1:e8361ea27191, 2021-05-24 (annotated)
- Committer:
- Kjansen45
- Date:
- Mon May 24 09:14:55 2021 +0000
- Revision:
- 1:e8361ea27191
- Parent:
- 0:45d07bb483bf
Removing library
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| Kjansen45 | 0:45d07bb483bf | 1 | /* Copyright (c) 2019 Analog Devices, Inc. All rights reserved. | 
| Kjansen45 | 0:45d07bb483bf | 2 | |
| Kjansen45 | 0:45d07bb483bf | 3 | Redistribution and use in source and binary forms, with or without modification, | 
| Kjansen45 | 0:45d07bb483bf | 4 | are permitted provided that the following conditions are met: | 
| Kjansen45 | 0:45d07bb483bf | 5 | - Redistributions of source code must retain the above copyright notice, | 
| Kjansen45 | 0:45d07bb483bf | 6 | this list of conditions and the following disclaimer. | 
| Kjansen45 | 0:45d07bb483bf | 7 | - Redistributions in binary form must reproduce the above copyright notice, | 
| Kjansen45 | 0:45d07bb483bf | 8 | this list of conditions and the following disclaimer in the documentation | 
| Kjansen45 | 0:45d07bb483bf | 9 | and/or other materials provided with the distribution. | 
| Kjansen45 | 0:45d07bb483bf | 10 | - Modified versions of the software must be conspicuously marked as such. | 
| Kjansen45 | 0:45d07bb483bf | 11 | - This software is licensed solely and exclusively for use with processors/products | 
| Kjansen45 | 0:45d07bb483bf | 12 | manufactured by or for Analog Devices, Inc. | 
| Kjansen45 | 0:45d07bb483bf | 13 | - This software may not be combined or merged with other code in any manner | 
| Kjansen45 | 0:45d07bb483bf | 14 | that would cause the software to become subject to terms and conditions which | 
| Kjansen45 | 0:45d07bb483bf | 15 | differ from those listed here. | 
| Kjansen45 | 0:45d07bb483bf | 16 | - Neither the name of Analog Devices, Inc. nor the names of its contributors | 
| Kjansen45 | 0:45d07bb483bf | 17 | may be used to endorse or promote products derived from this software without | 
| Kjansen45 | 0:45d07bb483bf | 18 | specific prior written permission. | 
| Kjansen45 | 0:45d07bb483bf | 19 | - The use of this software may or may not infringe the patent rights of one or | 
| Kjansen45 | 0:45d07bb483bf | 20 | more patent holders. This license does not release you from the requirement | 
| Kjansen45 | 0:45d07bb483bf | 21 | that you obtain separate licenses from these patent holders to use this software. | 
| Kjansen45 | 0:45d07bb483bf | 22 | |
| Kjansen45 | 0:45d07bb483bf | 23 | THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND | 
| Kjansen45 | 0:45d07bb483bf | 24 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, | 
| Kjansen45 | 0:45d07bb483bf | 25 | TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | 
| Kjansen45 | 0:45d07bb483bf | 26 | NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | 
| Kjansen45 | 0:45d07bb483bf | 27 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES | 
| Kjansen45 | 0:45d07bb483bf | 28 | (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL | 
| Kjansen45 | 0:45d07bb483bf | 29 | PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | 
| Kjansen45 | 0:45d07bb483bf | 30 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
| Kjansen45 | 0:45d07bb483bf | 31 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 
| Kjansen45 | 0:45d07bb483bf | 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | 
| Kjansen45 | 0:45d07bb483bf | 33 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| Kjansen45 | 0:45d07bb483bf | 34 | |
| Kjansen45 | 0:45d07bb483bf | 35 | 2019-01-10-7CBSD SLA | 
| Kjansen45 | 0:45d07bb483bf | 36 | */ | 
| Kjansen45 | 0:45d07bb483bf | 37 | |
| Kjansen45 | 0:45d07bb483bf | 38 | #include "mbed.h" | 
| Kjansen45 | 0:45d07bb483bf | 39 | |
| Kjansen45 | 0:45d07bb483bf | 40 | // LED Blinking rate in milliseconds (Note: need to define the unit of a time duration i.e. seconds(s) or milliseconds(ms)) | 
| Kjansen45 | 0:45d07bb483bf | 41 | #define SLEEP_TIME 500ms | 
| Kjansen45 | 0:45d07bb483bf | 42 | |
| Kjansen45 | 0:45d07bb483bf | 43 | // Initialise the digital pin that controls LED1 | 
| Kjansen45 | 0:45d07bb483bf | 44 | DigitalOut led(LED1); | 
| Kjansen45 | 0:45d07bb483bf | 45 | // Initialise the serial object with TX and RX pins | 
| Kjansen45 | 0:45d07bb483bf | 46 | static BufferedSerial serial_port(USBTX, USBRX); | 
| Kjansen45 | 0:45d07bb483bf | 47 | |
| Kjansen45 | 0:45d07bb483bf | 48 | // The File handler is needed to allow printf commands to write to the terminal | 
| Kjansen45 | 0:45d07bb483bf | 49 | FileHandle *mbed::mbed_override_console(int fd) | 
| Kjansen45 | 0:45d07bb483bf | 50 | { | 
| Kjansen45 | 0:45d07bb483bf | 51 | return &serial_port; | 
| Kjansen45 | 0:45d07bb483bf | 52 | } | 
| Kjansen45 | 0:45d07bb483bf | 53 | |
| Kjansen45 | 0:45d07bb483bf | 54 | // main() runs in its own thread in the OS | 
| Kjansen45 | 0:45d07bb483bf | 55 | int main() | 
| Kjansen45 | 0:45d07bb483bf | 56 | { | 
| Kjansen45 | 0:45d07bb483bf | 57 | // printing the Mbed OS version this example was written to the console | 
| Kjansen45 | 0:45d07bb483bf | 58 | printf("This Application has been developed on Mbed OS version 6.4\r\n"); | 
| Kjansen45 | 0:45d07bb483bf | 59 | |
| Kjansen45 | 0:45d07bb483bf | 60 | // printing the actual Mbed OS version that this application is using to the console. | 
| Kjansen45 | 0:45d07bb483bf | 61 | printf( | 
| Kjansen45 | 0:45d07bb483bf | 62 | "Mbed OS version %d.%d.%d is what this applicaiton is currently using\r\n", | 
| Kjansen45 | 0:45d07bb483bf | 63 | MBED_MAJOR_VERSION, | 
| Kjansen45 | 0:45d07bb483bf | 64 | MBED_MINOR_VERSION, | 
| Kjansen45 | 0:45d07bb483bf | 65 | MBED_PATCH_VERSION | 
| Kjansen45 | 0:45d07bb483bf | 66 | ); | 
| Kjansen45 | 0:45d07bb483bf | 67 | |
| Kjansen45 | 0:45d07bb483bf | 68 | // The loop will toggle the LED every 500ms(SLEEP_TIME = 500ms) and print LED1s current state to the terminal | 
| Kjansen45 | 0:45d07bb483bf | 69 | while (1) { | 
| Kjansen45 | 0:45d07bb483bf | 70 | led = !led; // toggle LED1 state | 
| Kjansen45 | 0:45d07bb483bf | 71 | printf("LED1 state: %d \r\n", (uint8_t)led); | 
| Kjansen45 | 0:45d07bb483bf | 72 | ThisThread::sleep_for(SLEEP_TIME); | 
| Kjansen45 | 0:45d07bb483bf | 73 | } | 
| Kjansen45 | 0:45d07bb483bf | 74 | } | 
| Kjansen45 | 0:45d07bb483bf | 75 |