Linking but does not give binary - Error L6320W

Dependencies:   mbed wave_player SDFileSystem PinDetect

Committer:
hcharan
Date:
Sun Aug 11 09:41:33 2019 +0000
Revision:
0:69e13b99ec01
Linking but not giving binary, error L6320W

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hcharan 0:69e13b99ec01 1 #include "mbed.h"
hcharan 0:69e13b99ec01 2 #include "SDFileSystem.h"
hcharan 0:69e13b99ec01 3 #include "wave_player.h"
hcharan 0:69e13b99ec01 4 #include "PinDetect.h"
hcharan 0:69e13b99ec01 5 #include <vector>
hcharan 0:69e13b99ec01 6 #include <string>
hcharan 0:69e13b99ec01 7
hcharan 0:69e13b99ec01 8 #define UP PC_13
hcharan 0:69e13b99ec01 9 #define DOWN PB_1
hcharan 0:69e13b99ec01 10 #define BACK PB_5
hcharan 0:69e13b99ec01 11 #define MENU PB_2
hcharan 0:69e13b99ec01 12 #define SELECT PB_9
hcharan 0:69e13b99ec01 13 #define VOLUP PB_7
hcharan 0:69e13b99ec01 14 #define VOLDOWN PB_6
hcharan 0:69e13b99ec01 15
hcharan 0:69e13b99ec01 16 #define LONG_PRESS_TIME 80 //Value * 20ms = debounce time
hcharan 0:69e13b99ec01 17 #define SHORT_PRESS_TIME 5 //Value * 20ms = debounce time
hcharan 0:69e13b99ec01 18
hcharan 0:69e13b99ec01 19 using namespace std;
hcharan 0:69e13b99ec01 20
hcharan 0:69e13b99ec01 21 SDFileSystem sd(PB_15, PB_14, PB_13, PB_12, "TEST");
hcharan 0:69e13b99ec01 22
hcharan 0:69e13b99ec01 23 PinDetect up(UP, PullUp);
hcharan 0:69e13b99ec01 24 PinDetect down(DOWN, PullUp);
hcharan 0:69e13b99ec01 25 PinDetect back(BACK, PullUp);
hcharan 0:69e13b99ec01 26 PinDetect menu(MENU, PullUp);
hcharan 0:69e13b99ec01 27 PinDetect select(SELECT, PullUp);
hcharan 0:69e13b99ec01 28 PinDetect volup(VOLUP, PullUp);
hcharan 0:69e13b99ec01 29 PinDetect voldown(VOLDOWN, PullUp);
hcharan 0:69e13b99ec01 30 bool buttonStatus = 0;
hcharan 0:69e13b99ec01 31
hcharan 0:69e13b99ec01 32 AnalogOut DACout(PA_4);
hcharan 0:69e13b99ec01 33 wave_player waver(&DACout);
hcharan 0:69e13b99ec01 34 int pos = 0; // index of the song
hcharan 0:69e13b99ec01 35 int vol = 0; // volume controller
hcharan 0:69e13b99ec01 36
hcharan 0:69e13b99ec01 37 bool playing = false; //variable for pause/play since we only have 1 pb for that
hcharan 0:69e13b99ec01 38 vector<string> filenames; //filenames are stored in a vector string
hcharan 0:69e13b99ec01 39
hcharan 0:69e13b99ec01 40 void read_file_names(char *dir) // function that reads in file names from sd cards
hcharan 0:69e13b99ec01 41 {
hcharan 0:69e13b99ec01 42 DIR *dp;
hcharan 0:69e13b99ec01 43 struct dirent *dirp;
hcharan 0:69e13b99ec01 44 dp = opendir(dir);
hcharan 0:69e13b99ec01 45 //read all directory and file names in current directory into filename vector
hcharan 0:69e13b99ec01 46 while((dirp = readdir(dp)) != NULL) {
hcharan 0:69e13b99ec01 47 filenames.push_back(string(dirp->d_name));
hcharan 0:69e13b99ec01 48 }
hcharan 0:69e13b99ec01 49 }
hcharan 0:69e13b99ec01 50
hcharan 0:69e13b99ec01 51 void upPressedCallback(void){
hcharan 0:69e13b99ec01 52 //printf("\nUP Pressed\n");
hcharan 0:69e13b99ec01 53
hcharan 0:69e13b99ec01 54 int l = filenames.size();
hcharan 0:69e13b99ec01 55 if (pos > 0) {
hcharan 0:69e13b99ec01 56 pos--;
hcharan 0:69e13b99ec01 57 } else if (pos == 0 ) {
hcharan 0:69e13b99ec01 58 pos = l-1;
hcharan 0:69e13b99ec01 59 }
hcharan 0:69e13b99ec01 60
hcharan 0:69e13b99ec01 61 }
hcharan 0:69e13b99ec01 62 void upHeldCallback(void){
hcharan 0:69e13b99ec01 63 printf("\nUP Held\n");
hcharan 0:69e13b99ec01 64 }
hcharan 0:69e13b99ec01 65
hcharan 0:69e13b99ec01 66 void downPressedCallback(void){
hcharan 0:69e13b99ec01 67 //printf("\ndown Pressed\n");
hcharan 0:69e13b99ec01 68 // it checks for the total number of songs in the sd card..then increments the index until it reaches the last one, then resets to 0
hcharan 0:69e13b99ec01 69
hcharan 0:69e13b99ec01 70 int l = filenames.size();
hcharan 0:69e13b99ec01 71 if (pos < (l-1)) {
hcharan 0:69e13b99ec01 72 pos++;
hcharan 0:69e13b99ec01 73 } else if (pos == (l-1)) {
hcharan 0:69e13b99ec01 74 pos = 0;
hcharan 0:69e13b99ec01 75 }
hcharan 0:69e13b99ec01 76
hcharan 0:69e13b99ec01 77 }
hcharan 0:69e13b99ec01 78 void downHeldCallback(void){
hcharan 0:69e13b99ec01 79 printf("\ndown Held\n");
hcharan 0:69e13b99ec01 80 }
hcharan 0:69e13b99ec01 81
hcharan 0:69e13b99ec01 82 void backPressedCallback(void){
hcharan 0:69e13b99ec01 83 printf("\nback Pressed\n");
hcharan 0:69e13b99ec01 84 }
hcharan 0:69e13b99ec01 85 void backHeldCallback(void){
hcharan 0:69e13b99ec01 86 printf("\nback Held\n");
hcharan 0:69e13b99ec01 87 }
hcharan 0:69e13b99ec01 88
hcharan 0:69e13b99ec01 89 void menuPressedCallback(void){
hcharan 0:69e13b99ec01 90 //printf("\nmenu Pressed\n");
hcharan 0:69e13b99ec01 91
hcharan 0:69e13b99ec01 92 //this interrupt handler changes the play to pause mode or vice versa
hcharan 0:69e13b99ec01 93 //this is done using the boolean playing
hcharan 0:69e13b99ec01 94
hcharan 0:69e13b99ec01 95 if (playing == false) {
hcharan 0:69e13b99ec01 96 playing = true;
hcharan 0:69e13b99ec01 97 } else if (playing == true) {
hcharan 0:69e13b99ec01 98 playing = false;
hcharan 0:69e13b99ec01 99 }
hcharan 0:69e13b99ec01 100
hcharan 0:69e13b99ec01 101 }
hcharan 0:69e13b99ec01 102 void menuHeldCallback(void){
hcharan 0:69e13b99ec01 103 //printf("\nmenu Held\n");
hcharan 0:69e13b99ec01 104 }
hcharan 0:69e13b99ec01 105
hcharan 0:69e13b99ec01 106 void volupPressedCallback(void){
hcharan 0:69e13b99ec01 107 printf("\nvolup Pressed\n");
hcharan 0:69e13b99ec01 108 }
hcharan 0:69e13b99ec01 109 void volupHeldCallback(void){
hcharan 0:69e13b99ec01 110 printf("\nvolup Held\n");
hcharan 0:69e13b99ec01 111 }
hcharan 0:69e13b99ec01 112
hcharan 0:69e13b99ec01 113 void voldownPressedCallback(void){
hcharan 0:69e13b99ec01 114 //printf("\nvoldown Pressed\n");
hcharan 0:69e13b99ec01 115 // this pb changes the volume by lowering the volume until it reaches 0. then it resets to the max volume
hcharan 0:69e13b99ec01 116 // the volume range has been divided into 16 possible ranges. and hence, it toggles through those 16 values
hcharan 0:69e13b99ec01 117 // this only changes the variable vol, which is then used in the wave player file to actually adjust the volume
hcharan 0:69e13b99ec01 118 vol = (vol+1) % 16;
hcharan 0:69e13b99ec01 119 }
hcharan 0:69e13b99ec01 120 void voldownHeldCallback(void){
hcharan 0:69e13b99ec01 121 printf("\nvoldown Held\n");
hcharan 0:69e13b99ec01 122 }
hcharan 0:69e13b99ec01 123
hcharan 0:69e13b99ec01 124 bool buttons_init(void) {
hcharan 0:69e13b99ec01 125 up.attach_deasserted( &upPressedCallback );
hcharan 0:69e13b99ec01 126 //up.attach_deasserted( &upReleasedCallback );
hcharan 0:69e13b99ec01 127 up.attach_asserted_held( &upHeldCallback );
hcharan 0:69e13b99ec01 128 up.setSamplesTillAssert( SHORT_PRESS_TIME );
hcharan 0:69e13b99ec01 129 up.setSamplesTillHeld( LONG_PRESS_TIME );
hcharan 0:69e13b99ec01 130 up.setAssertValue( 0 );
hcharan 0:69e13b99ec01 131 up.setSampleFrequency();
hcharan 0:69e13b99ec01 132 //up.fall(callback(this, &upCallback));
hcharan 0:69e13b99ec01 133
hcharan 0:69e13b99ec01 134 down.attach_deasserted( &downPressedCallback );
hcharan 0:69e13b99ec01 135 //down.attach_deasserted( &downReleasedCallback );
hcharan 0:69e13b99ec01 136 down.attach_asserted_held( &downHeldCallback );
hcharan 0:69e13b99ec01 137 down.setSamplesTillAssert( SHORT_PRESS_TIME );
hcharan 0:69e13b99ec01 138 down.setSamplesTillHeld( LONG_PRESS_TIME );
hcharan 0:69e13b99ec01 139 down.setAssertValue( 0 );
hcharan 0:69e13b99ec01 140 down.setSampleFrequency();
hcharan 0:69e13b99ec01 141
hcharan 0:69e13b99ec01 142 back.attach_deasserted( &backPressedCallback );
hcharan 0:69e13b99ec01 143 //back.attach_deasserted( &backReleasedCallback );
hcharan 0:69e13b99ec01 144 back.attach_asserted_held( &backHeldCallback );
hcharan 0:69e13b99ec01 145 back.setSamplesTillAssert( SHORT_PRESS_TIME );
hcharan 0:69e13b99ec01 146 back.setSamplesTillHeld( LONG_PRESS_TIME );
hcharan 0:69e13b99ec01 147 back.setAssertValue( 0 );
hcharan 0:69e13b99ec01 148 back.setSampleFrequency();
hcharan 0:69e13b99ec01 149
hcharan 0:69e13b99ec01 150 menu.attach_deasserted( &menuPressedCallback );
hcharan 0:69e13b99ec01 151 //menu.attach_deasserted( &menuReleasedCallback );
hcharan 0:69e13b99ec01 152 menu.attach_asserted_held( &menuHeldCallback );
hcharan 0:69e13b99ec01 153 menu.setSamplesTillAssert( SHORT_PRESS_TIME );
hcharan 0:69e13b99ec01 154 menu.setSamplesTillHeld( LONG_PRESS_TIME );
hcharan 0:69e13b99ec01 155 menu.setAssertValue( 0 );
hcharan 0:69e13b99ec01 156 menu.setSampleFrequency();
hcharan 0:69e13b99ec01 157
hcharan 0:69e13b99ec01 158 volup.attach_deasserted( &volupPressedCallback );
hcharan 0:69e13b99ec01 159 //volup.attach_deasserted( &volupReleasedCallback );
hcharan 0:69e13b99ec01 160 volup.attach_asserted_held( &volupHeldCallback );
hcharan 0:69e13b99ec01 161 volup.setSamplesTillAssert( SHORT_PRESS_TIME );
hcharan 0:69e13b99ec01 162 volup.setSamplesTillHeld( LONG_PRESS_TIME );
hcharan 0:69e13b99ec01 163 volup.setAssertValue( 0 );
hcharan 0:69e13b99ec01 164 volup.setSampleFrequency();
hcharan 0:69e13b99ec01 165
hcharan 0:69e13b99ec01 166 voldown.attach_deasserted( &voldownPressedCallback );
hcharan 0:69e13b99ec01 167 //voldown.attach_deasserted( &voldownReleasedCallback );
hcharan 0:69e13b99ec01 168 voldown.attach_asserted_held( &voldownHeldCallback );
hcharan 0:69e13b99ec01 169 voldown.setSamplesTillAssert( SHORT_PRESS_TIME );
hcharan 0:69e13b99ec01 170 voldown.setSamplesTillHeld( LONG_PRESS_TIME );
hcharan 0:69e13b99ec01 171 voldown.setAssertValue( 0 );
hcharan 0:69e13b99ec01 172 voldown.setSampleFrequency();
hcharan 0:69e13b99ec01 173
hcharan 0:69e13b99ec01 174 /*
hcharan 0:69e13b99ec01 175 down.fall(callback(&downCallback));
hcharan 0:69e13b99ec01 176 back.fall(callback(&backCallback));
hcharan 0:69e13b99ec01 177 menu.fall(callback(&menuCallback));
hcharan 0:69e13b99ec01 178 select.fall(callback(&selectCallback));
hcharan 0:69e13b99ec01 179 volup.fall(callback(&volupCallback));
hcharan 0:69e13b99ec01 180 voldown.fall(callback(&voldownCallback));
hcharan 0:69e13b99ec01 181 */
hcharan 0:69e13b99ec01 182
hcharan 0:69e13b99ec01 183 printf("\nButtons Initialized\n");
hcharan 0:69e13b99ec01 184 return 1;
hcharan 0:69e13b99ec01 185 }
hcharan 0:69e13b99ec01 186
hcharan 0:69e13b99ec01 187 int main()
hcharan 0:69e13b99ec01 188 {
hcharan 0:69e13b99ec01 189 printf("\n\n\nHello, wave world =======!\n");
hcharan 0:69e13b99ec01 190 buttonStatus = buttons_init();
hcharan 0:69e13b99ec01 191 read_file_names("/TEST/Music");
hcharan 0:69e13b99ec01 192
hcharan 0:69e13b99ec01 193 /*
hcharan 0:69e13b99ec01 194 //FILE *wave_file;
hcharan 0:69e13b99ec01 195 //wave_file=fopen("/TEST/queen.wav","r");
hcharan 0:69e13b99ec01 196 //wave_player waver(&DACout, wave_file);
hcharan 0:69e13b99ec01 197 //waver.play();
hcharan 0:69e13b99ec01 198
hcharan 0:69e13b99ec01 199 wave_file=fopen("/TEST/queen.wav","r");
hcharan 0:69e13b99ec01 200 waver.play();
hcharan 0:69e13b99ec01 201 fclose(wave_file);
hcharan 0:69e13b99ec01 202 */
hcharan 0:69e13b99ec01 203
hcharan 0:69e13b99ec01 204 while(1) {
hcharan 0:69e13b99ec01 205 //while pb3 is low, then we can start playing the song
hcharan 0:69e13b99ec01 206 while(playing == true) { //we have 2 while loops..one while loop makes sure the music player is always on, the other one is for the song
hcharan 0:69e13b99ec01 207 string songname = filenames[pos];
hcharan 0:69e13b99ec01 208 string a = "/TEST/";
hcharan 0:69e13b99ec01 209 string fname = a + songname; //retrieves the file name
hcharan 0:69e13b99ec01 210 FILE *wave_file;
hcharan 0:69e13b99ec01 211 wave_file = fopen(fname.c_str(),"r"); //opens the music file
hcharan 0:69e13b99ec01 212 waver.play(wave_file); //plays the music file
hcharan 0:69e13b99ec01 213 fclose(wave_file);
hcharan 0:69e13b99ec01 214 }
hcharan 0:69e13b99ec01 215 }
hcharan 0:69e13b99ec01 216
hcharan 0:69e13b99ec01 217 }
hcharan 0:69e13b99ec01 218