MBC003 - BusOut * This example use the BusOut function with a 7-Segment Display

Committer:
leandropg
Date:
Wed Jun 06 18:19:32 2018 +0000
Revision:
1:13bf93d687f3
Parent:
0:edeba2d48270
MBC003 - BusOut * This example use the BusOut function with a 7-Segment Display

Who changed what in which revision?

UserRevisionLine numberNew contents of line
leandropg 0:edeba2d48270 1 /**
leandropg 0:edeba2d48270 2 * MBC003 - BusOut
leandropg 1:13bf93d687f3 3 * This example use the BusOut function with a 7-Segment Display
leandropg 0:edeba2d48270 4 * 6 Jun 2018 - Mbed Colombia - http://mbedcolombia.wordpress.com/
leandropg 0:edeba2d48270 5 *
leandropg 0:edeba2d48270 6 * Board: ST-Nucleo-F446RE - https://os.mbed.com/platforms/ST-Nucleo-F446RE/
leandropg 0:edeba2d48270 7 *
leandropg 0:edeba2d48270 8 * Copyright [2018] [Leandro Perez Guatibonza / leandropg AT gmail DOT com]
leandropg 0:edeba2d48270 9 *
leandropg 0:edeba2d48270 10 * Licensed under the Apache License, Version 2.0 (the "License");
leandropg 0:edeba2d48270 11 * you may not use this file except in compliance with the License.
leandropg 0:edeba2d48270 12 * You may obtain a copy of the License at
leandropg 0:edeba2d48270 13 *
leandropg 0:edeba2d48270 14 * http://www.apache.org/licenses/LICENSE-2.0
leandropg 0:edeba2d48270 15 *
leandropg 0:edeba2d48270 16 * Unless required by applicable law or agreed to in writing, software
leandropg 0:edeba2d48270 17 * distributed under the License is distributed on an "AS IS" BASIS,
leandropg 0:edeba2d48270 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
leandropg 0:edeba2d48270 19 * See the License for the specific language governing permissions and
leandropg 0:edeba2d48270 20 * limitations under the License.
leandropg 0:edeba2d48270 21 */
leandropg 0:edeba2d48270 22 #include "mbed.h"
leandropg 0:edeba2d48270 23
leandropg 0:edeba2d48270 24 // Define GPIO Pins 7-Segment Display
leandropg 0:edeba2d48270 25 // PA_10 --> A
leandropg 0:edeba2d48270 26 // PB_3 --> B
leandropg 0:edeba2d48270 27 // PB_5 --> C
leandropg 0:edeba2d48270 28 // PB_4 --> D
leandropg 0:edeba2d48270 29 // PB_10 --> E
leandropg 0:edeba2d48270 30 // PA_8 --> F
leandropg 0:edeba2d48270 31 // PA_9 --> G
leandropg 0:edeba2d48270 32 BusOut display7Seg(PA_9, PA_8, PB_10, PB_4, PB_5, PB_3, PA_10);
leandropg 0:edeba2d48270 33
leandropg 0:edeba2d48270 34 // Define Logic Anode Comun Display
leandropg 0:edeba2d48270 35 // ABCDEFG
leandropg 0:edeba2d48270 36 int anodeComun[16] = { 0b0000001, // 0
leandropg 0:edeba2d48270 37 0b1001111, // 1
leandropg 0:edeba2d48270 38 0b0010010, // 2
leandropg 0:edeba2d48270 39 0b0000110, // 3
leandropg 0:edeba2d48270 40 0b1001100, // 4
leandropg 0:edeba2d48270 41 0b0100100, // 5
leandropg 0:edeba2d48270 42 0b0100000, // 6
leandropg 0:edeba2d48270 43 0b0001111, // 7
leandropg 0:edeba2d48270 44 0b0000000, // 8
leandropg 0:edeba2d48270 45 0b0001100, // 9
leandropg 0:edeba2d48270 46 0b0001000, // A
leandropg 0:edeba2d48270 47 0b1100000, // B
leandropg 0:edeba2d48270 48 0b1110010, // C
leandropg 0:edeba2d48270 49 0b1000010, // D
leandropg 0:edeba2d48270 50 0b0110000, // E
leandropg 0:edeba2d48270 51 0b0111000 }; // F
leandropg 0:edeba2d48270 52
leandropg 0:edeba2d48270 53 // Main Loop runs in its own thread in the OS
leandropg 0:edeba2d48270 54 int main() {
leandropg 0:edeba2d48270 55
leandropg 0:edeba2d48270 56 // Inifite Loop
leandropg 0:edeba2d48270 57 while(1) {
leandropg 0:edeba2d48270 58
leandropg 0:edeba2d48270 59 // Iterate 0x0 to 0xF -->
leandropg 0:edeba2d48270 60 for(int i = 0; i < 16; i++) {
leandropg 0:edeba2d48270 61
leandropg 0:edeba2d48270 62 // Export data to Bus
leandropg 0:edeba2d48270 63 display7Seg = anodeComun[i];
leandropg 0:edeba2d48270 64
leandropg 0:edeba2d48270 65 // Wait 500 millisecond
leandropg 0:edeba2d48270 66 wait_ms(500);
leandropg 0:edeba2d48270 67 }
leandropg 0:edeba2d48270 68 }
leandropg 0:edeba2d48270 69 }