project for 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
kblake9
Date:
Tue Nov 24 08:35:47 2020 +0000
Revision:
3:9dde875cd65c
Parent:
2:4947d6a82971
Child:
4:b687219ae447
Started

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DCchico 2:4947d6a82971 1 // Copyright 2020 Georgia Tech. All rights reserved.
DCchico 2:4947d6a82971 2 // The materials provided by the instructor in this course are for
DCchico 2:4947d6a82971 3 // the use of the students currently enrolled in the course.
DCchico 2:4947d6a82971 4 // Copyrighted course materials may not be further disseminated.
DCchico 2:4947d6a82971 5 // This file must not be made publicly available anywhere.
DCchico 2:4947d6a82971 6
DCchico 1:10330bce85cb 7 // This header has all the (extern) declarations of the globals.
DCchico 1:10330bce85cb 8 // "extern" means "this is instantiated somewhere, but here's what the name
DCchico 1:10330bce85cb 9 // means.
DCchico 1:10330bce85cb 10 #include "globals.h"
DCchico 1:10330bce85cb 11
DCchico 1:10330bce85cb 12 #include "hardware.h"
DCchico 1:10330bce85cb 13
DCchico 1:10330bce85cb 14 // We need to actually instantiate all of the globals (i.e. declare them once
DCchico 1:10330bce85cb 15 // without the extern keyword). That's what this file does!
DCchico 1:10330bce85cb 16
DCchico 1:10330bce85cb 17 // Hardware initialization: Instantiate all the things!
DCchico 1:10330bce85cb 18 uLCD_4DGL uLCD(p9,p10,p11); // LCD Screen (tx, rx, reset)
kblake9 3:9dde875cd65c 19 SDFileSystem sd(p5, p6, p7, p8, "sd"); // SD Card(mosi, miso, sck, cs)
DCchico 1:10330bce85cb 20 Serial pc(USBTX,USBRX); // USB Console (tx, rx)
kblake9 3:9dde875cd65c 21 MMA8452 acc(p28, p27, 100000); // Accelerometer (sda, sdc, rate)
DCchico 1:10330bce85cb 22 DigitalIn button1(p21); // Pushbuttons (pin)
DCchico 1:10330bce85cb 23 DigitalIn button2(p22);
DCchico 1:10330bce85cb 24 DigitalIn button3(p23);
DCchico 1:10330bce85cb 25 AnalogOut DACout(p18); // Speaker (pin)
DCchico 1:10330bce85cb 26 PwmOut speaker(p26);
DCchico 1:10330bce85cb 27 wave_player waver(&DACout);
DCchico 1:10330bce85cb 28
DCchico 1:10330bce85cb 29
DCchico 1:10330bce85cb 30 // Some hardware also needs to have functions called before it will set up
DCchico 1:10330bce85cb 31 // properly. Do that here.
DCchico 1:10330bce85cb 32 int hardware_init()
DCchico 1:10330bce85cb 33 {
DCchico 1:10330bce85cb 34 // Crank up the speed
DCchico 1:10330bce85cb 35 uLCD.baudrate(3000000);
DCchico 1:10330bce85cb 36 pc.baud(115200);
DCchico 1:10330bce85cb 37
DCchico 1:10330bce85cb 38 //Initialize pushbuttons
DCchico 1:10330bce85cb 39 button1.mode(PullUp);
DCchico 1:10330bce85cb 40 button2.mode(PullUp);
DCchico 1:10330bce85cb 41 button3.mode(PullUp);
DCchico 1:10330bce85cb 42
kblake9 3:9dde875cd65c 43 //Initialize accelerometer
kblake9 3:9dde875cd65c 44 accel.init();
kblake9 3:9dde875cd65c 45
DCchico 1:10330bce85cb 46 return ERROR_NONE;
DCchico 1:10330bce85cb 47 }
DCchico 1:10330bce85cb 48
DCchico 2:4947d6a82971 49 // Implement this function.
DCchico 2:4947d6a82971 50 // HINT: lookup your accelerometer under mbed site > Hardware> Components
DCchico 2:4947d6a82971 51 // and look at demo code
DCchico 1:10330bce85cb 52 GameInputs read_inputs()
DCchico 1:10330bce85cb 53 {
DCchico 1:10330bce85cb 54 GameInputs in;
DCchico 1:10330bce85cb 55 return in;
DCchico 1:10330bce85cb 56 }