Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
hardware.cpp
00001 // This header has all the (extern) declarations of the globals. 00002 // "extern" means "this is instantiated somewhere, but here's what the name 00003 // means. 00004 #include "globals.h" 00005 #include "hardware.h" 00006 00007 // We need to actually instantiate all of the globals (i.e. declare them once 00008 // without the extern keyword). That's what this file does! 00009 00010 // Hardware initialization: Instantiate all the things! 00011 //uLCD_4DGL uLCD(p9,p10,p11); // LCD Screen (tx, rx, reset) 00012 //SDFileSystem sd(p5, p6, p7, p8, "sd"); // SD Card(mosi, miso, sck, cs) 00013 Serial pc(USBTX,USBRX); // USB Console (tx, rx) 00014 //MMA8452 acc(p28, p27, 100000); // Accelerometer (sda, sdc, rate) 00015 DigitalIn button1(p8); // Pushbuttons (pin) 00016 //DigitalIn button2(p22); 00017 //DigitalIn button3(p23); 00018 //DigitalIn button4(p24); 00019 AnalogOut DACout(p18); // Speaker (pin) 00020 PwmOut speaker(p26); 00021 //wave_player waver(&DACout); 00022 00023 00024 // Some hardware also needs to have functions called before it will set up 00025 // properly. Do that here. 00026 int hardware_init() 00027 { 00028 // Crank up the speed 00029 //uLCD.baudrate(1500000); 00030 pc.baud(115200); 00031 00032 //Initialize pushbuttons 00033 button1.mode(PullUp); 00034 //button2.mode(PullUp); 00035 //button3.mode(PullUp); 00036 //button4.mode(PullUp); 00037 00038 // initialize the accelerometer 00039 // acc.activate(); 00040 00041 return ERROR_NONE; 00042 } 00043 00044 UserInputs read_inputs() 00045 { 00046 UserInputs inputs; // creates the struct for the game inputs 00047 00048 inputs.b1 = button1.read(); // give a value to button 1 00049 //inputs.b2 = button2; // give a value to button 2 00050 //inputs.b3 = button3; // give a value to button 3 00051 //inputs.b4 = button4; // give a value to button 4 00052 00053 /*acc.readXGravity(&inputs.ax); // give a value to x axis 00054 acc.readYGravity(&inputs.ay); // give a value to y axis 00055 acc.readZGravity(&inputs.az); // give a value to z axis 00056 */ 00057 return inputs; 00058 } 00059
Generated on Thu Sep 1 2022 20:44:59 by
1.7.2