PortInOut Hello World

Dependencies:   mbed

Fork of PortInOut_HelloWorld by Mbed

Note

Depending on your board your ports may be named as numbers or as letters. For example the NXP boards have Port1, Port2, Port3...etc but the Freescale boards have PortA, PortB, PortC, PortD. Please refer to the boards Platform page to find out which one your board uses.

API

API reference.

Import librarymbed

No documentation found.
Committer:
mbedAustin
Date:
Fri Mar 27 20:15:17 2015 +0000
Revision:
2:3f1944b9de6a
Parent:
0:018ca8a43b33
Added license to main.c file.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 2:3f1944b9de6a 1 /* mbed Example Program
mbedAustin 2:3f1944b9de6a 2 * Copyright (c) 2006-2014 ARM Limited
mbedAustin 2:3f1944b9de6a 3 *
mbedAustin 2:3f1944b9de6a 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbedAustin 2:3f1944b9de6a 5 * you may not use this file except in compliance with the License.
mbedAustin 2:3f1944b9de6a 6 * You may obtain a copy of the License at
mbedAustin 2:3f1944b9de6a 7 *
mbedAustin 2:3f1944b9de6a 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 2:3f1944b9de6a 9 *
mbedAustin 2:3f1944b9de6a 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 2:3f1944b9de6a 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbedAustin 2:3f1944b9de6a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 2:3f1944b9de6a 13 * See the License for the specific language governing permissions and
mbedAustin 2:3f1944b9de6a 14 * limitations under the License.
mbedAustin 2:3f1944b9de6a 15 */
mbedAustin 2:3f1944b9de6a 16
mbedAustin 2:3f1944b9de6a 17
mbed_official 0:018ca8a43b33 18 // Toggle all four LEDs
mbed_official 0:018ca8a43b33 19
mbed_official 0:018ca8a43b33 20 #include "mbed.h"
mbed_official 0:018ca8a43b33 21
mbed_official 0:018ca8a43b33 22 // LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23
mbed_official 0:018ca8a43b33 23 #define LED_MASK 0x00B40000
mbed_official 0:018ca8a43b33 24
mbed_official 0:018ca8a43b33 25 PortInOut ledport(Port1, LED_MASK);
mbed_official 0:018ca8a43b33 26
mbed_official 0:018ca8a43b33 27 int main() {
mbed_official 0:018ca8a43b33 28 int v = ledport;
mbed_official 0:018ca8a43b33 29 ledport.output();
mbed_official 0:018ca8a43b33 30 while(1) {
mbed_official 0:018ca8a43b33 31 ledport = LED_MASK;
mbed_official 0:018ca8a43b33 32 wait(0.5);
mbed_official 0:018ca8a43b33 33 ledport = 0;
mbed_official 0:018ca8a43b33 34 wait(1);
mbed_official 0:018ca8a43b33 35 }
mbed_official 0:018ca8a43b33 36 }