Example for Serial communication and LED Blinky

Fork of mbed-os-example-blinky by mbed-os-examples

Committer:
hyungo
Date:
Mon Oct 08 07:30:27 2018 +0000
Revision:
78:3937fde9c5d0
Parent:
77:9140e10d79ee
README.md Update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hyungo 77:9140e10d79ee 1 /* SDT-example-blinky
hyungo 77:9140e10d79ee 2 *
hyungo 77:9140e10d79ee 3 * Copyright (c) 2018 Sigma Delta Technologies Inc.
hyungo 77:9140e10d79ee 4 *
hyungo 77:9140e10d79ee 5 * MIT License
hyungo 77:9140e10d79ee 6 *
hyungo 77:9140e10d79ee 7 * Permission is hereby granted, free of charge, to any person
hyungo 77:9140e10d79ee 8 * obtaining a copy of this software and associated documentation
hyungo 77:9140e10d79ee 9 * files (the "Software"), to deal in the Software without
hyungo 77:9140e10d79ee 10 * restriction, including without limitation the rights to use,
hyungo 77:9140e10d79ee 11 * copy, modify, merge, publish, distribute, sublicense, and/or sell
hyungo 77:9140e10d79ee 12 * copies of the Software, and to permit persons to whom the
hyungo 77:9140e10d79ee 13 * Software is furnished to do so, subject to the following
hyungo 77:9140e10d79ee 14 * conditions:
hyungo 77:9140e10d79ee 15 *
hyungo 77:9140e10d79ee 16 * The above copyright notice and this permission notice shall be
hyungo 77:9140e10d79ee 17 * included in all copies or substantial portions of the Software.
hyungo 77:9140e10d79ee 18 *
hyungo 77:9140e10d79ee 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
hyungo 77:9140e10d79ee 20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
hyungo 77:9140e10d79ee 21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
hyungo 77:9140e10d79ee 22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
hyungo 77:9140e10d79ee 23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
hyungo 77:9140e10d79ee 24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
hyungo 77:9140e10d79ee 25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
hyungo 77:9140e10d79ee 26 * OTHER DEALINGS IN THE SOFTWARE.
hyungo 77:9140e10d79ee 27 */
hyungo 77:9140e10d79ee 28
Jonathan Austin 0:2757d7abb7d9 29 #include "mbed.h"
Jonathan Austin 0:2757d7abb7d9 30
hyungo 77:9140e10d79ee 31 /* Serial */
hyungo 77:9140e10d79ee 32 #define BAUDRATE 9600
hyungo 77:9140e10d79ee 33 Serial g_Serial_pc(USBTX, USBRX, BAUDRATE);
hyungo 77:9140e10d79ee 34
hyungo 77:9140e10d79ee 35 /* DigitalOut */
hyungo 77:9140e10d79ee 36 #define LED_ON 0
hyungo 77:9140e10d79ee 37 #define LED_OFF 1
hyungo 77:9140e10d79ee 38 DigitalOut g_DO_LedRed(LED_RED, LED_OFF);
hyungo 77:9140e10d79ee 39 DigitalOut g_DO_LedGreen(LED_GREEN, LED_OFF);
hyungo 77:9140e10d79ee 40 DigitalOut g_DO_LedBlue(LED_BLUE, LED_OFF);
Jonathan Austin 0:2757d7abb7d9 41
hyungo 77:9140e10d79ee 42 int main(void) {
hyungo 77:9140e10d79ee 43 g_Serial_pc.printf("< Sigma Delta Technologies Inc. >\n\r");
hyungo 77:9140e10d79ee 44
hyungo 77:9140e10d79ee 45 while(true) {
hyungo 77:9140e10d79ee 46 g_Serial_pc.printf("LED Toggle\n");
hyungo 77:9140e10d79ee 47 g_DO_LedBlue = !g_DO_LedBlue;
hyungo 77:9140e10d79ee 48 wait(1); // 1sec
Jonathan Austin 0:2757d7abb7d9 49 }
hyungo 77:9140e10d79ee 50
hyungo 77:9140e10d79ee 51 return 0;
Jonathan Austin 0:2757d7abb7d9 52 }