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